ManaPlus
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
OutfitWindow Class Reference

#include <outfitwindow.h>

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

Public Member Functions

 OutfitWindow ()
 
 ~OutfitWindow ()
 
void action (const ActionEvent &event)
 
void draw (Graphics *const graphics)
 
void safeDraw (Graphics *const graphics)
 
void mousePressed (MouseEvent &event)
 
void mouseDragged (MouseEvent &event)
 
void mouseReleased (MouseEvent &event)
 
void load ()
 
void wearOutfit (const int outfit, const bool unwearEmpty, const bool select)
 
void copyOutfit (const int outfit)
 
void copyOutfit (const int src, const int dst)
 
void copyFromEquiped ()
 
void copyFromEquiped (const int dst)
 
void unequipNotInOutfit (const int outfit) const
 
void next ()
 
void previous ()
 
void wearNextOutfit (const bool all)
 
void wearPreviousOutfit (const bool all)
 
void wearAwayOutfit ()
 
void unwearAwayOutfit ()
 
void showCurrentOutfit ()
 
void clearCurrentOutfit ()
 
std::string getOutfitString () const
 
- Public Member Functions inherited from Window
 Window (const std::string &caption, const Modal modal, Window *const parent, std::string skin)
 
 ~Window ()
 
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 widgetResized (const Event &event)
 
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)
 
void postInit ()
 
WindowgetParentWindow () const
 
virtual void scheduleDelete ()
 
void mouseMoved (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)
 

Static Public Member Functions

static std::string keyName (const int number)
 
- 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 Member Functions

int getIndexFromGrid (const int pointX, const int pointY) const
 
void save () const
 
- Private Member Functions inherited from ActionListener
virtual ~ActionListener ()
 
 ActionListener ()
 

Private Attributes

ButtonmPreviousButton
 
ButtonmNextButton
 
ButtonmEquipBottom
 
LabelmCurrentLabel
 
CheckBoxmUnequipCheck
 
CheckBoxmAwayOutfitCheck
 
LabelmKeyLabel
 
Color mBorderColor
 
int mCurrentOutfit
 
int mBoxWidth
 
int mBoxHeight
 
int mGridWidth
 
int mGridHeight
 
int mItems [OUTFITS_COUNT+1][OUTFIT_ITEM_COUNT]
 
int mAwayOutfit
 
ItemColor mItemColors [OUTFITS_COUNT+1][OUTFIT_ITEM_COUNT]
 
bool mItemClicked
 
bool mItemsUnequip [OUTFITS_COUNT]
 

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 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

Definition at line 40 of file outfitwindow.h.

Constructor & Destructor Documentation

◆ OutfitWindow()

OutfitWindow::OutfitWindow ( )

Constructor.

Definition at line 60 of file outfitwindow.cpp.

60  :
61  // TRANSLATORS: outfits window name
62  Window(_("Outfits"), Modal_false, nullptr, "outfits.xml"),
64  // TRANSLATORS: outfits window button
65  mPreviousButton(new Button(this, _("<"), "previous", BUTTON_SKIN, this)),
66  // TRANSLATORS: outfits window button
67  mNextButton(new Button(this, _(">"), "next", BUTTON_SKIN, this)),
68  // TRANSLATORS: outfits window button
69  mEquipBottom(new Button(this, _("Equip"), "equip", BUTTON_SKIN, this)),
70  // TRANSLATORS: outfits window label
71  mCurrentLabel(new Label(this, strprintf(_("Outfit: %d"), 1))),
72  // TRANSLATORS: outfits window checkbox
73  mUnequipCheck(new CheckBox(this, _("Unequip first"),
74  serverConfig.getValueBool("OutfitUnequip0", true),
75  nullptr, std::string())),
76  // TRANSLATORS: outfits window checkbox
77  mAwayOutfitCheck(new CheckBox(this, _("Away outfit"),
78  serverConfig.getValue("OutfitAwayIndex", OUTFITS_COUNT - 1) != 0U,
79  nullptr, std::string())),
80  // TRANSLATORS: outfits window label
81  mKeyLabel(new Label(this, strprintf(_("Key: %s"),
82  keyName(0).c_str()))),
83  mBorderColor(getThemeColor(ThemeColorId::BORDER, 64)),
84  mCurrentOutfit(0),
85  mBoxWidth(33),
86  mBoxHeight(33),
87  mGridWidth(4),
88  mGridHeight(4),
89  mItems(),
90  mAwayOutfit(0),
91  mItemColors(),
92  mItemClicked(false),
94 {
95  setWindowName("Outfits");
96  setResizable(true);
97  setCloseButton(true);
98  setStickyButtonLock(true);
99 
101 
102  setDefaultSize(250, 400, 150, 290);
103  setMinWidth(145);
104  setMinHeight(220);
105 
106  if (setupWindow != nullptr)
108 
111 
112  mUnequipCheck->setActionEventId("unequip");
114 
117 
118  place(1, 3, mEquipBottom, 2, 1);
119  place(0, 4, mKeyLabel, 4, 1);
120  place(0, 5, mPreviousButton, 1, 1);
121  place(1, 5, mCurrentLabel, 2, 1);
122  place(3, 5, mNextButton, 1, 1);
123  place(0, 6, mUnequipCheck, 4, 1);
124  place(0, 7, mAwayOutfitCheck, 4, 1);
125 
126  Layout &layout = getLayout();
127  layout.setRowHeight(0, LayoutType::SET);
128  layout.setColWidth(4, Layout::CENTER);
129 
130  loadWindowState();
131 
132  enableVisibleSound(true);
133  load();
134 }
const std::string BUTTON_SKIN
Definition: button.h:89
Definition: button.h:102
std::string getValue(const std::string &key, const std::string &deflt) const
bool getValueBool(const std::string &key, const bool deflt) const
@ CENTER
Definition: graphics.h:132
Definition: label.h:91
void setAlignment(Graphics::Alignment alignment)
Definition: label.h:153
void setRowHeight(const int n, const int h)
Definition: layoutcell.cpp:128
void setColWidth(const int n, const int w)
Definition: layoutcell.cpp:123
Definition: layout.h:45
static std::string keyName(const int number)
Label * mCurrentLabel
Definition: outfitwindow.h:112
ItemColor mItemColors[OUTFITS_COUNT+1][OUTFIT_ITEM_COUNT]
Definition: outfitwindow.h:128
CheckBox * mAwayOutfitCheck
Definition: outfitwindow.h:114
Color mBorderColor
Definition: outfitwindow.h:117
int mItems[OUTFITS_COUNT+1][OUTFIT_ITEM_COUNT]
Definition: outfitwindow.h:125
Button * mPreviousButton
Definition: outfitwindow.h:109
CheckBox * mUnequipCheck
Definition: outfitwindow.h:113
Button * mEquipBottom
Definition: outfitwindow.h:111
Label * mKeyLabel
Definition: outfitwindow.h:115
Button * mNextButton
Definition: outfitwindow.h:110
bool mItemsUnequip[OUTFITS_COUNT]
Definition: outfitwindow.h:130
void registerWindowForReset(Window *const window)
const Color & getThemeColor(const ThemeColorIdT type, const unsigned int alpha) const A_INLINE
Definition: widget2.h:45
Color mBackgroundColor
Definition: widget.h:1091
void setActionEventId(const std::string &actionEventId)
Definition: widget.h:596
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:252
void setResizable(const bool resize)
Definition: window.cpp:627
Layout & getLayout()
Definition: window.cpp:1365
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 setMinHeight(const int height)
Definition: window.cpp:604
void setMinWidth(const int width)
Definition: window.cpp:591
void enableVisibleSound(bool b)
Definition: window.h:481
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
void loadWindowState()
Definition: window.cpp:1087
Configuration serverConfig
#define _(s)
Definition: gettext.h:35
const bool Modal_false
Definition: modal.h:30
const unsigned int OUTFITS_COUNT
Definition: outfitwindow.h:33
SetupWindow * setupWindow
Definition: setupwindow.cpp:64
std::string strprintf(const char *const format,...)

