use of com.jme3.system.AppSettings in project jmonkeyengine by jMonkeyEngine.
the class TestChangeAppIcon method main.
public static void main(String[] args) {
TestChangeAppIcon app = new TestChangeAppIcon();
AppSettings settings = new AppSettings(true);
try {
Class<TestChangeAppIcon> clazz = TestChangeAppIcon.class;
settings.setIcons(new BufferedImage[] { ImageIO.read(clazz.getResourceAsStream("/Interface/icons/SmartMonkey256.png")), ImageIO.read(clazz.getResourceAsStream("/Interface/icons/SmartMonkey128.png")), ImageIO.read(clazz.getResourceAsStream("/Interface/icons/SmartMonkey32.png")), ImageIO.read(clazz.getResourceAsStream("/Interface/icons/SmartMonkey16.png")) });
} catch (IOException e) {
log.log(java.util.logging.Level.WARNING, "Unable to load program icons", e);
}
app.setSettings(settings);
app.start();
}
use of com.jme3.system.AppSettings in project jmonkeyengine by jMonkeyEngine.
the class TestCustomAppSettings method testPreferenceSettings.
/**
* 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);
// Objects not supported by preferences
settings.put("TestObj", new Mesh());
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);
}
use of com.jme3.system.AppSettings in project jmonkeyengine by jMonkeyEngine.
the class TestCustomAppSettings method testFileSettings.
/**
* Test Java properties file based AppSettings.
*/
private static void testFileSettings() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
AppSettings settings = new AppSettings(false);
settings.putBoolean("TestBool", true);
settings.putInteger("TestInt", 123);
settings.putString("TestStr", "HelloWorld");
settings.putFloat("TestFloat", 123.567f);
// Objects not supported by file settings
settings.put("TestObj", new Mesh());
try {
settings.save(baos);
} catch (IOException ex) {
ex.printStackTrace();
}
AppSettings loadedSettings = new AppSettings(false);
try {
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
loadedSettings.load(bais);
} catch (IOException ex) {
ex.printStackTrace();
}
assertEqual(loadedSettings.getBoolean("TestBool"), true);
assertEqual(loadedSettings.getInteger("TestInt"), 123);
assertEqual(loadedSettings.getString("TestStr"), "HelloWorld");
assertEqual(loadedSettings.get("TestFloat"), 123.567f);
}
use of com.jme3.system.AppSettings in project jmonkeyengine by jMonkeyEngine.
the class AndroidHarness method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
initializeLogHandler();
logger.fine("onCreate");
super.onCreate(savedInstanceState);
if (screenFullScreen) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
} else {
if (!screenShowTitle) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
}
}
final DataObject data = (DataObject) getLastNonConfigurationInstance();
if (data != null) {
logger.log(Level.FINE, "Using Retained App");
this.app = data.app;
} else {
// Discover the screen reolution
//TODO try to find a better way to get a hand on the resolution
WindowManager wind = this.getWindowManager();
Display disp = wind.getDefaultDisplay();
Log.d("AndroidHarness", "Resolution from Window, width:" + disp.getWidth() + ", height: " + disp.getHeight());
// Create Settings
logger.log(Level.FINE, "Creating settings");
AppSettings settings = new AppSettings(true);
settings.setEmulateMouse(mouseEventsEnabled);
settings.setEmulateMouseFlipAxis(mouseEventsInvertX, mouseEventsInvertY);
settings.setUseJoysticks(joystickEventsEnabled);
settings.setEmulateKeyboard(keyEventsEnabled);
settings.setBitsPerPixel(eglBitsPerPixel);
settings.setAlphaBits(eglAlphaBits);
settings.setDepthBits(eglDepthBits);
settings.setSamples(eglSamples);
settings.setStencilBits(eglStencilBits);
settings.setResolution(disp.getWidth(), disp.getHeight());
settings.setAudioRenderer(audioRendererType);
settings.setFrameRate(frameRate);
// Create application instance
try {
if (app == null) {
@SuppressWarnings("unchecked") Class<? extends LegacyApplication> clazz = (Class<? extends LegacyApplication>) Class.forName(appClass);
app = clazz.newInstance();
}
app.setSettings(settings);
app.start();
} catch (Exception ex) {
handleError("Class " + appClass + " init failed", ex);
setContentView(new TextView(this));
}
}
ctx = (OGLESContext) app.getContext();
view = ctx.createView(this);
// store the glSurfaceView in JmeAndroidSystem for future use
JmeAndroidSystem.setView(view);
// AndroidHarness wraps the app as a SystemListener.
ctx.setSystemListener(this);
layoutDisplay();
}
use of com.jme3.system.AppSettings in project jmonkeyengine by jMonkeyEngine.
the class TestCameraNode method main.
public static void main(String[] args) {
TestCameraNode app = new TestCameraNode();
AppSettings s = new AppSettings(true);
s.setFrameRate(100);
app.setSettings(s);
app.start();
}
Aggregations