mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 02:38:02 +00:00
update new game, save load and settings
This commit is contained in:
@@ -41,7 +41,7 @@ public class NewGameScene extends UIScene {
|
||||
}
|
||||
|
||||
public boolean start() {
|
||||
if(selectedName.getText().isEmpty()) {
|
||||
if (selectedName.getText().isEmpty()) {
|
||||
selectedName.setText(NameGenerator.getRandomName("Any", "Any", ""));
|
||||
}
|
||||
Runnable runnable = new Runnable() {
|
||||
@@ -53,7 +53,7 @@ public class NewGameScene extends UIScene {
|
||||
race.getCurrentIndex(),
|
||||
avatarIndex,
|
||||
deck.getCurrentIndex(),
|
||||
Config.instance().getConfigData().difficulties[difficulty.getCurrentIndex()],0);
|
||||
Config.instance().getConfigData().difficulties[difficulty.getCurrentIndex()], 0);
|
||||
GamePlayerUtil.getGuiPlayer().setName(selectedName.getText());
|
||||
Forge.clearTransitionScreen();
|
||||
Forge.switchScene(SceneType.GameScene.instance);
|
||||
@@ -82,7 +82,7 @@ public class NewGameScene extends UIScene {
|
||||
return NewGameScene.this.updateAvatar();
|
||||
}
|
||||
});
|
||||
Random rand=new Random();
|
||||
Random rand = new Random();
|
||||
|
||||
deck = ui.findActor("deck");
|
||||
|
||||
@@ -104,18 +104,17 @@ public class NewGameScene extends UIScene {
|
||||
difficulty = ui.findActor("difficulty");
|
||||
|
||||
Array<String> diffList = new Array<>(starterDeck.length);
|
||||
int i=0;
|
||||
int startingDifficulty=0;
|
||||
for (DifficultyData diff : Config.instance().getConfigData().difficulties)
|
||||
{
|
||||
if(diff.startingDifficulty)
|
||||
startingDifficulty=i;
|
||||
int i = 0;
|
||||
int startingDifficulty = 0;
|
||||
for (DifficultyData diff : Config.instance().getConfigData().difficulties) {
|
||||
if (diff.startingDifficulty)
|
||||
startingDifficulty = i;
|
||||
diffList.add(diff.name);
|
||||
i++;
|
||||
}
|
||||
difficulty.setTextList(diffList);
|
||||
difficulty.setCurrentIndex(startingDifficulty);
|
||||
avatarIndex=rand.nextInt();
|
||||
avatarIndex = rand.nextInt();
|
||||
gender.setCurrentIndex(rand.nextInt());
|
||||
deck.setCurrentIndex(rand.nextInt());
|
||||
race.setCurrentIndex(rand.nextInt());
|
||||
|
||||
@@ -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,9 +87,16 @@ 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)) {
|
||||
for (IntMap.Entry<TextButton> butt : new IntMap.Entries<TextButton>(buttons)) {
|
||||
butt.value.setColor(defColor);
|
||||
}
|
||||
if (buttons.containsKey(slot)) {
|
||||
@@ -123,18 +129,16 @@ public class SaveLoadScene extends UIScene {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keycode)
|
||||
{
|
||||
if (keycode == Input.Keys.ESCAPE)
|
||||
{
|
||||
back();
|
||||
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);
|
||||
}
|
||||
@@ -147,7 +151,7 @@ public class SaveLoadScene extends UIScene {
|
||||
File f = new File(WorldSave.getSaveDir());
|
||||
f.mkdirs();
|
||||
File[] names = f.listFiles();
|
||||
if(names==null)
|
||||
if (names == null)
|
||||
throw new RuntimeException("Can not find save directory");
|
||||
previews.clear();
|
||||
for (File name : names) {
|
||||
@@ -159,7 +163,7 @@ public class SaveLoadScene extends UIScene {
|
||||
ObjectInputStream oos = new ObjectInputStream(inf)) {
|
||||
|
||||
|
||||
int slot=WorldSave.filenameToSlot(name.getName());
|
||||
int slot = WorldSave.filenameToSlot(name.getName());
|
||||
WorldSaveHeader header = (WorldSaveHeader) oos.readObject();
|
||||
buttons.get(slot).setText(header.name);
|
||||
previews.put(slot, header);
|
||||
@@ -222,12 +226,13 @@ 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();
|
||||
layout.row();
|
||||
autoSave=addSaveSlot("Auto save", WorldSave.AUTO_SAVE_SLOT);
|
||||
quickSave=addSaveSlot("Quick save", WorldSave.QUICK_SAVE_SLOT);
|
||||
autoSave = addSaveSlot("Auto save", WorldSave.AUTO_SAVE_SLOT);
|
||||
quickSave = addSaveSlot("Quick save", WorldSave.QUICK_SAVE_SLOT);
|
||||
for (int i = 1; i < 11; i++)
|
||||
addSaveSlot("Slot:" + i, i);
|
||||
|
||||
|
||||
@@ -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,9 +108,10 @@ 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);
|
||||
private void addSettingSlider(String name, ForgePreferences.FPref pref, int min, int max) {
|
||||
|
||||
Slider slide = Controls.newSlider(min, max, 1, false);
|
||||
slide.setValue(Preference.getPrefInt(pref));
|
||||
slide.addListener(new ChangeListener() {
|
||||
@Override
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Label label = new Label(name, Controls.GetSkin().get("white",Label.LabelStyle.class));
|
||||
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();
|
||||
@@ -165,7 +170,7 @@ public class SettingsScene extends UIScene {
|
||||
SelectBox plane = Controls.newComboBox(Config.instance().getAllAdventures(), Config.instance().getSettingData().plane, new Function<Object, Void>() {
|
||||
@Override
|
||||
public Void apply(Object o) {
|
||||
Config.instance().getSettingData().plane= (String) o;
|
||||
Config.instance().getSettingData().plane = (String) o;
|
||||
Config.instance().saveSettings();
|
||||
return null;
|
||||
}
|
||||
@@ -177,7 +182,7 @@ public class SettingsScene extends UIScene {
|
||||
SelectBox videomode = Controls.newComboBox(new String[]{"720p", "768p", "900p", "1080p"}, Config.instance().getSettingData().videomode, new Function<Object, Void>() {
|
||||
@Override
|
||||
public Void apply(Object o) {
|
||||
String mode = (String)o;
|
||||
String mode = (String) o;
|
||||
if (mode == null)
|
||||
mode = "720p";
|
||||
Config.instance().getSettingData().videomode = mode;
|
||||
@@ -209,7 +214,7 @@ public class SettingsScene extends UIScene {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
boolean value = ((CheckBox) actor).isChecked();
|
||||
Config.instance().getSettingData().fullScreen=value;
|
||||
Config.instance().getSettingData().fullScreen = value;
|
||||
Config.instance().saveSettings();
|
||||
//update
|
||||
if (FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_FULLSCREEN_MODE) != value) {
|
||||
@@ -220,10 +225,10 @@ public class SettingsScene extends UIScene {
|
||||
});
|
||||
}
|
||||
addCheckBox(localizer.getMessage("lblCardName"), ForgePreferences.FPref.UI_OVERLAY_CARD_NAME);
|
||||
addSettingSlider(localizer.getMessage("cbAdjustMusicVolume"), ForgePreferences.FPref.UI_VOL_MUSIC,0,100);
|
||||
addSettingSlider(localizer.getMessage("cbAdjustSoundsVolume"), ForgePreferences.FPref.UI_VOL_SOUNDS, 0,100);
|
||||
addSettingSlider(localizer.getMessage("cbAdjustMusicVolume"), ForgePreferences.FPref.UI_VOL_MUSIC, 0, 100);
|
||||
addSettingSlider(localizer.getMessage("cbAdjustSoundsVolume"), ForgePreferences.FPref.UI_VOL_SOUNDS, 0, 100);
|
||||
addCheckBox(localizer.getMessage("lblManaCost"), ForgePreferences.FPref.UI_OVERLAY_CARD_MANA_COST);
|
||||
addCheckBox(localizer.getMessage("lblPowerOrToughness"), ForgePreferences.FPref.UI_OVERLAY_CARD_POWER);
|
||||
addCheckBox(localizer.getMessage("lblPowerOrToughness"), ForgePreferences.FPref.UI_OVERLAY_CARD_POWER);
|
||||
addCheckBox(localizer.getMessage("lblCardID"), ForgePreferences.FPref.UI_OVERLAY_CARD_ID);
|
||||
addCheckBox(localizer.getMessage("lblAbilityIcon"), ForgePreferences.FPref.UI_OVERLAY_ABILITY_ICONS);
|
||||
addCheckBox(localizer.getMessage("cbImageFetcher"), ForgePreferences.FPref.UI_ENABLE_ONLINE_IMAGE_FETCHER);
|
||||
|
||||
@@ -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
|
||||
}
|
||||
]
|
||||
|
||||
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