mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 15:29:55 +00:00
Moved GUI stuff into components
This commit is contained in:
parent
29522f57d3
commit
9c839e220e
10 changed files with 114 additions and 74 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
build
|
||||
*~
|
||||
|
|
|
@ -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
|
||||
|
@ -172,12 +185,13 @@ 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}
|
||||
${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
|
||||
|
||||
|
|
2
apps/mygui_dev/.gitignore
vendored
Normal file
2
apps/mygui_dev/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
old
|
||||
run.sh
|
|
@ -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}
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
#include "manager.hpp"
|
||||
#include "layout.hpp"
|
||||
#include "mw_layouts.hpp"
|
||||
#include <components/engine/gui/manager.hpp>
|
||||
#include <components/mw_gui/mw_layouts.hpp>
|
||||
|
||||
#include <components/engine/ogre/renderer.hpp>
|
||||
#include <OgreResourceGroupManager.h>
|
||||
#include <OgreRenderWindow.h>
|
||||
|
||||
#include <components/bsa/bsa_archive.hpp>
|
||||
|
||||
|
@ -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++;
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
#ifndef ENGINE_MYGUI_MANAGER_H
|
||||
#define ENGINE_MYGUI_MANAGER_H
|
||||
|
||||
#include <assert.h>
|
||||
#include <MyGUI.h>
|
||||
#include <MyGUI_OgrePlatform.h>
|
||||
|
||||
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
|
|
@ -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<Layout*> VectorBasePtr;
|
||||
VectorBasePtr mListBase;
|
||||
};
|
||||
}
|
||||
#endif
|
43
components/engine/gui/manager.cpp
Normal file
43
components/engine/gui/manager.cpp
Normal file
|
@ -0,0 +1,43 @@
|
|||
#include <MyGUI.h>
|
||||
#include <MyGUI_OgrePlatform.h>
|
||||
#include <assert.h>
|
||||
|
||||
#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;
|
||||
}
|
33
components/engine/gui/manager.hpp
Normal file
33
components/engine/gui/manager.hpp
Normal file
|
@ -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
|
|
@ -1,7 +1,20 @@
|
|||
#ifndef MWGUI_LAYOUTS_H
|
||||
#define MWGUI_LAYOUTS_H
|
||||
|
||||
#include "layout.hpp"
|
||||
#include <components/engine/gui/layout.hpp>
|
||||
|
||||
/*
|
||||
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
|
||||
{
|
Loading…
Reference in a new issue