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

#include <buydialog.h>

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

Public Types

enum  {
  Nick = -1 , Items = -2 , Market = -3 , Cash = -4 ,
  Vending = -5
}
 

Public Member Functions

 BuyDialog ()
 
 BuyDialog (const BeingId npcId, const std::string &currency)
 
 BuyDialog (const std::string &nick, const std::string &currency)
 
 BuyDialog (const Being *const being, const std::string &currency)
 
 ~BuyDialog ()
 
void init ()
 
void reset ()
 
void setMoney (const int amount)
 
ShopItemaddItem (const int id, const ItemTypeT type, const ItemColor color, const int amount, const int price)
 
void action (const ActionEvent &event)
 
int getNumberOfElements ()
 
void valueChanged (const SelectionEvent &event)
 
void updateButtonsAndLabels ()
 
void setVisible (Visible visible)
 
void sort ()
 
void close ()
 
- 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 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
 
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 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 ()
 
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 ()
 
- Public Member Functions inherited from SelectionListener
virtual ~SelectionListener ()
 

Static Public Member Functions

static bool isActive ()
 
static void closeAll ()
 
- 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::list< BuyDialog * > DialogList
 

Private Member Functions

void updateSlider (const int selectedItem)
 
void applyNameFilter (const std::string &filter)
 

Private Attributes

ButtonmBuyButton
 
ButtonmConfirmButton
 
ButtonmQuitButton
 
ButtonmAddMaxButton
 
ButtonmIncreaseButton
 
ButtonmDecreaseButton
 
ShopListBoxmShopItemList
 
ScrollAreamScrollArea
 
LabelmMoneyLabel
 
LabelmQuantityLabel
 
SlidermSlider
 
LabelmAmountLabel
 
IntTextFieldmAmountField
 
ShopItemsmShopItems
 
SortListModelBuymSortModel
 
DropDownmSortDropDown
 
TextFieldmFilterTextField
 
LabelmFilterLabel
 
std::string mNick
 
std::string mCurrency
 
BeingId mNpcId
 
int mMoney
 
int mAmountItems
 
int mMaxItems
 
bool mAdvanced
 

Static Private Attributes

static DialogList instances
 

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 Member Functions inherited from SelectionListener
 SelectionListener ()
 
- 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 buy dialog.

Definition at line 55 of file buydialog.h.

Member Typedef Documentation

◆ DialogList

typedef std::list<BuyDialog*> BuyDialog::DialogList
private

Definition at line 177 of file buydialog.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
Nick 
Items 
Market 
Cash 
Vending 

Definition at line 100 of file buydialog.h.

101  {
102 #ifdef TMWA_SUPPORT
103  Nick = -1,
104 #endif // TMWA_SUPPORT
105  Items = -2,
106  Market = -3,
107  Cash = -4,
108  Vending = -5
109  };

Constructor & Destructor Documentation

◆ BuyDialog() [1/4]

BuyDialog::BuyDialog ( )

Constructor.

See also
Window::Window

Definition at line 190 of file buydialog.cpp.

190  :
191  // TRANSLATORS: buy dialog name
192  Window(_("Create items"), Modal_false, nullptr, "buy.xml"),
193  ActionListener(),
196  mSortDropDown(new DropDown(this, mSortModel, false,
197  Modal_false, this, "sort")),
199  this, "namefilter", true)),
200  mFilterLabel(nullptr),
201  mNick(),
202  mCurrency(),
204  mMoney(0),
205  mAmountItems(0),
206  mMaxItems(0),
207  mAdvanced(false)
208 {
209  init();
210 }
int BeingId
Definition: beingid.h:30
std::string mCurrency
Definition: buydialog.h:200
int mMaxItems
Definition: buydialog.h:204
int mAmountItems
Definition: buydialog.h:203
BeingId mNpcId
Definition: buydialog.h:201
int mMoney
Definition: buydialog.h:202
Label * mFilterLabel
Definition: buydialog.h:197
void init()
Definition: buydialog.cpp:282
SortListModelBuy * mSortModel
Definition: buydialog.h:194
TextField * mFilterTextField
Definition: buydialog.h:196
bool mAdvanced
Definition: buydialog.h:205
std::string mNick
Definition: buydialog.h:199
DropDown * mSortDropDown
Definition: buydialog.h:195
Window(const std::string &caption, const Modal modal, Window *const parent, std::string skin)
Definition: window.cpp:109
#define _(s)
Definition: gettext.h:35
#define fromInt(val, name)
Definition: intdefines.h:46
const bool LoseFocusOnTab_true
const bool Modal_false
Definition: modal.h:30

References init().

◆ BuyDialog() [2/4]

BuyDialog::BuyDialog ( const BeingId  npcId,
const std::string &  currency 
)

Constructor.

See also
Window::Window

Definition at line 212 of file buydialog.cpp.

213  :
214  // TRANSLATORS: buy dialog name
215  Window(_("Buy"), Modal_false, nullptr, "buy.xml"),
216  ActionListener(),
218  mSortModel(nullptr),
219  mSortDropDown(nullptr),
221  this, "namefilter", true)),
222  mFilterLabel(nullptr),
223  mNick(),
224  mCurrency(currency),
225  mNpcId(npcId),
226  mMoney(0),
227  mAmountItems(0),
228  mMaxItems(0),
230 {
231  init();
232 }
ServerTypeT getNetworkType()
Definition: net.cpp:189