References Widget::addActionListener(), LinkHighlightMode::BACKGROUND, LayoutCell::CENTER, Graphics::CENTER, Window::enableVisibleSound(), Window::getLayout(), Widget2::getThemeColor(), load(), Window::loadWindowState(), mAwayOutfitCheck, Widget::mBackgroundColor, mCurrentLabel, mEquipBottom, mKeyLabel, mNextButton, mPreviousButton, mUnequipCheck, Window::place(), SetupWindow::registerWindowForReset(), LayoutType::SET, Widget::setActionEventId(), Label::setAlignment(), Window::setCloseButton(), LayoutCell::setColWidth(), Window::setDefaultSize(), Window::setMinHeight(), Window::setMinWidth(), Window::setResizable(), LayoutCell::setRowHeight(), Window::setStickyButtonLock(), setupWindow, and Window::setWindowName().

◆ ~OutfitWindow()

OutfitWindow::~OutfitWindow ( )

Destructor.

Definition at line 136 of file outfitwindow.cpp.

137 {
138  save();
139 }
void save() const

References save().

Member Function Documentation

◆ action()

void OutfitWindow::action ( const ActionEvent actionEvent)
virtual

Called when an action is recieved from a widget. It is used to be able to recieve a notification that an action has occured.

Parameters
actionEventThe event of the action.

Implements ActionListener.

Definition at line 239 of file outfitwindow.cpp.

240 {
241  const std::string &eventId = event.getId();
242  if (eventId == "next")
243  {
244  next();
245  }
246  else if (eventId == "previous")
247  {
248  previous();
249  }
250  else if (eventId == "unequip")
251  {
252  if (mCurrentOutfit >= 0 && mCurrentOutfit < CAST_S32(
253  OUTFITS_COUNT))
254  {
256  }
257  }
258  else if (eventId == "equip")
259  {
261  true,
262  false);
263  if (Game::instance() != nullptr)
265  }
266  else if (eventId == "away")
267  {
271  }
272 }
#define CAST_S32
Definition: cast.h:30
void setSelected(const bool selected)
Definition: checkbox.h:156
bool isSelected() const
Definition: checkbox.h:147
static Game * instance()
Definition: game.h:82
void setValidSpeed()
Definition: game.cpp:1273
void wearOutfit(const int outfit, const bool unwearEmpty, const bool select)

References CAST_S32, Game::instance(), CheckBox::isSelected(), mAwayOutfit, mAwayOutfitCheck, mCurrentOutfit, mItemsUnequip, mUnequipCheck, next(), OUTFITS_COUNT, previous(), CheckBox::setSelected(), Game::setValidSpeed(), and wearOutfit().

◆ clearCurrentOutfit()

void OutfitWindow::clearCurrentOutfit ( )

Definition at line 726 of file outfitwindow.cpp.

727 {
728  if (mCurrentOutfit < 0 || mCurrentOutfit
729  >= static_cast<signed int>(OUTFITS_COUNT))
730  {
731  return;
732  }
733  for (unsigned f = 0; f < OUTFIT_ITEM_COUNT; f++)
734  {
735  mItems[mCurrentOutfit][f] = -1;
737  }
738  save();
739 }
const ItemColor ItemColor_one
Definition: itemcolor.h:30
const unsigned int OUTFIT_ITEM_COUNT
Definition: outfitwindow.h:34

References ItemColor_one, mCurrentOutfit, mItemColors, mItems, OUTFIT_ITEM_COUNT, OUTFITS_COUNT, and save().

◆ copyFromEquiped() [1/2]

void OutfitWindow::copyFromEquiped ( )

Definition at line 685 of file outfitwindow.cpp.

686 {
688 }
void copyFromEquiped()

References mCurrentOutfit.

Referenced by wearAwayOutfit().

◆ copyFromEquiped() [2/2]

void OutfitWindow::copyFromEquiped ( const int  dst)

Definition at line 690 of file outfitwindow.cpp.

691 {
692  const Inventory *const inventory = PlayerInfo::getInventory();
693  if (inventory == nullptr)
694  return;
695 
696  int outfitCell = 0;
697  for (unsigned i = 0, sz = inventory->getSize(); i < sz; i++)
698  {
699  const Item *const item = inventory->getItem(i);
700  if ((item != nullptr) && item->isEquipped() == Equipped_true)
701  {
702  mItems[dst][outfitCell] = item->getId();
703  mItemColors[dst][outfitCell++] = item->getColor();
704  if (outfitCell >= CAST_S32(OUTFIT_ITEM_COUNT))
705  break;
706  }
707  }
708  save();
709 }
Item * getItem(const int index) const
Definition: inventory.cpp:83
unsigned getSize() const
Definition: inventory.h:76
Definition: item.h:50
Equipped isEquipped() const
Definition: item.h:129
int getId() const
Definition: item.h:81
ItemColor getColor() const
Definition: item.h:181
const bool Equipped_true
Definition: equipped.h:30
Inventory * getInventory()
Definition: playerinfo.cpp:195

References CAST_S32, Equipped_true, Item::getColor(), Item::getId(), PlayerInfo::getInventory(), Inventory::getItem(), Inventory::getSize(), Item::isEquipped(), mItemColors, mItems, OUTFIT_ITEM_COUNT, and save().

◆ copyOutfit() [1/2]

void OutfitWindow::copyOutfit ( const int  outfit)

Definition at line 312 of file outfitwindow.cpp.

313 {
315 }
void copyOutfit(const int outfit)
bool outfit(InputEvent &event)
Definition: actions.cpp:32

References mCurrentOutfit, and Actions::outfit().

◆ copyOutfit() [2/2]

void OutfitWindow::copyOutfit ( const int  src,
const int  dst 
)

Definition at line 317 of file outfitwindow.cpp.

318 {
319  if (src < 0 || src > CAST_S32(OUTFITS_COUNT)
320  || dst < 0 || dst > CAST_S32(OUTFITS_COUNT))
321  {
322  return;
323  }
324 
325  for (unsigned int i = 0; i < OUTFIT_ITEM_COUNT; i++)
326  mItems[dst][i] = mItems[src][i];
327  save();
328 }

References CAST_S32, mItems, OUTFIT_ITEM_COUNT, OUTFITS_COUNT, and save().

◆ draw()

void OutfitWindow::draw ( Graphics *const  graphics)
virtual

Draws the window.

Reimplemented from Window.

Definition at line 330 of file outfitwindow.cpp.

