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);
}
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);
}
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);
}
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);
}
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());
}
Aggregations