ManaPlus
Public Member Functions | Private Attributes
DragDrop Class Reference

#include <dragdrop.h>

Public Member Functions

 DragDrop (Item *const item, const DragDropSourceT source)
 
 ~DragDrop ()
 
int getItem () const
 
ItemColor getItemColor () const
 
void setItemColor (const ItemColor color)
 
ImagegetItemImage ()
 
void setItemData (const std::string &data)
 
std::string getItemData ()
 
DragDropSourceT getSource () const
 
void dragItem (const Item *const item, const DragDropSourceT source, const int tag)
 
void dragCommand (const TextCommand *const command, const DragDropSourceT source, const int tag)
 
void dragSkill (const SkillInfo *const info, const DragDropSourceT source, const int tag)
 
void clear ()
 
bool isEmpty () const
 
void select (const Item *const item)
 
void deselect ()
 
int getSelected () const
 
ItemColor getSelectedColor () const
 
bool isSelected () const
 
void clearItem (const Item *const item)
 
const std::string & getText () const
 
int getTag () const
 
void setItem (const int item)
 
bool isSourceItemContainer () const
 

Private Attributes

ImagemItemImage
 
std::string mText
 
std::string mItemData
 
DragDropSourceT mSource
 
int mItem
 
int mSelItem
 
int mTag
 
ItemColor mItemColor
 
ItemColor mSelItemColor
 

Detailed Description

Definition at line 39 of file dragdrop.h.

Constructor & Destructor Documentation

◆ DragDrop()

DragDrop::DragDrop ( Item *const  item,
const DragDropSourceT  source 
)
inline

Definition at line 42 of file dragdrop.h.

43  :
44  mItemImage(item != nullptr ? item->getImage() : nullptr),
45  mText(),
46  mItemData(),
47  mSource(source),
48  mItem(item != nullptr ? item->getId() : 0),
49  mSelItem(0),
50  mTag(-1),
51  mItemColor(item != nullptr ? item->getColor() : ItemColor_one),
53  {
54  if (mItemImage != nullptr)
55  mItemImage->incRef();
56  }
DragDropSourceT mSource
Definition: dragdrop.h:257
ItemColor mSelItemColor
Definition: dragdrop.h:262
Image * mItemImage
Definition: dragdrop.h:254
int mItem
Definition: dragdrop.h:258
ItemColor mItemColor
Definition: dragdrop.h:261
int mSelItem
Definition: dragdrop.h:259
std::string mText
Definition: dragdrop.h:255
int mTag
Definition: dragdrop.h:260
std::string mItemData
Definition: dragdrop.h:256
int getId() const
Definition: item.h:81
Image * getImage() const
Definition: item.h:87
ItemColor getColor() const
Definition: item.h:181
const ItemColor ItemColor_one
Definition: itemcolor.h:30

References mItemImage.

◆ ~DragDrop()

DragDrop::~DragDrop ( )
inline

Definition at line 60 of file dragdrop.h.

61  {
62  if (mItemImage != nullptr)
63  mItemImage->decRef();
64  }

References mItemImage.

Member Function Documentation

◆ clear()

void DragDrop::clear ( )
inline

◆ clearItem()

void DragDrop::clearItem ( const Item *const  item)
inline

Definition at line 228 of file dragdrop.h.

229  {
230  }

Referenced by Item::~Item().

◆ deselect()

void DragDrop::deselect ( )
inline

◆ dragCommand()

void DragDrop::dragCommand ( const TextCommand *const  command,
const DragDropSourceT  source,
const int  tag 
)
inline

Definition at line 117 of file dragdrop.h.

120  {
121  if (mItemImage != nullptr)
122  mItemImage->decRef();
123  mItem = 0;
125  mItemData.clear();
126 
127  if (command != nullptr)
128  {
129  mText = command->getSymbol();
130  mItemImage = command->getImage();
131  if (mItemImage != nullptr)
132  {
133  mItemImage->incRef();
134  }
135  else if (mText.empty())
136  {
137  mSource = source;
138  mTag = -1;
139  return;
140  }
141  mItem = command->getId();
142  }
143  else
144  {
145  mText.clear();
146  mItemImage = nullptr;
147  }
148  mSource = source;
149  mTag = tag;
150  }
int getId() const
Definition: textcommand.h:94
std::string getSymbol() const
Definition: textcommand.h:91
Image * getImage() const
Definition: textcommand.h:156