References init().

◆ BuyDialog() [3/4]

BuyDialog::BuyDialog ( const std::string &  nick,
const std::string &  currency 
)

Constructor.

See also
Window::Window

Definition at line 235 of file buydialog.cpp.

236  :
237  // TRANSLATORS: buy dialog name
238  Window(_("Buy"), Modal_false, nullptr, "buy.xml"),
239  ActionListener(),
242  mSortDropDown(new DropDown(this, mSortModel, false,
243  Modal_false, this, "sort")),
245  this, "namefilter", true)),
246  mFilterLabel(nullptr),
247  mNick(nick),
248  mCurrency(currency),
250  mMoney(0),
251  mAmountItems(0),
252  mMaxItems(0),
253  mAdvanced(false)
254 {
255  init();
256 }

References init().

◆ BuyDialog() [4/4]

BuyDialog::BuyDialog ( const Being *const  being,
const std::string &  currency 
)

Constructor.

See also
Window::Window

Definition at line 259 of file buydialog.cpp.

260  :
261  // TRANSLATORS: buy dialog name
262  Window(_("Buy"), Modal_false, nullptr, "buy.xml"),
263  ActionListener(),
266  mSortDropDown(new DropDown(this, mSortModel, false,
267  Modal_false, this, "sort")),
269  this, "namefilter", true)),
270  mFilterLabel(nullptr),
271  mNick(being != nullptr ? being->getName() : std::string()),
272  mCurrency(currency),
274  mMoney(0),
275  mAmountItems(0),
276  mMaxItems(0),
277  mAdvanced(true)
278 {
279  init();
280 }
const std::string & getName() const
Definition: being.h:232

References init().

◆ ~BuyDialog()

BuyDialog::~BuyDialog ( )

Destructor

Definition at line 428 of file buydialog.cpp.

429 {
432  instances.remove(this);
433  if (buySellHandler != nullptr)
435 }
Net::BuySellHandler * buySellHandler
Definition: net.cpp:100
static DialogList instances
Definition: buydialog.h:178
ShopItems * mShopItems
Definition: buydialog.h:193
virtual void cleanDialogReference(const BuyDialog *const dialog) const =0
#define delete2(var)
Definition: delete2.h:25

References buySellHandler, Net::BuySellHandler::cleanDialogReference(), delete2, instances, mShopItems, and mSortModel.

Member Function Documentation

◆ action()

void BuyDialog::action ( const ActionEvent event)
virtual

Called when receiving actions from the widgets.

Implements ActionListener.

Definition at line 529 of file buydialog.cpp.

