/** * Get a string from the settings. * <p> * If the key is not set, then null is returned. */ public String getString(String key) { String s = (String) get(key); if (s == null) { return null; } return s; }
/** * Process the attached settings and apply changes to this app state. * @param settings the app settings to process. */ protected void processSettings(AppSettings settings){ if (settings != null){ if (settings.get(VRConstants.SETTING_DISABLE_VR) != null){ DISABLE_VR = settings.getBoolean(VRConstants.SETTING_DISABLE_VR); } } } }
if (settings.get(VRConstants.SETTING_USE_COMPOSITOR) != null){ useCompositor = settings.getBoolean(VRConstants.SETTING_USE_COMPOSITOR); if( useCompositor == false ){ if (settings.get(VRConstants.SETTING_ENABLE_MIRROR_WINDOW) != null){ if( useCompositor == false ) { disableSwapBuffers = false; if (settings.get(VRConstants.SETTING_GUI_OVERDRAW) != null){ getVRGUIManager().setGuiOverdraw(settings.getBoolean(VRConstants.SETTING_GUI_OVERDRAW)); if (settings.get(VRConstants.SETTING_GUI_CURVED_SURFACE) != null){ getVRGUIManager().setCurvedSurface(settings.getBoolean(VRConstants.SETTING_GUI_CURVED_SURFACE)); if (settings.get(VRConstants.SETTING_NO_GUI) != null){ nogui = settings.getBoolean(VRConstants.SETTING_NO_GUI); if (settings.get(VRConstants.SETTING_VRAPI) != null){ vrBinding = settings.getInteger(VRConstants.SETTING_VRAPI); if (settings.get(VRConstants.SETTING_SEATED_EXPERIENCE) != null){ seated = settings.getBoolean(VRConstants.SETTING_SEATED_EXPERIENCE); if (settings.get(VRConstants.SETTING_INSTANCE_RENDERING) != null){ instanceRendering = settings.getBoolean(VRConstants.SETTING_INSTANCE_RENDERING); if (settings.get(VRConstants.SETTING_DEFAULT_FOV) != null){ defaultFOV = settings.getFloat(VRConstants.SETTING_DEFAULT_FOV);
assertEqual(loadedSettings.getInteger("TestInt"), 123); assertEqual(loadedSettings.getString("TestStr"), "HelloWorld"); assertEqual(loadedSettings.get("TestFloat"), 123.567f);
/** * Tests preference based AppSettings. */ private static void testPreferenceSettings() { AppSettings settings = new AppSettings(false); settings.putBoolean("TestBool", true); settings.putInteger("TestInt", 123); settings.putString("TestStr", "HelloWorld"); settings.putFloat("TestFloat", 123.567f); settings.put("TestObj", new Mesh()); // Objects not supported by preferences try { settings.save(APPSETTINGS_KEY); } catch (BackingStoreException ex) { ex.printStackTrace(); } AppSettings loadedSettings = new AppSettings(false); try { loadedSettings.load(APPSETTINGS_KEY); } catch (BackingStoreException ex) { ex.printStackTrace(); } assertEqual(loadedSettings.getBoolean("TestBool"), true); assertEqual(loadedSettings.getInteger("TestInt"), 123); assertEqual(loadedSettings.getString("TestStr"), "HelloWorld"); assertEqual(loadedSettings.get("TestFloat"), 123.567f); }
/** * Get the icon array * @see #setIcons(java.lang.Object[]) */ public Object[] getIcons() { return (Object[]) get("Icons"); }
/** * Get an integer from the settings. * <p> * If the key is not set, then 0 is returned. */ public int getInteger(String key) { Integer i = (Integer) get(key); if (i == null) { return 0; } return i.intValue(); }
/** * Get a float from the settings. * <p> * If the key is not set, then 0.0 is returned. */ public float getFloat(String key) { Float f = (Float) get(key); if (f == null) { return 0f; } return f.floatValue(); }
/** * Get a boolean from the settings. * <p> * If the key is not set, then false is returned. */ public boolean getBoolean(String key) { Boolean b = (Boolean) get(key); if (b == null) { return false; } return b.booleanValue(); }
/** * Same as {@link #copyFrom(com.jme3.system.AppSettings) }, except * doesn't overwrite settings that are already set. * * @param other The AppSettings to merge the settings from */ public void mergeFrom(AppSettings other) { for (String key : other.keySet()) { if( !this.containsKey(key) ) { put(key, other.get(key)); } } }
Object val = get(key); if (val instanceof Integer) { prefs.putInt("I_" + key, (Integer) val);
Object defaultValue = defaults.get(key); if (defaultValue instanceof Integer) { put(key, prefs.getInt(key, (Integer) defaultValue));
private Object getSetting(String key, Object defaultValue) { Object value = settings.get(key); if (value == null) { value = defaultValue; } return value; }
/** * Get a string from the settings. * <p> * If the key is not set, then null is returned. */ public String getString(String key) { String s = (String) get(key); if (s == null) { return null; } return s; }
/** * Get a string from the settings. * <p> * If the key is not set, then null is returned. */ public String getString(String key) { String s = (String) get(key); if (s == null) { return null; } return s; }
/** * Get the icon array * @see #setIcons(java.lang.Object[]) */ public Object[] getIcons() { return (Object[]) get("Icons"); }
/** * Get an integer from the settings. * <p> * If the key is not set, then 0 is returned. */ public int getInteger(String key) { Integer i = (Integer) get(key); if (i == null) { return 0; } return i.intValue(); }
/** * Get a float from the settings. * <p> * If the key is not set, then 0.0 is returned. */ public float getFloat(String key) { Float f = (Float) get(key); if (f == null) { return 0f; } return f.floatValue(); }
/** * Get a boolean from the settings. * <p> * If the key is not set, then false is returned. */ public boolean getBoolean(String key) { Boolean b = (Boolean) get(key); if (b == null) { return false; } return b.booleanValue(); }
/** * Same as {@link #copyFrom(com.jme3.system.AppSettings) }, except * doesn't overwrite settings that are already set. * * @param other The AppSettings to merge the settings from */ public void mergeFrom(AppSettings other) { for (String key : other.keySet()) { if (get(key) == null) { put(key, other.get(key)); } } }