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 updateModelsHidden ()
 
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, const Modal modal, Window *const parent, std::string skin)
 
 ~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, int offsetY)
 
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, const int offsetY)
 
virtual void resetToDefaultSize ()
 
void adjustPositionAfterResize (const int oldScreenWidth, const int oldScreenHeight)
 
LayoutgetLayout ()
 
void clearLayout ()
 
void reflowLayout (int w, int h)
 
LayoutCellplace (const int x, const int y, Widget *const wg, const int w, const int h)
 
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)
 
 ~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)
 
 ~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)
 
 ~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) 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) const
 
bool getOptionBool (const std::string &name, const bool def) 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 225 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", BUTTON_SKIN, this)),
94  // TRANSLATORS: skills dialog button
95  mIncreaseButton(new Button(this, _("Up"), "inc", BUTTON_SKIN, 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, 1);
116  place(3, 5, mUseButton, 1, 1);
117  place(4, 5, mIncreaseButton, 1, 1);
118 }
void setDefaultSize()
Definition: window.cpp:1193
LayoutCell & place(const int x, const int y, Widget *const wg, const int w, const int h)
Definition: window.cpp:1379
#define _(s)
Definition: gettext.h:34
int getWidth() const
Definition: widget.h:220
WindowContainer * windowContainer
Label * mPointsLabel
Definition: skilldialog.h:230
TabbedArea * mTabs
Definition: skilldialog.h:228
SkillTab * mDefaultTab
Definition: skilldialog.h:234
Button * mIncreaseButton
Definition: skilldialog.h:232
Definition: button.h:96
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
const std::string BUTTON_SKIN
Definition: button.h:88
Definition: label.h:87
Button * mUseButton
Definition: skilldialog.h:231
SkillModel * mDefaultModel
Definition: skilldialog.h:233
std::list< Tab * > mDeleteTabs
Definition: skilldialog.h:229
void setCloseButton(const bool flag)
Definition: window.cpp:744
void setEnabled(const bool enabled)
Definition: widget.h:351
void setSaveVisible(const bool save)
Definition: window.h:299
void setResizable(const bool resize)
Definition: window.cpp:622
void setStickyButtonLock(const bool sticky)
Definition: window.cpp:767
SetupWindow * setupWindow
Definition: setupwindow.cpp:63
SkillMap mSkills
Definition: skilldialog.h:226
#define CREATEWIDGETR(type,...)
Definition: createwidget.h:35
std::vector< SkillInfo * > mDurations
Definition: skilldialog.h:227
Window(const std::string &caption, const Modal modal, Window *const parent, std::string skin)
Definition: window.cpp:108
void setWindowName(const std::string &name)
Definition: window.h:354

◆ ~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 155 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.

156 {
157  const std::string &eventId = event.getId();
158  if (eventId == "inc")
159  {
160  if (playerHandler == nullptr)
161  return;
162  const SkillTab *const tab = static_cast<const SkillTab *>(
163  mTabs->getSelectedTab());
164  if (tab != nullptr)
165  {
166  if (const SkillInfo *const info = tab->getSelectedInfo())
168  }
169  }
170  else if (eventId == "sel")
171  {
172  const SkillTab *const tab = static_cast<const SkillTab *>(
173  mTabs->getSelectedTab());
174  if (tab != nullptr)
175  {
176  if (const SkillInfo *const info = tab->getSelectedInfo())
177  {
178  mUseButton->setEnabled(info->isUsable());
179  mUseButton->setCaption(info->useButton);
181  const int num = itemShortcutWindow->getTabIndex();
182  if (num >= 0 && num < CAST_S32(SHORTCUT_TABS)
183  && (itemShortcut[num] != nullptr))
184  {
186  info->id + SKILL_MIN_ID);
187  }
188  }
189  else
190  {
191  mUseButton->setEnabled(false);
192  mIncreaseButton->setEnabled(false);
193  // TRANSLATORS: skills dialog button
194  mUseButton->setCaption(_("Use"));
195  }
196  }
197  }
198  else if (eventId == "use")
199  {
200  const SkillTab *const tab = static_cast<const SkillTab *>(
201  mTabs->getSelectedTab());
202  if (tab != nullptr)
203  {
204  const SkillInfo *const info = tab->getSelectedInfo();
205  if (info == nullptr)
206  return;
207  useSkill(info,
208  fromBool(config.getBoolValue("skillAutotarget"), AutoTarget),
209  info->customSelectedLevel,
210  info->useTextParameter,
211  std::string(),
212  info->customCastType,
213  info->customOffsetX,
214  info->customOffsetY);
215  }
216  }
217  else if (eventId == "close")
218  {
220  }
221 }
Net::PlayerHandler * playerHandler
Definition: net.cpp:92
#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:228
CastTypeT customCastType
Definition: skillinfo.h:78
Button * mIncreaseButton
Definition: skilldialog.h:232
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:213
#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:231
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:773
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,
143  std::string());
146  // TRANSLATORS: unknown skills tab name
147  mDefaultTab = new SkillTab(this, _("Unknown"), listbox);
148  mDeleteTabs.push_back(mDefaultTab);
150  mTabs->addTab(mDefaultTab, scroll);
153 }
void adjustTabPositions()
Definition: tabbedarea.cpp:604
#define _(s)
Definition: gettext.h:34
TabbedArea * mTabs
Definition: skilldialog.h:228
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:251
void setVisible(Visible visible)
Definition: widget.cpp:224
SkillTab * mDefaultTab
Definition: skilldialog.h:234
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:431
SkillModel * mDefaultModel
Definition: skilldialog.h:233
std::list< Tab * > mDeleteTabs
Definition: skilldialog.h:229
const bool Opaque_false
Definition: opaque.h:29
void addTab(Tab *const tab, Widget *const widget)
Definition: tabbedarea.cpp:237
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 737 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().

