|
@@ -127,36 +127,19 @@ int OpenRaider::command(const char *command, std::vector<char *> *args) {
|
127
|
127
|
if (strcmp(command, "set") == 0) {
|
128
|
128
|
if (args->size() != 2) {
|
129
|
129
|
getConsole().print("Invalid use of set-command");
|
130
|
|
- return -2;
|
|
130
|
+ return -1;
|
131
|
131
|
} else {
|
132
|
132
|
return set(args->at(0), args->at(1));
|
133
|
133
|
}
|
134
|
134
|
} else if (strcmp(command, "bind") == 0) {
|
135
|
135
|
if (args->size() != 2) {
|
136
|
136
|
getConsole().print("Invalid use of bind-command");
|
137
|
|
- return -3;
|
|
137
|
+ return -2;
|
138
|
138
|
} else {
|
139
|
139
|
return bind(args->at(0), args->at(1));
|
140
|
140
|
}
|
141
|
141
|
} else if (strcmp(command, "quit") == 0) {
|
142
|
142
|
exit(0);
|
143
|
|
- } else if (strcmp(command, "help") == 0) {
|
144
|
|
- if (args->size() == 0) {
|
145
|
|
- getConsole().print("Available commands:");
|
146
|
|
- getConsole().print(" load - load a level");
|
147
|
|
- getConsole().print(" set - set a parameter");
|
148
|
|
- getConsole().print(" bind - bind a keyboard/mouse action");
|
149
|
|
- getConsole().print(" sshot - make a screenshot");
|
150
|
|
- getConsole().print(" game - send a command to the game engine");
|
151
|
|
- getConsole().print(" help - print command help");
|
152
|
|
- getConsole().print(" quit - exit OpenRaider");
|
153
|
|
- getConsole().print("Use help COMMAND to get additional info");
|
154
|
|
- } else if (args->size() == 1) {
|
155
|
|
- return help(args->at(0));
|
156
|
|
- } else {
|
157
|
|
- getConsole().print("Invalid use of help-command");
|
158
|
|
- return -4;
|
159
|
|
- }
|
160
|
143
|
} else if (strcmp(command, "load") == 0) {
|
161
|
144
|
char *tmp = bufferString("%s/%s", mPakDir, args->at(0));
|
162
|
145
|
int error = getGame().loadLevel(tmp);
|
|
@@ -181,11 +164,207 @@ int OpenRaider::command(const char *command, std::vector<char *> *args) {
|
181
|
164
|
}
|
182
|
165
|
getConsole().print("Screenshot stored...");
|
183
|
166
|
delete filename;
|
184
|
|
- } else if (strcmp(command, "game") == 0) {
|
185
|
|
- return getGame().command(args);
|
|
167
|
+ } else if (strcmp(command, "mode") == 0) {
|
|
168
|
+ if (args->size() > 0) {
|
|
169
|
+ char *mode = args->at(0);
|
|
170
|
+ if (strcmp(mode, "wireframe") == 0) {
|
|
171
|
+ if (getGame().mLoaded) {
|
|
172
|
+ getRender().setMode(Render::modeWireframe);
|
|
173
|
+ getConsole().print("Wireframe mode");
|
|
174
|
+ } else {
|
|
175
|
+ getConsole().print("Load a level to set this mode!");
|
|
176
|
+ return -3;
|
|
177
|
+ }
|
|
178
|
+ } else if (strcmp(mode, "solid") == 0) {
|
|
179
|
+ if (getGame().mLoaded) {
|
|
180
|
+ getRender().setMode(Render::modeSolid);
|
|
181
|
+ getConsole().print("Solid mode");
|
|
182
|
+ } else {
|
|
183
|
+ getConsole().print("Load a level to set this mode!");
|
|
184
|
+ return -4;
|
|
185
|
+ }
|
|
186
|
+ } else if (strcmp(mode, "texture") == 0) {
|
|
187
|
+ if (getGame().mLoaded) {
|
|
188
|
+ getRender().setMode(Render::modeTexture);
|
|
189
|
+ getConsole().print("Texture mode");
|
|
190
|
+ } else {
|
|
191
|
+ getConsole().print("Load a level to set this mode!");
|
|
192
|
+ return -5;
|
|
193
|
+ }
|
|
194
|
+ } else if (strcmp(mode, "vertexlight") == 0) {
|
|
195
|
+ if (getGame().mLoaded) {
|
|
196
|
+ getRender().setMode(Render::modeVertexLight);
|
|
197
|
+ getConsole().print("Vertexlight mode");
|
|
198
|
+ } else {
|
|
199
|
+ getConsole().print("Load a level to set this mode!");
|
|
200
|
+ return -6;
|
|
201
|
+ }
|
|
202
|
+ } else if (strcmp(mode, "titlescreen") == 0) {
|
|
203
|
+ getRender().setMode(Render::modeLoadScreen);
|
|
204
|
+ getConsole().print("Titlescreen mode");
|
|
205
|
+ } else {
|
|
206
|
+ getConsole().print("Invalid use of mode command (%s)!", mode);
|
|
207
|
+ return -7;
|
|
208
|
+ }
|
|
209
|
+ } else {
|
|
210
|
+ getConsole().print("Invalid use of mode command!");
|
|
211
|
+ return -8;
|
|
212
|
+ }
|
|
213
|
+ } else if (strcmp(command, "move") == 0) {
|
|
214
|
+ if (args->size() > 0) {
|
|
215
|
+ if (getGame().mLoaded) {
|
|
216
|
+ char *move = args->at(0);
|
|
217
|
+ if (strcmp(move, "walk") == 0) {
|
|
218
|
+ getGame().mLara->moveType = worldMoveType_walk;
|
|
219
|
+ getConsole().print("Lara is walking...");
|
|
220
|
+ } else if (strcmp(move, "fly") == 0) {
|
|
221
|
+ getGame().mLara->moveType = worldMoveType_fly;
|
|
222
|
+ getConsole().print("Lara is flying...");
|
|
223
|
+ } else if (strcmp(move, "noclip") == 0) {
|
|
224
|
+ getGame().mLara->moveType = worldMoveType_noClipping;
|
|
225
|
+ getConsole().print("Lara is noclipping...");
|
|
226
|
+ } else {
|
|
227
|
+ getConsole().print("Invalid use of move command (%s)!", move);
|
|
228
|
+ return -9;
|
|
229
|
+ }
|
|
230
|
+ } else {
|
|
231
|
+ getConsole().print("Load a level to change the movement type!");
|
|
232
|
+ return -10;
|
|
233
|
+ }
|
|
234
|
+ } else {
|
|
235
|
+ getConsole().print("Invalid use of move command!");
|
|
236
|
+ return -11;
|
|
237
|
+ }
|
|
238
|
+ } else if (strcmp(command, "sound") == 0) {
|
|
239
|
+ if (args->size() > 0) {
|
|
240
|
+ getSound().play(atoi(args->at(0)));
|
|
241
|
+ } else {
|
|
242
|
+ getConsole().print("Invalid use of sound command!");
|
|
243
|
+ return -12;
|
|
244
|
+ }
|
|
245
|
+ } else if (strcmp(command, "animate") == 0) {
|
|
246
|
+ if (args->size() > 0) {
|
|
247
|
+ char c = args->at(0)[0];
|
|
248
|
+ if (c == 'n') {
|
|
249
|
+ // Step all skeletal models to their next animation
|
|
250
|
+ if (getRender().getFlags() & Render::fAnimateAllModels) {
|
|
251
|
+ for (unsigned int i = 0; i < getRender().mModels.size(); i++) {
|
|
252
|
+ SkeletalModel *m = getRender().mModels[i];
|
|
253
|
+ if (m->getAnimation() < ((int)m->model->animation.size() - 1))
|
|
254
|
+ m->setAnimation(m->getAnimation() + 1);
|
|
255
|
+ else
|
|
256
|
+ if (m->getAnimation() != 0)
|
|
257
|
+ m->setAnimation(0);
|
|
258
|
+ }
|
|
259
|
+ } else {
|
|
260
|
+ getConsole().print("Animations need to be enabled!");
|
|
261
|
+ }
|
|
262
|
+ } else if (c == 'p') {
|
|
263
|
+ // Step all skeletal models to their previous animation
|
|
264
|
+ if (getRender().getFlags() & Render::fAnimateAllModels) {
|
|
265
|
+ for (unsigned int i = 0; i < getRender().mModels.size(); i++) {
|
|
266
|
+ SkeletalModel *m = getRender().mModels[i];
|
|
267
|
+ if (m->getAnimation() > 0)
|
|
268
|
+ m->setAnimation(m->getAnimation() - 1);
|
|
269
|
+ else
|
|
270
|
+ if (m->model->animation.size() > 0)
|
|
271
|
+ m->setAnimation(m->model->animation.size() - 1);
|
|
272
|
+ }
|
|
273
|
+ } else {
|
|
274
|
+ getConsole().print("Animations need to be enabled!");
|
|
275
|
+ }
|
|
276
|
+ } else {
|
|
277
|
+ // Enable or disable animating all skeletal models
|
|
278
|
+ bool b;
|
|
279
|
+ if (readBool(args->at(0), &b) < 0) {
|
|
280
|
+ getConsole().print("Pass BOOL to animate command!");
|
|
281
|
+ return -13;
|
|
282
|
+ }
|
|
283
|
+ if (b)
|
|
284
|
+ getRender().setFlags(Render::fAnimateAllModels);
|
|
285
|
+ else
|
|
286
|
+ getRender().clearFlags(Render::fAnimateAllModels);
|
|
287
|
+ getConsole().print(b ? "Animating all models" : "No longer animating all models");
|
|
288
|
+ }
|
|
289
|
+ } else {
|
|
290
|
+ getConsole().print("Invalid use of animate command!");
|
|
291
|
+ return -14;
|
|
292
|
+ }
|
|
293
|
+
|
|
294
|
+ } else if (strcmp(command, "light") == 0) {
|
|
295
|
+ if (args->size() > 0) {
|
|
296
|
+ bool b;
|
|
297
|
+ if (readBool(args->at(0), &b) < 0) {
|
|
298
|
+ getConsole().print("Pass BOOL to light command!");
|
|
299
|
+ return -15;
|
|
300
|
+ }
|
|
301
|
+ if (b)
|
|
302
|
+ getRender().setFlags(Render::fGL_Lights);
|
|
303
|
+ else
|
|
304
|
+ getRender().clearFlags(Render::fGL_Lights);
|
|
305
|
+ getConsole().print("GL-Lights are now %s", b ? "on" : "off");
|
|
306
|
+ } else {
|
|
307
|
+ getConsole().print("Invalid use of light-command!");
|
|
308
|
+ return -16;
|
|
309
|
+ }
|
|
310
|
+ } else if (strcmp(command, "fog") == 0) {
|
|
311
|
+ if (args->size() > 0) {
|
|
312
|
+ bool b;
|
|
313
|
+ if (readBool(args->at(0), &b) < 0) {
|
|
314
|
+ getConsole().print("Pass BOOL to fog command!");
|
|
315
|
+ return -17;
|
|
316
|
+ }
|
|
317
|
+ if (b)
|
|
318
|
+ getRender().setFlags(Render::fFog);
|
|
319
|
+ else
|
|
320
|
+ getRender().clearFlags(Render::fFog);
|
|
321
|
+ getConsole().print("Fog is now %s", b ? "on" : "off");
|
|
322
|
+ } else {
|
|
323
|
+ getConsole().print("Invalid use of fog-command!");
|
|
324
|
+ return -18;
|
|
325
|
+ }
|
|
326
|
+ } else if (strcmp(command, "hop") == 0) {
|
|
327
|
+ if (args->size() > 0) {
|
|
328
|
+ bool b;
|
|
329
|
+ if (readBool(args->at(0), &b) < 0) {
|
|
330
|
+ getConsole().print("Pass BOOL to hop command!");
|
|
331
|
+ return -19;
|
|
332
|
+ }
|
|
333
|
+ if (b)
|
|
334
|
+ getWorld().setFlag(World::fEnableHopping);
|
|
335
|
+ else
|
|
336
|
+ getWorld().clearFlag(World::fEnableHopping);
|
|
337
|
+ getConsole().print("Room hopping is now %s", b ? "on" : "off");
|
|
338
|
+ } else {
|
|
339
|
+ getConsole().print("Invalid use of hop-command!");
|
|
340
|
+ return -20;
|
|
341
|
+ }
|
|
342
|
+ } else if (strcmp(command, "help") == 0) {
|
|
343
|
+ if (args->size() == 0) {
|
|
344
|
+ getConsole().print("Available commands:");
|
|
345
|
+ getConsole().print(" load - load a level");
|
|
346
|
+ getConsole().print(" set - set a parameter");
|
|
347
|
+ getConsole().print(" bind - bind a keyboard/mouse action");
|
|
348
|
+ getConsole().print(" sshot - make a screenshot");
|
|
349
|
+ getConsole().print(" move - [walk|fly|noclip]");
|
|
350
|
+ getConsole().print(" sound - INT - Test play sound");
|
|
351
|
+ getConsole().print(" mode - MODE - Render mode");
|
|
352
|
+ getConsole().print(" animate - [BOOL|n|p] - Animate models");
|
|
353
|
+ getConsole().print(" light - BOOL - GL Lights");
|
|
354
|
+ getConsole().print(" fog - BOOL - GL Fog");
|
|
355
|
+ getConsole().print(" hop - BOOL - Room hop");
|
|
356
|
+ getConsole().print(" help - print command help");
|
|
357
|
+ getConsole().print(" quit - exit OpenRaider");
|
|
358
|
+ getConsole().print("Use help COMMAND to get additional info");
|
|
359
|
+ } else if (args->size() == 1) {
|
|
360
|
+ return help(args->at(0));
|
|
361
|
+ } else {
|
|
362
|
+ getConsole().print("Invalid use of help-command");
|
|
363
|
+ return -21;
|
|
364
|
+ }
|
186
|
365
|
} else {
|
187
|
366
|
getConsole().print("Unknown command: %s ", command);
|
188
|
|
- return -1;
|
|
367
|
+ return -22;
|
189
|
368
|
}
|
190
|
369
|
|
191
|
370
|
return 0;
|
|
@@ -199,19 +378,19 @@ int OpenRaider::help(const char *cmd) {
|
199
|
378
|
getConsole().print("set-Command Usage:");
|
200
|
379
|
getConsole().print(" set VAR VAL");
|
201
|
380
|
getConsole().print("Available Variables:");
|
202
|
|
- getConsole().print(" basedir STRING");
|
203
|
|
- getConsole().print(" pakdir STRING");
|
204
|
|
- getConsole().print(" audiodir STRING");
|
205
|
|
- getConsole().print(" datadir STRING");
|
206
|
|
- getConsole().print(" font STRING");
|
207
|
|
- getConsole().print(" gldriver STRING");
|
208
|
|
- getConsole().print(" size \"INTxINT\"");
|
209
|
|
- getConsole().print(" fullscreen BOOL");
|
210
|
|
- getConsole().print(" audio BOOL");
|
211
|
|
- getConsole().print(" volume BOOL");
|
212
|
|
- getConsole().print(" mouse_x FLOAT");
|
213
|
|
- getConsole().print(" mouse_y FLOAT");
|
214
|
|
- getConsole().print(" fps BOOL");
|
|
381
|
+ getConsole().print(" basedir STRING");
|
|
382
|
+ getConsole().print(" pakdir STRING");
|
|
383
|
+ getConsole().print(" audiodir STRING");
|
|
384
|
+ getConsole().print(" datadir STRING");
|
|
385
|
+ getConsole().print(" font STRING");
|
|
386
|
+ getConsole().print(" gldriver STRING");
|
|
387
|
+ getConsole().print(" size \"INTxINT\"");
|
|
388
|
+ getConsole().print(" fullscreen BOOL");
|
|
389
|
+ getConsole().print(" audio BOOL");
|
|
390
|
+ getConsole().print(" volume BOOL");
|
|
391
|
+ getConsole().print(" mouse_x FLOAT");
|
|
392
|
+ getConsole().print(" mouse_y FLOAT");
|
|
393
|
+ getConsole().print(" fps BOOL");
|
215
|
394
|
getConsole().print("Enclose STRINGs with \"\"!");
|
216
|
395
|
getConsole().print("size expects a STRING in the specified format");
|
217
|
396
|
} else if (strcmp(cmd, "bind") == 0) {
|
|
@@ -240,6 +419,33 @@ int OpenRaider::help(const char *cmd) {
|
240
|
419
|
getConsole().print("sshot-Command Usage:");
|
241
|
420
|
getConsole().print(" sshot [console|menu]");
|
242
|
421
|
getConsole().print("Add console/menu to capture them too");
|
|
422
|
+ } else if (strcmp(cmd, "sound") == 0) {
|
|
423
|
+ getConsole().print("sound-Command Usage:");
|
|
424
|
+ getConsole().print(" sound INT");
|
|
425
|
+ getConsole().print("Where INT is a valid sound ID integer");
|
|
426
|
+ } else if (strcmp(cmd, "move") == 0) {
|
|
427
|
+ getConsole().print("move-Command Usage:");
|
|
428
|
+ getConsole().print(" move COMMAND");
|
|
429
|
+ getConsole().print("Where COMMAND is one of the following:");
|
|
430
|
+ getConsole().print(" walk");
|
|
431
|
+ getConsole().print(" fly");
|
|
432
|
+ getConsole().print(" noclip");
|
|
433
|
+ } else if (strcmp(cmd, "mode") == 0) {
|
|
434
|
+ getConsole().print("mode-Command Usage:");
|
|
435
|
+ getConsole().print(" mode MODE");
|
|
436
|
+ getConsole().print("Where MODE is one of the following:");
|
|
437
|
+ getConsole().print(" wireframe");
|
|
438
|
+ getConsole().print(" solid");
|
|
439
|
+ getConsole().print(" texture");
|
|
440
|
+ getConsole().print(" vertexlight");
|
|
441
|
+ getConsole().print(" titlescreen");
|
|
442
|
+ } else if (strcmp(cmd, "animate") == 0) {
|
|
443
|
+ getConsole().print("animate-Command Usage:");
|
|
444
|
+ getConsole().print(" animate [n|p|BOOL]");
|
|
445
|
+ getConsole().print("Where the commands have the following meaning:");
|
|
446
|
+ getConsole().print(" BOOL to (de)activate animating all models");
|
|
447
|
+ getConsole().print(" n to step all models to their next animation");
|
|
448
|
+ getConsole().print(" p to step all models to their previous animation");
|
243
|
449
|
} else {
|
244
|
450
|
getConsole().print("No help available for %s", cmd);
|
245
|
451
|
return -1;
|
|
@@ -638,7 +844,7 @@ void OpenRaider::frame() {
|
638
|
844
|
glClear(GL_COLOR_BUFFER_BIT);
|
639
|
845
|
|
640
|
846
|
// Draw game scene
|
641
|
|
- getGame().display();
|
|
847
|
+ getRender().display();
|
642
|
848
|
|
643
|
849
|
// Draw 2D overlays (console and menu)
|
644
|
850
|
getWindow().glEnter2D();
|