ConfirmationDialog

actorid
scrawl 13 years ago
parent 656a8f1be9
commit 689cf7ce05

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

@ -0,0 +1,68 @@
#include "confirmationdialog.hpp"
#include <boost/lexical_cast.hpp>
#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);
}
}

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

@ -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);

@ -2,6 +2,9 @@
#include <OgreRoot.h>
#include <OgreRenderSystem.h>
#include <OgreString.h>
#include <boost/lexical_cast.hpp>
#include <components/settings/settings.hpp>
@ -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<int>(resXStr);
int resY = boost::lexical_cast<int>(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<MyGUI::Button>()->getCaption() == on)
{
_sender->castType<MyGUI::Button>()->setCaption(off);
newState = false;
}
else
{
_sender->castType<MyGUI::Button>()->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());
}

@ -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();
};
}

@ -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();
}

@ -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;

@ -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;
}
}
}

@ -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)

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Layout">
<Widget type="Window" skin="MW_Dialog" layer="Windows" position="0 0 300 125" name="_Main">
<Property key="Visible" value="false"/>
<Widget type="EditBox" skin="MW_TextEditClient" position="8 8 284 400" name="Message" align="Left Top Stretch">
<Property key="FontName" value = "Default" />
<Property key="TextAlign" value="Top HCenter" />
<Property key="TextColour" value = "0.75 0.6 0.35" />
<Property key="Static" value="true"/>
<Property key="WordWrap" value="true"/>
<Property key="MultiLine" value="true" />
</Widget>
<Widget type="Button" skin="MW_Button" position="212 84 60 24" name="OkButton" align="Right Bottom">
<Property key="Caption" value="#{sOk}"/>
</Widget>
<Widget type="Button" skin="MW_Button" position="117 84 60 24" name="CancelButton" align="Right Bottom">
<Property key="Caption" value="#{sCancel}"/>
</Widget>
</Widget>
</MyGUI>

@ -20,8 +20,12 @@
<Property key="MoveToClick" value="true"/>
</Widget>
<Widget type="Button" skin="MW_Button" position="512 90 60 24" name="OkButton" align="Right Top"/>
<Widget type="Button" skin="MW_Button" position="417 90 60 24" name="CancelButton" align="Right Top"/>
<Widget type="Button" skin="MW_Button" position="512 90 60 24" name="OkButton" align="Right Top">
<Property key="Caption" value="#{sOk}"/>
</Widget>
<Widget type="Button" skin="MW_Button" position="417 90 60 24" name="CancelButton" align="Right Top">
<Property key="Caption" value="#{sCancel}"/>
</Widget>
</Widget>
</MyGUI>

@ -34,9 +34,10 @@
<Property key="Caption" value=" #{sVideo} "/>
<Widget type="ListBox" skin="MW_List" position="4 4 200 110" align="Left Top" name="ResolutionList"/>
<Widget type="Button" skin="MW_Button" position="212 4 120 24" align="Left Top" name="ApplyResolutionButton">
<Property key="Caption" value="Apply"/>
<Widget type="TextBox" skin="SandText" position="252 4 120 24" align="Left Top">
<Property key="Caption" value="Fullscreen"/>
</Widget>
<Widget type="Button" skin="MW_Button" position="212 4 34 24" align="Left Top" name="FullscreenButton"/>
<Widget type="TextBox" skin="NormalText" position="4 130 352 18" align="Left Top">
<Property key="Caption" value="#{sRender_Distance}"/>

Loading…
Cancel
Save