summaryrefslogtreecommitdiff
path: root/NET/worlds/console/Window.java
blob: 04d61c27cb90d7dcd10c8ec7696a3b27d855ce6e (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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
package NET.worlds.console;

import NET.worlds.scape.Camera;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.TextArea;

public class Window {
   private static Window activeWindow;
   private int hWndGamma;
   private int hWndFrame;
   private static int hInstGamma;
   private static int hWndFrameStatic;
   public static final int NORMAL = 0;
   public static final int MINIMIZED = 1;
   public static final int MAXIMIZED = 2;
   private int windowInstancePtr;

   public Window(String frameTitle, Point loc, Dimension dim, Camera cam, boolean interceptEvents) throws WindowNotFoundException {
      nativeInit();
      if (hWndFrameStatic != 0) {
         this.hWndFrame = hWndFrameStatic;
      } else {
         this.hWndFrame = findWindow(frameTitle);
      }

      if (this.hWndFrame != 0) {
         this.hWndGamma = findOrMakeChildWindow(this.hWndFrame, loc.x, loc.y, dim.width, dim.height);
      }

      if (this.hWndGamma == 0) {
         throw new WindowNotFoundException("No such window");
      } else {
         if (hWndFrameStatic == 0) {
            hWndFrameStatic = this.hWndFrame;
         }

         hInstGamma = this.install(interceptEvents);
         this.maybeResize(dim.width, dim.height);
         if (interceptEvents) {
            activeWindow = this;
         }
      }
   }

   public void hookChatLine(Component chatLine) throws WindowNotFoundException {
      assert activeWindow == this;

      Dimension dim = chatLine.getSize();

      try {
         Point loc = chatLine.getLocationOnScreen();
         int hwndChatLine = findChildWindow(hWndFrameStatic, loc.x, loc.y, dim.width, dim.height);
         if (hwndChatLine != 0) {
            setChatLine(hwndChatLine);
            return;
         }
      } catch (Exception var5) {
      }

      throw new WindowNotFoundException();
   }

   private static native void setChatLine(int var0);

   public static native int getVoiceChatWParam();

   public static native int getVoiceChatLParam();

   public static native void resetVoiceChatMsg();

   public static native void doMicrosoftVMHacks();

   public static native boolean usingMicrosoftVMHacks();

   public static native boolean getActivated();

   public static native boolean isActivated();

   public static native int getGammaProcessID();

   public native void dispose();

   public static Window getMainWindow() {
      return activeWindow;
   }

   public native int getHwnd();

   public void hideNativeWindow() {
      if (this.hWndGamma != 0) {
         this.nativeHideChildWindow(this.hWndGamma);
      }
   }

   public void showNativeWindow() {
      if (this.hWndGamma != 0) {
         this.nativeShowChildWindow(this.hWndGamma);
      }
   }

   native void nativeHideChildWindow(int var1);

   native void nativeShowChildWindow(int var1);

   public static int getHWnd() {
      return activeWindow == null ? 0 : activeWindow.hWndGamma;
   }

   public static int getHInst() {
      return hInstGamma;
   }

   public native void maybeResize(int var1, int var2);

   public native void setDeltaMode(boolean var1);

   public static native int getAndResetUserActionCount();

   public native boolean getDeltaMode();

   public static native void makeJavaReleaseCapture();

   public native void reShape(int var1, int var2, int var3, int var4);

   public native int fullWidth();

   public native int fullHeight();

   public static native int findWindow(String var0);

   public static native int getFrameWindow();

   public static native void hideCursor();

   public static native int[] getHiddenCursorDelta();

   public static native void setCursor(int var0);

   public static native int getWindowState(int var0);

   public static native void setWindowState(int var0, int var1);

   public static native void setForegroundWindow(int var0);

   public static native void setVideoMode(int var0, int var1, int var2);

   public static native void nativeInit();

   private native int install(boolean var1);

   static synchronized int findChildWindow(int hWndParent, int x, int y, int w, int h) {
      return nativeFindChildWindow(hWndParent, x, y, w, h);
   }

   static synchronized int findOrMakeChildWindow(int hWndParent, int x, int y, int w, int h) {
      return nativeFindOrMakeChildWindow(hWndParent, x, y, w, h);
   }

   public static boolean isLastLineVisible(int hwnd, TextArea ta) {
      Dimension s = ta.getSize();
      return nativeIsLastLineVisible(hwnd, s.width, s.height) != 0;
   }

   private static native int nativeIsLastLineVisible(int var0, int var1, int var2);

   private static native int nativeFindChildWindow(int var0, int var1, int var2, int var3, int var4);

   private static native int nativeFindOrMakeChildWindow(int var0, int var1, int var2, int var3, int var4);

   public static int playVideoClip(Component c, String name) {
      Point p = c.getLocationOnScreen();
      Dimension s = c.getSize();
      return playVideoClip(name, findChildWindow(activeWindow.hWndFrame, p.x, p.y, s.width, s.height));
   }

   public static native boolean isVideoPlaying(int var0);

   private static native int playVideoClip(String var0, int var1);

   public static native void hookWinAPIs(String var0);

   public static native int getWindowWidth(int var0);

   public static native int getWindowHeight(int var0);

   public static native void allowFGJavaPalette(boolean var0);

   public static int getFrameHandle() {
      return hWndFrameStatic;
   }

   public static native int getSystemMetrics(int var0);
}