745 {
746  if (mDefaultModel != nullptr)
747  {
748  SkillInfo *const skill = new SkillInfo;
749  skill->id = CAST_U32(id);
750  skill->type = type;
751  skill->owner = owner;
752  SkillData *const data = skill->data;
753  if (name.empty())
754  {
755  data->name = "Unknown skill Id: " + toString(id);
756  data->dispName = data->name;
757  }
758  else
759  {
760  data->name = name;
761  data->dispName = strprintf("%s, %u", name.c_str(), skill->id);
762  }
763  data->description.clear();
764  const std::string icon = getDefaultSkillIcon(type);
765  if (icon.empty())
766  {
767  data->setIcon(paths.getStringValue("missingSkillIcon"));
768  data->haveIcon = false;
769  }
770  else
771  {
772  data->setIcon(icon);
773  data->haveIcon = true;
774  }
776  data->shortName = toString(skill->id);
777  skill->modifiable = modifiable;
778  skill->visible = Visible_false;
779  skill->alwaysVisible = Visible_false;
780  skill->model = mDefaultModel;
781  skill->level = level;
782  // TRANSLATORS: skills dialog. skill level
783  skill->skillLevel = strprintf(_("Lvl: %d"), level);
784  skill->range = range;
785  skill->sp = sp;
786  skill->update();
787  // TRANSLATORS: skills dialog button
788  skill->useButton = _("Use");
789  // TRANSLATORS: skill error message
790  skill->errorText = strprintf(_("Failed skill: %s"), name.c_str());
791  skill->tab = mDefaultTab;
792  mDefaultModel->addSkill(skill);
796 
797  mSkills[id] = skill;
799  }
800 }
void adjustTabPositions()
Definition: tabbedarea.cpp:604
#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:228
void setVisible(Visible visible)
Definition: widget.cpp:224
SkillTab * mDefaultTab
Definition: skilldialog.h:234
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:431
bool unknownSkillsAutoTab
Definition: settings.h:161
SkillModel * mDefaultModel
Definition: skilldialog.h:233
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:226
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 1385 of file skilldialog.cpp.

References FOR_EACH, SkillInfo::id, and mDurations.

Referenced by hasSkills(), and setSkillDuration().

1386 {
1387  if (skill == nullptr)
1388  return;
1389 
1390  FOR_EACH (STD_VECTOR<SkillInfo*>::const_iterator, it, mDurations)
1391  {
1392  if ((*it)->id == skill->id)
1393  return;
1394  }
1395  mDurations.push_back(skill);
1396 }
unsigned int id
Definition: skillinfo.h:68
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
std::vector< SkillInfo * > mDurations
Definition: skilldialog.h:227

◆ clearSkills()

void SkillDialog::clearSkills ( )

Definition at line 330 of file skilldialog.cpp.

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

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

331 {
332  mTabs->removeAll(true);
333  mDeleteTabs.clear();
334  mDefaultTab = nullptr;
335  mDefaultModel = nullptr;
336 
338  mSkills.clear();
339  mDurations.clear();
340 }
void removeAll(const bool del)
Definition: tabbedarea.cpp:727
TabbedArea * mTabs
Definition: skilldialog.h:228
SkillTab * mDefaultTab
Definition: skilldialog.h:234
void delete_all(Container &c)
Definition: dtor.h:55
SkillModel * mDefaultModel
Definition: skilldialog.h:233
std::list< Tab * > mDeleteTabs
Definition: skilldialog.h:229
SkillMap mSkills
Definition: skilldialog.h:226
std::vector< SkillInfo * > mDurations
Definition: skilldialog.h:227

◆ getDefaultSkillIcon()

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

Definition at line 705 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().

706 {
707  std::string icon;
708  switch (type)
709  {
710  case SkillType::Attack:
711  icon = paths.getStringValue("attackSkillIcon");
712  break;
713  case SkillType::Ground:
714  icon = paths.getStringValue("groundSkillIcon");
715  break;
716  case SkillType::Self:
717  icon = paths.getStringValue("selfSkillIcon");
718  break;
719  case SkillType::Unused:
720  icon = paths.getStringValue("unusedSkillIcon");
721  break;
722  case SkillType::Support:
723  icon = paths.getStringValue("supportSkillIcon");
724  break;
726  icon = paths.getStringValue("trapSkillIcon");
727  break;
728  case SkillType::Unknown:
729  icon = paths.getStringValue("unknownSkillIcon");
730  break;
731  default:
732  break;
733  }
734  return icon;
735 }
std::string getStringValue(const std::string &key) const
Configuration paths

◆ getSkill()

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

Definition at line 802 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().

803 {
804  SkillMap::const_iterator it = mSkills.find(id);
805  if (it != mSkills.end())
806  return (*it).second;
807  return nullptr;
808 }
SkillMap mSkills
Definition: skilldialog.h:226

◆ getSkillByItem()

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

Definition at line 810 of file skilldialog.cpp.

References mSkills, and SKILL_MIN_ID.

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

811 {
812  SkillMap::const_iterator it = mSkills.find(itemId - SKILL_MIN_ID);
813  if (it != mSkills.end())
814  return (*it).second;
815  return nullptr;
816 }
const int SKILL_MIN_ID
Definition: skill.h:24
SkillMap mSkills
Definition: skilldialog.h:226

