Search in sources :

Example 1 with DefaultOptions

use of net.catacombsnatch.game.resource.options.DefaultOptions in project Catacomb-Snatch by Catacomb-Snatch.

the class OptionsScene method init.

public void init(final OptionGroup group) {
    if (group != null)
        for (String k : group.getKeys()) {
            final String key = group.getCurrentPath() + k;
            final Object o = group.get(key);
            if (o instanceof OptionGroup) {
                addTextButton(Language.get("option." + key), 0, 0).addAction(new ReusableAction() {

                    @Override
                    public boolean use(float delta) {
                        OptionsScene scene = SceneManager.switchTo(OptionsScene.class);
                        scene.init((OptionGroup) o);
                        return true;
                    }
                });
            } else if (o instanceof Boolean) {
                final boolean b = (Boolean) o;
                final DefaultOptions option = DefaultOptions.getOption(key);
                final TextButton button = addTextButton(Language.get("option." + key + (b ? ".disable" : ".enable")), 0, 0);
                button.addAction(new ReusableAction() {

                    private boolean down = b;

                    @Override
                    public boolean use(float delta) {
                        down = !down;
                        if (option != null)
                            option.set(down);
                        else
                            group.set(key, down);
                        button.setText(Language.get("option." + key + (down ? ".disable" : ".enable")));
                        return true;
                    }
                });
            }
        // TODO add missing types
        }
    super.init();
}
Also used : TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) OptionGroup(net.catacombsnatch.game.resource.options.OptionGroup) ReusableAction(net.catacombsnatch.game.scene.ReusableAction) DefaultOptions(net.catacombsnatch.game.resource.options.DefaultOptions)

Aggregations

TextButton (com.badlogic.gdx.scenes.scene2d.ui.TextButton)1 DefaultOptions (net.catacombsnatch.game.resource.options.DefaultOptions)1 OptionGroup (net.catacombsnatch.game.resource.options.OptionGroup)1 ReusableAction (net.catacombsnatch.game.scene.ReusableAction)1