Added 'abandon sector' button
This commit is contained in:
@@ -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(){
|
||||
for(Sector sector : grid.values()){
|
||||
sector.texture.dispose();
|
||||
@@ -298,7 +317,9 @@ public class Sectors{
|
||||
Array<Sector> out = new Array<>();
|
||||
|
||||
for(Sector sector : grid.values()){
|
||||
out.add(sector);
|
||||
if(sector != null && !out.contains(sector, true)){
|
||||
out.add(sector);
|
||||
}
|
||||
}
|
||||
|
||||
Settings.putObject("sectors", out);
|
||||
|
||||
@@ -52,8 +52,12 @@ public class SectorsDialog extends FloatingDialog{
|
||||
hide();
|
||||
|
||||
ui.loadLogic(() -> world.sectors.playSector(selected));
|
||||
}).size(230f, 64f).disabled(b -> selected == null)
|
||||
.update(t -> t.setText(selected != null && selected.hasSave() ? "$text.sector.resume" : "$text.sector.deploy"));
|
||||
}).size(210f, 64f).disabled(b -> selected == null)
|
||||
.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){
|
||||
|
||||
Reference in New Issue
Block a user