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 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)
 
static void loadSkillData (const xmlNodePtr node, SkillInfo *const skill)
 

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 56 of file skilldialog.h.

Member Typedef Documentation

◆ SkillMap

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

Definition at line 226 of file skilldialog.h.

Constructor & Destructor Documentation

◆ SkillDialog()

SkillDialog::SkillDialog ( )

Definition at line 84 of file skilldialog.cpp.

84  :
85  // TRANSLATORS: skills dialog name
86  Window(_("Skills"), Modal_false, nullptr, "skills.xml"),
88  mSkills(),
89  mDurations(),
91  mDeleteTabs(),
92  mPointsLabel(new Label(this, "0")),
93  // TRANSLATORS: skills dialog button
94  mUseButton(new Button(this, _("Use"), "use", BUTTON_SKIN, this)),
95  // TRANSLATORS: skills dialog button
96  mIncreaseButton(new Button(this, _("Up"), "inc", BUTTON_SKIN, this)),
97  mDefaultModel(nullptr),
98  mDefaultTab(nullptr)
99 {
100  setWindowName("Skills");
101  setCloseButton(true);
102  setResizable(true);
103  setSaveVisible(true);
104  setStickyButtonLock(true);
105  setDefaultSize(windowContainer->getWidth() - 280, 30, 275, 425);
106  if (setupWindow != nullptr)
108 
109  mUseButton->setEnabled(false);
110  mIncreaseButton->setEnabled(false);
111  mTabs->setSelectable(false);
114 
115  place(0, 0, mTabs, 5, 5);
116  place(0, 5, mPointsLabel, 4, 1);
117  place(3, 5, mUseButton, 1, 1);
118  place(4, 5, mIncreaseButton, 1, 1);
119 }
const std::string BUTTON_SKIN
Definition: button.h:89
Definition: button.h:102
Definition: label.h:91
void registerWindowForReset(Window *const window)
SkillModel * mDefaultModel
Definition: skilldialog.h:234
SkillMap mSkills
Definition: skilldialog.h:227
std::vector< SkillInfo * > mDurations
Definition: skilldialog.h:228
SkillTab * mDefaultTab
Definition: skilldialog.h:235
Label * mPointsLabel
Definition: skilldialog.h:231
std::list< Tab * > mDeleteTabs
Definition: skilldialog.h:230
Button * mUseButton
Definition: skilldialog.h:232
Button * mIncreaseButton
Definition: skilldialog.h:233
TabbedArea * mTabs
Definition: skilldialog.h:229
Widget * getTabContainer() const
Definition: tabbedarea.h:241
Widget * getWidgetContainer() const
Definition: tabbedarea.h:244
void setEnabled(const bool enabled)
Definition: widget.h:352
void setSelectable(const bool selectable)
Definition: widget.h:948
int getWidth() const
Definition: widget.h:221
void setSaveVisible(const bool save)
Definition: window.h:300
void setResizable(const bool resize)
Definition: window.cpp:627
void setWindowName(const std::string &name)
Definition: window.h:355
Window(const std::string &caption, const Modal modal, Window *const parent, std::string skin)
Definition: window.cpp:109
void setCloseButton(const bool flag)
Definition: window.cpp:749
void setStickyButtonLock(const bool sticky)
Definition: window.cpp:772
LayoutCell & place(const int x, const int y, Widget *const wg, const int w, const int h)
Definition: window.cpp:1384
void setDefaultSize()
Definition: window.cpp:1198
#define CREATEWIDGETR(type,...)
Definition: createwidget.h:36
#define _(s)
Definition: gettext.h:35
const bool Modal_false
Definition: modal.h:30
SetupWindow * setupWindow
Definition: setupwindow.cpp:64
WindowContainer * windowContainer

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.

◆ ~SkillDialog()

SkillDialog::~SkillDialog ( )

Definition at line 129 of file skilldialog.cpp.

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

References clearSkills().

Member Function Documentation

◆ action()

void SkillDialog::action ( const ActionEvent event)
virtual

Called when receiving actions from widget.

Implements ActionListener.

Definition at line 156 of file skilldialog.cpp.

