From 313294c52297753aed1c168d61b553dc7d5615ef Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 22 May 2012 21:40:42 +0200 Subject: [PATCH] settings window (hotkey F2) which does nothing. Yay! --- apps/openmw/CMakeLists.txt | 2 +- apps/openmw/mwgui/mode.hpp | 1 + apps/openmw/mwgui/settingswindow.cpp | 25 ++++++++++++++++++ apps/openmw/mwgui/settingswindow.hpp | 26 +++++++++++++++++++ apps/openmw/mwgui/window_manager.cpp | 9 ++++++- apps/openmw/mwgui/window_manager.hpp | 2 ++ apps/openmw/mwinput/inputmanager.cpp | 15 +++++++++++ files/mygui/CMakeLists.txt | 1 + files/mygui/openmw_settings_window_layout.xml | 14 ++++++++++ 9 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 apps/openmw/mwgui/settingswindow.cpp create mode 100644 apps/openmw/mwgui/settingswindow.hpp create mode 100644 files/mygui/openmw_settings_window_layout.xml diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index c08c91c02..fd2fdf575 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -27,7 +27,7 @@ add_openmw_dir (mwgui text_input widgets race class birth review window_manager console dialogue 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 + formatting itemwidget inventorywindow container hud countdialog tradewindow settingswindow ) add_openmw_dir (mwdialogue diff --git a/apps/openmw/mwgui/mode.hpp b/apps/openmw/mwgui/mode.hpp index 775fe4a03..ad54ed1df 100644 --- a/apps/openmw/mwgui/mode.hpp +++ b/apps/openmw/mwgui/mode.hpp @@ -6,6 +6,7 @@ namespace MWGui enum GuiMode { GM_Game, // Game mode, only HUD + GM_Settings, // Settings window GM_Inventory, // Inventory mode GM_Container, GM_MainMenu, // Main menu mode diff --git a/apps/openmw/mwgui/settingswindow.cpp b/apps/openmw/mwgui/settingswindow.cpp new file mode 100644 index 000000000..3641a63a4 --- /dev/null +++ b/apps/openmw/mwgui/settingswindow.cpp @@ -0,0 +1,25 @@ +#include "settingswindow.hpp" + +#include "window_manager.hpp" + +namespace MWGui +{ + SettingsWindow::SettingsWindow(WindowManager& parWindowManager) : + WindowBase("openmw_settings_window_layout.xml", parWindowManager) + { + getWidget(mOkButton, "OkButton"); + + mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onOkButtonClicked); + + center(); + + int okSize = mOkButton->getTextSize().width + 24; + mOkButton->setCoord(mMainWidget->getWidth()-16-okSize, mOkButton->getTop(), + okSize, mOkButton->getHeight()); + } + + void SettingsWindow::onOkButtonClicked(MyGUI::Widget* _sender) + { + mWindowManager.setGuiMode(GM_Game); + } +} diff --git a/apps/openmw/mwgui/settingswindow.hpp b/apps/openmw/mwgui/settingswindow.hpp new file mode 100644 index 000000000..e37c00f7e --- /dev/null +++ b/apps/openmw/mwgui/settingswindow.hpp @@ -0,0 +1,26 @@ +#ifndef MWGUI_SETTINGS_H +#define MWGUI_SETTINGS_H + +#include "window_base.hpp" + +namespace MWGui +{ + class WindowManager; +} + +namespace MWGui +{ + class SettingsWindow : public WindowBase + { + public: + SettingsWindow(WindowManager& parWindowManager); + + protected: + MyGUI::Button* mOkButton; + + void onOkButtonClicked(MyGUI::Widget* _sender); + }; +} + +#endif + diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 2cacf2346..4bb34cf24 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -16,6 +16,7 @@ #include "mainmenu.hpp" #include "countdialog.hpp" #include "tradewindow.hpp" +#include "settingswindow.hpp" #include "../mwmechanics/mechanicsmanager.hpp" #include "../mwinput/inputmanager.hpp" @@ -45,11 +46,12 @@ WindowManager::WindowManager( , mMessageBoxManager(NULL) , console(NULL) , mJournal(NULL) - , mDialogueWindow(nullptr) + , mDialogueWindow(NULL) , mBookWindow(NULL) , mScrollWindow(NULL) , mCountDialog(NULL) , mTradeWindow(NULL) + , mSettingsWindow(NULL) , mCharGen(NULL) , playerClass() , playerName() @@ -118,6 +120,7 @@ WindowManager::WindowManager( mScrollWindow = new ScrollWindow(*this); mBookWindow = new BookWindow(*this); mCountDialog = new CountDialog(*this); + mSettingsWindow = new SettingsWindow(*this); // The HUD is always on hud->setVisible(true); @@ -217,6 +220,7 @@ void WindowManager::updateVisible() mScrollWindow->setVisible(false); mBookWindow->setVisible(false); mTradeWindow->setVisible(false); + mSettingsWindow->setVisible(false); // Mouse is visible whenever we're not in game mode MyGUI::PointerManager::getInstance().setVisible(isGuiMode()); @@ -233,6 +237,9 @@ void WindowManager::updateVisible() case GM_MainMenu: menu->setVisible(true); break; + case GM_Settings: + mSettingsWindow->setVisible(true); + break; case GM_Console: console->enable(); break; diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index 22fe973a5..aab307035 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -77,6 +77,7 @@ namespace MWGui class MessageBoxManager; class CountDialog; class TradeWindow; + class SettingsWindow; struct ClassPoint { @@ -230,6 +231,7 @@ namespace MWGui BookWindow* mBookWindow; CountDialog* mCountDialog; TradeWindow* mTradeWindow; + SettingsWindow* mSettingsWindow; CharacterCreation* mCharGen; diff --git a/apps/openmw/mwinput/inputmanager.cpp b/apps/openmw/mwinput/inputmanager.cpp index 8f8f1e1ee..8fd6a9c6b 100644 --- a/apps/openmw/mwinput/inputmanager.cpp +++ b/apps/openmw/mwinput/inputmanager.cpp @@ -71,6 +71,8 @@ namespace MWInput A_ToggleFps, // Toggle FPS display (this is temporary) + A_Settings, // Temporary hotkey + A_LAST // Marker for the last item }; @@ -140,6 +142,16 @@ namespace MWInput windows.messageBox ("Screenshot saved", empty); } + void showSettings() + { + if (mDragDrop) + return; + + MWGui::GuiMode mode = windows.getMode(); + if (mode != MWGui::GM_Settings) + setGuiMode(MWGui::GM_Settings); + } + /* toggleInventory() is called when the user presses the button to toggle the inventory screen. */ void toggleInventory() { @@ -261,6 +273,8 @@ namespace MWInput "Ready hands"); disp->funcs.bind(A_ToggleFps, boost::bind(&InputImpl::toggleFps, this), "Toggle FPS display"); + disp->funcs.bind(A_Settings, boost::bind(&InputImpl::showSettings, this), + "Show settings window"); // Add the exit listener ogre.getRoot()->addFrameListener(&exit); @@ -308,6 +322,7 @@ namespace MWInput disp->bind(A_ToggleWeapon,KC_F); disp->bind(A_ToggleSpell,KC_R); disp->bind(A_ToggleFps, KC_F10); + disp->bind(A_Settings, KC_F2); // Key bindings for polled keys // NOTE: These keys are constantly being polled. Only add keys that must be checked each frame. diff --git a/files/mygui/CMakeLists.txt b/files/mygui/CMakeLists.txt index cacfb7c5a..9f43f2d89 100644 --- a/files/mygui/CMakeLists.txt +++ b/files/mygui/CMakeLists.txt @@ -57,6 +57,7 @@ configure_file("${SDIR}/openmw_scroll_skin.xml" "${DDIR}/openmw_scroll_skin.xml" configure_file("${SDIR}/openmw_book_layout.xml" "${DDIR}/openmw_book_layout.xml" COPYONLY) 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}/atlas1.cfg" "${DDIR}/atlas1.cfg" COPYONLY) configure_file("${SDIR}/smallbars.png" "${DDIR}/smallbars.png" COPYONLY) configure_file("${SDIR}/transparent.png" "${DDIR}/transparent.png" COPYONLY) diff --git a/files/mygui/openmw_settings_window_layout.xml b/files/mygui/openmw_settings_window_layout.xml new file mode 100644 index 000000000..eaf9191bc --- /dev/null +++ b/files/mygui/openmw_settings_window_layout.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + +