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 }
|
||||
},
|
||||
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} }
|
||||
},
|
||||
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: {
|
||||
default: {down: button-down, up: button, over: button-over },
|
||||
empty: {},
|
||||
static: {up: button },
|
||||
static-down: {up: button-down },
|
||||
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 },
|
||||
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 }
|
||||
},
|
||||
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: {
|
||||
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: {
|
||||
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.ui.*;
|
||||
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;
|
||||
|
||||
public class UI extends SceneModule{
|
||||
Table itemtable, weapontable, tools, loadingtable, desctable, respawntable, configtable;
|
||||
SettingsDialog prefs;
|
||||
KeybindDialog keys;
|
||||
MindustrySettingsDialog prefs;
|
||||
MindustryKeybindDialog keys;
|
||||
Dialog about, restart, levels, upgrades, load, settingserror;
|
||||
MenuDialog menu;
|
||||
Tooltip tooltip;
|
||||
@ -51,15 +53,23 @@ public class UI extends SceneModule{
|
||||
private Array<Item> tempItems = new Array<>();
|
||||
|
||||
public UI() {
|
||||
Dialog.setShowAction(()-> sequence(Actions.moveToAligned(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), Align.center),
|
||||
parallel(Actions.moveToAligned(Gdx.graphics.getWidth()/2,
|
||||
Gdx.graphics.getHeight()/2, Align.center, 0.09f, Interpolation.fade),
|
||||
|
||||
Actions.fadeIn(0.09f, Interpolation.fade))));
|
||||
Dialog.setShowAction(()-> sequence(
|
||||
alpha(0f),
|
||||
originCenter(),
|
||||
moveToAligned(Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/2, Align.center),
|
||||
scaleTo(0.0f, 1f),
|
||||
parallel(
|
||||
scaleTo(1f, 1f, 0.1f, Interpolation.fade),
|
||||
fadeIn(0.1f, Interpolation.fade)
|
||||
)
|
||||
));
|
||||
|
||||
Dialog.setHideAction(()-> sequence(
|
||||
parallel(Actions.moveBy(0, -Gdx.graphics.getHeight()/2, 0.08f, Interpolation.fade),
|
||||
Actions.fadeOut(0.08f, Interpolation.fade))));
|
||||
parallel(
|
||||
scaleTo(0.01f, 0.01f, 0.1f, Interpolation.fade),
|
||||
fadeOut(0.1f, Interpolation.fade)
|
||||
)
|
||||
));
|
||||
|
||||
skin.font().setUseIntegerPositions(false);
|
||||
skin.font().getData().setScale(Vars.fontscale);
|
||||
@ -146,7 +156,7 @@ public class UI extends SceneModule{
|
||||
|
||||
levels = new LevelDialog();
|
||||
|
||||
prefs = new SettingsDialog();
|
||||
prefs = new MindustrySettingsDialog();
|
||||
prefs.setStyle(Core.skin.get("dialog", WindowStyle.class));
|
||||
|
||||
menu = new MenuDialog();
|
||||
@ -180,12 +190,14 @@ public class UI extends SceneModule{
|
||||
}
|
||||
});
|
||||
|
||||
keys = new KeybindDialog();
|
||||
keys = new MindustryKeybindDialog();
|
||||
|
||||
about = new TextDialog("About", aboutText);
|
||||
|
||||
for(Cell<?> cell : about.content().getCells())
|
||||
cell.left();
|
||||
about = new FloatingDialog("About");
|
||||
about.addCloseButton();
|
||||
for(String text : aboutText){
|
||||
about.content().add(text).left();
|
||||
about.content().row();
|
||||
}
|
||||
|
||||
restart = new Dialog("The core was destroyed.", "dialog");
|
||||
|
||||
@ -439,12 +451,6 @@ public class UI extends SceneModule{
|
||||
|
||||
row();
|
||||
}
|
||||
|
||||
new button("About", () -> {
|
||||
about.show(scene);
|
||||
});
|
||||
|
||||
row();
|
||||
|
||||
if(Gdx.app.getType() != ApplicationType.WebGL && !android){
|
||||
new button("Exit", () -> {
|
||||
@ -455,9 +461,17 @@ public class UI extends SceneModule{
|
||||
get().pad(Unit.dp.inPixels(16));
|
||||
}};
|
||||
|
||||
get().setVisible(nplay);
|
||||
visible(nplay);
|
||||
}}.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){
|
||||
new table(){{
|
||||
abottom();
|
||||
|
@ -48,11 +48,11 @@ public class Vars{
|
||||
public static Player player;
|
||||
|
||||
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:",
|
||||
"- [YELLOW]bfxr.com[] for sound effects",
|
||||
"- [RED]freemusicarchive.org[] for music",
|
||||
"Credits:",
|
||||
"- SFX made with [YELLOW]bfxr.com[]",
|
||||
"- Music made by [GREEN]RoccoW[]",
|
||||
};
|
||||
}
|
||||
|
@ -41,6 +41,8 @@ public enum Recipe{
|
||||
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)),
|
||||
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)),
|
||||
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.world.Map;
|
||||
import io.anuke.mindustry.world.World;
|
||||
import io.anuke.ucore.core.Core;
|
||||
import io.anuke.ucore.core.Settings;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
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.ScrollPane;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
|
||||
public class LevelDialog extends Dialog{
|
||||
public class LevelDialog extends FloatingDialog{
|
||||
private Map selectedMap = Map.delta;
|
||||
private TextureRegion region = new TextureRegion();
|
||||
|
||||
public LevelDialog(){
|
||||
super("Level Select");
|
||||
getTitleTable().getCell(title()).growX().center();
|
||||
getTitleTable().center();
|
||||
setup();
|
||||
}
|
||||
|
||||
void setup(){
|
||||
addCloseButton();
|
||||
getButtonTable().addButton("Play", ()->{
|
||||
hide();
|
||||
Vars.control.playMap(selectedMap);
|
||||
}).pad(3).size(180, 44).units(Unit.dp);
|
||||
Table maps = new Table();
|
||||
ScrollPane pane = new ScrollPane(maps);
|
||||
|
||||
ButtonGroup<ImageButton> mapgroup = new ButtonGroup<>();
|
||||
int maxwidth = 4;
|
||||
|
||||
for(Map map : Map.values()){
|
||||
for(int i = 0; i < Map.values().length; i ++){
|
||||
Map map = Map.values()[i];
|
||||
|
||||
if(!map.visible) continue;
|
||||
|
||||
content().add(map.name());
|
||||
}
|
||||
|
||||
content().row();
|
||||
|
||||
for(Map map : Map.values()){
|
||||
if(!map.visible) continue;
|
||||
if(i % maxwidth == 0){
|
||||
maps.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();
|
||||
|
||||
float images = Unit.dp.inPixels(154);
|
||||
|
||||
ImageButton image = new ImageButton(new TextureRegion(World.getTexture(map)), "togglemap");
|
||||
mapgroup.add(image);
|
||||
image.row();
|
||||
image.add(inset).width(images+6);
|
||||
image.clicked(()->{
|
||||
selectedMap = map;
|
||||
hide();
|
||||
Vars.control.playMap(selectedMap);
|
||||
});
|
||||
image.getImageCell().size(Unit.dp.inPixels(164));
|
||||
content().add(image).size(Unit.dp.inPixels(180));
|
||||
image.getImageCell().size(images);
|
||||
maps.add(image).width(Unit.dp.inPixels(170)).pad(4f).units(Unit.dp);
|
||||
}
|
||||
|
||||
content().row();
|
||||
content().add(pane);
|
||||
|
||||
for(Map map : Map.values()){
|
||||
if(!map.visible) continue;
|
||||
|
||||
content().add((StringSupplier)(()->"High Score: [lime]" + Settings.getInt("hiscore" + map.name())));
|
||||
}
|
||||
shown(()->{
|
||||
//this is necessary for some reason?
|
||||
Timers.run(2f, ()->{
|
||||
Core.scene.setScrollFocus(pane);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -8,25 +8,27 @@ import io.anuke.mindustry.GameState;
|
||||
import io.anuke.mindustry.GameState.State;
|
||||
import io.anuke.mindustry.Vars;
|
||||
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.TextButton;
|
||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
|
||||
//TODO unified save/load dialogs
|
||||
public class LoadDialog extends Dialog{
|
||||
public class LoadDialog extends FloatingDialog{
|
||||
|
||||
public LoadDialog() {
|
||||
super("Load Game");
|
||||
public LoadDialog(){
|
||||
this("Load Game");
|
||||
}
|
||||
|
||||
public LoadDialog(String title) {
|
||||
super(title);
|
||||
setup();
|
||||
|
||||
|
||||
shown(() -> {
|
||||
setup();
|
||||
});
|
||||
|
||||
getButtonTable().addButton("Back", () -> {
|
||||
hide();
|
||||
}).pad(2).size(180, 44).units(Unit.dp);
|
||||
addCloseButton();
|
||||
}
|
||||
|
||||
private void setup(){
|
||||
@ -49,34 +51,37 @@ public class LoadDialog extends Dialog{
|
||||
|
||||
button.add(info).padBottom(2).padTop(6);
|
||||
button.getLabel().setFontScale(Unit.dp.inPixels(0.75f));
|
||||
button.setDisabled(!SaveIO.isSaveValid(i));
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
modifyButton(button, slot);
|
||||
|
||||
content().add(button).size(400, 80).units(Unit.dp).pad(2);
|
||||
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.Vars;
|
||||
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.Unit;
|
||||
|
||||
public class MenuDialog extends Dialog{
|
||||
public class MenuDialog extends FloatingDialog{
|
||||
private SaveDialog save = new SaveDialog();
|
||||
private LoadDialog load = new LoadDialog();
|
||||
public boolean wasPaused = false;
|
||||
|
||||
public MenuDialog(){
|
||||
super("Paused", "dialog");
|
||||
super("Paused");
|
||||
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;
|
||||
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.badlogic.gdx.utils.Timer;
|
||||
import com.badlogic.gdx.utils.Timer.Task;
|
||||
import com.badlogic.gdx.utils.reflect.ClassReflection;
|
||||
|
||||
import io.anuke.mindustry.Vars;
|
||||
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.Unit;
|
||||
|
||||
//TODO unified save/load dialogs
|
||||
public class SaveDialog extends Dialog{
|
||||
|
||||
public SaveDialog() {
|
||||
public class SaveDialog extends LoadDialog{
|
||||
|
||||
public SaveDialog(){
|
||||
super("Save Game");
|
||||
setup();
|
||||
|
||||
shown(()->{
|
||||
setup();
|
||||
});
|
||||
|
||||
getButtonTable().addButton("Back", ()->{
|
||||
hide();
|
||||
}).pad(2).size(180, 44).units(Unit.dp);
|
||||
}
|
||||
|
||||
private void setup(){
|
||||
content().clear();
|
||||
|
||||
content().add("Select a save slot.").padBottom(2);
|
||||
content().row();
|
||||
|
||||
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{
|
||||
@Override
|
||||
public void modifyButton(TextButton button, int slot){
|
||||
button.clicked(()->{
|
||||
if(SaveIO.isSaveValid(slot)){
|
||||
new ConfirmDialog("Overwrite", "Are you sure you want to overwrite\nthis save slot?", ()->{
|
||||
save(slot);
|
||||
}
|
||||
});
|
||||
|
||||
content().add(button).size(400, 80).units(Unit.dp).pad(2);
|
||||
content().row();
|
||||
}
|
||||
}){{
|
||||
content().pad(16);
|
||||
for(Cell<?> cell : getButtonTable().getCells())
|
||||
cell.size(110, 45).pad(4).units(Unit.dp);
|
||||
}}.show();
|
||||
}else{
|
||||
save(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.Effects;
|
||||
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;
|
||||
|
||||
public class UpgradeDialog extends Dialog{
|
||||
public class UpgradeDialog extends FloatingDialog{
|
||||
boolean wasPaused = false;
|
||||
|
||||
public UpgradeDialog() {
|
||||
|
@ -1,15 +1,27 @@
|
||||
package io.anuke.mindustry.world;
|
||||
|
||||
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 String description;
|
||||
|
||||
private Map(boolean visible){
|
||||
this.visible = visible;
|
||||
this.description = "Test map!";
|
||||
}
|
||||
|
||||
private Map(){
|
||||
this(true);
|
||||
private Map(String description){
|
||||
this.visible = true;
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
@ -161,5 +161,19 @@ public class WeaponBlocks{
|
||||
health = 180;
|
||||
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
|
||||
public void draw(Tile tile){
|
||||
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
|
||||
@ -80,7 +85,7 @@ public class Turret extends Block{
|
||||
if(fract > 0)
|
||||
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
|
||||
@ -208,7 +213,7 @@ public class Turret extends Block{
|
||||
public static class TurretEntity extends TileEntity{
|
||||
public TileEntity blockTarget;
|
||||
public int ammo;
|
||||
public float rotation;
|
||||
public float rotation = 90;
|
||||
public Enemy target;
|
||||
|
||||
@Override
|
||||
|