summaryrefslogtreecommitdiff
path: root/NET/worlds/console/ChatPart.java
blob: dfdf1617a4ff331d8f79f2336180b46c9482834e (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
package NET.worlds.console;

import NET.worlds.scape.FrameEvent;
import NET.worlds.scape.Pilot;
import java.awt.Container;

public class ChatPart extends DuplexPart {
   private Window renderWindow;
   private DefaultConsole console;
   private static final String activateVCselfWhisper = "&|+debug<selfWhisperON";
   private static final String deactivateVCselfWhisper = "&|+debug<selfWhisperOFF";
   private static final String VCextraCommand = "&|+debug<VCcommand";

   @Override
   protected void sendText(String s) {
      int ii = s.indexOf(92);
      if (s.startsWith("&|+debug<")) {
         this.triggerLocalDebug(s);
      } else if (ii >= 0 && ii < s.length() - 1 && s.charAt(ii + 1) == 'u') {
         Pilot.sendText(Console.parseUnicode(s));
      } else {
         Pilot.sendText(s);
      }
   }

   @Override
   public void activate(Console c, Container f, Console prev) {
      super.activate(c, f, prev);
      this.console = (DefaultConsole)c;
   }

   @Override
   public void deactivate() {
      super.deactivate();
      this.renderWindow = null;
      this.console = null;
   }

   @Override
   public synchronized boolean handle(FrameEvent f) {
      boolean ret = super.handle(f);
      if (this.renderWindow == null && this.console != null) {
         RenderCanvas rc = this.console.getRender();
         if (rc != null) {
            Window w = rc.getWindow();
            if (w != null) {
               try {
                  w.hookChatLine(this.line);
                  this.renderWindow = w;
               } catch (WindowNotFoundException var6) {
               }
            }
         }
      }

      return ret;
   }

   private void triggerLocalDebug(String s) {
      if (s.startsWith("&|+debug<selfWhisperON")) {
         VoiceChat.activateSelfWhisper();
      }

      if (s.startsWith("&|+debug<selfWhisperOFF")) {
         VoiceChat.deactivateSelfWhisper();
      }

      if (s.startsWith("&|+debug<VCcommand")) {
         VoiceChat.setExtra(s);
      }
   }
}