◆ getSkillData()

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

Definition at line 929 of file skilldialog.cpp.

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

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

930 {
931  const SkillMap::const_iterator it = mSkills.find(id);
932  if (it != mSkills.end())
933  {
934  SkillInfo *const info = it->second;
935  if (info != nullptr)
936  return info->data;
937  }
938  return nullptr;
939 }
SkillData * data
Definition: skillinfo.h:62
bool info(InputEvent &event)
Definition: commands.cpp:56
SkillMap mSkills
Definition: skilldialog.h:226

◆ getSkillDataByLevel()

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

Definition at line 941 of file skilldialog.cpp.

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

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

943 {
944  const SkillMap::const_iterator it = mSkills.find(id);
945  if (it != mSkills.end())
946  {
947  SkillInfo *const info = it->second;
948  if (info != nullptr)
949  return info->getData1(level);
950  }
951  return nullptr;
952 }
bool info(InputEvent &event)
Definition: commands.cpp:56
SkillData * getData1(const int level) const
Definition: skillinfo.cpp:190
SkillMap mSkills
Definition: skilldialog.h:226

◆ hasSkills()

bool SkillDialog::hasSkills ( ) const
inline

◆ hideSkills()

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

Definition at line 342 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().

343 {
344  FOR_EACH (SkillMap::iterator, it, mSkills)
345  {
346  SkillInfo *const info = (*it).second;
347  if ((info != nullptr) && info->owner == owner)
348  {
349  PlayerInfo::setSkillLevel(info->id, 0);
350  if (info->alwaysVisible == Visible_false)
351  info->visible = Visible_false;
352  }
353  }
354 }
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:226

◆ loadSkill()

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

Definition at line 495 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().

497 {
498  int id = XML::getIntProperty(node, "id", -1, -1, 1000000);
499  if (id == -1)
500  {
501  id = XML::getIntProperty(node, "var", -1, -1, 100000);
502  if (id == -1)
503  return nullptr;
504  id += SKILL_VAR_MIN_ID;
505  }
506 
507  SkillInfo *skill = getSkill(id);
508  if (skill == nullptr)
509  {
510  std::string name = XML::langProperty(node, "name",
511  // TRANSLATORS: skills dialog. skill id
512  strprintf(_("Skill %d"), id));
513 
514  skill = new SkillInfo;
515  skill->id = CAST_U32(id);
516  skill->modifiable = Modifiable_false;
517  skill->model = model;
518  skill->update();
519  skill->useButton = XML::getProperty(
520  // TRANSLATORS: skills dialog button
521  node, "useButton", _("Use"));
523  node, "owner", "player"));
524  skill->errorText = XML::getProperty(
525  node, "errorText", name);
527  node, "alwaysVisible", false), Visible);
528  skill->castingAction = XML::getProperty(node,
529  "castingAction", SpriteAction::CAST);
530  skill->castingRideAction = XML::getProperty(node,
531  "castingRideAction", SpriteAction::CASTRIDE);
532  skill->castingSkyAction = XML::getProperty(node,
533  "castingSkyAction", SpriteAction::CASTSKY);
534  skill->castingWaterAction = XML::getProperty(node,
535  "castingWaterAction", SpriteAction::CASTWATER);
537  node, "useTextParameter", false);
538  skill->x = XML::getProperty(node,
539  "x", 0);
540  skill->y = XML::getProperty(node,
541  "y", 0);
542  skill->visible = skill->alwaysVisible;
543  model->addSkill(skill);
544  mSkills[id] = skill;
545  }
546 
547  loadSkillData(node, skill);
548  return skill;
549 }
#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:173
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:189
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:268
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:257
Visible visible
Definition: skillinfo.h:80
SkillMap mSkills
Definition: skilldialog.h:226
SkillModel * model
Definition: skillinfo.h:60

◆ loadSkillData()

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

Definition at line 551 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().

553 {
554  if (skill == nullptr)
555  return;
556  const int level = (skill->alwaysVisible == Visible_true) ?
557  0 : XML::getProperty(node, "level", 0);
558  SkillData *data = skill->getData(level);
559  if (data == nullptr)
560  data = new SkillData;
561 
562  const std::string name = XML::langProperty(node, "name",
563  // TRANSLATORS: skills dialog. skill id
564  strprintf(_("Skill %u"), skill->id));
565  data->name = name;
566  const std::string icon = XML::getProperty(node, "icon", "");
567  if (icon.empty())
568  {
569  data->setIcon(paths.getStringValue("missingSkillIcon"));
570  data->haveIcon = false;
571  }
572  else
573  {
574  data->setIcon(icon);
575  data->haveIcon = true;
576  }
577  if (skill->id < SKILL_VAR_MIN_ID)
578  {
579  data->dispName = strprintf("%s, %u",
580  name.c_str(),
581  skill->id);
582  }
583  else
584  {
585  data->dispName = strprintf("%s, (%u)",
586  name.c_str(),
587  skill->id - SKILL_VAR_MIN_ID);
588  }
589  data->shortName = XML::langProperty(node,
590  "shortName", name.substr(0, 3));
592  node, "description", "");
593 
594  MissileInfo &missile = data->missile;
595  missile.particle = XML::getProperty(
596  node, "missile-particle", "");
597  missile.z = XML::getFloatProperty(
598  node, "missile-z", 32.0f);
599  missile.lifeTime = XML::getProperty(
600  node, "missile-lifetime", 500);
601  missile.speed = XML::getFloatProperty(
602  node, "missile-speed", 7.0f);
604  node, "missile-diedistance", 8.0f);
605 
606  MissileInfo &castingMissile = data->castingMissile;
607  castingMissile.particle = XML::getProperty(
608  node, "castingMissile-particle", "");
609  castingMissile.z = XML::getFloatProperty(
610  node, "castingMissile-z", 32.0f);
611  castingMissile.lifeTime = XML::getProperty(
612  node, "castingMissile-lifetime", 500);
613  castingMissile.speed = XML::getFloatProperty(
614  node, "castingMissile-speed", 7.0f);
615  castingMissile.dieDistance = XML::getFloatProperty(
616  node, "castingMissile-diedistance", 8.0f);
617 
619  node,
620  "castingAnimation",
621  paths.getStringValue("skillCastingAnimation"));
622 
624  node, "soundHit", "");
626  node, "soundHitDelay", 0);
628  node, "soundMiss", "");
630  node, "soundMissDelay", 0);
631  data->invokeCmd = XML::getProperty(
632  node, "invokeCmd", "");
634  node, "levelUpEffectId", -1);
636  node, "removeEffectId", -1);
638  node, "hitEffectId", -1);
640  node, "missEffectId", -1);
642  node, "castingSrcEffectId", -1);
644  node, "castingDstEffectId", -1);
646  node, "srcEffectId", -1);
648  node, "dstEffectId", -1);
650  node, "castingGroundEffectId", -1);
652  node, "autoTab", true);
653 
654  skill->addData(level, data);
655 }
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:210
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:173
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:268
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:257
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 356 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().

357 {
358  clearSkills();
360  if (mSkills.empty())
362  loadXmlFile(paths.getStringValue("skillsPatchFile"), SkipError_true);
363  loadXmlDir("skillsPatchDir", loadXmlFile);
364  addDefaultTab();
365 
366  update();
367 }
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:226
const bool SkipError_true
Definition: skiperror.h:29

◆ loadXmlFile()

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

Definition at line 369 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().

371 {
374  skipError);
375  XmlNodePtrConst root = doc.rootNode();
376 
377  int setCount = 0;
378 
379  if ((root == nullptr) || !xmlNameEqual(root, "skills"))
380  {
381  logger->log("Error loading skills: " + fileName);
382  return;
383  }
384 
385  for_each_xml_child_node(set, root)
386  {
387  if (xmlNameEqual(set, "include"))
388  {
389  const std::string name = XML::getProperty(set, "name", "");
390  if (!name.empty())
391  loadXmlFile(name, skipError);
392  continue;
393  }
394  else if (xmlNameEqual(set, "set"))
395  {
396  setCount++;
397  const std::string setName = XML::getProperty(set, "name",
398  // TRANSLATORS: skills dialog default skill tab
399  strprintf(_("Skill Set %d"), setCount));
400 
401  const std::string setTypeStr = XML::getProperty(set, "type", "");
403  if (setTypeStr.empty() ||
404  setTypeStr == "list" ||
405  setTypeStr == "vertical")
406  {
407  setType = SkillSetType::VerticalList;
408  }
409  else if (setTypeStr == "rectangle")
410  {
411  setType = SkillSetType::Rectangle;
412  }
413 
414  bool alwaysVisible = false;
415  SkillModel *const model = new SkillModel;
416  SkillTab *tab = nullptr;
417  ScrollArea *scroll = nullptr;
418 
419  switch (setType)
420  {
422  {
423  // possible leak listbox, scroll
424  SkillListBox *const listbox = new SkillListBox(this,
425  model);
426  listbox->setActionEventId("sel");
427  listbox->addActionListener(this);
428  scroll = new ScrollArea(this,
429  listbox,
430  Opaque_false,
431  std::string());
434  tab = new SkillTab(this, setName, listbox);
435  break;
436  }
438  {
439  SkillRectangleListBox *const listbox =
440  new SkillRectangleListBox(this,
441  model);
442  listbox->setActionEventId("sel");
443  listbox->addActionListener(this);
444  scroll = new ScrollArea(this,
445  listbox,
446  Opaque_false,
447  std::string());
450  tab = new SkillTab(this, setName, listbox);
451  break;
452  }
453  default:
454  reportAlways("Unsupported skillset type: %s",
455  setTypeStr.c_str());
456  return;
457  }
458  if (mDefaultModel == nullptr)
459  {
461  mDefaultTab = tab;
462  }
463 
464  mDeleteTabs.push_back(tab);
465  if (alwaysVisible == true)
466  tab->setVisible(Visible_true);
467  else
469  mTabs->addTab(tab, scroll);
470 
471  for_each_xml_child_node(node, set)
472  {
473  if (xmlNameEqual(node, "skill"))
474  {
475  SkillInfo *const skill = loadSkill(node, model);
476  if (skill == nullptr)
477  continue;
478  if (skill->alwaysVisible == Visible_true)
479  alwaysVisible = true;
480  skill->tab = tab;
481  for_each_xml_child_node(levelNode, node)
482  {
483  if (!xmlNameEqual(levelNode, "level"))
484  continue;
485  loadSkillData(node, skill);
486  }
487  }
488  }
489 
490  model->updateVisibilities();
491  }
492  }
493 }
#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:38
TabbedArea * mTabs
Definition: skilldialog.h:228
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:234
SkillTab * tab
Definition: skillinfo.h:61
int getProperty(const xmlNodePtr node, const char *const name, int def)
Definition: libxml.cpp:173
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:88
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:233
std::list< Tab * > mDeleteTabs
Definition: skilldialog.h:229
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:264
#define reportAlways(...)
Definition: checkutils.h:252
void addTab(Tab *const tab, Widget *const widget)
Definition: tabbedarea.cpp:237
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 978 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().

