Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
Argent77 committed Nov 8, 2022
2 parents b8f92b6 + 10bcfb7 commit 6e66a76
Show file tree
Hide file tree
Showing 456 changed files with 27,730 additions and 6,201 deletions.
2 changes: 1 addition & 1 deletion .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="lib" path="lib/jorbis/jorbis.jar" sourcepath="lib/jorbis/jorbis-0.0.17.zip"/>
<classpathentry exported="true" kind="lib" path="lib/rsyntaxtextarea/rsyntaxtextarea.jar" sourcepath="lib/rsyntaxtextarea/RSyntaxTextArea-3.1.1-light.zip"/>
<classpathentry exported="true" kind="lib" path="lib/rsyntaxtextarea/rsyntaxtextarea.jar" sourcepath="lib/rsyntaxtextarea/rsyntaxtextarea-3.3.0-sources.jar"/>
<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"/>
Expand Down
Binary file removed lib/rsyntaxtextarea/RSyntaxTextArea-3.1.1-light.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion lib/rsyntaxtextarea/RSyntaxTextArea.License.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2019, Robert Futrell
Copyright (c) 2022, Robert Futrell
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
Binary file not shown.
Binary file modified lib/rsyntaxtextarea/rsyntaxtextarea.jar
Binary file not shown.
63 changes: 55 additions & 8 deletions src/org/infinity/NearInfinity.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@
import org.infinity.icon.Icons;
import org.infinity.resource.AbstractStruct;
import org.infinity.resource.Closeable;
import org.infinity.resource.EffectFactory;
import org.infinity.resource.Profile;
import org.infinity.resource.Resource;
import org.infinity.resource.ResourceFactory;
Expand All @@ -104,6 +103,7 @@
import org.infinity.resource.bcs.Signatures;
import org.infinity.resource.cre.decoder.util.ItemInfo;
import org.infinity.resource.cre.decoder.util.SpriteUtils;
import org.infinity.resource.effects.BaseOpcode;
import org.infinity.resource.graphics.ColorConvert;
import org.infinity.resource.key.FileResourceEntry;
import org.infinity.resource.key.ResourceEntry;
Expand All @@ -130,8 +130,6 @@
public final class NearInfinity extends JFrame implements ActionListener, ViewableContainer {
private static final int[] JAVA_VERSION = { 1, 8 }; // the minimum java version supported

private static final InfinityTextArea CONSOLE_TEXT = new InfinityTextArea(true);

private static final String KEYFILENAME = "chitin.key";
private static final String WINDOW_SIZEX = "WindowSizeX";
private static final String WINDOW_SIZEY = "WindowSizeY";
Expand All @@ -145,18 +143,32 @@ public final class NearInfinity extends JFrame implements ActionListener, Viewab
private static final String TABLE_WIDTH_SIZE = "TableColWidthSize";
private static final String TABLE_PANEL_HEIGHT = "TablePanelHeight";
private static final String OPTION_GLOBAL_FONT_SIZE = "GlobalFontSize";
private static final String APP_UI_SCALE_ENABLED = "AppUiScaleEnabled";
private static final String APP_UI_SCALE_FACTOR = "AppUiScaleFactor";

private static final String STATUSBAR_TEXT_FMT = "Welcome to Near Infinity! - %s @ %s - %d files available";

private static NearInfinity browser;

static {
// Setting Swing UI scale factor (only available for Java 9 or higher)
if (Platform.JAVA_VERSION > 8) {
final int uiScale = getUiScalingOption();
if (uiScale > 0) {
// Must be set BEFORE any Swing Library calls to be effective
System.setProperty("sun.java2d.uiScale.enabled", "true");
System.setProperty("sun.java2d.uiScale", Double.toString(uiScale / 100.0));
}
}

if (Platform.IS_MACOS) {
// Enforce proper macOS menu bar integration
System.setProperty("apple.laf.useScreenMenuBar", "true");
}
}

private static final InfinityTextArea CONSOLE_TEXT = new InfinityTextArea(true);

private static NearInfinity browser;

private final JPanel containerpanel;
private final JSplitPane spSplitter;
private final ResourceTree tree;
Expand All @@ -172,7 +184,8 @@ public final class NearInfinity extends JFrame implements ActionListener, Viewab
private JPopupMenu launchMenu;
private int tablePanelHeight;
private ProgressMonitor pmProgress;
private int progressIndex, globalFontSize;
private int progressIndex, globalFontSize, uiScalingFactor;
private boolean uiScalingEnabled;

private static Path findKeyfile() {
JFileChooser chooser;
Expand Down Expand Up @@ -316,6 +329,10 @@ private NearInfinity(Path gameOverride, Profile.Game forcedGame) {
Preferences prefs = Preferences.userNodeForPackage(getClass());
migratePreferences("infinity", prefs, true);

// updating UI scale override
uiScalingEnabled = prefs.getBoolean(APP_UI_SCALE_ENABLED, false);
uiScalingFactor = prefs.getInt(APP_UI_SCALE_FACTOR, 100);

// updating relative default font size globally
globalFontSize = Math.max(50, Math.min(400, prefs.getInt(OPTION_GLOBAL_FONT_SIZE, 100)));
resizeUIFont(globalFontSize);
Expand Down Expand Up @@ -368,6 +385,7 @@ protected Void doInBackground() throws Exception {
advanceProgress("Initializing GUI...");
BrowserMenuBar.getInstance().gameLoaded(Profile.Game.Unknown, null);
CreMapCache.reset();
BaseOpcode.initOpcodes();
// if (BrowserMenuBar.getInstance().getMonitorFileChanges()) {
// FileWatcher.getInstance().start();
// }
Expand Down Expand Up @@ -727,7 +745,7 @@ public void openGame(Path keyFile) {
Path oldKeyFile = Profile.getChitinKey();
ChildFrame.closeWindows();
clearCache(false);
EffectFactory.reset();
BaseOpcode.reset();
Profile.openGame(keyFile, BrowserMenuBar.getInstance().getBookmarkName(keyFile));

// making sure vital game resources are accessible
Expand Down Expand Up @@ -903,6 +921,20 @@ public int updateTablePanelHeight(int newValue) {
return retVal;
}

/**
* Returns whether global UI Scaling is overridden by the application.
*/
public boolean isUiScalingEnabled() {
return uiScalingEnabled;
}

/**
* Returns the currently selected UI Scaling factor, in percent.
*/
public int getUiScalingFactor() {
return uiScalingFactor;
}

/**
* Returns the currently selected global font size relative to UI defaults.
*/
Expand Down Expand Up @@ -978,12 +1010,24 @@ public void updateLauncher() {
});
}

/**
* Returns the UI scaling factor (in percent) if overridden by the app. Returns 0 if system-wide UI scale factor
* is used.
*/
private static int getUiScalingOption() {
int retVal = 0;
final Preferences prefs = Preferences.userNodeForPackage(NearInfinity.class);
if (prefs.getBoolean(APP_UI_SCALE_ENABLED, false)) {
retVal = Math.max(50, Math.min(400, prefs.getInt(APP_UI_SCALE_FACTOR, 100)));
}
return retVal;
}

private static boolean reloadFactory(boolean refreshOnly) {
boolean retVal = false;
clearCache(refreshOnly);
Path keyFile = refreshOnly ? Profile.getChitinKey() : findKeyfile();
if (keyFile != null) {
EffectFactory.reset();
retVal = Profile.openGame(keyFile, BrowserMenuBar.getInstance().getBookmarkName(keyFile));
if (retVal) {
CreMapCache.reset();
Expand All @@ -1006,6 +1050,7 @@ private static void clearCache(boolean refreshOnly) {
IniMapCache.clearCache();
Table2daCache.clearCache();
CreMapCache.clearCache();
BaseOpcode.reset();
// SearchFrame.clearCache();
StringTable.resetAll();
ProRef.clearCache();
Expand Down Expand Up @@ -1068,6 +1113,8 @@ private void storePreferences() {
prefs.putInt(TABLE_WIDTH_OFS, getTableColumnWidth(2));
prefs.putInt(TABLE_WIDTH_SIZE, getTableColumnWidth(3));
prefs.putInt(TABLE_PANEL_HEIGHT, getTablePanelHeight());
prefs.putBoolean(APP_UI_SCALE_ENABLED, BrowserMenuBar.getInstance().isUiScalingEnabled());
prefs.putInt(APP_UI_SCALE_FACTOR, BrowserMenuBar.getInstance().getUiScalingFactor());
prefs.putInt(OPTION_GLOBAL_FONT_SIZE, BrowserMenuBar.getInstance().getGlobalFontSize());
BrowserMenuBar.getInstance().storePreferences();
Updater.getInstance().saveUpdateSettings();
Expand Down
Loading

0 comments on commit 6e66a76

Please sign in to comment.