summaryrefslogtreecommitdiff
path: root/NET/worlds/console/AboutDialog.java
blob: 4fea33682ab2a257accba9e4f5480583ec336496 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package NET.worlds.console;

import NET.worlds.core.IniFile;
import NET.worlds.core.Std;
import NET.worlds.network.NetUpdate;
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Color;
import java.awt.Component;
import java.awt.Event;
import java.awt.Font;
import java.awt.Frame;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Label;
import java.awt.Panel;
import java.awt.TextArea;
import java.util.Enumeration;
import java.util.Vector;

public class AboutDialog extends PolledDialog {
   private static final long serialVersionUID = -2810306367601133331L;
   public static final String JavaVersion = "1890a40";
   Button okButton = new Button(Console.message("OK"));
   private static Font font = new Font(Console.message("ConsoleFont"), 0, 12);
   private static Font bfont = new Font(Console.message("ButtonFont"), 0, 12);
   String apptitle;

   AboutDialog(String apptitle, Frame frame) {
      super(frame, null, Console.message("About") + Std.getProductName(), true);
      this.apptitle = apptitle;
      this.ready();
   }

   private Component setConstraints(GridBagLayout gbag, Component comp, GridBagConstraints c) {
      gbag.setConstraints(comp, c);
      return comp;
   }

   @Override
   protected void build() {
      this.setBackground(Color.white);
      this.setLayout(new BorderLayout());
      this.add("North", new Filler(10, 10));
      this.add("South", new Filler(10, 10));
      this.add("East", new Filler(10, 10));
      this.add("West", new Filler(10, 10));
      GridBagLayout gbag = new GridBagLayout();
      Panel p = new Panel(gbag);
      p.setFont(font);
      GridBagConstraints c = new GridBagConstraints();
      c.fill = 0;
      c.weightx = 1.0;
      c.weighty = 1.0;
      c.gridwidth = 0;
      c.gridheight = 1;
      String logo = IniFile.override().getIniString("AboutLogo", Console.message("wlogo.gif"));
      p.add(this.setConstraints(gbag, new ImageCanvas(logo), c));
      c.weightx = 0.0;
      c.weighty = 0.0;
      p.add(this.setConstraints(gbag, new Label(this.apptitle), c));
      if (Gamma.getShaper() != null) {
         p.add(this.setConstraints(gbag, new Label(Console.message("about-box-build-date") + " " + Std.getBuildInfo() + ":" + "1890a40"), c));
      } else {
         p.add(this.setConstraints(gbag, new Label(Console.message("about-box-rev") + " " + Std.getVersion() + " : " + "1890a40"), c));
      }

      Vector<String> worlds = NetUpdate.aboutWorlds();
      TextArea worldList = new TextArea(10, 40);
      worldList.setEditable(false);
      p.add(this.setConstraints(gbag, worldList, c));
      Enumeration<String> e = worlds.elements();

      while (e.hasMoreElements()) {
         worldList.append(e.nextElement() + "\n");
      }

      p.add(this.setConstraints(gbag, new Label(Console.message("about-box-1")), c));
      p.add(this.setConstraints(gbag, new Label(Console.message("about-box-2")), c));
      this.okButton.setFont(bfont);
      p.add(this.setConstraints(gbag, this.okButton, c));
      this.add("Center", p);
   }

   @Override
   public boolean action(Event event, Object what) {
      return event.target == this.okButton ? this.done(true) : false;
   }

   @Override
   public boolean keyDown(Event event, int key) {
      return key != 27 && key != 10 ? super.keyDown(event, key) : this.done(true);
   }

   @Override
   public void show() {
      super.show();
      this.okButton.requestFocus();
   }
}