Browse Source

Added Selector, try fix for Travis

Thomas Buck 9 years ago
parent
commit
1d65995581
7 changed files with 114 additions and 16 deletions
  1. 1
    0
      ChangeLog.md
  2. 1
    1
      cmake/travis_before_install_linux.sh
  3. 10
    8
      cmake/travis_install_linux.sh
  4. 25
    0
      include/Selector.h
  5. 1
    0
      src/CMakeLists.txt
  6. 47
    0
      src/Selector.cpp
  7. 29
    7
      src/UI.cpp

+ 1
- 0
ChangeLog.md View File

@@ -4,6 +4,7 @@
4 4
 
5 5
     [ 20150801 ]
6 6
     * Updated to current Imgui version (now using indexed rendering)
7
+    * Added mouse selection window (not yet doing anything useful)
7 8
 
8 9
     [ 20150429 ]
9 10
     * Fixed the new BoundingBox rendering approach

+ 1
- 1
cmake/travis_before_install_linux.sh View File

@@ -3,6 +3,6 @@
3 3
 sudo add-apt-repository -y ppa:zoogie/sdl2-snapshots
4 4
 sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
5 5
 sudo add-apt-repository -y ppa:andykimpe/cmake
6
-sudo add-apt-repository -y ppa:h-rayflood/llvm
6
+sudo add-apt-repository -y ppa:h-rayflood/llvm-upper
7 7
 sudo apt-get -qq -y update
8 8
 

+ 10
- 8
cmake/travis_install_linux.sh View File

@@ -11,12 +11,14 @@ wget 'http://downloads.sourceforge.net/project/ogl-math/glm-0.9.6.3/glm-0.9.6.3.
11 11
 unzip glm-0.9.6.3.zip
12 12
 sudo cp -R glm/glm /usr/local/include/glm
13 13
 
14
-if [ "$CXX" = "clang++" ]; then export CXXFLAGS="-stdlib=libc++"; fi
15
-if [ "$CXX" = "clang++" ]; then svn co --quiet http://llvm.org/svn/llvm-project/libcxx/trunk libcxx; fi
16
-if [ "$CXX" = "clang++" ]; then cd libcxx/lib && bash buildit; fi
17
-if [ "$CXX" = "clang++" ]; then sudo cp ./libc++.so.1.0 /usr/lib/; fi
18
-if [ "$CXX" = "clang++" ]; then sudo mkdir /usr/include/c++/v1; fi
19
-if [ "$CXX" = "clang++" ]; then cd .. && sudo cp -r include/* /usr/include/c++/v1/; fi
20
-if [ "$CXX" = "clang++" ]; then cd /usr/lib && sudo ln -sf libc++.so.1.0 libc++.so; fi
21
-if [ "$CXX" = "clang++" ]; then sudo ln -sf libc++.so.1.0 libc++.so.1 && cd $cwd; fi
14
+if [ "$CXX" = "clang++" ]; then
15
+    export CXXFLAGS="-stdlib=libc++"
16
+    svn co --quiet http://llvm.org/svn/llvm-project/libcxx/trunk libcxx
17
+    cd libcxx/lib && bash buildit
18
+    sudo cp ./libc++.so.1.0 /usr/lib/
19
+    sudo mkdir /usr/include/c++/v1
20
+    cd .. && sudo cp -r include/* /usr/include/c++/v1/
21
+    cd /usr/lib && sudo ln -sf libc++.so.1.0 libc++.so
22
+    sudo ln -sf libc++.so.1.0 libc++.so.1 && cd $cwd
23
+fi
22 24
 

+ 25
- 0
include/Selector.h View File

@@ -0,0 +1,25 @@
1
+/*!
2
+ * \file include/Selector.h
3
+ * \brief Selector Window
4
+ *
5
+ * \author xythobuz
6
+ */
7
+
8
+#ifndef _SELECTOR_H_
9
+#define _SELECTOR_H_
10
+
11
+class Selector {
12
+  public:
13
+    static void display();
14
+
15
+    static bool isVisible() { return visible; }
16
+    static void setVisible(bool v) { visible = v; }
17
+
18
+    static void handleMouseClick(unsigned int x, unsigned int y, KeyboardButton button, bool released);
19
+
20
+  private:
21
+    static bool visible;
22
+};
23
+
24
+#endif
25
+

