mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
update new game, save load and settings
This commit is contained in:
@@ -106,8 +106,7 @@ public class NewGameScene extends UIScene {
|
|||||||
Array<String> diffList = new Array<>(starterDeck.length);
|
Array<String> diffList = new Array<>(starterDeck.length);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int startingDifficulty = 0;
|
int startingDifficulty = 0;
|
||||||
for (DifficultyData diff : Config.instance().getConfigData().difficulties)
|
for (DifficultyData diff : Config.instance().getConfigData().difficulties) {
|
||||||
{
|
|
||||||
if (diff.startingDifficulty)
|
if (diff.startingDifficulty)
|
||||||
startingDifficulty = i;
|
startingDifficulty = i;
|
||||||
diffList.add(diff.name);
|
diffList.add(diff.name);
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import forge.Forge;
|
|||||||
import forge.adventure.util.Controls;
|
import forge.adventure.util.Controls;
|
||||||
import forge.adventure.world.WorldSave;
|
import forge.adventure.world.WorldSave;
|
||||||
import forge.adventure.world.WorldSaveHeader;
|
import forge.adventure.world.WorldSaveHeader;
|
||||||
|
import forge.gui.GuiBase;
|
||||||
import forge.screens.TransitionScreen;
|
import forge.screens.TransitionScreen;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -30,7 +31,6 @@ import java.util.zip.InflaterInputStream;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Scene to load and save the game.
|
* Scene to load and save the game.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class SaveLoadScene extends UIScene {
|
public class SaveLoadScene extends UIScene {
|
||||||
private final IntMap<TextButton> buttons = new IntMap<>();
|
private final IntMap<TextButton> buttons = new IntMap<>();
|
||||||
@@ -43,17 +43,16 @@ public class SaveLoadScene extends UIScene {
|
|||||||
Label header;
|
Label header;
|
||||||
int currentSlot = -3;
|
int currentSlot = -3;
|
||||||
Image previewImage;
|
Image previewImage;
|
||||||
|
Image previewBorder;
|
||||||
TextButton saveLoadButton;
|
TextButton saveLoadButton;
|
||||||
TextButton quickSave;
|
TextButton quickSave;
|
||||||
TextButton autoSave;
|
TextButton autoSave;
|
||||||
|
|
||||||
public SaveLoadScene() {
|
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) {
|
private TextButton addSaveSlot(String name, int i) {
|
||||||
layout.add(Controls.newLabel(name)).colspan(1).align(Align.right).expandX();
|
layout.add(Controls.newLabel(name)).colspan(1).align(Align.right).expandX();
|
||||||
layout.add(Controls.newLabel(" "));
|
layout.add(Controls.newLabel(" "));
|
||||||
@@ -88,7 +87,14 @@ public class SaveLoadScene extends UIScene {
|
|||||||
if (header.preview != null) {
|
if (header.preview != null) {
|
||||||
previewImage.setDrawable(new TextureRegionDrawable(new Texture(header.preview)));
|
previewImage.setDrawable(new TextureRegionDrawable(new Texture(header.preview)));
|
||||||
previewImage.layout();
|
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)) {
|
for (IntMap.Entry<TextButton> butt : new IntMap.Entries<TextButton>(buttons)) {
|
||||||
butt.value.setColor(defColor);
|
butt.value.setColor(defColor);
|
||||||
@@ -123,18 +129,16 @@ public class SaveLoadScene extends UIScene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean keyPressed(int keycode)
|
public boolean keyPressed(int keycode) {
|
||||||
{
|
if (keycode == Input.Keys.ESCAPE) {
|
||||||
if (keycode == Input.Keys.ESCAPE)
|
|
||||||
{
|
|
||||||
back();
|
back();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
dialog.hide();
|
dialog.hide();
|
||||||
if( WorldSave.getCurrentSave().save(textInput.getText(), currentSlot))
|
if (WorldSave.getCurrentSave().save(textInput.getText(), currentSlot)) {
|
||||||
{
|
|
||||||
updateFiles();
|
updateFiles();
|
||||||
Forge.switchScene(SceneType.GameScene.instance);
|
Forge.switchScene(SceneType.GameScene.instance);
|
||||||
}
|
}
|
||||||
@@ -222,6 +226,7 @@ public class SaveLoadScene extends UIScene {
|
|||||||
})).align(Align.left);
|
})).align(Align.left);
|
||||||
|
|
||||||
previewImage = ui.findActor("preview");
|
previewImage = ui.findActor("preview");
|
||||||
|
previewBorder = ui.findActor("preview_border");
|
||||||
header = Controls.newLabel("Save");
|
header = Controls.newLabel("Save");
|
||||||
header.setHeight(header.getHeight() * 2);
|
header.setHeight(header.getHeight() * 2);
|
||||||
layout.add(header).colspan(3).align(Align.center).expand();
|
layout.add(header).colspan(3).align(Align.center).expand();
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class SettingsScene extends UIScene {
|
|||||||
private Table settingGroup;
|
private Table settingGroup;
|
||||||
|
|
||||||
public SettingsScene() {
|
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
|
@Override
|
||||||
public boolean keyPressed(int keycode)
|
public boolean keyPressed(int keycode) {
|
||||||
{
|
if (keycode == Input.Keys.ESCAPE) {
|
||||||
if (keycode == Input.Keys.ESCAPE)
|
|
||||||
{
|
|
||||||
back();
|
back();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean back() {
|
public boolean back() {
|
||||||
Forge.switchToLast();
|
Forge.switchToLast();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addInputField(String name, ForgePreferences.FPref pref) {
|
private void addInputField(String name, ForgePreferences.FPref pref) {
|
||||||
|
|
||||||
|
|
||||||
@@ -91,6 +91,7 @@ public class SettingsScene extends UIScene {
|
|||||||
addLabel(name);
|
addLabel(name);
|
||||||
settingGroup.add(box).align(Align.right);
|
settingGroup.add(box).align(Align.right);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addCheckBox(String name, ForgePreferences.FPref pref) {
|
private void addCheckBox(String name, ForgePreferences.FPref pref) {
|
||||||
|
|
||||||
|
|
||||||
@@ -107,6 +108,7 @@ public class SettingsScene extends UIScene {
|
|||||||
addLabel(name);
|
addLabel(name);
|
||||||
settingGroup.add(box).align(Align.right);
|
settingGroup.add(box).align(Align.right);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addSettingSlider(String name, ForgePreferences.FPref pref, int min, int max) {
|
private void addSettingSlider(String name, ForgePreferences.FPref pref, int min, int max) {
|
||||||
|
|
||||||
Slider slide = Controls.newSlider(min, max, 1, false);
|
Slider slide = Controls.newSlider(min, max, 1, false);
|
||||||
@@ -121,6 +123,7 @@ public class SettingsScene extends UIScene {
|
|||||||
addLabel(name);
|
addLabel(name);
|
||||||
settingGroup.add(slide).align(Align.right);
|
settingGroup.add(slide).align(Align.right);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addSettingField(String name, boolean value, ChangeListener change) {
|
private void addSettingField(String name, boolean value, ChangeListener change) {
|
||||||
|
|
||||||
CheckBox box = Controls.newCheckBox("");
|
CheckBox box = Controls.newCheckBox("");
|
||||||
@@ -129,6 +132,7 @@ public class SettingsScene extends UIScene {
|
|||||||
addLabel(name);
|
addLabel(name);
|
||||||
settingGroup.add(box).align(Align.right);
|
settingGroup.add(box).align(Align.right);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addSettingField(String name, int value, ChangeListener change) {
|
private void addSettingField(String name, int value, ChangeListener change) {
|
||||||
|
|
||||||
|
|
||||||
@@ -145,14 +149,15 @@ public class SettingsScene extends UIScene {
|
|||||||
addLabel(name);
|
addLabel(name);
|
||||||
settingGroup.add(text).align(Align.right);
|
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));
|
Label label = new Label(name, Controls.GetSkin().get("white", Label.LabelStyle.class));
|
||||||
|
|
||||||
settingGroup.row().space(5);
|
settingGroup.row().space(5);
|
||||||
settingGroup.add(label).align(Align.left).fillX();
|
settingGroup.add(label).align(Align.left).fillX();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resLoaded() {
|
public void resLoaded() {
|
||||||
super.resLoaded();
|
super.resLoaded();
|
||||||
|
|||||||
@@ -145,18 +145,18 @@
|
|||||||
"type": "TextButton",
|
"type": "TextButton",
|
||||||
"name": "back",
|
"name": "back",
|
||||||
"text": "Back",
|
"text": "Back",
|
||||||
"width": 44,
|
"width": 48,
|
||||||
"height": 30,
|
"height": 30,
|
||||||
"x": 38,
|
"x": 36,
|
||||||
"y": 212
|
"y": 212
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "TextButton",
|
"type": "TextButton",
|
||||||
"name": "start",
|
"name": "start",
|
||||||
"text": "Start",
|
"text": "Start",
|
||||||
"width": 44,
|
"width": 48,
|
||||||
"height": 30,
|
"height": 30,
|
||||||
"x": 400,
|
"x": 398,
|
||||||
"y": 212
|
"y": 212
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
60
forge-gui/res/adventure/Shandalar/ui/save_load_mobile.json
Normal file
60
forge-gui/res/adventure/Shandalar/ui/save_load_mobile.json
Normal 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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
30
forge-gui/res/adventure/Shandalar/ui/settings_mobile.json
Normal file
30
forge-gui/res/adventure/Shandalar/ui/settings_mobile.json
Normal 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
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user