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