331 {
332  BLOCK_START("OutfitWindow::draw")
333  Window::draw(graphics);
334 
336  >= static_cast<signed int>(OUTFITS_COUNT))
337  {
338  return;
339  }
340 
341  for (unsigned int i = 0; i < OUTFIT_ITEM_COUNT; i++)
342  {
343  const int itemX = mPadding + ((i % mGridWidth) * mBoxWidth);
344  const int itemY = mPadding + mTitleBarHeight
345  + ((i / CAST_U32(mGridWidth)) * mBoxHeight);
346 
347  graphics->setColor(mBorderColor);
348  graphics->drawRectangle(Rect(itemX, itemY, 32, 32));
349  graphics->setColor(mBackgroundColor);
350  graphics->fillRectangle(Rect(itemX, itemY, 32, 32));
351 
352  if (mItems[mCurrentOutfit][i] < 0)
353  continue;
354 
355  bool foundItem = false;
356  const Inventory *const inv = PlayerInfo::getInventory();
357  if (inv != nullptr)
358  {
359  const Item *const item = inv->findItem(mItems[mCurrentOutfit][i],
361  if (item != nullptr)
362  {
363  // Draw item icon.
364  const Image *const image = item->getImage();
365  if (image != nullptr)
366  {
367  graphics->drawImage(image, itemX, itemY);
368  foundItem = true;
369  }
370  }
371  }
372  if (!foundItem)
373  {
374  Image *const image = Item::getImage(mItems[mCurrentOutfit][i],
376  if (image != nullptr)
377  {
378  graphics->drawImage(image, itemX, itemY);
379  image->decRef();
380  }
381  }
382  }
383  BLOCK_END("OutfitWindow::draw")
384 }
#define CAST_U32
Definition: cast.h:31
virtual void drawImage(const Image *const image, int dstX, int dstY)=0
virtual void fillRectangle(const Rect &rectangle)=0
virtual void setColor(const Color &color)
Definition: graphics.h:320
virtual void drawRectangle(const Rect &rectangle)=0
Item * findItem(const int itemId, const ItemColor color) const
Definition: inventory.cpp:94
Image * getImage() const
Definition: item.h:87
void draw(Graphics *const graphics)
Definition: rect.h:74
Definition: window.h:102
unsigned int mTitleBarHeight
Definition: window.h:623
int mPadding
Definition: window.h:618
if(!vert) return
#define BLOCK_END(name)
Definition: perfomance.h:80
#define BLOCK_START(name)
Definition: perfomance.h:79

References BLOCK_END, BLOCK_START, CAST_U32, Window::draw(), Graphics::drawImage(), Graphics::drawRectangle(), Graphics::fillRectangle(), Inventory::findItem(), Item::getImage(), PlayerInfo::getInventory(), Widget::mBackgroundColor, mBorderColor, mBoxHeight, mBoxWidth, mCurrentOutfit, mGridWidth, mItemColors, mItems, Window::mPadding, Window::mTitleBarHeight, OUTFIT_ITEM_COUNT, OUTFITS_COUNT, and Graphics::setColor().

◆ getIndexFromGrid()

int OutfitWindow::getIndexFromGrid ( const int  pointX,
const int  pointY 
) const
private

Definition at line 556 of file outfitwindow.cpp.

557 {
558  const Rect tRect = Rect(mPadding, mTitleBarHeight,
560  if (!tRect.isPointInRect(pointX, pointY))
561  return -1;
562  const int index = (((pointY - mTitleBarHeight) / mBoxHeight) * mGridWidth)
563  + (pointX - mPadding) / mBoxWidth;
564  if (index >= CAST_S32(OUTFIT_ITEM_COUNT) || index < 0)
565  return -1;
566  return index;
567 }
bool isPointInRect(const int x_, const int y_) const
Definition: rect.h:197

References CAST_S32, Rect::isPointInRect(), mBoxHeight, mBoxWidth, mGridHeight, mGridWidth, Window::mPadding, Window::mTitleBarHeight, and OUTFIT_ITEM_COUNT.

Referenced by mouseDragged(), mousePressed(), and mouseReleased().

◆ getOutfitString()

std::string OutfitWindow::getOutfitString ( ) const

Definition at line 741 of file outfitwindow.cpp.

742 {
743  std::string str;
744  for (unsigned int i = 0; i < OUTFIT_ITEM_COUNT; i++)
745  {
746  const int id = mItems[mCurrentOutfit][i];
747  if (id < 0)
748  continue;
749 
750  const ItemColor color = mItemColors[mCurrentOutfit][i];
751  STD_VECTOR<int> ids;
752  ids.push_back(id);
753  ids.push_back(CAST_S32(color));
754 
755  const std::string name = ItemDB::getNamesStr(ids);
756  if (name.empty())
757  continue;
758  str.append("[");
759  str.append(name);
760  str.append("] ");
761  }
762  return str;
763 }
uint16_t ItemColor
Definition: itemcolor.h:30
std::string getNamesStr(const std::vector< int > &parts)
Definition: itemdb.cpp:1176

References CAST_S32, ItemDB::getNamesStr(), mCurrentOutfit, mItemColors, mItems, and OUTFIT_ITEM_COUNT.

◆ keyName()

std::string OutfitWindow::keyName ( const int  number)
static

Definition at line 598 of file outfitwindow.cpp.

599 {
600  if (number < 0 || number >= SHORTCUT_EMOTES)
601  return "";
603 }
std::string getKeyStringLong(const InputActionT index) const
static const int SHORTCUT_EMOTES
Definition: emoteshortcut.h:25
InputManager inputManager

References InputManager::getKeyStringLong(), inputManager, InputAction::OUTFIT_1, and SHORTCUT_EMOTES.

Referenced by EAthena::BeingRecv::processBeingSpawn(), EAthena::BeingRecv::processBeingVisible(), TmwAthena::BeingRecv::processBeingVisible(), LocalPlayer::setHome(), showCurrentOutfit(), and SocialNavigationTab::updateList().

◆ load()

void OutfitWindow::load ( )

Definition at line 141 of file outfitwindow.cpp.

142 {
143  const Configuration *cfg = &serverConfig;
144 
145  memset(mItems, -1, sizeof(mItems));
146  memset(mItemColors, 1, sizeof(mItemColors));
147 
148  for (unsigned o = 0; o < OUTFITS_COUNT; o++)
149  {
150  std::string outfit = cfg->getValue("Outfit" + toString(o), "-1");
151  std::string buf;
152  std::stringstream ss(outfit);
153 
154  STD_VECTOR<int> tokens;
155 
156  while (ss >> buf)
157  tokens.push_back(atoi(buf.c_str()));
158 
159  for (size_t i = 0, sz = tokens.size();
160  i < sz && i < OUTFIT_ITEM_COUNT; i++)
161  {
162  mItems[o][i] = tokens[i];
163  }
164 
165  outfit = cfg->getValue("OutfitColor" + toString(o), "1");
166  std::stringstream ss2(outfit);
167 
168  tokens.clear();
169 
170  STD_VECTOR<unsigned char> tokens2;
171  while (ss2 >> buf)
172  tokens2.push_back(CAST_U8(atoi(buf.c_str())));
173 
174  for (size_t i = 0, sz = tokens2.size();
175  i < sz && i < OUTFIT_ITEM_COUNT; i++)
176  {
177  mItemColors[o][i] = fromInt(tokens2[i], ItemColor);
178  }
179 
180  mItemsUnequip[o] = cfg->getValueBool("OutfitUnequip" + toString(o),
181  true);
182  }
183  mAwayOutfit = cfg->getValue("OutfitAwayIndex", OUTFITS_COUNT - 1);
186 
187  if (mAwayOutfitCheck != nullptr)
189 }
#define CAST_U8
Definition: cast.h:27
#define fromInt(val, name)
Definition: intdefines.h:46
std::string toString(T const &value)
converts any type to a string
Definition: catch.hpp:1774

References CAST_S32, CAST_U8, fromInt, ConfigurationObject::getValue(), ConfigurationObject::getValueBool(), mAwayOutfit, mAwayOutfitCheck, mCurrentOutfit, mItemColors, mItems, mItemsUnequip, Actions::outfit(), OUTFIT_ITEM_COUNT, OUTFITS_COUNT, serverConfig, CheckBox::setSelected(), and Catch::toString().

Referenced by OutfitWindow().

◆ mouseDragged()

void OutfitWindow::mouseDragged ( MouseEvent event)
virtual

Implements window resizing and makes sure the window is not dragged/resized outside of the screen.

Reimplemented from Window.

Definition at line 442 of file outfitwindow.cpp.

443 {
444  if (event.getButton() == MouseButton::LEFT)
445  {
446  if (dragDrop.isEmpty() && mItemClicked)
447  {
448  if (mCurrentOutfit < 0 || mCurrentOutfit
449  >= static_cast<signed int>(OUTFITS_COUNT))
450  {
451  Window::mouseDragged(event);
452  return;
453  }
454 
455  const int index = getIndexFromGrid(event.getX(), event.getY());
456  if (index == -1)
457  {
458  Window::mouseDragged(event);
459  return;
460  }
461  const int itemId = mItems[mCurrentOutfit][index];
462  const ItemColor itemColor = mItemColors[mCurrentOutfit][index];
463  if (itemId < 0)
464  {
465  Window::mouseDragged(event);
466  return;
467  }
468  mMoved = false;
469  event.consume();
470  const Inventory *const inv = PlayerInfo::getInventory();
471  if (inv != nullptr)
472  {
473  Item *const item = inv->findItem(itemId, itemColor);
474  if (item != nullptr)
476  else
477  dragDrop.clear();
478  mItems[mCurrentOutfit][index] = -1;
479  }
480  }
481  }
482  Window::mouseDragged(event);
483 }
void dragItem(const Item *const item, const DragDropSourceT source, const int tag)
Definition: dragdrop.h:87
bool isEmpty() const
Definition: dragdrop.h:196
void clear()
Definition: dragdrop.h:183
MouseButtonT getButton() const
Definition: mouseevent.h:116
int getX() const
Definition: mouseevent.h:127
int getY() const
Definition: mouseevent.h:138
int getIndexFromGrid(const int pointX, const int pointY) const
bool mMoved
Definition: window.h:647
void mouseDragged(MouseEvent &event)
Definition: window.cpp:982
DragDrop dragDrop

References DragDrop::clear(), dragDrop, DragDrop::dragItem(), Inventory::findItem(), MouseEvent::getButton(), getIndexFromGrid(), PlayerInfo::getInventory(), MouseEvent::getX(), MouseEvent::getY(), DragDrop::isEmpty(), MouseButton::LEFT, mCurrentOutfit, mItemClicked, mItemColors, mItems, Window::mMoved, Window::mouseDragged(), DragDropSource::Outfit, and OUTFITS_COUNT.

◆ mousePressed()

void OutfitWindow::mousePressed ( MouseEvent event)
virtual

Starts window resizing when appropriate.

Reimplemented from Window.

Definition at line 485 of file outfitwindow.cpp.

486 {
487  const int index = getIndexFromGrid(event.getX(), event.getY());
488  if (event.getButton() == MouseButton::RIGHT && (popupMenu != nullptr))
489  {
491  viewport->mMouseY);
492  event.consume();
493  return;
494  }
495  else if (index == -1)
496  {
497  Window::mousePressed(event);
498  return;
499  }
500  mMoved = false;
501  event.consume();
502 
503  if (mItems[mCurrentOutfit][index] > 0)
504  {
505  mItemClicked = true;
506  }
507  else
508  {
509  if (dragDrop.isSelected())
510  {
513  dragDrop.deselect();
514  save();
515  }
516  }
517 
518  Window::mousePressed(event);
519 }
ItemColor getSelectedColor() const
Definition: dragdrop.h:222
bool isSelected() const
Definition: dragdrop.h:225
void deselect()
Definition: dragdrop.h:213
int getSelected() const
Definition: dragdrop.h:219
void showOutfitsWindowPopup(const int x, const int y)
Definition: popupmenu.cpp:853
int mMouseX
Definition: viewport.h:154
int mMouseY
Definition: viewport.h:155
void mousePressed(MouseEvent &event)
Definition: window.cpp:836
Viewport * viewport
Definition: viewport.cpp:36
PopupMenu * popupMenu
Definition: popupmenu.cpp:103

References DragDrop::deselect(), dragDrop, MouseEvent::getButton(), getIndexFromGrid(), DragDrop::getSelected(), DragDrop::getSelectedColor(), MouseEvent::getX(), MouseEvent::getY(), DragDrop::isSelected(), mCurrentOutfit, mItemClicked, mItemColors, mItems, Viewport::mMouseX, Viewport::mMouseY, Window::mMoved, Window::mousePressed(), popupMenu, MouseButton::RIGHT, save(), PopupMenu::showOutfitsWindowPopup(), and viewport.

◆ mouseReleased()

void OutfitWindow::mouseReleased ( MouseEvent event)
virtual

When the mouse button has been let go, this ensures that the mouse custom cursor is restored back to it's standard image.

Reimplemented from Window.

Definition at line 521 of file outfitwindow.cpp.

522 {
523  if (event.getButton() == MouseButton::LEFT)
524  {
525  if (mCurrentOutfit < 0 || mCurrentOutfit
526  >= static_cast<signed int>(OUTFITS_COUNT))
527  {
528  return;
529  }
530  const int index = getIndexFromGrid(event.getX(), event.getY());
531  if (index == -1)
532  {
533  dragDrop.clear();
534  Window::mouseReleased(event);
535  return;
536  }
537  mMoved = false;
538  event.consume();
539  if (!dragDrop.isEmpty())
540  {
542  {
545  dragDrop.clear();
546  dragDrop.deselect();
547  save();
548  }
549  }
550  if (mItemClicked)
551  mItemClicked = false;
552  }
553  Window::mouseReleased(event);
554 }
bool isSourceItemContainer() const
Definition: dragdrop.h:241
int getItem() const
Definition: dragdrop.h:66
ItemColor getItemColor() const
Definition: dragdrop.h:69
void mouseReleased(MouseEvent &event)
Definition: window.cpp:907

References DragDrop::clear(), DragDrop::deselect(), dragDrop, MouseEvent::getButton(), getIndexFromGrid(), DragDrop::getItem(), DragDrop::getItemColor(), MouseEvent::getX(), MouseEvent::getY(), DragDrop::isEmpty(), DragDrop::isSourceItemContainer(), MouseButton::LEFT, mCurrentOutfit, mItemClicked, mItemColors, mItems, Window::mMoved, Window::mouseReleased(), OUTFITS_COUNT, and save().

◆ next()

void OutfitWindow::next ( )

Definition at line 605 of file outfitwindow.cpp.

606 {
608  mCurrentOutfit++;
609  else
610  mCurrentOutfit = 0;
612 }
void showCurrentOutfit()

References CAST_S32, mCurrentOutfit, OUTFITS_COUNT, and showCurrentOutfit().

Referenced by action(), and wearNextOutfit().

◆ previous()

void OutfitWindow::previous ( )

Definition at line 614 of file outfitwindow.cpp.

615 {
616  if (mCurrentOutfit > 0)
617  mCurrentOutfit--;
618  else
621 }

References mCurrentOutfit, OUTFITS_COUNT, and showCurrentOutfit().

Referenced by action(), and wearPreviousOutfit().

◆ safeDraw()

void OutfitWindow::safeDraw ( Graphics *const  graphics)
virtual

Reimplemented from Window.

Definition at line 386 of file outfitwindow.cpp.

387 {
388  BLOCK_START("OutfitWindow::draw")
389  Window::safeDraw(graphics);
390 
392  >= static_cast<signed int>(OUTFITS_COUNT))
393  {
394  return;
395  }
396 
397  for (unsigned int i = 0; i < OUTFIT_ITEM_COUNT; i++)
398  {
399  const int itemX = mPadding + ((i % mGridWidth) * mBoxWidth);
400  const int itemY = mPadding + mTitleBarHeight
401  + ((i / CAST_U32(mGridWidth)) * mBoxHeight);
402 
403  graphics->setColor(mBorderColor);
404  graphics->drawRectangle(Rect(itemX, itemY, 32, 32));
405  graphics->setColor(mBackgroundColor);
406  graphics->fillRectangle(Rect(itemX, itemY, 32, 32));
407 
408  if (mItems[mCurrentOutfit][i] < 0)
409  continue;
410 
411  bool foundItem = false;
412  const Inventory *const inv = PlayerInfo::getInventory();
413  if (inv != nullptr)
414  {
415  const Item *const item = inv->findItem(mItems[mCurrentOutfit][i],
417  if (item != nullptr)
418  {
419  // Draw item icon.
420  const Image *const image = item->getImage();
421  if (image != nullptr)
422  {
423  graphics->drawImage(image, itemX, itemY);
424  foundItem = true;
425  }
426  }
427  }
428  if (!foundItem)
429  {
430  Image *const image = Item::getImage(mItems[mCurrentOutfit][i],
432  if (image != nullptr)
433  {
434  graphics->drawImage(image, itemX, itemY);
435  image->decRef();
436  }
437  }
438  }
439  BLOCK_END("OutfitWindow::draw")
440 }
void safeDraw(Graphics *const graphics)

References BLOCK_END, BLOCK_START, CAST_U32, Graphics::drawImage(), Graphics::drawRectangle(), Graphics::fillRectangle(), Inventory::findItem(), Item::getImage(), PlayerInfo::getInventory(), Widget::mBackgroundColor, mBorderColor, mBoxHeight, mBoxWidth, mCurrentOutfit, mGridWidth, mItemColors, mItems, Window::mPadding, Window::mTitleBarHeight, OUTFIT_ITEM_COUNT, OUTFITS_COUNT, Window::safeDraw(), and Graphics::setColor().

◆ save()

void OutfitWindow::save ( ) const
private

Definition at line 191 of file outfitwindow.cpp.

192 {
193  std::string outfitStr;
194  std::string outfitColorsStr;
195  for (unsigned o = 0; o < OUTFITS_COUNT; o++)
196  {
197  bool good = false;
198  for (unsigned i = 0; i < OUTFIT_ITEM_COUNT; i++)
199  {
200  const int val = mItems[o][i];
201  const int res = val != 0 ? val : -1;
202  if (res != -1)
203  good = true;
204  outfitStr.append(toString(res));
205  if (i < OUTFIT_ITEM_COUNT - 1)
206  outfitStr.append(" ");
207  outfitColorsStr.append(toString(CAST_S32(
208  toInt(mItemColors[o][i], int))));
209  if (i < OUTFIT_ITEM_COUNT - 1)
210  outfitColorsStr.append(" ");
211  }
212  if (good)
213  {
214  serverConfig.setValue("Outfit" + toString(o), outfitStr);
215  serverConfig.setValue("OutfitColor" + toString(o),
216  outfitColorsStr);
217  }
218  else
219  {
220  serverConfig.deleteKey("Outfit" + toString(o));
221  serverConfig.deleteKey("OutfitColor" + toString(o));
222  }
223 
224  if (mItemsUnequip[o])
225  {
226  serverConfig.deleteKey("OutfitUnequip" + toString(o));
227  }
228  else
229  {
230  serverConfig.setValue("OutfitUnequip" + toString(o),
231  mItemsUnequip[o]);
232  }
233  outfitStr.clear();
234  outfitColorsStr.clear();
235  }
236  serverConfig.setValue("OutfitAwayIndex", mAwayOutfit);
237 }
void deleteKey(const std::string &key)
void setValue(const std::string &key, const std::string &value)
#define toInt(val, name)
Definition: intdefines.h:47

References CAST_S32, ConfigurationObject::deleteKey(), mAwayOutfit, mItemColors, mItems, mItemsUnequip, OUTFIT_ITEM_COUNT, OUTFITS_COUNT, serverConfig, Configuration::setValue(), toInt, and Catch::toString().

Referenced by clearCurrentOutfit(), copyFromEquiped(), copyOutfit(), mousePressed(), mouseReleased(), and ~OutfitWindow().

◆ showCurrentOutfit()

void OutfitWindow::showCurrentOutfit ( )

Definition at line 623 of file outfitwindow.cpp.

624 {
625  // TRANSLATORS: outfits window label
626  mCurrentLabel->setCaption(strprintf(_("Outfit: %d"), mCurrentOutfit + 1));
629  else
630  mUnequipCheck->setSelected(false);
631  // TRANSLATORS: outfits window label
632  mKeyLabel->setCaption(strprintf(_("Key: %s"),
633  keyName(mCurrentOutfit).c_str()));
635 }
void setCaption(const std::string &caption)
Definition: label.cpp:264

References _, CAST_S32, keyName(), mAwayOutfit, mAwayOutfitCheck, mCurrentLabel, mCurrentOutfit, mItemsUnequip, mKeyLabel, mUnequipCheck, OUTFITS_COUNT, Label::setCaption(), CheckBox::setSelected(), and strprintf().

Referenced by next(), previous(), and wearOutfit().

◆ unequipNotInOutfit()

void OutfitWindow::unequipNotInOutfit ( const int  outfit) const

Definition at line 569 of file outfitwindow.cpp.

570 {
571  // here we think that outfit is correct index
572 
573  const Inventory *const inventory = PlayerInfo::getInventory();
574  if (inventory == nullptr)
575  return;
576 
577  const unsigned int invSize = inventory->getSize();
578  for (unsigned i = 0; i < invSize; i++)
579  {
580  const Item *const item = inventory->getItem(i);
581  if ((item != nullptr) && item->isEquipped() == Equipped_true)
582  {
583  bool found = false;
584  for (unsigned f = 0; f < OUTFIT_ITEM_COUNT; f++)
585  {
586  if (item->getId() == mItems[outfit][f])
587  {
588  found = true;
589  break;
590  }
591  }
592  if (!found)
594  }
595  }
596 }
void unequipItem(const Item *const item, const Sfx sfx)
Definition: playerinfo.cpp:246
const bool Sfx_false
Definition: sfx.h:30

References Equipped_true, Item::getId(), PlayerInfo::getInventory(), Inventory::getItem(), Inventory::getSize(), Item::isEquipped(), mItems, Actions::outfit(), OUTFIT_ITEM_COUNT, Sfx_false, and PlayerInfo::unequipItem().

Referenced by wearOutfit().

◆ unwearAwayOutfit()

void OutfitWindow::unwearAwayOutfit ( )

Definition at line 719 of file outfitwindow.cpp.

720 {
722  true,
723  false);
724 }

References OUTFITS_COUNT, and wearOutfit().

Referenced by AwayListener::action().

◆ wearAwayOutfit()

void OutfitWindow::wearAwayOutfit ( )

Definition at line 711 of file outfitwindow.cpp.

712 {
715  false,
716  false);
717 }

References copyFromEquiped(), mAwayOutfit, OUTFITS_COUNT, and wearOutfit().

Referenced by GameModifiers::changeAwayMode().

◆ wearNextOutfit()

void OutfitWindow::wearNextOutfit ( const bool  all)

Definition at line 637 of file outfitwindow.cpp.

638 {
639  next();
640  if (!all && mCurrentOutfit >= 0 && mCurrentOutfit
642  {
643  bool fromStart = false;
644  while (!mItemsUnequip[mCurrentOutfit])
645  {
646  next();
647  if (mCurrentOutfit == 0)
648  {
649  if (!fromStart)
650  fromStart = true;
651  else
652  return;
653  }
654  }
655  }
657  true,
658  false);
659 }

References CAST_S32, mCurrentOutfit, mItemsUnequip, next(), OUTFITS_COUNT, and wearOutfit().

Referenced by CrazyMoves::crazyMoveAo().

◆ wearOutfit()

void OutfitWindow::wearOutfit ( const int  outfit,
const bool  unwearEmpty,
const bool  select 
)

Definition at line 274 of file outfitwindow.cpp.

277 {
278  bool isEmpty = true;
279 
280  if (outfit < 0 || outfit > CAST_S32(OUTFITS_COUNT))
281  return;
282 
283  for (unsigned i = 0; i < OUTFIT_ITEM_COUNT; i++)
284  {
285  const Item *const item = PlayerInfo::getInventory()->findItem(
286  mItems[outfit][i],
287  mItemColors[outfit][i]);
288  if ((item != nullptr)
289  && item->isEquipped() == Equipped_false
290  && (item->getQuantity() != 0))
291  {
292  if (item->isEquipment() == Equipm_true)
293  {
295  isEmpty = false;
296  }
297  }
298  }
299 
300  if ((!isEmpty || unwearEmpty) && outfit < CAST_S32(OUTFITS_COUNT)
301  && mItemsUnequip[outfit])
302  {
304  }
305  if (select)
306  {
309  }
310 }
Equipm isEquipment() const
Definition: item.h:117
int getQuantity() const
Definition: item.h:105
void unequipNotInOutfit(const int outfit) const
const bool Equipm_true
Definition: equipm.h:30
const bool Equipped_false
Definition: equipped.h:30
void equipItem(const Item *const item, const Sfx sfx)
Definition: playerinfo.cpp:238

