Merge branch 'unsector'
# Conflicts: # core/src/io/anuke/mindustry/maps/SectorPresets.java # core/src/io/anuke/mindustry/maps/Sectors.java # core/src/io/anuke/mindustry/maps/TutorialSector.java # core/src/io/anuke/mindustry/maps/generation/FortressGenerator.java # core/src/io/anuke/mindustry/maps/missions/MissionWithStartingCore.java # core/src/io/anuke/mindustry/world/blocks/storage/CoreBlock.java
This commit is contained in:
@@ -15,7 +15,7 @@ import io.anuke.arc.scene.event.InputListener;
|
||||
import io.anuke.arc.util.async.AsyncExecutor;
|
||||
import io.anuke.mindustry.content.Items;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.maps.generation.WorldGenerator.GenResult;
|
||||
import io.anuke.mindustry.maps.WorldGenerator.GenResult;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.world.ColorMapper;
|
||||
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.maps.Sector;
|
||||
|
||||
public class MissionDialog extends FloatingDialog{
|
||||
|
||||
public MissionDialog(){
|
||||
super("$text.mission.complete");
|
||||
setFillParent(false);
|
||||
}
|
||||
|
||||
public void show(Sector sector){
|
||||
buttons().clear();
|
||||
content().clear();
|
||||
|
||||
buttons().addButton("$text.nextmission", () -> {
|
||||
hide();
|
||||
Vars.ui.paused.runExitSave();
|
||||
Vars.ui.sectors.show();
|
||||
}).size(190f, 64f);
|
||||
|
||||
buttons().addButton("$text.continue", this::hide).size(190f, 64f);
|
||||
|
||||
content().add(Core.bundle.format("text.mission.complete.body", sector.x, sector.y)).pad(10);
|
||||
show();
|
||||
}
|
||||
}
|
||||
@@ -31,10 +31,6 @@ public class PausedDialog extends FloatingDialog{
|
||||
void rebuild(){
|
||||
missionTable.clear();
|
||||
missionTable.background((Drawable) null);
|
||||
if(world.getSector() != null){
|
||||
missionTable.background("underline");
|
||||
missionTable.add(Core.bundle.format("text.sector", world.getSector().x + ", " + world.getSector().y));
|
||||
}
|
||||
}
|
||||
|
||||
void setup(){
|
||||
@@ -58,7 +54,7 @@ public class PausedDialog extends FloatingDialog{
|
||||
content().addButton("$text.settings", ui.settings::show);
|
||||
|
||||
content().row();
|
||||
content().addButton("$text.savegame", save::show).disabled(s -> world.getSector() != null);
|
||||
content().addButton("$text.savegame", save::show);
|
||||
content().addButton("$text.loadgame", load::show).disabled(b -> Net.active());
|
||||
|
||||
content().row();
|
||||
@@ -79,11 +75,9 @@ public class PausedDialog extends FloatingDialog{
|
||||
content().defaults().size(120f).pad(5);
|
||||
float isize = 14f * 4;
|
||||
|
||||
content().addRowImageTextButton("$text.back", "icon-play-2", isize, () -> {
|
||||
hide();
|
||||
});
|
||||
content().addRowImageTextButton("$text.back", "icon-play-2", isize, this::hide);
|
||||
content().addRowImageTextButton("$text.settings", "icon-tools", isize, ui.settings::show);
|
||||
content().addRowImageTextButton("$text.save", "icon-save", isize, save::show).disabled(b -> world.getSector() != null);
|
||||
content().addRowImageTextButton("$text.save", "icon-save", isize, save::show);
|
||||
|
||||
content().row();
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package io.anuke.mindustry.ui.dialogs;
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.maps.Sector;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
@@ -34,7 +33,7 @@ public class RestartDialog extends FloatingDialog{
|
||||
state.set(State.menu);
|
||||
logic.reset();
|
||||
}).size(130f, 60f);
|
||||
}else if(world.getSector() == null){
|
||||
}else{
|
||||
if(control.isHighScore()){
|
||||
content().add("$text.highscore").pad(6);
|
||||
content().row();
|
||||
@@ -46,19 +45,6 @@ public class RestartDialog extends FloatingDialog{
|
||||
state.set(State.menu);
|
||||
logic.reset();
|
||||
}).size(130f, 60f);
|
||||
}else{
|
||||
content().add("$text.sector.gameover");
|
||||
buttons().addButton("$text.menu", () -> {
|
||||
hide();
|
||||
state.set(State.menu);
|
||||
logic.reset();
|
||||
}).size(130f, 60f);
|
||||
|
||||
buttons().addButton("$text.sector.retry", () -> {
|
||||
Sector sector = world.getSector();
|
||||
ui.loadLogic(() -> world.sectors.playSector(sector));
|
||||
hide();
|
||||
}).size(130f, 60f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,271 +0,0 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.input.KeyCode;
|
||||
import io.anuke.arc.math.geom.Geometry;
|
||||
import io.anuke.arc.math.geom.Point2;
|
||||
import io.anuke.arc.math.geom.Vector2;
|
||||
import io.anuke.arc.scene.Element;
|
||||
import io.anuke.arc.scene.Group;
|
||||
import io.anuke.arc.scene.event.InputEvent;
|
||||
import io.anuke.arc.scene.event.InputListener;
|
||||
import io.anuke.arc.scene.event.Touchable;
|
||||
import io.anuke.arc.scene.ui.layout.Cell;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.arc.scene.ui.layout.Unit;
|
||||
import io.anuke.arc.util.Align;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.maps.Sector;
|
||||
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
|
||||
public class SectorsDialog extends FloatingDialog{
|
||||
private static final float sectorSize = Unit.dp.scl(32*5);
|
||||
private Sector selected;
|
||||
private Table table;
|
||||
private SectorView view;
|
||||
|
||||
public SectorsDialog(){
|
||||
super("");
|
||||
|
||||
table = new Table(){
|
||||
@Override
|
||||
public float getPrefWidth(){
|
||||
return sectorSize*2f;
|
||||
}
|
||||
};
|
||||
table.visible(() -> selected != null);
|
||||
table.update(() -> {
|
||||
if(selected != null){
|
||||
|
||||
int offsetX = (int)(view.panX / sectorSize);
|
||||
int offsetY = (int)(view.panY / sectorSize);
|
||||
float drawX = x + width/2f+ selected.x * (sectorSize-2) - offsetX * sectorSize - view.panX % sectorSize + sectorSize/2f;
|
||||
float drawY = y + height/2f + selected.y * (sectorSize-2) - offsetY * sectorSize - view.panY % sectorSize + sectorSize/2f;
|
||||
|
||||
table.setPosition(drawX, drawY - sectorSize/2f + 1, Align.top);
|
||||
}
|
||||
});
|
||||
|
||||
Group container = new Group();
|
||||
container.touchable(Touchable.childrenOnly);
|
||||
container.addChild(table);
|
||||
|
||||
margin(0);
|
||||
getTitleTable().clear();
|
||||
clear();
|
||||
stack(content(), container, buttons()).grow();
|
||||
|
||||
shown(this::setup);
|
||||
}
|
||||
|
||||
void setup(){
|
||||
selected = null;
|
||||
|
||||
table.clear();
|
||||
content().clear();
|
||||
buttons().clear();
|
||||
buttons().bottom().margin(15);
|
||||
|
||||
addCloseButton();
|
||||
content().add(view = new SectorView()).grow();
|
||||
}
|
||||
|
||||
void selectSector(Sector sector){
|
||||
selected = sector;
|
||||
|
||||
table.clear();
|
||||
table.background("button").margin(5);
|
||||
|
||||
table.defaults().pad(3);
|
||||
table.add(Core.bundle.format("text.sector", sector.x + ", " + sector.y));
|
||||
table.row();
|
||||
|
||||
if(selected.completedMissions < selected.missions.size && !selected.complete){
|
||||
table.labelWrap(Core.bundle.format("text.mission", selected.getDominantMission().menuDisplayString())).growX();
|
||||
table.row();
|
||||
}
|
||||
|
||||
if(selected.hasSave()){
|
||||
table.labelWrap(Core.bundle.format("text.sector.time", selected.getSave().getPlayTime())).growX();
|
||||
table.row();
|
||||
}
|
||||
|
||||
table.table(t -> {
|
||||
Cell<?> cell = t.addImageTextButton(sector.hasSave() ? "$text.sector.resume" : "$text.sector.deploy", "icon-play", 10*3, () -> {
|
||||
hide();
|
||||
Vars.ui.loadLogic(() -> world.sectors.playSector(selected));
|
||||
}).height(60f);
|
||||
|
||||
if(selected.hasSave()){
|
||||
t.addImageTextButton("$text.sector.abandon", "icon-cancel", 16 * 2, () ->
|
||||
Vars.ui.showConfirm("$text.confirm", "$text.sector.abandon.confirm", () -> {
|
||||
world.sectors.abandonSector(selected);
|
||||
// Simulate a sector selection so the buttons get updated.
|
||||
selectSector(selected);
|
||||
})
|
||||
).width(sectorSize / Unit.dp.scl(1f)).height(60f);
|
||||
cell.width(sectorSize / Unit.dp.scl(1f));
|
||||
}else{
|
||||
cell.width(sectorSize*2f / Unit.dp.scl(1f));
|
||||
}
|
||||
}).pad(-5).growX().padTop(0);
|
||||
|
||||
table.pack();
|
||||
table.act(Core.graphics.getDeltaTime());
|
||||
}
|
||||
|
||||
public Sector getSelected(){
|
||||
return selected;
|
||||
}
|
||||
|
||||
class SectorView extends Element{
|
||||
float lastX, lastY;
|
||||
boolean clicked = false;
|
||||
float panX = sectorSize/2f, panY = sectorSize/2f;
|
||||
|
||||
SectorView(){
|
||||
addListener(new InputListener(){
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, KeyCode button){
|
||||
if(pointer != 0) return false;
|
||||
//Cursors.setHand();
|
||||
lastX = x;
|
||||
lastY = y;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void touchDragged(InputEvent event, float x, float y, int pointer){
|
||||
if(pointer != 0) return;
|
||||
panX -= x - lastX;
|
||||
panY -= y - lastY;
|
||||
|
||||
lastX = x;
|
||||
lastY = y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void touchUp(InputEvent event, float x, float y, int pointer, KeyCode button){
|
||||
if(pointer != 0) return;
|
||||
//Cursors.restoreCursor();
|
||||
}
|
||||
});
|
||||
|
||||
clicked(() -> clicked = true);
|
||||
|
||||
this.focus();
|
||||
}
|
||||
|
||||
private void focus(){
|
||||
Sector focusSector = null;
|
||||
long newestTimestamp = 0;
|
||||
for(Sector sector : world.sectors.getSectors()){
|
||||
if(sector.hasSave()){
|
||||
long timestamp = sector.getSave().getTimestamp();
|
||||
if(timestamp > newestTimestamp){
|
||||
focusSector = sector;
|
||||
newestTimestamp = timestamp;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(focusSector != null) {
|
||||
panX = (focusSector.x + 0.5f) * sectorSize;
|
||||
panY = (focusSector.y + 0.5f) * sectorSize;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
Draw.alpha(parentAlpha);
|
||||
|
||||
int shownSectorsX = (int)(width/sectorSize);
|
||||
int shownSectorsY = (int)(height/sectorSize);
|
||||
|
||||
int offsetX = (int)(panX / sectorSize);
|
||||
int offsetY = (int)(panY / sectorSize);
|
||||
|
||||
Vector2 mouse = Core.input.mouse();
|
||||
|
||||
for(int x = -shownSectorsX; x <= shownSectorsX; x++){
|
||||
for(int y = -shownSectorsY; y <= shownSectorsY; y++){
|
||||
int sectorX = offsetX + x;
|
||||
int sectorY = offsetY + y;
|
||||
|
||||
float drawX = x + width/2f+ sectorX * (sectorSize-2) - offsetX * sectorSize - panX % sectorSize + sectorSize/2f;
|
||||
float drawY = y + height/2f + sectorY * (sectorSize-2) - offsetY * sectorSize - panY % sectorSize + sectorSize/2f;
|
||||
|
||||
Sector sector = world.sectors.get(sectorX, sectorY);
|
||||
|
||||
if(sector == null || sector.texture == null){
|
||||
Draw.reset();
|
||||
Draw.rect(("empty-sector"), drawX, drawY, sectorSize, sectorSize);
|
||||
|
||||
int i = 0;
|
||||
for(Point2 point : Geometry.d4){
|
||||
Sector other = world.sectors.get(sectorX + point.x, sectorY + point.y);
|
||||
if(other != null){
|
||||
Draw.rect(("sector-edge"), drawX, drawY, sectorSize, sectorSize, i*90);
|
||||
}
|
||||
|
||||
i ++;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
Draw.colorl(!sector.complete ? 0.3f : 1f);
|
||||
Draw.rect(Draw.wrap(sector.texture), drawX, drawY, sectorSize, sectorSize);
|
||||
|
||||
if(sector.missions.size == 0) continue;
|
||||
|
||||
String region = sector.getDominantMission().getIcon();
|
||||
|
||||
if(sector.complete){
|
||||
region = "icon-mission-done";
|
||||
}
|
||||
|
||||
Color iconColor = Color.WHITE;
|
||||
Color backColor = Color.BLACK;
|
||||
Color selectColor = Color.CLEAR;
|
||||
|
||||
if(sector == selected){
|
||||
selectColor = Palette.accent;
|
||||
}else if(mouse.x > drawX - sectorSize / 2f && mouse.y > drawY - sectorSize / 2f
|
||||
&& mouse.x < drawX + sectorSize / 2f && mouse.y < drawY + sectorSize / 2f){
|
||||
if(clicked){
|
||||
selectSector(sector);
|
||||
}
|
||||
selectColor = Color.WHITE;
|
||||
}else if(sector.hasSave()){
|
||||
iconColor = Palette.command;
|
||||
}else{
|
||||
iconColor = Color.GRAY;
|
||||
}
|
||||
|
||||
if(sector.complete){
|
||||
iconColor = backColor = Color.CLEAR;
|
||||
}
|
||||
|
||||
Draw.color(selectColor);
|
||||
Draw.rect(("sector-select"), drawX, drawY, sectorSize, sectorSize);
|
||||
|
||||
Draw.color(backColor);
|
||||
Draw.alpha(0.75f * backColor.a);
|
||||
Draw.rect(("icon-mission-background"), drawX, drawY, Unit.dp.scl(18f * 5), Unit.dp.scl(18f * 5));
|
||||
|
||||
float size = Unit.dp.scl(10f * 5);
|
||||
|
||||
Draw.color(iconColor);
|
||||
Draw.rect((region), drawX, drawY, size, size);
|
||||
}
|
||||
}
|
||||
|
||||
Draw.reset();
|
||||
|
||||
clicked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -143,13 +143,6 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
dialog.setFillParent(false);
|
||||
dialog.content().defaults().size(230f, 60f).pad(3);
|
||||
dialog.addCloseButton();
|
||||
dialog.content().addButton("$text.settings.clearsectors", () -> {
|
||||
ui.showConfirm("$text.confirm", "$text.settings.clear.confirm", () -> {
|
||||
world.sectors.clear();
|
||||
dialog.hide();
|
||||
});
|
||||
});
|
||||
dialog.content().row();
|
||||
dialog.content().addButton("$text.settings.clearunlocks", () -> {
|
||||
ui.showConfirm("$text.confirm", "$text.settings.clear.confirm", () -> {
|
||||
control.unlocks.reset();
|
||||
|
||||
@@ -369,7 +369,6 @@ public class HudFragment extends Fragment{
|
||||
table.touchable(Touchable.enabled);
|
||||
|
||||
table.labelWrap(() ->
|
||||
world.getSector() == null ?
|
||||
(state.enemies() > 0 && state.mode.disableWaveTimer ?
|
||||
wavef.get(state.wave) + "\n" + (state.enemies() == 1 ?
|
||||
enemyf.get(state.enemies()) :
|
||||
@@ -377,17 +376,11 @@ public class HudFragment extends Fragment{
|
||||
wavef.get(state.wave) + "\n" +
|
||||
(!state.mode.disableWaveTimer ?
|
||||
Core.bundle.format("text.wave.waiting", (int)(state.wavetime/60)) :
|
||||
Core.bundle.get("text.waiting"))) :
|
||||
Core.bundle.format("text.mission.display", world.getSector().currentMission().displayString())).growX().pad(8f);
|
||||
Core.bundle.get("text.waiting")))
|
||||
).growX().pad(8f);
|
||||
|
||||
table.clicked(() -> {
|
||||
if(world.getSector() != null && world.getSector().currentMission().hasMessage()){
|
||||
world.getSector().currentMission().showMessage();
|
||||
}
|
||||
});
|
||||
|
||||
table.setDisabled(() -> !(world.getSector() != null && world.getSector().currentMission().hasMessage()));
|
||||
table.visible(() -> !((world.getSector() == null && state.mode.disableWaves) || !state.mode.showMission || (world.getSector() != null && world.getSector().complete)));
|
||||
table.setDisabled(true);
|
||||
table.visible(() -> !(state.mode.disableWaves || !state.mode.showMission));
|
||||
}
|
||||
|
||||
private void addPlayButton(Table table){
|
||||
|
||||
@@ -146,9 +146,9 @@ public class MenuFragment extends Fragment{
|
||||
dialog.addCloseButton();
|
||||
dialog.content().defaults().height(66f).width(w).padRight(5f);
|
||||
|
||||
dialog.content().add(new MenuButton("icon-play-2", "$text.sectors", () -> {
|
||||
dialog.content().add(new MenuButton("icon-play-2", "$text.map.random", () -> {
|
||||
dialog.hide();
|
||||
ui.sectors.show();
|
||||
world.generator.playRandomMap();
|
||||
})).width(bw).colspan(2);
|
||||
dialog.content().row();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user