ManaPlus
Public Member Functions | Protected Attributes | Private Member Functions
TextCommand Class Reference

#include <textcommand.h>

Public Member Functions

 TextCommand (const int id, const std::string &symbol, const std::string &command, const std::string &comment, const CommandTargetT type, const std::string &icon, const unsigned int basicLvl, const MagicSchoolT school, const unsigned int schoolLvl, const unsigned int mana)
 
 TextCommand (const int id, const std::string &symbol, const std::string &command, const std::string &comment, const CommandTargetT type, const std::string &icon)
 
 TextCommand (const int id)
 
 ~TextCommand ()
 
std::string getName () const
 
std::string getCommand () const
 
std::string getComment () const
 
std::string getSymbol () const
 
int getId () const
 
CommandTargetT getTargetType () const
 
std::string getIcon () const
 
unsigned int getMana () const
 
MagicSchoolT getSchool () const
 
unsigned getBaseLvl () const
 
unsigned getSchoolLvl () const
 
void setMana (const unsigned int mana)
 
void setSchool (const MagicSchoolT school)
 
void setBaseLvl (const unsigned int baseLvl)
 
void setSchoolLvl (const unsigned int schoolLvl)
 
TextCommandTypeT getCommandType () const
 
void setCommandType (const TextCommandTypeT commandType)
 
void setCommand (const std::string &command)
 
void setComment (const std::string &comment)
 
void setSymbol (const std::string &symbol)
 
void setId (const int id)
 
void setTargetType (const CommandTargetT targetType)
 
void setIcon (const std::string &icon)
 
bool isEmpty () const
 
ImagegetImage () const
 

Protected Attributes

std::string mCommand
 
std::string mComment
 
std::string mSymbol
 
CommandTargetT mTargetType
 
std::string mIcon
 
int mId
 
unsigned int mMana
 
MagicSchoolT mSchool
 
unsigned mBaseLvl
 
unsigned mSchoolLvl
 
TextCommandTypeT mCommandType
 
ImagemImage
 

Private Member Functions

void loadImage ()
 

Detailed Description

Represents one or more instances of a certain item type.

Definition at line 41 of file textcommand.h.

Constructor & Destructor Documentation

◆ TextCommand() [1/3]

TextCommand::TextCommand ( const int  id,
const std::string &  symbol,
const std::string &  command,
const std::string &  comment,
const CommandTargetT  type,
const std::string &  icon,
const unsigned int  basicLvl,
const MagicSchoolT  school,
const unsigned int  schoolLvl,
const unsigned int  mana 
)

Constructor.

Definition at line 40 of file textcommand.cpp.

49  :
50  mCommand(command),
51  mComment(comment),
52  mSymbol(symbol),
53  mTargetType(type),
54  mIcon(icon),
55  mId(id),
56  mMana(mana),
57  mSchool(school),
58  mBaseLvl(basicLvl),
59  mSchoolLvl(schoolLvl),
61  mImage(nullptr)
62 {
63  loadImage();
64 }
unsigned int mMana
Definition: textcommand.h:170
CommandTargetT mTargetType
Definition: textcommand.h:166
std::string mCommand
Definition: textcommand.h:163
void loadImage()
TextCommandTypeT mCommandType
Definition: textcommand.h:174
Image * mImage
Definition: textcommand.h:177
std::string mSymbol
Definition: textcommand.h:165
unsigned mSchoolLvl
Definition: textcommand.h:173
MagicSchoolT mSchool
Definition: textcommand.h:171
unsigned mBaseLvl
Definition: textcommand.h:172
std::string mIcon
Definition: textcommand.h:167
std::string mComment
Definition: textcommand.h:164

References loadImage().

◆ TextCommand() [2/3]

TextCommand::TextCommand ( const int  id,
const std::string &  symbol,
const std::string &  command,
const std::string &  comment,
const CommandTargetT  type,
const std::string &  icon 
)

Constructor.

Definition at line 67 of file textcommand.cpp.

72  :
73  mCommand(command),
74  mComment(comment),
75  mSymbol(symbol),
76  mTargetType(type),
77  mIcon(icon),
78  mId(id),
79 #ifdef TMWA_SUPPORT
80  mMana(0U),
82  mBaseLvl(0),
83  mSchoolLvl(0),
85 #endif // TMWA_SUPPORT
86  mImage(nullptr)
87 {
88  loadImage();
89 }

References loadImage().

◆ TextCommand() [3/3]

TextCommand::TextCommand ( const int  id)
explicit

Constructor.

Definition at line 91 of file textcommand.cpp.

91  :
92  mCommand(""),
93  mComment(""),
94  mSymbol(""),
96  mIcon(""),
97  mId(id),
98 #ifdef TMWA_SUPPORT
99  mMana(0U),
101  mBaseLvl(0),
102  mSchoolLvl(0),
104 #endif // TMWA_SUPPORT
105  mImage(nullptr)
106 {
107  loadImage();
108 }

