ソースを参照

Added sshot command

Thomas Buck 11年前
コミット
fce2d7b0d5
2個のファイルの変更70行の追加39行の削除
  1. 2
    0
      include/OpenRaider.h
  2. 68
    39
      src/OpenRaider.cpp

+ 2
- 0
include/OpenRaider.h ファイルの表示

43
 
43
 
44
     void run();
44
     void run();
45
 
45
 
46
+    void frame();
47
+
46
     void handleKeyboard(KeyboardButton key, bool pressed);
48
     void handleKeyboard(KeyboardButton key, bool pressed);
47
 
49
 
48
     void handleText(char *text, bool notFinished);
50
     void handleText(char *text, bool notFinished);

+ 68
- 39
src/OpenRaider.cpp ファイルの表示

143
     } else if (strcmp(command, "help") == 0) {
143
     } else if (strcmp(command, "help") == 0) {
144
         if (args->size() == 0) {
144
         if (args->size() == 0) {
145
             getConsole().print("Available commands:");
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
             getConsole().print("Use help COMMAND to get additional info");
153
             getConsole().print("Use help COMMAND to get additional info");
153
         } else if (args->size() == 1) {
154
         } else if (args->size() == 1) {
154
             return help(args->at(0));
155
             return help(args->at(0));
161
         int error = getGame().loadLevel(tmp);
162
         int error = getGame().loadLevel(tmp);
162
         delete [] tmp;
163
         delete [] tmp;
163
         return error;
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
     } else if (strcmp(command, "game") == 0) {
184
     } else if (strcmp(command, "game") == 0) {
165
         return getGame().command(args);
185
         return getGame().command(args);
166
     } else {
186
     } else {
216
         getConsole().print("  load levelfile.name");
236
         getConsole().print("  load levelfile.name");
217
     } else if (strcmp(cmd, "game") == 0) {
237
     } else if (strcmp(cmd, "game") == 0) {
218
         getConsole().print("Use \"game help\" for more info");
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
     } else {
243
     } else {
220
         getConsole().print("No help available for %s", cmd);
244
         getConsole().print("No help available for %s", cmd);
221
         return -1;
245
         return -1;
593
 void OpenRaider::run() {
617
 void OpenRaider::run() {
594
     assert(mRunning == false);
618
     assert(mRunning == false);
595
 
619
 
596
-    static clock_t fpsSum = 0, fpsCount = 0;
597
-    static int fps = 0;
598
-
599
     mRunning = true;
620
     mRunning = true;
600
     while (mRunning) {
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
 

読み込み中…
キャンセル
保存