1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-10-29 17:26:43 +00:00

Replace spellcreationdialog.hpp to add player gold to spell creation window.

This commit is contained in:
Garrett 2025-04-02 10:50:05 +00:00 committed by SkyHasACat
parent 15a525676c
commit f8c8b9b433

View file

@ -1,184 +1,191 @@
#ifndef MWGUI_SPELLCREATION_H #ifndef MWGUI_SPELLCREATION_H
#define MWGUI_SPELLCREATION_H #define MWGUI_SPELLCREATION_H
#include <memory> #include <memory>
#include <components/esm3/loadmgef.hpp> #include <components/esm3/loadmgef.hpp>
#include <components/esm3/loadspel.hpp> #include <components/esm3/loadspel.hpp>
#include "referenceinterface.hpp" #include "referenceinterface.hpp"
#include "windowbase.hpp" #include "windowbase.hpp"
namespace Gui namespace Gui
{ {
class MWList; class MWList;
} }
namespace MWGui namespace MWGui
{ {
class SelectSkillDialog; class SelectSkillDialog;
class SelectAttributeDialog; class SelectAttributeDialog;
class EditEffectDialog : public WindowModal class EditEffectDialog : public WindowModal
{ {
public: public:
EditEffectDialog(); EditEffectDialog();
void onOpen() override; void onOpen() override;
bool exit() override; bool exit() override;
void setConstantEffect(bool constant); void setConstantEffect(bool constant);
void setSkill(ESM::RefId skill); void setSkill(ESM::RefId skill);
void setAttribute(ESM::RefId attribute); void setAttribute(ESM::RefId attribute);
void newEffect(const ESM::MagicEffect* effect); void newEffect(const ESM::MagicEffect* effect);
void editEffect(ESM::ENAMstruct effect); void editEffect(ESM::ENAMstruct effect);
typedef MyGUI::delegates::MultiDelegate<ESM::ENAMstruct> EventHandle_Effect; typedef MyGUI::delegates::MultiDelegate<ESM::ENAMstruct> EventHandle_Effect;
EventHandle_Effect eventEffectAdded; EventHandle_Effect eventEffectAdded;
EventHandle_Effect eventEffectModified; EventHandle_Effect eventEffectModified;
EventHandle_Effect eventEffectRemoved; EventHandle_Effect eventEffectRemoved;
protected: protected:
MyGUI::Button* mCancelButton; MyGUI::Button* mCancelButton;
MyGUI::Button* mOkButton; MyGUI::Button* mOkButton;
MyGUI::Button* mDeleteButton; MyGUI::Button* mDeleteButton;
MyGUI::Button* mRangeButton;
MyGUI::Button* mRangeButton;
MyGUI::Widget* mDurationBox;
MyGUI::Widget* mMagnitudeBox; MyGUI::Widget* mDurationBox;
MyGUI::Widget* mAreaBox; MyGUI::Widget* mMagnitudeBox;
MyGUI::Widget* mAreaBox;
MyGUI::TextBox* mMagnitudeMinValue;
MyGUI::TextBox* mMagnitudeMaxValue; MyGUI::TextBox* mMagnitudeMinValue;
MyGUI::TextBox* mDurationValue; MyGUI::TextBox* mMagnitudeMaxValue;
MyGUI::TextBox* mAreaValue; MyGUI::TextBox* mDurationValue;
MyGUI::TextBox* mAreaValue;
MyGUI::ScrollBar* mMagnitudeMinSlider;
MyGUI::ScrollBar* mMagnitudeMaxSlider; MyGUI::ScrollBar* mMagnitudeMinSlider;
MyGUI::ScrollBar* mDurationSlider; MyGUI::ScrollBar* mMagnitudeMaxSlider;
MyGUI::ScrollBar* mAreaSlider; MyGUI::ScrollBar* mDurationSlider;
MyGUI::ScrollBar* mAreaSlider;
MyGUI::TextBox* mAreaText;
MyGUI::TextBox* mAreaText;
MyGUI::ImageBox* mEffectImage;
MyGUI::TextBox* mEffectName; MyGUI::ImageBox* mEffectImage;
MyGUI::TextBox* mEffectName;
bool mEditing;
bool mEditing;
protected:
void onRangeButtonClicked(MyGUI::Widget* sender); protected:
void onDeleteButtonClicked(MyGUI::Widget* sender); void onRangeButtonClicked(MyGUI::Widget* sender);
void onOkButtonClicked(MyGUI::Widget* sender); void onDeleteButtonClicked(MyGUI::Widget* sender);
void onCancelButtonClicked(MyGUI::Widget* sender); void onOkButtonClicked(MyGUI::Widget* sender);
void onCancelButtonClicked(MyGUI::Widget* sender);
void onMagnitudeMinChanged(MyGUI::ScrollBar* sender, size_t pos);
void onMagnitudeMaxChanged(MyGUI::ScrollBar* sender, size_t pos); void onMagnitudeMinChanged(MyGUI::ScrollBar* sender, size_t pos);
void onDurationChanged(MyGUI::ScrollBar* sender, size_t pos); void onMagnitudeMaxChanged(MyGUI::ScrollBar* sender, size_t pos);
void onAreaChanged(MyGUI::ScrollBar* sender, size_t pos); void onDurationChanged(MyGUI::ScrollBar* sender, size_t pos);
void setMagicEffect(const ESM::MagicEffect* effect); void onAreaChanged(MyGUI::ScrollBar* sender, size_t pos);
void setMagicEffect(const ESM::MagicEffect* effect);
void updateBoxes();
void updateBoxes();
protected:
ESM::ENAMstruct mEffect; protected:
ESM::ENAMstruct mOldEffect; ESM::ENAMstruct mEffect;
ESM::ENAMstruct mOldEffect;
const ESM::MagicEffect* mMagicEffect;
const ESM::MagicEffect* mMagicEffect;
bool mConstantEffect;
}; bool mConstantEffect;
};
class EffectEditorBase
{ class EffectEditorBase
public: {
enum Type public:
{ enum Type
Spellmaking, {
Enchanting Spellmaking,
}; Enchanting
};
EffectEditorBase(Type type);
virtual ~EffectEditorBase(); EffectEditorBase(Type type);
virtual ~EffectEditorBase();
void setConstantEffect(bool constant);
void setConstantEffect(bool constant);
protected:
std::map<int, short> mButtonMapping; // maps button ID to effect ID
Gui::MWList* mAvailableEffectsList; protected:
MyGUI::ScrollView* mUsedEffectsView; std::map<int, short> mButtonMapping; // maps button ID to effect ID
EditEffectDialog mAddEffectDialog; Gui::MWList* mAvailableEffectsList;
std::unique_ptr<SelectAttributeDialog> mSelectAttributeDialog; MyGUI::ScrollView* mUsedEffectsView;
std::unique_ptr<SelectSkillDialog> mSelectSkillDialog;
int mSelectedEffect; EditEffectDialog mAddEffectDialog;
short mSelectedKnownEffectId; std::unique_ptr<SelectAttributeDialog> mSelectAttributeDialog;
std::unique_ptr<SelectSkillDialog> mSelectSkillDialog;
bool mConstantEffect;
int mSelectedEffect;
std::vector<ESM::ENAMstruct> mEffects; short mSelectedKnownEffectId;
void onEffectAdded(ESM::ENAMstruct effect); bool mConstantEffect;
void onEffectModified(ESM::ENAMstruct effect);
void onEffectRemoved(ESM::ENAMstruct effect); std::vector<ESM::ENAMstruct> mEffects;
void onAvailableEffectClicked(MyGUI::Widget* sender); void onEffectAdded(ESM::ENAMstruct effect);
void onEffectModified(ESM::ENAMstruct effect);
void onAttributeOrSkillCancel(); void onEffectRemoved(ESM::ENAMstruct effect);
void onSelectAttribute();
void onSelectSkill(); void onAvailableEffectClicked(MyGUI::Widget* sender);
void onEditEffect(MyGUI::Widget* sender); void onAttributeOrSkillCancel();
void onSelectAttribute();
void updateEffectsView(); void onSelectSkill();
void startEditing(); void onEditEffect(MyGUI::Widget* sender);
void setWidgets(Gui::MWList* availableEffectsList, MyGUI::ScrollView* usedEffectsView);
void updateEffectsView();
virtual void notifyEffectsChanged() {}
void startEditing();
private: void setWidgets(Gui::MWList* availableEffectsList, MyGUI::ScrollView* usedEffectsView);
Type mType;
}; virtual void notifyEffectsChanged() {}
class SpellCreationDialog : public WindowBase, public ReferenceInterface, public EffectEditorBase private:
{ Type mType;
public: };
SpellCreationDialog();
class SpellCreationDialog : public WindowBase, public ReferenceInterface, public EffectEditorBase
void onOpen() override; {
void clear() override { resetReference(); } public:
SpellCreationDialog();
void onFrame(float dt) override { checkReferenceAvailable(); }
void onOpen() override;
void setPtr(const MWWorld::Ptr& actor) override; void clear() override { resetReference(); }
std::string_view getWindowIdForLua() const override { return "SpellCreationDialog"; } void onFrame(float dt) override { checkReferenceAvailable(); }
protected: void setPtr(const MWWorld::Ptr& actor) override;
void onReferenceUnavailable() override;
void updateLabels();
void onCancelButtonClicked(MyGUI::Widget* sender);
void onBuyButtonClicked(MyGUI::Widget* sender); std::string_view getWindowIdForLua() const override { return "SpellCreationDialog"; }
void onAccept(MyGUI::EditBox* sender);
protected:
void notifyEffectsChanged() override; void onReferenceUnavailable() override;
MyGUI::EditBox* mNameEdit; void onCancelButtonClicked(MyGUI::Widget* sender);
MyGUI::TextBox* mMagickaCost; void onBuyButtonClicked(MyGUI::Widget* sender);
MyGUI::TextBox* mSuccessChance; void onAccept(MyGUI::EditBox* sender);
MyGUI::Button* mBuyButton;
MyGUI::Button* mCancelButton; void notifyEffectsChanged() override;
MyGUI::TextBox* mPriceLabel;
MyGUI::EditBox* mNameEdit;
ESM::Spell mSpell; MyGUI::TextBox* mMagickaCost;
}; MyGUI::TextBox* mSuccessChance;
MyGUI::Button* mBuyButton;
} MyGUI::Button* mCancelButton;
MyGUI::TextBox* mPriceLabel;
#endif MyGUI::TextBox* mPlayerGold;
ESM::Spell mSpell;
};
}
#endif