Search in sources :

Example 11 with Preferences

use of com.badlogic.gdx.Preferences in project AnotherMonekyParadox by SantiagoMille.

the class PantallaHistoriaAstro method show.

@Override
public void show() {
    crearElementos();
    musicPantalla.setLooping(true);
    Preferences prefs = Gdx.app.getPreferences("AnotherMonkeyPreferenceStory");
    if (prefs.getBoolean("music", true)) {
        musicPantalla.play();
    }
    Gdx.input.setCatchBackKey(true);
}
Also used : Preferences(com.badlogic.gdx.Preferences)

Example 12 with Preferences

use of com.badlogic.gdx.Preferences in project AnotherMonekyParadox by SantiagoMille.

the class PantallaMenu method show.

@Override
public void show() {
    crearCamara();
    crearMenu();
    Preferences prefs = Gdx.app.getPreferences("AnotherMonkeyPreferenceStory");
    batch = new SpriteBatch();
    PantallaSplash.musicMenu.setLooping(true);
    if (prefs.getBoolean("music", true)) {
        PantallaSplash.musicMenu.play();
    }
    inputMultiplexer.addProcessor(new ProcesadorEntrada());
    Gdx.input.setInputProcessor(inputMultiplexer);
    Gdx.input.setCatchBackKey(true);
}
Also used : Preferences(com.badlogic.gdx.Preferences) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch)

Example 13 with Preferences

use of com.badlogic.gdx.Preferences in project AnotherMonekyParadox by SantiagoMille.

the class PantallaScoresStory method crearMenu.

@Override
void crearMenu() {
    super.stageMenu = new Stage(vista);
    title = new Texto(1, 1, 1);
    imgBackground = new Texture("logros.png");
    spriteBackground = new Sprite(imgBackground);
    spriteBackground.setPosition(0, 0);
    // spriteBackground.setAlpha(0.7f);
    // Skin skin = new Skin(Gdx.files.internal("skin/comic-ui.json"));
    Skin skin = new Skin(Gdx.files.internal("skin5/star-soldier-ui.json"));
    // Skin skin = new Skin(Gdx.files.internal("skin2/glassy-ui.json"));
    Preferences prefs = Gdx.app.getPreferences("AnotherMonkeyPreferenceStory");
    String score = prefs.getString("highscores", null);
    ArrayList<String> scoress = new ArrayList<String>();
    if (score == null) {
        // prefs.putString("highscores", "10000");
        scoress.add("Astro:10000");
    } else {
        for (String s : score.split(",")) {
            if (s.length() > 1) {
                scoress.add(s);
            }
        }
    }
    Table table = new Table(skin);
    table.defaults().pad(10f);
    table.setFillParent(true);
    table.setPosition(table.getX(), table.getY() + 130);
    /**
     * Se crean las columnas con puntuajes
     */
    Label columnName;
    Label columnScore;
    ArrayList<String> allScores = new ArrayList<String>();
    ArrayList<String> allNames = new ArrayList<String>();
    for (String s : scoress) {
        allScores.add(s.split(":")[1]);
        allNames.add(s.split(":")[0]);
    }
    int i = 0;
    // table.add(scoresTitle).colspan(2).fillX().height(150);
    table.row();
    for (String name : allNames) {
        columnName = new Label(name + ": ", skin);
        columnName.setFontScale(1.5f, 1.5f);
        table.add(columnName);
        columnScore = new Label(allScores.get(i), skin);
        columnScore.setFontScale(1.5f, 1.5f);
        table.add(columnScore);
        i++;
        table.row();
    }
    // Boton Return
    TextureRegionDrawable trdReturn = new TextureRegionDrawable(new TextureRegion(new Texture("go-back.png")));
    ImageButton btnReturn = new ImageButton(trdReturn);
    btnReturn.setPosition(30, ALTO - 30 - btnReturn.getHeight());
    // Click en boton Return
    btnReturn.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            main.setScreen(new PantallaMenu(main));
        }
    });
    stageMenu.addActor(table);
    stageMenu.addActor(btnReturn);
    Gdx.input.setInputProcessor(stageMenu);
}
Also used : Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Sprite(com.badlogic.gdx.graphics.g2d.Sprite) ArrayList(java.util.ArrayList) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) TextureRegionDrawable(com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable) Texto(mx.itesm.another_monkey_paradox.Utils.Texto) Texture(com.badlogic.gdx.graphics.Texture) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) ImageButton(com.badlogic.gdx.scenes.scene2d.ui.ImageButton) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) Preferences(com.badlogic.gdx.Preferences) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 14 with Preferences

