mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 18:35:20 +00:00
Merge branch 'dialog_unique_ptr' into 'master'
Use std::unique_ptr to manage dialogs lifetime See merge request OpenMW/openmw!2323
This commit is contained in:
commit
f888d85429
@ -6,6 +6,7 @@
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <memory>
|
||||
|
||||
#include <MyGUI_KeyCode.h>
|
||||
|
||||
@ -232,7 +233,7 @@ namespace MWBase
|
||||
virtual void addVisitedLocation(const std::string& name, int x, int y) = 0;
|
||||
|
||||
/// Hides dialog and schedules dialog to be deleted.
|
||||
virtual void removeDialog(MWGui::Layout* dialog) = 0;
|
||||
virtual void removeDialog(std::unique_ptr<MWGui::Layout>&& dialog) = 0;
|
||||
|
||||
///Gracefully attempts to exit the topmost GUI mode
|
||||
/** No guarantee of actually closing the window **/
|
||||
|
@ -82,15 +82,6 @@ namespace MWGui
|
||||
CharacterCreation::CharacterCreation(osg::Group* parent, Resource::ResourceSystem* resourceSystem)
|
||||
: mParent(parent)
|
||||
, mResourceSystem(resourceSystem)
|
||||
, mNameDialog(nullptr)
|
||||
, mRaceDialog(nullptr)
|
||||
, mClassChoiceDialog(nullptr)
|
||||
, mGenerateClassQuestionDialog(nullptr)
|
||||
, mGenerateClassResultDialog(nullptr)
|
||||
, mPickClassDialog(nullptr)
|
||||
, mCreateClassDialog(nullptr)
|
||||
, mBirthSignDialog(nullptr)
|
||||
, mReviewDialog(nullptr)
|
||||
, mGenerateClassStep(0)
|
||||
{
|
||||
mCreationStage = CSE_NotStarted;
|
||||
@ -178,9 +169,8 @@ namespace MWGui
|
||||
switch (id)
|
||||
{
|
||||
case GM_Name:
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(mNameDialog);
|
||||
mNameDialog = nullptr;
|
||||
mNameDialog = new TextInputDialog();
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(std::move(mNameDialog));
|
||||
mNameDialog = std::make_unique<TextInputDialog>();
|
||||
mNameDialog->setTextLabel(MWBase::Environment::get().getWindowManager()->getGameSettingString("sName", "Name"));
|
||||
mNameDialog->setTextInput(mPlayerName);
|
||||
mNameDialog->setNextButtonShow(mCreationStage >= CSE_NameChosen);
|
||||
@ -189,9 +179,8 @@ namespace MWGui
|
||||
break;
|
||||
|
||||
case GM_Race:
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(mRaceDialog);
|
||||
mRaceDialog = nullptr;
|
||||
mRaceDialog = new RaceDialog(mParent, mResourceSystem);
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(std::move(mRaceDialog));
|
||||
mRaceDialog = std::make_unique<RaceDialog>(mParent, mResourceSystem);
|
||||
mRaceDialog->setNextButtonShow(mCreationStage >= CSE_RaceChosen);
|
||||
mRaceDialog->setRaceId(mPlayerRaceId);
|
||||
mRaceDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onRaceDialogDone);
|
||||
@ -202,9 +191,8 @@ namespace MWGui
|
||||
break;
|
||||
|
||||
case GM_Class:
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(mClassChoiceDialog);
|
||||
mClassChoiceDialog = nullptr;
|
||||
mClassChoiceDialog = new ClassChoiceDialog();
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(std::move(mClassChoiceDialog));
|
||||
mClassChoiceDialog = std::make_unique<ClassChoiceDialog>();
|
||||
mClassChoiceDialog->eventButtonSelected += MyGUI::newDelegate(this, &CharacterCreation::onClassChoice);
|
||||
mClassChoiceDialog->setVisible(true);
|
||||
if (mCreationStage < CSE_RaceChosen)
|
||||
@ -212,9 +200,8 @@ namespace MWGui
|
||||
break;
|
||||
|
||||
case GM_ClassPick:
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(mPickClassDialog);
|
||||
mPickClassDialog = nullptr;
|
||||
mPickClassDialog = new PickClassDialog();
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(std::move(mPickClassDialog));
|
||||
mPickClassDialog = std::make_unique<PickClassDialog>();
|
||||
mPickClassDialog->setNextButtonShow(mCreationStage >= CSE_ClassChosen);
|
||||
mPickClassDialog->setClassId(mPlayerClass.mId);
|
||||
mPickClassDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onPickClassDialogDone);
|
||||
@ -225,9 +212,8 @@ namespace MWGui
|
||||
break;
|
||||
|
||||
case GM_Birth:
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(mBirthSignDialog);
|
||||
mBirthSignDialog = nullptr;
|
||||
mBirthSignDialog = new BirthDialog();
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(std::move(mBirthSignDialog));
|
||||
mBirthSignDialog = std::make_unique<BirthDialog>();
|
||||
mBirthSignDialog->setNextButtonShow(mCreationStage >= CSE_BirthSignChosen);
|
||||
mBirthSignDialog->setBirthId(mPlayerBirthSignId);
|
||||
mBirthSignDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogDone);
|
||||
@ -238,9 +224,9 @@ namespace MWGui
|
||||
break;
|
||||
|
||||
case GM_ClassCreate:
|
||||
if (!mCreateClassDialog)
|
||||
if (mCreateClassDialog == nullptr)
|
||||
{
|
||||
mCreateClassDialog = new CreateClassDialog();
|
||||
mCreateClassDialog = std::make_unique<CreateClassDialog>();
|
||||
mCreateClassDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onCreateClassDialogDone);
|
||||
mCreateClassDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onCreateClassDialogBack);
|
||||
}
|
||||
@ -260,9 +246,8 @@ namespace MWGui
|
||||
mCreationStage = CSE_RaceChosen;
|
||||
break;
|
||||
case GM_Review:
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(mReviewDialog);
|
||||
mReviewDialog = nullptr;
|
||||
mReviewDialog = new ReviewDialog();
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(std::move(mReviewDialog));
|
||||
mReviewDialog = std::make_unique<ReviewDialog>();
|
||||
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
|
||||
@ -310,16 +295,13 @@ namespace MWGui
|
||||
|
||||
void CharacterCreation::onReviewDialogDone(WindowBase* parWindow)
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(mReviewDialog);
|
||||
mReviewDialog = nullptr;
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(std::move(mReviewDialog));
|
||||
MWBase::Environment::get().getWindowManager()->popGuiMode();
|
||||
}
|
||||
|
||||
void CharacterCreation::onReviewDialogBack()
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(mReviewDialog);
|
||||
mReviewDialog = nullptr;
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(std::move(mReviewDialog));
|
||||
mCreationStage = CSE_ReviewBack;
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->popGuiMode();
|
||||
@ -328,8 +310,7 @@ namespace MWGui
|
||||
|
||||
void CharacterCreation::onReviewActivateDialog(int parDialog)
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(mReviewDialog);
|
||||
mReviewDialog = nullptr;
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(std::move(mReviewDialog));
|
||||
mCreationStage = CSE_ReviewNext;
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->popGuiMode();
|
||||
@ -364,8 +345,7 @@ namespace MWGui
|
||||
{
|
||||
mPlayerClass = *klass;
|
||||
}
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(mPickClassDialog);
|
||||
mPickClassDialog = nullptr;
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(std::move(mPickClassDialog));
|
||||
}
|
||||
}
|
||||
|
||||
@ -386,8 +366,7 @@ namespace MWGui
|
||||
|
||||
void CharacterCreation::onClassChoice(int _index)
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(mClassChoiceDialog);
|
||||
mClassChoiceDialog = nullptr;
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(std::move(mClassChoiceDialog));
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->popGuiMode();
|
||||
|
||||
@ -415,8 +394,7 @@ namespace MWGui
|
||||
{
|
||||
mPlayerName = mNameDialog->getTextInput();
|
||||
MWBase::Environment::get().getMechanicsManager()->setPlayerName(mPlayerName);
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(mNameDialog);
|
||||
mNameDialog = nullptr;
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(std::move(mNameDialog));
|
||||
}
|
||||
|
||||
handleDialogDone(CSE_NameChosen, GM_Race);
|
||||
@ -438,8 +416,7 @@ namespace MWGui
|
||||
}
|
||||
MWBase::Environment::get().getWindowManager()->getInventoryWindow()->rebuildAvatar();
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(mRaceDialog);
|
||||
mRaceDialog = nullptr;
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(std::move(mRaceDialog));
|
||||
}
|
||||
}
|
||||
|
||||
@ -465,8 +442,7 @@ namespace MWGui
|
||||
mPlayerBirthSignId = mBirthSignDialog->getBirthId();
|
||||
if (!mPlayerBirthSignId.empty())
|
||||
MWBase::Environment::get().getMechanicsManager()->setPlayerBirthsign(mPlayerBirthSignId);
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(mBirthSignDialog);
|
||||
mBirthSignDialog = nullptr;
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(std::move(mBirthSignDialog));
|
||||
}
|
||||
}
|
||||
|
||||
@ -539,8 +515,7 @@ namespace MWGui
|
||||
{
|
||||
MWBase::Environment::get().getSoundManager()->stopSay();
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(mGenerateClassQuestionDialog);
|
||||
mGenerateClassQuestionDialog = nullptr;
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(std::move(mGenerateClassQuestionDialog));
|
||||
|
||||
if (_index < 0 || _index >= 3)
|
||||
{
|
||||
@ -657,10 +632,9 @@ namespace MWGui
|
||||
}
|
||||
}
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(mGenerateClassResultDialog);
|
||||
mGenerateClassResultDialog = nullptr;
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(std::move(mGenerateClassResultDialog));
|
||||
|
||||
mGenerateClassResultDialog = new GenerateClassResultDialog();
|
||||
mGenerateClassResultDialog = std::make_unique<GenerateClassResultDialog>();
|
||||
mGenerateClassResultDialog->setClassId(mGenerateClass);
|
||||
mGenerateClassResultDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onGenerateClassBack);
|
||||
mGenerateClassResultDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onGenerateClassDone);
|
||||
@ -675,10 +649,9 @@ namespace MWGui
|
||||
return;
|
||||
}
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(mGenerateClassQuestionDialog);
|
||||
mGenerateClassQuestionDialog = nullptr;
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(std::move(mGenerateClassQuestionDialog));
|
||||
|
||||
mGenerateClassQuestionDialog = new InfoBoxDialog();
|
||||
mGenerateClassQuestionDialog = std::make_unique<InfoBoxDialog>();
|
||||
|
||||
Step step = sGenerateClassSteps(mGenerateClassStep);
|
||||
mGenerateClassResponses[0] = step.mResponses[0].mSpecialization;
|
||||
@ -699,8 +672,7 @@ namespace MWGui
|
||||
|
||||
void CharacterCreation::selectGeneratedClass()
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(mGenerateClassResultDialog);
|
||||
mGenerateClassResultDialog = nullptr;
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(std::move(mGenerateClassResultDialog));
|
||||
|
||||
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(mGenerateClass);
|
||||
|
||||
@ -725,18 +697,7 @@ namespace MWGui
|
||||
handleDialogDone(CSE_ClassChosen, GM_Birth);
|
||||
}
|
||||
|
||||
CharacterCreation::~CharacterCreation()
|
||||
{
|
||||
delete mNameDialog;
|
||||
delete mRaceDialog;
|
||||
delete mClassChoiceDialog;
|
||||
delete mGenerateClassQuestionDialog;
|
||||
delete mGenerateClassResultDialog;
|
||||
delete mPickClassDialog;
|
||||
delete mCreateClassDialog;
|
||||
delete mBirthSignDialog;
|
||||
delete mReviewDialog;
|
||||
}
|
||||
CharacterCreation::~CharacterCreation() = default;
|
||||
|
||||
void CharacterCreation::handleDialogDone(CSE currentStage, int nextMode)
|
||||
{
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
#include "statswatcher.hpp"
|
||||
|
||||
@ -61,15 +62,15 @@ namespace MWGui
|
||||
std::map<int, MWMechanics::SkillValue> mPlayerSkillValues;
|
||||
|
||||
//Dialogs
|
||||
TextInputDialog* mNameDialog;
|
||||
RaceDialog* mRaceDialog;
|
||||
ClassChoiceDialog* mClassChoiceDialog;
|
||||
InfoBoxDialog* mGenerateClassQuestionDialog;
|
||||
GenerateClassResultDialog* mGenerateClassResultDialog;
|
||||
PickClassDialog* mPickClassDialog;
|
||||
CreateClassDialog* mCreateClassDialog;
|
||||
BirthDialog* mBirthSignDialog;
|
||||
ReviewDialog* mReviewDialog;
|
||||
std::unique_ptr<TextInputDialog> mNameDialog;
|
||||
std::unique_ptr<RaceDialog> mRaceDialog;
|
||||
std::unique_ptr<ClassChoiceDialog> mClassChoiceDialog;
|
||||
std::unique_ptr<InfoBoxDialog> mGenerateClassQuestionDialog;
|
||||
std::unique_ptr<GenerateClassResultDialog> mGenerateClassResultDialog;
|
||||
std::unique_ptr<PickClassDialog> mPickClassDialog;
|
||||
std::unique_ptr<CreateClassDialog> mCreateClassDialog;
|
||||
std::unique_ptr<BirthDialog> mBirthSignDialog;
|
||||
std::unique_ptr<ReviewDialog> mReviewDialog;
|
||||
|
||||
//Player data
|
||||
std::string mPlayerName;
|
||||
|
@ -399,10 +399,6 @@ namespace MWGui
|
||||
|
||||
CreateClassDialog::CreateClassDialog()
|
||||
: WindowModal("openmw_chargen_create_class.layout")
|
||||
, mSpecDialog(nullptr)
|
||||
, mAttribDialog(nullptr)
|
||||
, mSkillDialog(nullptr)
|
||||
, mDescDialog(nullptr)
|
||||
, mAffectedAttribute(nullptr)
|
||||
, mAffectedSkill(nullptr)
|
||||
{
|
||||
@ -474,13 +470,7 @@ namespace MWGui
|
||||
update();
|
||||
}
|
||||
|
||||
CreateClassDialog::~CreateClassDialog()
|
||||
{
|
||||
delete mSpecDialog;
|
||||
delete mAttribDialog;
|
||||
delete mSkillDialog;
|
||||
delete mDescDialog;
|
||||
}
|
||||
CreateClassDialog::~CreateClassDialog() = default;
|
||||
|
||||
void CreateClassDialog::update()
|
||||
{
|
||||
@ -554,23 +544,15 @@ namespace MWGui
|
||||
|
||||
void CreateClassDialog::onDialogCancel()
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(mSpecDialog);
|
||||
mSpecDialog = nullptr;
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(mAttribDialog);
|
||||
mAttribDialog = nullptr;
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(mSkillDialog);
|
||||
mSkillDialog = nullptr;
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(mDescDialog);
|
||||
mDescDialog = nullptr;
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(std::move(mSpecDialog));
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(std::move(mAttribDialog));
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(std::move(mSkillDialog));
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(std::move(mDescDialog));
|
||||
}
|
||||
|
||||
void CreateClassDialog::onSpecializationClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
delete mSpecDialog;
|
||||
mSpecDialog = new SelectSpecializationDialog();
|
||||
mSpecDialog = std::make_unique<SelectSpecializationDialog>();
|
||||
mSpecDialog->eventCancel += MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel);
|
||||
mSpecDialog->eventItemSelected += MyGUI::newDelegate(this, &CreateClassDialog::onSpecializationSelected);
|
||||
mSpecDialog->setVisible(true);
|
||||
@ -581,8 +563,7 @@ namespace MWGui
|
||||
mSpecializationId = mSpecDialog->getSpecializationId();
|
||||
setSpecialization(mSpecializationId);
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(mSpecDialog);
|
||||
mSpecDialog = nullptr;
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(std::move(mSpecDialog));
|
||||
}
|
||||
|
||||
void CreateClassDialog::setSpecialization(int id)
|
||||
@ -600,8 +581,7 @@ namespace MWGui
|
||||
|
||||
void CreateClassDialog::onAttributeClicked(Widgets::MWAttributePtr _sender)
|
||||
{
|
||||
delete mAttribDialog;
|
||||
mAttribDialog = new SelectAttributeDialog();
|
||||
mAttribDialog = std::make_unique<SelectAttributeDialog>();
|
||||
mAffectedAttribute = _sender;
|
||||
mAttribDialog->eventCancel += MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel);
|
||||
mAttribDialog->eventItemSelected += MyGUI::newDelegate(this, &CreateClassDialog::onAttributeSelected);
|
||||
@ -622,16 +602,14 @@ namespace MWGui
|
||||
mFavoriteAttribute0->setAttributeId(mFavoriteAttribute1->getAttributeId());
|
||||
}
|
||||
mAffectedAttribute->setAttributeId(id);
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(mAttribDialog);
|
||||
mAttribDialog = nullptr;
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(std::move(mAttribDialog));
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
void CreateClassDialog::onSkillClicked(Widgets::MWSkillPtr _sender)
|
||||
{
|
||||
delete mSkillDialog;
|
||||
mSkillDialog = new SelectSkillDialog();
|
||||
mSkillDialog = std::make_unique<SelectSkillDialog>();
|
||||
mAffectedSkill = _sender;
|
||||
mSkillDialog->eventCancel += MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel);
|
||||
mSkillDialog->eventItemSelected += MyGUI::newDelegate(this, &CreateClassDialog::onSkillSelected);
|
||||
@ -655,14 +633,13 @@ namespace MWGui
|
||||
}
|
||||
|
||||
mAffectedSkill->setSkillId(mSkillDialog->getSkillId());
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(mSkillDialog);
|
||||
mSkillDialog = nullptr;
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(std::move(mSkillDialog));
|
||||
update();
|
||||
}
|
||||
|
||||
void CreateClassDialog::onDescriptionClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
mDescDialog = new DescriptionDialog();
|
||||
mDescDialog = std::make_unique<DescriptionDialog>();
|
||||
mDescDialog->setTextInput(mDescription);
|
||||
mDescDialog->eventDone += MyGUI::newDelegate(this, &CreateClassDialog::onDescriptionEntered);
|
||||
mDescDialog->setVisible(true);
|
||||
@ -671,8 +648,7 @@ namespace MWGui
|
||||
void CreateClassDialog::onDescriptionEntered(WindowBase* parWindow)
|
||||
{
|
||||
mDescription = mDescDialog->getTextInput();
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(mDescDialog);
|
||||
mDescDialog = nullptr;
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(std::move(mDescDialog));
|
||||
}
|
||||
|
||||
void CreateClassDialog::onOkClicked(MyGUI::Widget* _sender)
|
||||
|
@ -1,6 +1,8 @@
|
||||
#ifndef MWGUI_CLASS_H
|
||||
#define MWGUI_CLASS_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <MyGUI_EditBox.h>
|
||||
|
||||
#include <components/esm/attr.hpp>
|
||||
@ -322,10 +324,10 @@ namespace MWGui
|
||||
std::vector<Widgets::MWSkillPtr> mSkills;
|
||||
std::string mDescription;
|
||||
|
||||
SelectSpecializationDialog *mSpecDialog;
|
||||
SelectAttributeDialog *mAttribDialog;
|
||||
SelectSkillDialog *mSkillDialog;
|
||||
DescriptionDialog *mDescDialog;
|
||||
std::unique_ptr<SelectSpecializationDialog> mSpecDialog;
|
||||
std::unique_ptr<SelectAttributeDialog> mAttribDialog;
|
||||
std::unique_ptr<SelectSkillDialog> mSkillDialog;
|
||||
std::unique_ptr<DescriptionDialog> mDescDialog;
|
||||
|
||||
ESM::Class::Specialization mSpecializationId;
|
||||
|
||||
|
@ -28,7 +28,6 @@ namespace MWGui
|
||||
|
||||
Recharge::Recharge()
|
||||
: WindowBase("openmw_recharge_dialog.layout")
|
||||
, mItemSelectionDialog(nullptr)
|
||||
{
|
||||
getWidget(mBox, "Box");
|
||||
getWidget(mGemBox, "GemBox");
|
||||
@ -101,8 +100,7 @@ void Recharge::onCancel(MyGUI::Widget *sender)
|
||||
|
||||
void Recharge::onSelectItem(MyGUI::Widget *sender)
|
||||
{
|
||||
delete mItemSelectionDialog;
|
||||
mItemSelectionDialog = new ItemSelectionDialog("#{sSoulGemsWithSouls}");
|
||||
mItemSelectionDialog = std::make_unique<ItemSelectionDialog>("#{sSoulGemsWithSouls}");
|
||||
mItemSelectionDialog->eventItemSelected += MyGUI::newDelegate(this, &Recharge::onItemSelected);
|
||||
mItemSelectionDialog->eventDialogCanceled += MyGUI::newDelegate(this, &Recharge::onItemCancel);
|
||||
mItemSelectionDialog->setVisible(true);
|
||||
|
@ -1,6 +1,8 @@
|
||||
#ifndef OPENMW_MWGUI_RECHARGE_H
|
||||
#define OPENMW_MWGUI_RECHARGE_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "windowbase.hpp"
|
||||
|
||||
namespace MWWorld
|
||||
@ -31,7 +33,7 @@ protected:
|
||||
|
||||
ItemWidget* mGemIcon;
|
||||
|
||||
ItemSelectionDialog* mItemSelectionDialog;
|
||||
std::unique_ptr<ItemSelectionDialog> mItemSelectionDialog;
|
||||
|
||||
MyGUI::TextBox* mChargeLabel;
|
||||
|
||||
|
@ -26,7 +26,6 @@ namespace MWGui
|
||||
|
||||
Repair::Repair()
|
||||
: WindowBase("openmw_repair.layout")
|
||||
, mItemSelectionDialog(nullptr)
|
||||
{
|
||||
getWidget(mRepairBox, "RepairBox");
|
||||
getWidget(mToolBox, "ToolBox");
|
||||
@ -107,8 +106,7 @@ void Repair::updateRepairView()
|
||||
|
||||
void Repair::onSelectItem(MyGUI::Widget *sender)
|
||||
{
|
||||
delete mItemSelectionDialog;
|
||||
mItemSelectionDialog = new ItemSelectionDialog("#{sRepair}");
|
||||
mItemSelectionDialog = std::make_unique<ItemSelectionDialog>("#{sRepair}");
|
||||
mItemSelectionDialog->eventItemSelected += MyGUI::newDelegate(this, &Repair::onItemSelected);
|
||||
mItemSelectionDialog->eventDialogCanceled += MyGUI::newDelegate(this, &Repair::onItemCancel);
|
||||
mItemSelectionDialog->setVisible(true);
|
||||
|
@ -1,6 +1,8 @@
|
||||
#ifndef OPENMW_MWGUI_REPAIR_H
|
||||
#define OPENMW_MWGUI_REPAIR_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "windowbase.hpp"
|
||||
|
||||
#include "../mwmechanics/repair.hpp"
|
||||
@ -28,7 +30,7 @@ protected:
|
||||
|
||||
ItemWidget* mToolIcon;
|
||||
|
||||
ItemSelectionDialog* mItemSelectionDialog;
|
||||
std::unique_ptr<ItemSelectionDialog> mItemSelectionDialog;
|
||||
|
||||
MyGUI::TextBox* mUsesLabel;
|
||||
MyGUI::TextBox* mQualityLabel;
|
||||
|
@ -493,8 +493,6 @@ namespace MWGui
|
||||
: mAvailableEffectsList(nullptr)
|
||||
, mUsedEffectsView(nullptr)
|
||||
, mAddEffectDialog()
|
||||
, mSelectAttributeDialog(nullptr)
|
||||
, mSelectSkillDialog(nullptr)
|
||||
, mSelectedEffect(0)
|
||||
, mSelectedKnownEffectId(0)
|
||||
, mConstantEffect(false)
|
||||
@ -584,8 +582,7 @@ namespace MWGui
|
||||
|
||||
mAddEffectDialog.newEffect(effect);
|
||||
mAddEffectDialog.setAttribute (mSelectAttributeDialog->getAttributeId());
|
||||
MWBase::Environment::get().getWindowManager ()->removeDialog (mSelectAttributeDialog);
|
||||
mSelectAttributeDialog = nullptr;
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(std::move(mSelectAttributeDialog));
|
||||
}
|
||||
|
||||
void EffectEditorBase::onSelectSkill ()
|
||||
@ -595,19 +592,15 @@ namespace MWGui
|
||||
|
||||
mAddEffectDialog.newEffect(effect);
|
||||
mAddEffectDialog.setSkill (mSelectSkillDialog->getSkillId());
|
||||
MWBase::Environment::get().getWindowManager ()->removeDialog (mSelectSkillDialog);
|
||||
mSelectSkillDialog = nullptr;
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(std::move(mSelectSkillDialog));
|
||||
}
|
||||
|
||||
void EffectEditorBase::onAttributeOrSkillCancel ()
|
||||
{
|
||||
if (mSelectSkillDialog)
|
||||
MWBase::Environment::get().getWindowManager ()->removeDialog (mSelectSkillDialog);
|
||||
if (mSelectAttributeDialog)
|
||||
MWBase::Environment::get().getWindowManager ()->removeDialog (mSelectAttributeDialog);
|
||||
|
||||
mSelectSkillDialog = nullptr;
|
||||
mSelectAttributeDialog = nullptr;
|
||||
if (mSelectSkillDialog != nullptr)
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(std::move(mSelectSkillDialog));
|
||||
if (mSelectAttributeDialog != nullptr)
|
||||
MWBase::Environment::get().getWindowManager()->removeDialog(std::move(mSelectAttributeDialog));
|
||||
}
|
||||
|
||||
void EffectEditorBase::onAvailableEffectClicked (MyGUI::Widget* sender)
|
||||
@ -633,16 +626,14 @@ namespace MWGui
|
||||
|
||||
if (effect->mData.mFlags & ESM::MagicEffect::TargetSkill)
|
||||
{
|
||||
delete mSelectSkillDialog;
|
||||
mSelectSkillDialog = new SelectSkillDialog();
|
||||
mSelectSkillDialog = std::make_unique<SelectSkillDialog>();
|
||||
mSelectSkillDialog->eventCancel += MyGUI::newDelegate(this, &SpellCreationDialog::onAttributeOrSkillCancel);
|
||||
mSelectSkillDialog->eventItemSelected += MyGUI::newDelegate(this, &SpellCreationDialog::onSelectSkill);
|
||||
mSelectSkillDialog->setVisible (true);
|
||||
}
|
||||
else if (effect->mData.mFlags & ESM::MagicEffect::TargetAttribute)
|
||||
{
|
||||
delete mSelectAttributeDialog;
|
||||
mSelectAttributeDialog = new SelectAttributeDialog();
|
||||
mSelectAttributeDialog = std::make_unique<SelectAttributeDialog>();
|
||||
mSelectAttributeDialog->eventCancel += MyGUI::newDelegate(this, &SpellCreationDialog::onAttributeOrSkillCancel);
|
||||
mSelectAttributeDialog->eventItemSelected += MyGUI::newDelegate(this, &SpellCreationDialog::onSelectAttribute);
|
||||
mSelectAttributeDialog->setVisible (true);
|
||||
|
@ -1,6 +1,8 @@
|
||||
#ifndef MWGUI_SPELLCREATION_H
|
||||
#define MWGUI_SPELLCREATION_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <components/esm3/loadmgef.hpp>
|
||||
#include <components/esm3/loadspel.hpp>
|
||||
|
||||
@ -112,8 +114,8 @@ namespace MWGui
|
||||
MyGUI::ScrollView* mUsedEffectsView;
|
||||
|
||||
EditEffectDialog mAddEffectDialog;
|
||||
SelectAttributeDialog* mSelectAttributeDialog;
|
||||
SelectSkillDialog* mSelectSkillDialog;
|
||||
std::unique_ptr<SelectAttributeDialog> mSelectAttributeDialog;
|
||||
std::unique_ptr<SelectSkillDialog> mSelectSkillDialog;
|
||||
|
||||
int mSelectedEffect;
|
||||
short mSelectedKnownEffectId;
|
||||
|
@ -565,14 +565,7 @@ namespace MWGui
|
||||
void WindowManager::cleanupGarbage()
|
||||
{
|
||||
// Delete any dialogs which are no longer in use
|
||||
if (!mGarbageDialogs.empty())
|
||||
{
|
||||
for (Layout* widget : mGarbageDialogs)
|
||||
{
|
||||
delete widget;
|
||||
}
|
||||
mGarbageDialogs.clear();
|
||||
}
|
||||
mGarbageDialogs.clear();
|
||||
}
|
||||
|
||||
void WindowManager::enableScene(bool enable)
|
||||
@ -691,12 +684,12 @@ namespace MWGui
|
||||
mHud->setDrowningTimeLeft(time, maxTime);
|
||||
}
|
||||
|
||||
void WindowManager::removeDialog(Layout*dialog)
|
||||
void WindowManager::removeDialog(std::unique_ptr<Layout>&& dialog)
|
||||
{
|
||||
if (!dialog)
|
||||
return;
|
||||
dialog->setVisible(false);
|
||||
mGarbageDialogs.push_back(dialog);
|
||||
mGarbageDialogs.push_back(std::move(dialog));
|
||||
}
|
||||
|
||||
void WindowManager::exitCurrentGuiMode()
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include <stack>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
#include <osg/ref_ptr>
|
||||
|
||||
@ -264,7 +265,7 @@ namespace MWGui
|
||||
void addVisitedLocation(const std::string& name, int x, int y) override;
|
||||
|
||||
///Hides dialog and schedules dialog to be deleted.
|
||||
void removeDialog(Layout* dialog) override;
|
||||
void removeDialog(std::unique_ptr<Layout>&& dialog) override;
|
||||
|
||||
///Gracefully attempts to exit the topmost GUI mode
|
||||
void exitCurrentGuiMode() override;
|
||||
@ -498,7 +499,7 @@ namespace MWGui
|
||||
|
||||
SDLUtil::SDLCursorManager* mCursorManager;
|
||||
|
||||
std::vector<Layout*> mGarbageDialogs;
|
||||
std::vector<std::unique_ptr<Layout>> mGarbageDialogs;
|
||||
void cleanupGarbage();
|
||||
|
||||
GuiWindow mShown; // Currently shown windows in inventory mode
|
||||
|
Loading…
x
Reference in New Issue
Block a user