References CAST_S32, PlayerInfo::equipItem(), Equipm_true, Equipped_false, Inventory::findItem(), PlayerInfo::getInventory(), Item::getQuantity(), Item::isEquipment(), Item::isEquipped(), mCurrentOutfit, mItemColors, mItems, mItemsUnequip, Actions::outfit(), OUTFIT_ITEM_COUNT, OUTFITS_COUNT, Sfx_false, showCurrentOutfit(), and unequipNotInOutfit().

Referenced by action(), unwearAwayOutfit(), wearAwayOutfit(), wearNextOutfit(), and wearPreviousOutfit().

◆ wearPreviousOutfit()

void OutfitWindow::wearPreviousOutfit ( const bool  all)

Definition at line 661 of file outfitwindow.cpp.

662 {
663  previous();
664  if (!all && mCurrentOutfit >= 0 && mCurrentOutfit
666  {
667  bool fromStart = false;
668  while (!mItemsUnequip[mCurrentOutfit])
669  {
670  previous();
671  if (mCurrentOutfit == 0)
672  {
673  if (!fromStart)
674  fromStart = true;
675  else
676  return;
677  }
678  }
679  }
681  true,
682  false);
683 }

References CAST_S32, mCurrentOutfit, mItemsUnequip, OUTFITS_COUNT, previous(), and wearOutfit().

