diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 807b1b5ff..25e4b6370 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -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 diff --git a/apps/openmw/mwgui/imagebutton.cpp b/apps/openmw/mwgui/imagebutton.cpp index 98f05373b..f2565f5c0 100644 --- a/apps/openmw/mwgui/imagebutton.cpp +++ b/apps/openmw/mwgui/imagebutton.cpp @@ -42,12 +42,13 @@ namespace MWGui ImageBox::onMouseButtonPressed(_left, _top, _id); } - MyGUI::IntSize ImageButton::getRequestedSize() + MyGUI::IntSize ImageButton::getRequestedSize(bool logError) { Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().getByName(mImageNormal); if (texture.isNull()) { - std::cerr << "ImageButton: can't find " << mImageNormal << std::endl; + if (logError) + std::cerr << "ImageButton: can't find " << mImageNormal << std::endl; return MyGUI::IntSize(0,0); } return MyGUI::IntSize (texture->getWidth(), texture->getHeight()); diff --git a/apps/openmw/mwgui/imagebutton.hpp b/apps/openmw/mwgui/imagebutton.hpp index f531e2246..f4191a3a5 100644 --- a/apps/openmw/mwgui/imagebutton.hpp +++ b/apps/openmw/mwgui/imagebutton.hpp @@ -14,7 +14,7 @@ namespace MWGui MYGUI_RTTI_DERIVED(ImageButton) public: - MyGUI::IntSize getRequestedSize(); + MyGUI::IntSize getRequestedSize(bool logError = true); protected: virtual void setPropertyOverride(const std::string& _key, const std::string& _value); diff --git a/apps/openmw/mwgui/journalwindow.cpp b/apps/openmw/mwgui/journalwindow.cpp index ab8dc1584..f3c9e9c73 100644 --- a/apps/openmw/mwgui/journalwindow.cpp +++ b/apps/openmw/mwgui/journalwindow.cpp @@ -137,15 +137,28 @@ namespace getPage (QuestsPage)->adviseLinkClicked (callback); } - adjustButton(OptionsBTN); + adjustButton(OptionsBTN, true); adjustButton(PrevPageBTN); adjustButton(NextPageBTN); adjustButton(CloseBTN); adjustButton(CancelBTN); - adjustButton(ShowAllBTN); - adjustButton(ShowActiveBTN); + adjustButton(ShowAllBTN, true); + adjustButton(ShowActiveBTN, true); adjustButton(JournalBTN); + MWGui::ImageButton* optionsButton = getWidget(OptionsBTN); + if (optionsButton->getWidth() == 0) + { + // If tribunal is not installed (-> no options button), we still want the Topics button available, + // so place it where the options button would have been + MWGui::ImageButton* topicsButton = getWidget(TopicsBTN); + topicsButton->detachFromWidget(); + topicsButton->attachToWidget(optionsButton->getParent()); + topicsButton->setPosition(optionsButton->getPosition()); + topicsButton->eventMouseButtonClick.clear(); + topicsButton->eventMouseButtonClick += MyGUI::newDelegate(this, &JournalWindowImpl::notifyOptions); + } + MWGui::ImageButton* nextButton = getWidget(NextPageBTN); if (nextButton->getSize().width == 64) { @@ -155,7 +168,7 @@ namespace } adjustButton(TopicsBTN); - adjustButton(QuestsBTN); + adjustButton(QuestsBTN, true); int width = getWidget(TopicsBTN)->getSize().width + getWidget(QuestsBTN)->getSize().width; int topicsWidth = getWidget(TopicsBTN)->getSize().width; int pageWidth = getWidget(RightBookPage)->getSize().width; @@ -167,12 +180,12 @@ namespace mAllQuests = false; } - void adjustButton (char const * name) + void adjustButton (char const * name, bool optional = false) { MWGui::ImageButton* button = getWidget(name); - MyGUI::IntSize diff = button->getSize() - button->getRequestedSize(); - button->setSize(button->getRequestedSize()); + MyGUI::IntSize diff = button->getSize() - button->getRequestedSize(!optional); + button->setSize(button->getRequestedSize(!optional)); if (button->getAlign().isRight()) button->setPosition(button->getPosition() + MyGUI::IntPoint(diff.width,0)); diff --git a/apps/openmw/mwgui/mainmenu.cpp b/apps/openmw/mwgui/mainmenu.cpp index 2c42dc210..fa7ed2ace 100644 --- a/apps/openmw/mwgui/mainmenu.cpp +++ b/apps/openmw/mwgui/mainmenu.cpp @@ -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); + } } } diff --git a/apps/openmw/mwgui/savegamedialog.cpp b/apps/openmw/mwgui/savegamedialog.cpp new file mode 100644 index 000000000..a1acd3588 --- /dev/null +++ b/apps/openmw/mwgui/savegamedialog.cpp @@ -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); + } + +} diff --git a/apps/openmw/mwgui/savegamedialog.hpp b/apps/openmw/mwgui/savegamedialog.hpp new file mode 100644 index 000000000..1a3178ef3 --- /dev/null +++ b/apps/openmw/mwgui/savegamedialog.hpp @@ -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 diff --git a/apps/openmw/mwgui/settingswindow.cpp b/apps/openmw/mwgui/settingswindow.cpp index 923b9d01d..1969c5651 100644 --- a/apps/openmw/mwgui/settingswindow.cpp +++ b/apps/openmw/mwgui/settingswindow.cpp @@ -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(); } diff --git a/apps/openmw/mwgui/settingswindow.hpp b/apps/openmw/mwgui/settingswindow.hpp index a585bda7e..c81a86ab0 100644 --- a/apps/openmw/mwgui/settingswindow.hpp +++ b/apps/openmw/mwgui/settingswindow.hpp @@ -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); diff --git a/apps/openmw/mwgui/widgets.cpp b/apps/openmw/mwgui/widgets.cpp index 3fc3187e8..c37ae15fa 100644 --- a/apps/openmw/mwgui/widgets.cpp +++ b/apps/openmw/mwgui/widgets.cpp @@ -689,22 +689,26 @@ namespace MWGui int total_width = 0; int total_height = 0; std::vector< std::pair > 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(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(getChildAt(i)); if (w) { @@ -810,21 +823,27 @@ namespace MWGui int total_height = 0; int total_width = 0; std::vector< std::pair > 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(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(getChildAt(i)); if (w) { diff --git a/files/mygui/CMakeLists.txt b/files/mygui/CMakeLists.txt index 21153a474..f79f2c3ed 100644 --- a/files/mygui/CMakeLists.txt +++ b/files/mygui/CMakeLists.txt @@ -80,6 +80,7 @@ set(MYGUI_FILES openmw_merchantrepair.layout openmw_repair.layout openmw_companion_window.layout + openmw_savegame_dialog.layout smallbars.png DejaVuLGCSansMono.ttf markers.png diff --git a/files/mygui/openmw_list.skin.xml b/files/mygui/openmw_list.skin.xml index 02c11c354..7972527ac 100644 --- a/files/mygui/openmw_list.skin.xml +++ b/files/mygui/openmw_list.skin.xml @@ -126,6 +126,19 @@ + + + + + + + + + + + + + diff --git a/files/mygui/openmw_resources.xml b/files/mygui/openmw_resources.xml index 2c3908a1b..3901ab825 100644 --- a/files/mygui/openmw_resources.xml +++ b/files/mygui/openmw_resources.xml @@ -301,4 +301,22 @@ + + + + + + + + + + + + + + + + + + diff --git a/files/mygui/openmw_savegame_dialog.layout b/files/mygui/openmw_savegame_dialog.layout new file mode 100644 index 000000000..18de6a239 --- /dev/null +++ b/files/mygui/openmw_savegame_dialog.layout @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/files/mygui/openmw_settings_window.layout b/files/mygui/openmw_settings_window.layout index ebfaf678a..e6002b51d 100644 --- a/files/mygui/openmw_settings_window.layout +++ b/files/mygui/openmw_settings_window.layout @@ -216,7 +216,11 @@ - + + + + + @@ -308,9 +312,9 @@ - + - + @@ -336,9 +340,14 @@ - + + + + + + - +