-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTWIT.pde
executable file
·400 lines (312 loc) · 12.1 KB
/
TWIT.pde
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
// *****************************
// Timeway's Interfacing Toolkit
// *****************************
Object runTWIT(int opcode, Object[] args) {
try {
switch (opcode) {
case 1:
int val = (int)args[0];
String mssg = "Hello World "+val;
timewayEngine.console.log(mssg);
return mssg;
// print(Object[] args...)
case 2:
// print function can have unlimited args
// First arg is the size of the args list.
int len = min((int)args[0], 127);
String message = "";
for (int i = 1; i < len; i++) {
String element = "";
if (args[i] instanceof String) {
element = (String)args[i];
}
else if (args[i] instanceof Integer) {
element = str((int)args[i]);
}
else if (args[i] instanceof Float) {
element = str((float)args[i]);
}
else if (args[i] instanceof Long) {
element = str((long)args[i]);
}
else if (args[i] instanceof Boolean) {
element = str((boolean)args[i]);
}
else {
if (args[i] != null) element = args[i].getClass().getSimpleName();
}
message += (element + " ");
}
timewayEngine.console.log(message);
break;
case 3:
timewayEngine.console.warn((String)args[0]);
break;
// fileMkdir(String path) {
case 1000:
timewayEngine.file.mkdir((String)args[0]);
break;
// fileCopy(String src, String dest)
case 1001:
return timewayEngine.file.copy((String)args[0], (String)args[1]);
// fileGetLastModified
case 1002:
return timewayEngine.file.getLastModified((String)args[0]);
// fileGetExt
case 1003:
return timewayEngine.file.getExt((String)args[0]);
// FileGetDir
case 1004:
return timewayEngine.file.getDir((String)args[0]);
// fileIsDirectory
case 1005:
return timewayEngine.file.isDirectory((String)args[0]);
// fileGetPrevDir
case 1006:
return timewayEngine.file.getPrevDir((String)args[0]);
// fileGetRelativeDir
case 1007:
return timewayEngine.file.getRelativeDir((String)args[0], (String)args[1]);
// fileRelativeToAbsolute
case 1008:
return timewayEngine.file.relativeToAbsolute((String)args[0], (String)args[1]);
// fileDirectorify
case 1010:
return timewayEngine.file.directorify((String)args[0]);
// fileGetMyDir
case 1011:
return timewayEngine.file.getMyDir();
// fileExists
case 1012:
return timewayEngine.file.exists((String)args[0]);
// fileGetSize
case 1013:
return timewayEngine.file.fileSize((String)args[0]);
// fileIsImage
case 1014:
return timewayEngine.file.isImage((String)args[0]);
// fileGetFilename
case 1015:
return timewayEngine.file.getFilename((String)args[0]);
// fileGetIsolatedFilename
case 1016:
return timewayEngine.file.getIsolatedFilename((String)args[0]);
// fileAtRootDir
case 1017:
return timewayEngine.file.atRootDir((String)args[0]);
// fileExtToIco
case 1009:
return timewayEngine.file.typeToIco(timewayEngine.file.extToType((String)args[0]));
// fileHidden
case 1018:
return timewayEngine.file.fileHidden((String)args[0]);
// fileUnhide
case 1019:
return timewayEngine.file.unhide((String)args[0]);
// fileCountFiles
case 1020:
return timewayEngine.file.countFiles((String)args[0]);
// fileOpen
case 1021:
timewayEngine.file.open((String)args[0]);
break;
// fileOpenEntryReadonly
case 1022:
timewayEngine.file.openEntryReadonly((String)args[0]);
break;
// uiAddSpriteSystem
case 2000:
timewayEngine.ui.addSpriteSystem(timewayEngine, (String)args[0], (String)args[1]);
timewayEngine.ui.getSpriteSystem((String)args[0]).interactable = (boolean)args[2];
break;
// uiUseSpriteSystem
case 2001:
timewayEngine.ui.useSpriteSystem(timewayEngine.ui.getSpriteSystem((String)args[0]));
timewayEngine.ui.usingTWITSpriteSystem = true;
break;
// uiSetSpriteSystemInteractable
case 2002:
timewayEngine.ui.getSpriteSystem((String)args[0]).interactable = (boolean)args[1];
break;
// uiSprite
case 2003:
timewayEngine.ui.getInUseSpriteSystem().sprite((String)args[0], (String)args[1]);
break;
// uiButton
case 2004:
return timewayEngine.ui.buttonVary((String)args[0], (String)args[1], (String)args[2]);
// uiButtonHover
case 2005:
return timewayEngine.ui.buttonHoverVary((String)args[0]);
// uiBasicButton
case 2006:
return timewayEngine.ui.basicButton((String)args[0], (float)args[1], (float)args[2], (float)args[3], (float)args[4]);
// uiLoadingIcon
case 2007:
timewayEngine.ui.loadingIcon((float)args[0], (float)args[1], (float)args[2]);
break;
// uiUpdateSpriteSystems
case 2008:
timewayEngine.ui.updateSpriteSystems();
break;
// getPluginPath
case 3000:
if (timewayEngine.currScreen instanceof PixelRealmWithUI) {
return ((PixelRealmWithUI)timewayEngine.currScreen).currRealm.realmPluginPath;
}
return "";
// getRunPoint
case 3001:
if (timewayEngine.currScreen instanceof PixelRealmWithUI) {
return ((PixelRealmWithUI)timewayEngine.currScreen).apiMode;
}
return "";
// prPauseRefresher
case 3002:
if (timewayEngine.currScreen instanceof PixelRealmWithUI) {
((PixelRealmWithUI)timewayEngine.currScreen).issueRefresherCommand(PixelRealm.REFRESHER_LONGPAUSE);
}
break;
// prResumeRefresher
case 3003:
if (timewayEngine.currScreen instanceof PixelRealmWithUI) {
((PixelRealmWithUI)timewayEngine.currScreen).issueRefresherCommand(PixelRealm.REFRESHER_EXITLONGPAUSE);
}
break;
// prPrompt
case 3004:
if (timewayEngine.currScreen instanceof PixelRealmWithUI) {
((PixelRealmWithUI)timewayEngine.currScreen).prompt((String)args[0], (String)args[1], (int)args[2]);
}
break;
// prMenuShown()
case 3005:
if (timewayEngine.currScreen instanceof PixelRealmWithUI) {
return ((PixelRealmWithUI)timewayEngine.currScreen).menuShown;
}
return false;
// prCreateCustomMenu
case 3006:
if (timewayEngine.currScreen instanceof PixelRealmWithUI) {
((PixelRealmWithUI)timewayEngine.currScreen).createCustomMenu((String)args[0], (String)args[1], (Runnable)args[2]);
}
break;
// prCloseMenu
case 3007:
if (timewayEngine.currScreen instanceof PixelRealmWithUI) {
((PixelRealmWithUI)timewayEngine.currScreen).closeMenu();
}
break;
// soundPlay()
case 4000:
timewayEngine.sound.playSound((String)args[0], (float)args[1]);
break;
// soundPlayOnce()
case 4001:
timewayEngine.sound.playSoundOnce((String)args[0]);
break;
// soundPause()
case 4002:
timewayEngine.sound.pauseSound((String)args[0]);
break;
// soundLoop()
case 4003:
timewayEngine.sound.loopSound((String)args[0]);
break;
// soundLoop()
case 4004:
timewayEngine.sound.loopSound((String)args[0]);
break;
// soundSetVolume()
case 4005:
timewayEngine.sound.setSoundVolume((String)args[0], (float)args[1]);
break;
// soundSetMasterVolume()
case 4006:
timewayEngine.sound.setMasterVolume((float)args[0]);
break;
// soundSetMusicVolume()
case 4007:
timewayEngine.sound.setMusicVolume((float)args[0]);
break;
// soundStreamMusic
case 4008:
timewayEngine.sound.streamMusic((String)args[0]);
break;
// soundStreamMusicWithFade
case 4009:
timewayEngine.sound.streamMusicWithFade((String)args[0]);
break;
// soundStopMusic
case 4010:
timewayEngine.sound.stopMusic();
break;
// soundPauseMusic()
case 4011:
timewayEngine.sound.pauseMusic();
break;
// soundContinueMusic()
case 4012:
timewayEngine.sound.continueMusic();
break;
// soundFadeAndStopMusic
case 4013:
timewayEngine.sound.fadeAndStopMusic();
break;
// soundSyncMusic
case 4014:
timewayEngine.sound.syncMusic((float)args[0]);
break;
// soundGetMusicDuration()
case 4015:
return timewayEngine.sound.getCurrentMusicDuration();
// displayWidth()
case 5000:
return timewayEngine.display.WIDTH;
// displayHeight()
case 5001:
return timewayEngine.display.HEIGHT;
// displayDelta();
case 5002:
return timewayEngine.display.getDelta();
// displayTime()
case 5003:
return timewayEngine.display.getTime();
// displayTimeSeconds()
case 5004:
return timewayEngine.display.getTimeSeconds();
// displayGetUpperBarY()
case 5005:
return timewayEngine.currScreen.myUpperBarWeight;
// displayGetLowerBarY()
case 5006:
return timewayEngine.display.HEIGHT-timewayEngine.currScreen.myLowerBarWeight;
// displayLiveFPS()
case 5007:
return timewayEngine.display.getLiveFPS();
// displayImg(String name, float x, float y, float w, float h)
case 5008:
timewayEngine.display.img((String)args[0], (float)args[1], (float)args[2], (float)args[3], (float)args[4]);
break;
// displayImg(String name, float x, float y)
case 5009:
timewayEngine.display.img((String)args[0], (float)args[1], (float)args[2]);
break;
// imgCentre(String name, float x, float y, float w, float h)
case 5010:
timewayEngine.display.imgCentre((String)args[0], (float)args[1], (float)args[2], (float)args[3], (float)args[4]);
break;
// imgCentre(String name, float x, float y)
case 5011:
timewayEngine.display.imgCentre((String)args[0], (float)args[1], (float)args[2]);
break;
default:
timewayEngine.console.warn("Unknown opcode "+opcode);
break;
}
}
// Typically a bug in the boilerplate or here.
catch (IndexOutOfBoundsException e) {
}
return null;
}