157 {
158  const std::string &eventId = event.getId();
159  if (eventId == "inc")
160  {
161  if (playerHandler == nullptr)
162  return;
163  const SkillTab *const tab = static_cast<const SkillTab *>(
164  mTabs->getSelectedTab());
165  if (tab != nullptr)
166  {
167  if (const SkillInfo *const info = tab->getSelectedInfo())
169  }
170  }
171  else if (eventId == "sel")
172  {
173  const SkillTab *const tab = static_cast<const SkillTab *>(
174  mTabs->getSelectedTab());
175  if (tab != nullptr)
176  {
177  if (const SkillInfo *const info = tab->getSelectedInfo())
178  {
179  mUseButton->setEnabled(info->isUsable());
180  mUseButton->setCaption(info->useButton);
182  const int num = itemShortcutWindow->getTabIndex();
183  if (num >= 0 && num < CAST_S32(SHORTCUT_TABS)
184  && (itemShortcut[num] != nullptr))
185  {
187  info->id + SKILL_MIN_ID);
188  }
189  }
190  else
191  {
192  mUseButton->setEnabled(false);
193  mIncreaseButton->setEnabled(false);
194  // TRANSLATORS: skills dialog button
195  mUseButton->setCaption(_("Use"));
196  }
197  }
198  }
199  else if (eventId == "use")
200  {
201  const SkillTab *const tab = static_cast<const SkillTab *>(
202  mTabs->getSelectedTab());
203  if (tab != nullptr)
204  {
205  const SkillInfo *const info = tab->getSelectedInfo();
206  if (info == nullptr)
207  return;
208  useSkill(info,
209  fromBool(config.getBoolValue("skillAutotarget"), AutoTarget),
210  info->customSelectedLevel,
211  info->useTextParameter,
212  std::string(),
213  info->customCastType,
214  info->customOffsetX,
215  info->customOffsetY);
216  }
217  }
218  else if (eventId == "close")
219  {
221  }
222 }
bool AutoTarget
Definition: autotarget.h:30
#define fromBool(val, name)
Definition: booldefines.h:49
#define CAST_U16
Definition: cast.h:29
#define CAST_S32
Definition: cast.h:30
void setCaption(const std::string &caption)
Definition: button.h:214
bool getBoolValue(const std::string &key) const
void setItemSelected(const int itemId)
Definition: itemshortcut.h:126
virtual void increaseSkill(const uint16_t skillId) const =0
int getTabIndex() const
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)
SkillInfo * getSelectedInfo() const
Definition: skilltab.h:67
Tab * getSelectedTab() const
Definition: tabbedarea.h:175
virtual void setVisible(Visible visible)
Definition: window.cpp:778
Configuration config
const unsigned int SHORTCUT_TABS
Definition: itemshortcut.h:28
ItemShortcut * itemShortcut[SHORTCUT_TABS]
bool info(InputEvent &event)
Definition: commands.cpp:57
Net::PlayerHandler * playerHandler
Definition: net.cpp:96
const int SKILL_MIN_ID
Definition: skill.h:25
const unsigned int SKILL_VAR_MIN_ID
Definition: skill.h:26
ShortcutWindow * itemShortcutWindow
const bool Visible_false
Definition: visible.h:30

References _, CAST_S32, CAST_U16, config, 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(), and Visible_false.

◆ addDefaultTab()

void SkillDialog::addDefaultTab ( )
private

Definition at line 134 of file skilldialog.cpp.

135 {
137  SkillListBox *const listbox = new SkillListBox(this,
138  mDefaultModel);
139  listbox->setActionEventId("sel");
140  listbox->addActionListener(this);
141  ScrollArea *const scroll = new ScrollArea(this,
142  listbox,
143  Opaque_false,
144  std::string());
147  // TRANSLATORS: unknown skills tab name
148  mDefaultTab = new SkillTab(this, _("Unknown"), listbox);
149  mDeleteTabs.push_back(mDefaultTab);
151  mTabs->addTab(mDefaultTab, scroll);
154 }
void setVerticalScrollPolicy(const ScrollPolicy vPolicy)
void setHorizontalScrollPolicy(const ScrollPolicy hPolicy)
void setSelectedTabDefault()
Definition: tabbedarea.cpp:432
void adjustTabPositions()
Definition: tabbedarea.cpp:606
void addTab(Tab *const tab, Widget *const widget)
Definition: tabbedarea.cpp:238
void setVisible(Visible visible)
Definition: widget.cpp:225
void setActionEventId(const std::string &actionEventId)
Definition: widget.h:596
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:252
const bool Opaque_false
Definition: opaque.h:30

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 loadSkills().

◆ 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 738 of file skilldialog.cpp.

746 {
747  if (mDefaultModel != nullptr)
748  {
749  SkillInfo *const skill = new SkillInfo;
750  skill->id = CAST_U32(id);
751  skill->type = type;
752  skill->owner = owner;
753  SkillData *const data = skill->data;
754  if (name.empty())
755  {
756  data->name = "Unknown skill Id: " + toString(id);
757  data->dispName = data->name;
758  }
759  else
760  {
761  data->name = name;
762  data->dispName = strprintf("%s, %u", name.c_str(), skill->id);
763  }
764  data->description.clear();
765  const std::string icon = getDefaultSkillIcon(type);
766  if (icon.empty())
767  {
768  data->setIcon(paths.getStringValue("missingSkillIcon"));
769  data->haveIcon = false;
770  }
771  else
772  {
773  data->setIcon(icon);
774  data->haveIcon = true;
775  }
777  data->shortName = toString(skill->id);
778  skill->modifiable = modifiable;
779  skill->visible = Visible_false;
780  skill->alwaysVisible = Visible_false;
781  skill->model = mDefaultModel;
782  skill->level = level;
783  // TRANSLATORS: skills dialog. skill level
784  skill->skillLevel = strprintf(_("Lvl: %d"), level);
785  skill->range = range;
786  skill->sp = sp;
787  skill->update();
788  // TRANSLATORS: skills dialog button
789  skill->useButton = _("Use");
790  // TRANSLATORS: skill error message
791  skill->errorText = strprintf(_("Failed skill: %s"), name.c_str());
792  skill->tab = mDefaultTab;
797 
798  mSkills[id] = skill;
800  }
801 }
#define CAST_U32
Definition: cast.h:31
std::string getStringValue(const std::string &key) const
bool unknownSkillsAutoTab
Definition: settings.h:164
static std::string getDefaultSkillIcon(const SkillType::SkillType type)
void updateVisibilities()
Definition: skillmodel.cpp:54
void addSkill(SkillInfo *const info)
Definition: skillmodel.h:49
Configuration paths
uint32_t data
bool skill(InputEvent &event)
Definition: commands.cpp:97
std::string toString(T const &value)
converts any type to a string
Definition: catch.hpp:1774
Settings settings
Definition: settings.cpp:32
std::string strprintf(const char *const format,...)
const bool Visible_true
Definition: visible.h:30

