Added combo box widget and use it in options menu. Fixes to VBox / HBox. Added savegame dialog.

actorid
scrawl 11 years ago
parent c3d9bc31bb
commit bf5529819d

@ -34,7 +34,7 @@ add_openmw_dir (mwgui
enchantingdialog trainingwindow travelwindow imagebutton exposedwindow cursor spellicons
merchantrepair repair soulgemdialog companionwindow bookpage journalviewmodel journalbooks
keywordsearch itemmodel containeritemmodel inventoryitemmodel sortfilteritemmodel itemview
tradeitemmodel companionitemmodel pickpocketitemmodel fontloader controllers
tradeitemmodel companionitemmodel pickpocketitemmodel fontloader controllers savegamedialog
)
add_openmw_dir (mwdialogue

@ -9,6 +9,8 @@
#include "../mwbase/journal.hpp"
#include "../mwbase/dialoguemanager.hpp"
#include "savegamedialog.hpp"
namespace MWGui
{
@ -85,6 +87,19 @@ namespace MWGui
MWBase::Environment::get().getDialogueManager()->clear();
MWBase::Environment::get().getJournal()->clear();
}
else if (sender == mButtons["loadgame"])
{
MWGui::SaveGameDialog* dialog = new MWGui::SaveGameDialog();
dialog->setLoadOrSave(true);
dialog->setVisible(true);
}
else if (sender == mButtons["savegame"])
{
MWGui::SaveGameDialog* dialog = new MWGui::SaveGameDialog();
dialog->setLoadOrSave(false);
dialog->setVisible(true);
}
}
}

@ -0,0 +1,49 @@
#include "savegamedialog.hpp"
#include "widgets.hpp"
namespace MWGui
{
SaveGameDialog::SaveGameDialog()
: WindowModal("openmw_savegame_dialog.layout")
{
getWidget(mScreenshot, "Screenshot");
getWidget(mCharacterSelection, "SelectCharacter");
getWidget(mInfoText, "InfoText");
getWidget(mOkButton, "OkButton");
getWidget(mCancelButton, "CancelButton");
getWidget(mSaveList, "SaveList");
getWidget(mSaveNameEdit, "SaveNameEdit");
getWidget(mSpacer, "Spacer");
mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SaveGameDialog::onOkButtonClicked);
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SaveGameDialog::onCancelButtonClicked);
}
void SaveGameDialog::open()
{
center();
}
void SaveGameDialog::setLoadOrSave(bool load)
{
mSaveNameEdit->setVisible(!load);
mCharacterSelection->setUserString("Hidden", load ? "false" : "true");
mCharacterSelection->setVisible(load);
mSpacer->setUserString("Hidden", load ? "false" : "true");
center();
}
void SaveGameDialog::onCancelButtonClicked(MyGUI::Widget *sender)
{
setVisible(false);
}
void SaveGameDialog::onOkButtonClicked(MyGUI::Widget *sender)
{
setVisible(false);
}
}

@ -0,0 +1,37 @@
#ifndef OPENMW_MWGUI_SAVEGAMEDIALOG_H
#define OPENMW_MWGUI_SAVEGAMEDIALOG_H
#include "windowbase.hpp"
namespace MWGui
{
class SaveGameDialog : public MWGui::WindowModal
{
public:
SaveGameDialog();
virtual void open();
void setLoadOrSave(bool load);
void onCancelButtonClicked (MyGUI::Widget* sender);
void onOkButtonClicked (MyGUI::Widget* sender);
private:
MyGUI::ImageBox* mScreenshot;
MyGUI::ComboBox* mCharacterSelection;
MyGUI::EditBox* mInfoText;
MyGUI::Button* mOkButton;
MyGUI::Button* mCancelButton;
MyGUI::ListBox* mSaveList;
MyGUI::EditBox* mSaveNameEdit;
MyGUI::Widget* mSpacer;
};
}
#endif

