Many UI changes, WIP main menu rework
|
Before Width: | Height: | Size: 215 B After Width: | Height: | Size: 201 B |
BIN
core/assets-raw/sprites/blocks/chainturret-icon.png
Normal file
|
After Width: | Height: | Size: 259 B |
BIN
core/assets-raw/sprites/blocks/chainturret.png
Normal file
|
After Width: | Height: | Size: 541 B |
BIN
core/assets-raw/sprites/ui/border.9.png
Normal file
|
After Width: | Height: | Size: 195 B |
|
Before Width: | Height: | Size: 197 B After Width: | Height: | Size: 198 B |
BIN
core/assets-raw/sprites/ui/window-empty.9.png
Normal file
|
After Width: | Height: | Size: 249 B |
BIN
core/assets/maps/maze2.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
core/assets/maps/maze3.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
core/assets/maps/maze4.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
core/assets/maps/maze5.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
@@ -20,7 +20,7 @@ com.badlogic.gdx.graphics.Color: {
|
|||||||
link-label: {a: 1, b: 0.886, g: 0.631, r: 0.105 }
|
link-label: {a: 1, b: 0.886, g: 0.631, r: 0.105 }
|
||||||
},
|
},
|
||||||
io.anuke.ucore.scene.Skin$TintedDrawable: {
|
io.anuke.ucore.scene.Skin$TintedDrawable: {
|
||||||
dialogDim: {name: white, color: {r: 0, g: 0, b: 0, a: 0.45} }
|
dialogDim: {name: white, color: {r: 0, g: 0, b: 0, a: 0.9} }
|
||||||
loadDim: {name: white, color: {r: 0, g: 0, b: 0, a: 0.7} }
|
loadDim: {name: white, color: {r: 0, g: 0, b: 0, a: 0.7} }
|
||||||
},
|
},
|
||||||
io.anuke.ucore.scene.ui.Button$ButtonStyle: {
|
io.anuke.ucore.scene.ui.Button$ButtonStyle: {
|
||||||
@@ -33,10 +33,11 @@ io.anuke.ucore.scene.ui.TextButton$TextButtonStyle: {
|
|||||||
},
|
},
|
||||||
io.anuke.ucore.scene.ui.ImageButton$ImageButtonStyle: {
|
io.anuke.ucore.scene.ui.ImageButton$ImageButtonStyle: {
|
||||||
default: {down: button-down, up: button, over: button-over },
|
default: {down: button-down, up: button, over: button-over },
|
||||||
|
empty: {},
|
||||||
static: {up: button },
|
static: {up: button },
|
||||||
static-down: {up: button-down },
|
static-down: {up: button-down },
|
||||||
toggle: {checked: button-down, down: button-down, up: button },
|
toggle: {checked: button-down, down: button-down, up: button },
|
||||||
togglemap: {checked: button-map-down, down: button-map-down, up: button-map },
|
togglemap: {down: button-map-down, up: button-map },
|
||||||
select: {checked: button-select, up: clear },
|
select: {checked: button-select, up: clear },
|
||||||
close-window: {up: button, imageUp: icon-close, imageOver: icon-close-over, imageDown: icon-close-down, disabled: button }
|
close-window: {up: button, imageUp: icon-close, imageOver: icon-close-over, imageDown: icon-close-down, disabled: button }
|
||||||
},
|
},
|
||||||
@@ -45,11 +46,11 @@ io.anuke.ucore.scene.ui.ImageTextButton$ImageTextButtonStyle: {
|
|||||||
toggle: {checked: button-down, down: button-down, up: button, font: default-font, fontColor: white, over: button-over, disabled: button, disabledFontColor: grey }
|
toggle: {checked: button-down, down: button-down, up: button, font: default-font, fontColor: white, over: button-over, disabled: button, disabledFontColor: grey }
|
||||||
},
|
},
|
||||||
io.anuke.ucore.scene.ui.ScrollPane$ScrollPaneStyle: {
|
io.anuke.ucore.scene.ui.ScrollPane$ScrollPaneStyle: {
|
||||||
default: {vScroll: scroll, vScrollKnob: scroll-knob-vertical, hScroll: scroll-horizontal, hScrollKnob: scroll-knob-horizontal }
|
default: {background: border}
|
||||||
},
|
},
|
||||||
io.anuke.ucore.scene.ui.Window$WindowStyle: {
|
io.anuke.ucore.scene.ui.Window$WindowStyle: {
|
||||||
default: {titleFont: default-font, background: window, titleFontColor: orange },
|
default: {titleFont: default-font, background: window, titleFontColor: orange },
|
||||||
dialog: {stageBackground: dialogDim, titleFont: default-font, background: window, titleFontColor: orange }
|
dialog: {stageBackground: dialogDim, titleFont: default-font, background: window-empty, titleFontColor: orange }
|
||||||
},
|
},
|
||||||
io.anuke.ucore.scene.ui.KeybindDialog$KeybindDialogStyle: {
|
io.anuke.ucore.scene.ui.KeybindDialog$KeybindDialogStyle: {
|
||||||
default: {keyColor: red, keyNameColor: white},
|
default: {keyColor: red, keyNameColor: white},
|
||||||
|
|||||||
@@ -32,13 +32,15 @@ import io.anuke.ucore.scene.builders.*;
|
|||||||
import io.anuke.ucore.scene.event.Touchable;
|
import io.anuke.ucore.scene.event.Touchable;
|
||||||
import io.anuke.ucore.scene.ui.*;
|
import io.anuke.ucore.scene.ui.*;
|
||||||
import io.anuke.ucore.scene.ui.Window.WindowStyle;
|
import io.anuke.ucore.scene.ui.Window.WindowStyle;
|
||||||
import io.anuke.ucore.scene.ui.layout.*;
|
import io.anuke.ucore.scene.ui.layout.Stack;
|
||||||
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
|
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
public class UI extends SceneModule{
|
public class UI extends SceneModule{
|
||||||
Table itemtable, weapontable, tools, loadingtable, desctable, respawntable, configtable;
|
Table itemtable, weapontable, tools, loadingtable, desctable, respawntable, configtable;
|
||||||
SettingsDialog prefs;
|
MindustrySettingsDialog prefs;
|
||||||
KeybindDialog keys;
|
MindustryKeybindDialog keys;
|
||||||
Dialog about, restart, levels, upgrades, load, settingserror;
|
Dialog about, restart, levels, upgrades, load, settingserror;
|
||||||
MenuDialog menu;
|
MenuDialog menu;
|
||||||
Tooltip tooltip;
|
Tooltip tooltip;
|
||||||
@@ -51,15 +53,23 @@ public class UI extends SceneModule{
|
|||||||
private Array<Item> tempItems = new Array<>();
|
private Array<Item> tempItems = new Array<>();
|
||||||
|
|
||||||
public UI() {
|
public UI() {
|
||||||
Dialog.setShowAction(()-> sequence(Actions.moveToAligned(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), Align.center),
|
Dialog.setShowAction(()-> sequence(
|
||||||
parallel(Actions.moveToAligned(Gdx.graphics.getWidth()/2,
|
alpha(0f),
|
||||||
Gdx.graphics.getHeight()/2, Align.center, 0.09f, Interpolation.fade),
|
originCenter(),
|
||||||
|
moveToAligned(Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/2, Align.center),
|
||||||
Actions.fadeIn(0.09f, Interpolation.fade))));
|
scaleTo(0.0f, 1f),
|
||||||
|
parallel(
|
||||||
|
scaleTo(1f, 1f, 0.1f, Interpolation.fade),
|
||||||
|
fadeIn(0.1f, Interpolation.fade)
|
||||||
|
)
|
||||||
|
));
|
||||||
|
|
||||||
Dialog.setHideAction(()-> sequence(
|
Dialog.setHideAction(()-> sequence(
|
||||||
parallel(Actions.moveBy(0, -Gdx.graphics.getHeight()/2, 0.08f, Interpolation.fade),
|
parallel(
|
||||||
Actions.fadeOut(0.08f, Interpolation.fade))));
|
scaleTo(0.01f, 0.01f, 0.1f, Interpolation.fade),
|
||||||
|
fadeOut(0.1f, Interpolation.fade)
|
||||||
|
)
|
||||||
|
));
|
||||||
|
|
||||||
skin.font().setUseIntegerPositions(false);
|
skin.font().setUseIntegerPositions(false);
|
||||||
skin.font().getData().setScale(Vars.fontscale);
|
skin.font().getData().setScale(Vars.fontscale);
|
||||||
@@ -146,7 +156,7 @@ public class UI extends SceneModule{
|
|||||||
|
|
||||||
levels = new LevelDialog();
|
levels = new LevelDialog();
|
||||||
|
|
||||||
prefs = new SettingsDialog();
|
prefs = new MindustrySettingsDialog();
|
||||||
prefs.setStyle(Core.skin.get("dialog", WindowStyle.class));
|
prefs.setStyle(Core.skin.get("dialog", WindowStyle.class));
|
||||||
|
|
||||||
menu = new MenuDialog();
|
menu = new MenuDialog();
|
||||||
@@ -180,12 +190,14 @@ public class UI extends SceneModule{
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
keys = new KeybindDialog();
|
keys = new MindustryKeybindDialog();
|
||||||
|
|
||||||
about = new TextDialog("About", aboutText);
|
about = new FloatingDialog("About");
|
||||||
|
about.addCloseButton();
|
||||||
for(Cell<?> cell : about.content().getCells())
|
for(String text : aboutText){
|
||||||
cell.left();
|
about.content().add(text).left();
|
||||||
|
about.content().row();
|
||||||
|
}
|
||||||
|
|
||||||
restart = new Dialog("The core was destroyed.", "dialog");
|
restart = new Dialog("The core was destroyed.", "dialog");
|
||||||
|
|
||||||
@@ -440,12 +452,6 @@ public class UI extends SceneModule{
|
|||||||
row();
|
row();
|
||||||
}
|
}
|
||||||
|
|
||||||
new button("About", () -> {
|
|
||||||
about.show(scene);
|
|
||||||
});
|
|
||||||
|
|
||||||
row();
|
|
||||||
|
|
||||||
if(Gdx.app.getType() != ApplicationType.WebGL && !android){
|
if(Gdx.app.getType() != ApplicationType.WebGL && !android){
|
||||||
new button("Exit", () -> {
|
new button("Exit", () -> {
|
||||||
Gdx.app.exit();
|
Gdx.app.exit();
|
||||||
@@ -455,9 +461,17 @@ public class UI extends SceneModule{
|
|||||||
get().pad(Unit.dp.inPixels(16));
|
get().pad(Unit.dp.inPixels(16));
|
||||||
}};
|
}};
|
||||||
|
|
||||||
get().setVisible(nplay);
|
visible(nplay);
|
||||||
}}.end();
|
}}.end();
|
||||||
|
|
||||||
|
//settings icon
|
||||||
|
new table(){{
|
||||||
|
atop().aright();
|
||||||
|
new imagebutton("icon-settings", Unit.dp.inPixels(40f), ()->{
|
||||||
|
about.show();
|
||||||
|
}).get().pad(14).padTop(8);
|
||||||
|
}}.end().visible(nplay);
|
||||||
|
|
||||||
if(debug){
|
if(debug){
|
||||||
new table(){{
|
new table(){{
|
||||||
abottom();
|
abottom();
|
||||||
|
|||||||
@@ -48,11 +48,11 @@ public class Vars{
|
|||||||
public static Player player;
|
public static Player player;
|
||||||
|
|
||||||
public static String[] aboutText = {
|
public static String[] aboutText = {
|
||||||
"Made by [ROYAL]Anuken[] for the" + "\nGDL Metal Monstrosity jam.",
|
"Created by [ROYAL]Anuken.[]",
|
||||||
|
"Originally an entry in the [orange]GDL[] MM Jam.",
|
||||||
"",
|
"",
|
||||||
"Sources used:",
|
"Credits:",
|
||||||
"- [YELLOW]bfxr.com[] for sound effects",
|
"- SFX made with [YELLOW]bfxr.com[]",
|
||||||
"- [RED]freemusicarchive.org[] for music",
|
|
||||||
"- Music made by [GREEN]RoccoW[]",
|
"- Music made by [GREEN]RoccoW[]",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ public enum Recipe{
|
|||||||
mortarturret(weapon, WeaponBlocks.mortarturret, stack(Item.steel, 20), stack(Item.titanium, 15)),
|
mortarturret(weapon, WeaponBlocks.mortarturret, stack(Item.steel, 20), stack(Item.titanium, 15)),
|
||||||
teslaturret(weapon, WeaponBlocks.teslaturret, stack(Item.steel, 10), stack(Item.titanium, 15), stack(Item.dirium, 15)),
|
teslaturret(weapon, WeaponBlocks.teslaturret, stack(Item.steel, 10), stack(Item.titanium, 15), stack(Item.dirium, 15)),
|
||||||
plasmaturret(weapon, WeaponBlocks.plasmaturret, stack(Item.steel, 10), stack(Item.titanium, 10), stack(Item.dirium, 15)),
|
plasmaturret(weapon, WeaponBlocks.plasmaturret, stack(Item.steel, 10), stack(Item.titanium, 10), stack(Item.dirium, 15)),
|
||||||
|
chainturret(weapon, WeaponBlocks.chainturret, stack(Item.steel, 10), stack(Item.titanium, 10), stack(Item.dirium, 15)),
|
||||||
|
rocketturret(weapon, WeaponBlocks.plasmaturret, stack(Item.steel, 10), stack(Item.titanium, 10), stack(Item.dirium, 15)),
|
||||||
|
|
||||||
smelter(crafting, ProductionBlocks.smelter, stack(Item.stone, 40), stack(Item.iron, 40)),
|
smelter(crafting, ProductionBlocks.smelter, stack(Item.stone, 40), stack(Item.iron, 40)),
|
||||||
crucible(crafting, ProductionBlocks.crucible, stack(Item.titanium, 40), stack(Item.steel, 40)),
|
crucible(crafting, ProductionBlocks.crucible, stack(Item.titanium, 40), stack(Item.steel, 40)),
|
||||||
|
|||||||
33
core/src/io/anuke/mindustry/ui/FloatingDialog.java
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
package io.anuke.mindustry.ui;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Input.Keys;
|
||||||
|
import com.badlogic.gdx.graphics.Color;
|
||||||
|
import com.badlogic.gdx.utils.Align;
|
||||||
|
|
||||||
|
import io.anuke.ucore.scene.ui.Dialog;
|
||||||
|
import io.anuke.ucore.scene.ui.Image;
|
||||||
|
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||||
|
|
||||||
|
public class FloatingDialog extends Dialog{
|
||||||
|
|
||||||
|
public FloatingDialog(String title){
|
||||||
|
super(title, "dialog");
|
||||||
|
setFillParent(true);
|
||||||
|
title().setAlignment(Align.center);
|
||||||
|
getTitleTable().row();
|
||||||
|
getTitleTable().add(new Image("white"))
|
||||||
|
.growX().height(3f).pad(4f).units(Unit.dp).get().setColor(Color.ORANGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addCloseButton(){
|
||||||
|
buttons().addImageTextButton("Back", "icon-arrow-left", Unit.dp.inPixels(30f), ()->{
|
||||||
|
hide();
|
||||||
|
}).size(230f, 64f).units(Unit.dp);
|
||||||
|
|
||||||
|
keyDown(key->{
|
||||||
|
if(key == Keys.ESCAPE || key == Keys.BACK)
|
||||||
|
hide();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,56 +5,70 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
|||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.world.Map;
|
import io.anuke.mindustry.world.Map;
|
||||||
import io.anuke.mindustry.world.World;
|
import io.anuke.mindustry.world.World;
|
||||||
|
import io.anuke.ucore.core.Core;
|
||||||
import io.anuke.ucore.core.Settings;
|
import io.anuke.ucore.core.Settings;
|
||||||
|
import io.anuke.ucore.core.Timers;
|
||||||
import io.anuke.ucore.function.StringSupplier;
|
import io.anuke.ucore.function.StringSupplier;
|
||||||
import io.anuke.ucore.scene.ui.ButtonGroup;
|
|
||||||
import io.anuke.ucore.scene.ui.Dialog;
|
|
||||||
import io.anuke.ucore.scene.ui.ImageButton;
|
import io.anuke.ucore.scene.ui.ImageButton;
|
||||||
|
import io.anuke.ucore.scene.ui.ScrollPane;
|
||||||
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||||
|
|
||||||
public class LevelDialog extends Dialog{
|
public class LevelDialog extends FloatingDialog{
|
||||||
private Map selectedMap = Map.delta;
|
private Map selectedMap = Map.delta;
|
||||||
|
private TextureRegion region = new TextureRegion();
|
||||||
|
|
||||||
public LevelDialog(){
|
public LevelDialog(){
|
||||||
super("Level Select");
|
super("Level Select");
|
||||||
|
getTitleTable().getCell(title()).growX().center();
|
||||||
|
getTitleTable().center();
|
||||||
setup();
|
setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup(){
|
void setup(){
|
||||||
addCloseButton();
|
addCloseButton();
|
||||||
getButtonTable().addButton("Play", ()->{
|
Table maps = new Table();
|
||||||
hide();
|
ScrollPane pane = new ScrollPane(maps);
|
||||||
Vars.control.playMap(selectedMap);
|
|
||||||
}).pad(3).size(180, 44).units(Unit.dp);
|
|
||||||
|
|
||||||
ButtonGroup<ImageButton> mapgroup = new ButtonGroup<>();
|
int maxwidth = 4;
|
||||||
|
|
||||||
|
for(int i = 0; i < Map.values().length; i ++){
|
||||||
|
Map map = Map.values()[i];
|
||||||
|
|
||||||
for(Map map : Map.values()){
|
|
||||||
if(!map.visible) continue;
|
if(!map.visible) continue;
|
||||||
|
|
||||||
content().add(map.name());
|
if(i % maxwidth == 0){
|
||||||
}
|
maps.row();
|
||||||
|
}
|
||||||
|
|
||||||
content().row();
|
Table inset = new Table("pane");
|
||||||
|
inset.add("[orange]"+map.name()).pad(3f).units(Unit.dp);
|
||||||
|
inset.row();
|
||||||
|
inset.add((StringSupplier)(()->"High Score: [lime]" + Settings.getInt("hiscore" + map.name())))
|
||||||
|
.pad(3f).units(Unit.dp);
|
||||||
|
inset.pack();
|
||||||
|
|
||||||
for(Map map : Map.values()){
|
float images = Unit.dp.inPixels(154);
|
||||||
if(!map.visible) continue;
|
|
||||||
|
|
||||||
ImageButton image = new ImageButton(new TextureRegion(World.getTexture(map)), "togglemap");
|
ImageButton image = new ImageButton(new TextureRegion(World.getTexture(map)), "togglemap");
|
||||||
mapgroup.add(image);
|
image.row();
|
||||||
|
image.add(inset).width(images+6);
|
||||||
image.clicked(()->{
|
image.clicked(()->{
|
||||||
selectedMap = map;
|
selectedMap = map;
|
||||||
|
hide();
|
||||||
|
Vars.control.playMap(selectedMap);
|
||||||
});
|
});
|
||||||
image.getImageCell().size(Unit.dp.inPixels(164));
|
image.getImageCell().size(images);
|
||||||
content().add(image).size(Unit.dp.inPixels(180));
|
maps.add(image).width(Unit.dp.inPixels(170)).pad(4f).units(Unit.dp);
|
||||||
}
|
}
|
||||||
|
|
||||||
content().row();
|
content().add(pane);
|
||||||
|
|
||||||
for(Map map : Map.values()){
|
shown(()->{
|
||||||
if(!map.visible) continue;
|
//this is necessary for some reason?
|
||||||
|
Timers.run(2f, ()->{
|
||||||
content().add((StringSupplier)(()->"High Score: [lime]" + Settings.getInt("hiscore" + map.name())));
|
Core.scene.setScrollFocus(pane);
|
||||||
}
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,25 +8,27 @@ import io.anuke.mindustry.GameState;
|
|||||||
import io.anuke.mindustry.GameState.State;
|
import io.anuke.mindustry.GameState.State;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.io.SaveIO;
|
import io.anuke.mindustry.io.SaveIO;
|
||||||
import io.anuke.ucore.scene.ui.Dialog;
|
|
||||||
import io.anuke.ucore.scene.ui.Label;
|
import io.anuke.ucore.scene.ui.Label;
|
||||||
import io.anuke.ucore.scene.ui.TextButton;
|
import io.anuke.ucore.scene.ui.TextButton;
|
||||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||||
|
|
||||||
//TODO unified save/load dialogs
|
//TODO unified save/load dialogs
|
||||||
public class LoadDialog extends Dialog{
|
public class LoadDialog extends FloatingDialog{
|
||||||
|
|
||||||
public LoadDialog() {
|
public LoadDialog(){
|
||||||
super("Load Game");
|
this("Load Game");
|
||||||
|
}
|
||||||
|
|
||||||
|
public LoadDialog(String title) {
|
||||||
|
super(title);
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
|
|
||||||
shown(() -> {
|
shown(() -> {
|
||||||
setup();
|
setup();
|
||||||
});
|
});
|
||||||
|
|
||||||
getButtonTable().addButton("Back", () -> {
|
addCloseButton();
|
||||||
hide();
|
|
||||||
}).pad(2).size(180, 44).units(Unit.dp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setup(){
|
private void setup(){
|
||||||
@@ -49,34 +51,37 @@ public class LoadDialog extends Dialog{
|
|||||||
|
|
||||||
button.add(info).padBottom(2).padTop(6);
|
button.add(info).padBottom(2).padTop(6);
|
||||||
button.getLabel().setFontScale(Unit.dp.inPixels(0.75f));
|
button.getLabel().setFontScale(Unit.dp.inPixels(0.75f));
|
||||||
button.setDisabled(!SaveIO.isSaveValid(i));
|
modifyButton(button, slot);
|
||||||
|
|
||||||
button.clicked(() -> {
|
|
||||||
if(!button.isDisabled()){
|
|
||||||
Vars.ui.showLoading();
|
|
||||||
|
|
||||||
Timer.schedule(new Task(){
|
|
||||||
@Override
|
|
||||||
public void run(){
|
|
||||||
Vars.ui.hideLoading();
|
|
||||||
hide();
|
|
||||||
try{
|
|
||||||
SaveIO.loadFromSlot(slot);
|
|
||||||
}catch(Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
Vars.ui.showError("[orange]Save file corrupted or invalid!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Vars.ui.hideMenu();
|
|
||||||
GameState.set(State.playing);
|
|
||||||
}
|
|
||||||
}, 3f/60f);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
content().add(button).size(400, 80).units(Unit.dp).pad(2);
|
content().add(button).size(400, 80).units(Unit.dp).pad(2);
|
||||||
content().row();
|
content().row();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void modifyButton(TextButton button, int slot){
|
||||||
|
button.setDisabled(!SaveIO.isSaveValid(slot));
|
||||||
|
button.clicked(() -> {
|
||||||
|
if(!button.isDisabled()){
|
||||||
|
Vars.ui.showLoading();
|
||||||
|
|
||||||
|
Timer.schedule(new Task(){
|
||||||
|
@Override
|
||||||
|
public void run(){
|
||||||
|
Vars.ui.hideLoading();
|
||||||
|
hide();
|
||||||
|
try{
|
||||||
|
SaveIO.loadFromSlot(slot);
|
||||||
|
}catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
Vars.ui.showError("[orange]Save file corrupted or invalid!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Vars.ui.hideMenu();
|
||||||
|
GameState.set(State.playing);
|
||||||
|
}
|
||||||
|
}, 3f/60f);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,17 +9,16 @@ import io.anuke.mindustry.GameState;
|
|||||||
import io.anuke.mindustry.GameState.State;
|
import io.anuke.mindustry.GameState.State;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.ucore.scene.ui.ConfirmDialog;
|
import io.anuke.ucore.scene.ui.ConfirmDialog;
|
||||||
import io.anuke.ucore.scene.ui.Dialog;
|
|
||||||
import io.anuke.ucore.scene.ui.layout.Cell;
|
import io.anuke.ucore.scene.ui.layout.Cell;
|
||||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||||
|
|
||||||
public class MenuDialog extends Dialog{
|
public class MenuDialog extends FloatingDialog{
|
||||||
private SaveDialog save = new SaveDialog();
|
private SaveDialog save = new SaveDialog();
|
||||||
private LoadDialog load = new LoadDialog();
|
private LoadDialog load = new LoadDialog();
|
||||||
public boolean wasPaused = false;
|
public boolean wasPaused = false;
|
||||||
|
|
||||||
public MenuDialog(){
|
public MenuDialog(){
|
||||||
super("Paused", "dialog");
|
super("Paused");
|
||||||
setup();
|
setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
34
core/src/io/anuke/mindustry/ui/MindustryKeybindDialog.java
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
package io.anuke.mindustry.ui;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Input.Keys;
|
||||||
|
import com.badlogic.gdx.graphics.Color;
|
||||||
|
import com.badlogic.gdx.utils.Align;
|
||||||
|
|
||||||
|
import io.anuke.ucore.scene.ui.Image;
|
||||||
|
import io.anuke.ucore.scene.ui.KeybindDialog;
|
||||||
|
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||||
|
|
||||||
|
public class MindustryKeybindDialog extends KeybindDialog{
|
||||||
|
|
||||||
|
public MindustryKeybindDialog(){
|
||||||
|
setDialog();
|
||||||
|
|
||||||
|
setFillParent(true);
|
||||||
|
title().setAlignment(Align.center);
|
||||||
|
getTitleTable().row();
|
||||||
|
getTitleTable().add(new Image("white"))
|
||||||
|
.growX().height(3f).pad(4f).units(Unit.dp).get().setColor(Color.ORANGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addCloseButton(){
|
||||||
|
buttons().addImageTextButton("Back", "icon-arrow-left", Unit.dp.inPixels(30f), ()->{
|
||||||
|
hide();
|
||||||
|
}).size(230f, 64f).units(Unit.dp);
|
||||||
|
|
||||||
|
keyDown(key->{
|
||||||
|
if(key == Keys.ESCAPE || key == Keys.BACK)
|
||||||
|
hide();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
32
core/src/io/anuke/mindustry/ui/MindustrySettingsDialog.java
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
package io.anuke.mindustry.ui;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Input.Keys;
|
||||||
|
import com.badlogic.gdx.graphics.Color;
|
||||||
|
import com.badlogic.gdx.utils.Align;
|
||||||
|
|
||||||
|
import io.anuke.ucore.scene.ui.Image;
|
||||||
|
import io.anuke.ucore.scene.ui.SettingsDialog;
|
||||||
|
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||||
|
|
||||||
|
public class MindustrySettingsDialog extends SettingsDialog{
|
||||||
|
|
||||||
|
public MindustrySettingsDialog(){
|
||||||
|
setFillParent(true);
|
||||||
|
title().setAlignment(Align.center);
|
||||||
|
getTitleTable().row();
|
||||||
|
getTitleTable().add(new Image("white"))
|
||||||
|
.growX().height(3f).pad(4f).units(Unit.dp).get().setColor(Color.ORANGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addCloseButton(){
|
||||||
|
buttons().addImageTextButton("Back", "icon-arrow-left", Unit.dp.inPixels(30f), ()->{
|
||||||
|
hide();
|
||||||
|
}).size(230f, 64f).units(Unit.dp);
|
||||||
|
|
||||||
|
keyDown(key->{
|
||||||
|
if(key == Keys.ESCAPE || key == Keys.BACK)
|
||||||
|
hide();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,70 +1,38 @@
|
|||||||
package io.anuke.mindustry.ui;
|
package io.anuke.mindustry.ui;
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.Align;
|
|
||||||
import com.badlogic.gdx.utils.Timer;
|
import com.badlogic.gdx.utils.Timer;
|
||||||
import com.badlogic.gdx.utils.Timer.Task;
|
import com.badlogic.gdx.utils.Timer.Task;
|
||||||
import com.badlogic.gdx.utils.reflect.ClassReflection;
|
import com.badlogic.gdx.utils.reflect.ClassReflection;
|
||||||
|
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.io.SaveIO;
|
import io.anuke.mindustry.io.SaveIO;
|
||||||
import io.anuke.ucore.scene.ui.*;
|
import io.anuke.ucore.scene.ui.ConfirmDialog;
|
||||||
|
import io.anuke.ucore.scene.ui.TextButton;
|
||||||
import io.anuke.ucore.scene.ui.layout.Cell;
|
import io.anuke.ucore.scene.ui.layout.Cell;
|
||||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||||
|
|
||||||
//TODO unified save/load dialogs
|
//TODO unified save/load dialogs
|
||||||
public class SaveDialog extends Dialog{
|
public class SaveDialog extends LoadDialog{
|
||||||
|
|
||||||
public SaveDialog() {
|
public SaveDialog(){
|
||||||
super("Save Game");
|
super("Save Game");
|
||||||
setup();
|
|
||||||
|
|
||||||
shown(()->{
|
|
||||||
setup();
|
|
||||||
});
|
|
||||||
|
|
||||||
getButtonTable().addButton("Back", ()->{
|
|
||||||
hide();
|
|
||||||
}).pad(2).size(180, 44).units(Unit.dp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setup(){
|
@Override
|
||||||
content().clear();
|
public void modifyButton(TextButton button, int slot){
|
||||||
|
button.clicked(()->{
|
||||||
content().add("Select a save slot.").padBottom(2);
|
if(SaveIO.isSaveValid(slot)){
|
||||||
content().row();
|
new ConfirmDialog("Overwrite", "Are you sure you want to overwrite\nthis save slot?", ()->{
|
||||||
|
|
||||||
for(int i = 0; i < Vars.saveSlots; i ++){
|
|
||||||
final int slot = i;
|
|
||||||
|
|
||||||
TextButton button = new TextButton("[orange]Slot " + (i+1));
|
|
||||||
button.getLabelCell().top().left().growX();
|
|
||||||
button.row();
|
|
||||||
button.pad(Unit.dp.inPixels(10));
|
|
||||||
|
|
||||||
Label info = new Label("[gray]" + (!SaveIO.isSaveValid(i) ? "<empty>" : "Wave " +
|
|
||||||
SaveIO.getWave(slot)+"\nLast Saved: " + SaveIO.getTimeString(i)));
|
|
||||||
info.setAlignment(Align.center, Align.center);
|
|
||||||
|
|
||||||
button.add(info).padBottom(2).padTop(6);
|
|
||||||
button.getLabel().setFontScale(Unit.dp.inPixels(0.75f));
|
|
||||||
|
|
||||||
button.clicked(()->{
|
|
||||||
if(SaveIO.isSaveValid(slot)){
|
|
||||||
new ConfirmDialog("Overwrite", "Are you sure you want to overwrite\nthis save slot?", ()->{
|
|
||||||
save(slot);
|
|
||||||
}){{
|
|
||||||
content().pad(16);
|
|
||||||
for(Cell<?> cell : getButtonTable().getCells())
|
|
||||||
cell.size(110, 45).pad(4).units(Unit.dp);
|
|
||||||
}}.show();
|
|
||||||
}else{
|
|
||||||
save(slot);
|
save(slot);
|
||||||
}
|
}){{
|
||||||
});
|
content().pad(16);
|
||||||
|
for(Cell<?> cell : getButtonTable().getCells())
|
||||||
content().add(button).size(400, 80).units(Unit.dp).pad(2);
|
cell.size(110, 45).pad(4).units(Unit.dp);
|
||||||
content().row();
|
}}.show();
|
||||||
}
|
}else{
|
||||||
|
save(slot);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void save(int slot){
|
void save(int slot){
|
||||||
|
|||||||
@@ -12,10 +12,12 @@ import io.anuke.mindustry.resource.Weapon;
|
|||||||
import io.anuke.ucore.core.Draw;
|
import io.anuke.ucore.core.Draw;
|
||||||
import io.anuke.ucore.core.Effects;
|
import io.anuke.ucore.core.Effects;
|
||||||
import io.anuke.ucore.function.Listenable;
|
import io.anuke.ucore.function.Listenable;
|
||||||
import io.anuke.ucore.scene.ui.*;
|
import io.anuke.ucore.scene.ui.Image;
|
||||||
|
import io.anuke.ucore.scene.ui.TextButton;
|
||||||
|
import io.anuke.ucore.scene.ui.Tooltip;
|
||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
|
|
||||||
public class UpgradeDialog extends Dialog{
|
public class UpgradeDialog extends FloatingDialog{
|
||||||
boolean wasPaused = false;
|
boolean wasPaused = false;
|
||||||
|
|
||||||
public UpgradeDialog() {
|
public UpgradeDialog() {
|
||||||
|
|||||||
@@ -1,15 +1,27 @@
|
|||||||
package io.anuke.mindustry.world;
|
package io.anuke.mindustry.world;
|
||||||
|
|
||||||
public enum Map{
|
public enum Map{
|
||||||
delta, canyon, pit, maze, tutorial(false), test(false);
|
delta("Starting map."),
|
||||||
|
canyon("Badly drawn map."),
|
||||||
|
pit("Eck."),
|
||||||
|
maze("it's okay."),
|
||||||
|
maze2("test"),
|
||||||
|
maze3("test"),
|
||||||
|
maze4("test"),
|
||||||
|
maze5("test"),
|
||||||
|
tutorial(false),
|
||||||
|
test(false);
|
||||||
|
|
||||||
public final boolean visible;
|
public final boolean visible;
|
||||||
|
public final String description;
|
||||||
|
|
||||||
private Map(boolean visible){
|
private Map(boolean visible){
|
||||||
this.visible = visible;
|
this.visible = visible;
|
||||||
|
this.description = "Test map!";
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map(){
|
private Map(String description){
|
||||||
this(true);
|
this.visible = true;
|
||||||
|
this.description = description;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,5 +161,19 @@ public class WeaponBlocks{
|
|||||||
health = 180;
|
health = 180;
|
||||||
ammoMultiplier = 40;
|
ammoMultiplier = 40;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
chainturret = new Turret("chainturret"){
|
||||||
|
{
|
||||||
|
inaccuracy = 7f;
|
||||||
|
formalName = "chain turret";
|
||||||
|
range = 60f;
|
||||||
|
reload = 40f;
|
||||||
|
bullet = BulletType.shell;
|
||||||
|
ammo = Item.coal;
|
||||||
|
health = 360;
|
||||||
|
ammoMultiplier = 10;
|
||||||
|
width = height = 2;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,12 @@ public class Turret extends Block{
|
|||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(Tile tile){
|
||||||
Vector2 offset = getPlaceOffset();
|
Vector2 offset = getPlaceOffset();
|
||||||
Draw.rect("block", tile.worldx() + offset.x, tile.worldy() + offset.y);
|
|
||||||
|
if(isMultiblock()){
|
||||||
|
Draw.rect("block-" + width + "x" + height, tile.worldx() + offset.x, tile.worldy() + offset.y);
|
||||||
|
}else{
|
||||||
|
Draw.rect("block", tile.worldx() + offset.x, tile.worldy() + offset.y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -80,7 +85,7 @@ public class Turret extends Block{
|
|||||||
if(fract > 0)
|
if(fract > 0)
|
||||||
fract = Mathf.clamp(fract, 0.24f, 1f);
|
fract = Mathf.clamp(fract, 0.24f, 1f);
|
||||||
|
|
||||||
Vars.renderer.drawBar(Color.GREEN, tile.worldx() + offset.x, tile.worldy() + 6 + offset.y, fract);
|
Vars.renderer.drawBar(Color.GREEN, tile.worldx() + offset.x, 2 + tile.worldy() + height/2f*Vars.tilesize + offset.y, fract);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -208,7 +213,7 @@ public class Turret extends Block{
|
|||||||
public static class TurretEntity extends TileEntity{
|
public static class TurretEntity extends TileEntity{
|
||||||
public TileEntity blockTarget;
|
public TileEntity blockTarget;
|
||||||
public int ammo;
|
public int ammo;
|
||||||
public float rotation;
|
public float rotation = 90;
|
||||||
public Enemy target;
|
public Enemy target;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||