ManaPlus
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes

#include <skilldialog.h>

Inheritance diagram for SkillDialog:
Window ActionListener BasicContainer2 MouseListener WidgetListener BasicContainer Widget WidgetDeathListener Widget2

Public Member Functions

 SkillDialog ()
 
 ~SkillDialog ()
 
void postInit ()
 
void action (const ActionEvent &event)
 
std::string update (const int id)
 
void update ()
 
void updateModels ()
 
void loadXmlFile (const std::string &fileName, const SkipError skipError)
 
void clearSkills ()
 
void hideSkills (const SkillOwner::Type owner)
 
void loadSkills ()
 
bool updateSkill (const int id, const int range, const Modifiable modifiable, const SkillType::SkillType type, const int sp)
 
void addSkill (const SkillOwner::Type owner, const int id, const std::string &name, const int level, const int range, const Modifiable modifiable, const SkillType::SkillType type, const int sp)
 
SkillInfogetSkill (const int id) const
 
SkillInfogetSkillByItem (const int itemId) const
 
void setSkillDuration (const SkillOwner::Type owner, const int id, const int duration)
 
bool hasSkills () const
 
void widgetResized (const Event &event)
 
void useItem (const int itemId, const AutoTarget autoTarget, const int level, const std::string &data) const
 
void updateTabSelection ()
 
void updateQuest (const int var, const int val1, const int val2, const int val3, const int time1)
 
void playUpdateEffect (const int id) const
 
void playRemoveEffect (const int id) const
 
void playCastingDstTileEffect (const int id, const int level, const int x, const int y, const int delay) const
 
void slowLogic ()
 
void removeSkill (const int id)
 
SkillDatagetSkillData (const int id) const
 
SkillDatagetSkillDataByLevel (const int id, const int level) const
 
void selectSkillLevel (const int skillId, const int level)
 
void selectSkillCastType (const int skillId, const CastTypeT type)
 
void setSkillOffsetX (const int skillId, const int offset)
 
void setSkillOffsetY (const int skillId, const int offset)
 
- Public Member Functions inherited from Window
 Window (const std::string &caption="Window", const Modal modal=Modal_false, Window *const parent=0, std::string skin="")
 
virtual ~Window ()
 
void draw (Graphics *const graphics)
 
void safeDraw (Graphics *const graphics)
 
void setContentSize (int width, int height)
 
void setLocationRelativeTo (const Widget *const widget)
 
void setLocationHorisontallyRelativeTo (const Widget *const widget)
 
void setLocationRelativeTo (const ImagePosition::Type &position, int offsetX=0, int offsetY=0)
 
void setResizable (const bool resize)
 
void redraw ()
 
void widgetMoved (const Event &event)
 
void widgetHidden (const Event &event)
 
void setCloseButton (const bool flag)
 
bool getCloseButton () const
 
void setAllowClose (const bool b)
 
bool getAlowClose () const
 
bool isResizable () const
 
void setMinWidth (const int width)
 
int getMinWidth () const
 
void setMinHeight (const int height)
 
int getMinHeight () const
 
void setMaxWidth (const int width)
 
int getMaxWidth () const
 
void setMaxHeight (const int height)
 
int getMaxHeight () const
 
void setShowTitle (bool flag)
 
void setStickyButton (const bool flag)
 
void setSticky (const bool sticky)
 
bool isSticky () const
 
void setStickyButtonLock (const bool sticky)
 
bool isStickyButtonLock () const
 
virtual void setVisible (Visible visible)
 
void setVisible (const Visible visible, const bool forceSticky)
 
bool isDefaultVisible () const
 
void setDefaultVisible (const bool save)
 
bool willSaveVisible () const
 
void setSaveVisible (const bool save)
 
WindowgetParentWindow () const
 
virtual void scheduleDelete ()
 
void mousePressed (MouseEvent &event)
 
void mouseDragged (MouseEvent &event)
 
void mouseMoved (MouseEvent &event)
 
void mouseReleased (MouseEvent &event)
 
void mouseExited (MouseEvent &event)
 
void mouseEntered (MouseEvent &event)
 
void updateResizeHandler (MouseEvent &event)
 
void setWindowName (const std::string &name)
 
const std::string & getWindowName () const
 
void loadWindowState ()
 
void saveWindowState ()
 
void setDefaultSize (const int defaultX, const int defaultY, int defaultWidth, int defaultHeight)
 
void setDefaultSize ()
 
void setDefaultSize (const int defaultWidth, const int defaultHeight, const ImagePosition::Type &position, const int offsetx=0, const int offsetY=0)
 
virtual void resetToDefaultSize ()
 
void adjustPositionAfterResize (const int oldScreenWidth, const int oldScreenHeight)
 
LayoutgetLayout ()
 
void clearLayout ()
 
void reflowLayout (int w=0, int h=0)
 
LayoutCellplace (const int x, const int y, Widget *const wg, const int w=1, const int h=1)
 
ContainerPlacer getPlacer (const int x, const int y)
 
void center ()
 
void centerHorisontally ()
 
virtual void close ()
 
void setModal (const Modal modal)
 
Rect getWindowArea () const
 
bool isResizeAllowed (const MouseEvent &event) const
 
void setCaptionFont (Font *font)
 
void enableVisibleSound (bool b)
 
bool isWindowVisible () const
 
void setPadding (int padding)
 
int getPadding () const
 
void setTitleBarHeight (unsigned int height)
 
unsigned int getTitleBarHeight () const
 
void setCaption (const std::string &caption)
 
const std::string & getCaption () const
 
void setAlignment (Graphics::Alignment alignment)
 
Graphics::Alignment getAlignment () const
 
void setMovable (Move movable)
 
bool isMovable () const
 
Rect getChildrenArea ()
 
virtual void resizeToContent ()
 
- Public Member Functions inherited from BasicContainer2
 BasicContainer2 (const Widget2 *const widget)
 
virtual ~BasicContainer2 ()
 
void setOpaque (Opaque opaque)
 
bool isOpaque () const
 
virtual void add (Widget *const widget)
 
void addXY (Widget *const widget, const int x, const int y)
 
- Public Member Functions inherited from BasicContainer
 BasicContainer (const Widget2 *const widget)
 
virtual ~BasicContainer ()
 
void showWidgetPart (Widget *const widget, const Rect &area)
 
void moveToTop (Widget *const widget)
 
void moveToBottom (Widget *const widget)
 
void focusNext ()
 
void focusPrevious ()
 
void logic ()
 
void setFocusHandler (FocusHandler *const focusHandler)
 
void setInternalFocusHandler (FocusHandler *const focusHandler)
 
WidgetgetWidgetAt (int x, int y)
 
void death (const Event &event)
 
WidgetfindFirstWidget (const std::set< Widget *> &list)
 
void add (Widget *const widget)
 
virtual void remove (Widget *const widget)
 
virtual void clear ()
 
- Public Member Functions inherited from Widget
 Widget (const Widget2 *const widget)
 
virtual ~Widget ()
 
virtual void drawFrame (Graphics *graphics)
 
virtual void safeDrawFrame (Graphics *graphics)
 
void setFrameSize (const unsigned int frameSize)
 
unsigned int getFrameSize () const
 
WidgetgetParent () const
 
void setWidth (const int width)
 
int getWidth () const
 
void setHeight (const int height)
 
int getHeight () const
 
void setSize (const int width, const int height)
 
void setX (const int x)
 
int getX () const
 
void setY (const int y)
 
int getY () const
 
void setPosition (const int x, const int y)
 
void setDimension (const Rect &dimension)
 
const RectgetDimension () const
 
void setFocusable (const bool focusable)
 
bool isFocusable () const
 
virtual bool isFocused () const
 
void setEnabled (const bool enabled)
 
bool isEnabled () const
 
void setVisible (Visible visible)
 
bool isVisible () const
 
void setBaseColor (const Color &color)
 
const ColorgetBaseColor () const
 
void setForegroundColor (const Color &color)
 
const ColorgetForegroundColor () const
 
void setBackgroundColor (const Color &color)
 
const ColorgetBackgroundColor () const
 
virtual void requestFocus ()
 
virtual void requestMoveToTop ()
 
virtual void requestMoveToBottom ()
 
FocusHandlergetFocusHandler ()
 
void addActionListener (ActionListener *const actionListener)
 
void removeActionListener (ActionListener *const actionListener)
 
void addDeathListener (WidgetDeathListener *const deathListener)
 
void removeDeathListener (WidgetDeathListener *const deathListener)
 
void addMouseListener (MouseListener *const mouseListener)
 
void removeMouseListener (MouseListener *const mouseListener)
 
void addKeyListener (KeyListener *const keyListener)
 
void removeKeyListener (KeyListener *const keyListener)
 
void addFocusListener (FocusListener *const focusListener)
 
void removeFocusListener (FocusListener *const focusListener)
 
void addWidgetListener (WidgetListener *const widgetListener)
 
void removeWidgetListener (WidgetListener *const widgetListener)
 
void setActionEventId (const std::string &actionEventId)
 
const std::string & getActionEventId () const
 
virtual void getAbsolutePosition (int &x, int &y) const
 
virtual void setParent (Widget *parent)
 
FontgetFont () const
 
void setFont (Font *const font)
 
virtual void fontChanged ()
 
bool isTabInEnabled () const
 
void setTabInEnabled (const bool enabled)
 
bool isTabOutEnabled () const
 
void setTabOutEnabled (const bool enabled)
 
void requestModalFocus ()
 
virtual void requestModalMouseInputFocus ()
 
virtual void releaseModalFocus ()
 
virtual void releaseModalMouseInputFocus ()
 
virtual bool isModalFocused () const
 
virtual bool isModalMouseInputFocused () const
 
const std::list< MouseListener * > & getMouseListeners () const A_CONST
 
const std::list< KeyListener * > & getKeyListeners () const A_CONST
 
const std::list< FocusListener * > & getFocusListeners () const A_CONST
 
virtual FocusHandlergetInternalFocusHandler ()
 
void setInternalFocusHandler (FocusHandler *const internalFocusHandler)
 
void setId (const std::string &id)
 
const std::string & getId () const
 
virtual void showPart (const Rect &rectangle)
 
bool isAllowLogic () const
 
void setMouseConsume (const bool b)
 
bool isMouseConsume () const
 
void setRedraw (const bool b)
 
virtual bool isSelectable () const
 
void setSelectable (const bool selectable)
 
void windowResized ()
 
- Public Member Functions inherited from Widget2
virtual ~Widget2 ()
 
const ColorgetThemeColor (const ThemeColorIdT type, const unsigned int alpha=255U) const A_INLINE
 
const ColorgetThemeCharColor (const signed char c, bool &valid) const A_INLINE
 
virtual void setWidget2 (const Widget2 *const widget)
 
void setPalette (int palette)
 
void checkPalette ()
 
void setForegroundColor2 (const Color &color)
 
WidgetgetWindow () const
 
virtual void setWindow (Widget *const window)
 
- Public Member Functions inherited from WidgetDeathListener
virtual ~WidgetDeathListener ()
 
- Public Member Functions inherited from MouseListener
virtual ~MouseListener ()
 
virtual void mouseClicked (MouseEvent &event)
 
virtual void mouseWheelMovedUp (MouseEvent &event)
 
virtual void mouseWheelMovedDown (MouseEvent &event)
 
- Public Member Functions inherited from WidgetListener
virtual ~WidgetListener ()
 
virtual void widgetShown (const Event &event)
 
- Public Member Functions inherited from ActionListener
virtual ~ActionListener ()
 

Static Public Member Functions

static void useSkill (const int skillId, const AutoTarget autoTarget, int level, const bool withText, const std::string &text, CastTypeT castType, const int offsetX, const int offsetY)
 
static void useSkill (const SkillInfo *const info, const AutoTarget autoTarget, int level, const bool withText, const std::string &text, const CastTypeT castType, const int offsetX, const int offsetY)
 
- Static Public Member Functions inherited from Window
static void setWindowContainer (WindowContainer *const windowContainer)
 
- Static Public Member Functions inherited from Widget
static void setGlobalFont (Font *const font)
 
static FontgetGloablFont ()
 
static void cleanGlobalFont ()
 
static bool widgetExists (const Widget *const widget)
 
static void distributeWindowResizeEvent ()
 
static WidgetcallPostInit (Widget *const widget)
 

Private Types

typedef std::map< int, SkillInfo * > SkillMap
 

Private Member Functions

void addSkillDuration (SkillInfo *const skill)
 
SkillInfoloadSkill (const xmlNodePtr node, SkillModel *const model)
 
void loadSkillData (const xmlNodePtr node, SkillInfo *const skill)
 
void addDefaultTab ()
 

Static Private Member Functions

static void useSkillDefault (const SkillInfo *const info, const AutoTarget autoTarget, int level, const bool withText, const std::string &text, int offsetX, int offsetY)
 
static void useSkillTarget (const SkillInfo *const info, const AutoTarget autoTarget, int level, const bool withText, const std::string &text, const Being *being, int offsetX, int offsetY)
 
static void useSkillPosition (const SkillInfo *const info, int level, const bool withText, const std::string &text, const int x, const int y, int offsetX, int offsetY)
 
static std::string getDefaultSkillIcon (const SkillType::SkillType type)
 

Private Attributes

SkillMap mSkills
 
std::vector< SkillInfo * > mDurations
 
TabbedAreamTabs
 
std::list< Tab * > mDeleteTabs
 
LabelmPointsLabel
 
ButtonmUseButton
 
ButtonmIncreaseButton
 
SkillModelmDefaultModel
 
SkillTabmDefaultTab
 

Additional Inherited Members

- Data Fields inherited from Widget
Visible mVisible
 