References loadImage().

◆ ~TextCommand()

TextCommand::~TextCommand ( )

Destructor.

Definition at line 111 of file textcommand.cpp.

112 {
113  if (mImage != nullptr)
114  {
115  mImage->decRef();
116  mImage = nullptr;
117  }
118 }

References mImage.

Member Function Documentation

◆ getBaseLvl()

unsigned TextCommand::getBaseLvl ( ) const
inline

Definition at line 110 of file textcommand.h.

111  { return mBaseLvl; }

References mBaseLvl.

Referenced by SpellManager::invoke(), SpellManager::save(), and TextCommandEditor::TextCommandEditor().

◆ getCommand()

std::string TextCommand::getCommand ( ) const
inline

◆ getCommandType()

TextCommandTypeT TextCommand::getCommandType ( ) const
inline

Definition at line 128 of file textcommand.h.

129  { return mCommandType; }

References mCommandType.

Referenced by SpellManager::invoke(), SpellManager::save(), and TextCommandEditor::TextCommandEditor().

◆ getComment()

std::string TextCommand::getComment ( ) const
inline

Definition at line 88 of file textcommand.h.

89  { return mComment; }

References mComment.

Referenced by SpellPopup::setItem(), and TextCommandEditor::TextCommandEditor().

◆ getIcon()

std::string TextCommand::getIcon ( ) const
inline

Definition at line 100 of file textcommand.h.

101  { return mIcon; }

References mIcon.

Referenced by TextCommandEditor::TextCommandEditor().

◆ getId()

int TextCommand::getId ( ) const
inline

◆ getImage()

Image* TextCommand::getImage ( ) const
inline

◆ getMana()

unsigned int TextCommand::getMana ( ) const
inline

Definition at line 104 of file textcommand.h.

105  { return mMana; }

References mMana.

Referenced by SpellManager::invoke(), SpellManager::save(), and TextCommandEditor::TextCommandEditor().

◆ getName()

std::string TextCommand::getName ( ) const
inline

Definition at line 82 of file textcommand.h.

83  { return mCommand; }

References mCommand.

Referenced by SpellPopup::setItem().

◆ getSchool()

MagicSchoolT TextCommand::getSchool ( ) const
inline

Definition at line 107 of file textcommand.h.

108  { return mSchool; }

References mSchool.

Referenced by SpellManager::invoke(), SpellManager::save(), and TextCommandEditor::TextCommandEditor().

◆ getSchoolLvl()

unsigned TextCommand::getSchoolLvl ( ) const
inline

Definition at line 113 of file textcommand.h.

114  { return mSchoolLvl; }

References mSchoolLvl.

Referenced by SpellManager::invoke(), SpellManager::save(), and TextCommandEditor::TextCommandEditor().

◆ getSymbol()

std::string TextCommand::getSymbol ( ) const
inline

◆ getTargetType()

CommandTargetT TextCommand::getTargetType ( ) const
inline

◆ isEmpty()

bool TextCommand::isEmpty ( ) const
inline

◆ loadImage()

void TextCommand::loadImage ( )
private

Definition at line 120 of file textcommand.cpp.

121 {
122  if (mImage != nullptr)
123  {
124  mImage->decRef();
125  mImage = nullptr;
126  }
127 
128  if (mIcon.empty() ||
130  {
131  return;
132  }
133 
134  const ItemInfo &info = ItemDB::get(mIcon);
135  const SpriteDisplay &display = info.getDisplay();
137  display.image));
138 
139  if (mImage == nullptr)
140  mImage = Theme::getImageFromTheme("unknown-item.png");
141 }
std::string getStringValue(const std::string &key) const
static Image * getImageFromTheme(const std::string &path)
Definition: theme.cpp:655
Configuration paths
bool info(InputEvent &event)
Definition: commands.cpp:57
bool exists(const int id)
Definition: itemdb.cpp:773
const ItemInfo & get(const int id)
Definition: itemdb.cpp:792
Image * getImage(const std::string &idPath)
Definition: imageloader.cpp:86
std::string pathJoin(std::string str1, const std::string &str2)
std::string image
Definition: spritedisplay.h:45

References ItemDB::exists(), ItemDB::get(), Loader::getImage(), Theme::getImageFromTheme(), Configuration::getStringValue(), SpriteDisplay::image, Actions::info(), mIcon, mImage, pathJoin(), and paths.

Referenced by setIcon(), and TextCommand().

◆ setBaseLvl()

void TextCommand::setBaseLvl ( const unsigned int  baseLvl)
inline

Definition at line 122 of file textcommand.h.

123  { mBaseLvl = baseLvl; }

References mBaseLvl.

Referenced by TextCommandEditor::deleteCommand(), and TextCommandEditor::save().

