|
@@ -143,12 +143,13 @@ int OpenRaider::command(const char *command, std::vector<char *> *args) {
|
143
|
143
|
} else if (strcmp(command, "help") == 0) {
|
144
|
144
|
if (args->size() == 0) {
|
145
|
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(" game - send a command to the game engine");
|
150
|
|
- getConsole().print(" help - print command help");
|
151
|
|
- getConsole().print(" quit - exit OpenRaider");
|
|
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");
|
152
|
153
|
getConsole().print("Use help COMMAND to get additional info");
|
153
|
154
|
} else if (args->size() == 1) {
|
154
|
155
|
return help(args->at(0));
|
|
@@ -161,6 +162,25 @@ int OpenRaider::command(const char *command, std::vector<char *> *args) {
|
161
|
162
|
int error = getGame().loadLevel(tmp);
|
162
|
163
|
delete [] tmp;
|
163
|
164
|
return error;
|
|
165
|
+ } else if (strcmp(command, "sshot") == 0) {
|
|
166
|
+ char *filename = bufferString("%s/sshots/%s", mBaseDir, VERSION);
|
|
167
|
+ bool console = (args->size() > 0) && (strcmp(args->at(0), "console") == 0);
|
|
168
|
+ bool menu = (args->size() > 0) && (strcmp(args->at(0), "menu") == 0);
|
|
169
|
+ if (!console) {
|
|
170
|
+ getConsole().setVisible(false);
|
|
171
|
+ if (menu)
|
|
172
|
+ getMenu().setVisible(true);
|
|
173
|
+ frame();
|
|
174
|
+ frame(); // Double buffered
|
|
175
|
+ }
|
|
176
|
+ getGame().mRender->screenShot(filename);
|
|
177
|
+ if (!console) {
|
|
178
|
+ getConsole().setVisible(true);
|
|
179
|
+ if (menu)
|
|
180
|
+ getMenu().setVisible(false);
|
|
181
|
+ }
|
|
182
|
+ getConsole().print("Screenshot stored...");
|
|
183
|
+ delete filename;
|
164
|
184
|
} else if (strcmp(command, "game") == 0) {
|
165
|
185
|
return getGame().command(args);
|
166
|
186
|
} else {
|
|
@@ -216,6 +236,10 @@ int OpenRaider::help(const char *cmd) {
|
216
|
236
|
getConsole().print(" load levelfile.name");
|
217
|
237
|
} else if (strcmp(cmd, "game") == 0) {
|
218
|
238
|
getConsole().print("Use \"game help\" for more info");
|
|
239
|
+ } else if (strcmp(cmd, "sshot") == 0) {
|
|
240
|
+ getConsole().print("sshot-Command Usage:");
|
|
241
|
+ getConsole().print(" sshot [console|menu]");
|
|
242
|
+ getConsole().print("Add console/menu to capture them too");
|
219
|
243
|
} else {
|
220
|
244
|
getConsole().print("No help available for %s", cmd);
|
221
|
245
|
return -1;
|
|
@@ -593,51 +617,56 @@ void OpenRaider::fillMapList() {
|
593
|
617
|
void OpenRaider::run() {
|
594
|
618
|
assert(mRunning == false);
|
595
|
619
|
|
596
|
|
- static clock_t fpsSum = 0, fpsCount = 0;
|
597
|
|
- static int fps = 0;
|
598
|
|
-
|
599
|
620
|
mRunning = true;
|
600
|
621
|
while (mRunning) {
|
601
|
|
- clock_t startTime = systemTimerGet();
|
|
622
|
+ frame();
|
|
623
|
+ }
|
|
624
|
+}
|
602
|
625
|
|
603
|
|
- // Get keyboard and mouse input
|
604
|
|
- getWindow().eventHandling();
|
|
626
|
+void OpenRaider::frame() {
|
|
627
|
+ assert(mRunning == true);
|
|
628
|
+
|
|
629
|
+ static clock_t fpsSum = 0, fpsCount = 0;
|
|
630
|
+ static int fps = 0;
|
|
631
|
+ clock_t startTime = systemTimerGet();
|
605
|
632
|
|
606
|
|
- // Clear screen
|
607
|
|
- glClearColor(0.00f, 0.00f, 0.00f, 1.0f);
|
608
|
|
- glClear(GL_COLOR_BUFFER_BIT);
|
|
633
|
+ // Get keyboard and mouse input
|
|
634
|
+ getWindow().eventHandling();
|
609
|
635
|
|
610
|
|
- // Draw game scene
|
611
|
|
- getGame().display();
|
|
636
|
+ // Clear screen
|
|
637
|
+ glClearColor(0.00f, 0.00f, 0.00f, 1.0f);
|
|
638
|
+ glClear(GL_COLOR_BUFFER_BIT);
|
612
|
639
|
|
613
|
|
- // Draw 2D overlays (console and menu)
|
614
|
|
- getWindow().glEnter2D();
|
|
640
|
+ // Draw game scene
|
|
641
|
+ getGame().display();
|
615
|
642
|
|
616
|
|
- getConsole().display();
|
617
|
|
- getMenu().display();
|
|
643
|
+ // Draw 2D overlays (console and menu)
|
|
644
|
+ getWindow().glEnter2D();
|
618
|
645
|
|
619
|
|
- // Draw FPS counter
|
620
|
|
- if (mFPS)
|
621
|
|
- getWindow().drawText(10, getWindow().mHeight - 20, 0.5f, OR_BLUE, "%dFPS", fps);
|
|
646
|
+ getConsole().display();
|
|
647
|
+ getMenu().display();
|
622
|
648
|
|
623
|
|
- getWindow().glExit2D();
|
|
649
|
+ // Draw FPS counter
|
|
650
|
+ if (mFPS)
|
|
651
|
+ getWindow().drawText(10, getWindow().mHeight - 20, 0.5f, OR_BLUE, "%dFPS", fps);
|
624
|
652
|
|
625
|
|
- // Put new frame on screen
|
626
|
|
- getWindow().swapBuffersGL();
|
|
653
|
+ getWindow().glExit2D();
|
627
|
654
|
|
628
|
|
- // Fill map list after first render pass,
|
629
|
|
- // so menu *loading screen* is visible
|
630
|
|
- if (!mMapListFilled)
|
631
|
|
- fillMapList();
|
|
655
|
+ // Put new frame on screen
|
|
656
|
+ getWindow().swapBuffersGL();
|
632
|
657
|
|
633
|
|
- // Calculate FPS display value
|
634
|
|
- fpsCount++;
|
635
|
|
- fpsSum += (systemTimerGet() - startTime);
|
636
|
|
- if (fpsSum >= 500) {
|
637
|
|
- // Update every 500ms
|
638
|
|
- fps = (int)((float)fpsCount * (1000.0f / (float)fpsSum));
|
639
|
|
- fpsCount = fpsSum = 0;
|
640
|
|
- }
|
|
658
|
+ // Fill map list after first render pass,
|
|
659
|
+ // so menu *loading screen* is visible
|
|
660
|
+ if (!mMapListFilled)
|
|
661
|
+ fillMapList();
|
|
662
|
+
|
|
663
|
+ // Calculate FPS display value
|
|
664
|
+ fpsCount++;
|
|
665
|
+ fpsSum += (systemTimerGet() - startTime);
|
|
666
|
+ if (fpsSum >= 500) {
|
|
667
|
+ // Update every 500ms
|
|
668
|
+ fps = (int)((float)fpsCount * (1000.0f / (float)fpsSum));
|
|
669
|
+ fpsCount = fpsSum = 0;
|
641
|
670
|
}
|
642
|
671
|
}
|
643
|
672
|
|