Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
Argent77 committed Apr 1, 2020
2 parents 65582d3 + 9a9b5fc commit 2687ea6
Show file tree
Hide file tree
Showing 302 changed files with 16,726 additions and 15,482 deletions.
File renamed without changes.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/b5d10ca2684c4e30b6632e34584f1241)](https://www.codacy.com/manual/Mingun/NearInfinity)

# Near Infinity

A file browser and editor for the Infinity Engine. You can find out more in
A file browser and editor for the Infinity Engine. You can find out more in
the [Near Infinity Wiki](https://github.com/NearInfinityBrowser/NearInfinity/wiki).

## How to build Near Infinity
Expand All @@ -9,7 +11,7 @@ the [Near Infinity Wiki](https://github.com/NearInfinityBrowser/NearInfinity/wik
- [Java SE Development Kit 8 or higher](http://www.oracle.com/technetwork/java/javase/downloads/index.html)
- [Apache Ant](http://ant.apache.org/)

If you wish to compile Near Infinity from source, the easiest way to do so is
If you wish to compile Near Infinity from source, the easiest way to do so is
by using the included Ant build script. The default target builds the `NearInfinity.jar`.

```bash
Expand All @@ -22,7 +24,7 @@ It is preferred to use `Apache Ant` for compiling Near Infinity, however.

### Recreate parse tree

NI's BCS compiler uses code that is generated by the parser generator JavaCC. The file `src/org/infinity/resource/bcs/parser/BafParser.jjt` is used to build the parse tree.
NI's BCS compiler uses code that is generated by the parser generator JavaCC. The file `src/org/infinity/resource/bcs/parser/BafParser.jjt` is used to build the parse tree.
Use the following commands if you need to recreate it:

```bash
Expand All @@ -35,7 +37,7 @@ The JavaCC executable is already included in the Near Infinity sources.

### Unit Tests

The unit tests (that currently have far from complete coverage) can be run by
The unit tests (that currently have far from complete coverage) can be run by
passing `test` as the target parameter to ant:

```bash
Expand Down Expand Up @@ -111,7 +113,7 @@ The branch `gh-pages` is primarily used for hosting the update definition
file which is used to notify users when a new Near Infinity version has been
released.

Other branches, if any, are either used for testing purposes or are not
Other branches, if any, are either used for testing purposes or are not
actively maintained anymore.

### Specifics
Expand Down
9 changes: 8 additions & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,14 @@
debug="false"
debuglevel="lines,vars,source"
classpath="${classpath}:${jorbis.file}:${rsyntaxtextarea.file}:${jhexview.file}:${montemedia.file}">
<!--<compilerarg value="-Xlint:unchecked"/>-->
<!-- Various debugging options: -->
<!-- <compilerarg value="-Xlint:cast"/> -->
<!-- <compilerarg value="-Xlint:deprecation"/> -->
<!-- <compilerarg value="-Xlint:empty"/> -->
<!-- <compilerarg value="-Xlint:finally"/> -->
<!-- <compilerarg value="-Xlint:overrides"/> -->
<!-- <compilerarg value="-Xlint:path"/> -->
<compilerarg value="-Xlint:unchecked"/>
</javac>

<copy todir="${build.path}">
Expand Down
Binary file removed lib/jhexview/jhexview-current.zip
Binary file not shown.
6 changes: 4 additions & 2 deletions lib/jhexview/readme.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
JHexView component by Sebastian Porst ([email protected]), modified by Argent77

Official website: https://github.com/sporst/JHexView
Modified source: https://github.com/Argent77/NearInfinity/tree/devel/lib/jhexview
JHexView for Near Infinity: https://github.com/NearInfinityBrowser/JHexView
License: GPL 2.0

JHexView is a Java component for displaying binary data in Java applications
Expand All @@ -26,7 +26,9 @@ Features:
external source
- Full control over the display colors

Added by argent77:
Changes by Argent77:
- Included dependencies (splib)
- Added Apache Ant build script
- Find bytes/text support
- Copy/paste support
- Undo/redo support
504 changes: 504 additions & 0 deletions src/org/infinity/LICENSE.txt

Large diffs are not rendered by default.

22 changes: 17 additions & 5 deletions src/org/infinity/NearInfinity.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Near Infinity - An Infinity Engine Browser and Editor
// Copyright (C) 2001 - 2005 Jon Olav Hauglid
// Copyright (C) 2001 - 2018 Jon Olav Hauglid
// See LICENSE.txt for license information

package org.infinity;
Expand All @@ -12,6 +12,7 @@
import java.awt.Frame;
import java.awt.Image;
import java.awt.Insets;
import java.awt.KeyboardFocusManager;
import java.awt.Toolkit;
import java.awt.datatransfer.DataFlavor;
import java.awt.dnd.DnDConstants;
Expand Down Expand Up @@ -289,10 +290,12 @@ private NearInfinity(Path gameOverride, Profile.Game forcedGame)
globalFontSize = Math.max(50, Math.min(400, prefs.getInt(OPTION_GLOBAL_FONT_SIZE, 100)));
resizeUIFont(globalFontSize);

new BrowserMenuBar();
setJMenuBar(BrowserMenuBar.getInstance());
final BrowserMenuBar menu = new BrowserMenuBar();
// Registers menu as key event dispatcher to intercept Ctrl+Shift+D from any window
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(menu);
setJMenuBar(menu);

String lastDir = null;
final String lastDir;
if (gameOverride != null && Files.isDirectory(gameOverride)) {
lastDir = gameOverride.toString();
} else {
Expand Down Expand Up @@ -538,6 +541,15 @@ public void actionPerformed(ActionEvent event)
editGameIni(this);
} else if (event.getActionCommand().equals("Refresh")) {
refreshGame();
} else if (event.getActionCommand().equals("RefreshTree")) {
try {
WindowBlocker.blockWindow(this, true);
tree.reloadRenderer();
tree.repaint();
tree.requestFocusInWindow();
} finally {
WindowBlocker.blockWindow(this, false);
}
} else if (event.getActionCommand().equals("ChangeLook")) {
try {
LookAndFeelInfo info = BrowserMenuBar.getInstance().getLookAndFeel();
Expand Down Expand Up @@ -887,6 +899,7 @@ private static void resizeUIFont(int percent)
UIManager.put(key, new FontUIResource(f));
}
}
consoletext.setFont(Misc.getScaledFont(consoletext.getFont()));
}

private void storePreferences()
Expand Down Expand Up @@ -1108,4 +1121,3 @@ public void run()
}
}
}

103 changes: 103 additions & 0 deletions src/org/infinity/check/AbstractChecker.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// Near Infinity - An Infinity Engine Browser and Editor
// Copyright (C) 2001 - 2018 Jon Olav Hauglid
// See LICENSE.txt for license information

package org.infinity.check;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import org.infinity.NearInfinity;
import org.infinity.gui.Center;
import org.infinity.gui.ChildFrame;
import org.infinity.icon.Icons;
import org.infinity.resource.key.ResourceEntry;
import org.infinity.search.AbstractSearcher;
import org.infinity.search.FileTypeSelector;

/**
* Base class for selectiong files for check and runs checks in multithreaded mode.
*
* @author Mingun
*/
public abstract class AbstractChecker extends AbstractSearcher implements ActionListener, Runnable
{
/** The window with checkboxes allowing to configure operation settings before its start. */
private final ChildFrame settingsWindow;
/** Selector of file types in which search must be performed. */
private final FileTypeSelector selector;
/** Button that begins check with specified settings. */
private final JButton bStart = new JButton("Check", Icons.getIcon(Icons.ICON_FIND_16));
/** Button that closes start check dialog. */
private final JButton bCancel = new JButton("Cancel", Icons.getIcon(Icons.ICON_DELETE_16));

/** Key used to save and restore checkbox selection. */
private final String key;
/** Resources, selected for check. */
protected List<ResourceEntry> files;

public AbstractChecker(String title, String key, String[] filetypes)
{
super(CHECK_MULTI_TYPE_FORMAT, NearInfinity.getInstance());
settingsWindow = new ChildFrame(title, true);
settingsWindow.setIconImage(Icons.getIcon(Icons.ICON_REFRESH_16).getImage());
this.key = key;
selector = new FileTypeSelector("Select files to check:", key, filetypes, null);

final JPanel bpanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
bpanel.add(bStart);
bpanel.add(bCancel);

final JPanel pane = (JPanel)settingsWindow.getContentPane();
pane.setLayout(new BorderLayout());
pane.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
pane.add(selector, BorderLayout.CENTER);
pane.add(bpanel, BorderLayout.SOUTH);

bStart.setMnemonic('s');
bCancel.setMnemonic('c');
bStart.addActionListener(this);
bCancel.addActionListener(this);
settingsWindow.getRootPane().setDefaultButton(bStart);

settingsWindow.pack();
Center.center(settingsWindow, NearInfinity.getInstance().getBounds());
settingsWindow.setVisible(true);
}

/**
* Runs check that {@link #newWorker spawns} working items that performs actual
* checking.
*
* @param entries Entries for check. Any {@code null} values will be ignored,
* any other will be checked in several threads
*
* @return {@code true}, if check cancelled, {@code false} otherwise
*/
protected boolean runCheck(List<ResourceEntry> entries)
{
return runSearch("Checking", entries);
}

//<editor-fold defaultstate="collapsed" desc="ActionListener">
@Override
public void actionPerformed(ActionEvent event)
{
if (event.getSource() == bStart) {
settingsWindow.setVisible(false);
files = selector.getResources(key);
if (!files.isEmpty()) {
new Thread(this).start();
}
}
else if (event.getSource() == bCancel) {
settingsWindow.setVisible(false);
}
}
//</editor-fold>
}
Loading

0 comments on commit 2687ea6

Please sign in to comment.