summaryrefslogtreecommitdiff
path: root/NET/worlds/console/ChatDialog.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/ChatDialog.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/console/ChatDialog.java')
-rw-r--r--NET/worlds/console/ChatDialog.java143
1 files changed, 143 insertions, 0 deletions
diff --git a/NET/worlds/console/ChatDialog.java b/NET/worlds/console/ChatDialog.java
new file mode 100644
index 0000000..0f4821e
--- /dev/null
+++ b/NET/worlds/console/ChatDialog.java
@@ -0,0 +1,143 @@
+package NET.worlds.console;
+
+import java.awt.Button;
+import java.awt.Choice;
+import java.awt.Event;
+import java.awt.Font;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Label;
+import java.awt.Panel;
+import java.awt.TextField;
+
+public class ChatDialog extends PolledDialog {
+ private static final long serialVersionUID = 2346715931784644393L;
+ private Label fontsizeLabel = new Label(Console.message("Font-Size"));
+ private Label linesLabel = new Label(Console.message("Chat-Lines"));
+ private Label chatlengthLabel = new Label(Console.message("Chat-Buffer-Length"));
+ private Button okButton = new Button(Console.message("OK"));
+ private Button cancelButton = new Button(Console.message("Cancel"));
+ private static Font font = new Font(Console.message("MenuFont"), 0, 12);
+ private Choice fontsizeChoice = new Choice();
+ private Choice linesChoice = new Choice();
+ private TextField chatlengthField;
+
+ public ChatDialog(java.awt.Window parent, DialogReceiver receiver, String title, int defSize, int defLines, int defLength) {
+ super(parent, receiver, title, true);
+ this.chatlengthField = new TextField("" + defLength);
+
+ for (int i = 0; i <= 16; i++) {
+ this.fontsizeChoice.insert(i + 10 + "pt", i);
+ }
+
+ if (defSize >= 10 && defSize <= 16) {
+ this.fontsizeChoice.select(defSize - 10);
+ } else {
+ this.fontsizeChoice.select(2);
+ }
+
+ for (int i = 0; i < 24; i++) {
+ this.linesChoice.insert(i + 6 + " lines", i);
+ }
+
+ if (defLines >= 6 && defLines <= 30) {
+ this.linesChoice.select(defLines - 6);
+ } else {
+ this.linesChoice.select(0);
+ }
+
+ this.ready();
+ }
+
+ public int getFontsize() {
+ try {
+ return this.fontsizeChoice.getSelectedIndex() + 10;
+ } catch (Exception var2) {
+ return 12;
+ }
+ }
+
+ public int getLines() {
+ try {
+ return this.linesChoice.getSelectedIndex() + 6;
+ } catch (Exception var2) {
+ return 6;
+ }
+ }
+
+ public int getLength() {
+ try {
+ return Integer.parseInt(this.chatlengthField.getText());
+ } catch (Exception var2) {
+ return 20000;
+ }
+ }
+
+ @Override
+ protected void build() {
+ GridBagLayout gbag = new GridBagLayout();
+ this.setLayout(gbag);
+ GridBagConstraints c = new GridBagConstraints();
+ c.weightx = 1.0;
+ c.weighty = 1.0;
+ c.gridheight = 1;
+ c.fill = 0;
+ c.gridwidth = 2;
+ this.fontsizeLabel.setFont(font);
+ this.add(gbag, this.fontsizeLabel, c);
+ c.gridwidth = 0;
+ c.fill = 2;
+ this.add(gbag, this.fontsizeChoice, c);
+ c.fill = 0;
+ c.gridwidth = 2;
+ this.linesLabel.setFont(font);
+ this.add(gbag, this.linesLabel, c);
+ c.gridwidth = 0;
+ c.fill = 2;
+ this.add(gbag, this.linesChoice, c);
+ c.gridwidth = 2;
+ this.chatlengthLabel.setFont(font);
+ this.add(gbag, this.chatlengthLabel, c);
+ c.gridwidth = 0;
+ c.fill = 2;
+ this.chatlengthField.setFont(font);
+ this.add(gbag, this.chatlengthField, c);
+ Panel buttons = new Panel();
+ buttons.add(this.okButton);
+ buttons.add(this.cancelButton);
+ this.okButton.setFont(font);
+ this.cancelButton.setFont(font);
+ c.gridwidth = 0;
+ c.fill = 0;
+ this.add(gbag, buttons, c);
+ }
+
+ @Override
+ public void show() {
+ this.initialSize(320, 160);
+ super.show();
+ this.fontsizeChoice.requestFocus();
+ }
+
+ @Override
+ public boolean handleEvent(Event event) {
+ return event.id == 201 ? this.done(false) : super.handleEvent(event);
+ }
+
+ @Override
+ public boolean action(Event event, Object what) {
+ Object target = event.target;
+ if (target == this.cancelButton) {
+ this.done(false);
+ } else if (target == this.okButton) {
+ this.done(true);
+ }
+
+ return false;
+ }
+
+ @Override
+ public boolean keyDown(Event event, int key) {
+ return key == 27 ? this.done(false) : super.keyDown(event, key);
+ }
+}