983 {
984  if (effectManager == nullptr)
985  return;
986  SkillData *const data = getSkillDataByLevel(id, level);
987  if (data == nullptr)
988  return;
990  x * 32,
991  y * 32,
992  cur_time + delay / 1000, // end time in seconds
993  paths.getIntValue("skillCastingGroundEffectId"));
994 }
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 966 of file skilldialog.cpp.

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

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

967 {
968  if (effectManager == nullptr)
969  return;
970  const SkillData *const data = getSkillData(id);
971  if (data == nullptr)
972  return;
974  localPlayer,
975  paths.getIntValue("skillRemoveEffectId"));
976 }
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 954 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().

955 {
956  if (effectManager == nullptr)
957  return;
958  const SkillData *const data = getSkillData(id);
959  if (data == nullptr)
960  return;
962  localPlayer,
963  paths.getIntValue("skillLevelUpEffectId"));
964 }
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:1082
void enableVisibleSound(bool b)
Definition: window.h:480
Widget * getParent() const
Definition: widget.h:201
void setLocationRelativeTo(const Widget *const widget)
Definition: window.cpp:508
void postInit()
Definition: window.cpp:248

◆ removeSkill()

void SkillDialog::removeSkill ( const int  id)

Definition at line 657 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().

658 {
659  const SkillMap::const_iterator it = mSkills.find(id);
660 
661  if (it != mSkills.end())
662  {
663  SkillInfo *const info = it->second;
664  if (info != nullptr)
665  {
666  info->level = 0;
667  info->update();
669  if (info->alwaysVisible == Visible_false)
670  info->visible = Visible_false;
671  }
672  }
673 }
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:226

◆ selectSkillCastType()

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

Definition at line 1438 of file skilldialog.cpp.

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

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

1440 {
1441  SkillInfo *const info = getSkill(skillId);
1442  if (info == nullptr)
1443  return;
1444  info->customCastType = type;
1445  info->update();
1446 }
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 1425 of file skilldialog.cpp.

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

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

1427 {
1428  SkillInfo *const info = getSkill(skillId);
1429  if (info == nullptr)
1430  return;
1431  if (level > info->level)
1432  info->customSelectedLevel = info->level;
1433  else
1434  info->customSelectedLevel = level;
1435  info->update();
1436 }
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 818 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().

821 {
822  SkillMap::const_iterator it = mSkills.find(id);
823  SkillInfo *info = nullptr;
824  if (it == mSkills.end())
825  {
826  addSkill(owner, id, "", 0, 0, Modifiable_false, SkillType::Unknown, 0);
827  it = mSkills.find(id);
828  }
829  if (it != mSkills.end())
830  {
831  info = (*it).second;
832  }
833  if (info != nullptr)
834  {
835  info->duration = duration;
836  info->durationTime = tick_time;
837  addSkillDuration(info);
838  }
839 }
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:226
int durationTime
Definition: skillinfo.h:72

◆ setSkillOffsetX()

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

Definition at line 1448 of file skilldialog.cpp.

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

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

1450 {
1451  SkillInfo *const info = getSkill(skillId);
1452  if (info == nullptr)
1453  return;
1454  info->customOffsetX = offset;
1455  info->update();
1456 }
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 1458 of file skilldialog.cpp.

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

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

1460 {
1461  SkillInfo *const info = getSkill(skillId);
1462  if (info == nullptr)
1463  return;
1464  info->customOffsetY = offset;
1465  info->update();
1466 }
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 1398 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().

1399 {
1400  FOR_EACH_SAFE (STD_VECTOR<SkillInfo*>::iterator, it, mDurations)
1401  {
1402  SkillInfo *const skill = *it;
1403  if (skill != nullptr)
1404  {
1405  const int time = get_elapsed_time(skill->durationTime);
1406  if (time >= skill->duration)
1407  {
1408  it = mDurations.erase(it);
1409  skill->cooldown = 0;
1410  skill->duration = 0;
1411  skill->durationTime = 0;
1412  if (it == mDurations.end())
1413  return;
1414  if (it != mDurations.begin())
1415  -- it;
1416  }
1417  else if (time != 0)
1418  {
1419  skill->cooldown = skill->duration * 100 / time;
1420  }
1421  }
1422  }
1423 }
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:227
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 223 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().

224 {
225  const SkillMap::const_iterator i = mSkills.find(id);
226 
227  if (i != mSkills.end())
228  {
229  SkillInfo *const info = i->second;
230  if (info != nullptr)
231  {
232  info->update();
233  return info->data->name;
234  }
235  }
236 
237  return std::string();
238 }
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:226

◆ update() [2/2]

void SkillDialog::update ( )

Update other parts of the display

Definition at line 240 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().