◆ setCommand()

void TextCommand::setCommand ( const std::string &  command)
inline

Definition at line 135 of file textcommand.h.

136  { mCommand = command; }

References mCommand.

Referenced by TextCommandEditor::deleteCommand(), and TextCommandEditor::save().

◆ setCommandType()

void TextCommand::setCommandType ( const TextCommandTypeT  commandType)
inline

Definition at line 131 of file textcommand.h.

132  { mCommandType = commandType; }

References mCommandType.

Referenced by TextCommandEditor::deleteCommand(), and TextCommandEditor::save().

◆ setComment()

void TextCommand::setComment ( const std::string &  comment)
inline

Definition at line 138 of file textcommand.h.

139  { mComment = comment; }

References mComment.

Referenced by TextCommandEditor::deleteCommand(), and TextCommandEditor::save().

◆ setIcon()

void TextCommand::setIcon ( const std::string &  icon)
inline

Definition at line 150 of file textcommand.h.

151  { mIcon = icon; loadImage(); }

References loadImage(), and mIcon.

Referenced by TextCommandEditor::deleteCommand(), and TextCommandEditor::save().

◆ setId()

void TextCommand::setId ( const int  id)
inline

Definition at line 144 of file textcommand.h.

145  { mId = id; }

References mId.

Referenced by SpellManager::swap().

◆ setMana()

void TextCommand::setMana ( const unsigned int  mana)
inline

Definition at line 116 of file textcommand.h.

117  { mMana = mana; }

References mMana.

Referenced by TextCommandEditor::deleteCommand(), and TextCommandEditor::save().

◆ setSchool()

void TextCommand::setSchool ( const MagicSchoolT  school)
inline

Definition at line 119 of file textcommand.h.

120  { mSchool = school; }

References mSchool.

Referenced by TextCommandEditor::deleteCommand(), and TextCommandEditor::save().

◆ setSchoolLvl()

void TextCommand::setSchoolLvl ( const unsigned int  schoolLvl)
inline

Definition at line 125 of file textcommand.h.

126  { mSchoolLvl = schoolLvl; }

References mSchoolLvl.

Referenced by TextCommandEditor::deleteCommand(), and TextCommandEditor::save().

◆ setSymbol()

void TextCommand::setSymbol ( const std::string &  symbol)
inline

Definition at line 141 of file textcommand.h.

142  { mSymbol = symbol; }

References mSymbol.

Referenced by TextCommandEditor::deleteCommand(), and TextCommandEditor::save().

◆ setTargetType()

void TextCommand::setTargetType ( const CommandTargetT  targetType)
inline

Definition at line 147 of file textcommand.h.

148  { mTargetType = targetType; }

References mTargetType.

Referenced by TextCommandEditor::deleteCommand(), and TextCommandEditor::save().

Field Documentation

◆ mBaseLvl

unsigned TextCommand::mBaseLvl
protected

Definition at line 172 of file textcommand.h.

Referenced by getBaseLvl(), and setBaseLvl().

◆ mCommand

std::string TextCommand::mCommand
protected

Definition at line 163 of file textcommand.h.

Referenced by getCommand(), getName(), isEmpty(), and setCommand().

◆ mCommandType

TextCommandTypeT TextCommand::mCommandType
protected

Definition at line 174 of file textcommand.h.

Referenced by getCommandType(), and setCommandType().

◆ mComment

std::string TextCommand::mComment
protected

Definition at line 164 of file textcommand.h.

Referenced by getComment(), and setComment().

◆ mIcon

std::string TextCommand::mIcon
protected

Definition at line 167 of file textcommand.h.

Referenced by getIcon(), loadImage(), and setIcon().

◆ mId

int TextCommand::mId
protected

Definition at line 168 of file textcommand.h.

Referenced by getId(), and setId().

◆ mImage

Image* TextCommand::mImage
protected

Definition at line 177 of file textcommand.h.

Referenced by getImage(), loadImage(), and ~TextCommand().

◆ mMana

unsigned int TextCommand::mMana
protected

Definition at line 170 of file textcommand.h.

Referenced by getMana(), and setMana().

◆ mSchool

MagicSchoolT TextCommand::mSchool
protected

Definition at line 171 of file textcommand.h.

Referenced by getSchool(), and setSchool().

◆ mSchoolLvl

unsigned TextCommand::mSchoolLvl
protected

Definition at line 173 of file textcommand.h.

Referenced by getSchoolLvl(), and setSchoolLvl().

◆ mSymbol

std::string TextCommand::mSymbol
protected

Definition at line 165 of file textcommand.h.

Referenced by getSymbol(), isEmpty(), and setSymbol().

◆ mTargetType

CommandTargetT TextCommand::mTargetType
protected

Definition at line 166 of file textcommand.h.

Referenced by getTargetType(), and setTargetType().


The documentation for this class was generated from the following files: