Experimental multiplayer pausing variable
This commit is contained in:
@@ -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;
|
public static final float iconXLarge = 8*6f, iconLarge = 8*5f, iconMed = 8*4f, iconSmall = 8*3f;
|
||||||
/** for map generator dialog */
|
/** for map generator dialog */
|
||||||
public static boolean updateEditorOnChange = false;
|
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 */
|
/** all choosable player colors in join/host dialog */
|
||||||
public static final Color[] playerColors = {
|
public static final Color[] playerColors = {
|
||||||
Color.valueOf("82759a"),
|
Color.valueOf("82759a"),
|
||||||
|
|||||||
@@ -638,12 +638,12 @@ public class Control implements ApplicationListener, Loadable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//cannot launch while paused
|
//cannot launch while paused
|
||||||
if(state.is(State.paused) && renderer.isCutscene()){
|
if(state.isPaused() && renderer.isCutscene()){
|
||||||
state.set(State.playing);
|
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))){
|
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()){
|
if(Core.input.keyTap(Binding.menu) && !ui.restart.isShown() && !ui.minimapfrag.shown()){
|
||||||
|
|||||||
@@ -51,8 +51,12 @@ public class GameState{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void set(State astate){
|
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
|
//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));
|
Events.fire(new StateChangeEvent(state, astate));
|
||||||
state = astate;
|
state = astate;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class BaseDialog extends Dialog{
|
|||||||
.growX().height(3f).pad(4f);
|
.growX().height(3f).pad(4f);
|
||||||
|
|
||||||
hidden(() -> {
|
hidden(() -> {
|
||||||
if(shouldPause && state.isGame()){
|
if(shouldPause && state.isGame() && !net.active()){
|
||||||
if(!wasPaused || net.active()){
|
if(!wasPaused || net.active()){
|
||||||
state.set(State.playing);
|
state.set(State.playing);
|
||||||
}
|
}
|
||||||
@@ -33,7 +33,7 @@ public class BaseDialog extends Dialog{
|
|||||||
});
|
});
|
||||||
|
|
||||||
shown(() -> {
|
shown(() -> {
|
||||||
if(shouldPause && state.isGame()){
|
if(shouldPause && state.isGame() && !net.active()){
|
||||||
wasPaused = state.is(State.paused);
|
wasPaused = state.is(State.paused);
|
||||||
state.set(State.paused);
|
state.set(State.paused);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -147,14 +147,14 @@ public class HudFragment{
|
|||||||
if(net.active()){
|
if(net.active()){
|
||||||
ui.listfrag.toggle();
|
ui.listfrag.toggle();
|
||||||
}else{
|
}else{
|
||||||
state.set(state.is(State.paused) ? State.playing : State.paused);
|
state.set(state.isPaused() ? State.playing : State.paused);
|
||||||
}
|
}
|
||||||
}).name("pause").update(i -> {
|
}).name("pause").update(i -> {
|
||||||
if(net.active()){
|
if(net.active()){
|
||||||
i.getStyle().imageUp = Icon.players;
|
i.getStyle().imageUp = Icon.players;
|
||||||
}else{
|
}else{
|
||||||
i.setDisabled(false);
|
i.setDisabled(false);
|
||||||
i.getStyle().imageUp = state.is(State.paused) ? Icon.play : Icon.pause;
|
i.getStyle().imageUp = state.isPaused() ? Icon.play : Icon.pause;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user