References _, SkillModel::addSkill(), TabbedArea::adjustTabPositions(), CAST_U32, data, getDefaultSkillIcon(), Configuration::getStringValue(), mDefaultModel, mDefaultTab, mSkills, mTabs, paths, TabbedArea::setSelectedTabDefault(), settings, Widget::setVisible(), Actions::skill(), strprintf(), Catch::toString(), Settings::unknownSkillsAutoTab, SkillModel::updateVisibilities(), Visible_false, 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(), EAthena::SkillRecv::processSkillUpdate2(), and setSkillDuration().

◆ addSkillDuration()

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

Definition at line 1386 of file skilldialog.cpp.

1387 {
1388  if (skill == nullptr)
1389  return;
1390 
1391  FOR_EACH (STD_VECTOR<SkillInfo*>::const_iterator, it, mDurations)
1392  {
1393  if ((*it)->id == skill->id)
1394  return;
1395  }
1396  mDurations.push_back(skill);
1397 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:25

References FOR_EACH, mDurations, and Actions::skill().

Referenced by setSkillDuration().

◆ clearSkills()

void SkillDialog::clearSkills ( )

Definition at line 331 of file skilldialog.cpp.

332 {
333  mTabs->removeAll(true);
334  mDeleteTabs.clear();
335  mDefaultTab = nullptr;
336  mDefaultModel = nullptr;
337 
339  mSkills.clear();
340  mDurations.clear();
341 }
void removeAll(const bool del)
Definition: tabbedarea.cpp:730
void delete_all(Container &c)
Definition: dtor.h:56

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

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

◆ getDefaultSkillIcon()

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

Definition at line 706 of file skilldialog.cpp.

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

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

Referenced by addSkill().

◆ getSkill()

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

Definition at line 803 of file skilldialog.cpp.

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

References mSkills.

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

◆ getSkillByItem()

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

Definition at line 811 of file skilldialog.cpp.

812 {
813  SkillMap::const_iterator it = mSkills.find(itemId - SKILL_MIN_ID);
814  if (it != mSkills.end())
815  return (*it).second;
816  return nullptr;
817 }

References mSkills, and SKILL_MIN_ID.

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

◆ getSkillData()

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

Definition at line 930 of file skilldialog.cpp.

931 {
932  const SkillMap::const_iterator it = mSkills.find(id);
933  if (it != mSkills.end())
934  {
935  SkillInfo *const info = it->second;
936  if (info != nullptr)
937  return info->data;
938  }
939  return nullptr;
940 }

References Actions::info(), and mSkills.

Referenced by playRemoveEffect(), and playUpdateEffect().

◆ getSkillDataByLevel()

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

Definition at line 942 of file skilldialog.cpp.

944 {
945  const SkillMap::const_iterator it = mSkills.find(id);
946  if (it != mSkills.end())
947  {
948  SkillInfo *const info = it->second;
949  if (info != nullptr)
950  return info->getData1(level);
951  }
952  return nullptr;
953 }

References Actions::info(), and mSkills.

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

◆ hasSkills()

bool SkillDialog::hasSkills ( ) const
inline

Definition at line 119 of file skilldialog.h.

120  { return !mSkills.empty(); }

References mSkills.

Referenced by WindowMenu::WindowMenu().

◆ hideSkills()

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

Definition at line 343 of file skilldialog.cpp.

344 {
345  FOR_EACH (SkillMap::iterator, it, mSkills)
346  {
347  SkillInfo *const info = (*it).second;
348  if ((info != nullptr) && info->owner == owner)
349  {
351  if (info->alwaysVisible == Visible_false)
352  info->visible = Visible_false;
353  }
354  }
355 }
void setSkillLevel(const int id, const int value)
Definition: playerinfo.cpp:128

References FOR_EACH, Actions::info(), mSkills, PlayerInfo::setSkillLevel(), and Visible_false.

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

◆ loadSkill()

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

Definition at line 496 of file skilldialog.cpp.

498 {
499  int id = XML::getIntProperty(node, "id", -1, -1, 1000000);
500  if (id == -1)
501  {
502  id = XML::getIntProperty(node, "var", -1, -1, 100000);
503  if (id == -1)
504  return nullptr;
505  id += SKILL_VAR_MIN_ID;
506  }
507 
508  SkillInfo *skill = getSkill(id);
509  if (skill == nullptr)
510  {
511  std::string name = XML::langProperty(node, "name",
512  // TRANSLATORS: skills dialog. skill id
513  strprintf(_("Skill %d"), id));
514 
515  skill = new SkillInfo;
516  skill->id = CAST_U32(id);
517  skill->modifiable = Modifiable_false;
518  skill->model = model;
519  skill->update();
520  skill->useButton = XML::getProperty(
521  // TRANSLATORS: skills dialog button
522  node, "useButton", _("Use"));
524  node, "owner", "player"));
525  skill->errorText = XML::getProperty(
526  node, "errorText", name);
527  skill->alwaysVisible = fromBool(XML::getBoolProperty(
528  node, "alwaysVisible", false), Visible);
529  skill->castingAction = XML::getProperty(node,
530  "castingAction", SpriteAction::CAST);
531  skill->castingRideAction = XML::getProperty(node,
532  "castingRideAction", SpriteAction::CASTRIDE);
533  skill->castingSkyAction = XML::getProperty(node,
534  "castingSkyAction", SpriteAction::CASTSKY);
535  skill->castingWaterAction = XML::getProperty(node,
536  "castingWaterAction", SpriteAction::CASTWATER);
537  skill->useTextParameter = XML::getBoolProperty(
538  node, "useTextParameter", false);
539  skill->x = XML::getProperty(node,
540  "x", 0);
541  skill->y = XML::getProperty(node,
542  "y", 0);
543  skill->visible = skill->alwaysVisible;
544  model->addSkill(skill);
545  mSkills[id] = skill;
546  }
547 
548  loadSkillData(node, skill);
549  return skill;
550 }
SkillInfo * getSkill(const int id) const
static void loadSkillData(const xmlNodePtr node, SkillInfo *const skill)
const bool Modifiable_false
Definition: modifiable.h:30
static const std::string CASTSKY("castsky")
static const std::string CASTWATER("castwater")
static const std::string CASTRIDE("castride")
static const std::string CAST("cast")
std::string langProperty(const xmlNodePtr node, const char *const name, const std::string &def)
Definition: libxml.cpp:258
bool getBoolProperty(const xmlNodePtr node, const char *const name, const bool def)
Definition: libxml.cpp:269
int getProperty(const xmlNodePtr node, const char *const name, int def)
Definition: libxml.cpp:174
int getIntProperty(const xmlNodePtr node, const char *const name, int def, const int min, const int max)
Definition: libxml.cpp:190
static SkillOwner::Type parseOwner(const std::string &str)
Definition: skilldialog.cpp:73
bool Visible
Definition: visible.h:30

