Fixed connection not resetting on game load / Experimental click changes
This commit is contained in:
@@ -208,6 +208,7 @@ public class Control implements ApplicationListener{
|
||||
public void playZone(Zone zone){
|
||||
ui.loadAnd(() -> {
|
||||
logic.reset();
|
||||
Net.reset();
|
||||
world.loadGenerator(zone.generator);
|
||||
zone.rules.accept(state.rules);
|
||||
state.rules.zone = zone;
|
||||
|
||||
@@ -45,6 +45,8 @@ public class NetClient implements ApplicationListener{
|
||||
private boolean connecting = false;
|
||||
/** If true, no message will be shown on disconnect. */
|
||||
private boolean quiet = false;
|
||||
/** Whether to supress disconnect events completely.*/
|
||||
private boolean quietReset = false;
|
||||
/** Counter for data timeout. */
|
||||
private float timeoutTime = 0f;
|
||||
/** Last sent client snapshot ID. */
|
||||
@@ -94,8 +96,10 @@ public class NetClient implements ApplicationListener{
|
||||
});
|
||||
|
||||
Net.handleClient(Disconnect.class, packet -> {
|
||||
state.set(State.menu);
|
||||
if(quietReset) return;
|
||||
|
||||
connecting = false;
|
||||
state.set(State.menu);
|
||||
logic.reset();
|
||||
Platform.instance.updateRPC();
|
||||
|
||||
@@ -325,11 +329,11 @@ public class NetClient implements ApplicationListener{
|
||||
private void finishConnecting(){
|
||||
state.set(State.playing);
|
||||
connecting = false;
|
||||
ui.loadfrag.hide();
|
||||
ui.join.hide();
|
||||
Net.setClientLoaded(true);
|
||||
Core.app.post(Call::connectConfirm);
|
||||
Time.runTask(40f, Platform.instance::updateRPC);
|
||||
Core.app.post(() -> ui.loadfrag.hide());
|
||||
}
|
||||
|
||||
private void reset(){
|
||||
@@ -337,6 +341,7 @@ public class NetClient implements ApplicationListener{
|
||||
removed.clear();
|
||||
timeoutTime = 0f;
|
||||
connecting = true;
|
||||
quietReset = false;
|
||||
quiet = false;
|
||||
lastSent = 0;
|
||||
|
||||
@@ -348,11 +353,18 @@ public class NetClient implements ApplicationListener{
|
||||
connecting = true;
|
||||
}
|
||||
|
||||
/** Disconnects, resetting state to the menu. */
|
||||
public void disconnectQuietly(){
|
||||
quiet = true;
|
||||
Net.disconnect();
|
||||
}
|
||||
|
||||
/** Disconnects, causing no further changes or reset.*/
|
||||
public void disconnectNoReset(){
|
||||
quiet = quietReset = true;
|
||||
Net.disconnect();
|
||||
}
|
||||
|
||||
/** When set, any disconnects will be ignored and no dialogs will be shown. */
|
||||
public void setQuiet(){
|
||||
quiet = true;
|
||||
|
||||
@@ -16,7 +16,7 @@ public enum Binding implements KeyBind{
|
||||
diagonal_placement(KeyCode.CONTROL_LEFT),
|
||||
pick(KeyCode.MOUSE_MIDDLE),
|
||||
dash(KeyCode.SHIFT_LEFT),
|
||||
gridMode(KeyCode.GRAVE),
|
||||
gridMode(KeyCode.BACKTICK),
|
||||
gridModeShift(KeyCode.ALT_LEFT),
|
||||
zoom_hold(KeyCode.CONTROL_LEFT, "view"),
|
||||
zoom(new Axis(KeyCode.SCROLL)),
|
||||
|
||||
@@ -132,6 +132,11 @@ public class Net{
|
||||
active = false;
|
||||
}
|
||||
|
||||
public static void reset(){
|
||||
closeServer();
|
||||
netClient.disconnectNoReset();
|
||||
}
|
||||
|
||||
public static void disconnect(){
|
||||
clientProvider.disconnect();
|
||||
server = false;
|
||||
|
||||
@@ -17,6 +17,7 @@ import io.anuke.mindustry.core.GameState.*;
|
||||
import io.anuke.mindustry.game.Saves.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.io.SaveIO.*;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.type.Zone.*;
|
||||
import io.anuke.mindustry.ui.*;
|
||||
@@ -95,6 +96,8 @@ public class DeployDialog extends FloatingDialog{
|
||||
|
||||
hide();
|
||||
ui.loadAnd(() -> {
|
||||
logic.reset();
|
||||
Net.reset();
|
||||
try{
|
||||
control.saves.getZoneSlot().load();
|
||||
state.set(State.playing);
|
||||
|
||||
@@ -310,6 +310,7 @@ public class JoinDialog extends FloatingDialog{
|
||||
|
||||
Time.runTask(2f, () -> {
|
||||
logic.reset();
|
||||
Net.reset();
|
||||
Vars.netClient.beginConnecting();
|
||||
Net.connect(ip, port, () -> {
|
||||
hide();
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.arc.files.FileHandle;
|
||||
import io.anuke.arc.scene.ui.ScrollPane;
|
||||
import io.anuke.arc.scene.ui.TextButton;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.files.*;
|
||||
import io.anuke.arc.scene.ui.*;
|
||||
import io.anuke.arc.scene.ui.layout.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.core.Platform;
|
||||
import io.anuke.mindustry.game.Saves.SaveSlot;
|
||||
import io.anuke.mindustry.io.SaveIO;
|
||||
import io.anuke.mindustry.io.SaveIO.SaveException;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.core.GameState.*;
|
||||
import io.anuke.mindustry.core.*;
|
||||
import io.anuke.mindustry.game.Saves.*;
|
||||
import io.anuke.mindustry.io.*;
|
||||
import io.anuke.mindustry.io.SaveIO.*;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
@@ -170,6 +170,7 @@ public class LoadDialog extends FloatingDialog{
|
||||
|
||||
ui.loadAnd(() -> {
|
||||
try{
|
||||
Net.reset();
|
||||
slot.load();
|
||||
state.set(State.playing);
|
||||
}catch(SaveException e){
|
||||
@@ -184,7 +185,6 @@ public class LoadDialog extends FloatingDialog{
|
||||
public void modifyButton(TextButton button, SaveSlot slot){
|
||||
button.clicked(() -> {
|
||||
if(!button.childrenPressed()){
|
||||
int build = slot.getBuild();
|
||||
runLoadSave(slot);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -43,6 +43,7 @@ public class LoadingFragment extends Fragment{
|
||||
}
|
||||
|
||||
public void show(String text){
|
||||
table.clearActions();
|
||||
table.touchable(Touchable.enabled);
|
||||
table.<Label>find("namelabel").setText(text);
|
||||
table.visible(true);
|
||||
@@ -51,6 +52,7 @@ public class LoadingFragment extends Fragment{
|
||||
}
|
||||
|
||||
public void hide(){
|
||||
table.clearActions();
|
||||
table.toFront();
|
||||
table.touchable(Touchable.disabled);
|
||||
table.actions(Actions.fadeOut(1f), Actions.visible(false));
|
||||
|
||||
Reference in New Issue
Block a user