1
0
Fork 1
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:
scrawl 2012-09-18 18:29:03 +02:00
parent 747a4e1123
commit 0ba996f290
9 changed files with 257 additions and 18 deletions

View file

@ -29,7 +29,7 @@ add_openmw_dir (mwgui
map_window window_pinnable_base cursorreplace tooltips scrollwindow bookwindow list map_window window_pinnable_base cursorreplace tooltips scrollwindow bookwindow list
formatting inventorywindow container hud countdialog tradewindow settingswindow formatting inventorywindow container hud countdialog tradewindow settingswindow
confirmationdialog alchemywindow referenceinterface spellwindow mainmenu quickkeysmenu confirmationdialog alchemywindow referenceinterface spellwindow mainmenu quickkeysmenu
itemselection spellbuyingwindow loadingscreen levelupdialog itemselection spellbuyingwindow loadingscreen levelupdialog waitdialog
) )
add_openmw_dir (mwdialogue add_openmw_dir (mwdialogue

View file

@ -0,0 +1,12 @@
#include "waitdialog.hpp"
namespace MWGui
{
WaitDialog::WaitDialog(MWBase::WindowManager &parWindowManager)
: WindowBase("openmw_wait_dialog.layout", parWindowManager)
{
center();
}
}

View 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

View file

@ -869,29 +869,33 @@ void AutoSizedButton::setPropertyOverride(const std::string& _key, const std::st
Box::Box() Box::Box()
: mSpacing(4) : 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 () void Box::notifyChildrenSizeChanged ()
{ {
align(); 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 () void HBox::align ()
{ {
unsigned int count = getChildCount (); unsigned int count = getChildCount ();
size_t h_stretched_count = 0; size_t h_stretched_count = 0;
int total_width = 0; int total_width = 0;
int total_height = 0;
std::vector< std::pair<MyGUI::IntSize, bool> > sizes; std::vector< std::pair<MyGUI::IntSize, bool> > sizes;
for (unsigned int i = 0; i < count; ++i) for (unsigned int i = 0; i < count; ++i)
@ -904,28 +908,43 @@ void HBox::align ()
{ {
sizes.push_back(std::make_pair(aw->getRequestedSize (), hstretch)); sizes.push_back(std::make_pair(aw->getRequestedSize (), hstretch));
total_width += aw->getRequestedSize ().width; total_width += aw->getRequestedSize ().width;
total_height = std::max(total_height, aw->getRequestedSize ().height);
} }
else else
{ {
if (!hstretch) h_stretched_count ++; sizes.push_back (std::make_pair(w->getSize(), hstretch));
sizes.push_back (std::make_pair(MyGUI::IntSize(0,0), true)); total_width += w->getSize().width;
} }
if (i != count-1) if (i != count-1)
total_width += mSpacing; 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; int curX = 0;
for (unsigned int i = 0; i < count; ++i) for (unsigned int i = 0; i < count; ++i)
{ {
if (i == 0)
curX += mPadding;
MyGUI::Widget* w = getChildAt(i); MyGUI::Widget* w = getChildAt(i);
bool vstretch = w->getUserString ("VStretch") == "true";
int height = vstretch ? total_height : sizes[i].first.height;
MyGUI::IntCoord widgetCoord; MyGUI::IntCoord widgetCoord;
widgetCoord.left = curX; widgetCoord.left = curX;
widgetCoord.top = (getSize().height - sizes[i].first.height) / 2; widgetCoord.top = mPadding + (getSize().height-mPadding*2 - height) / 2;
int width = sizes[i].second ? sizes[i].first.width + (getSize().width - total_width)/h_stretched_count int width = sizes[i].second ? sizes[i].first.width + (getSize().width-mPadding*2 - total_width)/h_stretched_count
: sizes[i].first.width; : sizes[i].first.width;
widgetCoord.width = width; widgetCoord.width = width;
widgetCoord.height = sizes[i].first.height; widgetCoord.height = height;
w->setCoord(widgetCoord); w->setCoord(widgetCoord);
curX += width; 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) void HBox::setSize (const MyGUI::IntSize& _value)
{ {
MyGUI::Widget::setSize (_value); MyGUI::Widget::setSize (_value);
align(); 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 HBox::getRequestedSize ()
{ {
MyGUI::IntSize size(0,0); MyGUI::IntSize size(0,0);
@ -954,6 +994,16 @@ MyGUI::IntSize HBox::getRequestedSize ()
if (i != getChildCount()-1) if (i != getChildCount()-1)
size.width += mSpacing; 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; return size;
} }
@ -963,7 +1013,69 @@ MyGUI::IntSize HBox::getRequestedSize ()
void VBox::align () 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) void VBox::setSize (const MyGUI::IntSize& _value)
@ -972,6 +1084,12 @@ void VBox::setSize (const MyGUI::IntSize& _value)
align(); align();
} }
void VBox::setCoord (const MyGUI::IntCoord& _value)
{
MyGUI::Widget::setCoord (_value);
align();
}
MyGUI::IntSize VBox::getRequestedSize () MyGUI::IntSize VBox::getRequestedSize ()
{ {
MyGUI::IntSize size(0,0); MyGUI::IntSize size(0,0);
@ -986,6 +1104,26 @@ MyGUI::IntSize VBox::getRequestedSize ()
if (i != getChildCount()-1) if (i != getChildCount()-1)
size.height += mSpacing; 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; return size;
} }
void VBox::onWidgetCreated(MyGUI::Widget* _widget)
{
align();
}
void VBox::onWidgetDestroy(MyGUI::Widget* _widget)
{
align();
}

View file

@ -357,10 +357,13 @@ namespace MWGui
protected: protected:
virtual void align() = 0; 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 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 class HBox : public Box, public MyGUI::Widget
@ -369,10 +372,16 @@ namespace MWGui
public: public:
virtual void setSize (const MyGUI::IntSize &_value); virtual void setSize (const MyGUI::IntSize &_value);
virtual void setCoord (const MyGUI::IntCoord &_value);
protected: protected:
virtual void align(); virtual void align();
virtual MyGUI::IntSize getRequestedSize(); 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 class VBox : public Box, public MyGUI::Widget
@ -381,10 +390,16 @@ namespace MWGui
public: public:
virtual void setSize (const MyGUI::IntSize &_value); virtual void setSize (const MyGUI::IntSize &_value);
virtual void setCoord (const MyGUI::IntCoord &_value);
protected: protected:
virtual void align(); virtual void align();
virtual MyGUI::IntSize getRequestedSize(); 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);
}; };
} }
} }