References _, SkillModel::addSkill(), SpriteAction::CAST(), CAST_U32, SpriteAction::CASTRIDE(), SpriteAction::CASTSKY(), SpriteAction::CASTWATER(), fromBool, XML::getBoolProperty(), XML::getIntProperty(), XML::getProperty(), getSkill(), XML::langProperty(), loadSkillData(), Modifiable_false, mSkills, parseOwner(), Actions::skill(), SKILL_VAR_MIN_ID, and strprintf().

Referenced by loadXmlFile().

◆ loadSkillData()

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

Definition at line 552 of file skilldialog.cpp.

554 {
555  if (skill == nullptr)
556  return;
557  const int level = (skill->alwaysVisible == Visible_true) ?
558  0 : XML::getProperty(node, "level", 0);
559  SkillData *data = skill->getData(level);
560  if (data == nullptr)
561  data = new SkillData;
562 
563  const std::string name = XML::langProperty(node, "name",
564  // TRANSLATORS: skills dialog. skill id
565  strprintf(_("Skill %u"), skill->id));
566  data->name = name;
567  const std::string icon = XML::getProperty(node, "icon", "");
568  if (icon.empty())
569  {
570  data->setIcon(paths.getStringValue("missingSkillIcon"));
571  data->haveIcon = false;
572  }
573  else
574  {
575  data->setIcon(icon);
576  data->haveIcon = true;
577  }
578  if (skill->id < SKILL_VAR_MIN_ID)
579  {
580  data->dispName = strprintf("%s, %u",
581  name.c_str(),
582  skill->id);
583  }
584  else
585  {
586  data->dispName = strprintf("%s, (%u)",
587  name.c_str(),
588  skill->id - SKILL_VAR_MIN_ID);
589  }
590  data->shortName = XML::langProperty(node,
591  "shortName", name.substr(0, 3));
592  data->description = XML::langProperty(
593  node, "description", "");
594 
595  MissileInfo &missile = data->missile;
596  missile.particle = XML::getProperty(
597  node, "missile-particle", "");
598  missile.z = XML::getFloatProperty(
599  node, "missile-z", 32.0F);
600  missile.lifeTime = XML::getProperty(
601  node, "missile-lifetime", 500);
602  missile.speed = XML::getFloatProperty(
603  node, "missile-speed", 7.0F);
605  node, "missile-diedistance", 8.0F);
606 
607  MissileInfo &castingMissile = data->castingMissile;
608  castingMissile.particle = XML::getProperty(
609  node, "castingMissile-particle", "");
610  castingMissile.z = XML::getFloatProperty(
611  node, "castingMissile-z", 32.0F);
612  castingMissile.lifeTime = XML::getProperty(
613  node, "castingMissile-lifetime", 500);
614  castingMissile.speed = XML::getFloatProperty(
615  node, "castingMissile-speed", 7.0F);
616  castingMissile.dieDistance = XML::getFloatProperty(
617  node, "castingMissile-diedistance", 8.0F);
618 
619  data->castingAnimation = XML::getProperty(
620  node,
621  "castingAnimation",
622  paths.getStringValue("skillCastingAnimation"));
623 
624  data->soundHit.sound = XML::getProperty(
625  node, "soundHit", "");
626  data->soundHit.delay = XML::getProperty(
627  node, "soundHitDelay", 0);
628  data->soundMiss.sound = XML::getProperty(
629  node, "soundMiss", "");
630  data->soundMiss.delay = XML::getProperty(
631  node, "soundMissDelay", 0);
632  data->invokeCmd = XML::getProperty(
633  node, "invokeCmd", "");
634  data->updateEffectId = XML::getProperty(
635  node, "levelUpEffectId", -1);
636  data->removeEffectId = XML::getProperty(
637  node, "removeEffectId", -1);
638  data->hitEffectId = XML::getProperty(
639  node, "hitEffectId", -1);
640  data->missEffectId = XML::getProperty(
641  node, "missEffectId", -1);
642  data->castingSrcEffectId = XML::getProperty(
643  node, "castingSrcEffectId", -1);
644  data->castingDstEffectId = XML::getProperty(
645  node, "castingDstEffectId", -1);
646  data->srcEffectId = XML::getProperty(
647  node, "srcEffectId", -1);
648  data->dstEffectId = XML::getProperty(
649  node, "dstEffectId", -1);
650  data->castingGroundEffectId = XML::getProperty(
651  node, "castingGroundEffectId", -1);
652  data->autoTab = XML::getBoolProperty(
653  node, "autoTab", true);
654 
655  skill->addData(level, data);
656 }
float getFloatProperty(const xmlNodePtr node, const char *const name, float def)
Definition: libxml.cpp:211
std::string particle
Definition: missileinfo.h:41
float dieDistance
Definition: missileinfo.h:44
float speed
Definition: missileinfo.h:43