- Protected Types inherited from BasicContainer
typedef std::vector< Widget * > WidgetList
 
typedef WidgetList::iterator WidgetListIterator
 
typedef WidgetList::const_iterator WidgetListConstIterator
 
typedef WidgetList::reverse_iterator WidgetListReverseIterator
 
typedef WidgetList::const_reverse_iterator WidgetListCReverseIterator
 
- Protected Types inherited from Widget
typedef std::list< MouseListener * > MouseListenerList
 
typedef MouseListenerList::iterator MouseListenerIterator
 
typedef std::list< KeyListener * > KeyListenerList
 
typedef KeyListenerList::iterator KeyListenerIterator
 
typedef std::list< ActionListener * > ActionListenerList
 
typedef ActionListenerList::iterator ActionListenerIterator
 
typedef std::list< WidgetDeathListener * > WidgetDeathListenerList
 
typedef WidgetDeathListenerList::iterator WidgetDeathListenerIterator
 
typedef std::list< FocusListener * > FocusListenerList
 
typedef FocusListenerList::iterator FocusListenerIterator
 
typedef std::list< WidgetListener * > WidgetListenerList
 
typedef WidgetListenerList::iterator WidgetListenerIterator
 
- Protected Member Functions inherited from Window
bool canMove () const
 
int getOption (const std::string &name, const int def=0) const
 
bool getOptionBool (const std::string &name, const bool def=false) const
 
void setTitlePadding (const int p)
 
int getTitlePadding () const
 
- Protected Member Functions inherited from BasicContainer
virtual void drawChildren (Graphics *const graphics)
 
virtual void safeDrawChildren (Graphics *const graphics)
 
virtual void logicChildren ()
 
- Protected Member Functions inherited from Widget
void distributeActionEvent ()
 
void distributeResizedEvent ()
 
void distributeMovedEvent ()
 
void distributeHiddenEvent ()
 
void distributeShownEvent ()
 
- Protected Member Functions inherited from Widget2
 Widget2 (const Widget2 *const widget)
 
- Protected Member Functions inherited from WidgetDeathListener
 WidgetDeathListener ()
 
- Protected Member Functions inherited from MouseListener
 MouseListener ()
 
- Protected Member Functions inherited from WidgetListener
 WidgetListener ()
 
- Protected Member Functions inherited from ActionListener
 ActionListener ()
 
- Protected Attributes inherited from Window
std::string mCaption
 
Graphics::Alignment mAlignment
 
int mPadding
 
unsigned int mTitleBarHeight
 
Move mMovable
 
int mDragOffsetX
 
int mDragOffsetY
 
bool mMoved
 
SkinmSkin
 
int mDefaultX
 
int mDefaultY
 
int mDefaultWidth
 
int mDefaultHeight
 
int mCaptionOffsetX
 
int mCaptionOffsetY
 
bool mShowTitle
 
bool mLastRedraw
 
- Protected Attributes inherited from BasicContainer2
Opaque mOpaque
 
- Protected Attributes inherited from BasicContainer
WidgetList mWidgets
 
WidgetList mLogicWidgets
 
- Protected Attributes inherited from Widget
MouseListenerList mMouseListeners
 
KeyListenerList mKeyListeners
 
ActionListenerList mActionListeners
 
WidgetDeathListenerList mDeathListeners
 
FocusListenerList mFocusListeners
 
WidgetListenerList mWidgetListeners
 
Color mForegroundColor
 
Color mBackgroundColor
 
Color mBaseColor
 
Rect mDimension
 
std::string mActionEventId
 
std::string mId
 
FocusHandlermFocusHandler
 
FocusHandlermInternalFocusHandler
 
WidgetmParent
 
FontmCurrentFont
 
unsigned int mFrameSize
 
bool mFocusable
 
bool mTabIn
 
bool mTabOut
 
bool mEnabled
 
bool mAllowLogic
 
bool mMouseConsume
 
bool mRedraw
 
bool mSelectable
 
- Protected Attributes inherited from Widget2
int mPaletteOffset
 
WidgetmWindow
 
Color mForegroundColor2
 
- Static Protected Attributes inherited from Widget
static FontmGlobalFont = 0
 

Detailed Description

The skill dialog.

Definition at line 55 of file skilldialog.h.

Member Typedef Documentation

◆ SkillMap

typedef std::map<int, SkillInfo*> SkillDialog::SkillMap
private

Definition at line 223 of file skilldialog.h.

Constructor & Destructor Documentation

◆ SkillDialog()

SkillDialog::SkillDialog ( )

Definition at line 83 of file skilldialog.cpp.

References TabbedArea::getTabContainer(), TabbedArea::getWidgetContainer(), Widget::getWidth(), mIncreaseButton, mPointsLabel, mTabs, mUseButton, Window::place(), SetupWindow::registerWindowForReset(), Window::setCloseButton(), Window::setDefaultSize(), Widget::setEnabled(), Window::setResizable(), Window::setSaveVisible(), Widget::setSelectable(), Window::setStickyButtonLock(), setupWindow, Window::setWindowName(), and windowContainer.

83  :
84  // TRANSLATORS: skills dialog name
85  Window(_("Skills"), Modal_false, nullptr, "skills.xml"),
87  mSkills(),
88  mDurations(),
90  mDeleteTabs(),
91  mPointsLabel(new Label(this, "0")),
92  // TRANSLATORS: skills dialog button
93  mUseButton(new Button(this, _("Use"), "use", this)),
94  // TRANSLATORS: skills dialog button
95  mIncreaseButton(new Button(this, _("Up"), "inc", this)),
96  mDefaultModel(nullptr),
97  mDefaultTab(nullptr)
98 {
99  setWindowName("Skills");
100  setCloseButton(true);
101  setResizable(true);
102  setSaveVisible(true);
103  setStickyButtonLock(true);
104  setDefaultSize(windowContainer->getWidth() - 280, 30, 275, 425);
105  if (setupWindow != nullptr)
107 
108  mUseButton->setEnabled(false);
109  mIncreaseButton->setEnabled(false);
110  mTabs->setSelectable(false);
113 
114  place(0, 0, mTabs, 5, 5);
115  place(0, 5, mPointsLabel, 4);
116  place(3, 5, mUseButton);
117  place(4, 5, mIncreaseButton);
118 }
void setDefaultSize()
Definition: window.cpp:1186
#define _(s)
Definition: gettext.h:34
int getWidth() const
Definition: widget.h:220
WindowContainer * windowContainer
Label * mPointsLabel
Definition: skilldialog.h:228
TabbedArea * mTabs
Definition: skilldialog.h:226
SkillTab * mDefaultTab
Definition: skilldialog.h:232
Button * mIncreaseButton
Definition: skilldialog.h:230
Definition: button.h:94
void registerWindowForReset(Window *const window)
void setSelectable(const bool selectable)
Definition: widget.h:947
Widget * getWidgetContainer() const
Definition: tabbedarea.h:243
Widget * getTabContainer() const
Definition: tabbedarea.h:240
Definition: label.h:87
Button * mUseButton
Definition: skilldialog.h:229
LayoutCell & place(const int x, const int y, Widget *const wg, const int w=1, const int h=1)
Definition: window.cpp:1372
SkillModel * mDefaultModel
Definition: skilldialog.h:231
std::list< Tab * > mDeleteTabs
Definition: skilldialog.h:227
void setCloseButton(const bool flag)
Definition: window.cpp:737
void setEnabled(const bool enabled)
Definition: widget.h:351
void setSaveVisible(const bool save)
Definition: window.h:298
void setResizable(const bool resize)
Definition: window.cpp:615
void setStickyButtonLock(const bool sticky)
Definition: window.cpp:760
SetupWindow * setupWindow
Definition: setupwindow.cpp:63
SkillMap mSkills
Definition: skilldialog.h:224
#define CREATEWIDGETR(type,...)
Definition: createwidget.h:35
std::vector< SkillInfo * > mDurations
Definition: skilldialog.h:225
Window(const std::string &caption="Window", const Modal modal=Modal_false, Window *const parent=0, std::string skin="")
Definition: window.cpp:108
void setWindowName(const std::string &name)
Definition: window.h:353

◆ ~SkillDialog()

SkillDialog::~SkillDialog ( )

Definition at line 128 of file skilldialog.cpp.

References clearSkills().

129 {
130  clearSkills();
131 }
void clearSkills()

Member Function Documentation

◆ action()

void SkillDialog::action ( const ActionEvent event)
virtual

Called when receiving actions from widget.

Implements ActionListener.

Definition at line 154 of file skilldialog.cpp.

References _, CAST_S32, CAST_U16, config, SkillInfo::customCastType, SkillInfo::customOffsetX, SkillInfo::customOffsetY, SkillInfo::customSelectedLevel, fromBool, Configuration::getBoolValue(), SkillTab::getSelectedInfo(), TabbedArea::getSelectedTab(), ShortcutWindow::getTabIndex(), Net::PlayerHandler::increaseSkill(), Actions::info(), itemShortcut, itemShortcutWindow, mIncreaseButton, mTabs, mUseButton, playerHandler, Button::setCaption(), Widget::setEnabled(), ItemShortcut::setItemSelected(), Window::setVisible(), SHORTCUT_TABS, SKILL_MIN_ID, SKILL_VAR_MIN_ID, useSkill(), SkillInfo::useTextParameter, and Visible_false.

155 {
156  const std::string &eventId = event.getId();
157  if (eventId == "inc")
158  {
159  if (playerHandler == nullptr)
160  return;
161  const SkillTab *const tab = static_cast<const SkillTab *>(
162  mTabs->getSelectedTab());
163  if (tab != nullptr)
164  {
165  if (const SkillInfo *const info = tab->getSelectedInfo())
167  }
168  }
169  else if (eventId == "sel")
170  {
171  const SkillTab *const tab = static_cast<const SkillTab *>(
172  mTabs->getSelectedTab());
173  if (tab != nullptr)
174  {
175  if (const SkillInfo *const info = tab->getSelectedInfo())
176  {
177  mUseButton->setEnabled(info->isUsable());
178  mUseButton->setCaption(info->useButton);
180  const int num = itemShortcutWindow->getTabIndex();
181  if (num >= 0 && num < CAST_S32(SHORTCUT_TABS)
182  && (itemShortcut[num] != nullptr))
183  {
185  info->id + SKILL_MIN_ID);
186  }
187  }
188  else
189  {
190  mUseButton->setEnabled(false);
191  mIncreaseButton->setEnabled(false);
192  // TRANSLATORS: skills dialog button
193  mUseButton->setCaption(_("Use"));
194  }
195  }
196  }
197  else if (eventId == "use")
198  {
199  const SkillTab *const tab = static_cast<const SkillTab *>(
200  mTabs->getSelectedTab());
201  if (tab != nullptr)
202  {
203  const SkillInfo *const info = tab->getSelectedInfo();
204  if (info == nullptr)
205  return;
206  useSkill(info,
207  fromBool(config.getBoolValue("skillAutotarget"), AutoTarget),
208  info->customSelectedLevel,
209  info->useTextParameter,
210  std::string(),
211  info->customCastType,
212  info->customOffsetX,
213  info->customOffsetY);
214  }
215  }
216  else if (eventId == "close")
217  {
219  }
220 }
Net::PlayerHandler * playerHandler
Definition: net.cpp:89
#define _(s)
Definition: gettext.h:34
void setItemSelected(const int itemId)
Definition: itemshortcut.h:125
virtual void increaseSkill(const uint16_t skillId) const =0
bool useTextParameter
Definition: skillinfo.h:82
TabbedArea * mTabs
Definition: skilldialog.h:226
CastTypeT customCastType
Definition: skillinfo.h:78
Button * mIncreaseButton
Definition: skilldialog.h:230
Configuration config
const unsigned int SKILL_VAR_MIN_ID
Definition: skill.h:25
SkillInfo * getSelectedInfo() const
Definition: skilltab.h:66
int customOffsetY
Definition: skillinfo.h:66
const int SKILL_MIN_ID
Definition: skill.h:24
#define CAST_U16
Definition: cast.h:28
bool getBoolValue(const std::string &key) const
void setCaption(const std::string &caption)
Definition: button.h:214
#define CAST_S32
Definition: cast.h:29
bool AutoTarget
Definition: autotarget.h:29
int getTabIndex() const
const bool Visible_false
Definition: visible.h:29
#define fromBool(val, name)
Definition: booldefines.h:48
bool info(InputEvent &event)
Definition: commands.cpp:56
Button * mUseButton
Definition: skilldialog.h:229
int customOffsetX
Definition: skillinfo.h:65
ShortcutWindow * itemShortcutWindow
const unsigned int SHORTCUT_TABS
Definition: itemshortcut.h:27
int customSelectedLevel
Definition: skillinfo.h:64
ItemShortcut * itemShortcut[SHORTCUT_TABS]
void setEnabled(const bool enabled)
Definition: widget.h:351
static void useSkill(const int skillId, const AutoTarget autoTarget, int level, const bool withText, const std::string &text, CastTypeT castType, const int offsetX, const int offsetY)
virtual void setVisible(Visible visible)
Definition: window.cpp:766
Tab * getSelectedTab() const
Definition: tabbedarea.h:174

◆ addDefaultTab()

void SkillDialog::addDefaultTab ( )
private

Definition at line 133 of file skilldialog.cpp.

References _, Widget::addActionListener(), TabbedArea::addTab(), TabbedArea::adjustTabPositions(), mDefaultModel, mDefaultTab, mDeleteTabs, mTabs, Opaque_false, Widget::setActionEventId(), ScrollArea::setHorizontalScrollPolicy(), TabbedArea::setSelectedTabDefault(), ScrollArea::setVerticalScrollPolicy(), Widget::setVisible(), ScrollArea::SHOW_ALWAYS, ScrollArea::SHOW_NEVER, and Visible_false.