241 {
242  // TRANSLATORS: skills dialog label
243  mPointsLabel->setCaption(strprintf(_("Skill points available: %d"),
246 
247  ItemShortcut *const shortcuts = itemShortcut[SHORTCUT_AUTO_TAB];
248  shortcuts->clear();
249  size_t idx = 0;
250 
251  FOR_EACH (SkillMap::const_iterator, it, mSkills)
252  {
253  SkillInfo *const info = (*it).second;
254  if (info == nullptr)
255  continue;
256  if (info->modifiable == Modifiable_true)
257  info->update();
258  if (info->visible == Visible_false ||
259  idx >= SHORTCUT_ITEMS ||
260  !info->data->autoTab)
261  {
262  continue;
263  }
264  const SkillType::SkillType type = info->type;
265  if (type == SkillType::Attack ||
266  type == SkillType::Ground ||
267  type == SkillType::Self ||
268  type == SkillType::Support)
269  {
270  shortcuts->setItemFast(idx,
271  info->id + SKILL_MIN_ID,
273 
274  shortcuts->setItemData(idx,
275  info->toDataStr());
276  idx ++;
277  }
278  }
279 
280  skillPopup->reset();
281 }
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:230
#define fromInt(val, name)
Definition: intdefines.h:45
SkillPopup * skillPopup
Definition: skillpopup.cpp:41
void reset()
Definition: skillpopup.cpp:248
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:261
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:226
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:197
const unsigned int SHORTCUT_ITEMS
Definition: itemshortcut.h:26

◆ updateModels()

void SkillDialog::updateModels ( )

Definition at line 283 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().

284 {
285  std::set<SkillModel*> models;
286 
287  FOR_EACH (SkillMap::const_iterator, it, mSkills)
288  {
289  SkillInfo *const info = (*it).second;
290  if (info != nullptr)
291  {
292  SkillModel *const model = info->model;
293  if (model != nullptr)
294  models.insert(model);
295  }
296  }
297  FOR_EACH (std::set<SkillModel*>::iterator, it, models)
298  {
299  SkillModel *const model = *it;
300  if (model != nullptr)
301  model->updateVisibilities();
302  }
303 }
#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:226
SkillModel * model
Definition: skillinfo.h:60

◆ updateModelsHidden()

void SkillDialog::updateModelsHidden ( )

Definition at line 305 of file skilldialog.cpp.

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

Referenced by EAthena::SkillRecv::processPlayerSkills().

306 {
307  std::set<SkillModel*> models;
308 
309  FOR_EACH (SkillMap::const_iterator, it, mSkills)
310  {
311  SkillInfo *const info = (*it).second;
312  if (info != nullptr)
313  {
314  if (info->visible == Visible_false)
315  {
316  SkillModel *const model = info->model;
317  if (model != nullptr)
318  models.insert(model);
319  }
320  }
321  }
322  FOR_EACH (std::set<SkillModel*>::iterator, it, models)
323  {
324  SkillModel *const model = *it;
325  if (model != nullptr)
326  model->updateVisibilities();
327  }
328 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
void updateVisibilities()
Definition: skillmodel.cpp:53
const bool Visible_false
Definition: visible.h:29
bool info(InputEvent &event)
Definition: commands.cpp:56
Visible visible
Definition: skillinfo.h:80
SkillMap mSkills
Definition: skilldialog.h:226
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 908 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().

913 {
914  const int id = var + SKILL_VAR_MIN_ID;
915  const SkillMap::const_iterator it = mSkills.find(id);
916 
917  if (it != mSkills.end())
918  {
919  SkillInfo *const info = it->second;
920  if (info != nullptr)
921  {
922  PlayerInfo::setSkillLevel(id, val1);
923  info->level = val1;
924  info->update();
925  }
926  }
927 }
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:226

◆ updateSkill()

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

Definition at line 675 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().

680 {
681  const SkillMap::const_iterator it = mSkills.find(id);
682 
683  if (it != mSkills.end())
684  {
685  SkillInfo *const info = it->second;
686  if (info != nullptr)
687  {
688  info->modifiable = modifiable;
689  info->range = range;
690  info->type = type;
691  info->sp = sp;
692  info->update();
693  if (info->tab != nullptr)
694  {
695  info->tab->setVisible(Visible_true);
698  }
699  }
700  return true;
701  }
702  return false;
703 }
void adjustTabPositions()
Definition: tabbedarea.cpp:604
const bool Visible_true
Definition: visible.h:29
TabbedArea * mTabs
Definition: skilldialog.h:228
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:431
int range
Definition: skillinfo.h:69
int sp
Definition: skillinfo.h:70
void update()
Definition: skillinfo.cpp:82
SkillMap mSkills
Definition: skilldialog.h:226
SkillType::SkillType type
Definition: skillinfo.h:76

◆ updateTabSelection()

void SkillDialog::updateTabSelection ( )

Definition at line 887 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().

888 {
889  const SkillTab *const tab = static_cast<SkillTab*>(
890  mTabs->getSelectedTab());
891  if (tab != nullptr)
892  {
893  if (const SkillInfo *const info = tab->getSelectedInfo())
894  {
895  mUseButton->setEnabled(info->range > 0);
897  mUseButton->setCaption(info->useButton);
898  }
899  else
900  {
901  mUseButton->setEnabled(false);
902  // TRANSLATORS: inventory button
903  mUseButton->setCaption(_("Use"));
904  }
905  }
906 }
#define _(s)
Definition: gettext.h:34
TabbedArea * mTabs
Definition: skilldialog.h:228
Button * mIncreaseButton
Definition: skilldialog.h:232
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:213
bool info(InputEvent &event)
Definition: commands.cpp:56
Button * mUseButton
Definition: skilldialog.h:231
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 849 of file skilldialog.cpp.

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

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

853 {
854  const std::map<int, SkillInfo*>::const_iterator
855  it = mSkills.find(itemId - SKILL_MIN_ID);
856  if (it == mSkills.end())
857  return;
858 
859  const SkillInfo *const info = (*it).second;
860  CastTypeT castType = CastType::Default;
861  int offsetX = 0;
862  int offsetY = 0;
863 
864  if (!data.empty())
865  {
866  STD_VECTOR<int> vect;
867  splitToIntVector(vect, data, ' ');
868  const size_t sz = vect.size();
869  if (sz > 0)
870  castType = static_cast<CastTypeT>(vect[0]);
871  if (sz > 2)
872  {
873  offsetX = vect[1];
874  offsetY = vect[2];
875  }
876  }
877  useSkill(info,
878  autoTarget,
879  level,
880  false,
881  std::string(),
882  castType,
883  offsetX,
884  offsetY);
885 }
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:226
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 996 of file skilldialog.cpp.

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

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

1004 {
1005  SkillInfo *const info = skillDialog->getSkill(skillId);
1006  if (info == nullptr)
1007  return;
1008  if (castType == CastType::Default)
1009  castType = info->customCastType;
1010  useSkill(info,
1011  autoTarget,
1012  level,
1013  withText,
1014  text,
1015  castType,
1016  offsetX,
1017  offsetY);
1018 }
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 1020 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.

1028 {
1029  if ((info == nullptr) || (localPlayer == nullptr))
1030  return;
1031  if (level == 0)
1032  level = info->level;
1033 
1034  const SkillData *data = info->getData1(level);
1035  if (data != nullptr)
1036  {
1037  const std::string cmd = data->invokeCmd;
1038  if (!cmd.empty())
1040  }
1041  switch (castType)
1042  {
1043  default:
1044  case CastType::Default:
1045  useSkillDefault(info,
1046  autoTarget,
1047  level,
1048  withText,
1049  text,
1050  offsetX,
1051  offsetY);
1052  break;
1053  case CastType::Target:
1054  {
1055  const Being *const being = localPlayer->getTarget();
1056  useSkillTarget(info,
1057  autoTarget,
1058  level,
1059  withText,
1060  text,
1061  being,
1062  offsetX,
1063  offsetY);
1064  break;
1065  }
1066  case CastType::Position:
1067  {
1068  int x = 0;
1069  int y = 0;
1070  viewport->getMouseTile(x, y);
1071  useSkillPosition(info,
1072  level,
1073  withText,
1074  text,
1075  x,
1076  y,
1077  offsetX,
1078  offsetY);
1079  break;
1080  }
1081  case CastType::Self:
1082  // +++ probably need call useSkillSelf
1083  useSkillTarget(info,
1084  autoTarget,
1085  level,
1086  withText,
1087  text,
1088  localPlayer,
1089  offsetX,
1090  offsetY);
1091  break;
1092  }
1093 }
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:613
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 1283 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().

1290 {
1291  SkillType::SkillType type = info->type;
1292  if ((type & SkillType::Attack) != 0)
1293  {
1294  const Being *being = localPlayer->getTarget();
1295  if ((being == nullptr) && autoTarget == AutoTarget_true)
1296  {
1298  AllowSort_true);
1299  }
1300  if (being != nullptr)
1301  {
1302  skillHandler->useBeing(info->id,
1303  level,
1304  being->getId());
1305  }
1306  }
1307  else if ((type & SkillType::Support) != 0)
1308  {
1309  const Being *being = localPlayer->getTarget();
1310  if (being == nullptr)
1311  being = localPlayer;
1312  if (being != nullptr)
1313  {
1314  skillHandler->useBeing(info->id,
1315  level,
1316  being->getId());
1317  }
1318  }
1319  else if ((type & SkillType::Self) != 0)
1320  {
1321  skillHandler->useBeing(info->id,
1322  level,
1323  localPlayer->getId());
1324  }
1325  else if ((type & SkillType::Ground) != 0)
1326  {
1327  int x = 0;
1328  int y = 0;
1329  viewport->getMouseTile(x, y);
1330  localPlayer->fixDirectionOffsets(offsetX, offsetY);
1331  x += offsetX;
1332  y += offsetY;
1333  if (info->useTextParameter)
1334  {
1335  if (withText)
1336  {
1337  skillHandler->usePos(info->id,
1338  level,
1339  x, y,
1340  text);
1341  }
1342  else
1343  {
1344  const SkillData *data = info->getData1(level);
1346  x,
1347  y,
1348  level);
1349  TextDialog *const dialog = CREATEWIDGETR(TextDialog,
1350  // TRANSLATORS: text skill dialog header
1351  strprintf(_("Add text to skill %s"),
1352  data->name.c_str()),
1353  // TRANSLATORS: text skill dialog field
1354  _("Text: "),
1355  nullptr,
1356  false);
1357  dialog->setModal(Modal_true);
1358  textSkillListener.setDialog(dialog);
1359  dialog->setActionEventId("ok");
1361  }
1362  }
1363  else
1364  {
1365  skillHandler->usePos(info->id,
1366  level,
1367  x, y);
1368  }
1369  }
1370  else if ((type & SkillType::TargetTrap) != 0)
1371  {
1372  // for now unused
1373  }
1374  else if (type == SkillType::Unknown ||
1375  type == SkillType::Unused)
1376  {
1377  // unknown / unused
1378  }
1379  else
1380  {
1381  reportAlways("Unsupported skill type: %d", type);
1382  }
1383 }
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:93
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:613
void fixDirectionOffsets(int &offsetX, int &offsetY) const
Definition: being.cpp:5528
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:1064
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 1198 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().

1206 {
1207  SkillType::SkillType type = info->type;
1208  if ((type & SkillType::Ground) != 0)
1209  {
1210  localPlayer->fixDirectionOffsets(offsetX, offsetY);
1211  if (info->useTextParameter)
1212  {
1213  if (withText)
1214  {
1215  skillHandler->usePos(info->id,
1216  level,
1217  x + offsetX,
1218  y + offsetY,
1219  text);
1220  }
1221  else
1222  {
1223  const SkillData *data = info->getData1(level);
1225  x + offsetX,
1226  y + offsetY,
1227  level);
1228  TextDialog *const dialog = CREATEWIDGETR(TextDialog,
1229  // TRANSLATORS: text skill dialog header
1230  strprintf(_("Add text to skill %s"),
1231  data->name.c_str()),
1232  // TRANSLATORS: text skill dialog field
1233  _("Text: "),
1234  nullptr,
1235  false);
1236  dialog->setModal(Modal_true);
1237  textSkillListener.setDialog(dialog);
1238  dialog->setActionEventId("ok");
1240  }
1241  }
1242  else
1243  {
1244  skillHandler->usePos(info->id,
1245  level,
1246  x + offsetX,
1247  y + offsetY);
1248  }
1249  }
1250  else if ((type & SkillType::Support) != 0)
1251  {
1252  // wrong type
1253  skillHandler->useBeing(info->id,
1254  level,
1255  localPlayer->getId());
1256  }
1257  else if ((type & SkillType::Self) != 0)
1258  {
1259  skillHandler->useBeing(info->id,
1260  level,
1261  localPlayer->getId());
1262  }
1263  else if ((type & SkillType::Attack) != 0)
1264  {
1265  // do nothing
1266  // +++ probably need select some target on x,y position?
1267  }
1268  else if ((type & SkillType::TargetTrap) != 0)
1269  {
1270  // for now unused
1271  }
1272  else if (type == SkillType::Unknown ||
1273  type == SkillType::Unused)
1274  {
1275  // unknown / unused
1276  }
1277  else
1278  {
1279  reportAlways("Unsupported skill type: %d", type);
1280  }
1281 }
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:93
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:5528
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:1064

◆ 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 1095 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().

1103 {
1104  SkillType::SkillType type = info->type;
1105  if ((type & SkillType::Attack) != 0)
1106  {
1107  if ((being == nullptr) && autoTarget == AutoTarget_true)
1108  {
1109  if (localPlayer != nullptr)
1110  {
1112  AllowSort_true);
1113  }
1114  }
1115  if (being != nullptr)
1116  {
1117  skillHandler->useBeing(info->id,
1118  level,
1119  being->getId());
1120  }
1121  }
1122  else if ((type & SkillType::Support) != 0)
1123  {
1124  if (being == nullptr)
1125  being = localPlayer;
1126  if (being != nullptr)
1127  {
1128  skillHandler->useBeing(info->id,
1129  level,
1130  being->getId());
1131  }
1132  }
1133  else if ((type & SkillType::Self) != 0)
1134  {
1135  skillHandler->useBeing(info->id,
1136  level,
1137  localPlayer->getId());
1138  }
1139  else if ((type & SkillType::Ground) != 0)
1140  {
1141  if (being == nullptr)
1142  return;
1143  being->fixDirectionOffsets(offsetX, offsetY);
1144  const int x = being->getTileX() + offsetX;
1145  const int y = being->getTileY() + offsetY;
1146  if (info->useTextParameter)
1147  {
1148  if (withText)
1149  {
1150  skillHandler->usePos(info->id,
1151  level,
1152  x, y,
1153  text);
1154  }
1155  else
1156  {
1157  const SkillData *data = info->getData1(level);
1159  x,
1160  y,
1161  level);
1162  TextDialog *const dialog = CREATEWIDGETR(TextDialog,
1163  // TRANSLATORS: text skill dialog header
1164  strprintf(_("Add text to skill %s"),
1165  data->name.c_str()),
1166  // TRANSLATORS: text skill dialog field
1167  _("Text: "),
1168  nullptr,
1169  false);
1170  dialog->setModal(Modal_true);
1171  textSkillListener.setDialog(dialog);
1172  dialog->setActionEventId("ok");
1174  }
1175  }
1176  else
1177  {
1178  skillHandler->usePos(info->id,
1179  level,
1180  x, y);
1181  }
1182  }
1183  else if ((type & SkillType::TargetTrap) != 0)
1184  {
1185  // for now unused
1186  }
1187  else if (type == SkillType::Unknown ||
1188  type == SkillType::Unused)
1189  {
1190  // unknown / unused
1191  }
1192  else
1193  {
1194  reportAlways("Unsupported skill type: %d", type);
1195  }
1196 }
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:93
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:5528
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:1064