References _, data, MissileInfo::dieDistance, XML::getBoolProperty(), XML::getFloatProperty(), XML::getProperty(), Configuration::getStringValue(), XML::langProperty(), MissileInfo::lifeTime, MissileInfo::particle, paths, Actions::skill(), SKILL_VAR_MIN_ID, MissileInfo::speed, strprintf(), Visible_true, and MissileInfo::z.

Referenced by loadSkill(), and loadXmlFile().

◆ loadSkills()

void SkillDialog::loadSkills ( )

Definition at line 357 of file skilldialog.cpp.

358 {
359  clearSkills();
361  if (mSkills.empty())
363  loadXmlFile(paths.getStringValue("skillsPatchFile"), SkipError_true);
364  loadXmlDir("skillsPatchDir", loadXmlFile)
365  addDefaultTab();
366 
367  update();
368 }
#define loadXmlDir(name, function)
Definition: beingcommon.h:39
void addDefaultTab()
void loadXmlFile(const std::string &fileName, const SkipError skipError)
const bool SkipError_false
Definition: skiperror.h:30
const bool SkipError_true
Definition: skiperror.h:30

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

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

◆ loadXmlFile()

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

Definition at line 370 of file skilldialog.cpp.

372 {
375  skipError);
376  XmlNodePtrConst root = doc.rootNode();
377 
378  int setCount = 0;
379 
380  if ((root == nullptr) || !xmlNameEqual(root, "skills"))
381  {
382  logger->log("Error loading skills: " + fileName);
383  return;
384  }
385 
386  for_each_xml_child_node(set, root)
387  {
388  if (xmlNameEqual(set, "include"))
389  {
390  const std::string name = XML::getProperty(set, "name", "");
391  if (!name.empty())
392  loadXmlFile(name, skipError);
393  continue;
394  }
395  else if (xmlNameEqual(set, "set"))
396  {
397  setCount++;
398  const std::string setName = XML::getProperty(set, "name",
399  // TRANSLATORS: skills dialog default skill tab
400  strprintf(_("Skill Set %d"), setCount));
401 
402  const std::string setTypeStr = XML::getProperty(set, "type", "");
404  if (setTypeStr.empty() ||
405  setTypeStr == "list" ||
406  setTypeStr == "vertical")
407  {
408  setType = SkillSetType::VerticalList;
409  }
410  else if (setTypeStr == "rectangle")
411  {
412  setType = SkillSetType::Rectangle;
413  }
414 
415  bool alwaysVisible = false;
416  SkillModel *const model = new SkillModel;
417  SkillTab *tab = nullptr;
418  ScrollArea *scroll = nullptr;
419 
420  switch (setType)
421  {
423  {
424  // possible leak listbox, scroll
425  SkillListBox *const listbox = new SkillListBox(this,
426  model);
427  listbox->setActionEventId("sel");
428  listbox->addActionListener(this);
429  scroll = new ScrollArea(this,
430  listbox,
431  Opaque_false,
432  std::string());
435  tab = new SkillTab(this, setName, listbox);
436  break;
437  }
439  {
440  SkillRectangleListBox *const listbox =
441  new SkillRectangleListBox(this,
442  model);
443  listbox->setActionEventId("sel");
444  listbox->addActionListener(this);
445  scroll = new ScrollArea(this,
446  listbox,
447  Opaque_false,
448  std::string());
451  tab = new SkillTab(this, setName, listbox);
452  break;
453  }
454  default:
455  reportAlways("Unsupported skillset type: %s",
456  setTypeStr.c_str())
457  return;
458  }
459  if (mDefaultModel == nullptr)
460  {
461  mDefaultModel = model;
462  mDefaultTab = tab;
463  }
464 
465  mDeleteTabs.push_back(tab);
466  if (alwaysVisible == true)
467  tab->setVisible(Visible_true);
468  else
470  mTabs->addTab(tab, scroll);
471 
472  for_each_xml_child_node(node, set)
473  {
474  if (xmlNameEqual(node, "skill"))
475  {
476  SkillInfo *const skill = loadSkill(node, model);
477  if (skill == nullptr)
478  continue;
479  if (skill->alwaysVisible == Visible_true)
480  alwaysVisible = true;
481  skill->tab = tab;
482  for_each_xml_child_node(levelNode, node)
483  {
484  if (!xmlNameEqual(levelNode, "level"))
485  continue;
486  loadSkillData(node, skill);
487  }
488  }
489  }
490 
491  model->updateVisibilities();
492  }
493  }
494 }
#define reportAlways(...)
Definition: checkutils.h:253
void log(const char *const log_text,...)
Definition: logger.cpp:269
SkillInfo * loadSkill(const xmlNodePtr node, SkillModel *const model)
if(!vert) return
#define for_each_xml_child_node(var, parent)
Definition: libxml.h:161
Logger * logger
Definition: logger.cpp:89
SkillSetType ::T SkillSetTypeT
Definition: skillsettype.h:32
std::string fileName
Definition: testmain.cpp:39
const bool UseVirtFs_true
Definition: usevirtfs.h:30

References _, Widget::addActionListener(), TabbedArea::addTab(), fileName, for_each_xml_child_node, XML::getProperty(), loadSkill(), loadSkillData(), Logger::log(), logger, mDefaultModel, mDefaultTab, mDeleteTabs, 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(), SkillModel::updateVisibilities(), UseVirtFs_true, SkillSetType::VerticalList, Visible_false, and Visible_true.

Referenced by loadSkills().

◆ playCastingDstTileEffect()

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

Definition at line 979 of file skilldialog.cpp.

984 {
985  if (effectManager == nullptr)
986  return;
987  SkillData *const data = getSkillDataByLevel(id, level);
988  if (data == nullptr)
989  return;
990  effectManager->triggerDefault(data->castingGroundEffectId,
991  x * 32,
992  y * 32,
993  cur_time + delay / 1000, // end time in seconds
994  paths.getIntValue("skillCastingGroundEffectId"));
995 }
volatile time_t cur_time
Definition: timer.cpp:58
int getIntValue(const std::string &key) const
void triggerDefault(int effectId, Being *const being, const int defaultEffectId)
SkillData * getSkillDataByLevel(const int id, const int level) const
EffectManager * effectManager

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

Referenced by EAthena::BeingRecv::processSkillCastingContinue().

◆ playRemoveEffect()

void SkillDialog::playRemoveEffect ( const int  id) const

Definition at line 967 of file skilldialog.cpp.

968 {
969  if (effectManager == nullptr)
970  return;
971  const SkillData *const data = getSkillData(id);
972  if (data == nullptr)
973  return;
974  effectManager->triggerDefault(data->removeEffectId,
975  localPlayer,
976  paths.getIntValue("skillRemoveEffectId"));
977 }
SkillData * getSkillData(const int id) const
LocalPlayer * localPlayer

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

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

◆ playUpdateEffect()

void SkillDialog::playUpdateEffect ( const int  id) const

◆ postInit()

void SkillDialog::postInit ( )
virtual

Reimplemented from Window.

Definition at line 121 of file skilldialog.cpp.

122 {
125  loadWindowState();
126  enableVisibleSound(true);
127 }
Widget * getParent() const
Definition: widget.h:202
void postInit()
Definition: window.cpp:249
void enableVisibleSound(bool b)
Definition: window.h:481
void setLocationRelativeTo(const Widget *const widget)
Definition: window.cpp:509
void loadWindowState()
Definition: window.cpp:1087

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

◆ removeSkill()

void SkillDialog::removeSkill ( const int  id)

Definition at line 658 of file skilldialog.cpp.

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

References Actions::info(), mSkills, PlayerInfo::setSkillLevel(), and Visible_false.

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

◆ selectSkillCastType()

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

Definition at line 1439 of file skilldialog.cpp.

1441 {
1442  SkillInfo *const info = getSkill(skillId);
1443  if (info == nullptr)
1444  return;
1445  info->customCastType = type;
1446  info->update();
1447 }

References getSkill(), and Actions::info().

◆ selectSkillLevel()

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

Definition at line 1426 of file skilldialog.cpp.

1428 {
1429  SkillInfo *const info = getSkill(skillId);
1430  if (info == nullptr)
1431  return;
1432  if (level > info->level)
1433  info->customSelectedLevel = info->level;
1434  else
1435  info->customSelectedLevel = level;
1436  info->update();
1437 }

References getSkill(), and Actions::info().

◆ setSkillDuration()

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

Definition at line 819 of file skilldialog.cpp.

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

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

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

◆ setSkillOffsetX()

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

Definition at line 1449 of file skilldialog.cpp.

1451 {
1452  SkillInfo *const info = getSkill(skillId);
1453  if (info == nullptr)
1454  return;
1455  info->customOffsetX = offset;
1456  info->update();
1457 }

References getSkill(), and Actions::info().

◆ setSkillOffsetY()

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

Definition at line 1459 of file skilldialog.cpp.

1461 {
1462  SkillInfo *const info = getSkill(skillId);
1463  if (info == nullptr)
1464  return;
1465  info->customOffsetY = offset;
1466  info->update();
1467 }

References getSkill(), and Actions::info().

◆ slowLogic()

void SkillDialog::slowLogic ( )

Definition at line 1399 of file skilldialog.cpp.

1400 {
1401  FOR_EACH_SAFE (STD_VECTOR<SkillInfo*>::iterator, it, mDurations)
1402  {
1403  SkillInfo *const skill = *it;
1404  if (skill != nullptr)
1405  {
1406  const int time = get_elapsed_time(skill->durationTime);
1407  if (time >= skill->duration)
1408  {
1409  it = mDurations.erase(it);
1410  skill->cooldown = 0;
1411  skill->duration = 0;
1412  skill->durationTime = 0;
1413  if (it == mDurations.end())
1414  return;
1415  if (it != mDurations.begin())
1416  -- it;
1417  }
1418  else if (time != 0)
1419  {
1420  skill->cooldown = skill->duration * 100 / time;
1421  }
1422  }
1423  }
1424 }
#define FOR_EACH_SAFE(type, iter, array)
Definition: foreach.h:34
int get_elapsed_time(const int startTime)
Definition: timer.cpp:94