References TextCommand::getId(), TextCommand::getImage(), TextCommand::getSymbol(), ItemColor_one, mItem, mItemColor, mItemData, mItemImage, mSource, mTag, and mText.

Referenced by ItemShortcutContainer::mouseDragged(), and SpellShortcutContainer::mouseDragged().

◆ dragItem()

void DragDrop::dragItem ( const Item *const  item,
const DragDropSourceT  source,
const int  tag 
)
inline

Definition at line 87 of file dragdrop.h.

90  {
91  if (mItemImage != nullptr)
92  mItemImage->decRef();
93 
94  mItemData.clear();
95  mText.clear();
96  if (item != nullptr)
97  {
98  mItem = item->getId();
99  mItemColor = item->getColor();
100  mItemImage = item->getImage();
101  if (mItemImage != nullptr)
102  mItemImage->incRef();
103  mSource = source;
104  mTag = tag;
106  }
107  else
108  {
109  mItem = 0;
111  mItemImage = nullptr;
113  mTag = -1;
114  }
115  }
static void playSfx(const int item, const ItemSoundEvent::Type sound)

References DragDropSource::Empty, Item::getColor(), Item::getId(), Item::getImage(), ItemColor_one, mItem, mItemColor, mItemData, mItemImage, mSource, mTag, mText, ItemSoundManager::playSfx(), and ItemSoundEvent::TAKE.

Referenced by ItemShortcutContainer::mouseDragged(), VirtShortcutContainer::mouseDragged(), OutfitWindow::mouseDragged(), ItemContainer::mousePressed(), and EquipmentWindow::mousePressed().

◆ dragSkill()

void DragDrop::dragSkill ( const SkillInfo *const  info,
const DragDropSourceT  source,
const int  tag 
)
inline

Definition at line 152 of file dragdrop.h.

155  {
156  if (mItemImage != nullptr)
157  mItemImage->decRef();
158  mItem = 0;
160  mText.clear();
161  mItemImage = nullptr;
163  mTag = -1;
164  mItemData.clear();
165  if (info != nullptr)
166  {
167  const SkillData *const data = info->data;
168  if (data != nullptr)
169  {
170  mText = data->name;
171  mItemImage = data->icon;
172  if (mItemImage != nullptr)
173  mItemImage->incRef();
174  mSource = source;
175  mTag = tag;
176  }
177  mItem = info->id;
178  mItemColor = fromInt(info->customSelectedLevel,
179  ItemColor);
180  }
181  }
#define fromInt(val, name)
Definition: intdefines.h:46
uint16_t ItemColor
Definition: itemcolor.h:30
const ItemColor ItemColor_zero
Definition: itemcolor.h:30
uint32_t data
bool info(InputEvent &event)
Definition: commands.cpp:57

References data, DragDropSource::Empty, fromInt, Actions::info(), ItemColor_zero, mItem, mItemColor, mItemData, mItemImage, mSource, mTag, and mText.

Referenced by ItemShortcutContainer::mouseDragged(), SkillListBox::mouseDragged(), and SkillRectangleListBox::mouseDragged().

◆ getItem()

int DragDrop::getItem ( ) const
inline

◆ getItemColor()

ItemColor DragDrop::getItemColor ( ) const
inline

◆ getItemData()

std::string DragDrop::getItemData ( )
inline

Definition at line 81 of file dragdrop.h.

82  { return mItemData; }

References mItemData.

Referenced by ItemShortcutContainer::mouseReleased().

◆ getItemImage()

Image* DragDrop::getItemImage ( )
inline

Definition at line 75 of file dragdrop.h.

76  { return mItemImage; }

References mItemImage.

