diff --git a/src/mightypork/gamecore/core/Config.java b/src/mightypork/gamecore/core/config/Config.java
similarity index 56%
rename from src/mightypork/gamecore/core/Config.java
rename to src/mightypork/gamecore/core/config/Config.java
index b1d2556..9762953 100644
--- a/src/mightypork/gamecore/core/Config.java
+++ b/src/mightypork/gamecore/core/config/Config.java
@@ -1,4 +1,4 @@
-package mightypork.gamecore.core;
+package mightypork.gamecore.core.config;
import java.io.File;
@@ -6,111 +6,21 @@ import java.util.HashMap;
import java.util.Map;
import mightypork.gamecore.input.KeyStroke;
-import mightypork.gamecore.input.Keys;
-import mightypork.utils.files.config.Property;
import mightypork.utils.files.config.PropertyManager;
import mightypork.utils.logging.Log;
/**
- * Static application configuration
+ * Static application configuration; wrapper around {@link PropertyManager}
*
* @author Ondřej Hruška (MightyPork)
*/
public class Config {
- /**
- * Config setup. Used to populate the config file.
- */
- public static interface ConfigSetup {
-
- void addOptions(PropertyManager prop);
- }
-
- /**
- * Key configurator access
- */
- public static class KeyOpts {
-
- private KeyOpts()
- {
- }
-
-
- public void add(String cfgKey, String dataString)
- {
- add(cfgKey, dataString, null);
- }
-
-
- public void add(String cfgKey, String dataString, String comment)
- {
- final KeyProperty kprop = new KeyProperty(prefixKey(cfgKey), KeyStroke.createFromDataString(dataString), comment);
- strokes.put(prefixKey(cfgKey), kprop);
- cfg.putProperty(kprop);
- }
- }
-
- /**
- * Key configurator
- */
- public static interface KeySetup {
-
- public void addKeys(KeyOpts keys);
- }
-
- /**
- * Key property.
- * The stored value must be invariant ({@link KeyStroke} is mutable).
- *
- * @author Ondřej Hruška (MightyPork)
- */
- public static class KeyProperty extends Property {
-
- public KeyProperty(String key, KeyStroke defaultValue, String comment)
- {
- super(key, defaultValue, comment);
- }
-
-
- @Override
- public KeyStroke decode(String string, KeyStroke defval)
- {
- if (string != null) {
- // keep it invariant
-
- final int backup_key = getValue().getKey();
- final int backup_mod = getValue().getMod();
-
- getValue().fromDataString(string);
- if (getValue().getKey() == Keys.NONE) {
- getValue().setTo(backup_key, backup_mod);
- }
- }
-
- return getValue();
- }
-
-
- @Override
- public String encode(KeyStroke value)
- {
- return value.toDataString();
- }
-
-
- @Override
- public void setValue(Object value)
- {
- // keep it invariant
- getValue().setTo(((KeyStroke) value).getKey(), ((KeyStroke) value).getMod());
- }
- }
-
- public static Config.KeyOpts keyOpts = new Config.KeyOpts();
+ public static KeyOpts keyOpts = new KeyOpts();
public static Map strokes = new HashMap<>();
- private static PropertyManager cfg;
+ static PropertyManager cfg;
/**
@@ -204,7 +114,12 @@ public class Config {
}
- private static String prefixKey(String cfgKey)
+ /**
+ * Add "key." before the given config file key
+ * @param cfgKey config key
+ * @return key. + cfgKey
+ */
+ static String prefixKey(String cfgKey)
{
return "key." + cfgKey;
}
@@ -236,7 +151,7 @@ public class Config {
*/
public static void setKey(String cfgKey, int key, int mod)
{
- final Config.KeyProperty kp = strokes.get(prefixKey(cfgKey));
+ final KeyProperty kp = strokes.get(prefixKey(cfgKey));
if (kp == null) {
throw new IllegalArgumentException("No such stroke: " + cfgKey);
}
diff --git a/src/mightypork/gamecore/core/config/ConfigSetup.java b/src/mightypork/gamecore/core/config/ConfigSetup.java
new file mode 100644
index 0000000..1680753
--- /dev/null
+++ b/src/mightypork/gamecore/core/config/ConfigSetup.java
@@ -0,0 +1,11 @@
+package mightypork.gamecore.core.config;
+
+import mightypork.utils.files.config.PropertyManager;
+
+/**
+ * Config setup, class used to populate the config file.
+ */
+public interface ConfigSetup {
+
+ void addOptions(PropertyManager prop);
+}
\ No newline at end of file
diff --git a/src/mightypork/gamecore/core/config/KeyOpts.java b/src/mightypork/gamecore/core/config/KeyOpts.java
new file mode 100644
index 0000000..a28f3bf
--- /dev/null
+++ b/src/mightypork/gamecore/core/config/KeyOpts.java
@@ -0,0 +1,28 @@
+package mightypork.gamecore.core.config;
+
+import mightypork.gamecore.input.KeyStroke;
+
+/**
+ * Key options - restricted access to {@link Config} for keys
+ */
+public class KeyOpts {
+
+
+ public void add(String cfgKey, String dataString)
+ {
+ add(cfgKey, dataString, null);
+ }
+
+
+ /**
+ * @param cfgKey key in config file
+ * @param dataString string representing the keystroke (format for {@link KeyStroke})
+ * @param comment optional comment
+ */
+ public void add(String cfgKey, String dataString, String comment)
+ {
+ final KeyProperty kprop = new KeyProperty(Config.prefixKey(cfgKey), KeyStroke.createFromDataString(dataString), comment);
+ Config.strokes.put(Config.prefixKey(cfgKey), kprop);
+ Config.cfg.putProperty(kprop);
+ }
+}
\ No newline at end of file
diff --git a/src/mightypork/gamecore/core/config/KeyProperty.java b/src/mightypork/gamecore/core/config/KeyProperty.java
new file mode 100644
index 0000000..d5586ec
--- /dev/null
+++ b/src/mightypork/gamecore/core/config/KeyProperty.java
@@ -0,0 +1,53 @@
+package mightypork.gamecore.core.config;
+
+import mightypork.gamecore.input.KeyStroke;
+import mightypork.gamecore.input.Keys;
+import mightypork.utils.files.config.Property;
+
+/**
+ * Key property.
+ * The stored value must be invariant ({@link KeyStroke} is mutable).
+ *
+ * @author Ondřej Hruška (MightyPork)
+ */
+public class KeyProperty extends Property {
+
+ public KeyProperty(String key, KeyStroke defaultValue, String comment)
+ {
+ super(key, defaultValue, comment);
+ }
+
+
+ @Override
+ public KeyStroke decode(String string, KeyStroke defval)
+ {
+ if (string != null) {
+ // keep it invariant
+
+ final int backup_key = getValue().getKey();
+ final int backup_mod = getValue().getMod();
+
+ getValue().fromDataString(string);
+ if (getValue().getKey() == Keys.NONE) {
+ getValue().setTo(backup_key, backup_mod);
+ }
+ }
+
+ return getValue();
+ }
+
+
+ @Override
+ public String encode(KeyStroke value)
+ {
+ return value.toDataString();
+ }
+
+
+ @Override
+ public void setValue(Object value)
+ {
+ // keep it invariant
+ getValue().setTo(((KeyStroke) value).getKey(), ((KeyStroke) value).getMod());
+ }
+}
\ No newline at end of file
diff --git a/src/mightypork/gamecore/core/config/KeySetup.java b/src/mightypork/gamecore/core/config/KeySetup.java
new file mode 100644
index 0000000..bca57a0
--- /dev/null
+++ b/src/mightypork/gamecore/core/config/KeySetup.java
@@ -0,0 +1,10 @@
+package mightypork.gamecore.core.config;
+
+
+/**
+ * Key configurator. Config access restricted to key options.
+ */
+public interface KeySetup {
+
+ public void addKeys(KeyOpts keys);
+}
\ No newline at end of file
diff --git a/src/mightypork/gamecore/core/modules/BaseApp.java b/src/mightypork/gamecore/core/modules/BaseApp.java
index 97cc7ae..c4128f6 100644
--- a/src/mightypork/gamecore/core/modules/BaseApp.java
+++ b/src/mightypork/gamecore/core/modules/BaseApp.java
@@ -10,11 +10,11 @@ import java.util.logging.Level;
import javax.swing.JOptionPane;
-import mightypork.gamecore.core.Config;
-import mightypork.gamecore.core.Config.ConfigSetup;
-import mightypork.gamecore.core.Config.KeySetup;
import mightypork.gamecore.core.WorkDir;
import mightypork.gamecore.core.WorkDir.RouteSetup;
+import mightypork.gamecore.core.config.Config;
+import mightypork.gamecore.core.config.ConfigSetup;
+import mightypork.gamecore.core.config.KeySetup;
import mightypork.gamecore.gui.screens.ScreenRegistry;
import mightypork.gamecore.gui.screens.impl.CrossfadeOverlay;
import mightypork.gamecore.input.InputSystem;
@@ -66,7 +66,7 @@ public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler {
public String lockFile = ".lock";
private final List resourceLists = new ArrayList<>();
- private final List keyLists = new ArrayList<>();
+ private final List keyLists = new ArrayList<>();
private final List configLists = new ArrayList<>();
private final List routeLists = new ArrayList<>();
@@ -89,7 +89,7 @@ public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler {
}
- public void addKeys(Config.KeySetup keys)
+ public void addKeys(KeySetup keys)
{
keyLists.add(keys);
}
diff --git a/src/mightypork/rogue/RogueApp.java b/src/mightypork/rogue/RogueApp.java
index 49c89d3..6e7cf98 100644
--- a/src/mightypork/rogue/RogueApp.java
+++ b/src/mightypork/rogue/RogueApp.java
@@ -3,7 +3,7 @@ package mightypork.rogue;
import java.io.File;
-import mightypork.gamecore.core.Config;
+import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.core.events.MainLoopRequest;
import mightypork.gamecore.core.events.ShudownRequest;
import mightypork.gamecore.core.events.UserQuitRequest;
diff --git a/src/mightypork/rogue/RogueConfig.java b/src/mightypork/rogue/RogueConfig.java
index 8e08f78..df8141b 100644
--- a/src/mightypork/rogue/RogueConfig.java
+++ b/src/mightypork/rogue/RogueConfig.java
@@ -1,7 +1,7 @@
package mightypork.rogue;
-import mightypork.gamecore.core.Config.ConfigSetup;
+import mightypork.gamecore.core.config.ConfigSetup;
import mightypork.utils.files.config.PropertyManager;
diff --git a/src/mightypork/rogue/RogueKeys.java b/src/mightypork/rogue/RogueKeys.java
index 3653007..5dbb1c9 100644
--- a/src/mightypork/rogue/RogueKeys.java
+++ b/src/mightypork/rogue/RogueKeys.java
@@ -1,11 +1,11 @@
package mightypork.rogue;
-import mightypork.gamecore.core.Config;
-import mightypork.gamecore.core.Config.KeyOpts;
+import mightypork.gamecore.core.config.KeyOpts;
+import mightypork.gamecore.core.config.KeySetup;
-public class RogueKeys implements Config.KeySetup {
+public class RogueKeys implements KeySetup {
@Override
public void addKeys(KeyOpts keys)
diff --git a/src/mightypork/rogue/screens/FpsOverlay.java b/src/mightypork/rogue/screens/FpsOverlay.java
index b33dd9a..eedaa39 100644
--- a/src/mightypork/rogue/screens/FpsOverlay.java
+++ b/src/mightypork/rogue/screens/FpsOverlay.java
@@ -1,7 +1,7 @@
package mightypork.rogue.screens;
-import mightypork.gamecore.core.Config;
+import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.core.modules.AppAccess;
import mightypork.gamecore.gui.Action;
import mightypork.gamecore.gui.AlignX;
diff --git a/src/mightypork/rogue/screens/game/LayerAskSave.java b/src/mightypork/rogue/screens/game/LayerAskSave.java
index 0fc10af..4ba7e22 100644
--- a/src/mightypork/rogue/screens/game/LayerAskSave.java
+++ b/src/mightypork/rogue/screens/game/LayerAskSave.java
@@ -3,7 +3,7 @@ package mightypork.rogue.screens.game;
import java.io.IOException;
-import mightypork.gamecore.core.Config;
+import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.gui.Action;
import mightypork.gamecore.gui.AlignX;
import mightypork.gamecore.gui.components.input.TextButton;
diff --git a/src/mightypork/rogue/screens/game/LayerDeath.java b/src/mightypork/rogue/screens/game/LayerDeath.java
index db2c14f..8ccc78b 100644
--- a/src/mightypork/rogue/screens/game/LayerDeath.java
+++ b/src/mightypork/rogue/screens/game/LayerDeath.java
@@ -3,7 +3,7 @@ package mightypork.rogue.screens.game;
import java.io.IOException;
-import mightypork.gamecore.core.Config;
+import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.gui.Action;
import mightypork.gamecore.gui.AlignX;
import mightypork.gamecore.gui.components.input.TextButton;
diff --git a/src/mightypork/rogue/screens/game/LayerInv.java b/src/mightypork/rogue/screens/game/LayerInv.java
index 7d91c0f..b122eab 100644
--- a/src/mightypork/rogue/screens/game/LayerInv.java
+++ b/src/mightypork/rogue/screens/game/LayerInv.java
@@ -1,7 +1,7 @@
package mightypork.rogue.screens.game;
-import mightypork.gamecore.core.Config;
+import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.gui.AlignX;
import mightypork.gamecore.gui.components.layout.ConstraintLayout;
import mightypork.gamecore.gui.components.layout.FlowColumnLayout;
diff --git a/src/mightypork/rogue/screens/game/LayerWin.java b/src/mightypork/rogue/screens/game/LayerWin.java
index 3bc59ab..4f19b7f 100644
--- a/src/mightypork/rogue/screens/game/LayerWin.java
+++ b/src/mightypork/rogue/screens/game/LayerWin.java
@@ -3,7 +3,7 @@ package mightypork.rogue.screens.game;
import java.io.File;
-import mightypork.gamecore.core.Config;
+import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.gui.Action;
import mightypork.gamecore.gui.AlignX;
import mightypork.gamecore.gui.components.input.TextButton;
diff --git a/src/mightypork/rogue/screens/game/ScreenGame.java b/src/mightypork/rogue/screens/game/ScreenGame.java
index 48ca26f..49daa1b 100644
--- a/src/mightypork/rogue/screens/game/ScreenGame.java
+++ b/src/mightypork/rogue/screens/game/ScreenGame.java
@@ -3,7 +3,7 @@ package mightypork.rogue.screens.game;
import java.io.File;
-import mightypork.gamecore.core.Config;
+import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.core.events.UserQuitRequest;
import mightypork.gamecore.core.modules.AppAccess;
import mightypork.gamecore.gui.Action;
diff --git a/src/mightypork/rogue/screens/menu/ScreenMainMenu.java b/src/mightypork/rogue/screens/menu/ScreenMainMenu.java
index b992654..2b921a7 100644
--- a/src/mightypork/rogue/screens/menu/ScreenMainMenu.java
+++ b/src/mightypork/rogue/screens/menu/ScreenMainMenu.java
@@ -1,7 +1,7 @@
package mightypork.rogue.screens.menu;
-import mightypork.gamecore.core.Config;
+import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.core.events.UserQuitRequest;
import mightypork.gamecore.core.modules.AppAccess;
import mightypork.gamecore.gui.Action;
diff --git a/src/mightypork/rogue/screens/select_world/ScreenSelectWorld.java b/src/mightypork/rogue/screens/select_world/ScreenSelectWorld.java
index 593dbfe..f1db4a6 100644
--- a/src/mightypork/rogue/screens/select_world/ScreenSelectWorld.java
+++ b/src/mightypork/rogue/screens/select_world/ScreenSelectWorld.java
@@ -1,8 +1,8 @@
package mightypork.rogue.screens.select_world;
-import mightypork.gamecore.core.Config;
import mightypork.gamecore.core.WorkDir;
+import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.core.modules.AppAccess;
import mightypork.gamecore.gui.AlignX;
import mightypork.gamecore.gui.components.layout.RowLayout;
diff --git a/src/mightypork/rogue/screens/story/ScreenStory.java b/src/mightypork/rogue/screens/story/ScreenStory.java
index c26b1a6..cfdfb60 100644
--- a/src/mightypork/rogue/screens/story/ScreenStory.java
+++ b/src/mightypork/rogue/screens/story/ScreenStory.java
@@ -1,7 +1,7 @@
package mightypork.rogue.screens.story;
-import mightypork.gamecore.core.Config;
+import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.core.modules.AppAccess;
import mightypork.gamecore.gui.Action;
import mightypork.gamecore.gui.AlignX;
diff --git a/src/mightypork/rogue/world/gui/interaction/MIPKeyboard.java b/src/mightypork/rogue/world/gui/interaction/MIPKeyboard.java
index 916f112..63846c8 100644
--- a/src/mightypork/rogue/world/gui/interaction/MIPKeyboard.java
+++ b/src/mightypork/rogue/world/gui/interaction/MIPKeyboard.java
@@ -5,7 +5,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import mightypork.gamecore.core.Config;
+import mightypork.gamecore.core.config.Config;
import mightypork.gamecore.input.InputSystem;
import mightypork.gamecore.input.KeyBindingPool;
import mightypork.gamecore.input.KeyStroke;