References FOR_EACH_SAFE, get_elapsed_time(), mDurations, and Actions::skill().

Referenced by Game::slowLogic().

◆ update() [1/2]

void SkillDialog::update ( )

Update other parts of the display

Definition at line 241 of file skilldialog.cpp.

242 {
243  // TRANSLATORS: skills dialog label
244  mPointsLabel->setCaption(strprintf(_("Skill points available: %d"),
247 
248  ItemShortcut *const shortcuts = itemShortcut[SHORTCUT_AUTO_TAB];
249  shortcuts->clear();
250  size_t idx = 0;
251 
252  FOR_EACH (SkillMap::const_iterator, it, mSkills)
253  {
254  SkillInfo *const info = (*it).second;
255  if (info == nullptr)
256  continue;
257  if (info->modifiable == Modifiable_true)
258  info->update();
259  if (info->visible == Visible_false ||
260  idx >= SHORTCUT_ITEMS ||
261  !info->data->autoTab)
262  {
263  continue;
264  }
265  const SkillType::SkillType type = info->type;
266  if (type == SkillType::Attack ||
267  type == SkillType::Ground ||
268  type == SkillType::Self ||
269  type == SkillType::Support)
270  {
271  shortcuts->setItemFast(idx,
272  info->id + SKILL_MIN_ID,
273  fromInt(info->customSelectedLevel, ItemColor));
274 
275  shortcuts->setItemData(idx,
276  info->toDataStr());
277  idx ++;
278  }
279  }
280 
281  skillPopup->reset();
282 }
void setItemFast(const size_t index, const int item, const ItemColor color)
void setItemData(const size_t index, const std::string &data)
Definition: itemshortcut.h:76
void adjustSize()
Definition: label.cpp:200
void setCaption(const std::string &caption)
Definition: label.cpp:264
void reset()
Definition: skillpopup.cpp:249
const size_t SHORTCUT_AUTO_TAB
Definition: itemshortcut.h:29
const unsigned int SHORTCUT_ITEMS
Definition: itemshortcut.h:27
#define fromInt(val, name)
Definition: intdefines.h:46
uint16_t ItemColor
Definition: itemcolor.h:30
const bool Modifiable_true
Definition: modifiable.h:30
@ PLAYER_SKILL_POINTS
Definition: attributes.h:48
int32_t getAttribute(const AttributesT id)
Definition: playerinfo.cpp:102
SkillPopup * skillPopup
Definition: skillpopup.cpp:42

References _, Label::adjustSize(), SkillType::Attack, ItemShortcut::clear(), FOR_EACH, fromInt, PlayerInfo::getAttribute(), SkillType::Ground, Actions::info(), itemShortcut, 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, and Visible_false.

Referenced by loadSkills().

◆ update() [2/2]

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

Update the given skill's display

Definition at line 224 of file skilldialog.cpp.

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

References Actions::info(), and mSkills.

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

◆ updateModels()

void SkillDialog::updateModels ( )

Definition at line 284 of file skilldialog.cpp.

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

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

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

◆ updateModelsHidden()

void SkillDialog::updateModelsHidden ( )

Definition at line 306 of file skilldialog.cpp.

307 {
308  std::set<SkillModel*> models;
309 
310  FOR_EACH (SkillMap::const_iterator, it, mSkills)
311  {
312  SkillInfo *const info = (*it).second;
313  if (info != nullptr)
314  {
315  if (info->visible == Visible_false)
316  {
317  SkillModel *const model = info->model;
318  if (model != nullptr)
319  models.insert(model);
320  }
321  }
322  }
323  FOR_EACH (std::set<SkillModel*>::iterator, it, models)
324  {
325  SkillModel *const model = *it;
326  if (model != nullptr)
327  model->updateVisibilities();
328  }
329 }

References FOR_EACH, Actions::info(), mSkills, SkillModel::updateVisibilities(), and Visible_false.

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

◆ updateQuest()

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

Definition at line 909 of file skilldialog.cpp.

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

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

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

◆ updateSkill()

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

Definition at line 676 of file skilldialog.cpp.

681 {
682  const SkillMap::const_iterator it = mSkills.find(id);
683 
684  if (it != mSkills.end())
685  {
686  SkillInfo *const info = it->second;
687  if (info != nullptr)
688  {
689  info->modifiable = modifiable;
690  info->range = range;
691  info->type = type;
692  info->sp = sp;
693  info->update();
694  if (info->tab != nullptr)
695  {
696  info->tab->setVisible(Visible_true);
699  }
700  }
701  return true;
702  }
703  return false;
704 }

References TabbedArea::adjustTabPositions(), Actions::info(), mSkills, mTabs, TabbedArea::setSelectedTabDefault(), 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().

◆ updateTabSelection()

void SkillDialog::updateTabSelection ( )

Definition at line 888 of file skilldialog.cpp.

889 {
890  const SkillTab *const tab = static_cast<SkillTab*>(
891  mTabs->getSelectedTab());
892  if (tab != nullptr)
893  {
894  if (const SkillInfo *const info = tab->getSelectedInfo())
895  {
896  mUseButton->setEnabled(info->range > 0);
898  mUseButton->setCaption(info->useButton);
899  }
900  else
901  {
902  mUseButton->setEnabled(false);
903  // TRANSLATORS: inventory button
904  mUseButton->setCaption(_("Use"));
905  }
906  }
907 }

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

Referenced by SkillTab::setCurrent().

◆ useItem()

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

Definition at line 850 of file skilldialog.cpp.

854 {
855  const std::map<int, SkillInfo*>::const_iterator
856  it = mSkills.find(itemId - SKILL_MIN_ID);
857  if (it == mSkills.end())
858  return;
859 
860  const SkillInfo *const info = (*it).second;
861  CastTypeT castType = CastType::Default;
862  int offsetX = 0;
863  int offsetY = 0;
864 
865  if (!data.empty())
866  {
867  STD_VECTOR<int> vect;
868  splitToIntVector(vect, data, ' ');
869  const size_t sz = vect.size();
870  if (sz > 0)
871  castType = static_cast<CastTypeT>(vect[0]);
872  if (sz > 2)
873  {
874  offsetX = vect[1];
875  offsetY = vect[2];
876  }
877  }
878  useSkill(info,
879  autoTarget,
880  level,
881  false,
882  std::string(),
883  castType,
884  offsetX,
885  offsetY);
886 }
CastType ::T CastTypeT
Definition: casttype.h:34
@ Default
Definition: casttype.h:29
void splitToIntVector(std::vector< int > &tokens, const std::string &text, const char separator)

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

Referenced by ItemShortcut::useItem().

◆ 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 997 of file skilldialog.cpp.

1005 {
1006  SkillInfo *const info = skillDialog->getSkill(skillId);
1007  if (info == nullptr)
1008  return;
1009  if (castType == CastType::Default)
1010  castType = info->customCastType;
1011  useSkill(info,
1012  autoTarget,
1013  level,
1014  withText,
1015  text,
1016  castType,
1017  offsetX,
1018  offsetY);
1019 }
SkillDialog * skillDialog
Definition: skilldialog.cpp:66

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

Referenced by action(), and useItem().

◆ 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 1021 of file skilldialog.cpp.

1029 {
1030  if ((info == nullptr) || (localPlayer == nullptr))
1031  return;
1032  if (level == 0)
1033  level = info->level;
1034 
1035  const SkillData *data = info->getData1(level);
1036  if (data != nullptr)
1037  {
1038  const std::string cmd = data->invokeCmd;
1039  if (!cmd.empty())
1041  }
1042  switch (castType)
1043  {
1044  default:
1045  case CastType::Default:
1047  autoTarget,
1048  level,
1049  withText,
1050  text,
1051  offsetX,
1052  offsetY);
1053  break;
1054  case CastType::Target:
1055  {
1056  const Being *const being = localPlayer->getTarget();
1058  autoTarget,
1059  level,
1060  withText,
1061  text,
1062  being,
1063  offsetX,
1064  offsetY);
1065  break;
1066  }
1067  case CastType::Position:
1068  {
1069  int x = 0;
1070  int y = 0;
1071  viewport->getMouseTile(x, y);
1073  level,
1074  withText,
1075  text,
1076  x,
1077  y,
1078  offsetX,
1079  offsetY);
1080  break;
1081  }
1082  case CastType::Self:
1083  // +++ probably need call useSkillSelf
1085  autoTarget,
1086  level,
1087  withText,
1088  text,
1089  localPlayer,
1090  offsetX,
1091  offsetY);
1092  break;
1093  }
1094 }
Definition: being.h:96
Being * getTarget() const
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 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 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 invokeCommand(const std::string &command, const Being *const target)
void getMouseTile(int &destX, int &destY) const
Definition: viewport.cpp:614
Viewport * viewport
Definition: viewport.cpp:36
@ Position
Definition: casttype.h:31
@ Target
Definition: casttype.h:30
@ Self
Definition: casttype.h:32