Referenced by hasSkills(), and loadSkills().

134 {
136  SkillListBox *const listbox = new SkillListBox(this,
137  mDefaultModel);
138  listbox->setActionEventId("sel");
139  listbox->addActionListener(this);
140  ScrollArea *const scroll = new ScrollArea(this,
141  listbox,
142  Opaque_false);
145  // TRANSLATORS: unknown skills tab name
146  mDefaultTab = new SkillTab(this, _("Unknown"), listbox);
147  mDeleteTabs.push_back(mDefaultTab);
149  mTabs->addTab(mDefaultTab, scroll);
152 }
void adjustTabPositions()
Definition: tabbedarea.cpp:596
#define _(s)
Definition: gettext.h:34
TabbedArea * mTabs
Definition: skilldialog.h:226
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:251
void setVisible(Visible visible)
Definition: widget.cpp:224
SkillTab * mDefaultTab
Definition: skilldialog.h:232
void setActionEventId(const std::string &actionEventId)
Definition: widget.h:595
void setVerticalScrollPolicy(const ScrollPolicy vPolicy)
const bool Visible_false
Definition: visible.h:29
void setSelectedTabDefault()
Definition: tabbedarea.cpp:423
SkillModel * mDefaultModel
Definition: skilldialog.h:231
std::list< Tab * > mDeleteTabs
Definition: skilldialog.h:227
const bool Opaque_false
Definition: opaque.h:29
void addTab(Tab *const tab, Widget *const widget)
Definition: tabbedarea.cpp:229
void setHorizontalScrollPolicy(const ScrollPolicy hPolicy)

◆ addSkill()

void SkillDialog::addSkill ( const SkillOwner::Type  owner,
const int  id,
const std::string &  name,
const int  level,
const int  range,
const Modifiable  modifiable,
const SkillType::SkillType  type,
const int  sp 
)

Definition at line 709 of file skilldialog.cpp.

References _, SkillModel::addSkill(), TabbedArea::adjustTabPositions(), SkillInfo::alwaysVisible, SkillData::autoTab, CAST_U32, data, SkillInfo::data, SkillData::description, SkillData::dispName, SkillInfo::errorText, getDefaultSkillIcon(), Configuration::getStringValue(), SkillData::haveIcon, SkillInfo::id, SkillInfo::level, mDefaultModel, mDefaultTab, SkillInfo::model, SkillInfo::modifiable, mSkills, mTabs, SkillData::name, SkillInfo::owner, paths, SkillInfo::range, SkillData::setIcon(), TabbedArea::setSelectedTabDefault(), settings, Widget::setVisible(), SkillData::shortName, Actions::skill(), SkillInfo::skillLevel, SkillInfo::sp, strprintf(), SkillInfo::tab, Catch::toString(), SkillInfo::type, Settings::unknownSkillsAutoTab, SkillInfo::update(), SkillModel::updateVisibilities(), SkillInfo::useButton, SkillInfo::visible, Visible_false, and Visible_true.

Referenced by EAthena::GuildRecv::processGuildSkillInfo(), EAthena::HomunculusRecv::processHomunculusSkills(), EAthena::HomunculusRecv::processHomunculusSkillUp(), EAthena::MercenaryRecv::processMercenarySkills(), TmwAthena::SkillRecv::processPlayerSkills(), EAthena::SkillRecv::processPlayerSkills(), Ea::SkillRecv::processPlayerSkillUp(), EAthena::SkillRecv::processSkillAdd(), EAthena::SkillRecv::processSkillAdd2(), EAthena::SkillRecv::processSkillUpdate(), EAthena::SkillRecv::processSkillUpdate2(), and setSkillDuration().

717 {
718  if (mDefaultModel != nullptr)
719  {
720  SkillInfo *const skill = new SkillInfo;
721  skill->id = CAST_U32(id);
722  skill->type = type;
723  skill->owner = owner;
724  SkillData *const data = skill->data;
725  if (name.empty())
726  {
727  data->name = "Unknown skill Id: " + toString(id);
728  data->dispName = data->name;
729  }
730  else
731  {
732  data->name = name;
733  data->dispName = strprintf("%s, %u", name.c_str(), skill->id);
734  }
735  data->description.clear();
736  const std::string icon = getDefaultSkillIcon(type);
737  if (icon.empty())
738  {
739  data->setIcon(paths.getStringValue("missingSkillIcon"));
740  data->haveIcon = false;
741  }
742  else
743  {
744  data->setIcon(icon);
745  data->haveIcon = true;
746  }
748  data->shortName = toString(skill->id);
749  skill->modifiable = modifiable;
750  skill->visible = Visible_false;
751  skill->alwaysVisible = Visible_false;
752  skill->model = mDefaultModel;
753  skill->level = level;
754  // TRANSLATORS: skills dialog. skill level
755  skill->skillLevel = strprintf(_("Lvl: %d"), level);
756  skill->range = range;
757  skill->sp = sp;
758  skill->update();
759  // TRANSLATORS: skills dialog button
760  skill->useButton = _("Use");
761  // TRANSLATORS: skill error message
762  skill->errorText = strprintf(_("Failed skill: %s"), name.c_str());
763  skill->tab = mDefaultTab;
764  mDefaultModel->addSkill(skill);
768 
769  mSkills[id] = skill;
771  }
772 }
void adjustTabPositions()
Definition: tabbedarea.cpp:596
#define CAST_U32
Definition: cast.h:30
unsigned int id
Definition: skillinfo.h:68
std::string getStringValue(const std::string &key) const
#define _(s)
Definition: gettext.h:34
void addSkill(SkillInfo *const info)
Definition: skillmodel.h:48
bool skill(InputEvent &event)
Definition: commands.cpp:96
static std::string getDefaultSkillIcon(const SkillType::SkillType type)
std::string useButton
Definition: skillinfo.h:53
const bool Visible_true
Definition: visible.h:29
TabbedArea * mTabs
Definition: skilldialog.h:226
void setVisible(Visible visible)
Definition: widget.cpp:224
SkillTab * mDefaultTab
Definition: skilldialog.h:232
SkillTab * tab
Definition: skillinfo.h:61
std::string name
Definition: skilldata.h:33
std::string description
Definition: skilldata.h:36
void updateVisibilities()
Definition: skillmodel.cpp:53
SkillOwner::Type owner
Definition: skillinfo.h:77
std::string errorText
Definition: skillinfo.h:54
SkillData * data
Definition: skillinfo.h:62
Settings settings
Definition: settings.cpp:31
Modifiable modifiable
Definition: skillinfo.h:79
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
const bool Visible_false
Definition: visible.h:29
uint32_t data
void setSelectedTabDefault()
Definition: tabbedarea.cpp:423
bool unknownSkillsAutoTab
Definition: settings.h:162
SkillModel * mDefaultModel
Definition: skilldialog.h:231
int level
Definition: skillinfo.h:63
int range
Definition: skillinfo.h:69
void setIcon(const std::string &iconPath)
Definition: skilldata.cpp:70
int sp
Definition: skillinfo.h:70
Visible alwaysVisible
Definition: skillinfo.h:81
std::string skillLevel
Definition: skillinfo.h:51
bool haveIcon
Definition: skilldata.h:57
Configuration paths
void update()
Definition: skillinfo.cpp:82
std::string toString(T const &value)
converts any type to a string
Definition: catch.hpp:1774
std::string dispName
Definition: skilldata.h:35
Visible visible
Definition: skillinfo.h:80
SkillMap mSkills
Definition: skilldialog.h:224
SkillType::SkillType type
Definition: skillinfo.h:76
bool autoTab
Definition: skilldata.h:58
std::string shortName
Definition: skilldata.h:34
SkillModel * model
Definition: skillinfo.h:60

◆ addSkillDuration()

void SkillDialog::addSkillDuration ( SkillInfo *const  skill)
private

Definition at line 1351 of file skilldialog.cpp.

References FOR_EACH, SkillInfo::id, and mDurations.

Referenced by hasSkills(), and setSkillDuration().

1352 {
1353  if (skill == nullptr)
1354  return;
1355 
1356  FOR_EACH (STD_VECTOR<SkillInfo*>::const_iterator, it, mDurations)
1357  {
1358  if ((*it)->id == skill->id)
1359  return;
1360  }
1361  mDurations.push_back(skill);
1362 }
unsigned int id
Definition: skillinfo.h:68
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
std::vector< SkillInfo * > mDurations
Definition: skilldialog.h:225

◆ clearSkills()

void SkillDialog::clearSkills ( )

Definition at line 304 of file skilldialog.cpp.

References delete_all(), mDefaultModel, mDefaultTab, mDeleteTabs, mDurations, mSkills, mTabs, and TabbedArea::removeAll().

Referenced by loadSkills(), and ~SkillDialog().

305 {
306  mTabs->removeAll();
307  mDeleteTabs.clear();
308  mDefaultTab = nullptr;
309  mDefaultModel = nullptr;
310 
312  mSkills.clear();
313  mDurations.clear();
314 }
TabbedArea * mTabs
Definition: skilldialog.h:226
SkillTab * mDefaultTab
Definition: skilldialog.h:232
void delete_all(Container &c)
Definition: dtor.h:55
SkillModel * mDefaultModel
Definition: skilldialog.h:231
std::list< Tab * > mDeleteTabs
Definition: skilldialog.h:227
SkillMap mSkills
Definition: skilldialog.h:224
std::vector< SkillInfo * > mDurations
Definition: skilldialog.h:225
void removeAll(const bool del=true)
Definition: tabbedarea.cpp:719

◆ getDefaultSkillIcon()

std::string SkillDialog::getDefaultSkillIcon ( const SkillType::SkillType  type)
staticprivate

Definition at line 677 of file skilldialog.cpp.

References SkillType::Attack, Configuration::getStringValue(), SkillType::Ground, paths, SkillType::Self, SkillType::Support, SkillType::TargetTrap, SkillType::Unknown, and SkillType::Unused.

Referenced by addSkill(), and hasSkills().

678 {
679  std::string icon;
680  switch (type)
681  {
682  case SkillType::Attack:
683  icon = paths.getStringValue("attackSkillIcon");
684  break;
685  case SkillType::Ground:
686  icon = paths.getStringValue("groundSkillIcon");
687  break;
688  case SkillType::Self:
689  icon = paths.getStringValue("selfSkillIcon");
690  break;
691  case SkillType::Unused:
692  icon = paths.getStringValue("unusedSkillIcon");
693  break;
694  case SkillType::Support:
695  icon = paths.getStringValue("supportSkillIcon");
696  break;
698  icon = paths.getStringValue("trapSkillIcon");
699  break;
700  case SkillType::Unknown:
701  icon = paths.getStringValue("unknownSkillIcon");
702  break;
703  default:
704  break;
705  }
706  return icon;
707 }
std::string getStringValue(const std::string &key) const
Configuration paths

◆ getSkill()

SkillInfo * SkillDialog::getSkill ( const int  id) const

Definition at line 774 of file skilldialog.cpp.

References mSkills.

Referenced by Actions::changeRelation(), ItemShortcutContainer::draw(), Being::handleSkill(), loadSkill(), EAthena::SkillRecv::processSkillFailed(), ItemShortcutContainer::safeDraw(), selectSkillCastType(), selectSkillLevel(), Being::setAction(), setSkillOffsetX(), setSkillOffsetY(), and useSkill().

775 {
776  SkillMap::const_iterator it = mSkills.find(id);
777  if (it != mSkills.end())
778  return (*it).second;
779  return nullptr;
780 }
SkillMap mSkills
Definition: skilldialog.h:224

◆ getSkillByItem()

SkillInfo * SkillDialog::getSkillByItem ( const int  itemId) const

Definition at line 782 of file skilldialog.cpp.

References mSkills, and SKILL_MIN_ID.

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

783 {
784  SkillMap::const_iterator it = mSkills.find(itemId - SKILL_MIN_ID);
785  if (it != mSkills.end())
786  return (*it).second;
787  return nullptr;
788 }
const int SKILL_MIN_ID
Definition: skill.h:24
SkillMap mSkills
Definition: skilldialog.h:224

◆ getSkillData()

SkillData * SkillDialog::getSkillData ( const int  id) const

Definition at line 901 of file skilldialog.cpp.

References SkillInfo::data, Actions::info(), and mSkills.

Referenced by hasSkills(), playRemoveEffect(), and playUpdateEffect().

902 {
903  const SkillMap::const_iterator it = mSkills.find(id);
904  if (it != mSkills.end())
905  {
906  SkillInfo *const info = it->second;
907  if (info != nullptr)
908  return info->data;
909  }
910  return nullptr;
911 }
SkillData * data
Definition: skillinfo.h:62
bool info(InputEvent &event)
Definition: commands.cpp:56
SkillMap mSkills
Definition: skilldialog.h:224

◆ getSkillDataByLevel()

SkillData * SkillDialog::getSkillDataByLevel ( const int  id,
const int  level 
) const

Definition at line 913 of file skilldialog.cpp.

References SkillInfo::getData1(), Actions::info(), and mSkills.

Referenced by Being::addCast(), Being::getHitEffect(), Being::handleSkillCasting(), hasSkills(), and playCastingDstTileEffect().

915 {
916  const SkillMap::const_iterator it = mSkills.find(id);
917  if (it != mSkills.end())
918  {
919  SkillInfo *const info = it->second;
920  if (info != nullptr)
921  return info->getData1(level);
922  }
923  return nullptr;
924 }
bool info(InputEvent &event)
Definition: commands.cpp:56
SkillData * getData1(const int level) const
Definition: skillinfo.cpp:190
SkillMap mSkills
Definition: skilldialog.h:224