+ 1
- 0
src/CMakeLists.txt View File

@@ -61,6 +61,7 @@ set (SRCS ${SRCS} "RoomData.cpp" "../include/RoomData.h")
61 61
 set (SRCS ${SRCS} "RoomMesh.cpp" "../include/RoomMesh.h")
62 62
 set (SRCS ${SRCS} "RunTime.cpp" "../include/RunTime.h")
63 63
 set (SRCS ${SRCS} "Script.cpp" "../include/Script.h")
64
+set (SRCS ${SRCS} "Selector.cpp" "../include/Selector.h")
64 65
 set (SRCS ${SRCS} "SkeletalModel.cpp" "../include/SkeletalModel.h")
65 66
 set (SRCS ${SRCS} "SoundManager.cpp" "../include/SoundManager.h")
66 67
 set (SRCS ${SRCS} "Sprite.cpp" "../include/Sprite.h")

+ 47
- 0
src/Selector.cpp View File

@@ -0,0 +1,47 @@
1
+/*!
2
+ * \file src/Selector.cpp
3
+ * \brief Selector Window
4
+ *
5
+ * \author xythobuz
6
+ */
7
+
8
+#include "imgui/imgui.h"
9
+
10
+#include "global.h"
11
+#include "Log.h"
12
+#include "Selector.h"
13
+
14
+bool Selector::visible = false;
15
+
16
+static unsigned int lastX = -1, lastY = -1;
17
+
18
+void Selector::handleMouseClick(unsigned int x, unsigned int y, KeyboardButton button, bool released) {
19
+    if ((button == leftmouseKey) && (!released)) {
20
+        lastX = x;
21
+        lastY = y;
22
+    }
23
+}
24
+
25
+void Selector::display() {
26
+    if (!visible)
27
+        return;
28
+
29
+    if (!ImGui::Begin("Object Selector", &visible, ImVec2(300, 300))) {
30
+        ImGui::End();
31
+        return;
32
+    }
33
+
34
+    ImGui::Text("Last Click (Screen): (%d %d)", lastX, lastY);
35
+    if ((lastX < 0) || (lastY < 0)) {
36
+        ImGui::Text("Last Click (World): (? ?)");
37
+    } else {
38
+
39
+    }
40
+
41
+    if (ImGui::Button("Hide Selector")) {
42
+        visible = false;
43
+    }
44
+
45
+    ImGui::End();
46
+}
47
+

+ 29
- 7
src/UI.cpp View File

@@ -15,6 +15,7 @@
15 15
 #include "Menu.h"
16 16
 #include "Render.h"
17 17
 #include "RunTime.h"
18
+#include "Selector.h"
18 19
 #include "SoundManager.h"
19 20
 #include "TextureManager.h"
20 21
 #include "World.h"