References data, CastType::Default, Viewport::getMouseTile(), LocalPlayer::getTarget(), Actions::info(), SpellManager::invokeCommand(), localPlayer, CastType::Position, CastType::Self, CastType::Target, useSkillDefault(), useSkillPosition(), useSkillTarget(), viewport, x, and y.

◆ 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 1284 of file skilldialog.cpp.

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

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

Referenced by useSkill().

◆ 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 1199 of file skilldialog.cpp.

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

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

Referenced by useSkill().

◆ 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 1096 of file skilldialog.cpp.

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

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

Referenced by useSkill().

◆ widgetResized()

void SkillDialog::widgetResized ( const Event event)
virtual

Called whenever the widget changes size.

Reimplemented from Window.

Definition at line 842 of file skilldialog.cpp.

843 {
844  Window::widgetResized(event);
845 
846  if (mTabs != nullptr)
847  mTabs->adjustSize();
848 }
void adjustSize()
Definition: tabbedarea.cpp:569
void widgetResized(const Event &event)
Definition: window.cpp:655

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

Field Documentation

◆ mDefaultModel

SkillModel* SkillDialog::mDefaultModel
private

Definition at line 234 of file skilldialog.h.

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

◆ mDefaultTab

SkillTab* SkillDialog::mDefaultTab
private

Definition at line 235 of file skilldialog.h.

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

◆ mDeleteTabs

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

Definition at line 230 of file skilldialog.h.

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

◆ mDurations

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

Definition at line 228 of file skilldialog.h.

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

◆ mIncreaseButton

Button* SkillDialog::mIncreaseButton
private

Definition at line 233 of file skilldialog.h.

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

◆ mPointsLabel

Label* SkillDialog::mPointsLabel
private

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

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


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