◆ hasSkills()

bool SkillDialog::hasSkills ( ) const
inline

◆ hideSkills()

void SkillDialog::hideSkills ( const SkillOwner::Type  owner)

Definition at line 316 of file skilldialog.cpp.

References SkillInfo::alwaysVisible, FOR_EACH, SkillInfo::id, Actions::info(), mSkills, SkillInfo::owner, PlayerInfo::setSkillLevel(), SkillInfo::visible, and Visible_false.

Referenced by EAthena::MercenaryRecv::handleMercenaryMessage(), EAthena::GuildRecv::processGuildSkillInfo(), EAthena::HomunculusRecv::processHomunculusSkills(), EAthena::MercenaryRecv::processMercenarySkills(), and EAthena::SkillRecv::processPlayerSkills().

317 {
318  FOR_EACH (SkillMap::iterator, it, mSkills)
319  {
320  SkillInfo *const info = (*it).second;
321  if ((info != nullptr) && info->owner == owner)
322  {
323  PlayerInfo::setSkillLevel(info->id, 0);
324  if (info->alwaysVisible == Visible_false)
325  info->visible = Visible_false;
326  }
327  }
328 }
unsigned int id
Definition: skillinfo.h:68
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
SkillOwner::Type owner
Definition: skillinfo.h:77
const bool Visible_false
Definition: visible.h:29
bool info(InputEvent &event)
Definition: commands.cpp:56
Visible alwaysVisible
Definition: skillinfo.h:81
void setSkillLevel(const int id, const int value)
Definition: playerinfo.cpp:126
Visible visible
Definition: skillinfo.h:80
SkillMap mSkills
Definition: skilldialog.h:224

◆ loadSkill()

SkillInfo * SkillDialog::loadSkill ( const xmlNodePtr  node,
SkillModel *const  model 
)
private

Definition at line 467 of file skilldialog.cpp.

References _, SkillModel::addSkill(), SkillInfo::alwaysVisible, SpriteAction::CAST(), CAST_U32, SkillInfo::castingAction, SkillInfo::castingRideAction, SkillInfo::castingSkyAction, SkillInfo::castingWaterAction, SpriteAction::CASTRIDE(), SpriteAction::CASTSKY(), SpriteAction::CASTWATER(), SkillInfo::errorText, fromBool, XML::getBoolProperty(), XML::getIntProperty(), XML::getProperty(), getSkill(), SkillInfo::id, XML::langProperty(), loadSkillData(), SkillInfo::model, ServerCommandType::model, SkillInfo::modifiable, Modifiable_false, mSkills, SkillInfo::owner, parseOwner(), Actions::skill(), SKILL_VAR_MIN_ID, strprintf(), SkillInfo::update(), SkillInfo::useButton, SkillInfo::useTextParameter, SkillInfo::visible, SkillInfo::x, and SkillInfo::y.

Referenced by hasSkills(), and loadXmlFile().

469 {
470  int id = XML::getIntProperty(node, "id", -1, -1, 1000000);
471  if (id == -1)
472  {
473  id = XML::getIntProperty(node, "var", -1, -1, 100000);
474  if (id == -1)
475  return nullptr;
476  id += SKILL_VAR_MIN_ID;
477  }
478 
479  SkillInfo *skill = getSkill(id);
480  if (skill == nullptr)
481  {
482  std::string name = XML::langProperty(node, "name",
483  // TRANSLATORS: skills dialog. skill id
484  strprintf(_("Skill %d"), id));
485 
486  skill = new SkillInfo;
487  skill->id = CAST_U32(id);
488  skill->modifiable = Modifiable_false;
489  skill->model = model;
490  skill->update();
491  skill->useButton = XML::getProperty(
492  // TRANSLATORS: skills dialog button
493  node, "useButton", _("Use"));
495  node, "owner", "player"));
496  skill->errorText = XML::getProperty(
497  node, "errorText", name);
499  node, "alwaysVisible", false), Visible);
500  skill->castingAction = XML::getProperty(node,
501  "castingAction", SpriteAction::CAST);
502  skill->castingRideAction = XML::getProperty(node,
503  "castingRideAction", SpriteAction::CASTRIDE);
504  skill->castingSkyAction = XML::getProperty(node,
505  "castingSkyAction", SpriteAction::CASTSKY);
506  skill->castingWaterAction = XML::getProperty(node,
507  "castingWaterAction", SpriteAction::CASTWATER);
509  node, "useTextParameter", false);
510  skill->x = XML::getProperty(node,
511  "x", 0);
512  skill->y = XML::getProperty(node,
513  "y", 0);
514  skill->visible = skill->alwaysVisible;
515  model->addSkill(skill);
516  mSkills[id] = skill;
517  }
518 
519  loadSkillData(node, skill);
520  return skill;
521 }
#define CAST_U32
Definition: cast.h:30
unsigned int id
Definition: skillinfo.h:68
#define _(s)
Definition: gettext.h:34
void addSkill(SkillInfo *const info)
Definition: skillmodel.h:48
bool skill(InputEvent &event)
Definition: commands.cpp:96
std::string useButton
Definition: skillinfo.h:53
static const std::string CASTRIDE("castride")
bool useTextParameter
Definition: skillinfo.h:82
static SkillOwner::Type parseOwner(const std::string &str)
Definition: skilldialog.cpp:72
std::string castingWaterAction
Definition: skillinfo.h:58
int getProperty(const xmlNodePtr node, const char *const name, int def)
Definition: libxml.cpp:171
const unsigned int SKILL_VAR_MIN_ID
Definition: skill.h:25
void loadSkillData(const xmlNodePtr node, SkillInfo *const skill)
std::string castingRideAction
Definition: skillinfo.h:56
SkillOwner::Type owner
Definition: skillinfo.h:77
std::string errorText
Definition: skillinfo.h:54
int getIntProperty(const xmlNodePtr node, const char *const name, int def, const int min, const int max)
Definition: libxml.cpp:187
SkillInfo * getSkill(const int id) const
std::string castingAction
Definition: skillinfo.h:55
Modifiable modifiable
Definition: skillinfo.h:79
static const std::string CASTWATER("castwater")
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
#define fromBool(val, name)
Definition: booldefines.h:48
bool getBoolProperty(const xmlNodePtr node, const char *const name, const bool def)
Definition: libxml.cpp:266
static const std::string CAST("cast")
static const std::string CASTSKY("castsky")
const bool Modifiable_false
Definition: modifiable.h:29
Visible alwaysVisible
Definition: skillinfo.h:81
std::string castingSkyAction
Definition: skillinfo.h:57
void update()
Definition: skillinfo.cpp:82
std::string langProperty(const xmlNodePtr node, const char *const name, const std::string &def)
Definition: libxml.cpp:255
Visible visible
Definition: skillinfo.h:80
SkillMap mSkills
Definition: skilldialog.h:224
SkillModel * model
Definition: skillinfo.h:60

◆ loadSkillData()

void SkillDialog::loadSkillData ( const xmlNodePtr  node,
SkillInfo *const  skill 
)
private

Definition at line 523 of file skilldialog.cpp.

References _, SkillInfo::addData(), SkillInfo::alwaysVisible, SkillData::autoTab, SkillData::castingAnimation, SkillData::castingDstEffectId, SkillData::castingGroundEffectId, SkillData::castingMissile, SkillData::castingSrcEffectId, data, SoundInfo::delay, SkillData::description, MissileInfo::dieDistance, SkillData::dispName, SkillData::dstEffectId, XML::getBoolProperty(), SkillInfo::getData(), XML::getFloatProperty(), XML::getProperty(), Configuration::getStringValue(), SkillData::haveIcon, SkillData::hitEffectId, SkillInfo::id, SkillData::invokeCmd, XML::langProperty(), MissileInfo::lifeTime, SkillData::missEffectId, SkillData::missile, SkillData::name, MissileInfo::particle, paths, SkillData::removeEffectId, SkillData::setIcon(), SkillData::shortName, SKILL_VAR_MIN_ID, SoundInfo::sound, SkillData::soundHit, SkillData::soundMiss, MissileInfo::speed, SkillData::srcEffectId, strprintf(), SkillData::updateEffectId, Visible_true, and MissileInfo::z.

Referenced by hasSkills(), loadSkill(), and loadXmlFile().

525 {
526  if (skill == nullptr)
527  return;
528  const int level = (skill->alwaysVisible == Visible_true) ?
529  0 : XML::getProperty(node, "level", 0);
530  SkillData *data = skill->getData(level);
531  if (data == nullptr)
532  data = new SkillData;
533 
534  const std::string name = XML::langProperty(node, "name",
535  // TRANSLATORS: skills dialog. skill id
536  strprintf(_("Skill %u"), skill->id));
537  data->name = name;
538  const std::string icon = XML::getProperty(node, "icon", "");
539  if (icon.empty())
540  {
541  data->setIcon(paths.getStringValue("missingSkillIcon"));
542  data->haveIcon = false;
543  }
544  else
545  {
546  data->setIcon(icon);
547  data->haveIcon = true;
548  }
549  if (skill->id < SKILL_VAR_MIN_ID)
550  {
551  data->dispName = strprintf("%s, %u",
552  name.c_str(),
553  skill->id);
554  }
555  else
556  {
557  data->dispName = strprintf("%s, (%u)",
558  name.c_str(),
559  skill->id - SKILL_VAR_MIN_ID);
560  }
561  data->shortName = XML::langProperty(node,
562  "shortName", name.substr(0, 3));
564  node, "description", "");
565 
566  MissileInfo &missile = data->missile;
567  missile.particle = XML::getProperty(
568  node, "missile-particle", "");
569  missile.z = XML::getFloatProperty(
570  node, "missile-z", 32.0f);
571  missile.lifeTime = XML::getProperty(
572  node, "missile-lifetime", 500);
573  missile.speed = XML::getFloatProperty(
574  node, "missile-speed", 7.0f);
576  node, "missile-diedistance", 8.0f);
577 
578  MissileInfo &castingMissile = data->castingMissile;
579  castingMissile.particle = XML::getProperty(
580  node, "castingMissile-particle", "");
581  castingMissile.z = XML::getFloatProperty(
582  node, "castingMissile-z", 32.0f);
583  castingMissile.lifeTime = XML::getProperty(
584  node, "castingMissile-lifetime", 500);
585  castingMissile.speed = XML::getFloatProperty(
586  node, "castingMissile-speed", 7.0f);
587  castingMissile.dieDistance = XML::getFloatProperty(
588  node, "castingMissile-diedistance", 8.0f);
589 
591  node,
592  "castingAnimation",
593  paths.getStringValue("skillCastingAnimation"));
594 
596  node, "soundHit", "");
598  node, "soundHitDelay", 0);
600  node, "soundMiss", "");
602  node, "soundMissDelay", 0);
603  data->invokeCmd = XML::getProperty(
604  node, "invokeCmd", "");
606  node, "levelUpEffectId", -1);
608  node, "removeEffectId", -1);
610  node, "hitEffectId", -1);
612  node, "missEffectId", -1);
614  node, "castingSrcEffectId", -1);
616  node, "castingDstEffectId", -1);
618  node, "srcEffectId", -1);
620  node, "dstEffectId", -1);
622  node, "castingGroundEffectId", -1);
624  node, "autoTab", true);
625 
626  skill->addData(level, data);
627 }
unsigned int id
Definition: skillinfo.h:68
std::string getStringValue(const std::string &key) const
#define _(s)
Definition: gettext.h:34
int castingGroundEffectId
Definition: skilldata.h:54
float getFloatProperty(const xmlNodePtr node, const char *const name, float def)
Definition: libxml.cpp:208
std::string sound
Definition: soundinfo.h:44
const bool Visible_true
Definition: visible.h:29
int hitEffectId
Definition: skilldata.h:50
SkillData * getData(const int level) const
Definition: skillinfo.cpp:182
std::string name
Definition: skilldata.h:33
std::string description
Definition: skilldata.h:36
int getProperty(const xmlNodePtr node, const char *const name, int def)
Definition: libxml.cpp:171
const unsigned int SKILL_VAR_MIN_ID
Definition: skill.h:25
SoundInfo soundHit
Definition: skilldata.h:43
std::string castingAnimation
Definition: skilldata.h:41
int srcEffectId
Definition: skilldata.h:55
int castingSrcEffectId
Definition: skilldata.h:52
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
int dstEffectId
Definition: skilldata.h:56
int removeEffectId
Definition: skilldata.h:49
bool getBoolProperty(const xmlNodePtr node, const char *const name, const bool def)
Definition: libxml.cpp:266
uint32_t data
SoundInfo soundMiss
Definition: skilldata.h:44
MissileInfo castingMissile
Definition: skilldata.h:39
void setIcon(const std::string &iconPath)
Definition: skilldata.cpp:70
std::string particle
Definition: missileinfo.h:40
Visible alwaysVisible
Definition: skillinfo.h:81
bool haveIcon
Definition: skilldata.h:57
void addData(const int level, SkillData *const data)
Definition: skillinfo.cpp:177
Configuration paths
std::string langProperty(const xmlNodePtr node, const char *const name, const std::string &def)
Definition: libxml.cpp:255
int missEffectId
Definition: skilldata.h:51
int updateEffectId
Definition: skilldata.h:48
float dieDistance
Definition: missileinfo.h:43
std::string dispName
Definition: skilldata.h:35
std::string invokeCmd
Definition: skilldata.h:40
bool autoTab
Definition: skilldata.h:58
std::string shortName
Definition: skilldata.h:34
int delay
Definition: soundinfo.h:45
int castingDstEffectId
Definition: skilldata.h:53
MissileInfo missile
Definition: skilldata.h:38
float speed
Definition: missileinfo.h:42