◆ widgetResized()

void SkillDialog::widgetResized ( const Event event)
virtual

Called whenever the widget changes size.

Reimplemented from Window.

Definition at line 841 of file skilldialog.cpp.

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

Referenced by hasSkills().

842 {
843  Window::widgetResized(event);
844 
845  if (mTabs != nullptr)
846  mTabs->adjustSize();
847 }
TabbedArea * mTabs
Definition: skilldialog.h:228
void widgetResized(const Event &event)
Definition: window.cpp:650
void adjustSize()
Definition: tabbedarea.cpp:567

Field Documentation

◆ mDefaultModel

SkillModel* SkillDialog::mDefaultModel
private

Definition at line 233 of file skilldialog.h.

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

◆ mDefaultTab

SkillTab* SkillDialog::mDefaultTab
private

Definition at line 234 of file skilldialog.h.

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

◆ mDeleteTabs

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

Definition at line 229 of file skilldialog.h.

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

◆ mDurations

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

Definition at line 227 of file skilldialog.h.

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

◆ mIncreaseButton

Button* SkillDialog::mIncreaseButton
private

Definition at line 232 of file skilldialog.h.

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

◆ mPointsLabel

Label* SkillDialog::mPointsLabel
private

Definition at line 230 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 231 of file skilldialog.h.

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


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