summaryrefslogtreecommitdiff
path: root/NET/worlds/console/WhisperDialog.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/WhisperDialog.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/console/WhisperDialog.java')
-rw-r--r--NET/worlds/console/WhisperDialog.java135
1 files changed, 135 insertions, 0 deletions
diff --git a/NET/worlds/console/WhisperDialog.java b/NET/worlds/console/WhisperDialog.java
new file mode 100644
index 0000000..fd3e3f4
--- /dev/null
+++ b/NET/worlds/console/WhisperDialog.java
@@ -0,0 +1,135 @@
+package NET.worlds.console;
+
+import NET.worlds.core.IniFile;
+import NET.worlds.scape.Pilot;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Event;
+import java.awt.Panel;
+
+public class WhisperDialog extends PolledDialog {
+ private static final long serialVersionUID = -5767168735798633258L;
+ protected static java.awt.Window parent;
+ protected boolean building;
+ protected boolean isTrading = false;
+ protected WhisperPart whisperPart;
+ protected String partner;
+ protected boolean isBroadcast;
+ protected boolean built;
+ protected static int counter = 0;
+ protected static final int OFFSET = 20;
+ protected static final int OFF_TOT = 6;
+
+ static void setParent(java.awt.Window p) {
+ parent = p;
+ }
+
+ static void sendTalkMessage(final String msg) {
+ Main.register(new MainCallback() {
+ @Override
+ public void mainCallback() {
+ System.out.println("Sending a Text Message: " + msg);
+ Pilot.sendText(msg);
+ Main.unregister(this);
+ }
+ });
+ }
+
+ protected WhisperDialog(java.awt.Window parent, String partner) {
+ super(parent, null, Console.message("Whisper-to-from2") + Console.parseExtended(partner), false);
+ this.partner = partner;
+ this.isBroadcast = true;
+ if (partner.equals("room")) {
+ this.setTitle(Console.message("Broadcast-Users"));
+ } else if (partner.equals("world")) {
+ this.setTitle(Console.message("Broadcast-All"));
+ } else {
+ this.isBroadcast = false;
+ }
+
+ this.whisperPart = new WhisperPart(partner);
+ Console active = Console.getActive();
+ if (active != null) {
+ active.addPart(this.whisperPart);
+ }
+
+ int tier = counter / 6;
+ int pos = counter % 6;
+ this.setAlignment(1, ((pos + tier) % 12 - 5) * 20, (pos % 6 - 5) * 20);
+ counter++;
+ }
+
+ protected void takeFocus() {
+ this.whisperPart.forceTakeFocus();
+ }
+
+ @Override
+ public void show() {
+ super.show();
+ this.whisperPart.scrollToBottom();
+ int toFront = IniFile.override().getIniInt("whispersToFront", 0);
+ if (toFront != 0) {
+ this.toFront();
+ }
+ }
+
+ protected void send(String msg) {
+ this.whisperPart.println("< " + msg);
+ }
+
+ protected synchronized void print(String msg) {
+ this.whisperPart.println("> " + msg);
+ }
+
+ @Override
+ protected synchronized void build() {
+ this.building = false;
+ if (this.built) {
+ this.removeAll();
+ }
+
+ this.built = true;
+ Color bg1 = new Color(0, 0, 0);
+ Color bg2 = new Color(0, 192, 192);
+ Color fg1 = new Color(255, 255, 255);
+ this.setBackground(fg1);
+ this.setForeground(bg1);
+ this.whisperPart.line.setBackground(this.isTrading ? bg2 : fg1);
+ this.whisperPart.listen.setBackground(fg1);
+ Panel insListen = new InsetPanel(new BorderLayout(), 3, 1, 1, 1);
+ insListen.setBackground(Color.lightGray);
+ insListen.add("Center", this.whisperPart.listen.getComponent());
+ this.add("Center", insListen);
+ Panel insLine = new InsetPanel(new BorderLayout(), 2, 1, 2, 1);
+ insLine.setBackground(Color.lightGray);
+ insLine.add("Center", this.whisperPart.line);
+ this.add("South", insLine);
+ this.validate();
+ }
+
+ protected boolean setValue() {
+ return true;
+ }
+
+ @Override
+ public synchronized boolean keyDown(Event event, int key) {
+ this.whisperPart.line.requestFocus();
+ if (key == 10) {
+ this.whisperPart.trigger();
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Dimension preferredSize() {
+ return super.preferredSize();
+ }
+
+ @Override
+ public Dimension minimumSize() {
+ return super.minimumSize();
+ }
+}