Skip to content
This repository has been archived by the owner on Jan 4, 2024. It is now read-only.

Add option to show galaxy file names #4

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/whitehole/MainFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public MainFrame() {
settingsDialog = new SettingsForm(this);
}

private void openGameDir(String gameDir) {
public void openGameDir(String gameDir) {
btnOpenGalaxy.setEnabled(false);
btnBcsvEditor.setEnabled(false);

Expand Down
2 changes: 2 additions & 0 deletions src/whitehole/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ private Settings() {}
public static String getLastGameDir() { return PREFERENCES.get("whitehole_lastGameDir", null); }
public static boolean getSJISNotSupported() { return PREFERENCES.getBoolean("whitehole_sjisNotSupported", false); }
public static boolean getUseDarkMode() { return PREFERENCES.getBoolean("whitehole_useDarkMode", true); }
public static boolean getUseGalaxyFileNames() { return PREFERENCES.getBoolean("whitehole_useGalaxyFileNames", false);}

public static void setLastGameDir(String val) { PREFERENCES.put("whitehole_lastGameDir", val); }
public static void setSJISNotSupported(boolean val) { PREFERENCES.putBoolean("whitehole_sjisNotSupported", val); }
public static void setUseDarkMode(boolean val) { PREFERENCES.putBoolean("whitehole_useDarkMode", val); }
public static void setUseGalaxyFileNames(boolean val) { PREFERENCES.putBoolean("whitehole_useGalaxyFileNames", val); }

// Rendering
public static boolean getShowAxis() { return PREFERENCES.getBoolean("whitehole_showAxis", true); }
Expand Down
17 changes: 17 additions & 0 deletions src/whitehole/SettingsForm.form
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,23 @@
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JCheckBox" name="chkUseGalaxyFileNames">
<Properties>
<Property name="selected" type="boolean" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="Settings.getUseGalaxyFileNames()" type="code"/>
</Property>
<Property name="text" type="java.lang.String" value="Use Galaxy File Names"/>
</Properties>
<Events>
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="chkUseGalaxyFileNamesItemStateChanged"/>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="chkUseGalaxyFileNamesActionPerformed"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="-1" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="2" insetsLeft="2" insetsBottom="2" insetsRight="2" anchor="10" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
</SubComponents>
Expand Down
29 changes: 29 additions & 0 deletions src/whitehole/SettingsForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ private void initComponents() {
btnPosition = new KeybindButton();
btnRotation = new KeybindButton();
btnScale = new KeybindButton();
chkUseGalaxyFileNames = new javax.swing.JCheckBox();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle(String.format("%s -- Settings", Whitehole.NAME));
Expand Down Expand Up @@ -196,6 +197,24 @@ public void itemStateChanged(java.awt.event.ItemEvent evt) {
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
pnlSettings.add(btnScale, gridBagConstraints);

chkUseGalaxyFileNames.setSelected(Settings.getUseGalaxyFileNames());
chkUseGalaxyFileNames.setText("Use Galaxy File Names");
chkUseGalaxyFileNames.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
chkUseGalaxyFileNamesItemStateChanged(evt);
}
});
chkUseGalaxyFileNames.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
chkUseGalaxyFileNamesActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
pnlSettings.add(chkUseGalaxyFileNames, gridBagConstraints);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
Expand Down Expand Up @@ -243,6 +262,15 @@ private void chkUseDarkModeItemStateChanged(java.awt.event.ItemEvent evt) {//GEN
Settings.setUseDarkMode(evt.getStateChange() == ItemEvent.SELECTED);
Whitehole.requestUpdateLAF();
}//GEN-LAST:event_chkUseDarkModeItemStateChanged

private void chkUseGalaxyFileNamesItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_chkUseGalaxyFileNamesItemStateChanged
Settings.setUseGalaxyFileNames(evt.getStateChange() == ItemEvent.SELECTED);
Whitehole.updateGalaxyList();
}//GEN-LAST:event_chkUseGalaxyFileNamesItemStateChanged

private void chkUseGalaxyFileNamesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkUseGalaxyFileNamesActionPerformed

}//GEN-LAST:event_chkUseGalaxyFileNamesActionPerformed

private static class KeybindButton extends JButton {
boolean binding = false;
Expand Down Expand Up @@ -293,6 +321,7 @@ public void setKeyBind(int key) {
private javax.swing.JCheckBox chkDebugFakeColor;
private javax.swing.JCheckBox chkDebugFastDrag;
private javax.swing.JCheckBox chkUseDarkMode;
private javax.swing.JCheckBox chkUseGalaxyFileNames;
private javax.swing.JCheckBox chkUseReverseRot;
private javax.swing.JCheckBox chkUseWASD;
private javax.swing.JLabel lblAppearance;
Expand Down
4 changes: 4 additions & 0 deletions src/whitehole/Whitehole.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ public static void main(String[] args) throws IOException {
MAIN_FRAME.setVisible(true);
}

public static void updateGalaxyList() {
MAIN_FRAME.openGameDir(Settings.getLastGameDir());
}

public static void requestUpdateLAF() {
LookAndFeel next = null;

Expand Down
3 changes: 2 additions & 1 deletion src/whitehole/db/GalaxyNames.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.nio.charset.StandardCharsets;
import org.json.JSONObject;
import org.json.JSONTokener;
import whitehole.Settings;
import whitehole.io.ExternalFilesystem;

public final class GalaxyNames {
Expand Down Expand Up @@ -66,6 +67,6 @@ public static void clearProjectDatabase() {

public static String getSimplifiedStageName(String stage) {
JSONObject dbSrc = projectStageNames != null ? projectStageNames : originalStageNames;
return dbSrc.optString(stage, String.format("\"%s\"", stage));
return !Settings.getUseGalaxyFileNames() ? dbSrc.optString(stage, String.format("\"%s\"", stage)) : stage;
}
}