Referenced by CrazyMoves::crazyMoveAo().

Field Documentation

◆ mAwayOutfit

int OutfitWindow::mAwayOutfit
private

Definition at line 126 of file outfitwindow.h.

Referenced by action(), load(), save(), showCurrentOutfit(), and wearAwayOutfit().

◆ mAwayOutfitCheck

CheckBox* OutfitWindow::mAwayOutfitCheck
private

Definition at line 114 of file outfitwindow.h.

Referenced by action(), load(), OutfitWindow(), and showCurrentOutfit().

◆ mBorderColor

Color OutfitWindow::mBorderColor
private

Definition at line 117 of file outfitwindow.h.

Referenced by draw(), and safeDraw().

◆ mBoxHeight

int OutfitWindow::mBoxHeight
private

Definition at line 121 of file outfitwindow.h.

Referenced by draw(), getIndexFromGrid(), and safeDraw().

◆ mBoxWidth

int OutfitWindow::mBoxWidth
private

Definition at line 120 of file outfitwindow.h.

Referenced by draw(), getIndexFromGrid(), and safeDraw().

◆ mCurrentLabel

Label* OutfitWindow::mCurrentLabel
private

Definition at line 112 of file outfitwindow.h.

Referenced by OutfitWindow(), and showCurrentOutfit().