530 {
531  const std::string &eventId = event.getId();
532  if (eventId == "quit")
533  {
534  close();
535  return;
536  }
537  else if (eventId == "sort")
538  {
539  sort();
540  if (mSortDropDown != nullptr)
541  config.setValue("buySortOrder", mSortDropDown->getSelected());
542  return;
543  }
544  else if (eventId == "namefilter")
545  {
547  }
548 
549  const int selectedItem = mShopItemList->getSelected();
550 
551  // The following actions require a valid selection
552  if (selectedItem < 0 || selectedItem >= mShopItems->getNumberOfElements())
553  return;
554 
555  if (eventId == "slider")
556  {
560  }
561  else if (eventId == "inc" && mAmountItems < mMaxItems)
562  {
563  mAmountItems++;
567  }
568  else if (eventId == "dec" && mAmountItems > 1)
569  {
570  mAmountItems--;
574  }
575  else if (eventId == "max")
576  {
581  }
582  else if (eventId == "amount")
583  {
587  }
588  else if (eventId == "buy" && mAmountItems > 0 && mAmountItems <= mMaxItems)
589  {
590  ShopItem *const item = mShopItems->at(selectedItem);
591  if (item == nullptr)
592  return;
593  if (mNpcId == fromInt(Items, BeingId))
594  {
595  adminHandler->createItems(item->getId(),
596  item->getColor(),
597  mAmountItems);
598  }
599 #ifdef TMWA_SUPPORT
600  else if (mNpcId == fromInt(Nick, BeingId))
601  {
602  if (tradeWindow != nullptr)
603  {
605  item, mAmountItems);
607  item->getPrice() * mAmountItems);
608  }
609  }
610 #endif // TMWA_SUPPORT
611  else if (mNpcId == fromInt(Vending, BeingId))
612  {
614  item->update();
615  if (mConfirmButton != nullptr)
616  mConfirmButton->setEnabled(true);
617  }
618 #ifdef TMWA_SUPPORT
619  else if (mNpcId != fromInt(Nick, BeingId))
620 #else
621  else
622 #endif // TMWA_SUPPORT
623  {
624  if (mAdvanced)
625  {
627  item->update();
628  if (mConfirmButton != nullptr)
629  mConfirmButton->setEnabled(true);
630  }
631  else if (mNpcId == fromInt(Market, BeingId))
632  {
633  marketHandler->buyItem(item->getId(),
634  item->getType(),
635  item->getColor(),
636  mAmountItems);
638  item->update();
639  }
640  else if (mNpcId == fromInt(Cash, BeingId))
641  {
643  item->getId(),
644  item->getColor(),
645  mAmountItems);
646  }
647  else
648  {
650  item->getId(),
651  item->getColor(),
652  mAmountItems);
653  }
654 
655  updateSlider(selectedItem);
656  }
657  }
658  else if (eventId == "confirm")
659  {
660  STD_VECTOR<ShopItem*> &items = mShopItems->allItems();
661 
662  if (mNpcId == fromInt(Market, BeingId))
663  {
664  marketHandler->buyItems(items);
665  }
666  else if (mNpcId == fromInt(Vending, BeingId))
667  {
668  const Being *const being = actorManager->findBeingByName(
669  mNick,
671  if (being != nullptr)
672  {
673  vendingHandler->buyItems(being,
674  items);
675  }
676  }
677  else if (mNpcId == fromInt(Cash, BeingId))
678  {
679  cashShopHandler->buyItems(0, items);
680  }
681  else
682  {
683  npcHandler->buyItems(items);
684  }
685  close();
686  }
687 }
ActorManager * actorManager
Net::AdminHandler * adminHandler
Definition: net.cpp:84
Net::CashShopHandler * cashShopHandler
Definition: net.cpp:108
#define CAST_S32
Definition: cast.h:30
Being * findBeingByName(const std::string &name, const ActorTypeT type) const
Definition: being.h:96
IntTextField * mAmountField
Definition: buydialog.h:192
void applyNameFilter(const std::string &filter)
Definition: buydialog.cpp:793
void updateSlider(const int selectedItem)
Definition: buydialog.cpp:689
void sort()
Definition: buydialog.cpp:472
Slider * mSlider
Definition: buydialog.h:190
void close()
Definition: buydialog.cpp:504
void updateButtonsAndLabels()
Definition: buydialog.cpp:718
ShopListBox * mShopItemList
Definition: buydialog.h:186
Button * mConfirmButton
Definition: buydialog.h:181
void setValue(const std::string &key, const std::string &value)
int getSelected() const
Definition: dropdown.cpp:509
void setValue(const int value)
int getValue() const
int getId() const
Definition: item.h:81
ItemColor getColor() const
Definition: item.h:181
ItemTypeT getType() const
Definition: item.h:225
void increaseQuantity(const int amount)
Definition: item.h:99
int getSelected() const
Definition: listbox.h:168
virtual void createItems(const int id, const ItemColor color, const int amount) const =0
virtual void sendBuyRequest(const std::string &nick, const ShopItem *const item, const int amount) const =0
virtual void buyItem(const int points, const int itemId, const ItemColor color, const int amount) const =0
virtual void buyItems(const int points, const std::vector< ShopItem * > &items) const =0
virtual void buyItems(const std::vector< ShopItem * > &items) const =0
virtual void buyItem(const int itemId, const ItemTypeT type, const ItemColor color, const int amount) const =0
virtual void buyItems(std::vector< ShopItem * > &items) const =0
virtual void buyItem(const BeingId beingId, const int itemId, const ItemColor color, const int amount) const =0
virtual void buyItems(const Being *const being, const std::vector< ShopItem * > &items) const =0
void increaseUsedQuantity(const int amount)
Definition: shopitem.cpp:159
void update()
Definition: shopitem.cpp:119
int getPrice() const
Definition: shopitem.h:132
std::vector< ShopItem * > & allItems()
Definition: shopitems.h:139
int getNumberOfElements()
Definition: shopitems.h:99
ShopItem * at(const size_t i) const
Definition: shopitems.cpp:129
double getValue() const
Definition: slider.h:204
void setValue(const double value)
Definition: slider.cpp:474
const std::string & getText() const
Definition: textfield.h:224
void addAutoMoney(const std::string &nick, const int money)
void setEnabled(const bool enabled)
Definition: widget.h:352
Configuration config
Net::MarketHandler * marketHandler
Definition: net.cpp:116
Net::VendingHandler * vendingHandler
Definition: net.cpp:122
Net::NpcHandler * npcHandler
Definition: net.cpp:93
TradeWindow * tradeWindow
Definition: tradewindow.cpp:65

References actorManager, TradeWindow::addAutoMoney(), adminHandler, ShopItems::allItems(), applyNameFilter(), ShopItems::at(), Net::NpcHandler::buyItem(), Net::MarketHandler::buyItem(), Net::CashShopHandler::buyItem(), Net::VendingHandler::buyItems(), Net::CashShopHandler::buyItems(), Net::MarketHandler::buyItems(), Net::NpcHandler::buyItems(), buySellHandler, Cash, cashShopHandler, CAST_S32, close(), config, Net::AdminHandler::createItems(), ActorManager::findBeingByName(), fromInt, Item::getColor(), Item::getId(), ShopItems::getNumberOfElements(), ShopItem::getPrice(), DropDown::getSelected(), ListBox::getSelected(), TextField::getText(), Item::getType(), IntTextField::getValue(), Slider::getValue(), Item::increaseQuantity(), ShopItem::increaseUsedQuantity(), Items, mAdvanced, mAmountField, mAmountItems, Market, marketHandler, mConfirmButton, mFilterTextField, mMaxItems, mNick, mNpcId, mShopItemList, mShopItems, mSlider, mSortDropDown, Nick, npcHandler, ActorType::Player, Net::BuySellHandler::sendBuyRequest(), Widget::setEnabled(), Slider::setValue(), IntTextField::setValue(), Configuration::setValue(), sort(), tradeWindow, ShopItem::update(), updateButtonsAndLabels(), updateSlider(), Vending, and vendingHandler.

◆ addItem()

ShopItem * BuyDialog::addItem ( const int  id,
const ItemTypeT  type,
const ItemColor  color,
const int  amount,
const int  price 
)

Adds an item to the shop inventory.

Definition at line 457 of file buydialog.cpp.

462 {
463  ShopItem *const item = mShopItems->addItem(id,
464  type,
465  color,
466  amount,
467  price);
469  return item;
470 }
ShopItem * addItem(const int id, const ItemTypeT type, const ItemColor color, const int amount, const int price)
Definition: shopitems.cpp:59
void adjustSize()

References ShopItems::addItem(), ShopListBox::adjustSize(), mShopItemList, and mShopItems.

Referenced by EAthena::CashShopRecv::processCashShopOpen(), EAthena::VendingRecv::processItemsList(), EAthena::MarketRecv::processMarketOpen(), EAthena::BuySellRecv::processNpcBuy(), TmwAthena::BuySellRecv::processNpcBuy(), and ShopWindow::showList().

◆ applyNameFilter()

void BuyDialog::applyNameFilter ( const std::string &  filter)
private

Definition at line 793 of file buydialog.cpp.

794 {
795  STD_VECTOR<ShopItem*> &items = mShopItems->allItems();
796  std::string filterStr = filter;
797  toLower(filterStr);
798  FOR_EACH (STD_VECTOR<ShopItem*>::iterator, it, items)
799  {
800  ShopItem *const item = *it;
801  if (item == nullptr)
802  continue;
803  std::string name = item->getName();
804  toLower(name);
805  if (name.find(filterStr) != std::string::npos)
806  item->setVisible(true);
807  else
808  item->setVisible(false);
809  }
811 }
std::string getName() const
Definition: item.cpp:140
void setVisible(const bool b)
Definition: shopitem.h:143
void updateList()
Definition: shopitems.cpp:198
#define FOR_EACH(type, iter, array)
Definition: foreach.h:25
std::string toLower(std::string const &s)

References ShopItems::allItems(), FOR_EACH, Item::getName(), mShopItems, ShopItem::setVisible(), Catch::toLower(), and ShopItems::updateList().

Referenced by action().

◆ close()

void BuyDialog::close ( )
virtual

Overrideable functionality for when the window is to close. This allows for class implementations to clean up or do certain actions on window close they couldn't do otherwise.

Reimplemented from Window.

Definition at line 504 of file buydialog.cpp.

505 {
506  switch (toInt(mNpcId, int))
507  {
508 #ifdef TMWA_SUPPORT
509  case Nick:
510 #endif // TMWA_SUPPORT
511  case Items:
512  break;
513  case Market:
514  marketHandler->close();
515  break;
516  case Cash:
518  break;
519  case Vending:
521  break;
522  default:
524  break;
525  }
526  Window::close();
527 }
virtual void close() const =0
virtual void close() const =0
virtual void close() const =0
virtual void close() const =0
virtual void close()
Definition: window.cpp:902
#define toInt(val, name)
Definition: intdefines.h:47

References buySellHandler, Cash, cashShopHandler, Window::close(), Net::BuySellHandler::close(), Net::CashShopHandler::close(), Net::MarketHandler::close(), Net::VendingHandler::close(), Items, Market, marketHandler, mNpcId, Nick, toInt, Vending, and vendingHandler.

Referenced by action().

◆ closeAll()

void BuyDialog::closeAll ( )
static

Closes all instances.

Definition at line 784 of file buydialog.cpp.

785 {
786  FOR_EACH (DialogList::const_iterator, it, instances)
787  {
788  if (*it != nullptr)
789  (*it)->close();
790  }
791 }

References FOR_EACH, and instances.

Referenced by DialogsManager::closeDialogs().

◆ getNumberOfElements()

int BuyDialog::getNumberOfElements ( )

Returns the number of items in the shop inventory.

◆ init()

void BuyDialog::init ( )

Definition at line 282 of file buydialog.cpp.

283 {
284  setWindowName("Buy");
285  setResizable(true);
286  setCloseButton(true);
287  setStickyButtonLock(true);
288  setMinWidth(260);
289  setMinHeight(220);
290  setDefaultSize(260, 230, ImagePosition::CENTER, 0, 0);
291 
292 #ifdef TMWA_SUPPORT
293  // reset advance flag for personal shops
294  if (mAdvanced &&
295  mNpcId == fromInt(Nick, BeingId))
296  {
297  mAdvanced = false;
298  }
299 #endif // TMWA_SUPPORT
300 
301  if (setupWindow != nullptr)
303 
304  mShopItems = new ShopItems(false,
305  mCurrency);
306 
310  fromBool(getOptionBool("showbackground", false), Opaque),
311  "buy_background.xml");
313 
314  mSlider = new Slider(this, 1.0, 1.0);
315  mQuantityLabel = new Label(this, strprintf(
316  "%d / %d", mAmountItems, mMaxItems));
318  mMoneyLabel = new Label(this, strprintf(
319  // TRANSLATORS: buy dialog label
320  _("Price: %s / Total: %s"), "", ""));
321 
322  mAmountField = new IntTextField(this, 1, 1, 123, Enable_true, 0);
323  mAmountField->setActionEventId("amount");
326  mAmountField->setEnabled(false);
327 
328  // TRANSLATORS: buy dialog label
329  mAmountLabel = new Label(this, _("Amount:"));
331 
332  // TRANSLATORS: This is a narrow symbol used to denote 'increasing'.
333  // You may change this symbol if your language uses another.
334  mIncreaseButton = new Button(this, _("+"), "inc", BUTTON_SKIN, this);
335  // TRANSLATORS: This is a narrow symbol used to denote 'decreasing'.
336  // You may change this symbol if your language uses another.
337  mDecreaseButton = new Button(this, _("-"), "dec", BUTTON_SKIN, this);
338  mBuyButton = new Button(this, mNpcId == fromInt(Items, BeingId)
339  // TRANSLATORS: buy dialog button
340  ? _("Create") : (mAdvanced ? _("Add") : _("Buy")),
341  "buy",
342  BUTTON_SKIN,
343  this);
344  if (mAdvanced)
345  {
346  mConfirmButton = new Button(this,
347  // TRANSLATORS: buy dialog button
348  _("Buy"),
349  "confirm",
350  BUTTON_SKIN,
351  this);
352  mConfirmButton->setEnabled(false);
353  }
354  else
355  {
356  mConfirmButton = nullptr;
357  }
358  // TRANSLATORS: buy dialog button
359  mQuitButton = new Button(this, _("Quit"), "quit", BUTTON_SKIN, this);
360  // TRANSLATORS: buy dialog button
361  mAddMaxButton = new Button(this, _("Max"), "max", BUTTON_SKIN, this);
362 
365 
366  mIncreaseButton->setEnabled(false);
367  mDecreaseButton->setEnabled(false);
368  mBuyButton->setEnabled(false);
369  mSlider->setEnabled(false);
370 
371  mSlider->setActionEventId("slider");
372  mSlider->addActionListener(this);
373 
378 
380 
381  ContainerPlacer placer = getPlacer(0, 0);
382  placer(0, 0, mScrollArea, 9, 5).setPadding(3);
383  placer(0, 5, mDecreaseButton, 1, 1);
384  placer(1, 5, mSlider, 4, 1);
385  placer(5, 5, mIncreaseButton, 1, 1);
386  placer(6, 5, mQuantityLabel, 2, 1);
387  placer(8, 5, mAddMaxButton, 1, 1);
388  placer(0, 6, mAmountLabel, 2, 1);
389  placer(2, 6, mAmountField, 2, 1);
390  placer(0, 7, mMoneyLabel, 8, 1);
391  if (mSortDropDown != nullptr)
392  {
393  placer(0, 8, mSortDropDown, 2, 1);
394  }
395  else
396  {
397  // TRANSLATORS: buy dialog label
398  mFilterLabel = new Label(this, _("Filter:"));
400  placer(0, 8, mFilterLabel, 2, 1);
401  }
402  placer(2, 8, mFilterTextField, 2, 1);
403  if (mAdvanced)
404  {
405  placer(6, 8, mBuyButton, 1, 1);
406  placer(7, 8, mConfirmButton, 1, 1);
407  }
408  else
409  {
410  placer(7, 8, mBuyButton, 1, 1);
411  }
412  placer(8, 8, mQuitButton, 1, 1);
413 
414  Layout &layout = getLayout();
415  layout.setRowHeight(0, LayoutType::SET);
416 
417  center();
418  loadWindowState();
419  enableVisibleSound(true);
420 
421  instances.push_back(this);
423 
424  if (mSortDropDown != nullptr)
425  mSortDropDown->setSelected(config.getIntValue("buySortOrder"));
426 }
#define fromBool(val, name)
Definition: booldefines.h:49
const std::string BUTTON_SKIN
Definition: button.h:89
Definition: button.h:102
void adjustSize()
Definition: button.cpp:799
ScrollArea * mScrollArea
Definition: buydialog.h:187
Label * mQuantityLabel
Definition: buydialog.h:189
Button * mQuitButton
Definition: buydialog.h:182
Button * mIncreaseButton
Definition: buydialog.h:184
Label * mMoneyLabel
Definition: buydialog.h:188
void setVisible(Visible visible)
Definition: buydialog.cpp:774
Button * mAddMaxButton
Definition: buydialog.h:183
Button * mDecreaseButton
Definition: buydialog.h:185
Label * mAmountLabel
Definition: buydialog.h:191
Button * mBuyButton
Definition: buydialog.h:180
int getIntValue(const std::string &key) const
void setSelected(int selected)
Definition: dropdown.cpp:514
@ CENTER
Definition: graphics.h:132
Definition: label.h:91
void adjustSize()
Definition: label.cpp:200
void setAlignment(Graphics::Alignment alignment)
Definition: label.h:153
void setRowHeight(const int n, const int h)
Definition: layoutcell.cpp:128
Definition: layout.h:45
void setDistributeMousePressed(const bool b)
Definition: listbox.h:141
void addSelectionListener(SelectionListener *const selectionListener)
Definition: listbox.cpp:435
void setHorizontalScrollPolicy(const ScrollPolicy hPolicy)
void registerWindowForReset(Window *const window)
Definition: slider.h:89
void setSendAlwaysEvents(const bool b)
Definition: textfield.h:166
void setWidth(const int width)
Definition: widget.cpp:133
void setActionEventId(const std::string &actionEventId)
Definition: widget.h:596
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:252
int getWidth() const
Definition: widget.h:221
void center()
Definition: window.cpp:1417
void setResizable(const bool resize)
Definition: window.cpp:627
ContainerPlacer getPlacer(const int x, const int y)
Definition: window.cpp:1391
bool getOptionBool(const std::string &name, const bool def) const
Definition: window.cpp:1466
Layout & getLayout()
Definition: window.cpp:1365
void setWindowName(const std::string &name)
Definition: window.h:355
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
void setDefaultSize()
Definition: window.cpp:1198
void loadWindowState()
Definition: window.cpp:1087
#define CREATEWIDGETV(var, type,...)
Definition: createwidget.h:25
const bool Enable_true
Definition: enable.h:30
bool Opaque
Definition: opaque.h:30
SetupWindow * setupWindow
Definition: setupwindow.cpp:64
std::string strprintf(const char *const format,...)
const bool Visible_true
Definition: visible.h:30

