Experimental multiplayer pausing variable

This commit is contained in:
Anuken
2022-10-31 20:19:39 -04:00
parent 4e8e65d1dd
commit 6aeeb23d7c
5 changed files with 13 additions and 7 deletions

View File

@@ -115,6 +115,8 @@ public class Vars implements Loadable{
public static final float iconXLarge = 8*6f, iconLarge = 8*5f, iconMed = 8*4f, iconSmall = 8*3f;
/** for map generator dialog */
public static boolean updateEditorOnChange = false;
/** Experimental flag for multiplayer pausing. DO NOT USE YET! */
public static boolean multiplayerPausing = false;
/** all choosable player colors in join/host dialog */
public static final Color[] playerColors = {
Color.valueOf("82759a"),

View File

@@ -638,12 +638,12 @@ public class Control implements ApplicationListener, Loadable{
}
//cannot launch while paused
if(state.is(State.paused) && renderer.isCutscene()){
if(state.isPaused() && renderer.isCutscene()){
state.set(State.playing);
}
if(Core.input.keyTap(Binding.pause) && !renderer.isCutscene() && !scene.hasDialog() && !scene.hasKeyboard() && !ui.restart.isShown() && (state.is(State.paused) || state.is(State.playing))){
state.set(state.is(State.playing) ? State.paused : State.playing);
state.set(state.isPaused() ? State.playing : State.paused);
}
if(Core.input.keyTap(Binding.menu) && !ui.restart.isShown() && !ui.minimapfrag.shown()){

View File

@@ -51,8 +51,12 @@ public class GameState{
}
public void set(State astate){
//horrible horrible horrible
if(astate == State.paused && net.active() && multiplayerPausing) serverPaused = true;
if(astate != State.paused && net.active() && multiplayerPausing) serverPaused = false;
//cannot pause when in multiplayer
if(astate == State.paused && net.active()) return;
if(astate == State.paused && (net.active())) return;
Events.fire(new StateChangeEvent(state, astate));
state = astate;

View File

@@ -24,7 +24,7 @@ public class BaseDialog extends Dialog{
.growX().height(3f).pad(4f);
hidden(() -> {
if(shouldPause && state.isGame()){
if(shouldPause && state.isGame() && !net.active()){
if(!wasPaused || net.active()){
state.set(State.playing);
}
@@ -33,7 +33,7 @@ public class BaseDialog extends Dialog{
});
shown(() -> {
if(shouldPause && state.isGame()){
if(shouldPause && state.isGame() && !net.active()){
wasPaused = state.is(State.paused);
state.set(State.paused);
}

View File

@@ -147,14 +147,14 @@ public class HudFragment{
if(net.active()){
ui.listfrag.toggle();
}else{
state.set(state.is(State.paused) ? State.playing : State.paused);
state.set(state.isPaused() ? State.playing : State.paused);
}
}).name("pause").update(i -> {
if(net.active()){
i.getStyle().imageUp = Icon.players;
}else{
i.setDisabled(false);
i.getStyle().imageUp = state.is(State.paused) ? Icon.play : Icon.pause;
i.getStyle().imageUp = state.isPaused() ? Icon.play : Icon.pause;
}
});