瀏覽代碼

Mouse and keyboard handler for Menu

Thomas Buck 10 年之前
父節點
當前提交
4821f10582
共有 3 個文件被更改,包括 44 次插入8 次删除
  1. 9
    8
      data/OpenRaider.ini
  2. 7
    0
      include/Menu.h
  3. 28
    0
      src/Menu.cpp

+ 9
- 8
data/OpenRaider.ini 查看文件

@@ -22,11 +22,12 @@ set volume     0.5
22 22
 set mouse_x    1.0
23 23
 set mouse_y    1.0
24 24
 
25
-bind console   96
26
-bind forward   119
27
-bind backward  115
28
-bind jump      32
29
-bind crouch    99
30
-bind left      97
31
-bind right     100
32
-# bind attack    122
25
+bind menu     "esc"
26
+bind console  '`'
27
+bind forward  'w'
28
+bind backward 's'
29
+bind jump     ' '
30
+bind crouch   "ctrl"
31
+bind left     'a'
32
+bind right    'd'
33
+bind attack   "mouse_l"

+ 7
- 0
include/Menu.h 查看文件

@@ -32,7 +32,14 @@ public:
32 32
 
33 33
     void display();
34 34
 
35
+    void actionMouse(unsigned int x, unsigned int y, int button);
36
+
37
+    void actionKeyboard(int key);
38
+
35 39
 private:
40
+
41
+    void drawText(unsigned int x, unsigned int y, float scale, const char *s, ...) __attribute__((format(printf, 5, 0)));
42
+
36 43
     bool mVisible;
37 44
     WindowString mainText;
38 45
 };

+ 28
- 0
src/Menu.cpp 查看文件

@@ -5,6 +5,8 @@
5 5
  * \author xythobuz
6 6
  */
7 7
 
8
+#include <cstdarg>
9
+
8 10
 #ifdef __APPLE__
9 11
 #include <OpenGL/gl.h>
10 12
 #include <OpenGL/glu.h>
@@ -42,6 +44,22 @@ bool Menu::isVisible() {
42 44
     return mVisible;
43 45
 }
44 46
 
47
+void Menu::drawText(unsigned int x, unsigned int y, float scale, const char *s, ...) {
48
+    va_list args;
49
+    va_start(args, s);
50
+    WindowString w;
51
+    w.text = bufferString(s, args);
52
+    va_end(args);
53
+    w.scale = scale;
54
+    w.x = x;
55
+    w.y = y;
56
+    w.color[0] = 0xFF;
57
+    w.color[1] = 0xFF;
58
+    w.color[2] = 0xFF;
59
+    w.color[3] = 0xFF;
60
+    gOpenRaider->mWindow->writeString(&w);
61
+}
62
+
45 63
 void Menu::display() {
46 64
     Window *window = gOpenRaider->mWindow;
47 65
 
@@ -56,6 +74,16 @@ void Menu::display() {
56 74
         mainText.x = (window->mWidth / 2) - (mainText.w / 2);
57 75
         mainText.y = 10;
58 76
         window->writeString(&mainText);
77
+
78
+        drawText(20, (window->mHeight / 2) - 20, 0.75f, "Generating map list...");
59 79
     }
60 80
 }
61 81
 
82
+void Menu::actionMouse(unsigned int x, unsigned int y, int button) {
83
+
84
+}
85
+
86
+void Menu::actionKeyboard(int key) {
87
+
88
+}
89
+

Loading…
取消
儲存