Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
Argent77 committed Jun 9, 2023
2 parents a11d887 + 1241e54 commit 9d4d21d
Show file tree
Hide file tree
Showing 1,098 changed files with 3,630 additions and 1,835 deletions.
2 changes: 2 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<classpathentry exported="true" kind="lib" path="lib/jhexview/jhexview.jar" sourcepath="lib/jhexview/jhexview-current.zip"/>
<classpathentry exported="true" kind="lib" path="lib/montemedia/montemedia.jar" sourcepath="lib/montemedia/MonteMedia-0.7.7.zip"/>
<classpathentry exported="true" kind="lib" path="lib/apng-writer/apng-writer-core.jar" sourcepath="lib/apng-writer/apng-writer-core-src.zip"/>
<classpathentry exported="true" kind="lib" path="lib/json/json-20230227.jar" sourcepath="lib/json/JSON-java-20230227.zip"/>
<classpathentry exported="true" kind="lib" path="lib/commonmark/commonmark-0.21.0.jar" sourcepath="lib/commonmark/commonmark-java-commonmark-parent-0.21.0.zip"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
7 changes: 4 additions & 3 deletions .github/workflows/ant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up JDK 1.8
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
java-version: 1.8
distribution: 'temurin'
java-version: '8'
- name: Build with Ant
run: ant -noinput -buildfile build.xml
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ 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), or download it directly from the
[Releases section](https://github.com/Argent77/NearInfinity/releases).

**Discuss Near Infinity on:**
- [GitHub Discussions](https://github.com/NearInfinityBrowser/NearInfinity/discussions)
- [Beamdog Forums](https://forums.beamdog.com/discussion/30593/new-versions-of-nearinfinity-available/)
- [Spellhold Studios Forums](http://www.shsforums.net/topic/45358-nearinfinity/)

## How to build Near Infinity

**Required tools:**
Expand Down
6 changes: 5 additions & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
<property name="jhexview.file" value="${lib.path.rel}/jhexview/jhexview.jar"/>
<property name="montemedia.file" value="${lib.path.rel}/montemedia/montemedia.jar"/>
<property name="apng_writer.file" value="${lib.path.rel}/apng-writer/apng-writer-core.jar"/>
<property name="json.file" value="${lib.path.rel}/json/json-20230227.jar"/>
<property name="commonmark.file" value="${lib.path.rel}/commonmark/commonmark-0.21.0.jar"/>
<property name="javacc.home" value="lib/javacc"/>
<property name="parser.path" value="org/infinity/resource/bcs/parser"/>
<property name="src.parser.path" value="${src.path}/org/infinity/resource/bcs/parser"/>
Expand All @@ -27,7 +29,7 @@
deprecation="false"
debug="false"
debuglevel="lines,vars,source"
classpath="${classpath}:${jorbis.file}:${rsyntaxtextarea.file}:${jhexview.file}:${montemedia.file}:${apng_writer.file}">
classpath="${classpath}:${jorbis.file}:${rsyntaxtextarea.file}:${jhexview.file}:${montemedia.file}:${apng_writer.file}:${json.file}:${commonmark.file}">
<!-- Various debugging options: -->
<!-- <compilerarg value="-Xlint:cast"/> -->
<!-- <compilerarg value="-Xlint:deprecation"/> -->
Expand All @@ -51,6 +53,8 @@
<zipgroupfileset dir="." includes="${jhexview.file}"/>
<zipgroupfileset dir="." includes="${montemedia.file}"/>
<zipgroupfileset dir="." includes="${apng_writer.file}"/>
<zipgroupfileset dir="." includes="${json.file}"/>
<zipgroupfileset dir="." includes="${commonmark.file}"/>
<manifest>
<attribute name="Main-Class" value="org.infinity.NearInfinity"/>
</manifest>
Expand Down
23 changes: 23 additions & 0 deletions lib/commonmark/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Copyright (c) 2015, Atlassian Pty Ltd
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Binary file added lib/commonmark/commonmark-0.21.0.jar
Binary file not shown.
Binary file not shown.
Binary file added lib/json/JSON-java-20230227.zip
Binary file not shown.
Binary file added lib/json/json-20230227.jar
Binary file not shown.
169 changes: 120 additions & 49 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 - 2022 Jon Olav Hauglid
// Copyright (C) 2001 Jon Olav Hauglid
// See LICENSE.txt for license information

package org.infinity;
Expand All @@ -8,7 +8,6 @@
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.Event;
import java.awt.Font;
Expand Down Expand Up @@ -118,6 +117,7 @@
import org.infinity.util.FileDeletionHook;
import org.infinity.util.IdsMapCache;
import org.infinity.util.IniMapCache;
import org.infinity.util.LauncherUtils;
import org.infinity.util.Misc;
import org.infinity.util.Platform;
import org.infinity.util.StringTable;
Expand Down Expand Up @@ -231,13 +231,15 @@ public static void printHelp(String jarFile) {
}
System.out.format("Usage: java -jar %s [options] [game_path]", jarFile).println();
System.out.println("\nOptions:");
System.out.println(" -v, -version Display version information.");
System.out.println(" -h, -help Display this help.");
System.out.println(" -t type Force the current or specified game to be of");
System.out.println(" specific type. (Use with care!)");
System.out.println(" Supported game types:");
System.out.println(" -v, -version Display version information.");
System.out.println(" -h, -help Display this help.");
System.out.println(" -no-update Disables the update check option in the menu bar.");
System.out.println(" -no-launch-game Hides the \"Launch game\" button.");
System.out.println(" -t type Force the current or specified game to be of");
System.out.println(" specific type. (Use with care!)");
System.out.println(" Supported game types:");
for (final Profile.Game game : Profile.Game.values()) {
System.out.println(" " + game.toString());
System.out.println(" " + game.toString());
}
System.out.println("\nExamples:");
System.out.format("Specify game path: java -jar %s \"C:\\Games\\Baldurs Gate II\"", jarFile).println();
Expand All @@ -257,38 +259,54 @@ public static void advanceProgress(String note) {
public static void main(String args[]) {
Profile.Game forcedGame = null;
Path gameOverride = null;
boolean enableUpdate = true;
boolean showLaunchGame = true;

for (int idx = 0; idx < args.length; idx++) {
if (args[idx].equalsIgnoreCase("-v") || args[idx].equalsIgnoreCase("-version")) {
System.out.println("Near Infinity " + getVersion());
System.exit(0);
} else if (args[idx].equalsIgnoreCase("-h") || args[idx].equalsIgnoreCase("-help")) {
String jarFile = Utils.getJarFileName(NearInfinity.class);
if (!jarFile.isEmpty()) {
jarFile = FileManager.resolve(jarFile).getFileName().toString();
}
printHelp(jarFile);
System.exit(0);
} else if (args[idx].equalsIgnoreCase("-t") && idx + 1 < args.length) {
idx++;
String type = args[idx];
Profile.Game[] games = Profile.Game.values();
for (final Profile.Game game : games) {
if (game.toString().equalsIgnoreCase(type)) {
forcedGame = game;
break;
switch (args[idx].toLowerCase(Locale.ENGLISH)) {
case "-v":
case "-version":
System.out.println("Near Infinity " + getVersion());
System.exit(0);
case "-h":
case "-help":
String jarFile = Utils.getJarFileName(NearInfinity.class);
if (!jarFile.isEmpty()) {
jarFile = FileManager.resolve(jarFile).getFileName().toString();
}
}
} else {
// Override game folder via application parameter
Path f = FileManager.resolve(args[idx]);
if (FileEx.create(f).isFile()) {
f = f.getParent();
}
if (FileEx.create(f).isDirectory()) {
gameOverride = f;
printHelp(jarFile);
System.exit(0);
case "-no-update":
enableUpdate = false;
break;
}
case "-no-launch-game":
showLaunchGame = false;
break;
case "-t":
if (idx + 1 < args.length) {
idx++;
String type = args[idx];
Profile.Game[] games = Profile.Game.values();
for (final Profile.Game game : games) {
if (game.toString().equalsIgnoreCase(type)) {
forcedGame = game;
break;
}
}
break;
} else {
System.err.println("Missing argument for option '-t'.");
System.exit(1);
}
default:
// Override game folder via application parameter
Path f = FileManager.resolve(args[idx]);
if (FileEx.create(f).isFile()) {
f = f.getParent();
}
if (FileEx.create(f).isDirectory()) {
gameOverride = f;
}
}
}

Expand All @@ -310,10 +328,11 @@ public static void main(String args[]) {
System.setOut(new ConsoleStream(System.out, CONSOLE_TEXT));
System.setErr(new ConsoleStream(System.err, CONSOLE_TEXT));

new NearInfinity(gameOverride, forcedGame);
final Options options = new Options(gameOverride, forcedGame, enableUpdate, showLaunchGame);
new NearInfinity(options);
}

private NearInfinity(Path gameOverride, Profile.Game forcedGame) {
private NearInfinity(Options options) {
super("Near Infinity");
browser = this;
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
Expand All @@ -338,13 +357,14 @@ private NearInfinity(Path gameOverride, Profile.Game forcedGame) {
resizeUIFont(globalFontSize);

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

final String lastDir;
if (gameOverride != null && FileEx.create(gameOverride).isDirectory()) {
lastDir = gameOverride.toString();
if (options.isGameOverride() && FileEx.create(options.getGameOverride()).isDirectory()) {
lastDir = options.getGameOverride().toString();
} else {
lastDir = prefs.get(LAST_GAMEDIR, null);
}
Expand All @@ -366,7 +386,7 @@ private NearInfinity(Path gameOverride, Profile.Game forcedGame) {
SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
Profile.openGame(keyFile, BrowserMenuBar.getInstance().getBookmarkName(keyFile), forcedGame);
Profile.openGame(keyFile, BrowserMenuBar.getInstance().getBookmarkName(keyFile), options.getForcedGame());

// making sure vital game resources are accessible
Path tlkFile = Profile.getProperty(Profile.Key.GET_GAME_DIALOG_FILE);
Expand Down Expand Up @@ -494,6 +514,7 @@ public void popupWindowWillBecomeInvisible(PopupWindowEvent event) {
btnLaunchGame.setMargin(new Insets(0, 0, 0, 0));
btnLaunchGame.setToolTipText("Launch game");
btnLaunchGame.addActionListener(this);
btnLaunchGame.setVisible(options.isLaunchGameVisible());
toolBar.add(btnLaunchGame);
launchMenu = new JPopupMenu();

Expand Down Expand Up @@ -537,16 +558,22 @@ public void popupWindowWillBecomeInvisible(PopupWindowEvent event) {
new DropTarget(getRootPane(), new FileDropTargetListener());

// Checking for updates
if (Updater.getInstance().isAutoUpdateCheckEnabled() && Updater.getInstance().hasAutoUpdateCheckDateExpired()) {
if (options.isUpdateEnabled() &&
Updater.getInstance().isAutoUpdateCheckEnabled() &&
Updater.getInstance().hasAutoUpdateCheckDateExpired()) {
// storing last check date for future reference
Updater.getInstance().setAutoUpdateCheckDate(null);
// running check in background with as little as possible interference with user interactions
new Thread(() -> {
UpdateInfo info = Updater.getInstance().loadUpdateInfo();
if (info != null) {
if (Updater.isNewRelease(info.getRelease(), true)) {
UpdateCheck.showDialog(NearInfinity.getInstance(), info);
try {
UpdateInfo info = Updater.getInstance().loadUpdateInfo();
if (info != null) {
if (Updater.isNewRelease(info.getRelease(), true)) {
UpdateCheck.showDialog(NearInfinity.getInstance(), info);
}
}
} catch (Exception e) {
System.out.println("Failed to check for updates: " + e.getMessage());
}
}).start();
}
Expand Down Expand Up @@ -1122,8 +1149,13 @@ private void storePreferences() {

private void setAppIcon() {
List<Image> list = new ArrayList<>();
for (int i = 4; i < 8; i++) {
list.add(Icons.getImage(null, String.format("App%d.png", 1 << i)));
for (int i = 4; true; i++) {
final Image icon = Icons.getImage(null, String.format("App%d.png", 1 << i));
if (icon != null) {
list.add(icon);
} else {
break;
}
}
setIconImages(list);
}
Expand Down Expand Up @@ -1218,7 +1250,7 @@ private boolean launchGameBinary(Path binPath) {
try {
if (Platform.IS_MACOS && binPath.toString().toLowerCase(Locale.ENGLISH).endsWith(".app")) {
// This method may be required for launching Mac App Bundles
Desktop.getDesktop().open(binPath.toFile());
LauncherUtils.open(binPath);
} else {
ProcessBuilder pb = new ProcessBuilder(binPath.toString());
pb.directory(binPath.getParent().toFile());
Expand Down Expand Up @@ -1329,6 +1361,45 @@ private JPanel createJavaInfoPanel() {

// -------------------------- INNER CLASSES --------------------------

private static final class Options {
private final Path gameOverride;
private final Profile.Game forcedGame;
private final boolean enableUpdate;
private final boolean showLaunchGame;

public Options(Path gameOverride, Profile.Game forcedGame, boolean enableUpdate, boolean showLaunchGame) {
this.gameOverride = gameOverride;
this.forcedGame = forcedGame;
this.enableUpdate = enableUpdate;
this.showLaunchGame = showLaunchGame;
}

public boolean isGameOverride() {
return gameOverride != null;
}

public Path getGameOverride() {
return gameOverride;
}

@SuppressWarnings("unused")
public boolean isForcedGame() {
return forcedGame != null;
}

public Profile.Game getForcedGame() {
return forcedGame;
}

public boolean isUpdateEnabled() {
return enableUpdate;
}

public boolean isLaunchGameVisible() {
return showLaunchGame;
}
}

private static final class ConsoleStream extends PrintStream {
private final JTextArea text;

Expand Down
2 changes: 1 addition & 1 deletion src/org/infinity/check/AbstractChecker.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 - 2022 Jon Olav Hauglid
// Copyright (C) 2001 Jon Olav Hauglid
// See LICENSE.txt for license information

package org.infinity.check;
Expand Down
2 changes: 1 addition & 1 deletion src/org/infinity/check/BCSIDSChecker.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 - 2022 Jon Olav Hauglid
// Copyright (C) 2001 Jon Olav Hauglid
// See LICENSE.txt for license information

package org.infinity.check;
Expand Down
2 changes: 1 addition & 1 deletion src/org/infinity/check/CreInvChecker.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 - 2022 Jon Olav Hauglid
// Copyright (C) 2001 Jon Olav Hauglid
// See LICENSE.txt for license information

package org.infinity.check;
Expand Down
2 changes: 1 addition & 1 deletion src/org/infinity/check/DialogChecker.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 - 2022 Jon Olav Hauglid
// Copyright (C) 2001 Jon Olav Hauglid
// See LICENSE.txt for license information

package org.infinity.check;
Expand Down
2 changes: 1 addition & 1 deletion src/org/infinity/check/EffectsIndexChecker.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 - 2022 Jon Olav Hauglid
// Copyright (C) 2001 Jon Olav Hauglid
// See LICENSE.txt for license information

package org.infinity.check;
Expand Down
Loading

0 comments on commit 9d4d21d

Please sign in to comment.