◆ loadSkills()

void SkillDialog::loadSkills ( )

Definition at line 330 of file skilldialog.cpp.

References addDefaultTab(), clearSkills(), Configuration::getStringValue(), loadXmlDir, loadXmlFile(), mSkills, paths, SkipError_false, SkipError_true, and update().

Referenced by WindowManager::createValidateWindows(), TmwAthena::GeneralHandler::gameStarted(), and EAthena::GeneralHandler::gameStarted().

331 {
332  clearSkills();
334  if (mSkills.empty())
336  loadXmlFile(paths.getStringValue("skillsPatchFile"), SkipError_true);
337  loadXmlDir("skillsPatchDir", loadXmlFile);
338  addDefaultTab();
339 
340  update();
341 }
std::string getStringValue(const std::string &key) const
const bool SkipError_false
Definition: skiperror.h:29
void loadXmlFile(const std::string &fileName, const SkipError skipError)
#define loadXmlDir(name, function)
Definition: beingcommon.h:38
void clearSkills()
Configuration paths
void addDefaultTab()
SkillMap mSkills
Definition: skilldialog.h:224
const bool SkipError_true
Definition: skiperror.h:29

◆ loadXmlFile()

void SkillDialog::loadXmlFile ( const std::string &  fileName,
const SkipError  skipError 
)

Definition at line 343 of file skilldialog.cpp.

References _, Widget::addActionListener(), TabbedArea::addTab(), SkillInfo::alwaysVisible, for_each_xml_child_node, XML::getProperty(), loadSkill(), loadSkillData(), Logger::log(), logger, mDefaultModel, mDefaultTab, mDeleteTabs, ServerCommandType::model, mTabs, Opaque_false, SkillSetType::Rectangle, reportAlways, XML::Document::rootNode(), Widget::setActionEventId(), ScrollArea::setHorizontalScrollPolicy(), ScrollArea::setVerticalScrollPolicy(), Widget::setVisible(), ScrollArea::SHOW_ALWAYS, ScrollArea::SHOW_NEVER, Actions::skill(), strprintf(), SkillInfo::tab, SkillModel::updateVisibilities(), UseVirtFs_true, SkillSetType::VerticalList, Visible_false, and Visible_true.

Referenced by loadSkills().

345 {
348  skipError);
349  XmlNodePtrConst root = doc.rootNode();
350 
351  int setCount = 0;
352 
353  if ((root == nullptr) || !xmlNameEqual(root, "skills"))
354  {
355  logger->log("Error loading skills: " + fileName);
356  return;
357  }
358 
359  for_each_xml_child_node(set, root)
360  {
361  if (xmlNameEqual(set, "include"))
362  {
363  const std::string name = XML::getProperty(set, "name", "");
364  if (!name.empty())
365  loadXmlFile(name, skipError);
366  continue;
367  }
368  else if (xmlNameEqual(set, "set"))
369  {
370  setCount++;
371  const std::string setName = XML::getProperty(set, "name",
372  // TRANSLATORS: skills dialog default skill tab
373  strprintf(_("Skill Set %d"), setCount));
374 
375  const std::string setTypeStr = XML::getProperty(set, "type", "");
377  if (setTypeStr.empty() ||
378  setTypeStr == "list" ||
379  setTypeStr == "vertical")
380  {
381  setType = SkillSetType::VerticalList;
382  }
383  else if (setTypeStr == "rectangle")
384  {
385  setType = SkillSetType::Rectangle;
386  }
387 
388  bool alwaysVisible = false;
389  SkillModel *const model = new SkillModel;
390  SkillTab *tab = nullptr;
391  ScrollArea *scroll = nullptr;
392 
393  switch (setType)
394  {
396  {
397  // possible leak listbox, scroll
398  SkillListBox *const listbox = new SkillListBox(this,
399  model);
400  listbox->setActionEventId("sel");
401  listbox->addActionListener(this);
402  scroll = new ScrollArea(this,
403  listbox,
404  Opaque_false);
407  tab = new SkillTab(this, setName, listbox);
408  break;
409  }
411  {
412  SkillRectangleListBox *const listbox =
413  new SkillRectangleListBox(this,
414  model);
415  listbox->setActionEventId("sel");
416  listbox->addActionListener(this);
417  scroll = new ScrollArea(this,
418  listbox,
419  Opaque_false);
422  tab = new SkillTab(this, setName, listbox);
423  break;
424  }
425  default:
426  reportAlways("Unsupported skillset type: %s",
427  setTypeStr.c_str());
428  return;
429  }
430  if (mDefaultModel == nullptr)
431  {
433  mDefaultTab = tab;
434  }
435 
436  mDeleteTabs.push_back(tab);
437  if (alwaysVisible == true)
438  tab->setVisible(Visible_true);
439  else
441  mTabs->addTab(tab, scroll);
442 
443  for_each_xml_child_node(node, set)
444  {
445  if (xmlNameEqual(node, "skill"))
446  {
447  SkillInfo *const skill = loadSkill(node, model);
448  if (skill == nullptr)
449  continue;
450  if (skill->alwaysVisible == Visible_true)
451  alwaysVisible = true;
452  skill->tab = tab;
453  for_each_xml_child_node(levelNode, node)
454  {
455  if (!xmlNameEqual(levelNode, "level"))
456  continue;
457  loadSkillData(node, skill);
458  }
459  }
460  }
461 
462  model->updateVisibilities();
463  }
464  }
465 }
#define _(s)
Definition: gettext.h:34
bool skill(InputEvent &event)
Definition: commands.cpp:96
const bool Visible_true
Definition: visible.h:29
SkillSetType ::T SkillSetTypeT
Definition: skillsettype.h:31
std::string fileName
Definition: testmain.cpp:36
TabbedArea * mTabs
Definition: skilldialog.h:226
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:251
void loadXmlFile(const std::string &fileName, const SkipError skipError)
void setVisible(Visible visible)
Definition: widget.cpp:224
SkillTab * mDefaultTab
Definition: skilldialog.h:232
SkillTab * tab
Definition: skillinfo.h:61
int getProperty(const xmlNodePtr node, const char *const name, int def)
Definition: libxml.cpp:171
void loadSkillData(const xmlNodePtr node, SkillInfo *const skill)
void setActionEventId(const std::string &actionEventId)
Definition: widget.h:595
void updateVisibilities()
Definition: skillmodel.cpp:53
void setVerticalScrollPolicy(const ScrollPolicy vPolicy)
Logger * logger
Definition: logger.cpp:95
const bool UseVirtFs_true
Definition: usevirtfs.h:29
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
SkillInfo * loadSkill(const xmlNodePtr node, SkillModel *const model)
const bool Visible_false
Definition: visible.h:29
SkillModel * mDefaultModel
Definition: skilldialog.h:231
std::list< Tab * > mDeleteTabs
Definition: skilldialog.h:227
const bool Opaque_false
Definition: opaque.h:29
Visible alwaysVisible
Definition: skillinfo.h:81
#define for_each_xml_child_node(var, parent)
Definition: libxml.h:160
void log(const char *const log_text,...)
Definition: logger.cpp:243
#define reportAlways(...)
Definition: checkutils.h:252
void addTab(Tab *const tab, Widget *const widget)
Definition: tabbedarea.cpp:229
void setHorizontalScrollPolicy(const ScrollPolicy hPolicy)

◆ playCastingDstTileEffect()

void SkillDialog::playCastingDstTileEffect ( const int  id,
const int  level,
const int  x,
const int  y,
const int  delay 
) const

Definition at line 950 of file skilldialog.cpp.

References SkillData::castingGroundEffectId, cur_time, data, effectManager, Configuration::getIntValue(), getSkillDataByLevel(), paths, and EffectManager::triggerDefault().

Referenced by hasSkills(), and EAthena::BeingRecv::processSkillCastingContinue().

955 {
956  if (effectManager == nullptr)
957  return;
958  SkillData *const data = getSkillDataByLevel(id, level);
959  if (data == nullptr)
960  return;
962  x * 32,
963  y * 32,
964  cur_time + delay / 1000, // end time in seconds
965  paths.getIntValue("skillCastingGroundEffectId"));
966 }
int castingGroundEffectId
Definition: skilldata.h:54
int getIntValue(const std::string &key) const
SkillData * getSkillDataByLevel(const int id, const int level) const
void triggerDefault(int effectId, Being *const being, const int defaultEffectId)
uint32_t data
volatile time_t cur_time
Definition: timer.cpp:57
Configuration paths
EffectManager * effectManager

◆ playRemoveEffect()

void SkillDialog::playRemoveEffect ( const int  id) const

Definition at line 938 of file skilldialog.cpp.

References data, effectManager, Configuration::getIntValue(), getSkillData(), localPlayer, paths, SkillData::removeEffectId, and EffectManager::triggerDefault().

Referenced by hasSkills(), and EAthena::SkillRecv::processSkillDelete().

939 {
940  if (effectManager == nullptr)
941  return;
942  const SkillData *const data = getSkillData(id);
943  if (data == nullptr)
944  return;
946  localPlayer,
947  paths.getIntValue("skillRemoveEffectId"));
948 }
int getIntValue(const std::string &key) const
void triggerDefault(int effectId, Being *const being, const int defaultEffectId)
int removeEffectId
Definition: skilldata.h:49
uint32_t data
LocalPlayer * localPlayer
Configuration paths
SkillData * getSkillData(const int id) const
EffectManager * effectManager

◆ playUpdateEffect()

void SkillDialog::playUpdateEffect ( const int  id) const

Definition at line 926 of file skilldialog.cpp.

References data, effectManager, Configuration::getIntValue(), getSkillData(), localPlayer, paths, EffectManager::triggerDefault(), and SkillData::updateEffectId.

Referenced by hasSkills(), EAthena::QuestRecv::processAddQuest(), EAthena::QuestRecv::processAddQuest2(), EAthena::HomunculusRecv::processHomunculusSkillUp(), TmwAthena::SkillRecv::processPlayerSkills(), EAthena::SkillRecv::processPlayerSkills(), Ea::SkillRecv::processPlayerSkillUp(), EAthena::QuestRecv::processRemoveQuest(), TmwAthena::QuestRecv::processSetQuestVar(), EAthena::SkillRecv::processSkillAdd(), EAthena::SkillRecv::processSkillAdd2(), EAthena::SkillRecv::processSkillUpdate(), and EAthena::SkillRecv::processSkillUpdate2().

927 {
928  if (effectManager == nullptr)
929  return;
930  const SkillData *const data = getSkillData(id);
931  if (data == nullptr)
932  return;
934  localPlayer,
935  paths.getIntValue("skillLevelUpEffectId"));
936 }
int getIntValue(const std::string &key) const
void triggerDefault(int effectId, Being *const being, const int defaultEffectId)
uint32_t data
LocalPlayer * localPlayer
Configuration paths
int updateEffectId
Definition: skilldata.h:48
SkillData * getSkillData(const int id) const
EffectManager * effectManager

◆ postInit()

void SkillDialog::postInit ( )
virtual

Reimplemented from Window.

Definition at line 120 of file skilldialog.cpp.

References Window::enableVisibleSound(), Widget::getParent(), Window::loadWindowState(), Window::postInit(), and Window::setLocationRelativeTo().

121 {
124  loadWindowState();
125  enableVisibleSound(true);
126 }
void loadWindowState()
Definition: window.cpp:1075
void enableVisibleSound(bool b)
Definition: window.h:473
Widget * getParent() const
Definition: widget.h:201
void setLocationRelativeTo(const Widget *const widget)
Definition: window.cpp:501
void postInit()
Definition: window.cpp:241

◆ removeSkill()

void SkillDialog::removeSkill ( const int  id)

Definition at line 629 of file skilldialog.cpp.

References SkillInfo::alwaysVisible, Actions::info(), SkillInfo::level, mSkills, PlayerInfo::setSkillLevel(), SkillInfo::update(), SkillInfo::visible, and Visible_false.

Referenced by hasSkills(), and EAthena::SkillRecv::processSkillDelete().

630 {
631  const SkillMap::const_iterator it = mSkills.find(id);
632 
633  if (it != mSkills.end())
634  {
635  SkillInfo *const info = it->second;
636  if (info != nullptr)
637  {
638  info->level = 0;
639  info->update();
641  if (info->alwaysVisible == Visible_false)
642  info->visible = Visible_false;
643  }
644  }
645 }
const bool Visible_false
Definition: visible.h:29
bool info(InputEvent &event)
Definition: commands.cpp:56
int level
Definition: skillinfo.h:63
Visible alwaysVisible
Definition: skillinfo.h:81
void setSkillLevel(const int id, const int value)
Definition: playerinfo.cpp:126
void update()
Definition: skillinfo.cpp:82
Visible visible
Definition: skillinfo.h:80
SkillMap mSkills
Definition: skilldialog.h:224

◆ selectSkillCastType()

void SkillDialog::selectSkillCastType ( const int  skillId,
const CastTypeT  type 
)

Definition at line 1404 of file skilldialog.cpp.

References SkillInfo::customCastType, getSkill(), Actions::info(), and SkillInfo::update().

Referenced by Actions::changeRelation(), and hasSkills().

1406 {
1407  SkillInfo *const info = getSkill(skillId);
1408  if (info == nullptr)
1409  return;
1410  info->customCastType = type;
1411  info->update();
1412 }
CastTypeT customCastType
Definition: skillinfo.h:78
SkillInfo * getSkill(const int id) const
bool info(InputEvent &event)
Definition: commands.cpp:56
void update()
Definition: skillinfo.cpp:82

◆ selectSkillLevel()

void SkillDialog::selectSkillLevel ( const int  skillId,
const int  level 
)

Definition at line 1391 of file skilldialog.cpp.

References SkillInfo::customSelectedLevel, getSkill(), Actions::info(), SkillInfo::level, and SkillInfo::update().

Referenced by Actions::changeRelation(), and hasSkills().

1393 {
1394  SkillInfo *const info = getSkill(skillId);
1395  if (info == nullptr)
1396  return;
1397  if (level > info->level)
1398  info->customSelectedLevel = info->level;
1399  else
1400  info->customSelectedLevel = level;
1401  info->update();
1402 }
SkillInfo * getSkill(const int id) const
bool info(InputEvent &event)
Definition: commands.cpp:56
int level
Definition: skillinfo.h:63
int customSelectedLevel
Definition: skillinfo.h:64
void update()
Definition: skillinfo.cpp:82

◆ setSkillDuration()

void SkillDialog::setSkillDuration ( const SkillOwner::Type  owner,
const int  id,
const int  duration 
)

Definition at line 790 of file skilldialog.cpp.

References addSkill(), addSkillDuration(), SkillInfo::duration, SkillInfo::durationTime, Actions::info(), Modifiable_false, mSkills, tick_time, and SkillType::Unknown.

Referenced by EAthena::SkillRecv::processSkillCoolDown(), and EAthena::SkillRecv::processSkillCoolDownList().

793 {
794  SkillMap::const_iterator it = mSkills.find(id);
795  SkillInfo *info = nullptr;
796  if (it == mSkills.end())
797  {
798  addSkill(owner, id, "", 0, 0, Modifiable_false, SkillType::Unknown, 0);
799  it = mSkills.find(id);
800  }
801  if (it != mSkills.end())
802  {
803  info = (*it).second;
804  }
805  if (info != nullptr)
806  {
807  info->duration = duration;
808  info->durationTime = tick_time;
809  addSkillDuration(info);
810  }
811 }
volatile int tick_time
Definition: timer.cpp:52
int duration
Definition: skillinfo.h:71
bool info(InputEvent &event)
Definition: commands.cpp:56
const bool Modifiable_false
Definition: modifiable.h:29
void addSkillDuration(SkillInfo *const skill)
void addSkill(const SkillOwner::Type owner, const int id, const std::string &name, const int level, const int range, const Modifiable modifiable, const SkillType::SkillType type, const int sp)
SkillMap mSkills
Definition: skilldialog.h:224
int durationTime
Definition: skillinfo.h:72

◆ setSkillOffsetX()

void SkillDialog::setSkillOffsetX ( const int  skillId,
const int  offset 
)

Definition at line 1414 of file skilldialog.cpp.

References SkillInfo::customOffsetX, getSkill(), Actions::info(), and SkillInfo::update().

Referenced by Actions::changeRelation(), and hasSkills().

1416 {
1417  SkillInfo *const info = getSkill(skillId);
1418  if (info == nullptr)
1419  return;
1420  info->customOffsetX = offset;
1421  info->update();
1422 }
SkillInfo * getSkill(const int id) const
bool info(InputEvent &event)
Definition: commands.cpp:56
int customOffsetX
Definition: skillinfo.h:65
void update()
Definition: skillinfo.cpp:82

◆ setSkillOffsetY()

void SkillDialog::setSkillOffsetY ( const int  skillId,
const int  offset 
)

Definition at line 1424 of file skilldialog.cpp.

References SkillInfo::customOffsetY, getSkill(), Actions::info(), and SkillInfo::update().

Referenced by Actions::changeRelation(), and hasSkills().

1426 {
1427  SkillInfo *const info = getSkill(skillId);
1428  if (info == nullptr)
1429  return;
1430  info->customOffsetY = offset;
1431  info->update();
1432 }
int customOffsetY
Definition: skillinfo.h:66
SkillInfo * getSkill(const int id) const
bool info(InputEvent &event)
Definition: commands.cpp:56
void update()
Definition: skillinfo.cpp:82

◆ slowLogic()

void SkillDialog::slowLogic ( )

Definition at line 1364 of file skilldialog.cpp.

References SkillInfo::cooldown, SkillInfo::duration, SkillInfo::durationTime, FOR_EACH_SAFE, get_elapsed_time(), mDurations, Actions::skill(), and ServerCommandType::time.

Referenced by hasSkills(), and Game::slowLogic().

1365 {
1366  FOR_EACH_SAFE (STD_VECTOR<SkillInfo*>::iterator, it, mDurations)
1367  {
1368  SkillInfo *const skill = *it;
1369  if (skill != nullptr)
1370  {
1371  const int time = get_elapsed_time(skill->durationTime);
1372  if (time >= skill->duration)
1373  {
1374  it = mDurations.erase(it);
1375  skill->cooldown = 0;
1376  skill->duration = 0;
1377  skill->durationTime = 0;
1378  if (it == mDurations.end())
1379  return;
1380  if (it != mDurations.begin())
1381  -- it;
1382  }
1383  else if (time != 0)
1384  {
1385  skill->cooldown = skill->duration * 100 / time;
1386  }
1387  }
1388  }
1389 }
bool skill(InputEvent &event)
Definition: commands.cpp:96
int cooldown
Definition: skillinfo.h:73
int get_elapsed_time(const int startTime)
Definition: timer.cpp:93
int duration
Definition: skillinfo.h:71
#define FOR_EACH_SAFE(type, iter, array)
Definition: foreach.h:33
std::vector< SkillInfo * > mDurations
Definition: skilldialog.h:225
int durationTime
Definition: skillinfo.h:72

◆ update() [1/2]

std::string SkillDialog::update ( const int  id)

Update the given skill's display

Definition at line 222 of file skilldialog.cpp.

References SkillInfo::data, Actions::info(), mSkills, SkillData::name, and SkillInfo::update().

Referenced by EAthena::SkillRecv::processPlayerSkills(), TmwAthena::SkillRecv::processPlayerSkills(), EAthena::SkillRecv::processSkillAdd(), EAthena::SkillRecv::processSkillAdd2(), EAthena::SkillRecv::processSkillDelete(), EAthena::SkillRecv::processSkillUpdate(), EAthena::SkillRecv::processSkillUpdate2(), EAthena::PlayerHandler::setStat(), and TmwAthena::PlayerHandler::setStat().

223 {
224  const SkillMap::const_iterator i = mSkills.find(id);
225 
226  if (i != mSkills.end())
227  {
228  SkillInfo *const info = i->second;
229  if (info != nullptr)
230  {
231  info->update();
232  return info->data->name;
233  }
234  }
235 
236  return std::string();
237 }
std::string name
Definition: skilldata.h:33
SkillData * data
Definition: skillinfo.h:62
bool info(InputEvent &event)
Definition: commands.cpp:56
void update()
Definition: skillinfo.cpp:82
SkillMap mSkills
Definition: skilldialog.h:224

◆ update() [2/2]

void SkillDialog::update ( )

Update other parts of the display

Definition at line 239 of file skilldialog.cpp.

References _, Label::adjustSize(), SkillType::Attack, SkillData::autoTab, ItemShortcut::clear(), SkillInfo::customSelectedLevel, SkillInfo::data, FOR_EACH, fromInt, PlayerInfo::getAttribute(), SkillType::Ground, SkillInfo::id, Actions::info(), itemShortcut, SkillInfo::modifiable, Modifiable_true, mPointsLabel, mSkills, Attributes::PLAYER_SKILL_POINTS, SkillPopup::reset(), SkillType::Self, Label::setCaption(), ItemShortcut::setItemData(), ItemShortcut::setItemFast(), SHORTCUT_AUTO_TAB, SHORTCUT_ITEMS, SKILL_MIN_ID, skillPopup, strprintf(), SkillType::Support, SkillInfo::toDataStr(), SkillInfo::type, SkillInfo::update(), SkillInfo::visible, and Visible_false.

Referenced by loadSkills().