use of com.badlogic.gdx.Preferences in project AnotherMonekyParadox by SantiagoMille.

the class PantallaScoresSurvival method crearMenu.

@Override
void crearMenu() {
    super.stageMenu = new Stage(vista);
    title = new Texto(1, 1, 1);
    imgBackground = new Texture("logros.png");
    spriteBackground = new Sprite(imgBackground);
    spriteBackground.setPosition(0, 0);
    // spriteBackground.setAlpha(0.7f);
    // Skin skin = new Skin(Gdx.files.internal("skin/comic-ui.json"));
    Skin skin = new Skin(Gdx.files.internal("skin5/star-soldier-ui.json"));
    // Skin skin = new Skin(Gdx.files.internal("skin2/glassy-ui.json"));
    Preferences prefs = Gdx.app.getPreferences("AnotherMonkeyPreferenceSurvival");
    String score = prefs.getString("highscores", null);
    ArrayList<String> scoress = new ArrayList<String>();
    if (score == null) {
        // prefs.putString("highscores", "10000");
        scoress.add("Astro:10000");
    } else {
        for (String s : score.split(",")) {
            if (s.length() > 1) {
                scoress.add(s);
            }
        }
    }
    Table table = new Table(skin);
    table.defaults().pad(10f);
    table.setFillParent(true);
    table.setPosition(table.getX(), table.getY() + 130);
    /**
     * Se crean las columnas con puntuajes
     */
    Label columnName;
    Label columnScore;
    ArrayList<String> allScores = new ArrayList<String>();
    ArrayList<String> allNames = new ArrayList<String>();
    for (String s : scoress) {
        allScores.add(s.split(":")[1]);
        allNames.add(s.split(":")[0]);
    }
    int i = 0;
    // table.add(scoresTitle).colspan(2).fillX().height(150);
    table.row();
    for (String name : allNames) {
        columnName = new Label(name + ": ", skin);
        columnName.setFontScale(1.5f, 1.5f);
        table.add(columnName);
        columnScore = new Label(allScores.get(i), skin);
        columnScore.setFontScale(1.5f, 1.5f);
        table.add(columnScore);
        i++;
        table.row();
    }
    // Boton Return
    TextureRegionDrawable trdReturn = new TextureRegionDrawable(new TextureRegion(new Texture("go-back.png")));
    ImageButton btnReturn = new ImageButton(trdReturn);
    btnReturn.setPosition(30, ALTO - 30 - btnReturn.getHeight());
    // Click en boton Return
    btnReturn.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            main.setScreen(new PantallaMenu(main));
        }
    });
    stageMenu.addActor(table);
    stageMenu.addActor(btnReturn);
    Gdx.input.setInputProcessor(stageMenu);
}
Also used : Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Sprite(com.badlogic.gdx.graphics.g2d.Sprite) ArrayList(java.util.ArrayList) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) TextureRegionDrawable(com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable) Texto(mx.itesm.another_monkey_paradox.Utils.Texto) Texture(com.badlogic.gdx.graphics.Texture) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) ImageButton(com.badlogic.gdx.scenes.scene2d.ui.ImageButton) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) Preferences(com.badlogic.gdx.Preferences) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 15 with Preferences

use of com.badlogic.gdx.Preferences in project gdx-skineditor by cobolfoo.

the class MenuBar method showExportDialog.

/*
	 * Show export dialog
	 */
