summaryrefslogtreecommitdiff
path: root/NET/worlds/console/PersonalInfoDialog.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/PersonalInfoDialog.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/console/PersonalInfoDialog.java')
-rw-r--r--NET/worlds/console/PersonalInfoDialog.java113
1 files changed, 113 insertions, 0 deletions
diff --git a/NET/worlds/console/PersonalInfoDialog.java b/NET/worlds/console/PersonalInfoDialog.java
new file mode 100644
index 0000000..db5c6e2
--- /dev/null
+++ b/NET/worlds/console/PersonalInfoDialog.java
@@ -0,0 +1,113 @@
+package NET.worlds.console;
+
+import java.awt.Button;
+import java.awt.Event;
+import java.awt.Font;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Label;
+import java.awt.TextArea;
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+class PersonalInfoDialog extends PolledDialog {
+ private static final long serialVersionUID = 1200424099007473332L;
+ private Vector<String> info;
+ private Button okButton = new Button(Console.message("OK"));
+ private static Font font = new Font(Console.message("MenuFont"), 0, 12);
+ private static Font bfont = new Font(Console.message("ButtonFont"), 0, 12);
+
+ public PersonalInfoDialog(String name, Vector<String> info) {
+ super(Console.getFrame(), null, Console.message("Personal-Info") + name, false);
+ this.info = info;
+ this.ready();
+ }
+
+ @Override
+ protected void build() {
+ GridBagLayout gbag = new GridBagLayout();
+ this.setLayout(gbag);
+ GridBagConstraints c = new GridBagConstraints();
+
+ try {
+ int count = this.info.size();
+ int i = 0;
+
+ while (i < count) {
+ StringTokenizer tok = new StringTokenizer(this.info.elementAt(i++), ":");
+ String heading = tok.nextToken();
+ c.gridwidth = -1;
+ c.gridheight = 1;
+ c.fill = 1;
+ Label lHead = new Label(heading, 1);
+ lHead.setFont(font);
+ this.add(gbag, lHead, c);
+ int totalLines = Integer.parseInt(tok.nextToken());
+ int displayLines = Math.max(Math.min(3, totalLines), 1);
+ int maxLine = 0;
+
+ for (int j = 0; j < totalLines; j++) {
+ maxLine = Math.max(maxLine, this.info.elementAt(i + j).length());
+ }
+
+ int scrollFlags = 3;
+ if (maxLine > 40) {
+ if (totalLines > ++displayLines) {
+ scrollFlags = 0;
+ } else {
+ scrollFlags = 2;
+ }
+ } else if (totalLines > displayLines) {
+ scrollFlags = 1;
+ }
+
+ TextArea t = new TextArea("", displayLines, 40, scrollFlags);
+ t.setFont(font);
+
+ for (int j = 0; j < totalLines; j++) {
+ if (j > 0) {
+ t.append("\n");
+ }
+
+ t.append(this.info.elementAt(i++));
+ }
+
+ c.fill = 0;
+ c.gridwidth = 0;
+ c.gridheight = displayLines;
+ t.setEditable(false);
+ this.add(gbag, t, c);
+ }
+ } catch (Exception var14) {
+ this.removeAll();
+ c.fill = 0;
+ c.gridwidth = 0;
+ c.gridheight = 1;
+ Label lFormat = new Label(Console.message("Format-error"));
+ lFormat.setFont(font);
+ this.add(gbag, lFormat, c);
+ }
+
+ c.fill = 0;
+ c.gridwidth = 0;
+ c.gridheight = 1;
+ this.okButton.setFont(bfont);
+ this.add(gbag, this.okButton, c);
+ }
+
+ @Override
+ public boolean action(Event event, Object what) {
+ return event.target == this.okButton ? this.done(false) : false;
+ }
+
+ @Override
+ public boolean keyDown(Event event, int key) {
+ return key != 27 && key != 10 ? super.keyDown(event, key) : this.done(false);
+ }
+
+ @Override
+ public void show() {
+ super.show();
+ this.okButton.requestFocus();
+ }
+}