diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index fd2fdf575..a3c147b94 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -28,6 +28,7 @@ add_openmw_dir (mwgui dialogue_history window_base stats_window messagebox journalwindow charactercreation map_window window_pinnable_base cursorreplace tooltips scrollwindow bookwindow list formatting itemwidget inventorywindow container hud countdialog tradewindow settingswindow + confirmationdialog ) add_openmw_dir (mwdialogue diff --git a/apps/openmw/mwgui/confirmationdialog.cpp b/apps/openmw/mwgui/confirmationdialog.cpp new file mode 100644 index 000000000..a54bdb1d8 --- /dev/null +++ b/apps/openmw/mwgui/confirmationdialog.cpp @@ -0,0 +1,68 @@ +#include "confirmationdialog.hpp" + +#include + +#include "../mwbase/environment.hpp" +#include "../mwworld/world.hpp" + +namespace MWGui +{ + ConfirmationDialog::ConfirmationDialog(WindowManager& parWindowManager) : + WindowBase("openmw_confirmation_dialog_layout.xml", parWindowManager) + { + getWidget(mMessage, "Message"); + getWidget(mOkButton, "OkButton"); + getWidget(mCancelButton, "CancelButton"); + + mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ConfirmationDialog::onCancelButtonClicked); + mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ConfirmationDialog::onOkButtonClicked); + } + + void ConfirmationDialog::open(const std::string& message) + { + setVisible(true); + + mMessage->setCaptionWithReplacing(message); + + int height = mMessage->getTextSize().height + 72; + + mMainWidget->setSize(mMainWidget->getWidth(), height); + + mMessage->setSize(mMessage->getWidth(), mMessage->getTextSize().height+24); + + center(); + + // make other gui elements inaccessible while this dialog is open + MyGUI::InputManager::getInstance().addWidgetModal(mMainWidget); + + int okButtonWidth = mOkButton->getTextSize().width + 24; + mOkButton->setCoord(mMainWidget->getWidth() - 30 - okButtonWidth, + mOkButton->getTop(), + okButtonWidth, + mOkButton->getHeight()); + + int cancelButtonWidth = mCancelButton->getTextSize().width + 24; + mCancelButton->setCoord(mMainWidget->getWidth() - 30 - okButtonWidth - cancelButtonWidth - 8, + mCancelButton->getTop(), + cancelButtonWidth, + mCancelButton->getHeight()); + } + + void ConfirmationDialog::onCancelButtonClicked(MyGUI::Widget* _sender) + { + close(); + } + + void ConfirmationDialog::onOkButtonClicked(MyGUI::Widget* _sender) + { + eventOkClicked(); + + close(); + } + + void ConfirmationDialog::close() + { + setVisible(false); + MyGUI::InputManager::getInstance().removeWidgetModal(mMainWidget); + } +} diff --git a/apps/openmw/mwgui/confirmationdialog.hpp b/apps/openmw/mwgui/confirmationdialog.hpp new file mode 100644 index 000000000..a20034171 --- /dev/null +++ b/apps/openmw/mwgui/confirmationdialog.hpp @@ -0,0 +1,34 @@ +#ifndef MWGUI_CONFIRMATIONDIALOG_H +#define MWGUI_CONFIRMATIONDIALOG_H + +#include "window_base.hpp" + +namespace MWGui +{ + class ConfirmationDialog : public WindowBase + { + public: + ConfirmationDialog(WindowManager& parWindowManager); + void open(const std::string& message); + + typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void; + + /** Event : Ok button was clicked.\n + signature : void method()\n + */ + EventHandle_Void eventOkClicked; + + private: + MyGUI::EditBox* mMessage; + MyGUI::Button* mOkButton; + MyGUI::Button* mCancelButton; + + void onCancelButtonClicked(MyGUI::Widget* _sender); + void onOkButtonClicked(MyGUI::Widget* _sender); + + void close(); + }; + +} + +#endif diff --git a/apps/openmw/mwgui/countdialog.cpp b/apps/openmw/mwgui/countdialog.cpp index 16e3f9aab..e0a9bb908 100644 --- a/apps/openmw/mwgui/countdialog.cpp +++ b/apps/openmw/mwgui/countdialog.cpp @@ -17,9 +17,6 @@ namespace MWGui getWidget(mOkButton, "OkButton"); getWidget(mCancelButton, "CancelButton"); - mOkButton->setCaption(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sOk")->str); - mCancelButton->setCaption(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sCancel")->str); - mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &CountDialog::onCancelButtonClicked); mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &CountDialog::onOkButtonClicked); mItemEdit->eventEditTextChange += MyGUI::newDelegate(this, &CountDialog::onEditTextChange); diff --git a/apps/openmw/mwgui/settingswindow.cpp b/apps/openmw/mwgui/settingswindow.cpp index af909ea8c..6eaf31ce9 100644 --- a/apps/openmw/mwgui/settingswindow.cpp +++ b/apps/openmw/mwgui/settingswindow.cpp @@ -2,6 +2,9 @@ #include #include +#include + +#include #include @@ -9,6 +12,7 @@ #include "../mwworld/world.hpp" #include "window_manager.hpp" +#include "confirmationdialog.hpp" namespace MWGui { @@ -19,10 +23,13 @@ namespace MWGui getWidget(mResolutionList, "ResolutionList"); getWidget(mMenuTransparencySlider, "MenuTransparencySlider"); getWidget(mViewDistanceSlider, "ViewDistanceSlider"); + getWidget(mFullscreenButton, "FullscreenButton"); mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onOkButtonClicked); + mFullscreenButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled); mMenuTransparencySlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition); mViewDistanceSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onSliderChangePosition); + mResolutionList->eventListChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onResolutionSelected); center(); @@ -42,7 +49,15 @@ namespace MWGui // read settings int menu_transparency = (mMenuTransparencySlider->getScrollRange()-1) * Settings::Manager::getFloat("menu transparency", "GUI"); mMenuTransparencySlider->setScrollPosition(menu_transparency); - onSliderChangePosition(mMenuTransparencySlider, menu_transparency); + + float val = (Settings::Manager::getFloat("max viewing distance", "Viewing distance")-2000)/(5600-2000); + int viewdist = (mViewDistanceSlider->getScrollRange()-1) * val; + mViewDistanceSlider->setScrollPosition(viewdist); + + std::string on = mWindowManager.getGameSettingString("sOn", "On"); + std::string off = mWindowManager.getGameSettingString("sOff", "On"); + + mFullscreenButton->setCaption(Settings::Manager::getBool("fullscreen", "Video") ? on : off); } void SettingsWindow::onOkButtonClicked(MyGUI::Widget* _sender) @@ -50,6 +65,54 @@ namespace MWGui mWindowManager.setGuiMode(GM_Game); } + void SettingsWindow::onResolutionSelected(MyGUI::ListBox* _sender, size_t index) + { + if (index == MyGUI::ITEM_NONE) + return; + + ConfirmationDialog* dialog = mWindowManager.getConfirmationDialog(); + dialog->open("#{sNotifyMessage67}"); + dialog->eventOkClicked.clear(); + dialog->eventOkClicked += MyGUI::newDelegate(this, &SettingsWindow::onResolutionAccept); + } + + void SettingsWindow::onResolutionAccept() + { + std::string resStr = mResolutionList->getItemNameAt(mResolutionList->getIndexSelected()); + size_t xPos = resStr.find("x"); + std::string resXStr = resStr.substr(0, xPos-1); + Ogre::StringUtil::trim(resXStr); + std::string resYStr = resStr.substr(xPos+2, resStr.size()-(xPos+2)); + Ogre::StringUtil::trim(resYStr); + int resX = boost::lexical_cast(resXStr); + int resY = boost::lexical_cast(resYStr); + + Settings::Manager::setInt("resolution x", "Video", resX); + Settings::Manager::setInt("resolution y", "Video", resY); + + MWBase::Environment::get().getWorld()->processChangedSettings(Settings::Manager::apply()); + } + + void SettingsWindow::onButtonToggled(MyGUI::Widget* _sender) + { + std::string on = mWindowManager.getGameSettingString("sOn", "On"); + std::string off = mWindowManager.getGameSettingString("sOff", "On"); + bool newState; + if (_sender->castType()->getCaption() == on) + { + _sender->castType()->setCaption(off); + newState = false; + } + else + { + _sender->castType()->setCaption(on); + newState = true; + } + + if (_sender == mFullscreenButton) + Settings::Manager::setBool("fullscreen", "Video", newState); + } + void SettingsWindow::onSliderChangePosition(MyGUI::ScrollBar* scroller, size_t pos) { float val = pos / float(scroller->getScrollRange()-1); @@ -57,6 +120,10 @@ namespace MWGui { Settings::Manager::setFloat("menu transparency", "GUI", val); } + else if (scroller == mViewDistanceSlider) + { + Settings::Manager::setFloat("max viewing distance", "Viewing distance", (1-val) * 2000 + val * 5600); + } MWBase::Environment::get().getWorld()->processChangedSettings(Settings::Manager::apply()); } diff --git a/apps/openmw/mwgui/settingswindow.hpp b/apps/openmw/mwgui/settingswindow.hpp index 597f8dec1..785b0c9b1 100644 --- a/apps/openmw/mwgui/settingswindow.hpp +++ b/apps/openmw/mwgui/settingswindow.hpp @@ -18,11 +18,15 @@ namespace MWGui protected: MyGUI::Button* mOkButton; MyGUI::ListBox* mResolutionList; + MyGUI::Button* mFullscreenButton; MyGUI::ScrollBar* mMenuTransparencySlider; MyGUI::ScrollBar* mViewDistanceSlider; void onOkButtonClicked(MyGUI::Widget* _sender); void onSliderChangePosition(MyGUI::ScrollBar* scroller, size_t pos); + void onButtonToggled(MyGUI::Widget* _sender); + void onResolutionSelected(MyGUI::ListBox* _sender, size_t index); + void onResolutionAccept(); }; } diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 4bb34cf24..09ea6543a 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -17,6 +17,7 @@ #include "countdialog.hpp" #include "tradewindow.hpp" #include "settingswindow.hpp" +#include "confirmationdialog.hpp" #include "../mwmechanics/mechanicsmanager.hpp" #include "../mwinput/inputmanager.hpp" @@ -52,6 +53,7 @@ WindowManager::WindowManager( , mCountDialog(NULL) , mTradeWindow(NULL) , mSettingsWindow(NULL) + , mConfirmationDialog(NULL) , mCharGen(NULL) , playerClass() , playerName() @@ -121,6 +123,7 @@ WindowManager::WindowManager( mBookWindow = new BookWindow(*this); mCountDialog = new CountDialog(*this); mSettingsWindow = new SettingsWindow(*this); + mConfirmationDialog = new ConfirmationDialog(*this); // The HUD is always on hud->setVisible(true); @@ -161,6 +164,8 @@ WindowManager::~WindowManager() delete mBookWindow; delete mScrollWindow; delete mTradeWindow; + delete mSettingsWindow; + delete mConfirmationDialog; cleanupGarbage(); } diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index aab307035..9ccc42b1e 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -78,6 +78,7 @@ namespace MWGui class CountDialog; class TradeWindow; class SettingsWindow; + class ConfirmationDialog; struct ClassPoint { @@ -140,6 +141,7 @@ namespace MWGui MWGui::BookWindow* getBookWindow() {return mBookWindow;} MWGui::ScrollWindow* getScrollWindow() {return mScrollWindow;} MWGui::CountDialog* getCountDialog() {return mCountDialog;} + MWGui::ConfirmationDialog* getConfirmationDialog() {return mConfirmationDialog;} MWGui::TradeWindow* getTradeWindow() {return mTradeWindow;} MyGUI::Gui* getGui() const { return gui; } @@ -232,6 +234,7 @@ namespace MWGui CountDialog* mCountDialog; TradeWindow* mTradeWindow; SettingsWindow* mSettingsWindow; + ConfirmationDialog* mConfirmationDialog; CharacterCreation* mCharGen; diff --git a/components/settings/settings.cpp b/components/settings/settings.cpp index 28201eda2..9b941e253 100644 --- a/components/settings/settings.cpp +++ b/components/settings/settings.cpp @@ -131,7 +131,11 @@ void Manager::setString (const std::string& setting, const std::string& category } } else + { + if (mDefaultFile.getSetting(setting, category) != value) + mChangedSettings.push_back(std::make_pair(category, setting)); mNewSettings[s] = value; + } } } diff --git a/files/mygui/CMakeLists.txt b/files/mygui/CMakeLists.txt index 90a0c1fce..89ebd8f94 100644 --- a/files/mygui/CMakeLists.txt +++ b/files/mygui/CMakeLists.txt @@ -58,6 +58,7 @@ configure_file("${SDIR}/openmw_book_layout.xml" "${DDIR}/openmw_book_layout.xml" configure_file("${SDIR}/openmw_count_window_layout.xml" "${DDIR}/openmw_count_window_layout.xml" COPYONLY) configure_file("${SDIR}/openmw_trade_window_layout.xml" "${DDIR}/openmw_trade_window_layout.xml" COPYONLY) configure_file("${SDIR}/openmw_settings_window_layout.xml" "${DDIR}/openmw_settings_window_layout.xml" COPYONLY) +configure_file("${SDIR}/openmw_confirmation_dialog_layout.xml" "${DDIR}/openmw_confirmation_dialog_layout.xml" COPYONLY) configure_file("${SDIR}/atlas1.cfg" "${DDIR}/atlas1.cfg" COPYONLY) configure_file("${SDIR}/smallbars.png" "${DDIR}/smallbars.png" COPYONLY) configure_file("${SDIR}/EBGaramond-Regular.ttf" "${DDIR}/EBGaramond-Regular.ttf" COPYONLY) diff --git a/files/mygui/openmw_confirmation_dialog_layout.xml b/files/mygui/openmw_confirmation_dialog_layout.xml new file mode 100644 index 000000000..7b8bd2a1f --- /dev/null +++ b/files/mygui/openmw_confirmation_dialog_layout.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/files/mygui/openmw_count_window_layout.xml b/files/mygui/openmw_count_window_layout.xml index 38ba7644f..ae6635dff 100644 --- a/files/mygui/openmw_count_window_layout.xml +++ b/files/mygui/openmw_count_window_layout.xml @@ -20,8 +20,12 @@ - - + + + + + + diff --git a/files/mygui/openmw_settings_window_layout.xml b/files/mygui/openmw_settings_window_layout.xml index 9c6716ff0..2fa332d9a 100644 --- a/files/mygui/openmw_settings_window_layout.xml +++ b/files/mygui/openmw_settings_window_layout.xml @@ -34,9 +34,10 @@ - - + + +