References _, Widget::addActionListener(), ListBox::addSelectionListener(), Button::adjustSize(), Label::adjustSize(), BUTTON_SKIN, ImagePosition::CENTER, Window::center(), Graphics::CENTER, config, CREATEWIDGETV, Enable_true, Window::enableVisibleSound(), fromBool, fromInt, Configuration::getIntValue(), Window::getLayout(), Window::getOptionBool(), Window::getPlacer(), Widget::getWidth(), instances, Items, Window::loadWindowState(), mAddMaxButton, mAdvanced, mAmountField, mAmountItems, mAmountLabel, mBuyButton, mConfirmButton, mCurrency, mDecreaseButton, mFilterLabel, mFilterTextField, mIncreaseButton, mMaxItems, mMoneyLabel, mNpcId, mQuantityLabel, mQuitButton, mScrollArea, mShopItemList, mShopItems, mSlider, mSortDropDown, Nick, SetupWindow::registerWindowForReset(), LayoutType::SET, Widget::setActionEventId(), Label::setAlignment(), Window::setCloseButton(), Window::setDefaultSize(), ListBox::setDistributeMousePressed(), Widget::setEnabled(), ScrollArea::setHorizontalScrollPolicy(), Window::setMinHeight(), Window::setMinWidth(), Window::setResizable(), LayoutCell::setRowHeight(), DropDown::setSelected(), TextField::setSendAlwaysEvents(), Window::setStickyButtonLock(), setupWindow, setVisible(), Widget::setWidth(), Window::setWindowName(), ScrollArea::SHOW_NEVER, strprintf(), ShopListBoxType::Unknown, and Visible_true.

Referenced by BuyDialog().

◆ isActive()

static bool BuyDialog::isActive ( )
inlinestatic

Returns true if any instances exist.

Definition at line 164 of file buydialog.h.

165  { return !instances.empty(); }

References instances.

Referenced by InputManager::updateConditionMask().

◆ reset()

void BuyDialog::reset ( )

Resets the dialog, clearing shop inventory.

Definition at line 445 of file buydialog.cpp.

446 {
447  mShopItems->clear();
449 
450  // Reset previous selected items to prevent failing asserts
452  mSlider->setValue(0);
453 
454  setMoney(0);
455 }
void setMoney(const int amount)
Definition: buydialog.cpp:437
void setSelected(const int selected)
Definition: listbox.cpp:399
void clear()
Definition: shopitems.cpp:174

References ShopListBox::adjustSize(), ShopItems::clear(), mShopItemList, mShopItems, mSlider, setMoney(), ListBox::setSelected(), and Slider::setValue().

◆ setMoney()

void BuyDialog::setMoney ( const int  amount)

◆ setVisible()

void BuyDialog::setVisible ( Visible  visible)
virtual

Sets the visibility of this window.

Reimplemented from Window.

Definition at line 774 of file buydialog.cpp.

775 {
776  Window::setVisible(visible);
777 
778  if (visible == Visible_true && (mShopItemList != nullptr))
780  else
781  scheduleDelete();
782 }
virtual void requestFocus()
Definition: widget.cpp:204
virtual void setVisible(Visible visible)
Definition: window.cpp:778
virtual void scheduleDelete()
Definition: window.cpp:831

References mShopItemList, Widget::requestFocus(), Window::scheduleDelete(), Window::setVisible(), and Visible_true.

Referenced by init().

◆ sort()

void BuyDialog::sort ( )

Definition at line 472 of file buydialog.cpp.