240 {
241  // TRANSLATORS: skills dialog label
242  mPointsLabel->setCaption(strprintf(_("Skill points available: %d"),
245 
246  ItemShortcut *const shortcuts = itemShortcut[SHORTCUT_AUTO_TAB];
247  shortcuts->clear();
248  size_t idx = 0;
249 
250  FOR_EACH (SkillMap::const_iterator, it, mSkills)
251  {
252  SkillInfo *const info = (*it).second;
253  if (info == nullptr)
254  continue;
255  if (info->modifiable == Modifiable_true)
256  info->update();
257  if (info->visible == Visible_false ||
258  idx >= SHORTCUT_ITEMS ||
259  !info->data->autoTab)
260  {
261  continue;
262  }
263  const SkillType::SkillType type = info->type;
264  if (type == SkillType::Attack ||
265  type == SkillType::Ground ||
266  type == SkillType::Self ||
267  type == SkillType::Support)
268  {
269  shortcuts->setItemFast(idx,
270  info->id + SKILL_MIN_ID,
272 
273  shortcuts->setItemData(idx,
274  info->toDataStr());
275  idx ++;
276  }
277  }
278 
279  skillPopup->reset();
280 }
unsigned int id
Definition: skillinfo.h:68
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
#define _(s)
Definition: gettext.h:34
const bool Modifiable_true
Definition: modifiable.h:29
Label * mPointsLabel
Definition: skilldialog.h:228
#define fromInt(val, name)
Definition: intdefines.h:45
SkillPopup * skillPopup
Definition: skillpopup.cpp:41
void reset()
Definition: skillpopup.cpp:243
const size_t SHORTCUT_AUTO_TAB
Definition: itemshortcut.h:28
uint16_t ItemColor
Definition: itemcolor.h:29
const int SKILL_MIN_ID
Definition: skill.h:24
void setItemData(const size_t index, const std::string &data)
Definition: itemshortcut.h:75
SkillData * data
Definition: skillinfo.h:62
std::string toDataStr() const
Definition: skillinfo.cpp:198
Modifiable modifiable
Definition: skillinfo.h:79
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
void setCaption(const std::string &caption)
Definition: label.cpp:256
const bool Visible_false
Definition: visible.h:29
bool info(InputEvent &event)
Definition: commands.cpp:56
int customSelectedLevel
Definition: skillinfo.h:64
ItemShortcut * itemShortcut[SHORTCUT_TABS]
void update()
Definition: skillinfo.cpp:82
void setItemFast(const size_t index, const int item, const ItemColor color)
Visible visible
Definition: skillinfo.h:80
SkillMap mSkills
Definition: skilldialog.h:224
SkillType::SkillType type
Definition: skillinfo.h:76
bool autoTab
Definition: skilldata.h:58
int32_t getAttribute(const AttributesT id)
Definition: playerinfo.cpp:100
void adjustSize()
Definition: label.cpp:192
const unsigned int SHORTCUT_ITEMS
Definition: itemshortcut.h:26

◆ updateModels()

void SkillDialog::updateModels ( )

Definition at line 282 of file skilldialog.cpp.

References FOR_EACH, Actions::info(), SkillInfo::model, ServerCommandType::model, mSkills, and SkillModel::updateVisibilities().

Referenced by EAthena::MercenaryRecv::handleMercenaryMessage(), EAthena::GuildRecv::processGuildSkillInfo(), EAthena::HomunculusRecv::processHomunculusSkills(), and EAthena::MercenaryRecv::processMercenarySkills().

283 {
284  std::set<SkillModel*> models;
285 
286  FOR_EACH (SkillMap::const_iterator, it, mSkills)
287  {
288  SkillInfo *const info = (*it).second;
289  if (info != nullptr)
290  {
291  SkillModel *const model = info->model;
292  if (model != nullptr)
293  models.insert(model);
294  }
295  }
296  FOR_EACH (std::set<SkillModel*>::iterator, it, models)
297  {
298  SkillModel *const model = *it;
299  if (model != nullptr)
300  model->updateVisibilities();
301  }
302 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
void updateVisibilities()
Definition: skillmodel.cpp:53
bool info(InputEvent &event)
Definition: commands.cpp:56
SkillMap mSkills
Definition: skilldialog.h:224
SkillModel * model
Definition: skillinfo.h:60

◆ updateQuest()

void SkillDialog::updateQuest ( const int  var,
const int  val1,
const int  val2,
const int  val3,
const int  time1 
)

Definition at line 880 of file skilldialog.cpp.

References Actions::info(), SkillInfo::level, mSkills, PlayerInfo::setSkillLevel(), SKILL_VAR_MIN_ID, and SkillInfo::update().

Referenced by hasSkills(), EAthena::QuestRecv::processAddQuest(), EAthena::QuestRecv::processAddQuest2(), EAthena::QuestRecv::processAddQuests(), EAthena::QuestRecv::processAddQuests2(), TmwAthena::QuestRecv::processPlayerQuests(), EAthena::QuestRecv::processRemoveQuest(), and TmwAthena::QuestRecv::processSetQuestVar().

885 {
886  const int id = var + SKILL_VAR_MIN_ID;
887  const SkillMap::const_iterator it = mSkills.find(id);
888 
889  if (it != mSkills.end())
890  {
891  SkillInfo *const info = it->second;
892  if (info != nullptr)
893  {
894  PlayerInfo::setSkillLevel(id, val1);
895  info->level = val1;
896  info->update();
897  }
898  }
899 }
const unsigned int SKILL_VAR_MIN_ID
Definition: skill.h:25
bool info(InputEvent &event)
Definition: commands.cpp:56
int level
Definition: skillinfo.h:63
void setSkillLevel(const int id, const int value)
Definition: playerinfo.cpp:126
void update()
Definition: skillinfo.cpp:82
SkillMap mSkills
Definition: skilldialog.h:224

◆ updateSkill()

bool SkillDialog::updateSkill ( const int  id,
const int  range,
const Modifiable  modifiable,
const SkillType::SkillType  type,
const int  sp 
)

Definition at line 647 of file skilldialog.cpp.

References TabbedArea::adjustTabPositions(), Actions::info(), SkillInfo::modifiable, mSkills, mTabs, SkillInfo::range, TabbedArea::setSelectedTabDefault(), Widget::setVisible(), SkillInfo::sp, SkillInfo::tab, SkillInfo::type, SkillInfo::update(), and Visible_true.

Referenced by EAthena::GuildRecv::processGuildSkillInfo(), EAthena::HomunculusRecv::processHomunculusSkills(), EAthena::HomunculusRecv::processHomunculusSkillUp(), EAthena::MercenaryRecv::processMercenarySkills(), EAthena::SkillRecv::processPlayerSkills(), TmwAthena::SkillRecv::processPlayerSkills(), Ea::SkillRecv::processPlayerSkillUp(), EAthena::SkillRecv::processSkillAdd(), EAthena::SkillRecv::processSkillAdd2(), EAthena::SkillRecv::processSkillUpdate(), and EAthena::SkillRecv::processSkillUpdate2().

652 {
653  const SkillMap::const_iterator it = mSkills.find(id);
654 
655  if (it != mSkills.end())
656  {
657  SkillInfo *const info = it->second;
658  if (info != nullptr)
659  {
660  info->modifiable = modifiable;
661  info->range = range;
662  info->type = type;
663  info->sp = sp;
664  info->update();
665  if (info->tab != nullptr)
666  {
667  info->tab->setVisible(Visible_true);
670  }
671  }
672  return true;
673  }
674  return false;
675 }
void adjustTabPositions()
Definition: tabbedarea.cpp:596
const bool Visible_true
Definition: visible.h:29
TabbedArea * mTabs
Definition: skilldialog.h:226
void setVisible(Visible visible)
Definition: widget.cpp:224
SkillTab * tab
Definition: skillinfo.h:61
Modifiable modifiable
Definition: skillinfo.h:79
bool info(InputEvent &event)
Definition: commands.cpp:56
void setSelectedTabDefault()
Definition: tabbedarea.cpp:423
int range
Definition: skillinfo.h:69
int sp
Definition: skillinfo.h:70
void update()
Definition: skillinfo.cpp:82
SkillMap mSkills
Definition: skilldialog.h:224
SkillType::SkillType type
Definition: skillinfo.h:76

◆ updateTabSelection()

void SkillDialog::updateTabSelection ( )

Definition at line 859 of file skilldialog.cpp.

References _, SkillTab::getSelectedInfo(), TabbedArea::getSelectedTab(), Actions::info(), mIncreaseButton, mTabs, mUseButton, Button::setCaption(), Widget::setEnabled(), and SKILL_VAR_MIN_ID.

Referenced by hasSkills(), and SkillTab::setCurrent().

860 {
861  const SkillTab *const tab = static_cast<SkillTab*>(
862  mTabs->getSelectedTab());
863  if (tab != nullptr)
864  {
865  if (const SkillInfo *const info = tab->getSelectedInfo())
866  {
867  mUseButton->setEnabled(info->range > 0);
869  mUseButton->setCaption(info->useButton);
870  }
871  else
872  {
873  mUseButton->setEnabled(false);
874  // TRANSLATORS: inventory button
875  mUseButton->setCaption(_("Use"));
876  }
877  }
878 }
#define _(s)
Definition: gettext.h:34
TabbedArea * mTabs
Definition: skilldialog.h:226
Button * mIncreaseButton
Definition: skilldialog.h:230
const unsigned int SKILL_VAR_MIN_ID
Definition: skill.h:25
SkillInfo * getSelectedInfo() const
Definition: skilltab.h:66
void setCaption(const std::string &caption)
Definition: button.h:214
bool info(InputEvent &event)
Definition: commands.cpp:56
Button * mUseButton
Definition: skilldialog.h:229
void setEnabled(const bool enabled)
Definition: widget.h:351
Tab * getSelectedTab() const
Definition: tabbedarea.h:174

◆ useItem()

void SkillDialog::useItem ( const int  itemId,
const AutoTarget  autoTarget,
const int  level,
const std::string &  data 
) const

Definition at line 821 of file skilldialog.cpp.

References CastType::Default, Actions::info(), mSkills, SKILL_MIN_ID, splitToIntVector(), and useSkill().

Referenced by Actions::doSit(), hasSkills(), and ItemShortcut::useItem().

825 {
826  const std::map<int, SkillInfo*>::const_iterator
827  it = mSkills.find(itemId - SKILL_MIN_ID);
828  if (it == mSkills.end())
829  return;
830 
831  const SkillInfo *const info = (*it).second;
832  CastTypeT castType = CastType::Default;
833  int offsetX = 0;
834  int offsetY = 0;
835 
836  if (!data.empty())
837  {
838  STD_VECTOR<int> vect;
839  splitToIntVector(vect, data, ' ');
840  const size_t sz = vect.size();
841  if (sz > 0)
842  castType = static_cast<CastTypeT>(vect[0]);
843  if (sz > 2)
844  {
845  offsetX = vect[1];
846  offsetY = vect[2];
847  }
848  }
849  useSkill(info,
850  autoTarget,
851  level,
852  false,
853  std::string(),
854  castType,
855  offsetX,
856  offsetY);
857 }
const int SKILL_MIN_ID
Definition: skill.h:24
bool info(InputEvent &event)
Definition: commands.cpp:56
uint32_t data
static void useSkill(const int skillId, const AutoTarget autoTarget, int level, const bool withText, const std::string &text, CastTypeT castType, const int offsetX, const int offsetY)
void splitToIntVector(std::vector< int > &tokens, const std::string &text, const char separator)
SkillMap mSkills
Definition: skilldialog.h:224
CastType ::T CastTypeT
Definition: casttype.h:33

◆ useSkill() [1/2]

void SkillDialog::useSkill ( const int  skillId,
const AutoTarget  autoTarget,
int  level,
const bool  withText,
const std::string &  text,
CastTypeT  castType,
const int  offsetX,
const int  offsetY 
)
static

Definition at line 968 of file skilldialog.cpp.

References SkillInfo::customCastType, CastType::Default, getSkill(), and Actions::info().

Referenced by action(), Actions::changeRelation(), hasSkills(), and useItem().

976 {
977  SkillInfo *const info = skillDialog->getSkill(skillId);
978  if (info == nullptr)
979  return;
980  if (castType == CastType::Default)
981  castType = info->customCastType;
982  useSkill(info,
983  autoTarget,
984  level,
985  withText,
986  text,
987  castType,
988  offsetX,
989  offsetY);
990 }
CastTypeT customCastType
Definition: skillinfo.h:78
SkillInfo * getSkill(const int id) const
bool info(InputEvent &event)
Definition: commands.cpp:56
SkillDialog * skillDialog
Definition: skilldialog.cpp:65
static void useSkill(const int skillId, const AutoTarget autoTarget, int level, const bool withText, const std::string &text, CastTypeT castType, const int offsetX, const int offsetY)

◆ useSkill() [2/2]

void SkillDialog::useSkill ( const SkillInfo *const  info,
const AutoTarget  autoTarget,
int  level,
const bool  withText,
const std::string &  text,
const CastTypeT  castType,
const int  offsetX,
const int  offsetY 
)
static

Definition at line 992 of file skilldialog.cpp.

References data, CastType::Default, SkillInfo::getData1(), Viewport::getMouseTile(), LocalPlayer::getTarget(), SkillData::invokeCmd, SpellManager::invokeCommand(), SkillInfo::level, localPlayer, CastType::Position, CastType::Self, CastType::Target, useSkillDefault(), useSkillPosition(), useSkillTarget(), viewport, x, and y.

1000 {
1001  if ((info == nullptr) || (localPlayer == nullptr))
1002  return;
1003  if (level == 0)
1004  level = info->level;
1005 
1006  const SkillData *data = info->getData1(level);
1007  if (data != nullptr)
1008  {
1009  const std::string cmd = data->invokeCmd;
1010  if (!cmd.empty())
1012  }
1013  switch (castType)
1014  {
1015  default:
1016  case CastType::Default:
1017  useSkillDefault(info,
1018  autoTarget,
1019  level,
1020  withText,
1021  text,
1022  offsetX,
1023  offsetY);
1024  break;
1025  case CastType::Target:
1026  {
1027  const Being *const being = localPlayer->getTarget();
1028  useSkillTarget(info,
1029  autoTarget,
1030  level,
1031  withText,
1032  text,
1033  being,
1034  offsetX,
1035  offsetY);
1036  break;
1037  }
1038  case CastType::Position:
1039  {
1040  int x = 0;
1041  int y = 0;
1042  viewport->getMouseTile(x, y);
1043  useSkillPosition(info,
1044  level,
1045  withText,
1046  text,
1047  x,
1048  y,
1049  offsetX,
1050  offsetY);
1051  break;
1052  }
1053  case CastType::Self:
1054  // +++ probably need call useSkillSelf
1055  useSkillTarget(info,
1056  autoTarget,
1057  level,
1058  withText,
1059  text,
1060  localPlayer,
1061  offsetX,
1062  offsetY);
1063  break;
1064  }
1065 }
static void useSkillTarget(const SkillInfo *const info, const AutoTarget autoTarget, int level, const bool withText, const std::string &text, const Being *being, int offsetX, int offsetY)
uint32_t data
LocalPlayer * localPlayer
int level
Definition: skillinfo.h:63
void getMouseTile(int &destX, int &destY) const
Definition: viewport.cpp:611
static void useSkillPosition(const SkillInfo *const info, int level, const bool withText, const std::string &text, const int x, const int y, int offsetX, int offsetY)
SkillData * getData1(const int level) const
Definition: skillinfo.cpp:190
std::string invokeCmd
Definition: skilldata.h:40
static void invokeCommand(const std::string &command, const Being *const target)
Definition: being.h:93
static void useSkillDefault(const SkillInfo *const info, const AutoTarget autoTarget, int level, const bool withText, const std::string &text, int offsetX, int offsetY)
Viewport * viewport
Definition: viewport.cpp:35
Being * getTarget() const

◆ useSkillDefault()

void SkillDialog::useSkillDefault ( const SkillInfo *const  info,
const AutoTarget  autoTarget,
int  level,
const bool  withText,
const std::string &  text,
int  offsetX,
int  offsetY 
)
staticprivate

Definition at line 1251 of file skilldialog.cpp.

References _, Widget::addActionListener(), AllowSort_true, SkillType::Attack, AutoTarget_true, CREATEWIDGETR, data, Being::fixDirectionOffsets(), SkillInfo::getData1(), ActorSprite::getId(), Viewport::getMouseTile(), LocalPlayer::getTarget(), SkillType::Ground, SkillInfo::id, localPlayer, Modal_true, ActorType::Monster, SkillData::name, reportAlways, SkillType::Self, Widget::setActionEventId(), TextSkillListener::setDialog(), Window::setModal(), LocalPlayer::setNewTarget(), TextSkillListener::setSkill(), skillHandler, strprintf(), SkillType::Support, SkillType::TargetTrap, anonymous_namespace{skilldialog.cpp}::textSkillListener, SkillInfo::type, SkillType::Unknown, SkillType::Unused, Net::SkillHandler::useBeing(), Net::SkillHandler::usePos(), SkillInfo::useTextParameter, viewport, x, and y.

Referenced by hasSkills(), and useSkill().

1258 {
1259  SkillType::SkillType type = info->type;
1260  if ((type & SkillType::Attack) != 0)
1261  {
1262  const Being *being = localPlayer->getTarget();
1263  if ((being == nullptr) && autoTarget == AutoTarget_true)
1264  {
1266  AllowSort_true);
1267  }
1268  if (being != nullptr)
1269  {
1270  skillHandler->useBeing(info->id,
1271  level,
1272  being->getId());
1273  }
1274  }
1275  else if ((type & SkillType::Support) != 0)
1276  {
1277  const Being *being = localPlayer->getTarget();
1278  if (being == nullptr)
1279  being = localPlayer;
1280  if (being != nullptr)
1281  {
1282  skillHandler->useBeing(info->id,
1283  level,
1284  being->getId());
1285  }
1286  }
1287  else if ((type & SkillType::Self) != 0)
1288  {
1289  skillHandler->useBeing(info->id,
1290  level,
1291  localPlayer->getId());
1292  }
1293  else if ((type & SkillType::Ground) != 0)
1294  {
1295  int x = 0;
1296  int y = 0;
1297  viewport->getMouseTile(x, y);
1298  localPlayer->fixDirectionOffsets(offsetX, offsetY);
1299  x += offsetX;
1300  y += offsetY;
1301  if (info->useTextParameter)
1302  {
1303  if (withText)
1304  {
1305  skillHandler->usePos(info->id,
1306  level,
1307  x, y,
1308  text);
1309  }
1310  else
1311  {
1312  const SkillData *data = info->getData1(level);
1314  x,
1315  y,
1316  level);
1317  TextDialog *const dialog = CREATEWIDGETR(TextDialog,
1318  // TRANSLATORS: text skill dialog header
1319  strprintf(_("Add text to skill %s"),
1320  data->name.c_str()),
1321  // TRANSLATORS: text skill dialog field
1322  _("Text: "));
1323  dialog->setModal(Modal_true);
1324  textSkillListener.setDialog(dialog);
1325  dialog->setActionEventId("ok");
1327  }
1328  }
1329  else
1330  {
1331  skillHandler->usePos(info->id,
1332  level,
1333  x, y);
1334  }
1335  }
1336  else if ((type & SkillType::TargetTrap) != 0)
1337  {
1338  // for now unused
1339  }
1340  else if (type == SkillType::Unknown ||
1341  type == SkillType::Unused)
1342  {
1343  // unknown / unused
1344  }
1345  else
1346  {
1347  reportAlways("Unsupported skill type: %d", type);
1348  }
1349 }
const bool AutoTarget_true
Definition: autotarget.h:29
unsigned int id
Definition: skillinfo.h:68
#define _(s)
Definition: gettext.h:34
Being * setNewTarget(const ActorTypeT type, const AllowSort allowSort)
bool useTextParameter
Definition: skillinfo.h:82
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:251
BeingId getId() const
Definition: actorsprite.h:63
std::string name
Definition: skilldata.h:33
void setActionEventId(const std::string &actionEventId)
Definition: widget.h:595
const bool AllowSort_true
Definition: allowsort.h:29
void setSkill(const int skillId, const int x, const int y, const int level)
void setDialog(TextDialog *dialog)
Net::SkillHandler * skillHandler
Definition: net.cpp:90
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
uint32_t data
LocalPlayer * localPlayer
void getMouseTile(int &destX, int &destY) const
Definition: viewport.cpp:611
void fixDirectionOffsets(int &offsetX, int &offsetY) const
Definition: being.cpp:5447
virtual void useBeing(const int id, const int level, const BeingId beingId) const =0
SkillData * getData1(const int level) const
Definition: skillinfo.cpp:190
virtual void usePos(const int id, const int level, const int x, const int y) const =0
#define CREATEWIDGETR(type,...)
Definition: createwidget.h:35
SkillType::SkillType type
Definition: skillinfo.h:76
Definition: being.h:93
#define reportAlways(...)
Definition: checkutils.h:252
void setModal(const Modal modal)
Definition: window.cpp:1057
Viewport * viewport
Definition: viewport.cpp:35
Being * getTarget() const

◆ useSkillPosition()

void SkillDialog::useSkillPosition ( const SkillInfo *const  info,
int  level,
const bool  withText,
const std::string &  text,
const int  x,
const int  y,
int  offsetX,
int  offsetY 
)
staticprivate

Definition at line 1168 of file skilldialog.cpp.

References _, Widget::addActionListener(), SkillType::Attack, CREATEWIDGETR, data, Being::fixDirectionOffsets(), SkillInfo::getData1(), ActorSprite::getId(), SkillType::Ground, SkillInfo::id, localPlayer, Modal_true, SkillData::name, reportAlways, SkillType::Self, Widget::setActionEventId(), TextSkillListener::setDialog(), Window::setModal(), TextSkillListener::setSkill(), skillHandler, strprintf(), SkillType::Support, SkillType::TargetTrap, anonymous_namespace{skilldialog.cpp}::textSkillListener, SkillInfo::type, SkillType::Unknown, SkillType::Unused, Net::SkillHandler::useBeing(), Net::SkillHandler::usePos(), and SkillInfo::useTextParameter.

Referenced by hasSkills(), and useSkill().

1176 {
1177  SkillType::SkillType type = info->type;
1178  if ((type & SkillType::Ground) != 0)
1179  {
1180  localPlayer->fixDirectionOffsets(offsetX, offsetY);
1181  if (info->useTextParameter)
1182  {
1183  if (withText)
1184  {
1185  skillHandler->usePos(info->id,
1186  level,
1187  x + offsetX,
1188  y + offsetY,
1189  text);
1190  }
1191  else
1192  {
1193  const SkillData *data = info->getData1(level);
1195  x + offsetX,
1196  y + offsetY,
1197  level);
1198  TextDialog *const dialog = CREATEWIDGETR(TextDialog,
1199  // TRANSLATORS: text skill dialog header
1200  strprintf(_("Add text to skill %s"),
1201  data->name.c_str()),
1202  // TRANSLATORS: text skill dialog field
1203  _("Text: "));
1204  dialog->setModal(Modal_true);
1205  textSkillListener.setDialog(dialog);
1206  dialog->setActionEventId("ok");
1208  }
1209  }
1210  else
1211  {
1212  skillHandler->usePos(info->id,
1213  level,
1214  x + offsetX,
1215  y + offsetY);
1216  }
1217  }
1218  else if ((type & SkillType::Support) != 0)
1219  {
1220  // wrong type
1221  skillHandler->useBeing(info->id,
1222  level,
1223  localPlayer->getId());
1224  }
1225  else if ((type & SkillType::Self) != 0)
1226  {
1227  skillHandler->useBeing(info->id,
1228  level,
1229  localPlayer->getId());
1230  }
1231  else if ((type & SkillType::Attack) != 0)
1232  {
1233  // do nothing
1234  // +++ probably need select some target on x,y position?
1235  }
1236  else if ((type & SkillType::TargetTrap) != 0)
1237  {
1238  // for now unused
1239  }
1240  else if (type == SkillType::Unknown ||
1241  type == SkillType::Unused)
1242  {
1243  // unknown / unused
1244  }
1245  else
1246  {
1247  reportAlways("Unsupported skill type: %d", type);
1248  }
1249 }
unsigned int id
Definition: skillinfo.h:68
#define _(s)
Definition: gettext.h:34
bool useTextParameter
Definition: skillinfo.h:82
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:251
BeingId getId() const
Definition: actorsprite.h:63
std::string name
Definition: skilldata.h:33
void setActionEventId(const std::string &actionEventId)
Definition: widget.h:595
void setSkill(const int skillId, const int x, const int y, const int level)
void setDialog(TextDialog *dialog)
Net::SkillHandler * skillHandler
Definition: net.cpp:90
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
uint32_t data
LocalPlayer * localPlayer
void fixDirectionOffsets(int &offsetX, int &offsetY) const
Definition: being.cpp:5447
virtual void useBeing(const int id, const int level, const BeingId beingId) const =0
SkillData * getData1(const int level) const
Definition: skillinfo.cpp:190
virtual void usePos(const int id, const int level, const int x, const int y) const =0
#define CREATEWIDGETR(type,...)
Definition: createwidget.h:35
SkillType::SkillType type
Definition: skillinfo.h:76
#define reportAlways(...)
Definition: checkutils.h:252
void setModal(const Modal modal)
Definition: window.cpp:1057

◆ useSkillTarget()

void SkillDialog::useSkillTarget ( const SkillInfo *const  info,
const AutoTarget  autoTarget,
int  level,
const bool  withText,
const std::string &  text,
const Being being,
int  offsetX,
int  offsetY 
)
staticprivate

Definition at line 1067 of file skilldialog.cpp.

References _, Widget::addActionListener(), AllowSort_true, SkillType::Attack, AutoTarget_true, CREATEWIDGETR, data, Being::fixDirectionOffsets(), SkillInfo::getData1(), ActorSprite::getId(), Being::getTileX(), Being::getTileY(), SkillType::Ground, SkillInfo::id, localPlayer, Modal_true, ActorType::Monster, SkillData::name, reportAlways, SkillType::Self, Widget::setActionEventId(), TextSkillListener::setDialog(), Window::setModal(), LocalPlayer::setNewTarget(), TextSkillListener::setSkill(), skillHandler, strprintf(), SkillType::Support, SkillType::TargetTrap, anonymous_namespace{skilldialog.cpp}::textSkillListener, SkillInfo::type, SkillType::Unknown, SkillType::Unused, Net::SkillHandler::useBeing(), Net::SkillHandler::usePos(), SkillInfo::useTextParameter, x, and y.

Referenced by hasSkills(), and useSkill().

1075 {
1076  SkillType::SkillType type = info->type;
1077  if ((type & SkillType::Attack) != 0)
1078  {
1079  if ((being == nullptr) && autoTarget == AutoTarget_true)
1080  {
1081  if (localPlayer != nullptr)
1082  {
1084  AllowSort_true);
1085  }
1086  }
1087  if (being != nullptr)
1088  {
1089  skillHandler->useBeing(info->id,
1090  level,
1091  being->getId());
1092  }
1093  }
1094  else if ((type & SkillType::Support) != 0)
1095  {
1096  if (being == nullptr)
1097  being = localPlayer;
1098  if (being != nullptr)
1099  {
1100  skillHandler->useBeing(info->id,
1101  level,
1102  being->getId());
1103  }
1104  }
1105  else if ((type & SkillType::Self) != 0)
1106  {
1107  skillHandler->useBeing(info->id,
1108  level,
1109  localPlayer->getId());
1110  }
1111  else if ((type & SkillType::Ground) != 0)
1112  {
1113  if (being == nullptr)
1114  return;
1115  being->fixDirectionOffsets(offsetX, offsetY);
1116  const int x = being->getTileX() + offsetX;
1117  const int y = being->getTileY() + offsetY;
1118  if (info->useTextParameter)
1119  {
1120  if (withText)
1121  {
1122  skillHandler->usePos(info->id,
1123  level,
1124  x, y,
1125  text);
1126  }
1127  else
1128  {
1129  const SkillData *data = info->getData1(level);
1131  x,
1132  y,
1133  level);
1134  TextDialog *const dialog = CREATEWIDGETR(TextDialog,
1135  // TRANSLATORS: text skill dialog header
1136  strprintf(_("Add text to skill %s"),
1137  data->name.c_str()),
1138  // TRANSLATORS: text skill dialog field
1139  _("Text: "));
1140  dialog->setModal(Modal_true);
1141  textSkillListener.setDialog(dialog);
1142  dialog->setActionEventId("ok");
1144  }
1145  }
1146  else
1147  {
1148  skillHandler->usePos(info->id,
1149  level,
1150  x, y);
1151  }
1152  }
1153  else if ((type & SkillType::TargetTrap) != 0)
1154  {
1155  // for now unused
1156  }
1157  else if (type == SkillType::Unknown ||
1158  type == SkillType::Unused)
1159  {
1160  // unknown / unused
1161  }
1162  else
1163  {
1164  reportAlways("Unsupported skill type: %d", type);
1165  }
1166 }
const bool AutoTarget_true
Definition: autotarget.h:29
unsigned int id
Definition: skillinfo.h:68
#define _(s)
Definition: gettext.h:34
Being * setNewTarget(const ActorTypeT type, const AllowSort allowSort)
int getTileY() const
Definition: being.h:173
bool useTextParameter
Definition: skillinfo.h:82
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:251
BeingId getId() const
Definition: actorsprite.h:63
std::string name
Definition: skilldata.h:33
void setActionEventId(const std::string &actionEventId)
Definition: widget.h:595
const bool AllowSort_true
Definition: allowsort.h:29
void setSkill(const int skillId, const int x, const int y, const int level)
void setDialog(TextDialog *dialog)
Net::SkillHandler * skillHandler
Definition: net.cpp:90
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
uint32_t data
LocalPlayer * localPlayer
void fixDirectionOffsets(int &offsetX, int &offsetY) const
Definition: being.cpp:5447
virtual void useBeing(const int id, const int level, const BeingId beingId) const =0
SkillData * getData1(const int level) const
Definition: skillinfo.cpp:190
virtual void usePos(const int id, const int level, const int x, const int y) const =0
int getTileX() const
Definition: being.h:167
#define CREATEWIDGETR(type,...)
Definition: createwidget.h:35
SkillType::SkillType type
Definition: skillinfo.h:76
#define reportAlways(...)
Definition: checkutils.h:252
void setModal(const Modal modal)
Definition: window.cpp:1057

