2010-09-20 11:17:02 +00:00
|
|
|
#ifndef MWGUI_WIDGETS_H
|
|
|
|
#define MWGUI_WIDGETS_H
|
|
|
|
|
2013-03-03 12:11:02 +00:00
|
|
|
#include "../mwmechanics/stat.hpp"
|
2010-09-20 11:17:02 +00:00
|
|
|
|
2014-12-19 08:23:16 +00:00
|
|
|
#include <components/esm/effectlist.hpp>
|
|
|
|
#include <components/esm/loadskil.hpp>
|
|
|
|
|
2013-03-03 12:11:02 +00:00
|
|
|
#include <MyGUI_Button.h>
|
2013-03-12 16:18:47 +00:00
|
|
|
#include <MyGUI_EditBox.h>
|
2013-07-02 15:29:47 +00:00
|
|
|
#include <MyGUI_ScrollBar.h>
|
2010-09-20 11:17:02 +00:00
|
|
|
|
2013-03-03 12:11:02 +00:00
|
|
|
namespace MyGUI
|
|
|
|
{
|
|
|
|
class ImageBox;
|
2015-01-10 01:50:43 +00:00
|
|
|
class ControllerItem;
|
2013-03-03 12:11:02 +00:00
|
|
|
}
|
2010-09-20 11:17:02 +00:00
|
|
|
|
2012-08-12 16:11:09 +00:00
|
|
|
namespace MWBase
|
|
|
|
{
|
|
|
|
class WindowManager;
|
|
|
|
}
|
|
|
|
|
2010-09-20 11:17:02 +00:00
|
|
|
/*
|
|
|
|
This file contains various custom widgets used in OpenMW.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace MWGui
|
|
|
|
{
|
|
|
|
namespace Widgets
|
|
|
|
{
|
2012-05-24 12:47:57 +00:00
|
|
|
class MWEffectList;
|
|
|
|
|
2010-09-21 10:34:47 +00:00
|
|
|
void fixTexturePath(std::string &path);
|
|
|
|
|
2012-05-24 01:48:02 +00:00
|
|
|
struct SpellEffectParams
|
|
|
|
{
|
2012-05-24 12:47:57 +00:00
|
|
|
SpellEffectParams()
|
2015-04-25 18:37:42 +00:00
|
|
|
: mNoTarget(false)
|
|
|
|
, mIsConstant(false)
|
2019-05-06 23:48:13 +00:00
|
|
|
, mNoMagnitude(false)
|
2015-04-25 18:37:42 +00:00
|
|
|
, mKnown(true)
|
|
|
|
, mEffectID(-1)
|
|
|
|
, mSkill(-1)
|
|
|
|
, mAttribute(-1)
|
|
|
|
, mMagnMin(-1)
|
2012-05-24 12:47:57 +00:00
|
|
|
, mMagnMax(-1)
|
|
|
|
, mRange(-1)
|
|
|
|
, mDuration(-1)
|
2012-10-11 16:26:29 +00:00
|
|
|
, mArea(0)
|
2012-05-24 12:47:57 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool mNoTarget; // potion effects for example have no target (target is always the player)
|
2012-05-24 01:48:02 +00:00
|
|
|
bool mIsConstant; // constant effect means that duration will not be displayed
|
2019-05-06 23:48:13 +00:00
|
|
|
bool mNoMagnitude; // effect magnitude will not be displayed (e.g ingredients)
|
2012-05-24 01:48:02 +00:00
|
|
|
|
2013-01-11 00:23:24 +00:00
|
|
|
bool mKnown; // is this effect known to the player? (If not, will display as a question mark instead)
|
|
|
|
|
2012-05-24 12:47:57 +00:00
|
|
|
// value of -1 here means the effect is unknown to the player
|
|
|
|
short mEffectID;
|
|
|
|
|
|
|
|
// value of -1 here means there is no skill/attribute
|
|
|
|
signed char mSkill, mAttribute;
|
|
|
|
|
|
|
|
// value of -1 here means the value is unavailable
|
|
|
|
int mMagnMin, mMagnMax, mRange, mDuration;
|
2012-05-25 14:20:57 +00:00
|
|
|
|
2012-10-11 16:26:29 +00:00
|
|
|
// value of 0 -> no area effect
|
|
|
|
int mArea;
|
|
|
|
|
2012-05-25 14:20:57 +00:00
|
|
|
bool operator==(const SpellEffectParams& other) const
|
|
|
|
{
|
2012-06-04 18:56:13 +00:00
|
|
|
if (mEffectID != other.mEffectID)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
bool involvesAttribute = (mEffectID == 74 // restore attribute
|
|
|
|
|| mEffectID == 85 // absorb attribute
|
|
|
|
|| mEffectID == 17 // drain attribute
|
|
|
|
|| mEffectID == 79 // fortify attribute
|
|
|
|
|| mEffectID == 22); // damage attribute
|
|
|
|
bool involvesSkill = (mEffectID == 78 // restore skill
|
|
|
|
|| mEffectID == 89 // absorb skill
|
|
|
|
|| mEffectID == 21 // drain skill
|
|
|
|
|| mEffectID == 83 // fortify skill
|
|
|
|
|| mEffectID == 26); // damage skill
|
2012-10-11 16:26:29 +00:00
|
|
|
return ((other.mSkill == mSkill) || !involvesSkill) && ((other.mAttribute == mAttribute) && !involvesAttribute) && (other.mArea == mArea);
|
2012-05-25 14:20:57 +00:00
|
|
|
}
|
2012-05-24 01:48:02 +00:00
|
|
|
};
|
|
|
|
|
2012-05-24 12:47:57 +00:00
|
|
|
typedef std::vector<SpellEffectParams> SpellEffectList;
|
|
|
|
|
2020-02-13 20:36:56 +00:00
|
|
|
class MWSkill final : public MyGUI::Widget
|
2010-09-20 11:17:02 +00:00
|
|
|
{
|
2012-09-10 07:10:50 +00:00
|
|
|
MYGUI_RTTI_DERIVED( MWSkill )
|
2010-09-20 11:17:02 +00:00
|
|
|
public:
|
|
|
|
MWSkill();
|
|
|
|
|
|
|
|
typedef MWMechanics::Stat<float> SkillValue;
|
|
|
|
|
|
|
|
void setSkillId(ESM::Skill::SkillEnum skillId);
|
|
|
|
void setSkillNumber(int skillId);
|
|
|
|
void setSkillValue(const SkillValue& value);
|
|
|
|
|
2012-07-13 10:51:58 +00:00
|
|
|
ESM::Skill::SkillEnum getSkillId() const { return mSkillId; }
|
|
|
|
const SkillValue& getSkillValue() const { return mValue; }
|
2010-09-20 11:17:02 +00:00
|
|
|
|
2010-09-24 13:28:14 +00:00
|
|
|
// Events
|
2012-09-10 07:10:50 +00:00
|
|
|
typedef MyGUI::delegates::CMultiDelegate1<MWSkill*> EventHandle_SkillVoid;
|
2010-09-24 13:28:14 +00:00
|
|
|
|
|
|
|
/** Event : Skill clicked.\n
|
|
|
|
signature : void method(MWSkill* _sender)\n
|
|
|
|
*/
|
|
|
|
EventHandle_SkillVoid eventClicked;
|
|
|
|
|
2010-09-20 11:17:02 +00:00
|
|
|
protected:
|
2011-01-05 21:18:21 +00:00
|
|
|
virtual ~MWSkill();
|
2010-09-20 11:17:02 +00:00
|
|
|
|
2020-10-22 21:57:53 +00:00
|
|
|
void initialiseOverride() override;
|
2010-09-20 11:17:02 +00:00
|
|
|
|
2010-09-24 13:28:14 +00:00
|
|
|
void onClicked(MyGUI::Widget* _sender);
|
|
|
|
|
2011-01-05 21:18:21 +00:00
|
|
|
private:
|
2010-09-20 11:17:02 +00:00
|
|
|
|
|
|
|
void updateWidgets();
|
|
|
|
|
2012-07-13 10:51:58 +00:00
|
|
|
ESM::Skill::SkillEnum mSkillId;
|
|
|
|
SkillValue mValue;
|
2014-09-13 02:07:40 +00:00
|
|
|
MyGUI::TextBox* mSkillNameWidget;
|
|
|
|
MyGUI::TextBox* mSkillValueWidget;
|
2010-09-20 11:17:02 +00:00
|
|
|
};
|
|
|
|
typedef MWSkill* MWSkillPtr;
|
|
|
|
|
2020-02-13 20:36:56 +00:00
|
|
|
class MWAttribute final : public MyGUI::Widget
|
2010-09-20 11:17:02 +00:00
|
|
|
{
|
2012-09-10 07:10:50 +00:00
|
|
|
MYGUI_RTTI_DERIVED( MWAttribute )
|
2010-09-20 11:17:02 +00:00
|
|
|
public:
|
|
|
|
MWAttribute();
|
|
|
|
|
2014-01-03 00:59:15 +00:00
|
|
|
typedef MWMechanics::AttributeValue AttributeValue;
|
2010-09-20 11:17:02 +00:00
|
|
|
|
|
|
|
void setAttributeId(int attributeId);
|
|
|
|
void setAttributeValue(const AttributeValue& value);
|
|
|
|
|
2012-07-13 10:51:58 +00:00
|
|
|
int getAttributeId() const { return mId; }
|
|
|
|
const AttributeValue& getAttributeValue() const { return mValue; }
|
2010-09-20 11:17:02 +00:00
|
|
|
|
2010-09-24 13:28:14 +00:00
|
|
|
// Events
|
2012-09-10 07:10:50 +00:00
|
|
|
typedef MyGUI::delegates::CMultiDelegate1<MWAttribute*> EventHandle_AttributeVoid;
|
2010-09-24 13:28:14 +00:00
|
|
|
|
|
|
|
/** Event : Attribute clicked.\n
|
|
|
|
signature : void method(MWAttribute* _sender)\n
|
|
|
|
*/
|
|
|
|
EventHandle_AttributeVoid eventClicked;
|
|
|
|
|
2010-09-20 11:17:02 +00:00
|
|
|
protected:
|
2011-01-05 21:18:21 +00:00
|
|
|
virtual ~MWAttribute();
|
2010-09-20 11:17:02 +00:00
|
|
|
|
2020-10-22 21:57:53 +00:00
|
|
|
void initialiseOverride() override;
|
2010-09-20 11:17:02 +00:00
|
|
|
|
2010-09-24 13:28:14 +00:00
|
|
|
void onClicked(MyGUI::Widget* _sender);
|
|
|
|
|
2011-01-05 21:18:21 +00:00
|
|
|
private:
|
2010-09-20 11:17:02 +00:00
|
|
|
|
|
|
|
void updateWidgets();
|
|
|
|
|
2012-07-13 10:51:58 +00:00
|
|
|
int mId;
|
|
|
|
AttributeValue mValue;
|
2014-09-13 02:07:40 +00:00
|
|
|
MyGUI::TextBox* mAttributeNameWidget;
|
|
|
|
MyGUI::TextBox* mAttributeValueWidget;
|
2010-09-20 11:17:02 +00:00
|
|
|
};
|
|
|
|
typedef MWAttribute* MWAttributePtr;
|
2010-09-20 11:36:55 +00:00
|
|
|
|
2012-05-24 12:47:57 +00:00
|
|
|
/**
|
|
|
|
* @todo remove this class and use MWEffectList instead
|
|
|
|
*/
|
2010-09-21 10:34:47 +00:00
|
|
|
class MWSpellEffect;
|
2020-02-13 20:36:56 +00:00
|
|
|
class MWSpell final : public MyGUI::Widget
|
2010-09-20 11:36:55 +00:00
|
|
|
{
|
2012-09-10 07:10:50 +00:00
|
|
|
MYGUI_RTTI_DERIVED( MWSpell )
|
2010-09-20 11:36:55 +00:00
|
|
|
public:
|
|
|
|
MWSpell();
|
|
|
|
|
|
|
|
typedef MWMechanics::Stat<int> SpellValue;
|
|
|
|
|
|
|
|
void setSpellId(const std::string &id);
|
2012-04-29 22:57:41 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param vector to store the created effect widgets
|
|
|
|
* @param parent widget
|
|
|
|
* @param coordinates to use, will be expanded if more space is needed
|
|
|
|
* @param spell category, if this is 0, this means the spell effects are permanent and won't display e.g. duration
|
2012-04-30 00:10:55 +00:00
|
|
|
* @param various flags, see MWEffectList::EffectFlags
|
2012-04-29 22:57:41 +00:00
|
|
|
*/
|
2013-03-03 12:11:02 +00:00
|
|
|
void createEffectWidgets(std::vector<MyGUI::Widget*> &effects, MyGUI::Widget* creator, MyGUI::IntCoord &coord, int flags);
|
2010-09-20 11:36:55 +00:00
|
|
|
|
2012-07-13 10:51:58 +00:00
|
|
|
const std::string &getSpellId() const { return mId; }
|
2010-09-20 11:36:55 +00:00
|
|
|
|
|
|
|
protected:
|
2011-01-05 21:18:21 +00:00
|
|
|
virtual ~MWSpell();
|
2010-09-20 11:36:55 +00:00
|
|
|
|
2020-10-22 21:57:53 +00:00
|
|
|
void initialiseOverride() override;
|
2010-09-20 11:36:55 +00:00
|
|
|
|
2011-01-05 21:18:21 +00:00
|
|
|
private:
|
2010-09-20 11:36:55 +00:00
|
|
|
void updateWidgets();
|
|
|
|
|
2012-07-13 10:51:58 +00:00
|
|
|
std::string mId;
|
|
|
|
MyGUI::TextBox* mSpellNameWidget;
|
2010-09-20 11:36:55 +00:00
|
|
|
};
|
|
|
|
typedef MWSpell* MWSpellPtr;
|
2010-09-21 10:34:47 +00:00
|
|
|
|
2020-02-13 20:36:56 +00:00
|
|
|
class MWEffectList final : public MyGUI::Widget
|
2012-04-18 16:09:30 +00:00
|
|
|
{
|
2012-09-10 07:10:50 +00:00
|
|
|
MYGUI_RTTI_DERIVED( MWEffectList )
|
2012-04-18 16:09:30 +00:00
|
|
|
public:
|
2012-04-29 23:08:10 +00:00
|
|
|
MWEffectList();
|
2012-04-18 16:09:30 +00:00
|
|
|
|
|
|
|
typedef MWMechanics::Stat<int> EnchantmentValue;
|
|
|
|
|
2012-04-29 23:53:22 +00:00
|
|
|
enum EffectFlags
|
|
|
|
{
|
2012-05-24 12:47:57 +00:00
|
|
|
EF_NoTarget = 0x01, // potions have no target (target is always the player)
|
2019-05-06 23:48:13 +00:00
|
|
|
EF_Constant = 0x02, // constant effect means that duration will not be displayed
|
|
|
|
EF_NoMagnitude = 0x04 // ingredients have no magnitude
|
|
|
|
|
2012-04-29 23:53:22 +00:00
|
|
|
};
|
|
|
|
|
2012-05-24 12:47:57 +00:00
|
|
|
void setEffectList(const SpellEffectList& list);
|
|
|
|
|
|
|
|
static SpellEffectList effectListFromESM(const ESM::EffectList* effects);
|
2012-04-29 22:57:41 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param vector to store the created effect widgets
|
|
|
|
* @param parent widget
|
|
|
|
* @param coordinates to use, will be expanded if more space is needed
|
|
|
|
* @param center the effect widgets horizontally
|
2012-04-29 23:53:22 +00:00
|
|
|
* @param various flags, see MWEffectList::EffectFlags
|
2012-04-29 22:57:41 +00:00
|
|
|
*/
|
2013-03-03 12:11:02 +00:00
|
|
|
void createEffectWidgets(std::vector<MyGUI::Widget*> &effects, MyGUI::Widget* creator, MyGUI::IntCoord &coord, bool center, int flags);
|
2012-04-18 16:09:30 +00:00
|
|
|
|
|
|
|
protected:
|
2012-04-29 23:08:10 +00:00
|
|
|
virtual ~MWEffectList();
|
2012-04-18 16:09:30 +00:00
|
|
|
|
2020-10-22 21:57:53 +00:00
|
|
|
void initialiseOverride() override;
|
2012-04-18 16:09:30 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void updateWidgets();
|
|
|
|
|
2012-05-24 12:47:57 +00:00
|
|
|
SpellEffectList mEffectList;
|
2012-04-18 16:09:30 +00:00
|
|
|
};
|
2012-04-29 23:08:10 +00:00
|
|
|
typedef MWEffectList* MWEffectListPtr;
|
2012-04-18 16:09:30 +00:00
|
|
|
|
2020-02-13 20:36:56 +00:00
|
|
|
class MWSpellEffect final : public MyGUI::Widget
|
2010-09-21 10:34:47 +00:00
|
|
|
{
|
2012-09-10 07:10:50 +00:00
|
|
|
MYGUI_RTTI_DERIVED( MWSpellEffect )
|
2010-09-21 10:34:47 +00:00
|
|
|
public:
|
|
|
|
MWSpellEffect();
|
|
|
|
|
|
|
|
typedef ESM::ENAMstruct SpellEffectValue;
|
|
|
|
|
2012-05-24 12:47:57 +00:00
|
|
|
void setSpellEffect(const SpellEffectParams& params);
|
2012-04-18 19:18:53 +00:00
|
|
|
|
2012-04-29 22:57:41 +00:00
|
|
|
int getRequestedWidth() const { return mRequestedWidth; }
|
|
|
|
|
2010-09-21 10:34:47 +00:00
|
|
|
protected:
|
2011-01-05 21:18:21 +00:00
|
|
|
virtual ~MWSpellEffect();
|
2010-09-21 10:34:47 +00:00
|
|
|
|
2020-10-22 21:57:53 +00:00
|
|
|
void initialiseOverride() override;
|
2012-08-12 16:11:09 +00:00
|
|
|
|
2011-01-05 21:18:21 +00:00
|
|
|
private:
|
2019-09-02 17:13:56 +00:00
|
|
|
static const int sIconOffset = 24;
|
|
|
|
|
2010-09-21 10:34:47 +00:00
|
|
|
void updateWidgets();
|
|
|
|
|
2012-05-24 12:47:57 +00:00
|
|
|
SpellEffectParams mEffectParams;
|
2012-07-13 10:51:58 +00:00
|
|
|
MyGUI::ImageBox* mImageWidget;
|
|
|
|
MyGUI::TextBox* mTextWidget;
|
2012-04-29 22:57:41 +00:00
|
|
|
int mRequestedWidth;
|
2010-09-21 10:34:47 +00:00
|
|
|
};
|
|
|
|
typedef MWSpellEffect* MWSpellEffectPtr;
|
2010-10-20 19:39:18 +00:00
|
|
|
|
2020-02-13 20:36:56 +00:00
|
|
|
class MWDynamicStat final : public MyGUI::Widget
|
2010-10-20 19:39:18 +00:00
|
|
|
{
|
2012-09-10 07:10:50 +00:00
|
|
|
MYGUI_RTTI_DERIVED( MWDynamicStat )
|
2010-10-20 19:39:18 +00:00
|
|
|
public:
|
|
|
|
MWDynamicStat();
|
|
|
|
|
|
|
|
void setValue(int value, int max);
|
2012-06-06 18:29:30 +00:00
|
|
|
void setTitle(const std::string& text);
|
2010-10-20 19:39:18 +00:00
|
|
|
|
2012-07-13 10:51:58 +00:00
|
|
|
int getValue() const { return mValue; }
|
|
|
|
int getMax() const { return mMax; }
|
2010-10-20 19:39:18 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~MWDynamicStat();
|
|
|
|
|
2020-10-22 21:57:53 +00:00
|
|
|
void initialiseOverride() override;
|
2010-10-20 19:39:18 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2012-07-13 10:51:58 +00:00
|
|
|
int mValue, mMax;
|
|
|
|
MyGUI::TextBox* mTextWidget;
|
2014-09-13 02:07:40 +00:00
|
|
|
MyGUI::ProgressBar* mBarWidget;
|
2012-07-13 10:51:58 +00:00
|
|
|
MyGUI::TextBox* mBarTextWidget;
|
2010-10-20 19:39:18 +00:00
|
|
|
};
|
|
|
|
typedef MWDynamicStat* MWDynamicStatPtr;
|
2010-09-20 11:17:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|