From 8ebbd705a4f899ab0c094ddd6cd7f47e67061150 Mon Sep 17 00:00:00 2001 From: Thomas Buck Date: Fri, 13 Mar 2015 01:25:27 +0100 Subject: [PATCH] Main menu rewrite as imgui window --- ChangeLog.md | 5 + README.md | 4 +- include/Game.h | 3 +- include/Menu.h | 59 +- include/MenuFolder.h | 52 - include/Script.h | 6 +- include/utils/strings.h | 6 + src/CMakeLists.txt | 1 - src/Game.cpp | 6 +- src/Menu.cpp | 321 ++-- src/MenuFolder.cpp | 215 --- src/Render.cpp | 5 + src/Script.cpp | 22 +- src/TextureManager.cpp | 4 + src/UI.cpp | 70 +- src/deps/imgui/imconfig.h | 22 +- src/deps/imgui/imgui_user.h | 2 + src/deps/imgui/imgui_user.inl | 2 + src/deps/imguifilesystem/README.txt | 13 + src/deps/imguifilesystem/dirent_portable.h | 1040 +++++++++++ src/deps/imguifilesystem/imguifilesystem.cpp | 1655 ++++++++++++++++++ src/deps/imguifilesystem/imguifilesystem.h | 95 + src/loader/LoaderTR2.cpp | 22 +- src/main.cpp | 25 +- src/utils/strings.cpp | 30 + 25 files changed, 3143 insertions(+), 542 deletions(-) delete mode 100644 include/MenuFolder.h delete mode 100644 src/MenuFolder.cpp create mode 100755 src/deps/imgui/imgui_user.h create mode 100755 src/deps/imgui/imgui_user.inl create mode 100644 src/deps/imguifilesystem/README.txt create mode 100644 src/deps/imguifilesystem/dirent_portable.h create mode 100644 src/deps/imguifilesystem/imguifilesystem.cpp create mode 100644 src/deps/imguifilesystem/imguifilesystem.h diff --git a/ChangeLog.md b/ChangeLog.md index 64873b14..c0222003 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -2,6 +2,11 @@ ## OpenRaider (0.1.3) xythobuz + [ 20140312 ] + * Now including imguifilesystem dependency + * Completely re-wrote Main menu, now reading TOMBPC.DAT scripts + * Main menu is now just a full-screen ImGui window + [ 20140310 ] * Tried to fix moveable loading. Fixed TR1 angle parser, but still not working better. diff --git a/README.md b/README.md index a88ed0fe..3641c2e3 100644 --- a/README.md +++ b/README.md @@ -187,5 +187,7 @@ See the respective files in `cmake` for their licensing. The [clibs/commander](https://github.com/clibs/commander) dependency is Copyright (c) 2012 TJ Holowaychuk (tj@vision-media.ca) and licensed under the [MIT License](http://opensource.org/licenses/MIT). -The included GUI lib, [imgui](https://github.com/ocornut/imgui/) is Copyright (c) 2014 Omar Cornut. See src/deps/imgui/LICENSE for more informations about the MIT license used. +The included GUI lib, [imgui](https://github.com/ocornut/imgui/) is Copyright (c) 2014 Omar Cornut. See src/deps/imgui/LICENSE for more informations about the MIT license used. + +Also included is the imgui addon [imguifilesystem by Flix01](https://gist.github.com/Flix01/f34b5efa91e50a241c1b). diff --git a/include/Game.h b/include/Game.h index 7dcc0e18..77d63290 100644 --- a/include/Game.h +++ b/include/Game.h @@ -9,7 +9,6 @@ #define _GAME_H_ #include -#include #include "Entity.h" @@ -18,7 +17,7 @@ class Game { static void destroy(); static bool isLoaded() { return mLoaded; } - static int loadLevel(const char* level); + static int loadLevel(std::string level); static void handleAction(ActionEvents action, bool isFinished); static void handleMouseMotion(int xrel, int yrel, int xabs, int yabs); diff --git a/include/Menu.h b/include/Menu.h index 6e5351b7..0fbd7e5b 100644 --- a/include/Menu.h +++ b/include/Menu.h @@ -1,6 +1,6 @@ /*! * \file include/Menu.h - * \brief Menu 'overlay' interface + * \brief Main Menu * * \author xythobuz */ @@ -8,57 +8,30 @@ #ifndef _MENU_H_ #define _MENU_H_ -#include +#include + +#include "Script.h" +#include "utils/Folder.h" class Menu { public: + static int initialize(); + static void shutdown(); + static void display(); - virtual ~Menu() { } - - virtual int initialize() = 0; - - virtual void display() = 0; - - virtual void handleKeyboard(KeyboardButton key, bool pressed) = 0; - - virtual void handleMouseClick(unsigned int x, unsigned int y, - KeyboardButton button, bool released) = 0; - - virtual void handleMouseScroll(int xrel, int yrel) = 0; - - bool isVisible() { return visible; } - - void setVisible(bool v) { visible = v; } + static bool isVisible() { return visible; } + static void setVisible(bool v) { visible = v; } static const glm::vec4 textColor; static const glm::vec4 selectedColor; - protected: - - virtual void showDialog(std::string msg, std::string btn1, std::string btn2 = "", - std::function callback = std::function()); - - virtual void ackDialog(); - - virtual bool handleKeyboardDialog(KeyboardButton key, bool pressed); - - virtual bool handleMouseClickDialog(unsigned int x, unsigned int y, - KeyboardButton button, bool released); - - virtual bool handleMouseScrollDialog(int xrel, int yrel); - - virtual void displayDialog(); - - bool dialogState; - std::string dialogText; - std::string dialogButton1; - std::string dialogButton2; - std::function dialogFunction; - - bool visible; + private: + static bool visible; + static Folder* mapFolder; + static std::vector