473 {
474  if ((mSortDropDown != nullptr) && (mShopItems != nullptr))
475  {
476  STD_VECTOR<ShopItem*> &items = mShopItems->items();
477  switch (mSortDropDown->getSelected())
478  {
479  case 1:
480  std::sort(items.begin(), items.end(), itemPriceBuySorter);
481  break;
482  case 2:
483  std::sort(items.begin(), items.end(), itemNameBuySorter);
484  break;
485  case 3:
486  std::sort(items.begin(), items.end(), itemIdBuySorter);
487  break;
488  case 4:
489  std::sort(items.begin(), items.end(), itemWeightBuySorter);
490  break;
491  case 5:
492  std::sort(items.begin(), items.end(), itemAmountBuySorter);
493  break;
494  case 6:
495  std::sort(items.begin(), items.end(), itemTypeBuySorter);
496  break;
497  case 0:
498  default:
499  break;
500  }
501  }
502 }
std::vector< ShopItem * > & items()
Definition: shopitems.h:136
class anonymous_namespace{buydialog.cpp}::SortItemAmountFunctor itemAmountBuySorter
class anonymous_namespace{buydialog.cpp}::SortItemIdFunctor itemIdBuySorter
class anonymous_namespace{buydialog.cpp}::SortItemNameFunctor itemNameBuySorter
class anonymous_namespace{buydialog.cpp}::SortItemTypeFunctor itemTypeBuySorter
class anonymous_namespace{buydialog.cpp}::SortItemPriceFunctor itemPriceBuySorter
class anonymous_namespace{buydialog.cpp}::SortItemWeightFunctor itemWeightBuySorter

References DropDown::getSelected(), anonymous_namespace{buydialog.cpp}::itemAmountBuySorter, anonymous_namespace{buydialog.cpp}::itemIdBuySorter, anonymous_namespace{buydialog.cpp}::itemNameBuySorter, anonymous_namespace{buydialog.cpp}::itemPriceBuySorter, ShopItems::items(), anonymous_namespace{buydialog.cpp}::itemTypeBuySorter, anonymous_namespace{buydialog.cpp}::itemWeightBuySorter, mShopItems, and mSortDropDown.

Referenced by action(), EAthena::CashShopRecv::processCashShopOpen(), EAthena::VendingRecv::processItemsList(), EAthena::MarketRecv::processMarketOpen(), EAthena::BuySellRecv::processNpcBuy(), TmwAthena::BuySellRecv::processNpcBuy(), and ShopWindow::showList().

◆ updateButtonsAndLabels()

void BuyDialog::updateButtonsAndLabels ( )

Updates the state of buttons and labels.

Definition at line 718 of file buydialog.cpp.

719 {
720  const int selectedItem = mShopItemList->getSelected();
721  int price = 0;
722 
723  if (selectedItem > -1)
724  {
725  const ShopItem *const item = mShopItems->at(selectedItem);
726  if (item != nullptr)
727  {
728  const int itemPrice = item->getPrice();
729 
730  // Calculate how many the player can afford
731  if (mNpcId == fromInt(Items, BeingId))
732  mMaxItems = 100;
733  else if (itemPrice != 0)
734  mMaxItems = mMoney / itemPrice;
735  else
736  mMaxItems = 1;
737 
738  if (mNpcId == fromInt(Market, BeingId))
739  {
740  if (mMaxItems > item->getQuantity())
741  mMaxItems = item->getQuantity();
742  }
743  else if (item->getQuantity() > 0 &&
744  mMaxItems > item->getQuantity())
745  {
746  mMaxItems = item->getQuantity();
747  }
748 
749  if (mAmountItems > mMaxItems)
751 
752  price = mAmountItems * itemPrice;
753  }
754  }
755  else
756  {
757  mMaxItems = 0;
758  mAmountItems = 0;
759  }
760 
766 
768  // TRANSLATORS: buy dialog label
769  mMoneyLabel->setCaption(strprintf(_("Price: %s / Total: %s"),
770  UnitsDb::formatCurrency(mCurrency, price).c_str(),
771  UnitsDb::formatCurrency(mCurrency, mMoney - price).c_str()));
772 }
int getQuantity() const
Definition: item.h:105
void setCaption(const std::string &caption)
Definition: label.cpp:264
std::string formatCurrency(const int value)
Definition: unitsdb.cpp:324

References _, ShopItems::at(), UnitsDb::formatCurrency(), fromInt, ShopItem::getPrice(), Item::getQuantity(), ListBox::getSelected(), Items, mAmountField, mAmountItems, Market, mBuyButton, mCurrency, mDecreaseButton, mIncreaseButton, mMaxItems, mMoney, mMoneyLabel, mNpcId, mQuantityLabel, mShopItemList, mShopItems, mSlider, Label::setCaption(), Widget::setEnabled(), and strprintf().

Referenced by action(), setMoney(), and valueChanged().

◆ updateSlider()

void BuyDialog::updateSlider ( const int  selectedItem)
private

Definition at line 689 of file buydialog.cpp.

690 {
691  // Update money and adjust the max number of items
692  // that can be bought
694  const ShopItem *const item = mShopItems->at(selectedItem);
695  if (item != nullptr)
696  setMoney(mMoney - mAmountItems * item->getPrice());
697  else
698  setMoney(mMoney);
699 
700  // Reset selection
701  mAmountItems = 1;
703  mSlider->setValue(1);
704 }
void setScale(const double scaleStart, const double scaleEnd)
Definition: slider.cpp:468

