update new game, save load and settings

This commit is contained in:
Anthony Calosa
2022-02-23 16:09:55 +08:00
parent dc4eed4b08
commit aa0fca7b68
6 changed files with 145 additions and 46 deletions

View File

@@ -106,8 +106,7 @@ public class NewGameScene extends UIScene {
Array<String> diffList = new Array<>(starterDeck.length);
int i = 0;
int startingDifficulty = 0;
for (DifficultyData diff : Config.instance().getConfigData().difficulties)
{
for (DifficultyData diff : Config.instance().getConfigData().difficulties) {
if (diff.startingDifficulty)
startingDifficulty = i;
diffList.add(diff.name);

View File

@@ -20,6 +20,7 @@ import forge.Forge;
import forge.adventure.util.Controls;
import forge.adventure.world.WorldSave;
import forge.adventure.world.WorldSaveHeader;
import forge.gui.GuiBase;
import forge.screens.TransitionScreen;
import java.io.File;
@@ -30,7 +31,6 @@ import java.util.zip.InflaterInputStream;
/**
* Scene to load and save the game.
*
*/
public class SaveLoadScene extends UIScene {
private final IntMap<TextButton> buttons = new IntMap<>();
@@ -43,17 +43,16 @@ public class SaveLoadScene extends UIScene {
Label header;
int currentSlot = -3;
Image previewImage;
Image previewBorder;
TextButton saveLoadButton;
TextButton quickSave;
TextButton autoSave;
public SaveLoadScene() {
super("ui/save_load.json");
super(GuiBase.isAndroid() ? "ui/save_load_mobile.json" : "ui/save_load.json");
}
private TextButton addSaveSlot(String name, int i) {
layout.add(Controls.newLabel(name)).colspan(1).align(Align.right).expandX();
layout.add(Controls.newLabel(" "));
@@ -88,7 +87,14 @@ public class SaveLoadScene extends UIScene {
if (header.preview != null) {
previewImage.setDrawable(new TextureRegionDrawable(new Texture(header.preview)));
previewImage.layout();
previewImage.setVisible(true);
previewBorder.setVisible(true);
}
} else {
if (previewImage != null)
previewImage.setVisible(false);
if (previewBorder != null)
previewBorder.setVisible(false);
}
for (IntMap.Entry<TextButton> butt : new IntMap.Entries<TextButton>(buttons)) {
butt.value.setColor(defColor);
@@ -123,18 +129,16 @@ public class SaveLoadScene extends UIScene {
}
@Override
public boolean keyPressed(int keycode)
{
if (keycode == Input.Keys.ESCAPE)
{
public boolean keyPressed(int keycode) {
if (keycode == Input.Keys.ESCAPE) {
back();
}
return true;
}
public void save() {
dialog.hide();
if( WorldSave.getCurrentSave().save(textInput.getText(), currentSlot))
{
if (WorldSave.getCurrentSave().save(textInput.getText(), currentSlot)) {
updateFiles();
Forge.switchScene(SceneType.GameScene.instance);
}
@@ -222,6 +226,7 @@ public class SaveLoadScene extends UIScene {
})).align(Align.left);
previewImage = ui.findActor("preview");
previewBorder = ui.findActor("preview_border");
header = Controls.newLabel("Save");
header.setHeight(header.getHeight() * 2);
layout.add(header).colspan(3).align(Align.center).expand();

View File

@@ -37,7 +37,7 @@ public class SettingsScene extends UIScene {
private Table settingGroup;
public SettingsScene() {
super("ui/settings.json");
super(GuiBase.isAndroid() ? "ui/settings_mobile.json" : "ui/settings.json");
}
@@ -63,18 +63,18 @@ public class SettingsScene extends UIScene {
}
@Override
public boolean keyPressed(int keycode)
{
if (keycode == Input.Keys.ESCAPE)
{
public boolean keyPressed(int keycode) {
if (keycode == Input.Keys.ESCAPE) {
back();
}
return true;
}
public boolean back() {
Forge.switchToLast();
return true;
}
private void addInputField(String name, ForgePreferences.FPref pref) {
@@ -91,6 +91,7 @@ public class SettingsScene extends UIScene {
addLabel(name);
settingGroup.add(box).align(Align.right);
}
private void addCheckBox(String name, ForgePreferences.FPref pref) {
@@ -107,6 +108,7 @@ public class SettingsScene extends UIScene {
addLabel(name);
settingGroup.add(box).align(Align.right);
}
private void addSettingSlider(String name, ForgePreferences.FPref pref, int min, int max) {
Slider slide = Controls.newSlider(min, max, 1, false);
@@ -121,6 +123,7 @@ public class SettingsScene extends UIScene {
addLabel(name);
settingGroup.add(slide).align(Align.right);
}
private void addSettingField(String name, boolean value, ChangeListener change) {
CheckBox box = Controls.newCheckBox("");
@@ -129,6 +132,7 @@ public class SettingsScene extends UIScene {
addLabel(name);
settingGroup.add(box).align(Align.right);
}
private void addSettingField(String name, int value, ChangeListener change) {
@@ -145,14 +149,15 @@ public class SettingsScene extends UIScene {
addLabel(name);
settingGroup.add(text).align(Align.right);
}
void addLabel( String name)
{
void addLabel(String name) {
Label label = new Label(name, Controls.GetSkin().get("white", Label.LabelStyle.class));
settingGroup.row().space(5);
settingGroup.add(label).align(Align.left).fillX();
}
@Override
public void resLoaded() {
super.resLoaded();

View File

@@ -145,18 +145,18 @@
"type": "TextButton",
"name": "back",
"text": "Back",
"width": 44,
"width": 48,
"height": 30,
"x": 38,
"x": 36,
"y": 212
},
{
"type": "TextButton",
"name": "start",
"text": "Start",
"width": 44,
"width": 48,
"height": 30,
"x": 400,
"x": 398,
"y": 212
}
]

View File

@@ -0,0 +1,60 @@
{
"width": 480,
"height": 270,
"yDown": true,
"elements": [
{
"type": "Image",
"image": "ui/title_bg.png",
"width": 480,
"height": 270
},
{
"type": "Scroll",
"name": "saveSlots",
"x": 25,
"y": 18,
"width": 430,
"height": 235
},
{
"type": "Image",
"name" : "preview_border",
"image": "ui/avatarhud.png",
"width": 96,
"height": 54,
"x": 350,
"y": 26
},
{
"type": "Image",
"name": "preview",
"width": 86,
"height": 48,
"x": 356,
"y": 29
},
{
"type": "TextButton",
"name": "return",
"text": "Back",
"width": 48,
"height": 30,
"x": 36,
"y": 212
},
{
"type": "TextButton",
"name": "save",
"text": "saveLoad",
"width": 48,
"height": 30,
"x": 398,
"y": 212
},
{
"type": "Table",
"font": "default"
}
]
}

View File

@@ -0,0 +1,30 @@
{
"width": 480,
"height": 270,
"yDown": true,
"elements": [
{
"type": "Image",
"image": "ui/title_bg.png",
"width": 480,
"height": 270
},
{
"type": "Scroll",
"name": "settings",
"x": 25,
"y": 18,
"width": 430,
"height": 235
},
{
"type": "ImageButton",
"name": "return",
"style": "leftarrow",
"width": 32,
"height": 32,
"x": 25,
"y": 220
}
]
}