View file

@ -45,6 +45,7 @@
#include "quickkeysmenu.hpp" #include "quickkeysmenu.hpp"
#include "loadingscreen.hpp" #include "loadingscreen.hpp"
#include "levelupdialog.hpp" #include "levelupdialog.hpp"
#include "waitdialog.hpp"
using namespace MWGui; using namespace MWGui;
@ -71,6 +72,8 @@ WindowManager::WindowManager(
, mSpellWindow(NULL) , mSpellWindow(NULL)
, mLoadingScreen(NULL) , mLoadingScreen(NULL)
, mCharGen(NULL) , mCharGen(NULL)
, mLevelupDialog(NULL)
, mWaitDialog(NULL)
, mPlayerClass() , mPlayerClass()
, mPlayerName() , mPlayerName()
, mPlayerRaceId() , mPlayerRaceId()
@ -150,6 +153,7 @@ WindowManager::WindowManager(
mSpellWindow = new SpellWindow(*this); mSpellWindow = new SpellWindow(*this);
mQuickKeysMenu = new QuickKeysMenu(*this); mQuickKeysMenu = new QuickKeysMenu(*this);
mLevelupDialog = new LevelupDialog(*this); mLevelupDialog = new LevelupDialog(*this);
mWaitDialog = new WaitDialog(*this);
mLoadingScreen = new LoadingScreen(mOgre->getScene (), mOgre->getWindow (), *this); mLoadingScreen = new LoadingScreen(mOgre->getScene (), mOgre->getWindow (), *this);
mLoadingScreen->onResChange (w,h); mLoadingScreen->onResChange (w,h);
@ -204,6 +208,7 @@ WindowManager::~WindowManager()
delete mSpellWindow; delete mSpellWindow;
delete mLoadingScreen; delete mLoadingScreen;
delete mLevelupDialog; delete mLevelupDialog;
delete mWaitDialog;
cleanupGarbage(); cleanupGarbage();
@ -252,6 +257,7 @@ void WindowManager::updateVisible()
mSpellWindow->setVisible(false); mSpellWindow->setVisible(false);
mQuickKeysMenu->setVisible(false); mQuickKeysMenu->setVisible(false);
mLevelupDialog->setVisible(false); mLevelupDialog->setVisible(false);
mWaitDialog->setVisible(false);
mHud->setVisible(true); mHud->setVisible(true);
@ -304,7 +310,8 @@ void WindowManager::updateVisible()
mAlchemyWindow->setVisible(true); mAlchemyWindow->setVisible(true);
break; break;
case GM_Rest: case GM_Rest:
mLevelupDialog->setVisible(true); //mLevelupDialog->setVisible(true);
mWaitDialog->setVisible(true);
break; break;
case GM_Name: case GM_Name:
case GM_Race: case GM_Race:

View file

@ -63,6 +63,7 @@ namespace MWGui
class QuickKeysMenu; class QuickKeysMenu;
class LoadingScreen; class LoadingScreen;
class LevelupDialog; class LevelupDialog;
class WaitDialog;
class WindowManager : public MWBase::WindowManager class WindowManager : public MWBase::WindowManager
{ {
@ -229,6 +230,7 @@ namespace MWGui
QuickKeysMenu* mQuickKeysMenu; QuickKeysMenu* mQuickKeysMenu;
LoadingScreen* mLoadingScreen; LoadingScreen* mLoadingScreen;
LevelupDialog* mLevelupDialog; LevelupDialog* mLevelupDialog;
WaitDialog* mWaitDialog;
CharacterCreation* mCharGen; CharacterCreation* mCharGen;

View file

@ -73,6 +73,7 @@ set(MYGUI_FILES
openmw_spell_buying_window.layout openmw_spell_buying_window.layout
openmw_loading_screen.layout openmw_loading_screen.layout
openmw_levelup_dialog.layout openmw_levelup_dialog.layout
openmw_wait_dialog.layout
smallbars.png smallbars.png
VeraMono.ttf VeraMono.ttf
markers.png markers.png

View 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>