summaryrefslogtreecommitdiff
path: root/NET/worlds/console/WebControlImp.java
blob: 45cbfdec44c91c7e11a51c705af7a24454705081 (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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
package NET.worlds.console;

import NET.worlds.core.Std;
import NET.worlds.network.NetUpdate;
import NET.worlds.network.WorldServer;
import NET.worlds.scape.Pilot;
import NET.worlds.scape.Room;
import NET.worlds.scape.TextureSurfaceRenderer;
import java.util.Enumeration;
import java.util.Vector;

public abstract class WebControlImp implements TextureSurfaceRenderer {
   public static final int downloadBegin = 0;
   public static final int downloadEnd = 1;
   public static final int titleChanged = 2;
   public static final int propertyChanged = 3;
   public static final int statusChanged = 4;
   public static final int commandStateChanged = 5;
   Vector<WebControlListener> listeners = new Vector<WebControlListener>();

   WebControlImp(int hwnd) {
   }

   public static String processURL(String pURL) {
      if (pURL.indexOf("$USERNAME") == -1
         && pURL.indexOf("$UPGRADESERVER") == -1
         && pURL.indexOf("$SCRIPTSERVER") == -1
         && pURL.indexOf("$SERIALNUM") == -1
         && pURL.indexOf("$WORLD") == -1
         && pURL.indexOf("$ROOM") == -1) {
         return pURL;
      } else {
         pURL = Std.replaceStr(pURL, "$UPGRADESERVER", NetUpdate.getUpgradeServerURL());
         if (Console.getActive() != null) {
            pURL = Std.replaceStr(pURL, "$SCRIPTSERVER", Console.getActive().getScriptServer());
         } else if (pURL.indexOf("$SCRIPTSERVER") != -1) {
            return null;
         }

         if (Pilot.getActive() != null) {
            Pilot p = Pilot.getActive();
            if (p != null && p.getWorld() != null) {
               pURL = Std.replaceStr(pURL, "$WORLD", p.getWorld().toString());
            }

            Room r = Pilot.getActiveRoom();
            if (r != null) {
               pURL = Std.replaceStr(pURL, "$ROOM", Pilot.getActiveRoom().toString());
            }

            WorldServer w = Pilot.getActive().getServer();
            if (w != null && w.getGalaxy() != null) {
               String name = w.getGalaxy().getChatname();
               if (pURL.indexOf("$USERNAME") != -1) {
                  if (name == null || name.equals("")) {
                     return null;
                  }

                  pURL = Std.replaceStr(pURL, "$USERNAME", name);
               }

               String serial = w.getGalaxy().getSerialNum();
               if (pURL.indexOf("$SERIALNUM") != -1) {
                  if (serial == null || serial.equals("")) {
                     return null;
                  }

                  pURL = Std.replaceStr(pURL, "$SERIALNUM", serial);
               }
            } else if (pURL.indexOf("$SERIALNUM") != -1 || pURL.indexOf("$USERNAME") != -1) {
               return null;
            }
         }

         return pURL.indexOf("$SERIALNUM") == -1 && pURL.indexOf("$USERNAME") == -1 ? pURL : null;
      }
   }

   public abstract boolean setURL(String var1);

   public abstract boolean setURL(String var1, String var2);

   public abstract void goBack();

   public abstract void goForward();

   public abstract void stop();

   public abstract void refresh();

   public abstract void home();

   public abstract void resize(int var1, int var2, int var3, int var4);

   public abstract int getHWND();

   @Override
   public abstract void renderTo(int var1);

   public void addListener(WebControlListener l) {
      this.listeners.addElement(l);
   }

   public void removeListener(WebControlListener l) {
      this.listeners.removeElement(l);
   }

   void receiveEvent(int eventID) {
      Enumeration<WebControlListener> e = this.listeners.elements();

      while (e.hasMoreElements()) {
         WebControlListener l = e.nextElement();
         if (l != null) {
            l.webControlEvent(eventID);
         }
      }
   }

   public void detach() {
      this.listeners.removeAllElements();
   }
}