◆ widgetResized()

void SkillDialog::widgetResized ( const Event event)
virtual

Called whenever the widget changes size.

Reimplemented from Window.

Definition at line 813 of file skilldialog.cpp.

References TabbedArea::adjustSize(), mTabs, and Window::widgetResized().

Referenced by hasSkills().

814 {
815  Window::widgetResized(event);
816 
817  if (mTabs != nullptr)
818  mTabs->adjustSize();
819 }
TabbedArea * mTabs
Definition: skilldialog.h:226
void widgetResized(const Event &event)
Definition: window.cpp:643
void adjustSize()
Definition: tabbedarea.cpp:559

Field Documentation

◆ mDefaultModel

SkillModel* SkillDialog::mDefaultModel
private

Definition at line 231 of file skilldialog.h.

Referenced by addDefaultTab(), addSkill(), clearSkills(), and loadXmlFile().

◆ mDefaultTab

SkillTab* SkillDialog::mDefaultTab
private

Definition at line 232 of file skilldialog.h.

Referenced by addDefaultTab(), addSkill(), clearSkills(), and loadXmlFile().

◆ mDeleteTabs

std::list<Tab*> SkillDialog::mDeleteTabs
private

Definition at line 227 of file skilldialog.h.

Referenced by addDefaultTab(), clearSkills(), and loadXmlFile().

◆ mDurations

std::vector<SkillInfo*> SkillDialog::mDurations
private

Definition at line 225 of file skilldialog.h.

Referenced by addSkillDuration(), clearSkills(), and slowLogic().

◆ mIncreaseButton

Button* SkillDialog::mIncreaseButton
private

Definition at line 230 of file skilldialog.h.

Referenced by action(), SkillDialog(), and updateTabSelection().

◆ mPointsLabel

Label* SkillDialog::mPointsLabel
private

Definition at line 228 of file skilldialog.h.

Referenced by SkillDialog(), and update().

◆ mSkills

SkillMap SkillDialog::mSkills
private

◆ mTabs

TabbedArea* SkillDialog::mTabs
private

◆ mUseButton

Button* SkillDialog::mUseButton
private

Definition at line 229 of file skilldialog.h.

Referenced by action(), SkillDialog(), and updateTabSelection().


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