Browse Source

preparing menu

Thomas Buck 10 years ago
parent
commit
066ff8356c
3 changed files with 17 additions and 20 deletions
  1. 1
    3
      include/Menu.h
  2. 3
    6
      src/Menu.cpp
  3. 13
    11
      src/OpenRaider.cpp

+ 1
- 3
include/Menu.h View File

@@ -32,9 +32,7 @@ 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);
35
+    void handleKeyboard(KeyboardButton key, bool pressed);
38 36
 
39 37
 private:
40 38
 

+ 3
- 6
src/Menu.cpp View File

@@ -33,7 +33,7 @@ Menu::Menu() {
33 33
 }
34 34
 
35 35
 Menu::~Menu() {
36
-
36
+    delete [] mainText.text;
37 37
 }
38 38
 
39 39
 void Menu::setVisible(bool visible) {
@@ -58,6 +58,7 @@ void Menu::drawText(unsigned int x, unsigned int y, float scale, const char *s,
58 58
     w.color[2] = 0xFF;
59 59
     w.color[3] = 0xFF;
60 60
     gOpenRaider->mWindow->writeString(&w);
61
+    delete [] w.text;
61 62
 }
62 63
 
63 64
 void Menu::display() {
@@ -79,11 +80,7 @@ void Menu::display() {
79 80
     }
80 81
 }
81 82
 
82
-void Menu::actionMouse(unsigned int x, unsigned int y, int button) {
83
-
84
-}
85
-
86
-void Menu::actionKeyboard(int key) {
83
+void Menu::handleKeyboard(KeyboardButton key, bool pressed) {
87 84
 
88 85
 }
89 86
 

+ 13
- 11
src/OpenRaider.cpp View File

@@ -483,26 +483,28 @@ void OpenRaider::run() {
483 483
 void OpenRaider::handleKeyboard(KeyboardButton key, bool pressed) {
484 484
     if ((keyBindings[menu] == key) && pressed) {
485 485
         mMenu->setVisible(!mMenu->isVisible());
486
-    }
487
-
488
-    if (keyBindings[console] == key) {
486
+    } else if (!mMenu->isVisible()) {
487
+        if (keyBindings[console] == key) {
489 488
 
490
-    } else if (keyBindings[forward] == key) {
489
+        } else if (keyBindings[forward] == key) {
491 490
 
492
-    } else if (keyBindings[backward] == key) {
491
+        } else if (keyBindings[backward] == key) {
493 492
 
494
-    } else if (keyBindings[left] == key) {
493
+        } else if (keyBindings[left] == key) {
495 494
 
496
-    } else if (keyBindings[right] == key) {
495
+        } else if (keyBindings[right] == key) {
497 496
 
498
-    } else if (keyBindings[jump] == key) {
497
+        } else if (keyBindings[jump] == key) {
499 498
 
500
-    } else if (keyBindings[crouch] == key) {
499
+        } else if (keyBindings[crouch] == key) {
501 500
 
502
-    } else if (keyBindings[use] == key) {
501
+        } else if (keyBindings[use] == key) {
503 502
 
504
-    } else if (keyBindings[holster] == key) {
503
+        } else if (keyBindings[holster] == key) {
505 504
 
505
+        }
506
+    } else {
507
+        mMenu->handleKeyboard(key, pressed);
506 508
     }
507 509
 }
508 510
 

Loading…
Cancel
Save