Search in sources :

Example 6 with AppSettings

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();
}
Also used : AppSettings(com.jme3.system.AppSettings) IOException(java.io.IOException)

Example 7 with AppSettings

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);
}
Also used : AppSettings(com.jme3.system.AppSettings) BackingStoreException(java.util.prefs.BackingStoreException) Mesh(com.jme3.scene.Mesh)

Example 8 with AppSettings

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);
}
Also used : AppSettings(com.jme3.system.AppSettings) ByteArrayInputStream(java.io.ByteArrayInputStream) Mesh(com.jme3.scene.Mesh) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException)

Example 9 with AppSettings

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();
}
Also used : AppSettings(com.jme3.system.AppSettings) TextView(android.widget.TextView)

Example 10 with AppSettings

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();
}
Also used : AppSettings(com.jme3.system.AppSettings)

Aggregations

AppSettings (com.jme3.system.AppSettings)40 LegacyApplication (com.jme3.app.LegacyApplication)5 IOException (java.io.IOException)4 AL (com.jme3.audio.openal.AL)3 ALAudioRenderer (com.jme3.audio.openal.ALAudioRenderer)3 ALC (com.jme3.audio.openal.ALC)3 EFX (com.jme3.audio.openal.EFX)2 MouseInput (com.jme3.input.MouseInput)2 Vector2f (com.jme3.math.Vector2f)2 Mesh (com.jme3.scene.Mesh)2 JmeToJFXApplication (com.jme3x.jfx.injfx.JmeToJFXApplication)2 GraphicsDevice (java.awt.GraphicsDevice)2 BufferedReader (java.io.BufferedReader)2 File (java.io.File)2 InputStream (java.io.InputStream)2 TextView (android.widget.TextView)1 JmeUtil (com.cas.sim.tis.util.JmeUtil)1 SettingsDialog (com.jme3.app.SettingsDialog)1 SelectionListener (com.jme3.app.SettingsDialog.SelectionListener)1 AssetNotFoundException (com.jme3.asset.AssetNotFoundException)1