mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-05-08 03:28:15 +03:00
Move OEngine::Gui::Layout to MWGui
This commit is contained in:
parent
9f74be8fcb
commit
223e3a53f5
13 changed files with 26 additions and 40 deletions
|
@ -33,7 +33,7 @@ add_openmw_dir (mwrender
|
|||
# )
|
||||
|
||||
add_openmw_dir (mwgui
|
||||
textinput widgets race class birth review windowmanagerimp console dialogue
|
||||
layout textinput widgets race class birth review windowmanagerimp console dialogue
|
||||
windowbase statswindow messagebox journalwindow charactercreation
|
||||
mapwindow windowpinnablebase tooltips scrollwindow bookwindow
|
||||
formatting inventorywindow container hud countdialog tradewindow settingswindow
|
||||
|
|
|
@ -26,14 +26,6 @@ namespace MyGUI
|
|||
class UString;
|
||||
}
|
||||
|
||||
namespace OEngine
|
||||
{
|
||||
namespace GUI
|
||||
{
|
||||
class Layout;
|
||||
}
|
||||
}
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
struct Class;
|
||||
|
@ -58,6 +50,8 @@ namespace MWWorld
|
|||
|
||||
namespace MWGui
|
||||
{
|
||||
class Layout;
|
||||
|
||||
class Console;
|
||||
class SpellWindow;
|
||||
class TradeWindow;
|
||||
|
@ -241,7 +235,7 @@ namespace MWBase
|
|||
virtual void addVisitedLocation(const std::string& name, int x, int y) = 0;
|
||||
|
||||
/// Hides dialog and schedules dialog to be deleted.
|
||||
virtual void removeDialog(OEngine::GUI::Layout* dialog) = 0;
|
||||
virtual void removeDialog(MWGui::Layout* dialog) = 0;
|
||||
|
||||
///Gracefully attempts to exit the topmost GUI mode
|
||||
/** No guarentee of actually closing the window **/
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace MWGui
|
|||
class SpellIcons;
|
||||
class ItemWidget;
|
||||
|
||||
class HUD : public OEngine::GUI::Layout, public LocalMapBase
|
||||
class HUD : public Layout, public LocalMapBase
|
||||
{
|
||||
public:
|
||||
HUD(CustomMarkerCollection& customMarkers, int fpsLevel, DragAndDrop* dragAndDrop);
|
||||
|
|
78
apps/openmw/mwgui/layout.cpp
Normal file
78
apps/openmw/mwgui/layout.cpp
Normal file
|
@ -0,0 +1,78 @@
|
|||
#include "layout.hpp"
|
||||
|
||||
#include <MyGUI_LayoutManager.h>
|
||||
#include <MyGUI_Widget.h>
|
||||
#include <MyGUI_Gui.h>
|
||||
#include <MyGUI_TextBox.h>
|
||||
#include <MyGUI_Window.h>
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
void Layout::initialise(const std::string& _layout, MyGUI::Widget* _parent)
|
||||
{
|
||||
const std::string MAIN_WINDOW = "_Main";
|
||||
mLayoutName = _layout;
|
||||
|
||||
if (mLayoutName.empty())
|
||||
mMainWidget = _parent;
|
||||
else
|
||||
{
|
||||
mPrefix = MyGUI::utility::toString(this, "_");
|
||||
mListWindowRoot = MyGUI::LayoutManager::getInstance().loadLayout(mLayoutName, mPrefix, _parent);
|
||||
|
||||
const std::string main_name = mPrefix + MAIN_WINDOW;
|
||||
for (MyGUI::VectorWidgetPtr::iterator iter=mListWindowRoot.begin(); iter!=mListWindowRoot.end(); ++iter)
|
||||
{
|
||||
if ((*iter)->getName() == main_name)
|
||||
{
|
||||
mMainWidget = (*iter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
MYGUI_ASSERT(mMainWidget, "root widget name '" << MAIN_WINDOW << "' in layout '" << mLayoutName << "' not found.");
|
||||
}
|
||||
}
|
||||
|
||||
void Layout::shutdown()
|
||||
{
|
||||
MyGUI::Gui::getInstance().destroyWidget(mMainWidget);
|
||||
mListWindowRoot.clear();
|
||||
}
|
||||
|
||||
void Layout::setCoord(int x, int y, int w, int h)
|
||||
{
|
||||
mMainWidget->setCoord(x,y,w,h);
|
||||
}
|
||||
|
||||
void Layout::setVisible(bool b)
|
||||
{
|
||||
mMainWidget->setVisible(b);
|
||||
}
|
||||
|
||||
void Layout::setText(const std::string &name, const std::string &caption)
|
||||
{
|
||||
MyGUI::Widget* pt;
|
||||
getWidget(pt, name);
|
||||
static_cast<MyGUI::TextBox*>(pt)->setCaption(caption);
|
||||
}
|
||||
|
||||
void Layout::setTitle(const std::string& title)
|
||||
{
|
||||
static_cast<MyGUI::Window*>(mMainWidget)->setCaptionWithReplacing(title);
|
||||
}
|
||||
|
||||
MyGUI::Widget* Layout::getWidget(const std::string &_name)
|
||||
{
|
||||
for (MyGUI::VectorWidgetPtr::iterator iter=mListWindowRoot.begin();
|
||||
iter!=mListWindowRoot.end(); ++iter)
|
||||
{
|
||||
MyGUI::Widget* find = (*iter)->findWidget(mPrefix + _name);
|
||||
if (nullptr != find)
|
||||
{
|
||||
return find;
|
||||
}
|
||||
}
|
||||
MYGUI_EXCEPT("widget name '" << _name << "' in layout '" << mLayoutName << "' not found.");
|
||||
}
|
||||
|
||||
}
|
63
apps/openmw/mwgui/layout.hpp
Normal file
63
apps/openmw/mwgui/layout.hpp
Normal file
|
@ -0,0 +1,63 @@
|
|||
#ifndef OPENMW_MWGUI_LAYOUT_H
|
||||
#define OPENMW_MWGUI_LAYOUT_H
|
||||
|
||||
#include <string>
|
||||
#include <MyGUI_WidgetDefines.h>
|
||||
#include <MyGUI_Widget.h>
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
/** The Layout class is an utility class used to load MyGUI layouts
|
||||
from xml files, and to manipulate member widgets.
|
||||
*/
|
||||
class Layout
|
||||
{
|
||||
public:
|
||||
Layout(const std::string & _layout, MyGUI::Widget* _parent = nullptr)
|
||||
: mMainWidget(nullptr)
|
||||
{ initialise(_layout, _parent); }
|
||||
virtual ~Layout() { shutdown(); }
|
||||
|
||||
MyGUI::Widget* getWidget(const std::string& _name);
|
||||
|
||||
template <typename T>
|
||||
void getWidget(T * & _widget, const std::string & _name)
|
||||
{
|
||||
MyGUI::Widget* w = getWidget(_name);
|
||||
T* cast = w->castType<T>(false);
|
||||
if (!cast)
|
||||
{
|
||||
MYGUI_EXCEPT("Error cast : dest type = '" << T::getClassTypeName()
|
||||
<< "' source name = '" << w->getName()
|
||||
<< "' source type = '" << w->getTypeName() << "' in layout '" << mLayoutName << "'");
|
||||
}
|
||||
else
|
||||
_widget = cast;
|
||||
}
|
||||
|
||||
private:
|
||||
void initialise(const std::string & _layout,
|
||||
MyGUI::Widget* _parent = nullptr);
|
||||
|
||||
void shutdown();
|
||||
|
||||
public:
|
||||
void setCoord(int x, int y, int w, int h);
|
||||
|
||||
virtual void setVisible(bool b);
|
||||
|
||||
void setText(const std::string& name, const std::string& caption);
|
||||
|
||||
// NOTE: this assume that mMainWidget is of type Window.
|
||||
void setTitle(const std::string& title);
|
||||
|
||||
MyGUI::Widget* mMainWidget;
|
||||
|
||||
protected:
|
||||
|
||||
std::string mPrefix;
|
||||
std::string mLayoutName;
|
||||
MyGUI::VectorWidgetPtr mListWindowRoot;
|
||||
};
|
||||
}
|
||||
#endif
|
|
@ -30,7 +30,7 @@ namespace MWGui
|
|||
{
|
||||
|
||||
MainMenu::MainMenu(int w, int h)
|
||||
: OEngine::GUI::Layout("openmw_mainmenu.layout")
|
||||
: Layout("openmw_mainmenu.layout")
|
||||
, mButtonBox(0), mWidth (w), mHeight (h)
|
||||
, mSaveGameDialog(NULL)
|
||||
, mBackground(NULL)
|
||||
|
@ -80,7 +80,7 @@ namespace MWGui
|
|||
MWBase::Environment::get().getWindowManager()->containsMode(MWGui::GM_MainMenu) &&
|
||||
MWBase::Environment::get().getStateManager()->getState() == MWBase::StateManager::State_NoGame);
|
||||
|
||||
OEngine::GUI::Layout::setVisible (visible);
|
||||
Layout::setVisible (visible);
|
||||
}
|
||||
|
||||
void MainMenu::onNewGameConfirmed()
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef OPENMW_GAME_MWGUI_MAINMENU_H
|
||||
#define OPENMW_GAME_MWGUI_MAINMENU_H
|
||||
|
||||
#include <openengine/gui/layout.hpp>
|
||||
#include "layout.hpp"
|
||||
|
||||
namespace Gui
|
||||
{
|
||||
|
@ -15,7 +15,7 @@ namespace MWGui
|
|||
class SaveGameDialog;
|
||||
class VideoWidget;
|
||||
|
||||
class MainMenu : public OEngine::GUI::Layout
|
||||
class MainMenu : public Layout
|
||||
{
|
||||
int mWidth;
|
||||
int mHeight;
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace MWGui
|
|||
int mLastButtonPressed;
|
||||
};
|
||||
|
||||
class MessageBox : public OEngine::GUI::Layout
|
||||
class MessageBox : public Layout
|
||||
{
|
||||
public:
|
||||
MessageBox (MessageBoxManager& parMessageBoxManager, const std::string& message);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#ifndef MWGUI_TOOLTIPS_H
|
||||
#define MWGUI_TOOLTIPS_H
|
||||
|
||||
#include <openengine/gui/layout.hpp>
|
||||
#include "layout.hpp"
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
#include "widgets.hpp"
|
||||
|
@ -45,7 +45,7 @@ namespace MWGui
|
|||
bool wordWrap;
|
||||
};
|
||||
|
||||
class ToolTips : public OEngine::GUI::Layout
|
||||
class ToolTips : public Layout
|
||||
{
|
||||
public:
|
||||
ToolTips();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef MWGUI_WINDOW_BASE_H
|
||||
#define MWGUI_WINDOW_BASE_H
|
||||
|
||||
#include <openengine/gui/layout.hpp>
|
||||
#include "layout.hpp"
|
||||
|
||||
namespace MWBase
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ namespace MWGui
|
|||
class WindowManager;
|
||||
class DragAndDrop;
|
||||
|
||||
class WindowBase: public OEngine::GUI::Layout
|
||||
class WindowBase: public Layout
|
||||
{
|
||||
public:
|
||||
WindowBase(const std::string& parLayout);
|
||||
|
|
|
@ -422,7 +422,7 @@ namespace MWGui
|
|||
// Delete any dialogs which are no longer in use
|
||||
if (!mGarbageDialogs.empty())
|
||||
{
|
||||
for (std::vector<OEngine::GUI::Layout*>::iterator it = mGarbageDialogs.begin(); it != mGarbageDialogs.end(); ++it)
|
||||
for (std::vector<Layout*>::iterator it = mGarbageDialogs.begin(); it != mGarbageDialogs.end(); ++it)
|
||||
{
|
||||
delete *it;
|
||||
}
|
||||
|
@ -722,7 +722,7 @@ namespace MWGui
|
|||
mStatsWindow->updateSkillArea();
|
||||
}
|
||||
|
||||
void WindowManager::removeDialog(OEngine::GUI::Layout*dialog)
|
||||
void WindowManager::removeDialog(Layout*dialog)
|
||||
{
|
||||
if (!dialog)
|
||||
return;
|
||||
|
@ -1566,7 +1566,7 @@ namespace MWGui
|
|||
return mCursorVisible;
|
||||
}
|
||||
|
||||
void WindowManager::trackWindow(OEngine::GUI::Layout *layout, const std::string &name)
|
||||
void WindowManager::trackWindow(Layout *layout, const std::string &name)
|
||||
{
|
||||
MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
||||
MyGUI::IntPoint pos(static_cast<int>(Settings::Manager::getFloat(name + " x", "Windows") * viewSize.width),
|
||||
|
|
|
@ -242,7 +242,7 @@ namespace MWGui
|
|||
virtual void addVisitedLocation(const std::string& name, int x, int y);
|
||||
|
||||
///Hides dialog and schedules dialog to be deleted.
|
||||
virtual void removeDialog(OEngine::GUI::Layout* dialog);
|
||||
virtual void removeDialog(Layout* dialog);
|
||||
|
||||
///Gracefully attempts to exit the topmost GUI mode
|
||||
virtual void exitCurrentGuiMode();
|
||||
|
@ -366,7 +366,7 @@ namespace MWGui
|
|||
bool mConsoleOnlyScripts;
|
||||
|
||||
std::map<MyGUI::Window*, std::string> mTrackedWindows;
|
||||
void trackWindow(OEngine::GUI::Layout* layout, const std::string& name);
|
||||
void trackWindow(Layout* layout, const std::string& name);
|
||||
void onWindowChangeCoord(MyGUI::Window* _sender);
|
||||
|
||||
std::string mSelectedSpell;
|
||||
|
@ -448,7 +448,7 @@ namespace MWGui
|
|||
|
||||
SFO::CursorManager* mCursorManager;
|
||||
|
||||
std::vector<OEngine::GUI::Layout*> mGarbageDialogs;
|
||||
std::vector<Layout*> mGarbageDialogs;
|
||||
void cleanupGarbage();
|
||||
|
||||
GuiWindow mShown; // Currently shown windows in inventory mode
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue