diff --git a/.gitignore b/.gitignore index 378eac25d..dee53c537 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ build +*~ diff --git a/CMakeLists.txt b/CMakeLists.txt index 12a9ef83b..e577d96f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -136,6 +136,19 @@ set(OGRE_HEADER ${COMP_DIR}/engine/ogre/renderer.hpp) source_group(components\\engine\\ogre FILES ${OGRE} ${OGRE_HEADER}) +# components/mw_gui +set(MWGUI_HEADER + ${COMP_DIR}/mw_gui/mw_layouts.hpp) +source_group(components\\mw_gui FILES ${MWGUI_HEADER}) + +# components/engine/gui +set(EGUI + ${COMP_DIR}/engine/gui/manager.cpp) +set(EGUI_HEADER + ${COMP_DIR}/engine/gui/manager.hpp + ${COMP_DIR}/engine/gui/layout.hpp) +source_group(components\\engine\\gui FILES ${EGUI} ${EGUI_HEADER}) + set(INPUT ${COMP_DIR}/engine/input/oismanager.cpp) set(INPUT_HEADER @@ -171,13 +184,14 @@ file(GLOB INTERPRETER ${COMP_DIR}/interpreter/*.cpp) file(GLOB INTERPRETER_HEADER ${COMP_DIR}/interpreter/*.hpp) source_group(components\\interpreter FILES ${INTERPRETER} ${INTERPRETER_HEADER}) -set(COMPONENTS ${BSA} ${NIF} ${NIFOGRE} ${ESM_STORE} ${OGRE} ${INPUT} ${MISC} +set(COMPONENTS ${BSA} ${NIF} ${NIFOGRE} ${ESM_STORE} ${OGRE} ${INPUT} ${MISC} + ${EGUI} ${COMMANDSERVER} ${COMPILER} ${INTERPRETER}) set(COMPONENTS_HEADER ${BSA_HEADER} ${NIF_HEADER} ${NIFOGRE_HEADER} ${ESM_STORE_HEADER} ${ESM_HEADER} ${OGRE_HEADER} ${INPUT_HEADER} ${MISC_HEADER} ${COMPILER_HEADER} - ${INTERPRETER_HEADER}) + ${INTERPRETER_HEADER} ${EGUI_HEADER} ${MWGUI_HEADER}) # source directory: libs diff --git a/apps/mygui_dev/.gitignore b/apps/mygui_dev/.gitignore new file mode 100644 index 000000000..e36a9e026 --- /dev/null +++ b/apps/mygui_dev/.gitignore @@ -0,0 +1,2 @@ +old +run.sh diff --git a/apps/mygui_dev/CMakeLists.txt b/apps/mygui_dev/CMakeLists.txt index 2d1a2beb9..dd3ecb228 100644 --- a/apps/mygui_dev/CMakeLists.txt +++ b/apps/mygui_dev/CMakeLists.txt @@ -2,6 +2,7 @@ add_executable(mygui_test main.cpp ${BSA} ${BSA_HEADER} ${OGRE} ${OGRE_HEADER} + ${EGUI} ${EGUI_HEADER} ) target_link_libraries(mygui_test ${OGRE_LIBRARIES} diff --git a/apps/mygui_dev/main.cpp b/apps/mygui_dev/main.cpp index 1b11951ba..1a8c4c6a1 100644 --- a/apps/mygui_dev/main.cpp +++ b/apps/mygui_dev/main.cpp @@ -1,14 +1,12 @@ #include -#include -#include using namespace std; -#include "manager.hpp" -#include "layout.hpp" -#include "mw_layouts.hpp" +#include +#include #include #include +#include #include @@ -26,7 +24,7 @@ struct Listener : public Ogre::FrameListener total += evt.timeSinceLastFrame; // Countdown to exit - const int MAX = 5; + const int MAX = 4; if(total >= step) { step++; diff --git a/apps/mygui_dev/manager.hpp b/apps/mygui_dev/manager.hpp deleted file mode 100644 index 2771c666a..000000000 --- a/apps/mygui_dev/manager.hpp +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef ENGINE_MYGUI_MANAGER_H -#define ENGINE_MYGUI_MANAGER_H - -#include -#include -#include - -namespace GUI -{ - class MyGUIManager - { - MyGUI::OgrePlatform *mPlatform; - MyGUI::Gui *mGui; - - public: - MyGUIManager() : mPlatform(NULL), mGui(NULL) {} - MyGUIManager(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool logging=false) - { setup(wnd,mgr,logging); } - ~MyGUIManager() { shutdown(); } - - void setup(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool logging=false) - { - assert(wnd); - assert(mgr); - - using namespace MyGUI; - - // Enable/disable MyGUI logging to stdout. (Logging to MyGUI.log - // is still enabled.) In order to do this we have to initialize - // the log manager before the main gui system itself, otherwise - // the main object will get the chance to spit out a few messages - // before we can able to disable it. - LogManager::initialise(); - LogManager::setSTDOutputEnabled(logging); - - // Set up OGRE platform. We might make this more generic later. - mPlatform = new OgrePlatform(); - mPlatform->initialise(wnd, mgr); - - // Create GUI - mGui = new Gui(); - mGui->initialise(); - } - - void shutdown() - { - if(mGui) delete mGui; - if(mPlatform) - { - mPlatform->shutdown(); - delete mPlatform; - } - mGui = NULL; - mPlatform = NULL; - } - }; -} -#endif diff --git a/apps/mygui_dev/layout.hpp b/components/engine/gui/layout.hpp similarity index 93% rename from apps/mygui_dev/layout.hpp rename to components/engine/gui/layout.hpp index 4d0a7e663..ddd6887eb 100644 --- a/apps/mygui_dev/layout.hpp +++ b/components/engine/gui/layout.hpp @@ -70,11 +70,6 @@ namespace GUI void shutdown() { - for (VectorBasePtr::iterator iter=mListBase.begin(); iter!=mListBase.end(); ++iter) { - delete (*iter); - } - mListBase.clear(); - MyGUI::LayoutManager::getInstance().unloadLayout(mListWindowRoot); mListWindowRoot.clear(); } @@ -118,8 +113,6 @@ namespace GUI std::string mPrefix; std::string mLayoutName; MyGUI::VectorWidgetPtr mListWindowRoot; - typedef std::vector VectorBasePtr; - VectorBasePtr mListBase; }; } #endif diff --git a/components/engine/gui/manager.cpp b/components/engine/gui/manager.cpp new file mode 100644 index 000000000..e5e01e7d7 --- /dev/null +++ b/components/engine/gui/manager.cpp @@ -0,0 +1,43 @@ +#include +#include +#include + +#include "manager.hpp" + +using namespace GUI; + +void MyGUIManager::setup(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool logging) +{ + assert(wnd); + assert(mgr); + + using namespace MyGUI; + + // Enable/disable MyGUI logging to stdout. (Logging to MyGUI.log is + // still enabled.) In order to do this we have to initialize the log + // manager before the main gui system itself, otherwise the main + // object will get the chance to spit out a few messages before we + // can able to disable it. + LogManager::initialise(); + LogManager::setSTDOutputEnabled(logging); + + // Set up OGRE platform. We might make this more generic later. + mPlatform = new OgrePlatform(); + mPlatform->initialise(wnd, mgr); + + // Create GUI + mGui = new Gui(); + mGui->initialise(); +} + +void MyGUIManager::shutdown() +{ + if(mGui) delete mGui; + if(mPlatform) + { + mPlatform->shutdown(); + delete mPlatform; + } + mGui = NULL; + mPlatform = NULL; +} diff --git a/components/engine/gui/manager.hpp b/components/engine/gui/manager.hpp new file mode 100644 index 000000000..72843eccc --- /dev/null +++ b/components/engine/gui/manager.hpp @@ -0,0 +1,33 @@ +#ifndef ENGINE_MYGUI_MANAGER_H +#define ENGINE_MYGUI_MANAGER_H + +namespace MyGUI +{ + class OgrePlatform; + class Gui; +} + +namespace Ogre +{ + class RenderWindow; + class SceneManager; +} + +namespace GUI +{ + class MyGUIManager + { + MyGUI::OgrePlatform *mPlatform; + MyGUI::Gui *mGui; + + public: + MyGUIManager() : mPlatform(NULL), mGui(NULL) {} + MyGUIManager(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool logging=false) + { setup(wnd,mgr,logging); } + ~MyGUIManager() { shutdown(); } + + void setup(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool logging=false); + void shutdown(); + }; +} +#endif diff --git a/apps/mygui_dev/mw_layouts.hpp b/components/mw_gui/mw_layouts.hpp similarity index 91% rename from apps/mygui_dev/mw_layouts.hpp rename to components/mw_gui/mw_layouts.hpp index 03e9fa007..1b72833f0 100644 --- a/apps/mygui_dev/mw_layouts.hpp +++ b/components/mw_gui/mw_layouts.hpp @@ -1,7 +1,20 @@ #ifndef MWGUI_LAYOUTS_H #define MWGUI_LAYOUTS_H -#include "layout.hpp" +#include + +/* + This file contains classes corresponding to all the window layouts + defined in resources/mygui/ *.xml. + + Each class inherites GUI::Layout and loads the XML file, and + provides some helper functions to manipulate the elements of the + window. + + The windows are never created or destroyed (except at startup and + shutdown), they are only hid. You can control visibility with + setVisible(). + */ namespace MWGUI {