package de.longri.cachebox3.settings;

public class PlatformSettings {
	// ------ setPlatformSetting ------
	public interface IPlatformSettings {
		public SettingBase<?> Read(SettingBase<?> setting);

		public void Write(SettingBase<?> setting);

	}

	public static IPlatformSettings platformSettingsListener;

	public static void setPlatformSettings(IPlatformSettings listener) {
		platformSettingsListener = listener;
	}

	public static SettingBase<?> ReadSetting(SettingBase<?> setting) {
		if (platformSettingsListener != null)
			setting = platformSettingsListener.Read(setting);
		return setting;
	}

	public static <T> void WriteSetting(SettingBase<T> setting) {
		if (platformSettingsListener != null)
			platformSettingsListener.Write(setting);
	}

	/**
	 * @return True, if platform settings are set
	 */
	public static boolean canUsePlatformSettings() {
		return (platformSettingsListener != null);
	}

}

@@ -38,124 +38,333 @@
 %0D%0A%0D%0A
-public class PlatformSettings %7B%0D%0A%09// ------ setPlatformSetting ------%0D%0A%09public interface IPlatformSettings %7B%0D%0A%09%09publ
+import com.badlogic.gdx.Gdx;%0D%0Aimport com.badlogic.gdx.Preferences;%0D%0A%0D%0Apublic class PlatformSettings %7B%0D%0A%0D%0A%0D%0A    private static Preferences prefs;%0D%0A%0D%0A%0D%0A    private static void checkPrefs() %7B%0D%0A        if (prefs == null) %7B%0D%0A            prefs = Gdx.app.getPreferences(%22CacheboxPreferences%22);%0D%0A        %7D%0D%0A    %7D%0D%0A%0D%0A%0D%0A    public stat
 ic S
@@ -381,16 +381,23 @@
 %3C?%3E Read
+Setting
 (Setting
@@ -416,412 +416,685 @@
 ing)
-;%0D%0A%0D%0A%09%09public void Write(SettingBase%3C?%3E setting);%0D%0A%0D%0A%09%7D%0D%0A%0D%0A%09public static IPlatformSettings platformSettingsListener;%0D%0A%0D%0A%09public static void setPlatformSettings(IPlatformSettings listener) %7B%0D%0A%09%09platformSettingsListener = listener;%0D%0A%09%7D%0D%0A%0D%0A%09public static SettingBase%3C?%3E ReadSetting(SettingBase%3C?%3E setting) %7B%0D%0A%09%09if (platformSettingsListener != null)%0D%0A%09%09%09setting = platformSettingsListener.Read(setting);%0D%0A%09%09
+ %7B%0D%0A        checkPrefs();%0D%0A        if (setting instanceof SettingString) %7B%0D%0A            String value = prefs.getString(setting.getName(), %22%22);%0D%0A            ((SettingString) setting).setValue(value);%0D%0A        %7D else if (setting instanceof SettingBool) %7B%0D%0A            boolean value = prefs.getBoolean(setting.getName(), ((SettingBool) setting).getDefaultValue());%0D%0A            ((SettingBool) setting).setValue(value);%0D%0A        %7D else if (setting instanceof SettingInt) %7B%0D%0A            int value = prefs.getInteger(setting.getName(), ((SettingInt) setting).getDefaultValue());%0D%0A            ((SettingInt) setting).setValue(value);%0D%0A        %7D%0D%0A        setting.clearDirty();%0D%0A        
 retu
@@ -1106,23 +1106,29 @@
 tting;%0D%0A
-%09
+    
 %7D%0D%0A%0D%0A
-%09
+    
 public s
@@ -1186,107 +1186,534 @@
  %7B%0D%0A
-%09%09if (platformSettingsListener != null)%0D%0A%09%09%09platformSettingsListener.Write(setting);%0D%0A%09
+        checkPrefs();%0D%0A%0D%0A        if (setting instanceof SettingBool) %7B%0D%0A            prefs.putBoolean(setting.getName(), ((SettingBool) setting).getValue());%0D%0A        %7D else if (setting instanceof SettingString) %7B%0D%0A            prefs.putString(setting.getName(), ((SettingString) setting).getValue());%0D%0A        %7D else if (setting instanceof SettingInt) %7B%0D%0A            prefs.putInteger(setting.getName(), ((SettingInt) setting).getValue());%0D%0A        %7D%0D%0A        // Commit the edits!%0D%0A        prefs.flush();%0D%0A    
 %7D%0D%0A%0D%0A
-%09
+    
 /**%0D%0A
-%09
+    
  * @
@@ -1759,15 +1759,21 @@
 et%0D%0A
-%09
+    
  */%0D%0A
-%09
+    
 publ
@@ -1822,55 +1822,34 @@
  %7B%0D%0A
-%09%09return (platformSettingsListener != null);%0D%0A%09
+        return true;%0D%0A    
 %7D%0D%0A%0D

implement PlatformSettings