References ShopItems::at(), ShopItem::getPrice(), mAmountItems, mMaxItems, mMoney, mShopItems, mSlider, setMoney(), Slider::setScale(), and Slider::setValue().

Referenced by action().

◆ valueChanged()

void BuyDialog::valueChanged ( const SelectionEvent event)
virtual

Updates the labels according to the selected item.

Reimplemented from SelectionListener.

Definition at line 706 of file buydialog.cpp.

707 {
708  // Reset amount of items and update labels
709  mAmountItems = 1;
710  mSlider->setValue(1);
711 
716 }
void setRange(const int minimum, const int maximum)

References mAmountField, mAmountItems, mMaxItems, mSlider, IntTextField::setRange(), Slider::setScale(), Slider::setValue(), IntTextField::setValue(), and updateButtonsAndLabels().

Field Documentation

◆ instances

BuyDialog::DialogList BuyDialog::instances
staticprivate

Definition at line 178 of file buydialog.h.

Referenced by closeAll(), init(), isActive(), and ~BuyDialog().

◆ mAddMaxButton

Button* BuyDialog::mAddMaxButton
private

Definition at line 183 of file buydialog.h.

Referenced by init().

◆ mAdvanced

bool BuyDialog::mAdvanced
private

Definition at line 205 of file buydialog.h.

Referenced by action(), and init().

◆ mAmountField

IntTextField* BuyDialog::mAmountField
private

Definition at line 192 of file buydialog.h.

Referenced by action(), init(), updateButtonsAndLabels(), and valueChanged().

◆ mAmountItems

int BuyDialog::mAmountItems
private

Definition at line 203 of file buydialog.h.

Referenced by action(), init(), updateButtonsAndLabels(), updateSlider(), and valueChanged().

◆ mAmountLabel

Label* BuyDialog::mAmountLabel
private

Definition at line 191 of file buydialog.h.

Referenced by init().

◆ mBuyButton

Button* BuyDialog::mBuyButton
private

Definition at line 180 of file buydialog.h.

Referenced by init(), and updateButtonsAndLabels().

◆ mConfirmButton

Button* BuyDialog::mConfirmButton
private

Definition at line 181 of file buydialog.h.

Referenced by action(), and init().

◆ mCurrency

std::string BuyDialog::mCurrency
private

Definition at line 200 of file buydialog.h.

Referenced by init(), and updateButtonsAndLabels().

◆ mDecreaseButton

Button* BuyDialog::mDecreaseButton
private

Definition at line 185 of file buydialog.h.

Referenced by init(), and updateButtonsAndLabels().

◆ mFilterLabel

Label* BuyDialog::mFilterLabel
private

Definition at line 197 of file buydialog.h.

Referenced by init().

◆ mFilterTextField

TextField* BuyDialog::mFilterTextField
private

Definition at line 196 of file buydialog.h.

Referenced by action(), and init().

◆ mIncreaseButton

Button* BuyDialog::mIncreaseButton
private

Definition at line 184 of file buydialog.h.

Referenced by init(), and updateButtonsAndLabels().

◆ mMaxItems

int BuyDialog::mMaxItems
private

Definition at line 204 of file buydialog.h.

Referenced by action(), init(), updateButtonsAndLabels(), updateSlider(), and valueChanged().

◆ mMoney

int BuyDialog::mMoney
private

Definition at line 202 of file buydialog.h.

Referenced by setMoney(), updateButtonsAndLabels(), and updateSlider().

◆ mMoneyLabel

Label* BuyDialog::mMoneyLabel
private

Definition at line 188 of file buydialog.h.

Referenced by init(), and updateButtonsAndLabels().

◆ mNick

std::string BuyDialog::mNick
private

Definition at line 199 of file buydialog.h.

Referenced by action().

◆ mNpcId

BeingId BuyDialog::mNpcId
private

Definition at line 201 of file buydialog.h.

Referenced by action(), close(), init(), and updateButtonsAndLabels().

◆ mQuantityLabel

Label* BuyDialog::mQuantityLabel
private

Definition at line 189 of file buydialog.h.

Referenced by init(), and updateButtonsAndLabels().

◆ mQuitButton

Button* BuyDialog::mQuitButton
private

Definition at line 182 of file buydialog.h.

Referenced by init().

◆ mScrollArea

ScrollArea* BuyDialog::mScrollArea
private

Definition at line 187 of file buydialog.h.

Referenced by init().

◆ mShopItemList

ShopListBox* BuyDialog::mShopItemList
private

Definition at line 186 of file buydialog.h.

Referenced by action(), addItem(), init(), reset(), setMoney(), setVisible(), and updateButtonsAndLabels().

◆ mShopItems

ShopItems* BuyDialog::mShopItems
private

◆ mSlider

Slider* BuyDialog::mSlider
private

Definition at line 190 of file buydialog.h.

Referenced by action(), init(), reset(), updateButtonsAndLabels(), updateSlider(), and valueChanged().

◆ mSortDropDown

DropDown* BuyDialog::mSortDropDown
private

Definition at line 195 of file buydialog.h.

Referenced by action(), init(), and sort().

◆ mSortModel

SortListModelBuy* BuyDialog::mSortModel
private

Definition at line 194 of file buydialog.h.

Referenced by ~BuyDialog().


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