protected void showExportDialog() {
    final Preferences prefs = Gdx.app.getPreferences("skin_editor_project_" + game.screenMain.getcurrentProject());
    final TextField textDirectory = new TextField(prefs.getString("export_to_directory"), game.skin);
    Dialog dlg = new Dialog("Export to Directory", game.skin) {

        @Override
        protected void result(Object object) {
            if ((Boolean) object == true) {
                if (textDirectory.getText().isEmpty() == true) {
                    game.showNotice("Warning", "Directory field is empty!", game.screenMain.stage);
                    return;
                }
                FileHandle targetDirectory = new FileHandle(textDirectory.getText());
                if (targetDirectory.exists() == false) {
                    game.showNotice("Warning", "Directory not found!", game.screenMain.stage);
                    return;
                }
                // Copy uiskin.* and *.fnt
                FileHandle projectFolder = Gdx.files.local("projects").child(game.screenMain.getcurrentProject());
                for (FileHandle file : projectFolder.list()) {
                    if (file.name().startsWith("uiskin.") || (file.extension().equalsIgnoreCase("fnt"))) {
                        Gdx.app.log("MenuBar", "Copying file: " + file.name() + " ...");
                        FileHandle target = targetDirectory.child(file.name());
                        file.copyTo(target);
                    }
                }
                game.showNotice("Operation Completed", "Project successfully exported!", game.screenMain.stage);
            }
        }
    };
    dlg.pad(20);
    Table table = dlg.getContentTable();
    table.padTop(20);
    table.add("Directory:");
    table.add(textDirectory).width(320);
    TextButton buttonChoose = new TextButton("...", game.skin);
    buttonChoose.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            // Need to steal focus first with this hack (Thanks to Z-Man)
            Frame frame = new Frame();
            frame.setUndecorated(true);
            frame.setOpacity(0);
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
            frame.toFront();
            frame.setVisible(false);
            frame.dispose();
            JFileChooser chooser = new JFileChooser();
            chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            int ret = chooser.showOpenDialog(null);
            if (ret == JFileChooser.APPROVE_OPTION) {
                File f = chooser.getSelectedFile();
                textDirectory.setText(f.getAbsolutePath());
                // Store to file
                prefs.putString("export_to_directory", f.getAbsolutePath());
                prefs.flush();
            }
        }
    });
    table.add(buttonChoose);
    table.row();
    table.padBottom(20);
    dlg.button("Export", true);
    dlg.button("Cancel", false);
    dlg.key(com.badlogic.gdx.Input.Keys.ENTER, true);
    dlg.key(com.badlogic.gdx.Input.Keys.ESCAPE, false);
    dlg.show(getStage());
}
Also used : TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) Frame(java.awt.Frame) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) FileHandle(com.badlogic.gdx.files.FileHandle) JFileChooser(javax.swing.JFileChooser) DrawablePickerDialog(org.shadebob.skineditor.DrawablePickerDialog) Dialog(com.badlogic.gdx.scenes.scene2d.ui.Dialog) ColorPickerDialog(org.shadebob.skineditor.ColorPickerDialog) FontPickerDialog(org.shadebob.skineditor.FontPickerDialog) Actor(com.badlogic.gdx.scenes.scene2d.Actor) TextField(com.badlogic.gdx.scenes.scene2d.ui.TextField) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) Preferences(com.badlogic.gdx.Preferences) File(java.io.File)

Aggregations

Preferences (com.badlogic.gdx.Preferences)23 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)7 Texture (com.badlogic.gdx.graphics.Texture)5 Sprite (com.badlogic.gdx.graphics.g2d.Sprite)5 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)5 Bala (mx.itesm.another_monkey_paradox.Objetos.Bala)5 Enemigo (mx.itesm.another_monkey_paradox.Objetos.Enemigo)5 Granada (mx.itesm.another_monkey_paradox.Objetos.Granada)5 Fondo (mx.itesm.another_monkey_paradox.Utils.Fondo)5 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)4 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)4 Stage (com.badlogic.gdx.scenes.scene2d.Stage)4 ImageButton (com.badlogic.gdx.scenes.scene2d.ui.ImageButton)4 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)4 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)4 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)4 TextureRegionDrawable (com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable)4 File (java.io.File)3 ArrayList (java.util.ArrayList)3 GdxRuntimeException (com.badlogic.gdx.utils.GdxRuntimeException)2