Cleaned up pause menu mess / Added sector links
This commit is contained in:
@@ -379,17 +379,12 @@ public class Control extends Module{
|
||||
state.set(state.is(State.playing) ? State.paused : State.playing);
|
||||
}
|
||||
|
||||
if(Inputs.keyTap("menu")){
|
||||
if(state.is(State.paused)){
|
||||
ui.paused.hide();
|
||||
state.set(State.playing);
|
||||
}else if(!ui.restart.isShown()){
|
||||
if(ui.chatfrag.chatOpen()){
|
||||
ui.chatfrag.hide();
|
||||
}else{
|
||||
ui.paused.show();
|
||||
state.set(State.paused);
|
||||
}
|
||||
if(Inputs.keyTap("menu") && !ui.restart.isShown()){
|
||||
if(ui.chatfrag.chatOpen()){
|
||||
ui.chatfrag.hide();
|
||||
}else if(!ui.paused.isShown() && !ui.hasDialog()){
|
||||
ui.paused.show();
|
||||
state.set(State.paused);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package io.anuke.mindustry.maps;
|
||||
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.IntArray;
|
||||
import io.anuke.annotations.Annotations.Serialize;
|
||||
import io.anuke.mindustry.game.Saves.SaveSlot;
|
||||
import io.anuke.mindustry.game.SpawnGroup;
|
||||
@@ -24,6 +25,8 @@ public class Sector{
|
||||
public int saveID = -1;
|
||||
/**Num of missions in this sector that have been completed so far.*/
|
||||
public int completedMissions;
|
||||
/**List of links to other sector coords.*/
|
||||
public IntArray links = new IntArray();
|
||||
|
||||
/**Display texture. Needs to be disposed.*/
|
||||
public transient Texture texture;
|
||||
|
||||
@@ -13,7 +13,6 @@ import io.anuke.ucore.scene.ui.Dialog;
|
||||
import io.anuke.ucore.scene.ui.ScrollPane;
|
||||
|
||||
import static io.anuke.mindustry.Vars.state;
|
||||
import static io.anuke.mindustry.Vars.ui;
|
||||
|
||||
public class FloatingDialog extends Dialog{
|
||||
private boolean wasPaused;
|
||||
@@ -29,19 +28,16 @@ public class FloatingDialog extends Dialog{
|
||||
|
||||
hidden(() -> {
|
||||
if(shouldPause && !state.is(State.menu)){
|
||||
if(!wasPaused || Net.active())
|
||||
if(!wasPaused || Net.active()){
|
||||
state.set(State.playing);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
shown(() -> {
|
||||
if(shouldPause && !state.is(State.menu)){
|
||||
wasPaused = state.is(State.paused);
|
||||
if(ui.paused.getScene() != null){
|
||||
wasPaused = ui.paused.wasPaused;
|
||||
}
|
||||
if(!Net.active()) state.set(State.paused);
|
||||
ui.paused.hide();
|
||||
state.set(State.paused);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -71,8 +67,9 @@ public class FloatingDialog extends Dialog{
|
||||
buttons().addImageTextButton("$text.back", "icon-arrow-left", 30f, this::hide).size(230f, 64f);
|
||||
|
||||
keyDown(key -> {
|
||||
if(key == Keys.ESCAPE || key == Keys.BACK)
|
||||
hide();
|
||||
if(key == Keys.ESCAPE || key == Keys.BACK) {
|
||||
Gdx.app.postRunnable(this::hide);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import com.badlogic.gdx.Input.Keys;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
@@ -8,16 +9,22 @@ import io.anuke.ucore.util.Bundles;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class PausedDialog extends FloatingDialog{
|
||||
public boolean wasPaused = false;
|
||||
private SaveDialog save = new SaveDialog();
|
||||
private LoadDialog load = new LoadDialog();
|
||||
private Table missionTable;
|
||||
|
||||
public PausedDialog(){
|
||||
super("$text.menu");
|
||||
shouldPause = true;
|
||||
setup();
|
||||
|
||||
shown(this::rebuild);
|
||||
|
||||
keyDown(key -> {
|
||||
if(key == Keys.ESCAPE || key == Keys.BACK) {
|
||||
hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void rebuild(){
|
||||
@@ -40,11 +47,6 @@ public class PausedDialog extends FloatingDialog{
|
||||
}
|
||||
});
|
||||
|
||||
shown(() -> {
|
||||
wasPaused = state.is(State.paused);
|
||||
if(!Net.active()) state.set(State.paused);
|
||||
});
|
||||
|
||||
content().table(t -> missionTable = t).colspan(mobile ? 3 : 1);
|
||||
content().row();
|
||||
|
||||
@@ -53,8 +55,6 @@ public class PausedDialog extends FloatingDialog{
|
||||
|
||||
content().addButton("$text.back", () -> {
|
||||
hide();
|
||||
if((!wasPaused || Net.active()) && !state.is(State.menu))
|
||||
state.set(State.playing);
|
||||
});
|
||||
|
||||
content().row();
|
||||
@@ -86,8 +86,6 @@ public class PausedDialog extends FloatingDialog{
|
||||
|
||||
content().addRowImageTextButton("$text.back", "icon-play-2", isize, () -> {
|
||||
hide();
|
||||
if(!wasPaused && !state.is(State.menu))
|
||||
state.set(State.playing);
|
||||
});
|
||||
content().addRowImageTextButton("$text.settings", "icon-tools", isize, ui.settings::show);
|
||||
content().addRowImageTextButton("$text.save", "icon-save", isize, save::show).disabled(b -> world.getSector() != null);
|
||||
|
||||
@@ -50,11 +50,7 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
shown(() -> {
|
||||
if(!state.is(State.menu)){
|
||||
wasPaused = state.is(State.paused);
|
||||
if(ui.paused.getScene() != null){
|
||||
wasPaused = ui.paused.wasPaused;
|
||||
}
|
||||
if(!Net.active()) state.set(State.paused);
|
||||
ui.paused.hide();
|
||||
state.set(State.paused);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ public class UnlocksDialog extends FloatingDialog{
|
||||
public UnlocksDialog(){
|
||||
super("$text.unlocks");
|
||||
|
||||
addCloseButton();
|
||||
shouldPause = true;
|
||||
addCloseButton();
|
||||
shown(this::rebuild);
|
||||
onResize(this::rebuild);
|
||||
}
|
||||
@@ -36,7 +36,7 @@ public class UnlocksDialog extends FloatingDialog{
|
||||
|
||||
Array<Content>[] allContent = content.getContentMap();
|
||||
|
||||
for(int j =0; j< allContent.length; j ++){
|
||||
for(int j = 0; j < allContent.length; j ++){
|
||||
ContentType type = ContentType.values()[j];
|
||||
|
||||
Array<Content> array = allContent[j];
|
||||
|
||||
Reference in New Issue
Block a user