1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-17 01:10:10 +00:00
OpenMW/apps/openmw/mwgui/class.hpp
fteppe 125b21de20 Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID

Slowly going through all the changes to make, still hundreds of errors

a lot of functions/structures use std::string or stringview to designate an ID. So it takes time

Continues slowly replacing ids. There are technically more and more compilation errors

I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type

Continue moving forward, changes to the stores

slowly moving along

Starting to see the fruit of those changes.

still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.

More replacements. Things are starting to get easier

I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.

Still moving forward, and for the first time error count is going down!

Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably

Cells are back to using string for the name, haven't fixed everything yet. Many other changes

Under the bar of 400 compilation errors.

more good progress <100 compile errors!

More progress

Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string

some more progress on other fronts

Mostly game settings clean

one error opened a lot of other errors. Down to 18, but more will prbably appear

only link errors left??

Fixed link errors

OpenMW compiles, and launches, with some issues, but still!
2022-12-27 19:15:54 +01:00

338 lines
9.2 KiB
C++

#ifndef MWGUI_CLASS_H
#define MWGUI_CLASS_H
#include <memory>
#include <MyGUI_EditBox.h>
#include <components/esm/attr.hpp>
#include <components/esm/refid.hpp>
#include <components/esm3/loadclas.hpp>
#include "widgets.hpp"
#include "windowbase.hpp"
namespace MWGui
{
void setClassImage(MyGUI::ImageBox* imageBox, const ESM::RefId& classId);
class InfoBoxDialog : public WindowModal
{
public:
InfoBoxDialog();
typedef std::vector<std::string> ButtonList;
void setText(const std::string& str);
std::string getText() const;
void setButtons(ButtonList& buttons);
void onOpen() override;
bool exit() override { return false; }
// Events
typedef MyGUI::delegates::CMultiDelegate1<int> EventHandle_Int;
/** Event : Button was clicked.\n
signature : void method(int index)\n
*/
EventHandle_Int eventButtonSelected;
protected:
void onButtonClicked(MyGUI::Widget* _sender);
private:
void fitToText(MyGUI::TextBox* widget);
void layoutVertically(MyGUI::Widget* widget, int margin);
MyGUI::Widget* mTextBox;
MyGUI::TextBox* mText;
MyGUI::Widget* mButtonBar;
std::vector<MyGUI::Button*> mButtons;
};
// Lets the player choose between 3 ways of creating a class
class ClassChoiceDialog : public InfoBoxDialog
{
public:
// Corresponds to the buttons that can be clicked
enum ClassChoice
{
Class_Generate = 0,
Class_Pick = 1,
Class_Create = 2,
Class_Back = 3
};
ClassChoiceDialog();
};
class GenerateClassResultDialog : public WindowModal
{
public:
GenerateClassResultDialog();
void setClassId(const ESM::RefId& classId);
bool exit() override { return false; }
// Events
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
/** Event : Back button clicked.\n
signature : void method()\n
*/
EventHandle_Void eventBack;
/** Event : Dialog finished, OK button clicked.\n
signature : void method()\n
*/
EventHandle_WindowBase eventDone;
protected:
void onOkClicked(MyGUI::Widget* _sender);
void onBackClicked(MyGUI::Widget* _sender);
private:
MyGUI::ImageBox* mClassImage;
MyGUI::TextBox* mClassName;
ESM::RefId mCurrentClassId;
};
class PickClassDialog : public WindowModal
{
public:
PickClassDialog();
const ESM::RefId& getClassId() const { return mCurrentClassId; }
void setClassId(const ESM::RefId& classId);
void setNextButtonShow(bool shown);
void onOpen() override;
bool exit() override { return false; }
// Events
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
/** Event : Back button clicked.\n
signature : void method()\n
*/
EventHandle_Void eventBack;
/** Event : Dialog finished, OK button clicked.\n
signature : void method()\n
*/
EventHandle_WindowBase eventDone;
protected:
void onSelectClass(MyGUI::ListBox* _sender, size_t _index);
void onAccept(MyGUI::ListBox* _sender, size_t _index);
void onOkClicked(MyGUI::Widget* _sender);
void onBackClicked(MyGUI::Widget* _sender);
private:
void updateClasses();
void updateStats();
MyGUI::ImageBox* mClassImage;
MyGUI::ListBox* mClassList;
MyGUI::TextBox* mSpecializationName;
Widgets::MWAttributePtr mFavoriteAttribute[2];
Widgets::MWSkillPtr mMajorSkill[5];
Widgets::MWSkillPtr mMinorSkill[5];
ESM::RefId mCurrentClassId;
};
class SelectSpecializationDialog : public WindowModal
{
public:
SelectSpecializationDialog();
~SelectSpecializationDialog();
bool exit() override;
ESM::Class::Specialization getSpecializationId() const { return mSpecializationId; }
// Events
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
/** Event : Cancel button clicked.\n
signature : void method()\n
*/
EventHandle_Void eventCancel;
/** Event : Dialog finished, specialization selected.\n
signature : void method()\n
*/
EventHandle_Void eventItemSelected;
protected:
void onSpecializationClicked(MyGUI::Widget* _sender);
void onCancelClicked(MyGUI::Widget* _sender);
private:
MyGUI::TextBox *mSpecialization0, *mSpecialization1, *mSpecialization2;
ESM::Class::Specialization mSpecializationId;
};
class SelectAttributeDialog : public WindowModal
{
public:
SelectAttributeDialog();
~SelectAttributeDialog();
bool exit() override;
ESM::Attribute::AttributeID getAttributeId() const { return mAttributeId; }
// Events
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
/** Event : Cancel button clicked.\n
signature : void method()\n
*/
EventHandle_Void eventCancel;
/** Event : Dialog finished, attribute selected.\n
signature : void method()\n
*/
EventHandle_Void eventItemSelected;
protected:
void onAttributeClicked(Widgets::MWAttributePtr _sender);
void onCancelClicked(MyGUI::Widget* _sender);
private:
ESM::Attribute::AttributeID mAttributeId;
};
class SelectSkillDialog : public WindowModal
{
public:
SelectSkillDialog();
~SelectSkillDialog();
bool exit() override;
ESM::Skill::SkillEnum getSkillId() const { return mSkillId; }
// Events
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
/** Event : Cancel button clicked.\n
signature : void method()\n
*/
EventHandle_Void eventCancel;
/** Event : Dialog finished, skill selected.\n
signature : void method()\n
*/
EventHandle_Void eventItemSelected;
protected:
void onSkillClicked(Widgets::MWSkillPtr _sender);
void onCancelClicked(MyGUI::Widget* _sender);
private:
Widgets::MWSkillPtr mCombatSkill[9];
Widgets::MWSkillPtr mMagicSkill[9];
Widgets::MWSkillPtr mStealthSkill[9];
ESM::Skill::SkillEnum mSkillId;
};
class DescriptionDialog : public WindowModal
{
public:
DescriptionDialog();
~DescriptionDialog();
std::string getTextInput() const { return mTextEdit->getCaption(); }
void setTextInput(const std::string& text) { mTextEdit->setCaption(text); }
/** Event : Dialog finished, OK button clicked.\n
signature : void method()\n
*/
EventHandle_WindowBase eventDone;
protected:
void onOkClicked(MyGUI::Widget* _sender);
private:
MyGUI::EditBox* mTextEdit;
};
class CreateClassDialog : public WindowModal
{
public:
CreateClassDialog();
virtual ~CreateClassDialog();
bool exit() override { return false; }
std::string getName() const;
std::string getDescription() const;
ESM::Class::Specialization getSpecializationId() const;
std::vector<int> getFavoriteAttributes() const;
std::vector<ESM::Skill::SkillEnum> getMajorSkills() const;
std::vector<ESM::Skill::SkillEnum> getMinorSkills() const;
void setNextButtonShow(bool shown);
// Events
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
/** Event : Back button clicked.\n
signature : void method()\n
*/
EventHandle_Void eventBack;
/** Event : Dialog finished, OK button clicked.\n
signature : void method()\n
*/
EventHandle_WindowBase eventDone;
protected:
void onOkClicked(MyGUI::Widget* _sender);
void onBackClicked(MyGUI::Widget* _sender);
void onSpecializationClicked(MyGUI::Widget* _sender);
void onSpecializationSelected();
void onAttributeClicked(Widgets::MWAttributePtr _sender);
void onAttributeSelected();
void onSkillClicked(Widgets::MWSkillPtr _sender);
void onSkillSelected();
void onDescriptionClicked(MyGUI::Widget* _sender);
void onDescriptionEntered(WindowBase* parWindow);
void onDialogCancel();
void setSpecialization(int id);
void update();
private:
MyGUI::EditBox* mEditName;
MyGUI::TextBox* mSpecializationName;
Widgets::MWAttributePtr mFavoriteAttribute0, mFavoriteAttribute1;
Widgets::MWSkillPtr mMajorSkill[5];
Widgets::MWSkillPtr mMinorSkill[5];
std::vector<Widgets::MWSkillPtr> mSkills;
std::string mDescription;
std::unique_ptr<SelectSpecializationDialog> mSpecDialog;
std::unique_ptr<SelectAttributeDialog> mAttribDialog;
std::unique_ptr<SelectSkillDialog> mSkillDialog;
std::unique_ptr<DescriptionDialog> mDescDialog;
ESM::Class::Specialization mSpecializationId;
Widgets::MWAttributePtr mAffectedAttribute;
Widgets::MWSkillPtr mAffectedSkill;
};
}
#endif