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

Commit

Permalink
improved ObjectDB system
Browse files Browse the repository at this point in the history
  • Loading branch information
SunakazeKun committed May 13, 2022
1 parent 938bd1c commit d261b67
Show file tree
Hide file tree
Showing 17 changed files with 464 additions and 280 deletions.
2 changes: 1 addition & 1 deletion data/objectdb.json

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion src/whitehole/MainFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.*;
import javax.swing.*;
import whitehole.db.GalaxyNames;
import whitehole.db.ObjectDB;
import whitehole.editor.BcsvEditorForm;
import whitehole.editor.GalaxyEditorForm;
import whitehole.editor.ObjectSelectForm;
Expand Down Expand Up @@ -68,6 +69,11 @@ private void openGameDir(String gameDir) {
btnOpenGalaxy.setEnabled(false);
btnBcsvEditor.setEnabled(false);

// Reload object database if previous selected game overwrite its data
if (Whitehole.GAME != null && Whitehole.GAME.hasOverwrittenDB()) {
ObjectDB.init(false);
}

// Load game system and store last selected game directory
try {
Whitehole.GAME = new GameArchive(new ExternalFilesystem(gameDir));
Expand Down Expand Up @@ -336,7 +342,7 @@ private void listGalaxyValueChanged(javax.swing.event.ListSelectionEvent evt) {/
}//GEN-LAST:event_listGalaxyValueChanged

private void listGalaxyKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_listGalaxyKeyReleased
if (listGalaxy.getSelectedIndex() != -1) {
if (listGalaxy.getSelectedIndex() == -1) {
return;
}

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

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 setDisplaySimpleNameDB(boolean val) { PREFERENCES.putBoolean("whitehole_displaySimpleNameDB", val); }
public static void setUseDarkMode(boolean val) { PREFERENCES.putBoolean("whitehole_useDarkMode", val); }

// Rendering
Expand Down
16 changes: 0 additions & 16 deletions src/whitehole/SettingsForm.form
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,6 @@
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JCheckBox" name="chkDisplaySimpleNameDB">
<Properties>
<Property name="selected" type="boolean" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="Settings.getDisplaySimpleNameDB()" type="code"/>
</Property>
<Property name="text" type="java.lang.String" value="Display object database names"/>
</Properties>
<Events>
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="chkDisplaySimpleNameDBItemStateChanged"/>
</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>
<Component class="javax.swing.JCheckBox" name="chkDebugFakeColor">
<Properties>
<Property name="selected" type="boolean" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
Expand Down
19 changes: 0 additions & 19 deletions src/whitehole/SettingsForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ private void initComponents() {
lblAppearance = new javax.swing.JLabel();
lblControls = new javax.swing.JLabel();
chkUseDarkMode = new javax.swing.JCheckBox();
chkDisplaySimpleNameDB = new javax.swing.JCheckBox();
chkDebugFakeColor = new javax.swing.JCheckBox();
chkDebugFastDrag = new javax.swing.JCheckBox();
chkUseReverseRot = new javax.swing.JCheckBox();
Expand Down Expand Up @@ -101,19 +100,6 @@ public void itemStateChanged(java.awt.event.ItemEvent evt) {
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
pnlSettings.add(chkUseDarkMode, gridBagConstraints);

chkDisplaySimpleNameDB.setSelected(Settings.getDisplaySimpleNameDB());
chkDisplaySimpleNameDB.setText("Display object database names");
chkDisplaySimpleNameDB.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
chkDisplaySimpleNameDBItemStateChanged(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(chkDisplaySimpleNameDB, gridBagConstraints);

chkDebugFakeColor.setSelected(Settings.getDebugFakeColor());
chkDebugFakeColor.setText("[Debug] Render picking colors");
chkDebugFakeColor.addItemListener(new java.awt.event.ItemListener() {
Expand Down Expand Up @@ -231,10 +217,6 @@ public void itemStateChanged(java.awt.event.ItemEvent evt) {
setLocationRelativeTo(null);
}// </editor-fold>//GEN-END:initComponents

private void chkDisplaySimpleNameDBItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_chkDisplaySimpleNameDBItemStateChanged
Settings.setDisplaySimpleNameDB(evt.getStateChange() == ItemEvent.SELECTED);
}//GEN-LAST:event_chkDisplaySimpleNameDBItemStateChanged

private void chkDebugFakeColorItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_chkDebugFakeColorItemStateChanged
Settings.setDebugFakeColor(evt.getStateChange() == ItemEvent.SELECTED);
}//GEN-LAST:event_chkDebugFakeColorItemStateChanged
Expand Down Expand Up @@ -310,7 +292,6 @@ public void setKeyBind(int key) {
private javax.swing.JButton btnScale;
private javax.swing.JCheckBox chkDebugFakeColor;
private javax.swing.JCheckBox chkDebugFastDrag;
private javax.swing.JCheckBox chkDisplaySimpleNameDB;
private javax.swing.JCheckBox chkUseDarkMode;
private javax.swing.JCheckBox chkUseReverseRot;
private javax.swing.JCheckBox chkUseWASD;
Expand Down
2 changes: 1 addition & 1 deletion src/whitehole/Whitehole.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static void main(String[] args) throws IOException {
// Initialize data
FieldHashes.init();
GalaxyNames.init();
ObjectDB.init();
ObjectDB.init(true);
ModelSubstitutions.init();

MAIN_FRAME = new MainFrame();
Expand Down
Loading

0 comments on commit d261b67

Please sign in to comment.