Referenced by Gui::draw().

◆ getSelected()

int DragDrop::getSelected ( ) const
inline

Definition at line 219 of file dragdrop.h.

220  { return mSelItem; }

References mSelItem.

Referenced by VirtShortcutContainer::mousePressed(), and OutfitWindow::mousePressed().

◆ getSelectedColor()

ItemColor DragDrop::getSelectedColor ( ) const
inline

Definition at line 222 of file dragdrop.h.

223  { return mSelItemColor; }

References mSelItemColor.

Referenced by VirtShortcutContainer::mousePressed(), and OutfitWindow::mousePressed().

◆ getSource()

DragDropSourceT DragDrop::getSource ( ) const
inline

◆ getTag()

int DragDrop::getTag ( ) const
inline

◆ getText()

const std::string& DragDrop::getText ( ) const
inline

Definition at line 232 of file dragdrop.h.

233  { return mText; }

References mText.

Referenced by Gui::draw().

◆ isEmpty()

bool DragDrop::isEmpty ( ) const
inline

◆ isSelected()

bool DragDrop::isSelected ( ) const
inline

Definition at line 225 of file dragdrop.h.

226  { return mSelItem > 0; }

References mSelItem.

Referenced by VirtShortcutContainer::mousePressed(), and OutfitWindow::mousePressed().

◆ isSourceItemContainer()

bool DragDrop::isSourceItemContainer ( ) const
inline

◆ select()

void DragDrop::select ( const Item *const  item)
inline

Definition at line 199 of file dragdrop.h.

200  {
201  if (item != nullptr)
202  {
203  mSelItem = item->getId();
204  mSelItemColor = item->getColor();
205  }
206  else
207  {
208  mSelItem = 0;
210  }
211  }

References Item::getColor(), Item::getId(), ItemColor_one, mSelItem, and mSelItemColor.

Referenced by ItemContainer::mousePressed().

◆ setItem()

void DragDrop::setItem ( const int  item)
inline

◆ setItemColor()

void DragDrop::setItemColor ( const ItemColor  color)
inline

Definition at line 72 of file dragdrop.h.

73  { mItemColor = color; }

References mItemColor.

Referenced by ItemShortcutContainer::mouseDragged().

◆ setItemData()

void DragDrop::setItemData ( const std::string &  data)
inline

Field Documentation

◆ mItem

int DragDrop::mItem
private

Definition at line 258 of file dragdrop.h.

Referenced by clear(), dragCommand(), dragItem(), dragSkill(), getItem(), and setItem().

◆ mItemColor

ItemColor DragDrop::mItemColor
private

Definition at line 261 of file dragdrop.h.

Referenced by clear(), dragCommand(), dragItem(), dragSkill(), getItemColor(), and setItemColor().

◆ mItemData

std::string DragDrop::mItemData
private

Definition at line 256 of file dragdrop.h.

Referenced by clear(), dragCommand(), dragItem(), dragSkill(), getItemData(), and setItemData().

◆ mItemImage

Image* DragDrop::mItemImage
private

Definition at line 254 of file dragdrop.h.

Referenced by clear(), dragCommand(), DragDrop(), dragItem(), dragSkill(), getItemImage(), and ~DragDrop().

◆ mSelItem

int DragDrop::mSelItem
private

Definition at line 259 of file dragdrop.h.

Referenced by deselect(), getSelected(), isSelected(), and select().

◆ mSelItemColor

ItemColor DragDrop::mSelItemColor
private

Definition at line 262 of file dragdrop.h.

Referenced by deselect(), getSelectedColor(), and select().

◆ mSource

DragDropSourceT DragDrop::mSource
private

◆ mTag

int DragDrop::mTag
private

Definition at line 260 of file dragdrop.h.

Referenced by clear(), dragCommand(), dragItem(), dragSkill(), and getTag().

◆ mText

std::string DragDrop::mText
private

Definition at line 255 of file dragdrop.h.

Referenced by clear(), dragCommand(), dragItem(), dragSkill(), and getText().


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