Added 'abandon sector' button

This commit is contained in:
Anuken
2018-10-13 23:07:57 -04:00
parent a5ebeadd95
commit 5f89d8588d
5 changed files with 776 additions and 735 deletions

View File

@@ -54,6 +54,8 @@ text.sectors=Sectors
text.sector=Sector: [LIGHT_GRAY]{0} text.sector=Sector: [LIGHT_GRAY]{0}
text.sector.time=Time: [LIGHT_GRAY]{0} text.sector.time=Time: [LIGHT_GRAY]{0}
text.sector.deploy=Deploy text.sector.deploy=Deploy
text.sector.abandon=Abandon
text.sector.abandon.confirm=Are you sure you want to abandon all progress at this sector?\nThis cannot be undone!
text.sector.resume=Resume text.sector.resume=Resume
text.sector.locked=[scarlet][[Incomplete] text.sector.locked=[scarlet][[Incomplete]
text.sector.unexplored=[accent][[Unexplored] text.sector.unexplored=[accent][[Unexplored]

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

After

Width:  |  Height:  |  Size: 101 KiB

View File

@@ -260,6 +260,25 @@ public class Sectors{
} }
} }
public void abandonSector(Sector sector){
for(int x = sector.x; x < sector.width + sector.x; x++){
for(int y = sector.y; y < sector.y + sector.height; y++){
grid.put(x, y, null);
}
}
if(sector.hasSave()){
sector.getSave().delete();
}
sector.completedMissions = 0;
initSector(sector);
for(int x = sector.x; x < sector.width + sector.x; x++){
for(int y = sector.y; y < sector.y + sector.height; y++){
grid.put(x, y, sector);
}
}
}
public void load(){ public void load(){
for(Sector sector : grid.values()){ for(Sector sector : grid.values()){
sector.texture.dispose(); sector.texture.dispose();
@@ -298,8 +317,10 @@ public class Sectors{
Array<Sector> out = new Array<>(); Array<Sector> out = new Array<>();
for(Sector sector : grid.values()){ for(Sector sector : grid.values()){
if(sector != null && !out.contains(sector, true)){
out.add(sector); out.add(sector);
} }
}
Settings.putObject("sectors", out); Settings.putObject("sectors", out);
Settings.save(); Settings.save();

View File

@@ -52,8 +52,12 @@ public class SectorsDialog extends FloatingDialog{
hide(); hide();
ui.loadLogic(() -> world.sectors.playSector(selected)); ui.loadLogic(() -> world.sectors.playSector(selected));
}).size(230f, 64f).disabled(b -> selected == null) }).size(210f, 64f).disabled(b -> selected == null)
.update(t -> t.setText(selected != null && selected.hasSave() ? "$text.sector.resume" : "$text.sector.deploy")); .update(t -> t.setText(selected != null && selected.hasSave() ? "$text.sector.resume" : "$text.sector.deploy"));
buttons().addImageTextButton("$text.sector.abandon", "icon-cancel", 16*2, () ->
ui.showConfirm("$text.confirm", "$text.sector.abandon.confirm", () -> world.sectors.abandonSector(selected)))
.size(210f, 64f).disabled(b -> selected == null || !selected.hasSave());
} }
void selectSector(Sector sector){ void selectSector(Sector sector){