|
6 | 6 | import com.badlogic.gdx.graphics.GL20;
|
7 | 7 | import com.rolandoislas.drcsimclient.audio.Audio;
|
8 | 8 | import com.rolandoislas.drcsimclient.control.Control;
|
| 9 | +import com.rolandoislas.drcsimclient.data.ArgumentParser; |
| 10 | +import com.rolandoislas.drcsimclient.data.Constants; |
9 | 11 | import com.rolandoislas.drcsimclient.net.Sockets;
|
10 | 12 | import com.rolandoislas.drcsimclient.stage.Stage;
|
11 | 13 | import com.rolandoislas.drcsimclient.stage.StageConnect;
|
12 |
| -import com.rolandoislas.drcsimclient.stage.StageControl; |
13 | 14 | import com.rolandoislas.drcsimclient.stage.StageLoad;
|
14 | 15 | import com.rolandoislas.drcsimclient.util.logging.Logger;
|
15 | 16 |
|
16 | 17 | public class Client extends ApplicationAdapter {
|
| 18 | + public static ArgumentParser args; |
17 | 19 | public static Audio audio;
|
18 | 20 | private static Stage stage;
|
19 | 21 | public static Sockets sockets;
|
20 | 22 | public static Control[] controls;
|
21 | 23 |
|
22 |
| - public Client(Control[] controls, Audio audio) { |
| 24 | + public Client(Control[] controls, Audio audio, ArgumentParser argumentParser) { |
23 | 25 | Client.controls = controls;
|
24 | 26 | Client.audio = audio;
|
| 27 | + Client.args = argumentParser; |
| 28 | + Logger.info("Starting %1$s version %2$s", Constants.NAME, Constants.VERSION); |
| 29 | + } |
| 30 | + |
| 31 | + public Client(Control[] controls, Audio audio) { |
| 32 | + this(controls, audio, new ArgumentParser()); |
25 | 33 | }
|
26 | 34 |
|
27 | 35 | @Override
|
@@ -65,13 +73,17 @@ public static void setStage(Stage stage) {
|
65 | 73 | Gdx.input.setInputProcessor(stage);
|
66 | 74 | }
|
67 | 75 |
|
68 |
| - public static boolean connect(String ip) { |
| 76 | + public static boolean connect(String ip, boolean setStageOnFailure) { |
69 | 77 | sockets.dispose();
|
70 | 78 | sockets.setIp(ip);
|
71 | 79 | try {
|
72 | 80 | sockets.connect();
|
73 | 81 | } catch (Exception e) {
|
74 |
| - setStage(new StageConnect(e.getMessage())); |
| 82 | + Logger.info("Failed to connect to host \"%1$s\"", ip); |
| 83 | + Logger.info(e.getMessage()); |
| 84 | + Logger.exception(e); |
| 85 | + if (setStageOnFailure) |
| 86 | + setStage(new StageConnect(e.getMessage())); |
75 | 87 | return false;
|
76 | 88 | }
|
77 | 89 | return true;
|
|
0 commit comments