@@ -173,7 +174,7 @@ void UI::eventsFinished() {
173 174
 
174 175
     ImGui::NewFrame();
175 176
 
176
-    if (!(visible || Console::isVisible() || Menu::isVisible())) {
177
+    if (!(visible || Console::isVisible() || Menu::isVisible() || Selector::isVisible())) {
177 178
         while (!motionEvents.empty()) {
178 179
             auto i = motionEvents.front();
179 180
             Game::handleMouseMotion(std::get<0>(i), std::get<1>(i),
@@ -185,7 +186,7 @@ void UI::eventsFinished() {
185 186
     while (!keyboardEvents.empty()) {
186 187
         auto i = keyboardEvents.front();
187 188
 
188
-        if (!(visible || Console::isVisible() || Menu::isVisible())) {
189
+        if (!(visible || Console::isVisible() || Menu::isVisible() || Selector::isVisible())) {
189 190
             for (int n = forwardAction; n < ActionEventCount; n++) {
190 191
                 auto ae = static_cast<ActionEvents>(n);
191 192
                 if (RunTime::getKeyBinding(ae) == std::get<0>(i))
@@ -194,7 +195,7 @@ void UI::eventsFinished() {
194 195
         }
195 196
 
196 197
         if (std::get<1>(i)) {
197
-            if ((!io.WantCaptureKeyboard) || (!(visible || Console::isVisible() || Menu::isVisible()))) {
198
+            if ((!io.WantCaptureKeyboard) || (!(visible || Console::isVisible() || Menu::isVisible() || Selector::isVisible()))) {
198 199
                 if (!metaKeyIsActive) {
199 200
                     if (RunTime::getKeyBinding(debugAction) == std::get<0>(i)) {
200 201
                         visible = !visible;
@@ -215,6 +216,16 @@ void UI::eventsFinished() {
215 216
     }
216 217
 
217 218
     bool clicked = !clickEvents.empty();
219
+    while (!clickEvents.empty()) {
220
+        auto i = clickEvents.front();
221
+
222
+        if (Selector::isVisible() && (!io.WantCaptureMouse)) {
223
+            Selector::handleMouseClick(std::get<0>(i), std::get<1>(i), std::get<2>(i), std::get<3>(i));
224
+        }
225
+
226
+        clickEvents.pop_front();
227
+    }
228
+
218 229
     clickEvents.clear();
219 230
     motionEvents.clear();
220 231
     scrollEvents.clear();
@@ -225,10 +236,10 @@ void UI::eventsFinished() {
225 236
         Console::setVisible(false);
226 237
     }
227 238
 
228
-    if (Window::getTextInput() != (visible || Console::isVisible() || Menu::isVisible()))
229
-        Window::setTextInput(visible || Console::isVisible() || Menu::isVisible());
239
+    if (Window::getTextInput() != (visible || Console::isVisible() || Menu::isVisible() || Selector::isVisible()))
240
+        Window::setTextInput(visible || Console::isVisible() || Menu::isVisible() || Selector::isVisible());
230 241
 
231
-    bool input = !(visible || Console::isVisible() || Menu::isVisible());
242
+    bool input = !(visible || Console::isVisible() || Menu::isVisible() || Selector::isVisible());
232 243
     if (Window::getMousegrab() != input)
233 244
         Window::setMousegrab(input);
234 245
 
@@ -263,6 +274,7 @@ void UI::display() {
263 274
 
264 275
     Console::display();
265 276
     Menu::display();
277
+    Selector::display();
266 278
 
267 279
     if (!visible) {
268 280
         ImGui::Render();
@@ -272,6 +284,16 @@ void UI::display() {
272 284
     static bool showTestWindow = false;
273 285
     static bool showStyleWindow = false;
274 286
     if (ImGui::Begin("Engine", &visible, ImVec2(500, 600))) {
287
+        if (Selector::isVisible()) {
288
+            if (ImGui::Button("Disable Mouse Object Picking")) {
289
+                Selector::setVisible(false);
290
+            }
291
+        } else {
292
+            if (ImGui::Button("Enable Mouse Object Picking")) {
293
+                Selector::setVisible(true);
294
+            }
295
+        }
296
+
275 297
         Render::displayUI();
276 298
         RunTime::display();
277 299
         TextureManager::display();
@@ -456,7 +478,7 @@ void UI::handleControllerAxis(float value, KeyboardButton axis) {
456 478
 }
457 479
 
458 480
 void UI::handleControllerButton(KeyboardButton button, bool released) {
459
-    if (visible || Console::isVisible())
481
+    if (visible || Console::isVisible() || Menu::isVisible() || Selector::isVisible())
460 482
         return;
461 483
 
462 484
     if (Menu::isVisible()) {

Loading…
Cancel
Save