@ -31,9 +31,7 @@ namespace
std::string textureFilteringToStr(const std::string& val)
{
if (val == "none")
return "None";
else if (val == "anisotropic")
if (val == "anisotropic")
return "Anisotropic";
else if (val == "bilinear")
return "Bilinear";
@ -145,7 +143,7 @@ namespace MWGui
mReflectObjectsButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
mReflectTerrainButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
mReflectActorsButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
mTextureFilteringButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onTextureFilteringToggled);
mTextureFilteringButton->eventComboChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onTextureFilteringChanged);
mVSyncButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
mFPSButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onFpsToggled);
mMenuTransparencySlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition);
@ -157,7 +155,7 @@ namespace MWGui
mShadowsEnabledButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
mShadowsLargeDistance->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
mShadowsTextureSize->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onShadowTextureSize);
mShadowsTextureSize->eventComboChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onShadowTextureSizeChanged);
mActorShadows->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
mStaticsShadows->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
mMiscShadows->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
@ -297,22 +295,9 @@ namespace MWGui
mResolutionList->setIndexSelected(MyGUI::ITEM_NONE);
}
void SettingsWindow::onShadowTextureSize(MyGUI::Widget* _sender)
void SettingsWindow::onShadowTextureSizeChanged(MyGUI::ComboBox *_sender, size_t pos)
{
std::string size = mShadowsTextureSize->getCaption();
if (size == "512")
size = "1024";
else if (size == "1024")
size = "2048";
else if (size == "2048")
size = "4096";
else
size = "512";
mShadowsTextureSize->setCaption(size);
Settings::Manager::setString("texture size", "Shadows", size);
Settings::Manager::setString("texture size", "Shadows", _sender->getItemNameAt(pos));
apply();
}
@ -482,22 +467,9 @@ namespace MWGui
apply();
}
void SettingsWindow::onTextureFilteringToggled(MyGUI::Widget* _sender)
void SettingsWindow::onTextureFilteringChanged(MyGUI::ComboBox* _sender, size_t pos)
{
std::string current = Settings::Manager::getString("texture filtering", "General");
std::string next;
if (current == "none")
next = "bilinear";
else if (current == "bilinear")
next = "trilinear";
else if (current == "trilinear")
next = "anisotropic";
else
next = "none";
mTextureFilteringButton->setCaption(textureFilteringToStr(next));
Settings::Manager::setString("texture filtering", "General", next);
Settings::Manager::setString("texture filtering", "General", Misc::StringUtils::lowerCase(_sender->getItemNameAt(pos)));
apply();
}

@ -42,7 +42,7 @@ namespace MWGui
MyGUI::ScrollBar* mViewDistanceSlider;
MyGUI::ScrollBar* mFOVSlider;
MyGUI::ScrollBar* mAnisotropySlider;
MyGUI::Button* mTextureFilteringButton;
MyGUI::ComboBox* mTextureFilteringButton;
MyGUI::TextBox* mAnisotropyLabel;
MyGUI::Widget* mAnisotropyBox;
MyGUI::Button* mWaterShaderButton;
@ -55,7 +55,7 @@ namespace MWGui
MyGUI::Button* mShadowsEnabledButton;
MyGUI::Button* mShadowsLargeDistance;
MyGUI::Button* mShadowsTextureSize;
MyGUI::ComboBox* mShadowsTextureSize;
MyGUI::Button* mActorShadows;
MyGUI::Button* mStaticsShadows;
MyGUI::Button* mMiscShadows;
@ -76,7 +76,7 @@ namespace MWGui
void onOkButtonClicked(MyGUI::Widget* _sender);
void onFpsToggled(MyGUI::Widget* _sender);
void onTextureFilteringToggled(MyGUI::Widget* _sender);
void onTextureFilteringChanged(MyGUI::ComboBox* _sender, size_t pos);
void onSliderChangePosition(MyGUI::ScrollBar* scroller, size_t pos);
void onButtonToggled(MyGUI::Widget* _sender);
void onResolutionSelected(MyGUI::ListBox* _sender, size_t index);
@ -85,7 +85,7 @@ namespace MWGui
void onShadersToggled(MyGUI::Widget* _sender);
void onShaderModeToggled(MyGUI::Widget* _sender);
void onShadowTextureSize(MyGUI::Widget* _sender);
void onShadowTextureSizeChanged(MyGUI::ComboBox* _sender, size_t pos);
void onRebindAction(MyGUI::Widget* _sender);
void onInputTabMouseWheel(MyGUI::Widget* _sender, int _rel);

