3
3
import org .runejs .client .frame .ScreenController ;
4
4
import org .runejs .client .frame .ScreenMode ;
5
5
import org .runejs .client .input .MouseHandler ;
6
+ import org .runejs .client .language .Native ;
6
7
import org .runejs .client .media .renderable .actor .Actor ;
8
+ import org .runejs .client .media .renderable .actor .Player ;
7
9
import org .runejs .client .media .renderable .actor .PlayerAppearance ;
8
10
import org .runejs .client .net .PacketBuffer ;
9
11
import org .runejs .client .scene .SceneCluster ;
19
21
import java .net .InetAddress ;
20
22
import java .net .URL ;
21
23
22
- public abstract class GameShell extends Canvas implements Runnable , FocusListener , WindowListener {
24
+ public class GameShell extends Canvas implements GameErrorHandler , Runnable , FocusListener , WindowListener {
23
25
public static long [] tickSamples = new long [32 ];
24
26
25
27
public static long exitTimeInMillis = 0L ;
@@ -30,6 +32,74 @@ public abstract class GameShell extends Canvas implements Runnable, FocusListene
30
32
private final int millisPerTick = 20 ;
31
33
public boolean gameShellError = false ;
32
34
35
+ private Game game ;
36
+
37
+ public GameShell (Game game ) {
38
+ this .game = game ;
39
+ }
40
+
41
+ public static void main (String [] args ) {
42
+ Configuration .read ();
43
+ Native .username = Configuration .getUsername ();
44
+ Native .password = Configuration .getPassword ();
45
+ String [] params = new String []{"1" , "live" , "live" , "highmem" , "members" };
46
+ if (args .length != 0 ) {
47
+ params = args ;
48
+ }
49
+ try {
50
+ if (params .length != 5 )
51
+ Game .printHelp ();
52
+
53
+ Player .worldId = Integer .parseInt (params [0 ]);
54
+
55
+ // Location argument (to set server IP based on JMod location?)
56
+ if (params [1 ].equals ("live" )) {
57
+ Game .modewhere = 0 ;
58
+ } else if (params [1 ].equals ("office" )) {
59
+ Game .modewhere = 1 ;
60
+ } else if (params [1 ].equals ("local" )) {
61
+ Game .modewhere = 2 ;
62
+ } else {
63
+ Game .printHelp ();
64
+ }
65
+
66
+ if (params [2 ].equals ("live" ))
67
+ Game .modewhat = 0 ;
68
+ else if (!params [2 ].equals ("rc" )) {
69
+ if (params [2 ].equals ("wip" ))
70
+ Game .modewhat = 2 ;
71
+ else
72
+ Game .printHelp ();
73
+ } else
74
+ Game .modewhat = 1 ;
75
+
76
+ // Memory argument
77
+ if (params [3 ].equals ("lowmem" )) {
78
+ Class59 .setLowMemory ();
79
+ } else if (params [3 ].equals ("highmem" )) {
80
+ MovedStatics .setHighMemory ();
81
+ } else {
82
+ Game .printHelp ();
83
+ }
84
+
85
+ // Player membership argument
86
+ if (params [4 ].equals ("free" )) {
87
+ MovedStatics .membersWorld = false ;
88
+ } else if (params [4 ].equals ("members" )) {
89
+ MovedStatics .membersWorld = true ;
90
+ } else {
91
+ Game .printHelp ();
92
+ }
93
+
94
+ Game game = new Game ();
95
+ GameShell shell = new GameShell (game );
96
+ game .setErrorHandler (shell );
97
+ shell .openClientApplet ("client435" , 13 , 32 + Game .modewhat , InetAddress .getByName (Configuration .SERVER_ADDRESS ), 435 );
98
+
99
+ } catch (Exception exception ) {
100
+ exception .printStackTrace ();
101
+ }
102
+ }
33
103
34
104
public void run () {
35
105
if (Signlink .javaVendor != null ) {
@@ -59,7 +129,7 @@ public void run() {
59
129
}
60
130
setCanvas ();
61
131
ProducingGraphicsBuffer_Sub1 .aProducingGraphicsBuffer_2213 = MovedStatics .createGraphicsBuffer (Class12 .width , MovedStatics .height , MouseHandler .gameCanvas );
62
- startup ();
132
+ this . game . startup ();
63
133
SceneCluster .gameTimer = Timer .create ();
64
134
SceneCluster .gameTimer .start ();
65
135
@@ -80,7 +150,7 @@ public void run() {
80
150
MovedStatics .aBoolean571 = clientFocused ;
81
151
}
82
152
83
- processGameLoop ();
153
+ this . game . processGameLoop ();
84
154
}
85
155
86
156
runAfterGameLoop ();
@@ -99,7 +169,7 @@ public synchronized void closeGameShell() {
99
169
/* empty */
100
170
}
101
171
try {
102
- close ();
172
+ this . game . close ();
103
173
} catch (Exception exception ) {
104
174
/* empty */
105
175
}
@@ -160,14 +230,10 @@ public void start() {
160
230
exitTimeInMillis = 0L ;
161
231
}
162
232
163
- public abstract void processGameLoop ();
164
-
165
233
public void focusLost (FocusEvent arg0 ) {
166
234
clientFocused = false ;
167
235
}
168
236
169
- public abstract void close ();
170
-
171
237
public synchronized void paint (Graphics arg0 ) {
172
238
if (this == currentGameShell && !PacketBuffer .closedClient ) {
173
239
MovedStatics .clearScreen = true ;
@@ -255,7 +321,10 @@ public void runAfterGameLoop() {
255
321
MouseHandler .gameCanvas .setLocation (insets .left , insets .top );
256
322
}
257
323
}
258
- updateStatusText ();
324
+ if (MovedStatics .aBoolean1575 ) {
325
+ this .setCanvas ();
326
+ }
327
+ this .game .updateStatusText ();
259
328
}
260
329
261
330
// public AppletContext getAppletContext() {
@@ -297,8 +366,6 @@ public URL getCodeBase() {
297
366
return this .getDocumentBase ();
298
367
}
299
368
300
- public abstract void startup ();
301
-
302
369
public void update (Graphics graphics ) {
303
370
paint (graphics );
304
371
}
@@ -342,8 +409,6 @@ public synchronized void setCanvas() {
342
409
MovedStatics .aLong174 = System .currentTimeMillis ();
343
410
}
344
411
345
- public abstract void updateStatusText ();
346
-
347
412
public void windowDeiconified (WindowEvent windowEvent ) {
348
413
}
349
414
@@ -352,4 +417,9 @@ public void windowClosed(WindowEvent windowEvent) {
352
417
353
418
public void windowActivated (WindowEvent windowEvent ) {
354
419
}
420
+
421
+ @ Override
422
+ public void handleGameError (String errorMessage ) {
423
+ this .openErrorPage (errorMessage );
424
+ }
355
425
}
0 commit comments