mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 12:49:40 +00:00
dialog layout
This commit is contained in:
parent
747a4e1123
commit
0ba996f290
9 changed files with 257 additions and 18 deletions
|
@ -29,7 +29,7 @@ add_openmw_dir (mwgui
|
|||
map_window window_pinnable_base cursorreplace tooltips scrollwindow bookwindow list
|
||||
formatting inventorywindow container hud countdialog tradewindow settingswindow
|
||||
confirmationdialog alchemywindow referenceinterface spellwindow mainmenu quickkeysmenu
|
||||
itemselection spellbuyingwindow loadingscreen levelupdialog
|
||||
itemselection spellbuyingwindow loadingscreen levelupdialog waitdialog
|
||||
)
|
||||
|
||||
add_openmw_dir (mwdialogue
|
||||
|
|
12
apps/openmw/mwgui/waitdialog.cpp
Normal file
12
apps/openmw/mwgui/waitdialog.cpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
#include "waitdialog.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
||||
WaitDialog::WaitDialog(MWBase::WindowManager &parWindowManager)
|
||||
: WindowBase("openmw_wait_dialog.layout", parWindowManager)
|
||||
{
|
||||
center();
|
||||
}
|
||||
|
||||
}
|
19
apps/openmw/mwgui/waitdialog.hpp
Normal file
19
apps/openmw/mwgui/waitdialog.hpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
#ifndef MWGUI_WAIT_DIALOG_H
|
||||
#define MWGUI_WAIT_DIALOG_H
|
||||
|
||||
#include "window_base.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
||||
class WaitDialog : public WindowBase
|
||||
{
|
||||
public:
|
||||
WaitDialog(MWBase::WindowManager& parWindowManager);
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -869,29 +869,33 @@ void AutoSizedButton::setPropertyOverride(const std::string& _key, const std::st
|
|||
|
||||
Box::Box()
|
||||
: mSpacing(4)
|
||||
, mPadding(0)
|
||||
, mAutoResize(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Box::setPropertyOverride(const std::string& _key, const std::string& _value)
|
||||
{
|
||||
if (_key == "Spacing")
|
||||
{
|
||||
mSpacing = MyGUI::utility::parseValue<int>(_value);
|
||||
}
|
||||
}
|
||||
|
||||
void Box::notifyChildrenSizeChanged ()
|
||||
{
|
||||
align();
|
||||
}
|
||||
|
||||
void Box::_setPropertyImpl(const std::string& _key, const std::string& _value)
|
||||
{
|
||||
if (_key == "Spacing")
|
||||
mSpacing = MyGUI::utility::parseValue<int>(_value);
|
||||
else if (_key == "Padding")
|
||||
mPadding = MyGUI::utility::parseValue<int>(_value);
|
||||
else if (_key == "AutoResize")
|
||||
mAutoResize = MyGUI::utility::parseValue<bool>(_value);
|
||||
}
|
||||
|
||||
void HBox::align ()
|
||||
{
|
||||
unsigned int count = getChildCount ();
|
||||
size_t h_stretched_count = 0;
|
||||
int total_width = 0;
|
||||
int total_height = 0;
|
||||
std::vector< std::pair<MyGUI::IntSize, bool> > sizes;
|
||||
|
||||
for (unsigned int i = 0; i < count; ++i)
|
||||
|
@ -904,28 +908,43 @@ void HBox::align ()
|
|||
{
|
||||
sizes.push_back(std::make_pair(aw->getRequestedSize (), hstretch));
|
||||
total_width += aw->getRequestedSize ().width;
|
||||
total_height = std::max(total_height, aw->getRequestedSize ().height);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!hstretch) h_stretched_count ++;
|
||||
sizes.push_back (std::make_pair(MyGUI::IntSize(0,0), true));
|
||||
sizes.push_back (std::make_pair(w->getSize(), hstretch));
|
||||
total_width += w->getSize().width;
|
||||
}
|
||||
|
||||
if (i != count-1)
|
||||
total_width += mSpacing;
|
||||
}
|
||||
|
||||
if (mAutoResize && (total_width+mPadding*2 != getSize().width || total_height+mPadding*2 != getSize().height))
|
||||
{
|
||||
setSize(MyGUI::IntSize(total_width+mPadding*2, total_height+mPadding*2));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int curX = 0;
|
||||
for (unsigned int i = 0; i < count; ++i)
|
||||
{
|
||||
if (i == 0)
|
||||
curX += mPadding;
|
||||
|
||||
MyGUI::Widget* w = getChildAt(i);
|
||||
|
||||
bool vstretch = w->getUserString ("VStretch") == "true";
|
||||
int height = vstretch ? total_height : sizes[i].first.height;
|
||||
|
||||
MyGUI::IntCoord widgetCoord;
|
||||
widgetCoord.left = curX;
|
||||
widgetCoord.top = (getSize().height - sizes[i].first.height) / 2;
|
||||
int width = sizes[i].second ? sizes[i].first.width + (getSize().width - total_width)/h_stretched_count
|
||||
widgetCoord.top = mPadding + (getSize().height-mPadding*2 - height) / 2;
|
||||
int width = sizes[i].second ? sizes[i].first.width + (getSize().width-mPadding*2 - total_width)/h_stretched_count
|
||||
: sizes[i].first.width;
|
||||
widgetCoord.width = width;
|
||||
widgetCoord.height = sizes[i].first.height;
|
||||
widgetCoord.height = height;
|
||||
w->setCoord(widgetCoord);
|
||||
curX += width;
|
||||
|
||||
|
@ -934,12 +953,33 @@ void HBox::align ()
|
|||
}
|
||||
}
|
||||
|
||||
void HBox::setPropertyOverride(const std::string& _key, const std::string& _value)
|
||||
{
|
||||
Box::_setPropertyImpl (_key, _value);
|
||||
}
|
||||
|
||||
void HBox::setSize (const MyGUI::IntSize& _value)
|
||||
{
|
||||
MyGUI::Widget::setSize (_value);
|
||||
align();
|
||||
}
|
||||
|
||||
void HBox::setCoord (const MyGUI::IntCoord& _value)
|
||||
{
|
||||
MyGUI::Widget::setCoord (_value);
|
||||
align();
|
||||
}
|
||||
|
||||
void HBox::onWidgetCreated(MyGUI::Widget* _widget)
|
||||
{
|
||||
align();
|
||||
}
|
||||
|
||||
void HBox::onWidgetDestroy(MyGUI::Widget* _widget)
|
||||
{
|
||||
align();
|
||||
}
|
||||
|
||||
MyGUI::IntSize HBox::getRequestedSize ()
|
||||
{
|
||||
MyGUI::IntSize size(0,0);
|
||||
|
@ -954,6 +994,16 @@ MyGUI::IntSize HBox::getRequestedSize ()
|
|||
if (i != getChildCount()-1)
|
||||
size.width += mSpacing;
|
||||
}
|
||||
else
|
||||
{
|
||||
MyGUI::IntSize requested = getChildAt(i)->getSize ();
|
||||
size.height = std::max(size.height, requested.height);
|
||||
size.width = size.width + requested.width;
|
||||
if (i != getChildCount()-1)
|
||||
size.width += mSpacing;
|
||||
}
|
||||
size.height += mPadding*2;
|
||||
size.width += mPadding*2;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
@ -963,7 +1013,69 @@ MyGUI::IntSize HBox::getRequestedSize ()
|
|||
|
||||
void VBox::align ()
|
||||
{
|
||||
// not yet implemented
|
||||
unsigned int count = getChildCount ();
|
||||
size_t v_stretched_count = 0;
|
||||
int total_height = 0;
|
||||
int total_width = 0;
|
||||
std::vector< std::pair<MyGUI::IntSize, bool> > sizes;
|
||||
for (unsigned int i = 0; i < count; ++i)
|
||||
{
|
||||
MyGUI::Widget* w = getChildAt(i);
|
||||
bool vstretch = w->getUserString ("VStretch") == "true";
|
||||
v_stretched_count += vstretch;
|
||||
AutoSizedWidget* aw = dynamic_cast<AutoSizedWidget*>(w);
|
||||
if (aw)
|
||||
{
|
||||
sizes.push_back(std::make_pair(aw->getRequestedSize (), vstretch));
|
||||
total_height += aw->getRequestedSize ().height;
|
||||
total_width = std::max(total_width, aw->getRequestedSize ().width);
|
||||
}
|
||||
else
|
||||
{
|
||||
sizes.push_back (std::make_pair(w->getSize(), vstretch));
|
||||
total_height += w->getSize().height;
|
||||
}
|
||||
|
||||
if (i != count-1)
|
||||
total_height += mSpacing;
|
||||
}
|
||||
|
||||
if (mAutoResize && (total_width+mPadding*2 != getSize().width || total_height+mPadding*2 != getSize().height))
|
||||
{
|
||||
setSize(MyGUI::IntSize(total_width+mPadding*2, total_height+mPadding*2));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int curY = 0;
|
||||
for (unsigned int i = 0; i < count; ++i)
|
||||
{
|
||||
if (i==0)
|
||||
curY += mPadding;
|
||||
|
||||
MyGUI::Widget* w = getChildAt(i);
|
||||
|
||||
bool hstretch = w->getUserString ("HStretch") == "true";
|
||||
int width = hstretch ? total_width : sizes[i].first.width;
|
||||
|
||||
MyGUI::IntCoord widgetCoord;
|
||||
widgetCoord.top = curY;
|
||||
widgetCoord.left = mPadding + (getSize().width-mPadding*2 - width) / 2;
|
||||
int height = sizes[i].second ? sizes[i].first.height + (getSize().height-mPadding*2 - total_height)/v_stretched_count
|
||||
: sizes[i].first.height;
|
||||
widgetCoord.height = height;
|
||||
widgetCoord.width = width;
|
||||
w->setCoord(widgetCoord);
|
||||
curY += height;
|
||||
|
||||
if (i != count-1)
|
||||
curY += mSpacing;
|
||||
}
|
||||
}
|
||||
|
||||
void VBox::setPropertyOverride(const std::string& _key, const std::string& _value)
|
||||
{
|
||||
Box::_setPropertyImpl (_key, _value);
|
||||
}
|
||||
|
||||
void VBox::setSize (const MyGUI::IntSize& _value)
|
||||
|
@ -972,6 +1084,12 @@ void VBox::setSize (const MyGUI::IntSize& _value)
|
|||
align();
|
||||
}
|
||||
|
||||
void VBox::setCoord (const MyGUI::IntCoord& _value)
|
||||
{
|
||||
MyGUI::Widget::setCoord (_value);
|
||||
align();
|
||||
}
|
||||
|
||||
MyGUI::IntSize VBox::getRequestedSize ()
|
||||
{
|
||||
MyGUI::IntSize size(0,0);
|
||||
|
@ -986,6 +1104,26 @@ MyGUI::IntSize VBox::getRequestedSize ()
|
|||
if (i != getChildCount()-1)
|
||||
size.height += mSpacing;
|
||||
}
|
||||
else
|
||||
{
|
||||
MyGUI::IntSize requested = getChildAt(i)->getSize ();
|
||||
size.width = std::max(size.width, requested.width);
|
||||
size.height = size.height + requested.height;
|
||||
if (i != getChildCount()-1)
|
||||
size.height += mSpacing;
|
||||
}
|
||||
size.height += mPadding*2;
|
||||
size.width += mPadding*2;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
void VBox::onWidgetCreated(MyGUI::Widget* _widget)
|
||||
{
|
||||
align();
|
||||
}
|
||||
|
||||
void VBox::onWidgetDestroy(MyGUI::Widget* _widget)
|
||||
{
|
||||
align();
|
||||
}
|
||||
|
|
|
@ -357,10 +357,13 @@ namespace MWGui
|
|||
protected:
|
||||
virtual void align() = 0;
|
||||
|
||||
virtual void setPropertyOverride(const std::string& _key, const std::string& _value);
|
||||
|
||||
virtual void _setPropertyImpl(const std::string& _key, const std::string& _value);
|
||||
|
||||
int mSpacing; // how much space to put between elements
|
||||
|
||||
int mPadding; // outer padding
|
||||
|
||||
bool mAutoResize; // auto resize the box so that it exactly fits all elements
|
||||
};
|
||||
|
||||
class HBox : public Box, public MyGUI::Widget
|
||||
|
@ -369,10 +372,16 @@ namespace MWGui
|
|||
|
||||
public:
|
||||
virtual void setSize (const MyGUI::IntSize &_value);
|
||||
virtual void setCoord (const MyGUI::IntCoord &_value);
|
||||
|
||||
protected:
|
||||
virtual void align();
|
||||
virtual MyGUI::IntSize getRequestedSize();
|
||||
|
||||
virtual void setPropertyOverride(const std::string& _key, const std::string& _value);
|
||||
|
||||
virtual void onWidgetCreated(MyGUI::Widget* _widget);
|
||||
virtual void onWidgetDestroy(MyGUI::Widget* _widget);
|
||||
};
|
||||
|
||||
class VBox : public Box, public MyGUI::Widget
|
||||
|
@ -381,10 +390,16 @@ namespace MWGui
|
|||
|
||||
public:
|
||||
virtual void setSize (const MyGUI::IntSize &_value);
|
||||
virtual void setCoord (const MyGUI::IntCoord &_value);
|
||||
|
||||
protected:
|
||||
virtual void align();
|
||||
virtual MyGUI::IntSize getRequestedSize();
|
||||
|
||||
virtual void setPropertyOverride(const std::string& _key, const std::string& _value);
|
||||
|
||||
virtual void onWidgetCreated(MyGUI::Widget* _widget);
|
||||
virtual void onWidgetDestroy(MyGUI::Widget* _widget);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include "quickkeysmenu.hpp"
|
||||
#include "loadingscreen.hpp"
|
||||
#include "levelupdialog.hpp"
|
||||
#include "waitdialog.hpp"
|
||||
|
||||
using namespace MWGui;
|
||||
|
||||
|
@ -71,6 +72,8 @@ WindowManager::WindowManager(
|
|||
, mSpellWindow(NULL)
|
||||
, mLoadingScreen(NULL)
|
||||
, mCharGen(NULL)
|
||||
, mLevelupDialog(NULL)
|
||||
, mWaitDialog(NULL)
|
||||
, mPlayerClass()
|
||||
, mPlayerName()
|
||||
, mPlayerRaceId()
|
||||
|
@ -150,6 +153,7 @@ WindowManager::WindowManager(
|
|||
mSpellWindow = new SpellWindow(*this);
|
||||
mQuickKeysMenu = new QuickKeysMenu(*this);
|
||||
mLevelupDialog = new LevelupDialog(*this);
|
||||
mWaitDialog = new WaitDialog(*this);
|
||||
|
||||
mLoadingScreen = new LoadingScreen(mOgre->getScene (), mOgre->getWindow (), *this);
|
||||
mLoadingScreen->onResChange (w,h);
|
||||
|
@ -204,6 +208,7 @@ WindowManager::~WindowManager()
|
|||
delete mSpellWindow;
|
||||
delete mLoadingScreen;
|
||||
delete mLevelupDialog;
|
||||
delete mWaitDialog;
|
||||
|
||||
cleanupGarbage();
|
||||
|
||||
|
@ -252,6 +257,7 @@ void WindowManager::updateVisible()
|
|||
mSpellWindow->setVisible(false);
|
||||
mQuickKeysMenu->setVisible(false);
|
||||
mLevelupDialog->setVisible(false);
|
||||
mWaitDialog->setVisible(false);
|
||||
|
||||
mHud->setVisible(true);
|
||||
|
||||
|
@ -304,7 +310,8 @@ void WindowManager::updateVisible()
|
|||
mAlchemyWindow->setVisible(true);
|
||||
break;
|
||||
case GM_Rest:
|
||||
mLevelupDialog->setVisible(true);
|
||||
//mLevelupDialog->setVisible(true);
|
||||
mWaitDialog->setVisible(true);
|
||||
break;
|
||||
case GM_Name:
|
||||
case GM_Race:
|
||||
|
|
|
@ -63,6 +63,7 @@ namespace MWGui
|
|||
class QuickKeysMenu;
|
||||
class LoadingScreen;
|
||||
class LevelupDialog;
|
||||
class WaitDialog;
|
||||
|
||||
class WindowManager : public MWBase::WindowManager
|
||||
{
|
||||
|
@ -229,6 +230,7 @@ namespace MWGui
|
|||
QuickKeysMenu* mQuickKeysMenu;
|
||||
LoadingScreen* mLoadingScreen;
|
||||
LevelupDialog* mLevelupDialog;
|
||||
WaitDialog* mWaitDialog;
|
||||
|
||||
CharacterCreation* mCharGen;
|
||||
|
||||
|
|
|
@ -73,6 +73,7 @@ set(MYGUI_FILES
|
|||
openmw_spell_buying_window.layout
|
||||
openmw_loading_screen.layout
|
||||
openmw_levelup_dialog.layout
|
||||
openmw_wait_dialog.layout
|
||||
smallbars.png
|
||||
VeraMono.ttf
|
||||
markers.png
|
||||
|
|
45
files/mygui/openmw_wait_dialog.layout
Normal file
45
files/mygui/openmw_wait_dialog.layout
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<MyGUI type="Layout">
|
||||
<Widget type="VBox" skin="MW_Dialog" layer="Windows" position="0 0 600 200" name="_Main">
|
||||
<Property key="Padding" value="12"/>
|
||||
<Property key="Spacing" value="8"/>
|
||||
<Property key="AutoResize" value="true"/>
|
||||
|
||||
<Widget type="AutoSizedTextBox" skin="SandText">
|
||||
<Property key="Caption" value="24 Herzfeuer (Tag 24) 2 a.m."/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="AutoSizedTextBox" skin="SandText">
|
||||
<Property key="Caption" value="#{sRestIllegal}"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="AutoSizedTextBox" skin="SandText">
|
||||
<Property key="Caption" value="1 Stunde(n)"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="ScrollBar" skin="MW_HScroll" name="HourSlider" position="0 0 0 18">
|
||||
<Property key="MoveToClick" value="true"/>
|
||||
<Property key="Range" value="25"/>
|
||||
<Property key="RangePosition" value="23"/>
|
||||
<UserString key="HStretch" value="true"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="HBox">
|
||||
<UserString key="HStretch" value="true"/>
|
||||
<Widget type="Widget">
|
||||
<UserString key="HStretch" value="true"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="AutoSizedButton" skin="MW_Button" name="UntilHealedButton">
|
||||
<Property key="Caption" value="#{sUntilHealed}"/>
|
||||
</Widget>
|
||||
<Widget type="AutoSizedButton" skin="MW_Button" name="WaitButton">
|
||||
<Property key="Caption" value="#{sRest}"/>
|
||||
</Widget>
|
||||
<Widget type="AutoSizedButton" skin="MW_Button" name="CancelButton">
|
||||
<Property key="Caption" value="#{sCancel}"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
</Widget>
|
||||
</MyGUI>
|
Loading…
Reference in a new issue