Added loading dialogs for saving
This commit is contained in:
@@ -391,39 +391,40 @@ public class UI extends SceneModule{
|
||||
|
||||
//menu table
|
||||
new table(){{
|
||||
float w = Unit.dp.inPixels(200);
|
||||
|
||||
new table("button"){{
|
||||
defaults().size(Unit.dp.inPixels(220), Unit.dp.inPixels(50));
|
||||
|
||||
new button("Play", () -> {
|
||||
levels.show();
|
||||
}).width(w);
|
||||
});
|
||||
|
||||
row();
|
||||
|
||||
new button("Settings", () -> {
|
||||
prefs.show(scene);
|
||||
}).width(w);
|
||||
});
|
||||
|
||||
row();
|
||||
|
||||
if(!android){
|
||||
new button("Controls", () -> {
|
||||
keys.show(scene);
|
||||
}).width(w);
|
||||
});
|
||||
|
||||
row();
|
||||
}
|
||||
|
||||
new button("About", () -> {
|
||||
about.show(scene);
|
||||
}).width(w);
|
||||
});
|
||||
|
||||
row();
|
||||
|
||||
if(Gdx.app.getType() != ApplicationType.WebGL)
|
||||
new button("Exit", () -> {
|
||||
Gdx.app.exit();
|
||||
}).width(w);
|
||||
});
|
||||
|
||||
get().pad(Unit.dp.inPixels(20));
|
||||
}};
|
||||
@@ -452,7 +453,9 @@ public class UI extends SceneModule{
|
||||
|
||||
loadingtable = new table("loadDim"){{
|
||||
new table("button"){{
|
||||
new label("[yellow]Loading...").scale(1).pad(10);
|
||||
new label("[yellow]Loading..."){{
|
||||
get().setName("namelabel");
|
||||
}}.scale(1).pad(10);
|
||||
}}.end();
|
||||
}}.end().get();
|
||||
|
||||
@@ -520,7 +523,13 @@ public class UI extends SceneModule{
|
||||
}
|
||||
|
||||
public void showLoading(){
|
||||
showLoading("[yellow]Loading..");
|
||||
}
|
||||
|
||||
public void showLoading(String text){
|
||||
loadingtable.<Label>find("namelabel").setText(text);
|
||||
loadingtable.setVisible(true);
|
||||
loadingtable.toFront();
|
||||
}
|
||||
|
||||
public void hideLoading(){
|
||||
|
||||
@@ -53,6 +53,10 @@ public class AndroidInput extends InputAdapter{
|
||||
Tile tile = selected();
|
||||
player.breaktime += Mathf.delta();
|
||||
if(player.breaktime >= tile.block().breaktime){
|
||||
if(tile.block().drops != null){
|
||||
Inventory.addItem(tile.block().drops.item, tile.block().drops.amount);
|
||||
}
|
||||
|
||||
Effects.effect("break", tile.worldx(), tile.worldy());
|
||||
Effects.shake(3f, 1f);
|
||||
tile.setBlock(Blocks.air);
|
||||
|
||||
@@ -86,6 +86,10 @@ public class Input{
|
||||
Tile tile = cursor;
|
||||
player.breaktime += Mathf.delta();
|
||||
if(player.breaktime >= tile.block().breaktime){
|
||||
if(tile.block().drops != null){
|
||||
Inventory.addItem(tile.block().drops.item, tile.block().drops.amount);
|
||||
}
|
||||
|
||||
Effects.effect("break", tile.worldx(), tile.worldy());
|
||||
Effects.shake(3f, 1f);
|
||||
tile.setBlock(Blocks.air);
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
package io.anuke.mindustry.ui;
|
||||
|
||||
import com.badlogic.gdx.utils.Timer;
|
||||
import com.badlogic.gdx.utils.Timer.Task;
|
||||
|
||||
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;
|
||||
@@ -18,7 +23,7 @@ public class LoadDialog extends Dialog{
|
||||
|
||||
getButtonTable().addButton("Back", ()->{
|
||||
hide();
|
||||
}).pad(8).size(180, 60);
|
||||
}).pad(8).size(180, 50);
|
||||
}
|
||||
|
||||
private void setup(){
|
||||
@@ -40,12 +45,21 @@ public class LoadDialog extends Dialog{
|
||||
|
||||
button.clicked(()->{
|
||||
if(!button.isDisabled()){
|
||||
SaveIO.loadFromSlot(slot);
|
||||
hide();
|
||||
Vars.ui.showLoading();
|
||||
|
||||
Timer.schedule(new Task(){
|
||||
public void run(){
|
||||
SaveIO.loadFromSlot(slot);
|
||||
Vars.ui.hideLoading();
|
||||
hide();
|
||||
Vars.ui.hideMenu();
|
||||
GameState.set(State.playing);
|
||||
}
|
||||
}, 2f/60f);
|
||||
}
|
||||
});
|
||||
|
||||
content().add(button).size(400, 100).units(Unit.dp).pad(10);
|
||||
content().add(button).size(400, 90).units(Unit.dp).pad(10);
|
||||
content().row();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ public class MenuDialog extends Dialog{
|
||||
}
|
||||
|
||||
void setup(){
|
||||
content().defaults().width(200).units(Unit.dp);
|
||||
content().defaults().width(220).height(50).units(Unit.dp);
|
||||
|
||||
content().addButton("Back", ()->{
|
||||
hide();
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package io.anuke.mindustry.ui;
|
||||
|
||||
import com.badlogic.gdx.utils.Timer;
|
||||
import com.badlogic.gdx.utils.Timer.Task;
|
||||
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.io.SaveIO;
|
||||
import io.anuke.ucore.scene.ui.ConfirmDialog;
|
||||
@@ -20,7 +23,7 @@ public class SaveDialog extends Dialog{
|
||||
|
||||
getButtonTable().addButton("Back", ()->{
|
||||
hide();
|
||||
}).pad(8).size(180, 60);
|
||||
}).pad(8).size(180, 50);
|
||||
}
|
||||
|
||||
private void setup(){
|
||||
@@ -36,28 +39,39 @@ public class SaveDialog extends Dialog{
|
||||
button.getLabelCell().top().left().growX();
|
||||
button.row();
|
||||
button.pad(12);
|
||||
button.add("[gray]" + (!SaveIO.isSaveValid(i) ? "<empty>" : "Last Saved: " + SaveIO.getTimeString(i)));
|
||||
button.add((!SaveIO.isSaveValid(i) ? "[gray]<empty>" : "[LIGHT_GRAY]Last Saved: " + SaveIO.getTimeString(i)));
|
||||
button.getLabel().setFontScale(1f);
|
||||
|
||||
button.clicked(()->{
|
||||
if(SaveIO.isSaveValid(slot)){
|
||||
new ConfirmDialog("Overwrite", "Are you sure you want to overwrite\nthis save slot?", ()->{
|
||||
SaveIO.saveToSlot(slot);
|
||||
hide();
|
||||
save(slot);
|
||||
}){{
|
||||
content().pad(16);
|
||||
for(Cell<?> cell : getButtonTable().getCells())
|
||||
cell.size(110, 45).pad(4);
|
||||
}}.show();
|
||||
}else{
|
||||
SaveIO.saveToSlot(slot);
|
||||
hide();
|
||||
save(slot);
|
||||
}
|
||||
});
|
||||
|
||||
content().add(button).size(400, 100).units(Unit.dp).pad(10);
|
||||
content().add(button).size(400, 90).units(Unit.dp).pad(8);
|
||||
content().row();
|
||||
}
|
||||
}
|
||||
|
||||
void save(int slot){
|
||||
Vars.ui.showLoading("[yellow]Saving...");
|
||||
|
||||
Timer.schedule(new Task(){
|
||||
@Override
|
||||
public void run(){
|
||||
SaveIO.saveToSlot(slot);
|
||||
hide();
|
||||
Vars.ui.hideLoading();
|
||||
}
|
||||
}, 2f/60f);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.World;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.resource.ItemStack;
|
||||
import io.anuke.ucore.core.Draw;
|
||||
import io.anuke.ucore.graphics.Caches;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
@@ -30,6 +31,8 @@ public class Block{
|
||||
public String edge = "stone";
|
||||
//whether to have 3 variants
|
||||
public boolean vary = true;
|
||||
//stuff that drops when broken
|
||||
public ItemStack drops = null;
|
||||
|
||||
public Block(String name) {
|
||||
blocks.add(this);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package io.anuke.mindustry.world.blocks;
|
||||
|
||||
import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.resource.ItemStack;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
|
||||
@@ -65,12 +67,14 @@ public class Blocks{
|
||||
shadow = "rockshadow";
|
||||
breakable = true;
|
||||
breaktime = 15;
|
||||
drops = new ItemStack(Item.stone, 3);
|
||||
}},
|
||||
|
||||
rock2 = new Block("rock2"){{
|
||||
shadow = "rock2shadow";
|
||||
breakable = true;
|
||||
breaktime = 15;
|
||||
drops = new ItemStack(Item.stone, 3);
|
||||
}},
|
||||
|
||||
dirtblock = new Block("dirtblock"){{
|
||||
|
||||
Reference in New Issue
Block a user