summaryrefslogtreecommitdiff
path: root/NET/worlds/console/InternetConnectionDialog.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-12 22:33:32 -0800
committerFuwn <[email protected]>2026-02-12 22:33:32 -0800
commitc7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch)
treedf9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/console/InternetConnectionDialog.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/console/InternetConnectionDialog.java')
-rw-r--r--NET/worlds/console/InternetConnectionDialog.java79
1 files changed, 79 insertions, 0 deletions
diff --git a/NET/worlds/console/InternetConnectionDialog.java b/NET/worlds/console/InternetConnectionDialog.java
new file mode 100644
index 0000000..66a3c7c
--- /dev/null
+++ b/NET/worlds/console/InternetConnectionDialog.java
@@ -0,0 +1,79 @@
+package NET.worlds.console;
+
+import NET.worlds.network.Galaxy;
+import NET.worlds.network.VarErrorException;
+import java.awt.BorderLayout;
+import java.awt.Button;
+import java.awt.Event;
+import java.awt.Font;
+import java.awt.Panel;
+
+public class InternetConnectionDialog extends PolledDialog {
+ private static final long serialVersionUID = 612016940893432560L;
+ private String msg;
+ private Button okButton = new Button(Console.message("Retry"));
+ private Button cancelButton = new Button(Console.message("Single-user"));
+ private static boolean firstTimeDone;
+ private static boolean choseSingleUserMode;
+ private static Font bfont = new Font(Console.message("ButtonFont"), 0, 12);
+
+ public static boolean isFirstTimeDone() {
+ return firstTimeDone;
+ }
+
+ public static boolean choseSingleUserMode() {
+ return choseSingleUserMode;
+ }
+
+ public InternetConnectionDialog(Galaxy galaxy, VarErrorException ve) {
+ super(Console.getFrame(), galaxy, Console.message("Internet-Connection"), true);
+ this.setAlignment(1);
+ this.msg = ve.getMsg().replace('\n', ' ');
+ this.ready();
+ }
+
+ @Override
+ protected boolean done(boolean confirmed) {
+ boolean ret = super.done(confirmed);
+ choseSingleUserMode = !confirmed;
+ firstTimeDone = true;
+ return ret;
+ }
+
+ @Override
+ protected void build() {
+ this.setLayout(new BorderLayout());
+ Panel txtPanel = new Panel(new BorderLayout());
+ txtPanel.add("Center", new TextCanvas(this.msg, 400));
+ txtPanel.add("North", new Filler(10, 10));
+ txtPanel.add("South", new Filler(10, 10));
+ txtPanel.add("East", new Filler(10, 10));
+ txtPanel.add("West", new Filler(10, 10));
+ this.add("Center", txtPanel);
+ Panel buttons = new Panel();
+ this.okButton.setFont(bfont);
+ this.cancelButton.setFont(bfont);
+ buttons.add(this.okButton);
+ buttons.add(this.cancelButton);
+ this.add("South", buttons);
+ }
+
+ @Override
+ public boolean action(Event event, Object what) {
+ Object target = event.target;
+ if (target == this.okButton) {
+ return this.done(true);
+ } else {
+ return target == this.cancelButton ? this.done(false) : false;
+ }
+ }
+
+ @Override
+ public boolean keyDown(Event event, int key) {
+ if (key == 27) {
+ return this.done(false);
+ } else {
+ return key == 10 ? this.done(true) : super.keyDown(event, key);
+ }
+ }
+}