Decrease number of classes that need to know about other components

actorid
Jan-Peter Nilsson 14 years ago
parent 67b4243a7f
commit 54fc64cb6a

@ -1,6 +1,4 @@
#include "birth.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include "window_manager.hpp"
#include "widgets.hpp"
#include "components/esm_store/store.hpp"
@ -11,8 +9,8 @@
using namespace MWGui;
using namespace Widgets;
BirthDialog::BirthDialog(MWWorld::Environment& environment)
: WindowBase("openmw_chargen_birth_layout.xml", environment)
BirthDialog::BirthDialog(WindowManager& parWindowManager)
: WindowBase("openmw_chargen_birth_layout.xml", parWindowManager)
{
// Centre dialog
center();
@ -121,7 +119,7 @@ void BirthDialog::updateBirths()
{
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 end = store.birthSigns.list.end();
@ -151,7 +149,7 @@ void BirthDialog::updateSpells()
const int lineHeight = 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);
std::string texturePath = std::string("textures\\") + birth->texture;
@ -191,7 +189,7 @@ void BirthDialog::updateSpells()
if (!categories[category].spells.empty())
{
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);
coord.top += lineHeight;
@ -200,7 +198,7 @@ void BirthDialog::updateSpells()
{
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->setEnvironment(&environment);
spellWidget->setWindowManager(&mWindowManager);
spellWidget->setSpellId(spellId);
spellItems.push_back(spellWidget);

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

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

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

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

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

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

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

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

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

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

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

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

@ -1,8 +1,7 @@
#include "stats_window.hpp"
#include "../mwworld/class.hpp"
#include "../mwmechanics/mechanicsmanager.hpp"
#include "../mwgui/window_manager.hpp"
#include "window_manager.hpp"
#include <cmath>
#include <algorithm>
@ -12,8 +11,8 @@
using namespace MWGui;
const int StatsWindow::lineHeight = 18;
StatsWindow::StatsWindow (MWWorld::Environment& environment)
: WindowBase("openmw_stats_window_layout.xml", environment)
StatsWindow::StatsWindow (WindowManager& parWindowManager)
: WindowBase("openmw_stats_window_layout.xml", parWindowManager)
, lastPos(0)
, reputation(0)
, bounty(0)
@ -39,7 +38,7 @@ StatsWindow::StatsWindow (MWWorld::Environment& environment)
{ 0, 0 }
};
const ESMS::ESMStore &store = environment.mWorld->getStore();
const ESMS::ESMStore &store = mWindowManager.getStore();
for (int i=0; names[i][0]; ++i)
{
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)
{
WindowManager *wm = environment.mWindowManager;
// Add a line separator if there are items above
if (!skillWidgets.empty())
{
addSeparator(coord1, coord2);
}
addGroup(wm->getGameSettingString(titleId, titleDefault), coord1, coord2);
addGroup(mWindowManager.getGameSettingString(titleId, titleDefault), coord1, coord2);
SkillList::const_iterator end = skills.end();
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;
else if (modified < base)
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;
}
}
@ -326,8 +323,7 @@ void StatsWindow::updateSkillArea()
if (!miscSkills.empty())
addSkills(miscSkills, "sSkillClassMisc", "Misc Skills", coord1, coord2);
WindowManager *wm = environment.mWindowManager;
ESMS::ESMStore &store = environment.mWorld->getStore();
ESMS::ESMStore &store = mWindowManager.getStore();
if (!factions.empty())
{
@ -335,7 +331,7 @@ void StatsWindow::updateSkillArea()
if (!skillWidgets.empty())
addSeparator(coord1, coord2);
addGroup(wm->getGameSettingString("sFaction", "Faction"), coord1, coord2);
addGroup(mWindowManager.getGameSettingString("sFaction", "Faction"), coord1, coord2);
FactionList::const_iterator end = factions.end();
for (FactionList::const_iterator it = factions.begin(); it != end; ++it)
{
@ -351,7 +347,7 @@ void StatsWindow::updateSkillArea()
if (!skillWidgets.empty())
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);
addItem(sign->name, coord1, coord2);
}
@ -360,8 +356,8 @@ void StatsWindow::updateSkillArea()
if (!skillWidgets.empty())
addSeparator(coord1, coord2);
addValueItem(wm->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("sReputation", "Reputation"), boost::lexical_cast<std::string>(static_cast<int>(reputation)), 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;
updateScroller();

@ -3,21 +3,17 @@
#include <components/esm_store/store.hpp>
#include <openengine/gui/layout.hpp>
#include <boost/array.hpp>
#include <sstream>
#include <set>
#include <string>
#include <utility>
#include "../mwmechanics/stat.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
#include "window_base.hpp"
namespace MWGui
{
class WindowManager;
class StatsWindow : public WindowBase
{
@ -27,7 +23,7 @@ namespace MWGui
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 setPlayerName(const std::string& playerName);

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

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

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

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

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

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

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

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

Loading…
Cancel
Save