Skip to content

Commit

Permalink
Add new Preferences option and reorganize categories
Browse files Browse the repository at this point in the history
- Added option "Use last available IDS symbol for display"
- Moved several options from the "General" category to the new "Resources" subcategory
  • Loading branch information
Argent77 committed Dec 27, 2024
1 parent 87cb143 commit 57b041e
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 67 deletions.
55 changes: 30 additions & 25 deletions src/org/infinity/AppOption.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,30 +93,6 @@ public class AppOption {
/** Menu Options: LaunchGameAllowed (Boolean, Default: true) */
public static final AppOption LAUNCH_GAME_ALLOWED = new AppOption(OptionsMenuItem.OPTION_LAUNCHGAMEALLOWED,
"Allow launching games", true);
/** Menu Options: IgnoreOverride (Boolean, Default: false) */
public static final AppOption IGNORE_OVERRIDE = new AppOption(OptionsMenuItem.OPTION_IGNOREOVERRIDE, "Ignore Override",
false);
/** Menu Options: IgnoreReadErrors (Boolean, Default: false) */
public static final AppOption IGNORE_READ_ERRORS = new AppOption(OptionsMenuItem.OPTION_IGNOREREADERRORS,
"Ignore Read Errors", false);
/** Menu Options: ShowUnknownResources (Boolean, Default: true) */
public static final AppOption SHOW_UNKNOWN_RESOURCES = new AppOption(OptionsMenuItem.OPTION_SHOWUNKNOWNRESOURCES,
"Show Unknown Resource Types", true);
/** Menu Options: ShowTreeSearchNames (Boolean, Default: true) */
public static final AppOption SHOW_TREE_SEARCH_NAMES = new AppOption(OptionsMenuItem.OPTION_SHOWTREESEARCHNAMES,
"Show Search Names in Resource Tree", true);
/** Menu Options: Show Icons in Resource List (Boolean, Default: false) */
public static final AppOption SHOW_RESOURCE_LIST_ICONS = new AppOption(OptionsMenuItem.OPTION_SHOW_RESOURCE_LIST_ICONS,
"Show Icons in Resource List", false);
/** Menu Options: Show Icons in Resource Tree (Boolean, Default: false) */
public static final AppOption SHOW_RESOURCE_TREE_ICONS = new AppOption(OptionsMenuItem.OPTION_SHOW_RESOURCE_TREE_ICONS,
"Show Icons in Resource Tree", false);
/** Menu Options: HighlightOverridden (Boolean, Default: true) */
public static final AppOption HIGHLIGHT_OVERRIDDEN = new AppOption(OptionsMenuItem.OPTION_HIGHLIGHT_OVERRIDDEN,
"Show Overridden Files in Bold in Resource Tree", true);
/** Menu Options: CacheOverride (Boolean, Default: true) */
public static final AppOption CACHE_OVERRIDE = new AppOption(OptionsMenuItem.OPTION_CACHEOVERRIDE,
"Autocheck for Overrides", true);
/** Menu Options: UpdateTreeOnCopy (Boolean, Default: false) */
public static final AppOption KEEP_VIEW_ON_COPY = new AppOption(OptionsMenuItem.OPTION_KEEPVIEWONCOPY,
"Keep View after Copy Operations", false);
Expand Down Expand Up @@ -150,7 +126,36 @@ public class AppOption {
public static final AppOption OPTION_FIXED_INTERNAL = new AppOption(OptionsMenuItem.OPTION_OPTION_FIXED,
"Internal fixes", 0);

// Category: Show Table Columns
// Category: Resources
/** Menu Options: IgnoreOverride (Boolean, Default: false) */
public static final AppOption IGNORE_OVERRIDE = new AppOption(OptionsMenuItem.OPTION_IGNOREOVERRIDE, "Ignore Override",
false);
/** Menu Options: IgnoreReadErrors (Boolean, Default: false) */
public static final AppOption IGNORE_READ_ERRORS = new AppOption(OptionsMenuItem.OPTION_IGNOREREADERRORS,
"Ignore Read Errors", false);
/** Menu Options: ShowUnknownResources (Boolean, Default: true) */
public static final AppOption SHOW_UNKNOWN_RESOURCES = new AppOption(OptionsMenuItem.OPTION_SHOWUNKNOWNRESOURCES,
"Show Unknown Resource Types", true);
/** Menu Options: ShowTreeSearchNames (Boolean, Default: true) */
public static final AppOption SHOW_TREE_SEARCH_NAMES = new AppOption(OptionsMenuItem.OPTION_SHOWTREESEARCHNAMES,
"Show Search Names in Resource Tree", true);
/** Menu Options: Show Icons in Resource List (Boolean, Default: false) */
public static final AppOption SHOW_RESOURCE_LIST_ICONS = new AppOption(OptionsMenuItem.OPTION_SHOW_RESOURCE_LIST_ICONS,
"Show Icons in Resource List", false);
/** Menu Options: Show Icons in Resource Tree (Boolean, Default: false) */
public static final AppOption SHOW_RESOURCE_TREE_ICONS = new AppOption(OptionsMenuItem.OPTION_SHOW_RESOURCE_TREE_ICONS,
"Show Icons in Resource Tree", false);
/** Menu Options: HighlightOverridden (Boolean, Default: true) */
public static final AppOption HIGHLIGHT_OVERRIDDEN = new AppOption(OptionsMenuItem.OPTION_HIGHLIGHT_OVERRIDDEN,
"Show Overridden Files in Bold in Resource Tree", true);
/** Menu Options: CacheOverride (Boolean, Default: true) */
public static final AppOption CACHE_OVERRIDE = new AppOption(OptionsMenuItem.OPTION_CACHEOVERRIDE,
"Autocheck for Overrides", true);
/** Menu Options: ShowLastIdsSymbol (Boolean, Default: true) */
public static final AppOption IDS_SYMBOL_DISPLAY = new AppOption(OptionsMenuItem.OPTION_IDS_SYMBOL_DISPLAY,
"Use last available IDS symbol for display", true);

// Category: Table Columns
/** Menu Options > Show Table Columns: ShowOffsets (Boolean, Default: true) */
public static final AppOption TABLE_SHOW_OFFSETS = new AppOption(OptionsMenuItem.OPTION_SHOWOFFSETS,
"Show Field Offsets", true);
Expand Down
93 changes: 52 additions & 41 deletions src/org/infinity/gui/PreferencesDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public class PreferencesDialog extends JDialog {
public enum Category {
DEFAULT(""),
GENERAL_OPTIONS("General"),
RESOURCES("Resources"),
TABLE_COLUMNS("Table Columns"),
SCRIPT_COMPILER("Script Compiler"),
TEXT_EDITOR("Text Editor"),
Expand Down Expand Up @@ -137,6 +138,57 @@ public String toString() {
/** Root element of the options definition tree. */
private final OptionCategory optionRoot = OptionCategory.createDefault(
OptionCategory.create(Category.GENERAL_OPTIONS,
OptionCategory.create(Category.RESOURCES,
OptionGroup.createDefault(
OptionCheckBox.create(AppOption.IGNORE_OVERRIDE.getName(), AppOption.IGNORE_OVERRIDE.getLabel(),
"With this option enabled Near Infinity ignores resources in the override folder if they are also "
+ "present in biff archives.",
AppOption.IGNORE_OVERRIDE),
OptionCheckBox.create(AppOption.IGNORE_READ_ERRORS.getName(), AppOption.IGNORE_READ_ERRORS.getLabel(),
"With this option enabled Near Infinity shows a message box when a resource cannot be read. "
+ "Otherwise, a message is printed to the status bar and debug console.",
AppOption.IGNORE_READ_ERRORS),
OptionCheckBox.create(AppOption.SHOW_UNKNOWN_RESOURCES.getName(), AppOption.SHOW_UNKNOWN_RESOURCES.getLabel(),
"With this option enabled Near Infinity shows unknown or unsupported resources in their own type "
+ "folder in the resource tree.",
AppOption.SHOW_UNKNOWN_RESOURCES),
OptionCheckBox.create(AppOption.SHOW_TREE_SEARCH_NAMES.getName(), AppOption.SHOW_TREE_SEARCH_NAMES.getLabel(),
"With this option enabled Near Infinity shows the search name of resources in the resource tree "
+ "in parentheses if available, such as creature, item or spell names.",
AppOption.SHOW_TREE_SEARCH_NAMES),
OptionCheckBox.create(AppOption.SHOW_RESOURCE_TREE_ICONS.getName(), AppOption.SHOW_RESOURCE_TREE_ICONS.getLabel(),
"With this option enabled Near Infinity shows icons alongside names in the resource tree for BMP, ITM "
+ "and SPL resources."
+ "<p><strong>Caution:</strong> Enabling this option may result in increased memory usage and "
+ "noticeable lags on slower systems.</p>",
AppOption.SHOW_RESOURCE_TREE_ICONS),
OptionCheckBox.create(AppOption.SHOW_RESOURCE_LIST_ICONS.getName(), AppOption.SHOW_RESOURCE_LIST_ICONS.getLabel(),
"With this option enabled Near Infinity shows icons alongside names in resource selection lists and "
+ "tables for BMP, ITM and SPL resources as well as portrait thumbnails for characters in GAM resources."
+ "<p><strong>Caution:</strong> Enabling this option may result in increased memory usage and "
+ "noticeable lags on slower systems.</p>",
AppOption.SHOW_RESOURCE_LIST_ICONS),
OptionCheckBox.create(AppOption.HIGHLIGHT_OVERRIDDEN.getName(), AppOption.HIGHLIGHT_OVERRIDDEN.getLabel(),
"If checked, files that are listed in the <em>chitin.key</em> and are also available in the "
+ "Override folder, will be shown in <strong>bold</strong> in the resource tree."
+ "<p><strong>Note:</strong> This setting has no effect if overridden files are only shown in "
+ "the override folder (see <code>" + Category.VISUAL_OPTIONS.getLabel() + "</code> &gt; <code>"
+ AppOption.SHOW_OVERRIDES_IN.getLabel() + "</code>.)",
AppOption.HIGHLIGHT_OVERRIDDEN),
OptionCheckBox.create(AppOption.CACHE_OVERRIDE.getName(), AppOption.CACHE_OVERRIDE.getLabel(),
"With this option enabled Near Infinity checks whether resources have been overridden every time a "
+ "resource has been requested."
+ "<p>If this option is disabled then Near Infinity will only check for the existence of overridden "
+ "resources after opening a new game or using the command \"Refresh Tree\" (Shortcut: <code>F5</code>).</p>",
AppOption.CACHE_OVERRIDE),
OptionCheckBox.create(AppOption.IDS_SYMBOL_DISPLAY.getName(), AppOption.IDS_SYMBOL_DISPLAY.getLabel(),
"With this option enabled IDS entries with multiple symbolic names will display the last available "
+ "symbol in scripts, effects, and other resources."
+ "<p>Disable this option to show the first available symbolic name instead.</p>"
+ "<p>You may need to refresh the game (Shortcut: <code>F5</code>) for the option to take effect.</p>",
AppOption.IDS_SYMBOL_DISPLAY)
)
),
OptionCategory.create(Category.TABLE_COLUMNS,
OptionGroup.createDefault(
OptionCheckBox.create(AppOption.TABLE_SHOW_OFFSETS.getName(), AppOption.TABLE_SHOW_OFFSETS.getLabel(),
Expand Down Expand Up @@ -167,47 +219,6 @@ public String toString() {
+ "from within Near Infinity.",
AppOption.LAUNCH_GAME_ALLOWED)
.setOnCreated(this::launchGameAllowedOnCreated),
OptionCheckBox.create(AppOption.IGNORE_OVERRIDE.getName(), AppOption.IGNORE_OVERRIDE.getLabel(),
"With this option enabled Near Infinity ignores resources in the override folder if they are also "
+ "present in biff archives.",
AppOption.IGNORE_OVERRIDE),
OptionCheckBox.create(AppOption.IGNORE_READ_ERRORS.getName(), AppOption.IGNORE_READ_ERRORS.getLabel(),
"With this option enabled Near Infinity shows a message box when a resource cannot be read. "
+ "Otherwise, a message is printed to the status bar and debug console.",
AppOption.IGNORE_READ_ERRORS),
OptionCheckBox.create(AppOption.SHOW_UNKNOWN_RESOURCES.getName(), AppOption.SHOW_UNKNOWN_RESOURCES.getLabel(),
"With this option enabled Near Infinity shows unknown or unsupported resources in their own type "
+ "folder in the resource tree.",
AppOption.SHOW_UNKNOWN_RESOURCES),
OptionCheckBox.create(AppOption.SHOW_TREE_SEARCH_NAMES.getName(), AppOption.SHOW_TREE_SEARCH_NAMES.getLabel(),
"With this option enabled Near Infinity shows the search name of resources in the resource tree "
+ "in parentheses if available, such as creature, item or spell names.",
AppOption.SHOW_TREE_SEARCH_NAMES),
OptionCheckBox.create(AppOption.SHOW_RESOURCE_TREE_ICONS.getName(), AppOption.SHOW_RESOURCE_TREE_ICONS.getLabel(),
"With this option enabled Near Infinity shows icons alongside names in the resource tree for BMP, ITM "
+ "and SPL resources."
+ "<p><strong>Caution:</strong> Enabling this option may result in increased memory usage and "
+ "noticeable lags on slower systems.</p>",
AppOption.SHOW_RESOURCE_TREE_ICONS),
OptionCheckBox.create(AppOption.SHOW_RESOURCE_LIST_ICONS.getName(), AppOption.SHOW_RESOURCE_LIST_ICONS.getLabel(),
"With this option enabled Near Infinity shows icons alongside names in resource selection lists and "
+ "tables for BMP, ITM and SPL resources as well as portrait thumbnails for characters in GAM resources."
+ "<p><strong>Caution:</strong> Enabling this option may result in increased memory usage and "
+ "noticeable lags on slower systems.</p>",
AppOption.SHOW_RESOURCE_LIST_ICONS),
OptionCheckBox.create(AppOption.HIGHLIGHT_OVERRIDDEN.getName(), AppOption.HIGHLIGHT_OVERRIDDEN.getLabel(),
"If checked, files that are listed in the <em>chitin.key</em> and are also available in the "
+ "Override folder, will be shown in <strong>bold</strong> in the resource tree."
+ "<p><strong>Note:</strong> This setting has no effect if overridden files are only shown in "
+ "the override folder (see <code>" + Category.VISUAL_OPTIONS.getLabel() + "</code> &gt; <code>"
+ AppOption.SHOW_OVERRIDES_IN.getLabel() + "</code>.)",
AppOption.HIGHLIGHT_OVERRIDDEN),
OptionCheckBox.create(AppOption.CACHE_OVERRIDE.getName(), AppOption.CACHE_OVERRIDE.getLabel(),
"With this option enabled Near Infinity checks whether resources have been overridden every time a "
+ "resource has been requested."
+ "<p>If this option is disabled then Near Infinity will only check for the existence of overridden "
+ "resources after opening a new game or using the command \"Refresh Tree\" (Shortcut: <code>F5</code>).</p>",
AppOption.CACHE_OVERRIDE),
OptionCheckBox.create(AppOption.KEEP_VIEW_ON_COPY.getName(), AppOption.KEEP_VIEW_ON_COPY.getLabel(),
"With this option enabled the resource tree will keep the original resource selected after performing "
+ "the \"Add Copy Of\" operation on the resource. Otherwise, the new resource is selected instead.",
Expand Down
9 changes: 9 additions & 0 deletions src/org/infinity/gui/menu/OptionsMenuItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ public String toString() {
public static final String OPTION_SHOW_RESOURCE_TREE_ICONS = "ShowResourceTreeIcons";
public static final String OPTION_HIGHLIGHT_OVERRIDDEN = "HighlightOverridden";
public static final String OPTION_CACHEOVERRIDE = "CacheOverride";
public static final String OPTION_IDS_SYMBOL_DISPLAY = "IdsSymbolDisplay";
public static final String OPTION_KEEPVIEWONCOPY = "UpdateTreeOnCopy";
public static final String OPTION_SHOWSTRREFS = "ShowStrrefs";
public static final String OPTION_SHOWCOLOREDSTRUCTURES = "ShowColoredStructures";
Expand Down Expand Up @@ -486,6 +487,14 @@ public boolean cacheOverride() {
return AppOption.CACHE_OVERRIDE.getBoolValue();
}

/**
* Returns whether the last available symbolic name of an IDS entry is used for display if multiple definitions are
* available.
*/
public boolean showLastIdsSymbol() {
return AppOption.IDS_SYMBOL_DISPLAY.getBoolValue();
}

/** Returns whether the "Add copy of" operation keeps the original resource selected. */
public boolean getKeepViewOnCopy() {
return AppOption.KEEP_VIEW_ON_COPY.getBoolValue();
Expand Down
9 changes: 8 additions & 1 deletion src/org/infinity/util/IdsMapEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import java.util.ArrayDeque;
import java.util.Iterator;

import org.infinity.gui.menu.BrowserMenuBar;

/**
* Mapping from several symbolic names to an integer and vice versa. Used for script purposes and for mapping the file
* index to filename.
Expand All @@ -33,8 +35,13 @@ public int getNumSymbols() {
return symbols.size();
}

/** Returns the first available symbolic name. */
/** Returns the symbolic name depending on the current global option. */
public String getSymbol() {
return BrowserMenuBar.getInstance().getOptions().showLastIdsSymbol() ? getLastSymbol() : getFirstSymbol();
}

/** Returns the first available symbolic name. */
public String getFirstSymbol() {
return symbols.peekFirst();
}

Expand Down

0 comments on commit 57b041e

Please sign in to comment.