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

+ 1
- 1
cmake/travis_before_install_linux.sh View File

3
 sudo add-apt-repository -y ppa:zoogie/sdl2-snapshots
3
 sudo add-apt-repository -y ppa:zoogie/sdl2-snapshots
4
 sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
4
 sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
5
 sudo add-apt-repository -y ppa:andykimpe/cmake
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
 sudo apt-get -qq -y update
7
 sudo apt-get -qq -y update
8
 
8
 

+ 10
- 8
cmake/travis_install_linux.sh View File

11
 unzip glm-0.9.6.3.zip
11
 unzip glm-0.9.6.3.zip
12
 sudo cp -R glm/glm /usr/local/include/glm
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

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
 set (SRCS ${SRCS} "RoomMesh.cpp" "../include/RoomMesh.h")
61
 set (SRCS ${SRCS} "RoomMesh.cpp" "../include/RoomMesh.h")
62
 set (SRCS ${SRCS} "RunTime.cpp" "../include/RunTime.h")
62
 set (SRCS ${SRCS} "RunTime.cpp" "../include/RunTime.h")
63
 set (SRCS ${SRCS} "Script.cpp" "../include/Script.h")
63
 set (SRCS ${SRCS} "Script.cpp" "../include/Script.h")
64
+set (SRCS ${SRCS} "Selector.cpp" "../include/Selector.h")
64
 set (SRCS ${SRCS} "SkeletalModel.cpp" "../include/SkeletalModel.h")
65
 set (SRCS ${SRCS} "SkeletalModel.cpp" "../include/SkeletalModel.h")
65
 set (SRCS ${SRCS} "SoundManager.cpp" "../include/SoundManager.h")
66
 set (SRCS ${SRCS} "SoundManager.cpp" "../include/SoundManager.h")
66
 set (SRCS ${SRCS} "Sprite.cpp" "../include/Sprite.h")
67
 set (SRCS ${SRCS} "Sprite.cpp" "../include/Sprite.h")

+ 47
- 0
src/Selector.cpp View File

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
 #include "Menu.h"
15
 #include "Menu.h"
16
 #include "Render.h"
16
 #include "Render.h"
17
 #include "RunTime.h"
17
 #include "RunTime.h"
18
+#include "Selector.h"
18
 #include "SoundManager.h"
19
 #include "SoundManager.h"
19
 #include "TextureManager.h"
20
 #include "TextureManager.h"
20
 #include "World.h"
21
 #include "World.h"
173
 
174
 
174
     ImGui::NewFrame();
175
     ImGui::NewFrame();
175
 
176
 
176
-    if (!(visible || Console::isVisible() || Menu::isVisible())) {
177
+    if (!(visible || Console::isVisible() || Menu::isVisible() || Selector::isVisible())) {
177
         while (!motionEvents.empty()) {
178
         while (!motionEvents.empty()) {
178
             auto i = motionEvents.front();
179
             auto i = motionEvents.front();
179
             Game::handleMouseMotion(std::get<0>(i), std::get<1>(i),
180
             Game::handleMouseMotion(std::get<0>(i), std::get<1>(i),
185
     while (!keyboardEvents.empty()) {
186
     while (!keyboardEvents.empty()) {
186
         auto i = keyboardEvents.front();
187
         auto i = keyboardEvents.front();
187
 
188
 
188
-        if (!(visible || Console::isVisible() || Menu::isVisible())) {
189
+        if (!(visible || Console::isVisible() || Menu::isVisible() || Selector::isVisible())) {
189
             for (int n = forwardAction; n < ActionEventCount; n++) {
190
             for (int n = forwardAction; n < ActionEventCount; n++) {
190
                 auto ae = static_cast<ActionEvents>(n);
191
                 auto ae = static_cast<ActionEvents>(n);
191
                 if (RunTime::getKeyBinding(ae) == std::get<0>(i))
192
                 if (RunTime::getKeyBinding(ae) == std::get<0>(i))
194
         }
195
         }
195
 
196
 
196
         if (std::get<1>(i)) {
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
                 if (!metaKeyIsActive) {
199
                 if (!metaKeyIsActive) {
199
                     if (RunTime::getKeyBinding(debugAction) == std::get<0>(i)) {
200
                     if (RunTime::getKeyBinding(debugAction) == std::get<0>(i)) {
200
                         visible = !visible;
201
                         visible = !visible;
215
     }
216
     }
216
 
217
 
217
     bool clicked = !clickEvents.empty();
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
     clickEvents.clear();
229
     clickEvents.clear();
219
     motionEvents.clear();
230
     motionEvents.clear();
220
     scrollEvents.clear();
231
     scrollEvents.clear();
225
         Console::setVisible(false);
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
     if (Window::getMousegrab() != input)
243
     if (Window::getMousegrab() != input)
233
         Window::setMousegrab(input);
244
         Window::setMousegrab(input);
234
 
245
 
263
 
274
 
264
     Console::display();
275
     Console::display();
265
     Menu::display();
276
     Menu::display();
277
+    Selector::display();
266
 
278
 
267
     if (!visible) {
279
     if (!visible) {
268
         ImGui::Render();
280
         ImGui::Render();
272
     static bool showTestWindow = false;
284
     static bool showTestWindow = false;
273
     static bool showStyleWindow = false;
285
     static bool showStyleWindow = false;
274
     if (ImGui::Begin("Engine", &visible, ImVec2(500, 600))) {
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
         Render::displayUI();
297
         Render::displayUI();
276
         RunTime::display();
298
         RunTime::display();
277
         TextureManager::display();
299
         TextureManager::display();
456
 }
478
 }
457
 
479
 
458
 void UI::handleControllerButton(KeyboardButton button, bool released) {
480
 void UI::handleControllerButton(KeyboardButton button, bool released) {
459
-    if (visible || Console::isVisible())
481
+    if (visible || Console::isVisible() || Menu::isVisible() || Selector::isVisible())
460
         return;
482
         return;
461
 
483
 
462
     if (Menu::isVisible()) {
484
     if (Menu::isVisible()) {

Loading…
Cancel
Save