◆ mCurrentOutfit

int OutfitWindow::mCurrentOutfit
private

◆ mEquipBottom

Button* OutfitWindow::mEquipBottom
private

Definition at line 111 of file outfitwindow.h.

Referenced by OutfitWindow().

◆ mGridHeight

int OutfitWindow::mGridHeight
private

Definition at line 123 of file outfitwindow.h.

Referenced by getIndexFromGrid().

◆ mGridWidth

int OutfitWindow::mGridWidth
private

Definition at line 122 of file outfitwindow.h.

Referenced by draw(), getIndexFromGrid(), and safeDraw().

◆ mItemClicked

bool OutfitWindow::mItemClicked
private

Definition at line 129 of file outfitwindow.h.

Referenced by mouseDragged(), mousePressed(), and mouseReleased().

◆ mItemColors

ItemColor OutfitWindow::mItemColors[OUTFITS_COUNT+1][OUTFIT_ITEM_COUNT]
private

◆ mItems

int OutfitWindow::mItems[OUTFITS_COUNT+1][OUTFIT_ITEM_COUNT]
private

◆ mItemsUnequip

bool OutfitWindow::mItemsUnequip[OUTFITS_COUNT]
private

◆ mKeyLabel

Label* OutfitWindow::mKeyLabel
private

Definition at line 115 of file outfitwindow.h.

Referenced by OutfitWindow(), and showCurrentOutfit().

◆ mNextButton

Button* OutfitWindow::mNextButton
private

Definition at line 110 of file outfitwindow.h.

Referenced by OutfitWindow().

◆ mPreviousButton

Button* OutfitWindow::mPreviousButton
private

Definition at line 109 of file outfitwindow.h.

Referenced by OutfitWindow().

◆ mUnequipCheck

CheckBox* OutfitWindow::mUnequipCheck
private

Definition at line 113 of file outfitwindow.h.

Referenced by action(), OutfitWindow(), and showCurrentOutfit().


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