@ -689,22 +689,26 @@ namespace MWGui
int total_width = 0;
int total_height = 0;
std::vector< std::pair<MyGUI::IntSize, bool> > sizes;
sizes.resize(count);
for (unsigned int i = 0; i < count; ++i)
{
MyGUI::Widget* w = getChildAt(i);
bool hstretch = w->getUserString ("HStretch") == "true";
bool hidden = w->getUserString("Hidden") == "true";
if (hidden)
continue;
h_stretched_count += hstretch;
AutoSizedWidget* aw = dynamic_cast<AutoSizedWidget*>(w);
if (aw)
{
sizes.push_back(std::make_pair(aw->getRequestedSize (), hstretch));
sizes[i] = std::make_pair(aw->getRequestedSize (), hstretch);
total_width += aw->getRequestedSize ().width;
total_height = std::max(total_height, aw->getRequestedSize ().height);
}
else
{
sizes.push_back (std::make_pair(w->getSize(), hstretch));
sizes[i] = std::make_pair(w->getSize(), hstretch);
total_width += w->getSize().width;
if (!(w->getUserString("VStretch") == "true"))
total_height = std::max(total_height, w->getSize().height);
@ -729,8 +733,13 @@ namespace MWGui
MyGUI::Widget* w = getChildAt(i);
bool hidden = w->getUserString("Hidden") == "true";
if (hidden)
continue;
bool vstretch = w->getUserString ("VStretch") == "true";
int height = vstretch ? total_height : sizes[i].first.height;
int max_height = getSize().height - mPadding*2;
int height = vstretch ? max_height : sizes[i].first.height;
MyGUI::IntCoord widgetCoord;
widgetCoord.left = curX;
@ -774,6 +783,10 @@ namespace MWGui
MyGUI::IntSize size(0,0);
for (unsigned int i = 0; i < getChildCount (); ++i)
{
bool hidden = getChildAt(i)->getUserString("Hidden") == "true";
if (hidden)
continue;
AutoSizedWidget* w = dynamic_cast<AutoSizedWidget*>(getChildAt(i));
if (w)
{
@ -810,21 +823,27 @@ namespace MWGui
int total_height = 0;
int total_width = 0;
std::vector< std::pair<MyGUI::IntSize, bool> > sizes;
sizes.resize(count);
for (unsigned int i = 0; i < count; ++i)
{
MyGUI::Widget* w = getChildAt(i);
bool hidden = w->getUserString("Hidden") == "true";
if (hidden)
continue;
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));
sizes[i] = 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));
sizes[i] = std::make_pair(w->getSize(), vstretch);
total_height += w->getSize().height;
if (!(w->getUserString("HStretch") == "true"))
@ -850,8 +869,13 @@ namespace MWGui
MyGUI::Widget* w = getChildAt(i);
bool hidden = w->getUserString("Hidden") == "true";
if (hidden)
continue;
bool hstretch = w->getUserString ("HStretch") == "true";
int width = hstretch ? total_width : sizes[i].first.width;
int maxWidth = getSize().width - mPadding*2;
int width = hstretch ? maxWidth : sizes[i].first.width;
MyGUI::IntCoord widgetCoord;
widgetCoord.top = curY;
@ -890,6 +914,10 @@ namespace MWGui
MyGUI::IntSize size(0,0);
for (unsigned int i = 0; i < getChildCount (); ++i)
{
bool hidden = getChildAt(i)->getUserString("Hidden") == "true";
if (hidden)
continue;
AutoSizedWidget* w = dynamic_cast<AutoSizedWidget*>(getChildAt(i));
if (w)
{

@ -81,6 +81,7 @@ set(MYGUI_FILES
openmw_merchantrepair.layout
openmw_repair.layout
openmw_companion_window.layout
openmw_savegame_dialog.layout
smallbars.png
DejaVuLGCSansMono.ttf
markers.png

@ -126,6 +126,19 @@
</Skin>
<Skin name="MW_PopupList" size="516 516" align="Left Top">
<Property key="NeedKey" value="true"/>
<Property key="SkinLine" value="MW_ListLine"/>
<Property key="HeightLine" value="20"/>
<Child type="Widget" skin="BlackBG" offset="0 0 516 516" align="Stretch"/>
<Child type="Widget" skin="MW_Box" offset="0 0 516 516" align="Stretch"/>
<Child type="MWScrollBar" skin="MW_VScroll" offset="498 3 14 509" align="Right VStretch" name="VScroll"/>
<Child type="Widget" skin="" offset="3 3 493 509" align="Stretch" name="Client"/>
</Skin>
<Skin name="MW_ItemView" size="516 516" align="Left Top">
<Child type="Widget" skin="MW_Box" offset="0 0 516 516" align="Stretch"/>

@ -301,4 +301,22 @@
</Widget>
</Resource>
<Resource type="ResourceLayout" name="MW_ComboBox" version="3.2.0">
<Widget type="Widget" skin="" position="65 10 100 26" name="Root">
<Property key="MaxListLength" value="200"/>
<Property key="SmoothShow" value="true"/>
<Property key="ModeDrop" value="true"/>
<Widget type="Widget" skin="MW_Box" position="0 0 100 26" align="Stretch">
<Widget type="TextBox" skin="SandText" position="2 2 75 20" align="Stretch" name="Client">
<Property key="TextAlign" value="Left VCenter"/>
</Widget>
<Widget type="ListBox" skin="MW_PopupList" position="65 38 100 200" style="Popup" layer="Popup" name="List">
<Property key="Visible" value="false"/>
</Widget>
<Widget type="Button" skin="MW_ArrowDown" position="79 7 14 11" align="Right VCenter" name="Button"/>
</Widget>
</Widget>
</Resource>
</MyGUI>

@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Layout">
<Widget type="VBox" skin="MW_Dialog" layer="Windows" position="0 0 600 400" name="_Main">
<Property key="Padding" value="8"/>
<Property key="Spacing" value="6"/>
<Widget type="HBox" skin="">
<UserString key="HStretch" value="true"/>
<UserString key="VStretch" value="true"/>
<Widget type="VBox" skin="">
<UserString key="HStretch" value="true"/>
<UserString key="VStretch" value="true"/>
<Widget type="ComboBox" skin="MW_ComboBox" position="0 0 200 24" name="SelectCharacter">
<Property key="Caption" value="Select Character"/>
<Property key="AddItem" value="Gandalf (Level 654)"/>
<Property key="AddItem" value="Frodo (Level 3)"/>
<UserString key="HStretch" value="true"/>
</Widget>
<Widget type="ListBox" skin="MW_List" position="0 0 200 200" name="SaveList">
<UserString key="HStretch" value="true"/>
<UserString key="VStretch" value="true"/>
<Property key="AddItem" value="Quicksave"/>
<Property key="AddItem" value="Autosave"/>
<Property key="AddItem" value="Save 3"/>
<Property key="AddItem" value="Save 2"/>
<Property key="AddItem" value="Save 1"/>
</Widget>
</Widget>
<Widget type="VBox" skin="">
<UserString key="HStretch" value="false"/>
<UserString key="VStretch" value="true"/>
<Property key="Spacing" value="4"/>
<Widget type="AutoSizedButton" skin="" name="Spacer">
<Property key="Visible" value="false"/>
</Widget>
<Widget type="Widget" skin="MW_Box" position="0 0 263 137">
<Widget type="ImageBox" skin="ImageBox" position="2 2 259 133" name="Screenshot"/>
</Widget>
<Widget type="AutoSizedEditBox" skin="SandText" position="0 0 263 0" name="InfoText">
<Property key="Static" value="true"/>
<Property key="MultiLine" value="true"/>
<Property key="Caption" value="4:21 AM\nTuesday, November 5, 2013\n\nLevel 23\nBalmora, Guild of Mages\n16 Last Seed (Day 12) 9 a.m. "/>
</Widget>
</Widget>
</Widget>
<Widget type="HBox" skin="">
<UserString key="HStretch" value="true"/>
<Widget type="EditBox" skin="MW_TextEdit" name="SaveNameEdit">
<UserString key="HStretch" value="true"/>
<UserString key="VStretch" value="true"/>
</Widget>
<Widget type="AutoSizedButton" skin="MW_Button" name="CancelButton">
<Property key="Caption" value="#{sCancel}"/>
</Widget>
<Widget type="AutoSizedButton" skin="MW_Button" name="OkButton">
<Property key="Caption" value="#{sOk}"/>
</Widget>
</Widget>
</Widget>
</MyGUI>

@ -216,7 +216,11 @@
<Widget type="TextBox" skin="NormalText" position="4 4 300 24" align="Left Top">
<Property key="Caption" value="Texture filtering"/>
</Widget>
<Widget type="AutoSizedButton" skin="MW_Button" position="18 28 140 24" align="Left Top" name="TextureFilteringButton"/>
<Widget type="ComboBox" skin="MW_ComboBox" position="14 28 110 24" align="Left Top" name="TextureFilteringButton">
<Property key="AddItem" value="Bilinear"/>
<Property key="AddItem" value="Trilinear"/>
<Property key="AddItem" value="Anisotropic"/>
</Widget>
<Widget type="Widget" skin="" position="184 4 300 50" align="Left Top" name="AnisotropyBox">
<Widget type="TextBox" skin="SandText" position="0 0 300 24" align="Left Top" name="AnisotropyLabel">
@ -308,9 +312,9 @@
</Widget>
<Widget type="HBox" position="4 28 350 24">
<Widget type="AutoSizedButton" skin="MW_Button" align="Left Top" name="ShadowsTextureSize"/>
<Widget type="AutoSizedButton" skin="MW_Button" align="Left Top" name="TerrainShadows"/>
<Widget type="AutoSizedTextBox" skin="SandText" align="Left Top">
<Property key="Caption" value="Texture size"/>
<Property key="Caption" value="Terrain shadows"/>
</Widget>
</Widget>
@ -336,9 +340,14 @@
</Widget>
<Widget type="HBox" position="4 140 350 24">
<Widget type="AutoSizedButton" skin="MW_Button" align="Left Top" name="TerrainShadows"/>
<Widget type="ComboBox" skin="MW_ComboBox" align="Left Top" name="ShadowsTextureSize" position="0 0 60 24">
<Property key="AddItem" value="512"/>
<Property key="AddItem" value="1024"/>
<Property key="AddItem" value="2048"/>
<Property key="AddItem" value="4096"/>
</Widget>
<Widget type="AutoSizedTextBox" skin="SandText" align="Left Top">
<Property key="Caption" value="Terrain shadows"/>
<Property key="Caption" value="Texture size"/>
</Widget>
</Widget>

Loading…
Cancel
Save