소스 검색

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
 set mouse_x    1.0
22
 set mouse_x    1.0
23
 set mouse_y    1.0
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
 
32
 
33
     void display();
33
     void display();
34
 
34
 
35
+    void actionMouse(unsigned int x, unsigned int y, int button);
36
+
37
+    void actionKeyboard(int key);
38
+
35
 private:
39
 private:
40
+
41
+    void drawText(unsigned int x, unsigned int y, float scale, const char *s, ...) __attribute__((format(printf, 5, 0)));
42
+
36
     bool mVisible;
43
     bool mVisible;
37
     WindowString mainText;
44
     WindowString mainText;
38
 };
45
 };

+ 28
- 0
src/Menu.cpp 파일 보기

5
  * \author xythobuz
5
  * \author xythobuz
6
  */
6
  */
7
 
7
 
8
+#include <cstdarg>
9
+
8
 #ifdef __APPLE__
10
 #ifdef __APPLE__
9
 #include <OpenGL/gl.h>
11
 #include <OpenGL/gl.h>
10
 #include <OpenGL/glu.h>
12
 #include <OpenGL/glu.h>
42
     return mVisible;
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
 void Menu::display() {
63
 void Menu::display() {
46
     Window *window = gOpenRaider->mWindow;
64
     Window *window = gOpenRaider->mWindow;
47
 
65
 
56
         mainText.x = (window->mWidth / 2) - (mainText.w / 2);
74
         mainText.x = (window->mWidth / 2) - (mainText.w / 2);
57
         mainText.y = 10;
75
         mainText.y = 10;
58
         window->writeString(&mainText);
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…
취소
저장