1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-04 07:45:34 +00:00

Decrease number of classes that need to know about other components

This commit is contained in:
Jan-Peter Nilsson 2011-02-21 20:36:35 +01:00
parent 67b4243a7f
commit 54fc64cb6a
23 changed files with 192 additions and 248 deletions

View file

@ -1,6 +1,4 @@
#include "birth.hpp" #include "birth.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include "window_manager.hpp" #include "window_manager.hpp"
#include "widgets.hpp" #include "widgets.hpp"
#include "components/esm_store/store.hpp" #include "components/esm_store/store.hpp"
@ -11,8 +9,8 @@
using namespace MWGui; using namespace MWGui;
using namespace Widgets; using namespace Widgets;
BirthDialog::BirthDialog(MWWorld::Environment& environment) BirthDialog::BirthDialog(WindowManager& parWindowManager)
: WindowBase("openmw_chargen_birth_layout.xml", environment) : WindowBase("openmw_chargen_birth_layout.xml", parWindowManager)
{ {
// Centre dialog // Centre dialog
center(); center();
@ -121,7 +119,7 @@ void BirthDialog::updateBirths()
{ {
birthList->removeAllItems(); birthList->removeAllItems();
ESMS::ESMStore &store = environment.mWorld->getStore(); ESMS::ESMStore &store = mWindowManager.getStore();
ESMS::RecListT<ESM::BirthSign>::MapType::const_iterator it = store.birthSigns.list.begin(); ESMS::RecListT<ESM::BirthSign>::MapType::const_iterator it = store.birthSigns.list.begin();
ESMS::RecListT<ESM::BirthSign>::MapType::const_iterator end = store.birthSigns.list.end(); ESMS::RecListT<ESM::BirthSign>::MapType::const_iterator end = store.birthSigns.list.end();
@ -151,7 +149,7 @@ void BirthDialog::updateSpells()
const int lineHeight = 18; const int lineHeight = 18;
MyGUI::IntCoord coord(0, 0, spellArea->getWidth(), 18); MyGUI::IntCoord coord(0, 0, spellArea->getWidth(), 18);
ESMS::ESMStore &store = environment.mWorld->getStore(); ESMS::ESMStore &store = mWindowManager.getStore();
const ESM::BirthSign *birth = store.birthSigns.find(currentBirthId); const ESM::BirthSign *birth = store.birthSigns.find(currentBirthId);
std::string texturePath = std::string("textures\\") + birth->texture; std::string texturePath = std::string("textures\\") + birth->texture;
@ -191,7 +189,7 @@ void BirthDialog::updateSpells()
if (!categories[category].spells.empty()) if (!categories[category].spells.empty())
{ {
MyGUI::StaticTextPtr label = spellArea->createWidget<MyGUI::StaticText>("SandBrightText", coord, MyGUI::Align::Default, std::string("Label")); MyGUI::StaticTextPtr label = spellArea->createWidget<MyGUI::StaticText>("SandBrightText", coord, MyGUI::Align::Default, std::string("Label"));
label->setCaption(environment.mWindowManager->getGameSettingString(categories[category].label, "")); label->setCaption(mWindowManager.getGameSettingString(categories[category].label, ""));
spellItems.push_back(label); spellItems.push_back(label);
coord.top += lineHeight; coord.top += lineHeight;
@ -200,7 +198,7 @@ void BirthDialog::updateSpells()
{ {
const std::string &spellId = *it; const std::string &spellId = *it;
spellWidget = spellArea->createWidget<MWSpell>("MW_StatName", coord, MyGUI::Align::Default, std::string("Spell") + boost::lexical_cast<std::string>(i)); spellWidget = spellArea->createWidget<MWSpell>("MW_StatName", coord, MyGUI::Align::Default, std::string("Spell") + boost::lexical_cast<std::string>(i));
spellWidget->setEnvironment(&environment); spellWidget->setWindowManager(&mWindowManager);
spellWidget->setSpellId(spellId); spellWidget->setSpellId(spellId);
spellItems.push_back(spellWidget); spellItems.push_back(spellWidget);

View file

@ -3,11 +3,6 @@
#include "window_base.hpp" #include "window_base.hpp"
namespace MWWorld
{
class Environment;
}
/* /*
This file contains the dialog for choosing a birth sign. This file contains the dialog for choosing a birth sign.
Layout is defined by resources/mygui/openmw_chargen_race_layout.xml. Layout is defined by resources/mygui/openmw_chargen_race_layout.xml.
@ -17,10 +12,12 @@ namespace MWGui
{ {
using namespace MyGUI; using namespace MyGUI;
class WindowManager;
class BirthDialog : public WindowBase class BirthDialog : public WindowBase
{ {
public: public:
BirthDialog(MWWorld::Environment& environment); BirthDialog(WindowManager& parWindowManager);
enum Gender enum Gender
{ {

View file

@ -1,6 +1,4 @@
#include "class.hpp" #include "class.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include "window_manager.hpp" #include "window_manager.hpp"
#include "components/esm_store/store.hpp" #include "components/esm_store/store.hpp"
@ -14,14 +12,13 @@ using namespace MWGui;
/* GenerateClassResultDialog */ /* GenerateClassResultDialog */
GenerateClassResultDialog::GenerateClassResultDialog(MWWorld::Environment& environment) GenerateClassResultDialog::GenerateClassResultDialog(WindowManager& parWindowManager)
: WindowBase("openmw_chargen_generate_class_result_layout.xml", environment) : WindowBase("openmw_chargen_generate_class_result_layout.xml", parWindowManager)
{ {
// Centre dialog // Centre dialog
center(); center();
WindowManager *wm = environment.mWindowManager; setText("ReflectT", mWindowManager.getGameSettingString("sMessageQuestionAnswer1", ""));
setText("ReflectT", wm->getGameSettingString("sMessageQuestionAnswer1", ""));
getWidget(classImage, "ClassImage"); getWidget(classImage, "ClassImage");
getWidget(className, "ClassName"); getWidget(className, "ClassName");
@ -50,7 +47,7 @@ void GenerateClassResultDialog::setClassId(const std::string &classId)
{ {
currentClassId = classId; currentClassId = classId;
classImage->setImageTexture(std::string("textures\\levelup\\") + currentClassId + ".dds"); classImage->setImageTexture(std::string("textures\\levelup\\") + currentClassId + ".dds");
ESMS::ESMStore &store = environment.mWorld->getStore(); ESMS::ESMStore &store = mWindowManager.getStore();
className->setCaption(store.classes.find(currentClassId)->name); className->setCaption(store.classes.find(currentClassId)->name);
} }
@ -68,31 +65,30 @@ void GenerateClassResultDialog::onBackClicked(MyGUI::Widget* _sender)
/* PickClassDialog */ /* PickClassDialog */
PickClassDialog::PickClassDialog(MWWorld::Environment& environment) PickClassDialog::PickClassDialog(WindowManager& parWindowManager)
: WindowBase("openmw_chargen_class_layout.xml", environment) : WindowBase("openmw_chargen_class_layout.xml", parWindowManager)
{ {
// Centre dialog // Centre dialog
center(); center();
WindowManager *wm = environment.mWindowManager; setText("SpecializationT", mWindowManager.getGameSettingString("sChooseClassMenu1", "Specialization"));
setText("SpecializationT", wm->getGameSettingString("sChooseClassMenu1", "Specialization"));
getWidget(specializationName, "SpecializationName"); getWidget(specializationName, "SpecializationName");
setText("FavoriteAttributesT", wm->getGameSettingString("sChooseClassMenu2", "Favorite Attributes:")); setText("FavoriteAttributesT", mWindowManager.getGameSettingString("sChooseClassMenu2", "Favorite Attributes:"));
getWidget(favoriteAttribute[0], "FavoriteAttribute0"); getWidget(favoriteAttribute[0], "FavoriteAttribute0");
getWidget(favoriteAttribute[1], "FavoriteAttribute1"); getWidget(favoriteAttribute[1], "FavoriteAttribute1");
favoriteAttribute[0]->setWindowManager(wm); favoriteAttribute[0]->setWindowManager(&mWindowManager);
favoriteAttribute[1]->setWindowManager(wm); favoriteAttribute[1]->setWindowManager(&mWindowManager);
setText("MajorSkillT", wm->getGameSettingString("sChooseClassMenu3", "Major Skills:")); setText("MajorSkillT", mWindowManager.getGameSettingString("sChooseClassMenu3", "Major Skills:"));
setText("MinorSkillT", wm->getGameSettingString("sChooseClassMenu4", "Minor Skills:")); setText("MinorSkillT", mWindowManager.getGameSettingString("sChooseClassMenu4", "Minor Skills:"));
for(int i = 0; i < 5; i++) for(int i = 0; i < 5; i++)
{ {
char theIndex = '0'+i; char theIndex = '0'+i;
getWidget(majorSkill[i], std::string("MajorSkill").append(1, theIndex)); getWidget(majorSkill[i], std::string("MajorSkill").append(1, theIndex));
getWidget(minorSkill[i], std::string("MinorSkill").append(1, theIndex)); getWidget(minorSkill[i], std::string("MinorSkill").append(1, theIndex));
majorSkill[i]->setWindowManager(wm); majorSkill[i]->setWindowManager(&mWindowManager);
minorSkill[i]->setWindowManager(wm); minorSkill[i]->setWindowManager(&mWindowManager);
} }
getWidget(classList, "ClassList"); getWidget(classList, "ClassList");
@ -197,7 +193,7 @@ void PickClassDialog::updateClasses()
{ {
classList->removeAllItems(); classList->removeAllItems();
ESMS::ESMStore &store = environment.mWorld->getStore(); ESMS::ESMStore &store = mWindowManager.getStore();
ESMS::RecListT<ESM::Class>::MapType::const_iterator it = store.classes.list.begin(); ESMS::RecListT<ESM::Class>::MapType::const_iterator it = store.classes.list.begin();
ESMS::RecListT<ESM::Class>::MapType::const_iterator end = store.classes.list.end(); ESMS::RecListT<ESM::Class>::MapType::const_iterator end = store.classes.list.end();
@ -221,8 +217,7 @@ void PickClassDialog::updateStats()
{ {
if (currentClassId.empty()) if (currentClassId.empty())
return; return;
WindowManager *wm = environment.mWindowManager; ESMS::ESMStore &store = mWindowManager.getStore();
ESMS::ESMStore &store = environment.mWorld->getStore();
const ESM::Class *klass = store.classes.search(currentClassId); const ESM::Class *klass = store.classes.search(currentClassId);
if (!klass) if (!klass)
return; return;
@ -234,7 +229,7 @@ void PickClassDialog::updateStats()
"sSpecializationMagic", "sSpecializationMagic",
"sSpecializationStealth" "sSpecializationStealth"
}; };
specializationName->setCaption(wm->getGameSettingString(specIds[specialization], specIds[specialization])); specializationName->setCaption(mWindowManager.getGameSettingString(specIds[specialization], specIds[specialization]));
favoriteAttribute[0]->setAttributeId(klass->data.attribute[0]); favoriteAttribute[0]->setAttributeId(klass->data.attribute[0]);
favoriteAttribute[1]->setAttributeId(klass->data.attribute[1]); favoriteAttribute[1]->setAttributeId(klass->data.attribute[1]);
@ -280,8 +275,8 @@ void InfoBoxDialog::layoutVertically(MyGUI::WidgetPtr widget, int margin)
widget->setSize(width, pos); widget->setSize(width, pos);
} }
InfoBoxDialog::InfoBoxDialog(MWWorld::Environment& environment) InfoBoxDialog::InfoBoxDialog(WindowManager& parWindowManager)
: WindowBase("openmw_infobox_layout.xml", environment) : WindowBase("openmw_infobox_layout.xml", parWindowManager)
, currentButton(-1) , currentButton(-1)
{ {
getWidget(textBox, "TextBox"); getWidget(textBox, "TextBox");
@ -364,23 +359,22 @@ void InfoBoxDialog::onButtonClicked(MyGUI::WidgetPtr _sender)
/* ClassChoiceDialog */ /* ClassChoiceDialog */
ClassChoiceDialog::ClassChoiceDialog(MWWorld::Environment& environment) ClassChoiceDialog::ClassChoiceDialog(WindowManager& parWindowManager)
: InfoBoxDialog(environment) : InfoBoxDialog(parWindowManager)
{ {
WindowManager *mw = environment.mWindowManager;
setText(""); setText("");
ButtonList buttons; ButtonList buttons;
buttons.push_back(mw->getGameSettingString("sClassChoiceMenu1", "")); buttons.push_back(mWindowManager.getGameSettingString("sClassChoiceMenu1", ""));
buttons.push_back(mw->getGameSettingString("sClassChoiceMenu2", "")); buttons.push_back(mWindowManager.getGameSettingString("sClassChoiceMenu2", ""));
buttons.push_back(mw->getGameSettingString("sClassChoiceMenu3", "")); buttons.push_back(mWindowManager.getGameSettingString("sClassChoiceMenu3", ""));
buttons.push_back(mw->getGameSettingString("sBack", "")); buttons.push_back(mWindowManager.getGameSettingString("sBack", ""));
setButtons(buttons); setButtons(buttons);
} }
/* CreateClassDialog */ /* CreateClassDialog */
CreateClassDialog::CreateClassDialog(MWWorld::Environment& environment) CreateClassDialog::CreateClassDialog(WindowManager& parWindowManager)
: WindowBase("openmw_chargen_create_class_layout.xml", environment) : WindowBase("openmw_chargen_create_class_layout.xml", parWindowManager)
, specDialog(nullptr) , specDialog(nullptr)
, attribDialog(nullptr) , attribDialog(nullptr)
, skillDialog(nullptr) , skillDialog(nullptr)
@ -389,22 +383,21 @@ CreateClassDialog::CreateClassDialog(MWWorld::Environment& environment)
// Centre dialog // Centre dialog
center(); center();
WindowManager *wm = environment.mWindowManager; setText("SpecializationT", mWindowManager.getGameSettingString("sChooseClassMenu1", "Specialization"));
setText("SpecializationT", wm->getGameSettingString("sChooseClassMenu1", "Specialization"));
getWidget(specializationName, "SpecializationName"); getWidget(specializationName, "SpecializationName");
specializationName->setCaption(wm->getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Combat], "")); specializationName->setCaption(mWindowManager.getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Combat], ""));
specializationName->eventMouseButtonClick = MyGUI::newDelegate(this, &CreateClassDialog::onSpecializationClicked); specializationName->eventMouseButtonClick = MyGUI::newDelegate(this, &CreateClassDialog::onSpecializationClicked);
setText("FavoriteAttributesT", wm->getGameSettingString("sChooseClassMenu2", "Favorite Attributes:")); setText("FavoriteAttributesT", mWindowManager.getGameSettingString("sChooseClassMenu2", "Favorite Attributes:"));
getWidget(favoriteAttribute0, "FavoriteAttribute0"); getWidget(favoriteAttribute0, "FavoriteAttribute0");
getWidget(favoriteAttribute1, "FavoriteAttribute1"); getWidget(favoriteAttribute1, "FavoriteAttribute1");
favoriteAttribute0->setWindowManager(wm); favoriteAttribute0->setWindowManager(&mWindowManager);
favoriteAttribute1->setWindowManager(wm); favoriteAttribute1->setWindowManager(&mWindowManager);
favoriteAttribute0->eventClicked = MyGUI::newDelegate(this, &CreateClassDialog::onAttributeClicked); favoriteAttribute0->eventClicked = MyGUI::newDelegate(this, &CreateClassDialog::onAttributeClicked);
favoriteAttribute1->eventClicked = MyGUI::newDelegate(this, &CreateClassDialog::onAttributeClicked); favoriteAttribute1->eventClicked = MyGUI::newDelegate(this, &CreateClassDialog::onAttributeClicked);
setText("MajorSkillT", wm->getGameSettingString("sSkillClassMajor", "")); setText("MajorSkillT", mWindowManager.getGameSettingString("sSkillClassMajor", ""));
setText("MinorSkillT", wm->getGameSettingString("sSkillClassMinor", "")); setText("MinorSkillT", mWindowManager.getGameSettingString("sSkillClassMinor", ""));
for(int i = 0; i < 5; i++) for(int i = 0; i < 5; i++)
{ {
char theIndex = '0'+i; char theIndex = '0'+i;
@ -417,11 +410,11 @@ CreateClassDialog::CreateClassDialog(MWWorld::Environment& environment)
std::vector<Widgets::MWSkillPtr>::const_iterator end = skills.end(); std::vector<Widgets::MWSkillPtr>::const_iterator end = skills.end();
for (std::vector<Widgets::MWSkillPtr>::const_iterator it = skills.begin(); it != end; ++it) for (std::vector<Widgets::MWSkillPtr>::const_iterator it = skills.begin(); it != end; ++it)
{ {
(*it)->setWindowManager(wm); (*it)->setWindowManager(&mWindowManager);
(*it)->eventClicked = MyGUI::newDelegate(this, &CreateClassDialog::onSkillClicked); (*it)->eventClicked = MyGUI::newDelegate(this, &CreateClassDialog::onSkillClicked);
} }
setText("LabelT", wm->getGameSettingString("sName", "")); setText("LabelT", mWindowManager.getGameSettingString("sName", ""));
getWidget(editName, "EditName"); getWidget(editName, "EditName");
// Make sure the edit box has focus // Make sure the edit box has focus
@ -563,7 +556,7 @@ void CreateClassDialog::onSpecializationClicked(MyGUI::WidgetPtr _sender)
{ {
if (specDialog) if (specDialog)
delete specDialog; delete specDialog;
specDialog = new SelectSpecializationDialog(environment, environment.mWindowManager->getGui()->getViewSize()); specDialog = new SelectSpecializationDialog(mWindowManager);
specDialog->eventCancel = MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel); specDialog->eventCancel = MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel);
specDialog->eventItemSelected = MyGUI::newDelegate(this, &CreateClassDialog::onSpecializationSelected); specDialog->eventItemSelected = MyGUI::newDelegate(this, &CreateClassDialog::onSpecializationSelected);
specDialog->setVisible(true); specDialog->setVisible(true);
@ -572,7 +565,7 @@ void CreateClassDialog::onSpecializationClicked(MyGUI::WidgetPtr _sender)
void CreateClassDialog::onSpecializationSelected() void CreateClassDialog::onSpecializationSelected()
{ {
specializationId = specDialog->getSpecializationId(); specializationId = specDialog->getSpecializationId();
specializationName->setCaption(environment.mWindowManager->getGameSettingString(ESM::Class::gmstSpecializationIds[specializationId], "")); specializationName->setCaption(mWindowManager.getGameSettingString(ESM::Class::gmstSpecializationIds[specializationId], ""));
specDialog->setVisible(false); specDialog->setVisible(false);
} }
@ -580,7 +573,7 @@ void CreateClassDialog::onAttributeClicked(Widgets::MWAttributePtr _sender)
{ {
if (attribDialog) if (attribDialog)
delete attribDialog; delete attribDialog;
attribDialog = new SelectAttributeDialog(environment, environment.mWindowManager->getGui()->getViewSize()); attribDialog = new SelectAttributeDialog(mWindowManager);
attribDialog->setAffectedWidget(_sender); attribDialog->setAffectedWidget(_sender);
attribDialog->eventCancel = MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel); attribDialog->eventCancel = MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel);
attribDialog->eventItemSelected = MyGUI::newDelegate(this, &CreateClassDialog::onAttributeSelected); attribDialog->eventItemSelected = MyGUI::newDelegate(this, &CreateClassDialog::onAttributeSelected);
@ -609,7 +602,7 @@ void CreateClassDialog::onSkillClicked(Widgets::MWSkillPtr _sender)
{ {
if (skillDialog) if (skillDialog)
delete skillDialog; delete skillDialog;
skillDialog = new SelectSkillDialog(environment, environment.mWindowManager->getGui()->getViewSize()); skillDialog = new SelectSkillDialog(mWindowManager);
skillDialog->setAffectedWidget(_sender); skillDialog->setAffectedWidget(_sender);
skillDialog->eventCancel = MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel); skillDialog->eventCancel = MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel);
skillDialog->eventItemSelected = MyGUI::newDelegate(this, &CreateClassDialog::onSkillSelected); skillDialog->eventItemSelected = MyGUI::newDelegate(this, &CreateClassDialog::onSkillSelected);
@ -640,7 +633,7 @@ void CreateClassDialog::onSkillSelected()
void CreateClassDialog::onDescriptionClicked(MyGUI::Widget* _sender) void CreateClassDialog::onDescriptionClicked(MyGUI::Widget* _sender)
{ {
descDialog = new DescriptionDialog(environment, environment.mWindowManager->getGui()->getViewSize()); descDialog = new DescriptionDialog(mWindowManager);
descDialog->setTextInput(description); descDialog->setTextInput(description);
descDialog->eventDone = MyGUI::newDelegate(this, &CreateClassDialog::onDescriptionEntered); descDialog->eventDone = MyGUI::newDelegate(this, &CreateClassDialog::onDescriptionEntered);
descDialog->setVisible(true); descDialog->setVisible(true);
@ -649,7 +642,7 @@ void CreateClassDialog::onDescriptionClicked(MyGUI::Widget* _sender)
void CreateClassDialog::onDescriptionEntered() void CreateClassDialog::onDescriptionEntered()
{ {
description = descDialog->getTextInput(); description = descDialog->getTextInput();
environment.mWindowManager->removeDialog(descDialog); mWindowManager.removeDialog(descDialog);
} }
void CreateClassDialog::onOkClicked(MyGUI::Widget* _sender) void CreateClassDialog::onOkClicked(MyGUI::Widget* _sender)
@ -664,31 +657,29 @@ void CreateClassDialog::onBackClicked(MyGUI::Widget* _sender)
/* SelectSpecializationDialog */ /* SelectSpecializationDialog */
SelectSpecializationDialog::SelectSpecializationDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize) SelectSpecializationDialog::SelectSpecializationDialog(WindowManager& parWindowManager)
: WindowBase("openmw_chargen_select_specialization_layout.xml", environment) : WindowBase("openmw_chargen_select_specialization_layout.xml", parWindowManager)
{ {
// Centre dialog // Centre dialog
center(); center();
WindowManager *wm = environment.mWindowManager; setText("LabelT", mWindowManager.getGameSettingString("sSpecializationMenu1", ""));
setText("LabelT", wm->getGameSettingString("sSpecializationMenu1", ""));
getWidget(specialization0, "Specialization0"); getWidget(specialization0, "Specialization0");
getWidget(specialization1, "Specialization1"); getWidget(specialization1, "Specialization1");
getWidget(specialization2, "Specialization2"); getWidget(specialization2, "Specialization2");
specialization0->setCaption(wm->getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Combat], "")); specialization0->setCaption(mWindowManager.getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Combat], ""));
specialization0->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked); specialization0->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked);
specialization1->setCaption(wm->getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Magic], "")); specialization1->setCaption(mWindowManager.getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Magic], ""));
specialization1->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked); specialization1->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked);
specialization2->setCaption(wm->getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Stealth], "")); specialization2->setCaption(mWindowManager.getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Stealth], ""));
specialization2->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked); specialization2->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked);
specializationId = ESM::Class::Combat; specializationId = ESM::Class::Combat;
// TODO: These buttons should be managed by a Dialog class // TODO: These buttons should be managed by a Dialog class
MyGUI::ButtonPtr cancelButton; MyGUI::ButtonPtr cancelButton;
getWidget(cancelButton, "CancelButton"); getWidget(cancelButton, "CancelButton");
cancelButton->setCaption(wm->getGameSettingString("sCancel", "")); cancelButton->setCaption(mWindowManager.getGameSettingString("sCancel", ""));
cancelButton->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSpecializationDialog::onCancelClicked); cancelButton->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSpecializationDialog::onCancelClicked);
} }
@ -715,15 +706,13 @@ void SelectSpecializationDialog::onCancelClicked(MyGUI::Widget* _sender)
/* SelectAttributeDialog */ /* SelectAttributeDialog */
SelectAttributeDialog::SelectAttributeDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize) SelectAttributeDialog::SelectAttributeDialog(WindowManager& parWindowManager)
: WindowBase("openmw_chargen_select_attribute_layout.xml", environment) : WindowBase("openmw_chargen_select_attribute_layout.xml", parWindowManager)
{ {
// Centre dialog // Centre dialog
center(); center();
WindowManager *wm = environment.mWindowManager; setText("LabelT", mWindowManager.getGameSettingString("sAttributesMenu1", ""));
setText("LabelT", wm->getGameSettingString("sAttributesMenu1", ""));
for (int i = 0; i < 8; ++i) for (int i = 0; i < 8; ++i)
{ {
@ -731,7 +720,7 @@ SelectAttributeDialog::SelectAttributeDialog(MWWorld::Environment& environment,
char theIndex = '0'+i; char theIndex = '0'+i;
getWidget(attribute, std::string("Attribute").append(1, theIndex)); getWidget(attribute, std::string("Attribute").append(1, theIndex));
attribute->setWindowManager(wm); attribute->setWindowManager(&parWindowManager);
attribute->setAttributeId(ESM::Attribute::attributeIds[i]); attribute->setAttributeId(ESM::Attribute::attributeIds[i]);
attribute->eventClicked = MyGUI::newDelegate(this, &SelectAttributeDialog::onAttributeClicked); attribute->eventClicked = MyGUI::newDelegate(this, &SelectAttributeDialog::onAttributeClicked);
} }
@ -739,7 +728,7 @@ SelectAttributeDialog::SelectAttributeDialog(MWWorld::Environment& environment,
// TODO: These buttons should be managed by a Dialog class // TODO: These buttons should be managed by a Dialog class
MyGUI::ButtonPtr cancelButton; MyGUI::ButtonPtr cancelButton;
getWidget(cancelButton, "CancelButton"); getWidget(cancelButton, "CancelButton");
cancelButton->setCaption(wm->getGameSettingString("sCancel", "")); cancelButton->setCaption(mWindowManager.getGameSettingString("sCancel", ""));
cancelButton->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectAttributeDialog::onCancelClicked); cancelButton->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectAttributeDialog::onCancelClicked);
} }
@ -760,18 +749,16 @@ void SelectAttributeDialog::onCancelClicked(MyGUI::Widget* _sender)
/* SelectSkillDialog */ /* SelectSkillDialog */
SelectSkillDialog::SelectSkillDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize) SelectSkillDialog::SelectSkillDialog(WindowManager& parWindowManager)
: WindowBase("openmw_chargen_select_skill_layout.xml", environment) : WindowBase("openmw_chargen_select_skill_layout.xml", parWindowManager)
{ {
// Centre dialog // Centre dialog
center(); center();
WindowManager *wm = environment.mWindowManager; setText("LabelT", mWindowManager.getGameSettingString("sSkillsMenu1", ""));
setText("CombatLabelT", mWindowManager.getGameSettingString("sSpecializationCombat", ""));
setText("LabelT", wm->getGameSettingString("sSkillsMenu1", "")); setText("MagicLabelT", mWindowManager.getGameSettingString("sSpecializationMagic", ""));
setText("CombatLabelT", wm->getGameSettingString("sSpecializationCombat", "")); setText("StealthLabelT", mWindowManager.getGameSettingString("sSpecializationStealth", ""));
setText("MagicLabelT", wm->getGameSettingString("sSpecializationMagic", ""));
setText("StealthLabelT", wm->getGameSettingString("sSpecializationStealth", ""));
for(int i = 0; i < 9; i++) for(int i = 0; i < 9; i++)
{ {
@ -821,7 +808,7 @@ SelectSkillDialog::SelectSkillDialog(MWWorld::Environment& environment, MyGUI::I
{ {
for (int i = 0; i < 9; ++i) for (int i = 0; i < 9; ++i)
{ {
skills[spec][i].widget->setWindowManager(wm); skills[spec][i].widget->setWindowManager(&mWindowManager);
skills[spec][i].widget->setSkillId(skills[spec][i].skillId); skills[spec][i].widget->setSkillId(skills[spec][i].skillId);
skills[spec][i].widget->eventClicked = MyGUI::newDelegate(this, &SelectSkillDialog::onSkillClicked); skills[spec][i].widget->eventClicked = MyGUI::newDelegate(this, &SelectSkillDialog::onSkillClicked);
} }
@ -830,7 +817,7 @@ SelectSkillDialog::SelectSkillDialog(MWWorld::Environment& environment, MyGUI::I
// TODO: These buttons should be managed by a Dialog class // TODO: These buttons should be managed by a Dialog class
MyGUI::ButtonPtr cancelButton; MyGUI::ButtonPtr cancelButton;
getWidget(cancelButton, "CancelButton"); getWidget(cancelButton, "CancelButton");
cancelButton->setCaption(wm->getGameSettingString("sCancel", "")); cancelButton->setCaption(mWindowManager.getGameSettingString("sCancel", ""));
cancelButton->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSkillDialog::onCancelClicked); cancelButton->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSkillDialog::onCancelClicked);
} }
@ -849,8 +836,8 @@ void SelectSkillDialog::onCancelClicked(MyGUI::Widget* _sender)
/* DescriptionDialog */ /* DescriptionDialog */
DescriptionDialog::DescriptionDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize) DescriptionDialog::DescriptionDialog(WindowManager& parWindowManager)
: WindowBase("openmw_chargen_class_description_layout.xml", environment) : WindowBase("openmw_chargen_class_description_layout.xml", parWindowManager)
{ {
// Centre dialog // Centre dialog
center(); center();
@ -861,7 +848,7 @@ DescriptionDialog::DescriptionDialog(MWWorld::Environment& environment, MyGUI::I
MyGUI::ButtonPtr okButton; MyGUI::ButtonPtr okButton;
getWidget(okButton, "OKButton"); getWidget(okButton, "OKButton");
okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &DescriptionDialog::onOkClicked); okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &DescriptionDialog::onOkClicked);
okButton->setCaption(environment.mWindowManager->getGameSettingString("sInputMenu1", "")); okButton->setCaption(mWindowManager.getGameSettingString("sInputMenu1", ""));
// Make sure the edit box has focus // Make sure the edit box has focus
MyGUI::InputManager::getInstance().setKeyFocusWidget(textEdit); MyGUI::InputManager::getInstance().setKeyFocusWidget(textEdit);

View file

@ -5,11 +5,6 @@
#include "widgets.hpp" #include "widgets.hpp"
#include "window_base.hpp" #include "window_base.hpp"
namespace MWWorld
{
class Environment;
}
/* /*
This file contains the dialogs for choosing a class. This file contains the dialogs for choosing a class.
Layout is defined by resources/mygui/openmw_chargen_class_layout.xml. Layout is defined by resources/mygui/openmw_chargen_class_layout.xml.
@ -19,10 +14,12 @@ namespace MWGui
{ {
using namespace MyGUI; using namespace MyGUI;
class WindowManager;
class InfoBoxDialog : public WindowBase class InfoBoxDialog : public WindowBase
{ {
public: public:
InfoBoxDialog(MWWorld::Environment& environment); InfoBoxDialog(WindowManager& parWindowManager);
typedef std::vector<std::string> ButtonList; typedef std::vector<std::string> ButtonList;
@ -67,13 +64,13 @@ namespace MWGui
Class_Create = 2, Class_Create = 2,
Class_Back = 3 Class_Back = 3
}; };
ClassChoiceDialog(MWWorld::Environment& environment); ClassChoiceDialog(WindowManager& parWindowManager);
}; };
class GenerateClassResultDialog : public WindowBase class GenerateClassResultDialog : public WindowBase
{ {
public: public:
GenerateClassResultDialog(MWWorld::Environment& environment); GenerateClassResultDialog(WindowManager& parWindowManager);
std::string getClassId() const; std::string getClassId() const;
void setClassId(const std::string &classId); void setClassId(const std::string &classId);
@ -107,7 +104,7 @@ namespace MWGui
class PickClassDialog : public WindowBase class PickClassDialog : public WindowBase
{ {
public: public:
PickClassDialog(MWWorld::Environment& environment); PickClassDialog(WindowManager& parWindowManager);
const std::string &getClassId() const { return currentClassId; } const std::string &getClassId() const { return currentClassId; }
void setClassId(const std::string &classId); void setClassId(const std::string &classId);
@ -151,7 +148,7 @@ namespace MWGui
class SelectSpecializationDialog : public WindowBase class SelectSpecializationDialog : public WindowBase
{ {
public: public:
SelectSpecializationDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize); SelectSpecializationDialog(WindowManager& parWindowManager);
ESM::Class::Specialization getSpecializationId() const { return specializationId; } ESM::Class::Specialization getSpecializationId() const { return specializationId; }
@ -181,7 +178,7 @@ namespace MWGui
class SelectAttributeDialog : public WindowBase class SelectAttributeDialog : public WindowBase
{ {
public: public:
SelectAttributeDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize); SelectAttributeDialog(WindowManager& parWindowManager);
ESM::Attribute::AttributeID getAttributeId() const { return attributeId; } ESM::Attribute::AttributeID getAttributeId() const { return attributeId; }
Widgets::MWAttributePtr getAffectedWidget() const { return affectedWidget; } Widgets::MWAttributePtr getAffectedWidget() const { return affectedWidget; }
@ -213,7 +210,7 @@ namespace MWGui
class SelectSkillDialog : public WindowBase class SelectSkillDialog : public WindowBase
{ {
public: public:
SelectSkillDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize); SelectSkillDialog(WindowManager& parWindowManager);
ESM::Skill::SkillEnum getSkillId() const { return skillId; } ESM::Skill::SkillEnum getSkillId() const { return skillId; }
Widgets::MWSkillPtr getAffectedWidget() const { return affectedWidget; } Widgets::MWSkillPtr getAffectedWidget() const { return affectedWidget; }
@ -248,7 +245,7 @@ namespace MWGui
class DescriptionDialog : public WindowBase class DescriptionDialog : public WindowBase
{ {
public: public:
DescriptionDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize); DescriptionDialog(WindowManager& parWindowManager);
std::string getTextInput() const { return textEdit ? textEdit->getOnlyText() : ""; } std::string getTextInput() const { return textEdit ? textEdit->getOnlyText() : ""; }
void setTextInput(const std::string &text) { if (textEdit) textEdit->setOnlyText(text); } void setTextInput(const std::string &text) { if (textEdit) textEdit->setOnlyText(text); }
@ -271,7 +268,7 @@ namespace MWGui
class CreateClassDialog : public WindowBase class CreateClassDialog : public WindowBase
{ {
public: public:
CreateClassDialog(MWWorld::Environment& environment); CreateClassDialog(WindowManager& parWindowManager);
virtual ~CreateClassDialog(); virtual ~CreateClassDialog();
std::string getName() const; std::string getName() const;

View file

@ -1,7 +1,5 @@
#include "dialogue.hpp" #include "dialogue.hpp"
#include "dialogue_history.hpp" #include "dialogue_history.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include "window_manager.hpp" #include "window_manager.hpp"
#include "widgets.hpp" #include "widgets.hpp"
#include "components/esm_store/store.hpp" #include "components/esm_store/store.hpp"
@ -16,8 +14,8 @@
using namespace MWGui; using namespace MWGui;
using namespace Widgets; using namespace Widgets;
DialogueWindow::DialogueWindow(MWWorld::Environment& environment) DialogueWindow::DialogueWindow(WindowManager& parWindowManager)
: WindowBase("openmw_dialogue_window_layout.xml", environment) : WindowBase("openmw_dialogue_window_layout.xml", parWindowManager)
{ {
// Centre dialog // Centre dialog
center(); center();

View file

@ -4,9 +4,9 @@
#include "window_base.hpp" #include "window_base.hpp"
#include <boost/array.hpp> #include <boost/array.hpp>
namespace MWWorld namespace MWGui
{ {
class Environment; class WindowManager;
} }
/* /*
@ -23,7 +23,7 @@ namespace MWGui
class DialogueWindow: public WindowBase class DialogueWindow: public WindowBase
{ {
public: public:
DialogueWindow(MWWorld::Environment& environment); DialogueWindow(WindowManager& parWindowManager);
void open(); void open();

View file

@ -1,6 +1,4 @@
#include "dialogue_history.hpp" #include "dialogue_history.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include "window_manager.hpp" #include "window_manager.hpp"
#include "widgets.hpp" #include "widgets.hpp"
#include "components/esm_store/store.hpp" #include "components/esm_store/store.hpp"

View file

@ -1,8 +1,7 @@
#include "layouts.hpp" #include "layouts.hpp"
#include "../mwworld/class.hpp"
#include "../mwmechanics/mechanicsmanager.hpp" #include "../mwmechanics/mechanicsmanager.hpp"
#include "../mwgui/window_manager.hpp" #include "window_manager.hpp"
#include <cmath> #include <cmath>
#include <algorithm> #include <algorithm>

View file

@ -3,8 +3,6 @@
#include <components/esm_store/store.hpp> #include <components/esm_store/store.hpp>
#include <openengine/gui/layout.hpp>
#include <boost/array.hpp> #include <boost/array.hpp>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
@ -14,8 +12,6 @@
#include <utility> #include <utility>
#include "../mwmechanics/stat.hpp" #include "../mwmechanics/stat.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include "window_base.hpp" #include "window_base.hpp"
/* /*

View file

@ -1,6 +1,4 @@
#include "race.hpp" #include "race.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include "window_manager.hpp" #include "window_manager.hpp"
#include "widgets.hpp" #include "widgets.hpp"
#include "components/esm_store/store.hpp" #include "components/esm_store/store.hpp"
@ -15,8 +13,8 @@
using namespace MWGui; using namespace MWGui;
using namespace Widgets; using namespace Widgets;
RaceDialog::RaceDialog(MWWorld::Environment& environment) RaceDialog::RaceDialog(WindowManager& parWindowManager)
: WindowBase("openmw_chargen_race_layout.xml", environment) : WindowBase("openmw_chargen_race_layout.xml", parWindowManager)
, genderIndex(0) , genderIndex(0)
, faceIndex(0) , faceIndex(0)
, hairIndex(0) , hairIndex(0)
@ -29,8 +27,7 @@ RaceDialog::RaceDialog(MWWorld::Environment& environment)
// These are just demo values, you should replace these with // These are just demo values, you should replace these with
// real calls from outside the class later. // real calls from outside the class later.
WindowManager *wm = environment.mWindowManager; setText("AppearanceT", mWindowManager.getGameSettingString("sRaceMenu1", "Appearance"));
setText("AppearanceT", wm->getGameSettingString("sRaceMenu1", "Appearance"));
getWidget(appearanceBox, "AppearanceBox"); getWidget(appearanceBox, "AppearanceBox");
getWidget(headRotate, "HeadRotate"); getWidget(headRotate, "HeadRotate");
@ -42,34 +39,34 @@ RaceDialog::RaceDialog(MWWorld::Environment& environment)
// Set up next/previous buttons // Set up next/previous buttons
MyGUI::ButtonPtr prevButton, nextButton; MyGUI::ButtonPtr prevButton, nextButton;
setText("GenderChoiceT", wm->getGameSettingString("sRaceMenu2", "Change Sex")); setText("GenderChoiceT", mWindowManager.getGameSettingString("sRaceMenu2", "Change Sex"));
getWidget(prevButton, "PrevGenderButton"); getWidget(prevButton, "PrevGenderButton");
getWidget(nextButton, "NextGenderButton"); getWidget(nextButton, "NextGenderButton");
prevButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousGender); prevButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousGender);
nextButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectNextGender); nextButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectNextGender);
setText("FaceChoiceT", wm->getGameSettingString("sRaceMenu3", "Change Face")); setText("FaceChoiceT", mWindowManager.getGameSettingString("sRaceMenu3", "Change Face"));
getWidget(prevButton, "PrevFaceButton"); getWidget(prevButton, "PrevFaceButton");
getWidget(nextButton, "NextFaceButton"); getWidget(nextButton, "NextFaceButton");
prevButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousFace); prevButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousFace);
nextButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectNextFace); nextButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectNextFace);
setText("HairChoiceT", wm->getGameSettingString("sRaceMenu3", "Change Hair")); setText("HairChoiceT", mWindowManager.getGameSettingString("sRaceMenu3", "Change Hair"));
getWidget(prevButton, "PrevHairButton"); getWidget(prevButton, "PrevHairButton");
getWidget(nextButton, "NextHairButton"); getWidget(nextButton, "NextHairButton");
prevButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousHair); prevButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousHair);
nextButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectNextHair); nextButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectNextHair);
setText("RaceT", wm->getGameSettingString("sRaceMenu4", "Race")); setText("RaceT", mWindowManager.getGameSettingString("sRaceMenu4", "Race"));
getWidget(raceList, "RaceList"); getWidget(raceList, "RaceList");
raceList->setScrollVisible(true); raceList->setScrollVisible(true);
raceList->eventListSelectAccept = MyGUI::newDelegate(this, &RaceDialog::onSelectRace); raceList->eventListSelectAccept = MyGUI::newDelegate(this, &RaceDialog::onSelectRace);
raceList->eventListMouseItemActivate = MyGUI::newDelegate(this, &RaceDialog::onSelectRace); raceList->eventListMouseItemActivate = MyGUI::newDelegate(this, &RaceDialog::onSelectRace);
raceList->eventListChangePosition = MyGUI::newDelegate(this, &RaceDialog::onSelectRace); raceList->eventListChangePosition = MyGUI::newDelegate(this, &RaceDialog::onSelectRace);
setText("SkillsT", wm->getGameSettingString("sBonusSkillTitle", "Skill Bonus")); setText("SkillsT", mWindowManager.getGameSettingString("sBonusSkillTitle", "Skill Bonus"));
getWidget(skillList, "SkillList"); getWidget(skillList, "SkillList");
setText("SpellPowerT", wm->getGameSettingString("sRaceMenu7", "Specials")); setText("SpellPowerT", mWindowManager.getGameSettingString("sRaceMenu7", "Specials"));
getWidget(spellPowerList, "SpellPowerList"); getWidget(spellPowerList, "SpellPowerList");
// TODO: These buttons should be managed by a Dialog class // TODO: These buttons should be managed by a Dialog class
@ -215,7 +212,7 @@ void RaceDialog::updateRaces()
{ {
raceList->removeAllItems(); raceList->removeAllItems();
ESMS::ESMStore &store = environment.mWorld->getStore(); ESMS::ESMStore &store = mWindowManager.getStore();
ESMS::RecListT<ESM::Race>::MapType::const_iterator it = store.races.list.begin(); ESMS::RecListT<ESM::Race>::MapType::const_iterator it = store.races.list.begin();
ESMS::RecListT<ESM::Race>::MapType::const_iterator end = store.races.list.end(); ESMS::RecListT<ESM::Race>::MapType::const_iterator end = store.races.list.end();
@ -249,8 +246,7 @@ void RaceDialog::updateSkills()
const int lineHeight = 18; const int lineHeight = 18;
MyGUI::IntCoord coord1(0, 0, skillList->getWidth(), 18); MyGUI::IntCoord coord1(0, 0, skillList->getWidth(), 18);
WindowManager *wm = environment.mWindowManager; ESMS::ESMStore &store = mWindowManager.getStore();
ESMS::ESMStore &store = environment.mWorld->getStore();
const ESM::Race *race = store.races.find(currentRaceId); const ESM::Race *race = store.races.find(currentRaceId);
int count = sizeof(race->data.bonus)/sizeof(race->data.bonus[0]); // TODO: Find a portable macro for this ARRAYSIZE? int count = sizeof(race->data.bonus)/sizeof(race->data.bonus[0]); // TODO: Find a portable macro for this ARRAYSIZE?
for (int i = 0; i < count; ++i) for (int i = 0; i < count; ++i)
@ -261,7 +257,7 @@ void RaceDialog::updateSkills()
skillWidget = skillList->createWidget<MWSkill>("MW_StatNameValue", coord1, MyGUI::Align::Default, skillWidget = skillList->createWidget<MWSkill>("MW_StatNameValue", coord1, MyGUI::Align::Default,
std::string("Skill") + boost::lexical_cast<std::string>(i)); std::string("Skill") + boost::lexical_cast<std::string>(i));
skillWidget->setWindowManager(wm); skillWidget->setWindowManager(&mWindowManager);
skillWidget->setSkillNumber(skillId); skillWidget->setSkillNumber(skillId);
skillWidget->setSkillValue(MWSkill::SkillValue(race->data.bonus[i].bonus)); skillWidget->setSkillValue(MWSkill::SkillValue(race->data.bonus[i].bonus));
@ -286,7 +282,7 @@ void RaceDialog::updateSpellPowers()
const int lineHeight = 18; const int lineHeight = 18;
MyGUI::IntCoord coord(0, 0, spellPowerList->getWidth(), 18); MyGUI::IntCoord coord(0, 0, spellPowerList->getWidth(), 18);
ESMS::ESMStore &store = environment.mWorld->getStore(); ESMS::ESMStore &store = mWindowManager.getStore();
const ESM::Race *race = store.races.find(currentRaceId); const ESM::Race *race = store.races.find(currentRaceId);
std::vector<std::string>::const_iterator it = race->powers.list.begin(); std::vector<std::string>::const_iterator it = race->powers.list.begin();
@ -295,7 +291,7 @@ void RaceDialog::updateSpellPowers()
{ {
const std::string &spellpower = *it; const std::string &spellpower = *it;
spellPowerWidget = spellPowerList->createWidget<MWSpell>("MW_StatName", coord, MyGUI::Align::Default, std::string("SpellPower") + boost::lexical_cast<std::string>(i)); spellPowerWidget = spellPowerList->createWidget<MWSpell>("MW_StatName", coord, MyGUI::Align::Default, std::string("SpellPower") + boost::lexical_cast<std::string>(i));
spellPowerWidget->setEnvironment(&environment); spellPowerWidget->setWindowManager(&mWindowManager);
spellPowerWidget->setSpellId(spellpower); spellPowerWidget->setSpellId(spellpower);
spellPowerItems.push_back(spellPowerWidget); spellPowerItems.push_back(spellPowerWidget);

View file

@ -7,9 +7,9 @@
#include <boost/array.hpp> #include <boost/array.hpp>
namespace MWWorld namespace MWGui
{ {
class Environment; class WindowManager;
} }
/* /*
@ -24,7 +24,7 @@ namespace MWGui
class RaceDialog : public WindowBase class RaceDialog : public WindowBase
{ {
public: public:
RaceDialog(MWWorld::Environment& environment); RaceDialog(WindowManager& parWindowManager);
enum Gender enum Gender
{ {

View file

@ -1,6 +1,4 @@
#include "review.hpp" #include "review.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include "window_manager.hpp" #include "window_manager.hpp"
#include "widgets.hpp" #include "widgets.hpp"
#include "components/esm_store/store.hpp" #include "components/esm_store/store.hpp"
@ -15,48 +13,46 @@ using namespace Widgets;
const int ReviewDialog::lineHeight = 18; const int ReviewDialog::lineHeight = 18;
ReviewDialog::ReviewDialog(MWWorld::Environment& environment) ReviewDialog::ReviewDialog(WindowManager& parWindowManager)
: WindowBase("openmw_chargen_review_layout.xml", environment) : WindowBase("openmw_chargen_review_layout.xml", parWindowManager)
, lastPos(0) , lastPos(0)
{ {
// Centre dialog // Centre dialog
center(); center();
WindowManager *wm = environment.mWindowManager;
// Setup static stats // Setup static stats
ButtonPtr button; ButtonPtr button;
getWidget(nameWidget, "NameText"); getWidget(nameWidget, "NameText");
getWidget(button, "NameButton"); getWidget(button, "NameButton");
button->setCaption(wm->getGameSettingString("sName", "")); button->setCaption(mWindowManager.getGameSettingString("sName", ""));
button->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onNameClicked);; button->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onNameClicked);;
getWidget(raceWidget, "RaceText"); getWidget(raceWidget, "RaceText");
getWidget(button, "RaceButton"); getWidget(button, "RaceButton");
button->setCaption(wm->getGameSettingString("sRace", "")); button->setCaption(mWindowManager.getGameSettingString("sRace", ""));
button->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onRaceClicked);; button->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onRaceClicked);;
getWidget(classWidget, "ClassText"); getWidget(classWidget, "ClassText");
getWidget(button, "ClassButton"); getWidget(button, "ClassButton");
button->setCaption(wm->getGameSettingString("sClass", "")); button->setCaption(mWindowManager.getGameSettingString("sClass", ""));
button->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onClassClicked);; button->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onClassClicked);;
getWidget(birthSignWidget, "SignText"); getWidget(birthSignWidget, "SignText");
getWidget(button, "SignButton"); getWidget(button, "SignButton");
button->setCaption(wm->getGameSettingString("sBirthSign", "")); button->setCaption(mWindowManager.getGameSettingString("sBirthSign", ""));
button->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onBirthSignClicked);; button->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onBirthSignClicked);;
// Setup dynamic stats // Setup dynamic stats
getWidget(health, "Health"); getWidget(health, "Health");
health->setTitle(wm->getGameSettingString("sHealth", "")); health->setTitle(mWindowManager.getGameSettingString("sHealth", ""));
health->setValue(45, 45); health->setValue(45, 45);
getWidget(magicka, "Magicka"); getWidget(magicka, "Magicka");
magicka->setTitle(wm->getGameSettingString("sMagic", "")); magicka->setTitle(mWindowManager.getGameSettingString("sMagic", ""));
magicka->setValue(50, 50); magicka->setValue(50, 50);
getWidget(fatigue, "Fatigue"); getWidget(fatigue, "Fatigue");
fatigue->setTitle(wm->getGameSettingString("sFatigue", "")); fatigue->setTitle(mWindowManager.getGameSettingString("sFatigue", ""));
fatigue->setValue(160, 160); fatigue->setValue(160, 160);
// Setup attributes // Setup attributes
@ -66,7 +62,7 @@ ReviewDialog::ReviewDialog(MWWorld::Environment& environment)
{ {
getWidget(attribute, std::string("Attribute") + boost::lexical_cast<std::string>(idx)); getWidget(attribute, std::string("Attribute") + boost::lexical_cast<std::string>(idx));
attributeWidgets.insert(std::make_pair(static_cast<int>(ESM::Attribute::attributeIds[idx]), attribute)); attributeWidgets.insert(std::make_pair(static_cast<int>(ESM::Attribute::attributeIds[idx]), attribute));
attribute->setWindowManager(wm); attribute->setWindowManager(&mWindowManager);
attribute->setAttributeId(ESM::Attribute::attributeIds[idx]); attribute->setAttributeId(ESM::Attribute::attributeIds[idx]);
attribute->setAttributeValue(MWAttribute::AttributeValue(0, 0)); attribute->setAttributeValue(MWAttribute::AttributeValue(0, 0));
} }
@ -131,7 +127,7 @@ void ReviewDialog::setPlayerName(const std::string &name)
void ReviewDialog::setRace(const std::string &raceId_) void ReviewDialog::setRace(const std::string &raceId_)
{ {
raceId = raceId_; raceId = raceId_;
const ESM::Race *race = environment.mWorld->getStore().races.search(raceId); const ESM::Race *race = mWindowManager.getStore().races.search(raceId);
if (race) if (race)
raceWidget->setCaption(race->name); raceWidget->setCaption(race->name);
} }
@ -145,7 +141,7 @@ void ReviewDialog::setClass(const ESM::Class& class_)
void ReviewDialog::setBirthSign(const std::string& signId) void ReviewDialog::setBirthSign(const std::string& signId)
{ {
birthSignId = signId; birthSignId = signId;
const ESM::BirthSign *sign = environment.mWorld->getStore().birthSigns.search(birthSignId); const ESM::BirthSign *sign = mWindowManager.getStore().birthSigns.search(birthSignId);
if (sign) if (sign)
birthSignWidget->setCaption(sign->name); birthSignWidget->setCaption(sign->name);
} }
@ -275,15 +271,13 @@ void ReviewDialog::addItem(const std::string text, MyGUI::IntCoord &coord1, MyGU
void ReviewDialog::addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) void ReviewDialog::addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
{ {
WindowManager *wm = environment.mWindowManager;
// Add a line separator if there are items above // Add a line separator if there are items above
if (!skillWidgets.empty()) if (!skillWidgets.empty())
{ {
addSeparator(coord1, coord2); addSeparator(coord1, coord2);
} }
addGroup(wm->getGameSettingString(titleId, titleDefault), coord1, coord2); addGroup(mWindowManager.getGameSettingString(titleId, titleDefault), coord1, coord2);
SkillList::const_iterator end = skills.end(); SkillList::const_iterator end = skills.end();
for (SkillList::const_iterator it = skills.begin(); it != end; ++it) for (SkillList::const_iterator it = skills.begin(); it != end; ++it)
@ -302,7 +296,7 @@ void ReviewDialog::addSkills(const SkillList &skills, const std::string &titleId
style = CS_Super; style = CS_Super;
else if (modified < base) else if (modified < base)
style = CS_Sub; style = CS_Sub;
MyGUI::StaticTextPtr widget = addValueItem(wm->getGameSettingString(skillNameId, skillNameId), boost::lexical_cast<std::string>(static_cast<int>(modified)), style, coord1, coord2); MyGUI::StaticTextPtr widget = addValueItem(mWindowManager.getGameSettingString(skillNameId, skillNameId), boost::lexical_cast<std::string>(static_cast<int>(modified)), style, coord1, coord2);
skillWidgetMap[skillId] = widget; skillWidgetMap[skillId] = widget;
} }
} }

View file

@ -5,9 +5,9 @@
#include "../mwmechanics/stat.hpp" #include "../mwmechanics/stat.hpp"
#include "widgets.hpp" #include "widgets.hpp"
namespace MWWorld namespace MWGui
{ {
class Environment; class WindowManager;
} }
/* /*
@ -30,7 +30,7 @@ namespace MWGui
}; };
typedef std::vector<int> SkillList; typedef std::vector<int> SkillList;
ReviewDialog(MWWorld::Environment& environment); ReviewDialog(WindowManager& parWindowManager);
void setPlayerName(const std::string &name); void setPlayerName(const std::string &name);
void setRace(const std::string &raceId); void setRace(const std::string &raceId);

View file

@ -1,8 +1,7 @@
#include "stats_window.hpp" #include "stats_window.hpp"
#include "../mwworld/class.hpp"
#include "../mwmechanics/mechanicsmanager.hpp" #include "../mwmechanics/mechanicsmanager.hpp"
#include "../mwgui/window_manager.hpp" #include "window_manager.hpp"
#include <cmath> #include <cmath>
#include <algorithm> #include <algorithm>
@ -12,8 +11,8 @@
using namespace MWGui; using namespace MWGui;
const int StatsWindow::lineHeight = 18; const int StatsWindow::lineHeight = 18;
StatsWindow::StatsWindow (MWWorld::Environment& environment) StatsWindow::StatsWindow (WindowManager& parWindowManager)
: WindowBase("openmw_stats_window_layout.xml", environment) : WindowBase("openmw_stats_window_layout.xml", parWindowManager)
, lastPos(0) , lastPos(0)
, reputation(0) , reputation(0)
, bounty(0) , bounty(0)
@ -39,7 +38,7 @@ StatsWindow::StatsWindow (MWWorld::Environment& environment)
{ 0, 0 } { 0, 0 }
}; };
const ESMS::ESMStore &store = environment.mWorld->getStore(); const ESMS::ESMStore &store = mWindowManager.getStore();
for (int i=0; names[i][0]; ++i) for (int i=0; names[i][0]; ++i)
{ {
setText (names[i][0], store.gameSettings.find (names[i][1])->str); setText (names[i][0], store.gameSettings.find (names[i][1])->str);
@ -273,15 +272,13 @@ void StatsWindow::addItem(const std::string text, MyGUI::IntCoord &coord1, MyGUI
void StatsWindow::addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) void StatsWindow::addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
{ {
WindowManager *wm = environment.mWindowManager;
// Add a line separator if there are items above // Add a line separator if there are items above
if (!skillWidgets.empty()) if (!skillWidgets.empty())
{ {
addSeparator(coord1, coord2); addSeparator(coord1, coord2);
} }
addGroup(wm->getGameSettingString(titleId, titleDefault), coord1, coord2); addGroup(mWindowManager.getGameSettingString(titleId, titleDefault), coord1, coord2);
SkillList::const_iterator end = skills.end(); SkillList::const_iterator end = skills.end();
for (SkillList::const_iterator it = skills.begin(); it != end; ++it) for (SkillList::const_iterator it = skills.begin(); it != end; ++it)
@ -300,7 +297,7 @@ void StatsWindow::addSkills(const SkillList &skills, const std::string &titleId,
style = CS_Super; style = CS_Super;
else if (modified < base) else if (modified < base)
style = CS_Sub; style = CS_Sub;
MyGUI::StaticTextPtr widget = addValueItem(wm->getGameSettingString(skillNameId, skillNameId), boost::lexical_cast<std::string>(static_cast<int>(modified)), style, coord1, coord2); MyGUI::StaticTextPtr widget = addValueItem(mWindowManager.getGameSettingString(skillNameId, skillNameId), boost::lexical_cast<std::string>(static_cast<int>(modified)), style, coord1, coord2);
skillWidgetMap[skillId] = widget; skillWidgetMap[skillId] = widget;
} }
} }
@ -326,8 +323,7 @@ void StatsWindow::updateSkillArea()
if (!miscSkills.empty()) if (!miscSkills.empty())
addSkills(miscSkills, "sSkillClassMisc", "Misc Skills", coord1, coord2); addSkills(miscSkills, "sSkillClassMisc", "Misc Skills", coord1, coord2);
WindowManager *wm = environment.mWindowManager; ESMS::ESMStore &store = mWindowManager.getStore();
ESMS::ESMStore &store = environment.mWorld->getStore();
if (!factions.empty()) if (!factions.empty())
{ {
@ -335,7 +331,7 @@ void StatsWindow::updateSkillArea()
if (!skillWidgets.empty()) if (!skillWidgets.empty())
addSeparator(coord1, coord2); addSeparator(coord1, coord2);
addGroup(wm->getGameSettingString("sFaction", "Faction"), coord1, coord2); addGroup(mWindowManager.getGameSettingString("sFaction", "Faction"), coord1, coord2);
FactionList::const_iterator end = factions.end(); FactionList::const_iterator end = factions.end();
for (FactionList::const_iterator it = factions.begin(); it != end; ++it) for (FactionList::const_iterator it = factions.begin(); it != end; ++it)
{ {
@ -351,7 +347,7 @@ void StatsWindow::updateSkillArea()
if (!skillWidgets.empty()) if (!skillWidgets.empty())
addSeparator(coord1, coord2); addSeparator(coord1, coord2);
addGroup(wm->getGameSettingString("sSign", "Sign"), coord1, coord2); addGroup(mWindowManager.getGameSettingString("sSign", "Sign"), coord1, coord2);
const ESM::BirthSign *sign = store.birthSigns.find(birthSignId); const ESM::BirthSign *sign = store.birthSigns.find(birthSignId);
addItem(sign->name, coord1, coord2); addItem(sign->name, coord1, coord2);
} }
@ -360,8 +356,8 @@ void StatsWindow::updateSkillArea()
if (!skillWidgets.empty()) if (!skillWidgets.empty())
addSeparator(coord1, coord2); addSeparator(coord1, coord2);
addValueItem(wm->getGameSettingString("sReputation", "Reputation"), boost::lexical_cast<std::string>(static_cast<int>(reputation)), CS_Normal, coord1, coord2); addValueItem(mWindowManager.getGameSettingString("sReputation", "Reputation"), boost::lexical_cast<std::string>(static_cast<int>(reputation)), CS_Normal, coord1, coord2);
addValueItem(wm->getGameSettingString("sBounty", "Bounty"), boost::lexical_cast<std::string>(static_cast<int>(bounty)), CS_Normal, coord1, coord2); addValueItem(mWindowManager.getGameSettingString("sBounty", "Bounty"), boost::lexical_cast<std::string>(static_cast<int>(bounty)), CS_Normal, coord1, coord2);
clientHeight = coord1.top; clientHeight = coord1.top;
updateScroller(); updateScroller();

View file

@ -3,21 +3,17 @@
#include <components/esm_store/store.hpp> #include <components/esm_store/store.hpp>
#include <openengine/gui/layout.hpp>
#include <boost/array.hpp>
#include <sstream> #include <sstream>
#include <set> #include <set>
#include <string> #include <string>
#include <utility> #include <utility>
#include "../mwmechanics/stat.hpp" #include "../mwmechanics/stat.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include "window_base.hpp" #include "window_base.hpp"
namespace MWGui namespace MWGui
{ {
class WindowManager;
class StatsWindow : public WindowBase class StatsWindow : public WindowBase
{ {
@ -27,7 +23,7 @@ namespace MWGui
typedef std::vector<int> SkillList; typedef std::vector<int> SkillList;
StatsWindow (MWWorld::Environment& environment); StatsWindow(WindowManager& parWindowManager);
void setBar(const std::string& name, const std::string& tname, int val, int max); void setBar(const std::string& name, const std::string& tname, int val, int max);
void setPlayerName(const std::string& playerName); void setPlayerName(const std::string& playerName);

View file

@ -1,12 +1,10 @@
#include "text_input.hpp" #include "text_input.hpp"
#include "window_manager.hpp" #include "window_manager.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
using namespace MWGui; using namespace MWGui;
TextInputDialog::TextInputDialog(MWWorld::Environment& environment) TextInputDialog::TextInputDialog(WindowManager& parWindowManager)
: WindowBase("openmw_text_input_layout.xml", environment) : WindowBase("openmw_text_input_layout.xml", parWindowManager)
{ {
// Centre dialog // Centre dialog
center(); center();

View file

@ -3,9 +3,9 @@
#include "window_base.hpp" #include "window_base.hpp"
namespace MWWorld namespace MWGui
{ {
class Environment; class WindowManager;
} }
/* /*
@ -18,7 +18,7 @@ namespace MWGui
class TextInputDialog : public WindowBase class TextInputDialog : public WindowBase
{ {
public: public:
TextInputDialog(MWWorld::Environment& environment); TextInputDialog(WindowManager& parWindowManager);
std::string getTextInput() const { return textEdit ? textEdit->getOnlyText() : ""; } std::string getTextInput() const { return textEdit ? textEdit->getOnlyText() : ""; }
void setTextInput(const std::string &text) { if (textEdit) textEdit->setOnlyText(text); } void setTextInput(const std::string &text) { if (textEdit) textEdit->setOnlyText(text); }

View file

@ -1,7 +1,5 @@
#include "widgets.hpp" #include "widgets.hpp"
#include "window_manager.hpp" #include "window_manager.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include "components/esm_store/store.hpp" #include "components/esm_store/store.hpp"
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
@ -264,7 +262,7 @@ void MWAttribute::shutdownWidgetSkin()
/* MWSpell */ /* MWSpell */
MWSpell::MWSpell() MWSpell::MWSpell()
: env(nullptr) : mWindowManager(nullptr)
, spellNameWidget(nullptr) , spellNameWidget(nullptr)
{ {
} }
@ -277,7 +275,7 @@ void MWSpell::setSpellId(const std::string &spellId)
void MWSpell::createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord) void MWSpell::createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord)
{ {
ESMS::ESMStore &store = env->mWorld->getStore(); ESMS::ESMStore &store = mWindowManager->getStore();
const ESM::Spell *spell = store.spells.search(id); const ESM::Spell *spell = store.spells.search(id);
MYGUI_ASSERT(spell, "spell with id '" << id << "' not found"); MYGUI_ASSERT(spell, "spell with id '" << id << "' not found");
@ -286,7 +284,7 @@ void MWSpell::createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI:
for (std::vector<ESM::ENAMstruct>::const_iterator it = spell->effects.list.begin(); it != end; ++it) for (std::vector<ESM::ENAMstruct>::const_iterator it = spell->effects.list.begin(); it != end; ++it)
{ {
effect = creator->createWidget<MWSpellEffect>("MW_EffectImage", coord, MyGUI::Align::Default); effect = creator->createWidget<MWSpellEffect>("MW_EffectImage", coord, MyGUI::Align::Default);
effect->setEnvironment(env); effect->setWindowManager(mWindowManager);
effect->setSpellEffect(*it); effect->setSpellEffect(*it);
effects.push_back(effect); effects.push_back(effect);
coord.top += effect->getHeight(); coord.top += effect->getHeight();
@ -295,9 +293,9 @@ void MWSpell::createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI:
void MWSpell::updateWidgets() void MWSpell::updateWidgets()
{ {
if (spellNameWidget && env) if (spellNameWidget && mWindowManager)
{ {
ESMS::ESMStore &store = env->mWorld->getStore(); ESMS::ESMStore &store = mWindowManager->getStore();
const ESM::Spell *spell = store.spells.search(id); const ESM::Spell *spell = store.spells.search(id);
if (spell) if (spell)
spellNameWidget->setCaption(spell->name); spellNameWidget->setCaption(spell->name);
@ -345,7 +343,7 @@ void MWSpell::shutdownWidgetSkin()
/* MWSpellEffect */ /* MWSpellEffect */
MWSpellEffect::MWSpellEffect() MWSpellEffect::MWSpellEffect()
: env(nullptr) : mWindowManager(nullptr)
, imageWidget(nullptr) , imageWidget(nullptr)
, textWidget(nullptr) , textWidget(nullptr)
{ {
@ -359,11 +357,10 @@ void MWSpellEffect::setSpellEffect(SpellEffectValue value)
void MWSpellEffect::updateWidgets() void MWSpellEffect::updateWidgets()
{ {
if (!env) if (!mWindowManager)
return; return;
ESMS::ESMStore &store = env->mWorld->getStore(); ESMS::ESMStore &store = mWindowManager->getStore();
WindowManager *wm = env->mWindowManager;
const ESM::MagicEffect *magicEffect = store.magicEffects.search(effect.effectID); const ESM::MagicEffect *magicEffect = store.magicEffects.search(effect.effectID);
if (textWidget) if (textWidget)
{ {
@ -373,7 +370,7 @@ void MWSpellEffect::updateWidgets()
std::string spellLine = ""; std::string spellLine = "";
if (effect.skill >= 0 && effect.skill < ESM::Skill::Length) if (effect.skill >= 0 && effect.skill < ESM::Skill::Length)
{ {
spellLine += " " + wm->getGameSettingString(ESM::Skill::sSkillNameIds[effect.skill], ""); spellLine += " " + mWindowManager->getGameSettingString(ESM::Skill::sSkillNameIds[effect.skill], "");
} }
if (effect.attribute >= 0 && effect.attribute < 8) if (effect.attribute >= 0 && effect.attribute < 8)
{ {
@ -387,7 +384,7 @@ void MWSpellEffect::updateWidgets()
"sAttributePersonality", "sAttributePersonality",
"sAttributeLuck" "sAttributeLuck"
}; };
spellLine += " " + wm->getGameSettingString(attributes[effect.attribute], ""); spellLine += " " + mWindowManager->getGameSettingString(attributes[effect.attribute], "");
} }
if (effect.magnMin >= 0 || effect.magnMax >= 0) if (effect.magnMin >= 0 || effect.magnMax >= 0)
{ {

View file

@ -7,11 +7,6 @@
#include "../mwmechanics/stat.hpp" #include "../mwmechanics/stat.hpp"
namespace MWWorld
{
class Environment;
}
/* /*
This file contains various custom widgets used in OpenMW. This file contains various custom widgets used in OpenMW.
*/ */
@ -129,11 +124,10 @@ namespace MWGui
typedef MWMechanics::Stat<int> SpellValue; typedef MWMechanics::Stat<int> SpellValue;
void setEnvironment(MWWorld::Environment *env_) { env = env_; } void setWindowManager(WindowManager* parWindowManager) { mWindowManager = parWindowManager; }
void setSpellId(const std::string &id); void setSpellId(const std::string &id);
void createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord); void createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord);
MWWorld::Environment *getEnvironment() const { return env; }
const std::string &getSpellId() const { return id; } const std::string &getSpellId() const { return id; }
/*internal:*/ /*internal:*/
@ -150,7 +144,7 @@ namespace MWGui
void updateWidgets(); void updateWidgets();
MWWorld::Environment *env; WindowManager* mWindowManager;
std::string id; std::string id;
MyGUI::StaticTextPtr spellNameWidget; MyGUI::StaticTextPtr spellNameWidget;
}; };
@ -164,10 +158,9 @@ namespace MWGui
typedef ESM::ENAMstruct SpellEffectValue; typedef ESM::ENAMstruct SpellEffectValue;
void setEnvironment(MWWorld::Environment *env_) { env = env_; } void setWindowManager(WindowManager* parWindowManager) { mWindowManager = parWindowManager; }
void setSpellEffect(SpellEffectValue value); void setSpellEffect(SpellEffectValue value);
MWWorld::Environment *getEnvironment() const { return env; }
const SpellEffectValue &getSpellEffect() const { return effect; } const SpellEffectValue &getSpellEffect() const { return effect; }
/*internal:*/ /*internal:*/
@ -184,7 +177,7 @@ namespace MWGui
void updateWidgets(); void updateWidgets();
MWWorld::Environment *env; WindowManager* mWindowManager;
SpellEffectValue effect; SpellEffectValue effect;
MyGUI::StaticImagePtr imageWidget; MyGUI::StaticImagePtr imageWidget;
MyGUI::StaticTextPtr textWidget; MyGUI::StaticTextPtr textWidget;

View file

@ -1,12 +1,11 @@
#include "window_base.hpp" #include "window_base.hpp"
#include "../mwworld/environment.hpp"
#include "window_manager.hpp" #include "window_manager.hpp"
using namespace MWGui; using namespace MWGui;
WindowBase::WindowBase(const std::string& parLayout, MWWorld::Environment& parEnvironment) WindowBase::WindowBase(const std::string& parLayout, WindowManager& parWindowManager)
: Layout(parLayout) : Layout(parLayout)
, environment(parEnvironment) , mWindowManager(parWindowManager)
{ {
} }
@ -17,7 +16,7 @@ void WindowBase::open()
void WindowBase::center() void WindowBase::center()
{ {
// Centre dialog // Centre dialog
MyGUI::IntSize gameWindowSize = environment.mWindowManager->getGui()->getViewSize(); MyGUI::IntSize gameWindowSize = mWindowManager.getGui()->getViewSize();
MyGUI::IntCoord coord = mMainWidget->getCoord(); MyGUI::IntCoord coord = mMainWidget->getCoord();
coord.left = (gameWindowSize.width - coord.width)/2; coord.left = (gameWindowSize.width - coord.width)/2;
coord.top = (gameWindowSize.height - coord.height)/2; coord.top = (gameWindowSize.height - coord.height)/2;

View file

@ -3,23 +3,20 @@
#include <openengine/gui/layout.hpp> #include <openengine/gui/layout.hpp>
namespace MWWorld
{
class Environment;
}
namespace MWGui namespace MWGui
{ {
class WindowManager;
class WindowBase: public OEngine::GUI::Layout class WindowBase: public OEngine::GUI::Layout
{ {
public: public:
WindowBase(const std::string& parLayout, MWWorld::Environment& parEnvironment); WindowBase(const std::string& parLayout, WindowManager& parWindowManager);
virtual void open(); virtual void open();
void center(); void center();
protected: protected:
MWWorld::Environment& environment; WindowManager& mWindowManager;
}; };
} }

View file

@ -55,7 +55,7 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment
hud = new HUD(w,h, showFPSCounter); hud = new HUD(w,h, showFPSCounter);
menu = new MainMenu(w,h); menu = new MainMenu(w,h);
map = new MapWindow(); map = new MapWindow();
stats = new StatsWindow (environment); stats = new StatsWindow(*this);
#if 0 #if 0
inventory = new InventoryWindow (); inventory = new InventoryWindow ();
#endif #endif
@ -180,7 +180,7 @@ void WindowManager::updateVisible()
{ {
if (nameDialog) if (nameDialog)
removeDialog(nameDialog); removeDialog(nameDialog);
nameDialog = new TextInputDialog(environment); nameDialog = new TextInputDialog(*this);
std::string sName = getGameSettingString("sName", "Name"); std::string sName = getGameSettingString("sName", "Name");
nameDialog->setTextLabel(sName); nameDialog->setTextLabel(sName);
nameDialog->setTextInput(playerName); nameDialog->setTextInput(playerName);
@ -194,7 +194,7 @@ void WindowManager::updateVisible()
{ {
if (raceDialog) if (raceDialog)
removeDialog(raceDialog); removeDialog(raceDialog);
raceDialog = new RaceDialog(environment); raceDialog = new RaceDialog(*this);
raceDialog->setNextButtonShow(creationStage >= RaceChosen); raceDialog->setNextButtonShow(creationStage >= RaceChosen);
raceDialog->setRaceId(playerRaceId); raceDialog->setRaceId(playerRaceId);
raceDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onRaceDialogDone); raceDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onRaceDialogDone);
@ -207,7 +207,7 @@ void WindowManager::updateVisible()
{ {
if (classChoiceDialog) if (classChoiceDialog)
removeDialog(classChoiceDialog); removeDialog(classChoiceDialog);
classChoiceDialog = new ClassChoiceDialog(environment); classChoiceDialog = new ClassChoiceDialog(*this);
classChoiceDialog->eventButtonSelected = MyGUI::newDelegate(this, &WindowManager::onClassChoice); classChoiceDialog->eventButtonSelected = MyGUI::newDelegate(this, &WindowManager::onClassChoice);
classChoiceDialog->open(); classChoiceDialog->open();
return; return;
@ -228,7 +228,7 @@ void WindowManager::updateVisible()
{ {
if (pickClassDialog) if (pickClassDialog)
removeDialog(pickClassDialog); removeDialog(pickClassDialog);
pickClassDialog = new PickClassDialog(environment); pickClassDialog = new PickClassDialog(*this);
pickClassDialog->setNextButtonShow(creationStage >= ClassChosen); pickClassDialog->setNextButtonShow(creationStage >= ClassChosen);
pickClassDialog->setClassId(playerClass.name); pickClassDialog->setClassId(playerClass.name);
pickClassDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onPickClassDialogDone); pickClassDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onPickClassDialogDone);
@ -241,7 +241,7 @@ void WindowManager::updateVisible()
{ {
if (createClassDialog) if (createClassDialog)
removeDialog(createClassDialog); removeDialog(createClassDialog);
createClassDialog = new CreateClassDialog(environment); createClassDialog = new CreateClassDialog(*this);
createClassDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onCreateClassDialogDone); createClassDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onCreateClassDialogDone);
createClassDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onCreateClassDialogBack); createClassDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onCreateClassDialogBack);
createClassDialog->open(); createClassDialog->open();
@ -252,7 +252,7 @@ void WindowManager::updateVisible()
{ {
if (birthSignDialog) if (birthSignDialog)
removeDialog(birthSignDialog); removeDialog(birthSignDialog);
birthSignDialog = new BirthDialog(environment); birthSignDialog = new BirthDialog(*this);
birthSignDialog->setNextButtonShow(creationStage >= BirthSignChosen); birthSignDialog->setNextButtonShow(creationStage >= BirthSignChosen);
birthSignDialog->setBirthId(playerBirthSignId); birthSignDialog->setBirthId(playerBirthSignId);
birthSignDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onBirthSignDialogDone); birthSignDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onBirthSignDialogDone);
@ -265,7 +265,7 @@ void WindowManager::updateVisible()
{ {
if (reviewDialog) if (reviewDialog)
removeDialog(reviewDialog); removeDialog(reviewDialog);
reviewDialog = new ReviewDialog(environment); reviewDialog = new ReviewDialog(*this);
reviewDialog->setPlayerName(playerName); reviewDialog->setPlayerName(playerName);
reviewDialog->setRace(playerRaceId); reviewDialog->setRace(playerRaceId);
reviewDialog->setClass(playerClass); reviewDialog->setClass(playerClass);
@ -318,10 +318,11 @@ void WindowManager::updateVisible()
if (mode == GM_Dialogue) if (mode == GM_Dialogue)
{ {
if (dialogueWindow) if (!dialogueWindow)
removeDialog(dialogueWindow); {
dialogueWindow = new DialogueWindow(environment); dialogueWindow = new DialogueWindow(*this);
dialogueWindow->eventBye = MyGUI::newDelegate(this, &WindowManager::onDialogueWindowBye); dialogueWindow->eventBye = MyGUI::newDelegate(this, &WindowManager::onDialogueWindowBye);
}
dialogueWindow->open(); dialogueWindow->open();
return; return;
} }
@ -702,7 +703,7 @@ void WindowManager::showClassQuestionDialog()
if (generateClassResultDialog) if (generateClassResultDialog)
removeDialog(generateClassResultDialog); removeDialog(generateClassResultDialog);
generateClassResultDialog = new GenerateClassResultDialog(environment); generateClassResultDialog = new GenerateClassResultDialog(*this);
generateClassResultDialog->setClassId(generateClass); generateClassResultDialog->setClassId(generateClass);
generateClassResultDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onGenerateClassBack); generateClassResultDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onGenerateClassBack);
generateClassResultDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onGenerateClassDone); generateClassResultDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onGenerateClassDone);
@ -718,7 +719,7 @@ void WindowManager::showClassQuestionDialog()
if (generateClassQuestionDialog) if (generateClassQuestionDialog)
removeDialog(generateClassQuestionDialog); removeDialog(generateClassQuestionDialog);
generateClassQuestionDialog = new InfoBoxDialog(environment); generateClassQuestionDialog = new InfoBoxDialog(*this);
InfoBoxDialog::ButtonList buttons; InfoBoxDialog::ButtonList buttons;
generateClassQuestionDialog->setText(generateClassSteps[generateClassStep].text); generateClassQuestionDialog->setText(generateClassSteps[generateClassStep].text);
@ -938,3 +939,8 @@ void WindowManager::onReviewActivateDialog(int parDialog)
setGuiMode(GM_Birth); setGuiMode(GM_Birth);
}; };
} }
ESMS::ESMStore& WindowManager::getStore()
{
return environment.mWorld->getStore();
}

View file

@ -256,6 +256,8 @@ namespace MWGui
*/ */
const std::string &getGameSettingString(const std::string &id, const std::string &default_); const std::string &getGameSettingString(const std::string &id, const std::string &default_);
ESMS::ESMStore& getStore();
private: private:
void onDialogueWindowBye(); void onDialogueWindowBye();