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

#include <npcdialog.h>

Inheritance diagram for NpcDialog:
Window ActionListener ExtendedListModel ConfigListener BasicContainer2 MouseListener WidgetListener ListModel BasicContainer Widget WidgetDeathListener Widget2

Public Member Functions

 NpcDialog (const BeingId npcId)
 
 ~NpcDialog ()
 
void postInit ()
 
void action (const ActionEvent &event)
 
void addText (const std::string &string, const bool save)
 
void showNextButton ()
 
void showCloseButton ()
 
void nextDialog ()
 
void closeDialog ()
 
int getNumberOfElements ()
 
std::string getElementAt (int i)
 
const ImagegetImageAt (int i)
 
void choiceRequest ()
 
void addChoice (const std::string &)
 
void parseListItems (const std::string &itemString)
 
void textRequest (const std::string &defaultText)
 
bool isInputFocused () const
 
bool isTextInputFocused () const
 
void integerRequest (const int defaultValue, const int min, const int max)
 
void itemRequest (const int size)
 
void itemIndexRequest (const int size)
 
void itemCraftRequest (const int size)
 
void move (const int amount)
 
void setVisible (Visible visible)
 
void optionChanged (const std::string &name)
 
void saveCamera ()
 
void restoreCamera ()
 
void refocus ()
 
void showAvatar (const BeingTypeId avatarId)
 
void setAvatarDirection (const uint8_t direction)
 
void setAvatarAction (const int actionId)
 
void logic ()
 
void clearRows ()
 
void mousePressed (MouseEvent &event)
 
int isCloseState () const
 
void setSkin (const std::string &skin)
 
void addCraftItem (Item *const item, const int amount, const int slot)
 
NpcInputStateT getInputState ()
 
void copyToClipboard (const int x, const int y) const
 
- 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)
 
WindowgetParentWindow () const
 
virtual void scheduleDelete ()
 
void mouseDragged (MouseEvent &event)
 
void mouseMoved (MouseEvent &event)
 
void mouseReleased (MouseEvent &event)
 
void mouseExited (MouseEvent &event)
 
void mouseEntered (MouseEvent &event)
 
void updateResizeHandler (MouseEvent &event)
 
void setWindowName (const std::string &name)
 
const std::string & getWindowName () const
 
void loadWindowState ()
 
void saveWindowState ()
 
void setDefaultSize (const int defaultX, const int defaultY, int defaultWidth, int defaultHeight)
 
void setDefaultSize ()
 
void setDefaultSize (const int defaultWidth, const int defaultHeight, const ImagePosition::Type &position, const int offsetx, const int offsetY)
 
virtual void resetToDefaultSize ()
 
void adjustPositionAfterResize (const int oldScreenWidth, const int oldScreenHeight)
 
LayoutgetLayout ()
 
void clearLayout ()
 
void reflowLayout (int w, int h)
 
LayoutCellplace (const int x, const int y, Widget *const wg, const int w, const int h)
 
ContainerPlacer getPlacer (const int x, const int y)
 
void center ()
 
void centerHorisontally ()
 
virtual void close ()
 
void setModal (const Modal modal)
 
Rect getWindowArea () const
 
bool isResizeAllowed (const MouseEvent &event) const
 
void setCaptionFont (Font *font)
 
void enableVisibleSound (bool b)
 
bool isWindowVisible () const
 
void setPadding (int padding)
 
int getPadding () const
 
void setTitleBarHeight (unsigned int height)
 
unsigned int getTitleBarHeight () const
 
void setCaption (const std::string &caption)
 
const std::string & getCaption () const
 
void setAlignment (Graphics::Alignment alignment)
 
Graphics::Alignment getAlignment () const
 
void setMovable (Move movable)
 
bool isMovable () const
 
Rect getChildrenArea ()
 
virtual void resizeToContent ()
 
- Public Member Functions inherited from BasicContainer2
 BasicContainer2 (const Widget2 *const widget)
 
 ~BasicContainer2 ()
 
void setOpaque (Opaque opaque)
 
bool isOpaque () const
 
virtual void add (Widget *const widget)
 
void addXY (Widget *const widget, const int x, const int y)
 
- Public Member Functions inherited from BasicContainer
 BasicContainer (const Widget2 *const widget)
 
 ~BasicContainer ()
 
void showWidgetPart (Widget *const widget, const Rect &area)
 
void moveToTop (Widget *const widget)
 
void moveToBottom (Widget *const widget)
 
void focusNext ()
 
void focusPrevious ()
 
void 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 ExtendedListModel
 ExtendedListModel ()
 
- Public Member Functions inherited from ListModel
 ListModel ()
 
virtual ~ListModel ()
 
- Public Member Functions inherited from ConfigListener
 ConfigListener ()
 
virtual ~ConfigListener ()
 

Static Public Member Functions

static bool isAnyInputFocused ()
 
static bool isActive ()
 
static NpcDialoggetActive ()
 
static void closeAll ()
 
static void destroyAll ()
 
static void clearDialogs ()
 
- 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)
 

Static Public Attributes

static NpcDialogs mNpcDialogs
 

Private Types

typedef std::list< NpcDialog * > DialogList
 

Private Member Functions

void buildLayout ()
 
void placeNormalControls ()
 
void placeMenuControls ()
 
void placeSkinControls ()
 
void placeTextInputControls ()
 
void placeIntInputControls ()
 
void placeItemInputControls ()
 
void createSkinControls ()
 
void deleteSkinControls ()
 
void restoreVirtuals ()
 
std::string complexItemToStr (const ComplexItem *const item)
 

Private Attributes

BeingId mNpcId
 
int mDefaultInt
 
std::string mDefaultString
 
BrowserBoxmTextBox
 
ScrollAreamScrollArea
 
std::string mText
 
std::string mNewText
 
StringVect mItems
 
std::vector< Image * > mImages
 
ExtendedListBoxmItemList
 
ScrollAreamListScrollArea
 
ContainermSkinContainer
 
ScrollAreamSkinScrollArea
 
ItemLinkHandlermItemLinkHandler
 
TextFieldmTextField
 
IntTextFieldmIntField
 
ButtonmPlusButton
 
ButtonmMinusButton
 
ButtonmClearButton
 
ButtonmButton
 
ButtonmButton2
 
ButtonmButton3
 
ButtonmResetButton
 
InventorymInventory
 
ComplexInventorymComplexInventory
 
ItemContainermItemContainer
 
ScrollAreamItemScrollArea
 
NpcInputStateT mInputState
 
NpcActionStateT mActionState
 
std::vector< Widget * > mSkinControls
 
std::string mSkinName
 
PlayerBoxmPlayerBox
 
BeingmAvatarBeing
 
const NpcDialogInfomDialogInfo
 
int mLastNextTime
 
int mCameraMode
 
int mCameraX
 
int mCameraY
 
bool mShowAvatar
 
bool mLogInteraction
 

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 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 npc dialog.

Definition at line 64 of file npcdialog.h.

Member Typedef Documentation

◆ DialogList

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

Definition at line 246 of file npcdialog.h.

Constructor & Destructor Documentation

◆ NpcDialog()

NpcDialog::NpcDialog ( const BeingId  npcId)
explicit

Constructor.

See also
Window::Window

Definition at line 97 of file npcdialog.cpp.

References Widget::addActionListener(), buildLayout(), CAPTION_CLOSE, CAPTION_NEXT, CAPTION_SUBMIT, CAPTION_WAITING, Window::center(), config, Widget::getFont(), Font::getHeight(), Configuration::getIntValue(), Gui::getNpcFont(), Font::getWidth(), gui, instances, Window::loadWindowState(), ImagePosition::LOWER_LEFT, mButton, mIntField, mItemLinkHandler, mItemList, mItemScrollArea, mListScrollArea, mPlayerBox, mScrollArea, mSkinScrollArea, mTextBox, mTextField, Opaque_false, Widget::setActionEventId(), Window::setContentSize(), Window::setDefaultSize(), ListBox::setDistributeMousePressed(), BrowserBox::setEnableImages(), BrowserBox::setEnableKeys(), BrowserBox::setEnableTabs(), Widget::setFocusable(), Widget::setFont(), Widget::setHeight(), ScrollArea::setHorizontalScrollPolicy(), BrowserBox::setLinkHandler(), BrowserBox::setMaxRow(), Window::setMinHeight(), Window::setMinWidth(), BrowserBox::setOpaque(), BrowserBox::setProcessVars(), Window::setResizable(), ListBox::setRowHeight(), ScrollArea::setScrollPolicy(), Window::setStickyButtonLock(), ScrollArea::setVerticalScrollPolicy(), Widget::setVisible(), Widget::setWidth(), Window::setWindowName(), ListBox::setWrappingEnabled(), ScrollArea::SHOW_ALWAYS, ScrollArea::SHOW_NEVER, and Visible_true.

97  :
98  // TRANSLATORS: npc dialog name
99  Window(_("NPC"), Modal_false, nullptr, "npc.xml"),
100  ActionListener(),
101  mNpcId(npcId),
102  mDefaultInt(0),
103  mDefaultString(),
104  mTextBox(new BrowserBox(this, Opaque_true,
105  "browserbox.xml")),
106  mScrollArea(new ScrollArea(this, mTextBox,
107  fromBool(getOptionBool("showtextbackground", false), Opaque),
108  "npc_textbackground.xml")),
109  mText(),
110  mNewText(),
111  mItems(),
112  mImages(),
114  this, this, "extendedlistbox.xml", 13)),
116  fromBool(getOptionBool("showlistbackground", false), Opaque),
117  "npc_listbackground.xml")),
118  mSkinContainer(new Container(this)),
120  fromBool(getOptionBool("showlistbackground", false), Opaque),
121  "npc_listbackground.xml")),
123  mTextField(new TextField(this, std::string(), LoseFocusOnTab_true,
124  nullptr, std::string(), false)),
125  mIntField(new IntTextField(this, 0, 0, 0, Enable_true, 0)),
126  // TRANSLATORS: npc dialog button
127  mPlusButton(new Button(this, _("+"), "inc", BUTTON_SKIN, this)),
128  // TRANSLATORS: npc dialog button
129  mMinusButton(new Button(this, _("-"), "dec", BUTTON_SKIN, this)),
130  // TRANSLATORS: npc dialog button
131  mClearButton(new Button(this, _("Clear"), "clear", BUTTON_SKIN, this)),
132  mButton(new Button(this, "", "ok", BUTTON_SKIN, this)),
133  // TRANSLATORS: npc dialog button
134  mButton2(new Button(this, _("Close"), "close", BUTTON_SKIN, this)),
135  // TRANSLATORS: npc dialog button
136  mButton3(new Button(this, _("Add"), "add", BUTTON_SKIN, this)),
137  // TRANSLATORS: npc dialog button
138  mResetButton(new Button(this, _("Reset"), "reset", BUTTON_SKIN, this)),
144  fromBool(getOptionBool("showitemsbackground", false), Opaque),
145  "npc_listbackground.xml")),
148  mSkinControls(),
149  mSkinName(),
150  mPlayerBox(new PlayerBox(nullptr, std::string(), std::string())),
151  mAvatarBeing(nullptr),
152  mDialogInfo(nullptr),
153  mLastNextTime(0),
154  mCameraMode(-1),
155  mCameraX(0),
156  mCameraY(0),
157  mShowAvatar(false),
158  mLogInteraction(config.getBoolValue("logNpcInGui"))
159 {
160  // Basic Window Setup
161  setWindowName("NpcText");
162  setResizable(true);
163  setFocusable(true);
164  setStickyButtonLock(true);
165 
166  setMinWidth(200);
167  setMinHeight(150);
168 
169  setDefaultSize(300, 578, ImagePosition::LOWER_LEFT, 0, 0);
170 
171  mPlayerBox->setWidth(70);
172  mPlayerBox->setHeight(100);
173 
174  // Setup output text box
176  mTextBox->setMaxRow(config.getIntValue("ChatLogLength"));
178  mTextBox->setProcessVars(true);
180  mTextBox->setEnableKeys(true);
181  mTextBox->setEnableTabs(true);
182  mTextBox->setEnableImages(true);
183 
186 
187  // Setup listbox
193  if (gui->getNpcFont()->getHeight() < 20)
194  mItemList->setRowHeight(20);
195  else
197 
198  setContentSize(260, 175);
206 
207  const Font *const fnt = mButton->getFont();
208  int width = std::max(fnt->getWidth(CAPTION_WAITING),
209  fnt->getWidth(CAPTION_NEXT));
210  width = std::max(width, fnt->getWidth(CAPTION_CLOSE));
211  width = std::max(width, fnt->getWidth(CAPTION_SUBMIT));
212  mButton->setWidth(8 + width);
213 
214  // Place widgets
215  buildLayout();
216 
217  center();
218  loadWindowState();
219 
220  instances.push_back(this);
221 }
Font * getFont() const
Definition: widget.cpp:330
void setDefaultSize()
Definition: window.cpp:1197
#define _(s)
Definition: gettext.h:34
const bool ShowEmptyRows_true
Definition: showemptyrows.h:29
void setEnableKeys(const bool n)
Definition: browserbox.h:138
const bool LoseFocusOnTab_true
void setWidth(const int width)
Definition: widget.cpp:132
Button * mButton2
Definition: npcdialog.h:300
bool getOptionBool(const std::string &name, const bool def) const
Definition: window.cpp:1465
NpcActionStateT mActionState
Definition: npcdialog.h:312
Gui * gui
Definition: gui.cpp:110
Definition: font.h:88
#define CAPTION_CLOSE
Definition: npcdialog.cpp:88
const bool Visible_true
Definition: visible.h:29
void loadWindowState()
Definition: window.cpp:1086
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:251
void setVisible(Visible visible)
Definition: widget.cpp:224
BeingId mNpcId
Definition: npcdialog.h:271
void setScrollPolicy(const ScrollPolicy hPolicy, const ScrollPolicy vPolicy)
ComplexInventory * mComplexInventory
Definition: npcdialog.h:307
void setMinWidth(const int width)
Definition: window.cpp:590
std::string mDefaultString
Definition: npcdialog.h:274
StringVect mItems
Definition: npcdialog.h:283
ItemContainer * mItemContainer
Definition: npcdialog.h:308
Definition: button.h:96
Configuration config
ScrollArea * mScrollArea
Definition: npcdialog.h:278
Button * mButton3
Definition: npcdialog.h:301
void setDistributeMousePressed(const bool b)
Definition: listbox.h:140
int getIntValue(const std::string &key) const
void setActionEventId(const std::string &actionEventId)
Definition: widget.h:595
const bool Enable_true
Definition: enable.h:29
Button * mResetButton
Definition: npcdialog.h:304
void setVerticalScrollPolicy(const ScrollPolicy vPolicy)
IntTextField * mIntField
Definition: npcdialog.h:293
void buildLayout()
Definition: npcdialog.cpp:1051
void setContentSize(int width, int height)
Definition: window.cpp:491
bool getBoolValue(const std::string &key) const
void setWrappingEnabled(const bool wrappingEnabled)
Definition: listbox.h:222
const std::string BUTTON_SKIN
Definition: button.h:88
int mCameraX
Definition: npcdialog.h:320
#define CAPTION_WAITING
Definition: npcdialog.cpp:84
#define fromBool(val, name)
Definition: booldefines.h:48
#define CAPTION_NEXT
Definition: npcdialog.cpp:86
BrowserBox * mTextBox
Definition: npcdialog.h:277
const NpcDialogInfo * mDialogInfo
Definition: npcdialog.h:317
void setProcessVars(const bool n)
Definition: browserbox.h:132
void setEnableTabs(const bool n)
Definition: browserbox.h:141
std::vector< Image * > mImages
Definition: npcdialog.h:284
const bool Opaque_false
Definition: opaque.h:29
Being * mAvatarBeing
Definition: npcdialog.h:316
std::string mSkinName
Definition: npcdialog.h:314
std::string mText
Definition: npcdialog.h:279
int mCameraY
Definition: npcdialog.h:321
int mLastNextTime
Definition: npcdialog.h:318
void setMinHeight(const int height)
Definition: window.cpp:603
Button * mClearButton
Definition: npcdialog.h:296
Inventory * mInventory
Definition: npcdialog.h:306
ScrollArea * mSkinScrollArea
Definition: npcdialog.h:288
int mDefaultInt
Definition: npcdialog.h:273
NpcInputStateT mInputState
Definition: npcdialog.h:311
static DialogList instances
Definition: npcdialog.h:247
void setHeight(const int height)
Definition: widget.cpp:139
ExtendedListBox * mItemList
Definition: npcdialog.h:285
bool mShowAvatar
Definition: npcdialog.h:322
Container * mSkinContainer
Definition: npcdialog.h:287
void setMaxRow(unsigned max)
Definition: browserbox.h:80
void setFocusable(const bool focusable)
Definition: widget.cpp:191
void center()
Definition: window.cpp:1416
std::string mNewText
Definition: npcdialog.h:280
void setLinkHandler(LinkHandler *linkHandler)
Definition: browserbox.cpp:165
void setFont(Font *const font)
Definition: widget.cpp:348
void setEnableImages(const bool n)
Definition: browserbox.h:135
int mCameraMode
Definition: npcdialog.h:319
const bool Opaque_true
Definition: opaque.h:29
ItemLinkHandler * mItemLinkHandler
Definition: npcdialog.h:289
int getWidth(const std::string &text) const
Definition: font.cpp:333
ScrollArea * mItemScrollArea
Definition: npcdialog.h:309
const bool ForceQuantity_false
Definition: forcequantity.h:29
Font * getNpcFont() const
Definition: gui.h:177
void setOpaque(Opaque opaque)
Definition: browserbox.h:74
void setResizable(const bool resize)
Definition: window.cpp:626
void setStickyButtonLock(const bool sticky)
Definition: window.cpp:771
std::vector< Widget * > mSkinControls
Definition: npcdialog.h:313
#define CREATEWIDGETR(type,...)
Definition: createwidget.h:35
int getHeight() const
Definition: font.cpp:361
Button * mMinusButton
Definition: npcdialog.h:295
Button * mButton
Definition: npcdialog.h:299
#define CAPTION_SUBMIT
Definition: npcdialog.cpp:90
Window(const std::string &caption, const Modal modal, Window *const parent, std::string skin)
Definition: window.cpp:108
ScrollArea * mListScrollArea
Definition: npcdialog.h:286
PlayerBox * mPlayerBox
Definition: npcdialog.h:315
TextField * mTextField
Definition: npcdialog.h:292
void setRowHeight(unsigned int n)
Definition: listbox.h:158
bool mLogInteraction
Definition: npcdialog.h:323
Button * mPlusButton
Definition: npcdialog.h:294
void setWindowName(const std::string &name)
Definition: window.h:354
void setHorizontalScrollPolicy(const ScrollPolicy hPolicy)

◆ ~NpcDialog()

NpcDialog::~NpcDialog ( )

Definition at line 245 of file npcdialog.cpp.

References CHECKLISTENERS, Window::clearLayout(), config, delete2, deleteSkinControls(), FOR_EACH, PlayerBox::getBeing(), instances, mButton, mButton2, mButton3, mClearButton, mComplexInventory, mImages, mIntField, mInventory, mItemContainer, mItemLinkHandler, mItemList, mItemScrollArea, mListScrollArea, mMinusButton, mPlayerBox, mPlusButton, mResetButton, mScrollArea, mSkinScrollArea, mTextBox, mTextField, and Configuration::removeListeners().

246 {
247  config.removeListeners(this);
249  clearLayout();
250 
251  if (mPlayerBox != nullptr)
252  {
253  delete mPlayerBox->getBeing();
254  delete mPlayerBox;
255  }
256 
258 
278 
280  {
281  if (*it != nullptr)
282  (*it)->decRef();
283  }
284 
285  mImages.clear();
286 
287  instances.remove(this);
288 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
void deleteSkinControls()
Definition: npcdialog.cpp:1269
Button * mButton2
Definition: npcdialog.h:300
ComplexInventory * mComplexInventory
Definition: npcdialog.h:307
ItemContainer * mItemContainer
Definition: npcdialog.h:308
Configuration config
ScrollArea * mScrollArea
Definition: npcdialog.h:278
Button * mButton3
Definition: npcdialog.h:301
#define delete2(var)
Definition: delete2.h:24
Button * mResetButton
Definition: npcdialog.h:304
IntTextField * mIntField
Definition: npcdialog.h:293
BrowserBox * mTextBox
Definition: npcdialog.h:277
std::vector< Image * > mImages
Definition: npcdialog.h:284
Button * mClearButton
Definition: npcdialog.h:296
Inventory * mInventory
Definition: npcdialog.h:306
ScrollArea * mSkinScrollArea
Definition: npcdialog.h:288
static DialogList instances
Definition: npcdialog.h:247
ExtendedListBox * mItemList
Definition: npcdialog.h:285
void removeListeners(ConfigListener *const listener)
ItemLinkHandler * mItemLinkHandler
Definition: npcdialog.h:289
ScrollArea * mItemScrollArea
Definition: npcdialog.h:309
#define CHECKLISTENERS
Definition: localconsts.h:276
Button * mMinusButton
Definition: npcdialog.h:295
Button * mButton
Definition: npcdialog.h:299
void clearLayout()
Definition: window.cpp:1371
ScrollArea * mListScrollArea
Definition: npcdialog.h:286
PlayerBox * mPlayerBox
Definition: npcdialog.h:315
TextField * mTextField
Definition: npcdialog.h:292
std::vector< Image * >::iterator ImageVectorIter
Definition: npcdialog.cpp:95
Button * mPlusButton
Definition: npcdialog.h:294
Being * getBeing()
Definition: playerbox.h:91

Member Function Documentation

◆ action()

void NpcDialog::action ( const ActionEvent event)
virtual

Called when receiving actions from the widgets.

Implements ActionListener.

Definition at line 318 of file npcdialog.cpp.

References addText(), ComplexInventory::addVirtualItem(), Inventory::addVirtualItem(), CAST_S32, CAST_U8, Inventory::clear(), BrowserBox::clearRows(), clearRows(), NpcActionState::CLOSE, closeDialog(), complexItemToStr(), cutInWindow, FOR_EACH, Item::getColor(), Item::getId(), PlayerInfo::getInventory(), Inventory::getItem(), ListBox::getSelected(), InventoryWindow::getSelectedItem(), Inventory::getSize(), Item::getTag(), TextField::getText(), IntTextField::getValue(), gui, CutInWindow::hide(), NpcActionState::INPUT, NpcInputState::INTEGER, Net::NpcHandler::integerInput(), inventoryWindow, NpcInputState::ITEM, ServerCommandType::item, NpcInputState::ITEM_CRAFT, NpcInputState::ITEM_INDEX, PacketLimiter::limitPackets(), NpcInputState::LIST, Net::NpcHandler::listInput(), mActionState, mComplexInventory, mDefaultInt, mDefaultString, mDialogInfo, mInputState, mIntField, mInventory, mItemList, mItems, mLogInteraction, mNewText, mNpcId, mTextBox, mTextField, NpcActionState::NEXT, nextDialog(), NpcInputState::NONE, npcHandler, PacketType::PACKET_NPC_INPUT, PacketType::PACKET_NPC_NEXT, Gui::resetClickCount(), restoreVirtuals(), TextField::setText(), IntTextField::setValue(), ServerCommandType::str, NpcInputState::STRING, Net::NpcHandler::stringInput(), strprintf(), toInt, Inventory::virtualRemove(), and NpcActionState::WAIT.

319 {
320  const std::string &eventId = event.getId();
321  if (eventId == "ok")
322  {
324  {
326  return;
327 
328  nextDialog();
329  addText(std::string(), false);
330  }
333  {
334  if (cutInWindow != nullptr)
335  cutInWindow->hide();
336  closeDialog();
337  }
339  {
340  std::string printText; // Text that will get printed
341  // in the textbox
342  switch (mInputState)
343  {
344  case NpcInputState::LIST:
345  {
346  if (mDialogInfo != nullptr)
347  return;
348  if (gui != nullptr)
349  gui->resetClickCount();
350  const int selectedIndex = mItemList->getSelected();
351 
352  if (selectedIndex >= CAST_S32(mItems.size())
353  || selectedIndex < 0
356  {
357  return;
358  }
359  unsigned char choice = CAST_U8(
360  selectedIndex + 1);
361  printText = mItems[selectedIndex];
362 
363  npcHandler->listInput(mNpcId, choice);
364  break;
365  }
367  {
370  {
371  return;
372  }
373  printText = mTextField->getText();
374  npcHandler->stringInput(mNpcId, printText);
375  break;
376  }
378  {
381  {
382  return;
383  }
384  printText = strprintf("%d", mIntField->getValue());
387  break;
388  }
389  case NpcInputState::ITEM:
390  {
391  restoreVirtuals();
394  {
395  return;
396  }
397 
398  std::string str;
399  const int sz = mInventory->getSize();
400  if (sz == 0)
401  {
402  str = "0,0";
403  }
404  else
405  {
406  const Item *item = mInventory->getItem(0);
407  if (item != nullptr)
408  {
409  str = strprintf("%d,%d", item->getId(),
410  toInt(item->getColor(), int));
411  }
412  else
413  {
414  str = "0,0";
415  }
416  for (int f = 1; f < sz; f ++)
417  {
418  str.append(";");
419  item = mInventory->getItem(f);
420  if (item != nullptr)
421  {
422  str.append(strprintf("%d,%d", item->getId(),
423  toInt(item->getColor(), int)));
424  }
425  else
426  {
427  str.append("0,0");
428  }
429  }
430  }
431 
432  // need send selected item
434  mInventory->clear();
435  break;
436  }
438  {
439  restoreVirtuals();
442  {
443  return;
444  }
445 
446  std::string str;
447  const int sz = mInventory->getSize();
448  if (sz == 0)
449  {
450  str = "-1";
451  }
452  else
453  {
454  const Item *item = mInventory->getItem(0);
455  if (item != nullptr)
456  {
457  str = strprintf("%d", item->getTag());
458  }
459  else
460  {
461  str = "-1";
462  }
463  for (int f = 1; f < sz; f ++)
464  {
465  str.append(";");
466  item = mInventory->getItem(f);
467  if (item != nullptr)
468  str.append(strprintf("%d", item->getTag()));
469  else
470  str.append("-1");
471  }
472  }
473 
474  // need send selected item
476  mInventory->clear();
477  break;
478  }
480  {
481  restoreVirtuals();
484  {
485  return;
486  }
487 
488  std::string str;
489  const int sz = mComplexInventory->getSize();
490  if (sz == 0)
491  {
492  str.clear();
493  }
494  else
495  {
496  const ComplexItem *item = dynamic_cast<ComplexItem*>(
498  str = complexItemToStr(item);
499  for (int f = 1; f < sz; f ++)
500  {
501  str.append("|");
502  item = dynamic_cast<ComplexItem*>(
504  str.append(complexItemToStr(item));
505  }
506  }
507 
508  // need send selected item
510  mInventory->clear();
511  break;
512  }
513 
514  case NpcInputState::NONE:
515  default:
516  break;
517  }
521  {
522  // addText will auto remove the input layout
523  addText(strprintf("> \"%s\"", printText.c_str()), false);
524  }
525  mNewText.clear();
526  }
527 
528  if (!mLogInteraction)
529  mTextBox->clearRows();
530  }
531  else if (eventId == "reset")
532  {
533  switch (mInputState)
534  {
537  break;
540  break;
541  case NpcInputState::ITEM:
543  mInventory->clear();
544  break;
547  break;
548  case NpcInputState::NONE:
549  case NpcInputState::LIST:
550  default:
551  break;
552  }
553  }
554  else if (eventId == "inc")
555  {
557  }
558  else if (eventId == "dec")
559  {
561  }
562  else if (eventId == "clear")
563  {
564  switch (mInputState)
565  {
566  case NpcInputState::ITEM:
568  mInventory->clear();
569  break;
572  break;
575  case NpcInputState::LIST:
576  case NpcInputState::NONE:
577  default:
578  clearRows();
579  break;
580  }
581  }
582  else if (eventId == "close")
583  {
584  restoreVirtuals();
586  {
587  switch (mInputState)
588  {
589  case NpcInputState::ITEM:
590  npcHandler->stringInput(mNpcId, "0,0");
591  break;
593  npcHandler->stringInput(mNpcId, "-1");
594  break;
597  break;
600  case NpcInputState::NONE:
601  case NpcInputState::LIST:
602  default:
603  npcHandler->listInput(mNpcId, 255);
604  break;
605  }
606  if (cutInWindow != nullptr)
607  cutInWindow->hide();
608  closeDialog();
609  }
610  }
611  else if (eventId == "add")
612  {
613  if (inventoryWindow != nullptr)
614  {
615  Item *const item = inventoryWindow->getSelectedItem();
616  Inventory *const inventory = PlayerInfo::getInventory();
617  if (inventory != nullptr)
618  {
620  {
621  if (mComplexInventory->addVirtualItem(item, -1, 1))
622  inventory->virtualRemove(item, 1);
623  }
624  else
625  {
626  if (mInventory->addVirtualItem(item, -1, 1))
627  inventory->virtualRemove(item, 1);
628  }
629  }
630  }
631  }
632  else if (eventId.find("skin_") == 0)
633  {
634  const std::string cmd = eventId.substr(5);
635  std::string printText;
636  int cnt = 0;
638  {
639  if (cmd == *it)
640  {
641  npcHandler->listInput(mNpcId, CAST_U8(cnt + 1));
642  printText = mItems[cnt];
643 
647  {
648  // addText will auto remove the input layout
649  addText(strprintf("> \"%s\"", printText.c_str()), false);
650  }
651  mNewText.clear();
652  break;
653  }
654  cnt ++;
655  }
656  }
657 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
void setValue(const int value)
int getTag() const
Definition: item.h:230
#define CAST_U8
Definition: cast.h:26
StringVect::const_iterator StringVectCIter
Definition: stringvector.h:30
void addText(const std::string &string, const bool save)
Definition: npcdialog.cpp:290
NpcActionStateT mActionState
Definition: npcdialog.h:312
bool addVirtualItem(const Item *const item, int index, const int amount)
Gui * gui
Definition: gui.cpp:110
virtual void integerInput(const BeingId npcId, const int value) const =0
virtual void stringInput(const BeingId npcId, const std::string &value) const =0
std::string complexItemToStr(const ComplexItem *const item)
Definition: npcdialog.cpp:1350
BeingId mNpcId
Definition: npcdialog.h:271
ComplexInventory * mComplexInventory
Definition: npcdialog.h:307
Inventory * getInventory()
Definition: playerinfo.cpp:193
void restoreVirtuals()
Definition: npcdialog.cpp:1343
std::string mDefaultString
Definition: npcdialog.h:274
StringVect mItems
Definition: npcdialog.h:283
bool limitPackets(const PacketTypeT type)
void virtualRemove(Item *const item, const int amount)
Definition: inventory.cpp:484
InventoryWindow * inventoryWindow
void setText(const std::string &text)
Definition: textfield.cpp:802
void clear()
Definition: inventory.cpp:237
IntTextField * mIntField
Definition: npcdialog.h:293
virtual bool addVirtualItem(const Item *const item, int index, const int amount)
Definition: inventory.cpp:438
#define toInt(val, name)
Definition: intdefines.h:46
void nextDialog()
Definition: npcdialog.cpp:659
void clearRows()
Definition: npcdialog.cpp:1211
#define CAST_S32
Definition: cast.h:29
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
BrowserBox * mTextBox
Definition: npcdialog.h:277
const NpcDialogInfo * mDialogInfo
Definition: npcdialog.h:317
void closeDialog()
Definition: npcdialog.cpp:664
ItemColor getColor() const
Definition: item.h:180
void resetClickCount()
Definition: gui.cpp:979
int getSelected() const
Definition: listbox.h:167
Definition: item.h:48
int getValue() const
virtual void listInput(const BeingId npcId, const unsigned char value) const =0
Inventory * mInventory
Definition: npcdialog.h:306
int mDefaultInt
Definition: npcdialog.h:273
NpcInputStateT mInputState
Definition: npcdialog.h:311
ExtendedListBox * mItemList
Definition: npcdialog.h:285
int getId() const
Definition: item.h:80
Item * getSelectedItem() const
std::string mNewText
Definition: npcdialog.h:280
Net::NpcHandler * npcHandler
Definition: net.cpp:90
Item * getItem(const int index) const
Definition: inventory.cpp:82
void clearRows()
Definition: browserbox.cpp:358
const std::string & getText() const
Definition: textfield.h:223
TextField * mTextField
Definition: npcdialog.h:292
bool mLogInteraction
Definition: npcdialog.h:323
CutInWindow * cutInWindow
Definition: cutinwindow.cpp:36
unsigned getSize() const
Definition: inventory.h:75

◆ addChoice()

void NpcDialog::addChoice ( const std::string &  choice)

Adds a choice to the list box.

Definition at line 699 of file npcdialog.cpp.

References mImages, and mItems.

700 {
701  mItems.push_back(choice);
702  mImages.push_back(nullptr);
703 }
StringVect mItems
Definition: npcdialog.h:283
std::vector< Image * > mImages
Definition: npcdialog.h:284

◆ addCraftItem()

void NpcDialog::addCraftItem ( Item *const  item,
const int  amount,
const int  slot 
)

Definition at line 1381 of file npcdialog.cpp.

References ComplexInventory::addVirtualItem(), PlayerInfo::getInventory(), NpcInputState::ITEM_CRAFT, mComplexInventory, mInputState, and Inventory::virtualRemove().

Referenced by ItemAmountWindow::finish(), isCloseState(), and InventoryWindow::moveItemToCraft().

1384 {
1386  return;
1387 
1388  Inventory *const inventory = PlayerInfo::getInventory();
1389 
1390  if (inventory == nullptr)
1391  return;
1392 
1394  item,
1395  slot,
1396  amount))
1397  {
1398  inventory->virtualRemove(item, amount);
1399  }
1400 }
bool addVirtualItem(const Item *const item, int index, const int amount)
ComplexInventory * mComplexInventory
Definition: npcdialog.h:307
Inventory * getInventory()
Definition: playerinfo.cpp:193
void virtualRemove(Item *const item, const int amount)
Definition: inventory.cpp:484
NpcInputStateT mInputState
Definition: npcdialog.h:311

◆ addText()

void NpcDialog::addText ( const std::string &  string,
const bool  save 
)

Sets the text shows in the dialog.

Parameters
stringThe new text. Adds the text to the text shows in the dialog. Also adds a newline to the end.
stringThe text to add.

Definition at line 290 of file npcdialog.cpp.

References BrowserBox::addRow(), buildLayout(), ScrollArea::getVerticalMaxScroll(), mActionState, mLogInteraction, mNewText, mScrollArea, mText, mTextBox, ScrollArea::setVerticalScrollAmount(), and NpcActionState::WAIT.

Referenced by action(), and Ea::NpcRecv::processNpcMessage().

291 {
292  if (save || mLogInteraction)
293  {
294  if (mText.size() > 5000)
295  mText.clear();
296 
297  mNewText.append(text);
298  mTextBox->addRow(text,
299  false);
300  }
303  buildLayout();
304 }
NpcActionStateT mActionState
Definition: npcdialog.h:312
ScrollArea * mScrollArea
Definition: npcdialog.h:278
void setVerticalScrollAmount(const int vScroll)
int getVerticalMaxScroll()
void buildLayout()
Definition: npcdialog.cpp:1051
BrowserBox * mTextBox
Definition: npcdialog.h:277
std::string mText
Definition: npcdialog.h:279
void addRow(const std::string &row, const bool atTop)
Definition: browserbox.cpp:170
std::string mNewText
Definition: npcdialog.h:280
bool mLogInteraction
Definition: npcdialog.h:323

◆ buildLayout()

void NpcDialog::buildLayout ( )
private

Definition at line 1051 of file npcdialog.cpp.

References CAPTION_CLOSE, CAPTION_NEXT, CAPTION_SUBMIT, CAPTION_WAITING, Window::clearLayout(), NpcActionState::CLOSE, Window::getLayout(), ScrollArea::getVerticalMaxScroll(), NpcActionState::INPUT, NpcInputState::INTEGER, NpcInputState::ITEM, NpcInputState::ITEM_CRAFT, NpcInputState::ITEM_INDEX, NpcInputState::LIST, mActionState, mButton, mDialogInfo, mInputState, mItemList, mScrollArea, NpcActionState::NEXT, NpcInputState::NONE, placeIntInputControls(), placeItemInputControls(), placeMenuControls(), placeNormalControls(), placeSkinControls(), placeTextInputControls(), Window::redraw(), LayoutType::SET, Button::setCaption(), LayoutCell::setRowHeight(), ListBox::setSelected(), ScrollArea::setVerticalScrollAmount(), NpcInputState::STRING, and NpcActionState::WAIT.

Referenced by addText(), choiceRequest(), integerRequest(), itemCraftRequest(), itemIndexRequest(), itemRequest(), logic(), NpcDialog(), showAvatar(), showCloseButton(), showNextButton(), and textRequest().

1052 {
1053  clearLayout();
1054 
1056  {
1059  else if (mActionState == NpcActionState::NEXT)
1061  else if (mActionState == NpcActionState::CLOSE)
1064  }
1065  else if (mInputState != NpcInputState::NONE)
1066  {
1068  switch (mInputState)
1069  {
1070  case NpcInputState::LIST:
1071  if (mDialogInfo == nullptr)
1073  else
1075  mItemList->setSelected(-1);
1076  break;
1077 
1078  case NpcInputState::STRING:
1080  break;
1081 
1084  break;
1085 
1086  case NpcInputState::ITEM:
1090  break;
1091 
1092  case NpcInputState::NONE:
1093  default:
1094  break;
1095  }
1096  }
1097 
1098  Layout &layout = getLayout();
1099  layout.setRowHeight(1, LayoutType::SET);
1100  redraw();
1102 }
void redraw()
Definition: window.cpp:1405
void setSelected(const int selected)
Definition: listbox.cpp:398
void placeNormalControls()
Definition: npcdialog.cpp:874
NpcActionStateT mActionState
Definition: npcdialog.h:312
#define CAPTION_CLOSE
Definition: npcdialog.cpp:88
ScrollArea * mScrollArea
Definition: npcdialog.h:278
void setVerticalScrollAmount(const int vScroll)
void placeTextInputControls()
Definition: npcdialog.cpp:947
int getVerticalMaxScroll()
void placeMenuControls()
Definition: npcdialog.cpp:891
void setCaption(const std::string &caption)
Definition: button.h:213
void placeSkinControls()
Definition: npcdialog.cpp:912
#define CAPTION_WAITING
Definition: npcdialog.cpp:84
#define CAPTION_NEXT
Definition: npcdialog.cpp:86
const NpcDialogInfo * mDialogInfo
Definition: npcdialog.h:317
Layout & getLayout()
Definition: window.cpp:1364
NpcInputStateT mInputState
Definition: npcdialog.h:311
ExtendedListBox * mItemList
Definition: npcdialog.h:285
void placeIntInputControls()
Definition: npcdialog.cpp:968
void placeItemInputControls()
Definition: npcdialog.cpp:993
Definition: layout.h:43
Button * mButton
Definition: npcdialog.h:299
#define CAPTION_SUBMIT
Definition: npcdialog.cpp:90
void clearLayout()
Definition: window.cpp:1371
void setRowHeight(const int n, const int h)
Definition: layoutcell.cpp:127

◆ choiceRequest()

void NpcDialog::choiceRequest ( )

Makes this dialog request a choice selection from the user.

Definition at line 685 of file npcdialog.cpp.

References buildLayout(), FOR_EACH, NpcActionState::INPUT, NpcInputState::LIST, mActionState, mImages, mInputState, and mItems.

Referenced by Ea::NpcRecv::processNpcChoice().

686 {
687  mItems.clear();
689  {
690  if (*it != nullptr)
691  (*it)->decRef();
692  }
693  mImages.clear();
696  buildLayout();
697 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
NpcActionStateT mActionState
Definition: npcdialog.h:312
StringVect mItems
Definition: npcdialog.h:283
void buildLayout()
Definition: npcdialog.cpp:1051
std::vector< Image * > mImages
Definition: npcdialog.h:284
NpcInputStateT mInputState
Definition: npcdialog.h:311
std::vector< Image * >::iterator ImageVectorIter
Definition: npcdialog.cpp:95

◆ clearDialogs()

void NpcDialog::clearDialogs ( )
static

Definition at line 1216 of file npcdialog.cpp.

References mNpcDialogs.

Referenced by PlayerPostDeathListener::action(), DialogsManager::closeDialogs(), and Client::stateSwitchLogin1().

1217 {
1218  NpcDialogs::iterator it = mNpcDialogs.begin();
1219  const NpcDialogs::iterator it_end = mNpcDialogs.end();
1220  while (it != it_end)
1221  {
1222  delete (*it).second;
1223  ++ it;
1224  }
1225  mNpcDialogs.clear();
1226 }
static NpcDialogs mNpcDialogs
Definition: npcdialog.h:241

◆ clearRows()

void NpcDialog::clearRows ( )

Definition at line 1211 of file npcdialog.cpp.

References BrowserBox::clearRows(), and mTextBox.

Referenced by action(), isActive(), and Ea::NpcRecv::processNpcCommand().

1212 {
1213  mTextBox->clearRows();
1214 }
BrowserBox * mTextBox
Definition: npcdialog.h:277
void clearRows()
Definition: browserbox.cpp:358

◆ closeAll()

void NpcDialog::closeAll ( )
static

Closes all instances.

Definition at line 865 of file npcdialog.cpp.

References FOR_EACH, and instances.

Referenced by DialogsManager::closeDialogs(), and isActive().

866 {
867  FOR_EACH (DialogList::const_iterator, it, instances)
868  {
869  if (*it != nullptr)
870  (*it)->close();
871  }
872 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
static DialogList instances
Definition: npcdialog.h:247

◆ closeDialog()

void NpcDialog::closeDialog ( )

Notifies the server that the client has performed a close action.

Definition at line 664 of file npcdialog.cpp.

References Net::NpcHandler::closeDialog(), mNpcId, npcHandler, and restoreCamera().

Referenced by action(), and Actions::closeMoveNpcDialog().

665 {
666  restoreCamera();
668 }
BeingId mNpcId
Definition: npcdialog.h:271
void restoreCamera()
Definition: npcdialog.cpp:1114
Net::NpcHandler * npcHandler
Definition: net.cpp:90
virtual void closeDialog(const BeingId npcId)=0

◆ complexItemToStr()

std::string NpcDialog::complexItemToStr ( const ComplexItem *const  item)
private

Definition at line 1350 of file npcdialog.cpp.

References ComplexItem::getChilds(), Item::getInvIndex(), Item::getQuantity(), ServerCommandType::item2, ServerCommandType::str, and strprintf().

Referenced by action().

1351 {
1352  std::string str;
1353  if (item != nullptr)
1354  {
1355  const STD_VECTOR<Item*> &items = item->getChilds();
1356  const size_t sz = items.size();
1357  if (sz == 0U)
1358  return str;
1359 
1360  const Item *item2 = items[0];
1361 
1362  str = strprintf("%d,%d",
1363  item2->getInvIndex(),
1364  item2->getQuantity());
1365  for (size_t f = 1; f < sz; f ++)
1366  {
1367  str.append(";");
1368  item2 = items[f];
1369  str.append(strprintf("%d,%d",
1370  item2->getInvIndex(),
1371  item2->getQuantity()));
1372  }
1373  }
1374  else
1375  {
1376  str.clear();
1377  }
1378  return str;
1379 }
int getInvIndex() const
Definition: item.h:164
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
int getQuantity() const
Definition: item.h:104
Definition: item.h:48
const std::vector< Item * > & getChilds() const
Definition: complexitem.h:58

◆ copyToClipboard()

void NpcDialog::copyToClipboard ( const int  x,
const int  y 
) const

Definition at line 1244 of file npcdialog.cpp.

References BrowserBox::getTextAtPos(), mTextBox, sendBuffer(), and ServerCommandType::str.

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

1245 {
1246  std::string str = mTextBox->getTextAtPos(x, y);
1247  sendBuffer(str);
1248 }
bool sendBuffer(const std::string &text)
Definition: copynpaste.cpp:517
std::string getTextAtPos(const int x, const int y) const
Definition: browserbox.cpp:869
BrowserBox * mTextBox
Definition: npcdialog.h:277

◆ createSkinControls()

void NpcDialog::createSkinControls ( )
private

Definition at line 1274 of file npcdialog.cpp.

References BasicContainer2::add(), Widget::addActionListener(), BrowserBox::addRow(), Button::adjustSize(), AutoRelease_true, BUTTON_SKIN, NpcDialogMenuInfo::buttons, config, deleteSkinControls(), FOR_EACH, Theme::getImageFromTheme(), Configuration::getIntValue(), Gui::getNpcFont(), gui, NpcTextInfo::height, NpcButtonInfo::image, NpcButtonInfo::imageHeight, NpcDialogMenuInfo::images, NpcButtonInfo::imageWidth, Actions::info(), Button::loadImageSet(), mDialogInfo, NpcDialogInfo::menu, mItemLinkHandler, mSkinContainer, NpcImageInfo::name, NpcButtonInfo::name, Opaque_false, Opaque_true, Widget::setActionEventId(), Button::setCaption(), BrowserBox::setEnableKeys(), BrowserBox::setEnableTabs(), Widget::setFont(), Widget::setHeight(), Button::setImageHeight(), Button::setImageWidth(), BrowserBox::setLinkHandler(), BrowserBox::setMaxRow(), BrowserBox::setOpaque(), Widget::setPosition(), BrowserBox::setProcessVars(), Widget::setWidth(), splitToStringVector(), NpcTextInfo::text, NpcDialogMenuInfo::texts, NpcButtonInfo::value, NpcTextInfo::width, NpcImageInfo::x, NpcTextInfo::x, NpcButtonInfo::x, NpcImageInfo::y, NpcTextInfo::y, and NpcButtonInfo::y.

Referenced by placeSkinControls().

1275 {
1277 
1278  if (mDialogInfo == nullptr)
1279  return;
1280 
1281  FOR_EACH (STD_VECTOR<NpcImageInfo*>::const_iterator,
1282  it,
1284  {
1285  const NpcImageInfo *const info = *it;
1286  Image *const image = Theme::getImageFromTheme(info->name);
1287  if (image != nullptr)
1288  {
1289  Icon *const icon = new Icon(this, image, AutoRelease_true);
1290  icon->setPosition(info->x, info->y);
1291  mSkinContainer->add(icon);
1292  }
1293  }
1294  FOR_EACH (STD_VECTOR<NpcTextInfo*>::const_iterator,
1295  it,
1297  {
1298  const NpcTextInfo *const info = *it;
1299  BrowserBox *box = new BrowserBox(this,
1300  Opaque_true,
1301  "browserbox.xml");
1302  box->setOpaque(Opaque_false);
1303  box->setMaxRow(config.getIntValue("ChatLogLength"));
1305  box->setProcessVars(true);
1306  box->setFont(gui->getNpcFont());
1307  box->setEnableKeys(true);
1308  box->setEnableTabs(true);
1309  box->setPosition(info->x, info->y);
1310  mSkinContainer->add(box);
1311  box->setWidth(info->width);
1312  box->setHeight(info->height);
1313  StringVect parts;
1314  splitToStringVector(parts, info->text, '\n');
1315  FOR_EACH (StringVectCIter, it2, parts)
1316  {
1317  box->addRow(*it2,
1318  false);
1319  }
1320  }
1321  FOR_EACH (STD_VECTOR<NpcButtonInfo*>::const_iterator,
1322  it,
1324  {
1325  const NpcButtonInfo *const info = *it;
1326  Button *const button = new Button(this,
1327  BUTTON_SKIN);
1328  button->setCaption(info->name);
1329  button->setActionEventId("skin_" + info->value);
1330  button->addActionListener(this);
1331  button->setPosition(info->x, info->y);
1332  if (!info->image.empty())
1333  {
1334  button->setImageWidth(info->imageWidth);
1335  button->setImageHeight(info->imageHeight);
1336  button->loadImageSet(info->image);
1337  }
1338  mSkinContainer->add(button);
1339  button->adjustSize();
1340  }
1341 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
void deleteSkinControls()
Definition: npcdialog.cpp:1269
std::string value
Definition: npcbuttoninfo.h:44
void loadImageSet(const std::string &imageName)
Definition: button.cpp:394
void setEnableKeys(const bool n)
Definition: browserbox.h:138
void setWidth(const int width)
Definition: widget.cpp:132
StringVect::const_iterator StringVectCIter
Definition: stringvector.h:30
void splitToStringVector(StringVect &tokens, const std::string &text, const char separator)
Gui * gui
Definition: gui.cpp:110
std::string name
Definition: npcbuttoninfo.h:43
std::vector< NpcButtonInfo * > buttons
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:251
void setImageHeight(const int height)
Definition: button.h:260
Definition: button.h:96
Configuration config
std::vector< NpcTextInfo * > texts
int getIntValue(const std::string &key) const
void setActionEventId(const std::string &actionEventId)
Definition: widget.h:595
std::vector< std::string > StringVect
Definition: stringvector.h:28
void adjustSize()
Definition: button.cpp:798
std::string image
Definition: npcbuttoninfo.h:45
void setCaption(const std::string &caption)
Definition: button.h:213
Definition: icon.h:39
std::string text
Definition: npctextinfo.h:41
const std::string BUTTON_SKIN
Definition: button.h:88
bool info(InputEvent &event)
Definition: commands.cpp:56
const NpcDialogInfo * mDialogInfo
Definition: npcdialog.h:317
static Image * getImageFromTheme(const std::string &path)
Definition: theme.cpp:654
virtual void add(Widget *const widget)
void setProcessVars(const bool n)
Definition: browserbox.h:132
void setEnableTabs(const bool n)
Definition: browserbox.h:141
const bool Opaque_false
Definition: opaque.h:29
void setImageWidth(const int width)
Definition: button.h:257
void setPosition(const int x, const int y)
Definition: widget.cpp:160
void setHeight(const int height)
Definition: widget.cpp:139
Container * mSkinContainer
Definition: npcdialog.h:287
void setMaxRow(unsigned max)
Definition: browserbox.h:80
void addRow(const std::string &row, const bool atTop)
Definition: browserbox.cpp:170
void setLinkHandler(LinkHandler *linkHandler)
Definition: browserbox.cpp:165
void setFont(Font *const font)
Definition: widget.cpp:348
const bool Opaque_true
Definition: opaque.h:29
ItemLinkHandler * mItemLinkHandler
Definition: npcdialog.h:289
Definition: image.h:61
Font * getNpcFont() const
Definition: gui.h:177
const bool AutoRelease_true
Definition: autorelease.h:29
void setOpaque(Opaque opaque)
Definition: browserbox.h:74
std::vector< NpcImageInfo * > images
NpcDialogMenuInfo menu
Definition: npcdialoginfo.h:41
std::string name
Definition: npcimageinfo.h:39

◆ deleteSkinControls()

void NpcDialog::deleteSkinControls ( )
private

Definition at line 1269 of file npcdialog.cpp.

References mSkinContainer, and Container::removeControls().

Referenced by createSkinControls(), and ~NpcDialog().

1270 {
1272 }
void removeControls()
Definition: container.cpp:42
Container * mSkinContainer
Definition: npcdialog.h:287

◆ destroyAll()

static void NpcDialog::destroyAll ( )
static

Closes all instances and destroy also net handler dialogs.

Referenced by isActive().

◆ getActive()

NpcDialog * NpcDialog::getActive ( )
static

Returns the first active instance. Useful for pushing user interaction.

Definition at line 851 of file npcdialog.cpp.

References FOR_EACH, and instances.

Referenced by Actions::closeMoveNpcDialog(), Actions::getAmountFromEvent(), Game::handleMove(), isActive(), and InputManager::updateConditionMask().

852 {
853  if (instances.size() == 1)
854  return instances.front();
855 
856  FOR_EACH (DialogList::const_iterator, it, instances)
857  {
858  if (((*it) != nullptr) && (*it)->isFocused())
859  return (*it);
860  }
861 
862  return nullptr;
863 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
static DialogList instances
Definition: npcdialog.h:247

◆ getElementAt()

std::string NpcDialog::getElementAt ( int  i)
virtual

Returns the name of item number i of the choices list.

Implements ListModel.

Definition at line 675 of file npcdialog.cpp.

References mItems.

676 {
677  return mItems[i];
678 }
StringVect mItems
Definition: npcdialog.h:283

◆ getImageAt()

const Image * NpcDialog::getImageAt ( int  i)
virtual

Returns the image of item number i of the choices list.

Implements ExtendedListModel.

Definition at line 680 of file npcdialog.cpp.

References mImages.

681 {
682  return mImages[i];
683 }
std::vector< Image * > mImages
Definition: npcdialog.h:284

◆ getInputState()

NpcInputStateT NpcDialog::getInputState ( )
inline

Definition at line 236 of file npcdialog.h.

References copyToClipboard(), mInputState, x, and y.

Referenced by InventoryWindow::moveItemToCraft(), and PopupMenu::showPopup().

237  { return mInputState; }
NpcInputStateT mInputState
Definition: npcdialog.h:311

◆ getNumberOfElements()

int NpcDialog::getNumberOfElements ( )
virtual

Returns the number of items in the choices list.

Implements ListModel.

Definition at line 670 of file npcdialog.cpp.

References CAST_S32, and mItems.

671 {
672  return CAST_S32(mItems.size());
673 }
StringVect mItems
Definition: npcdialog.h:283
#define CAST_S32
Definition: cast.h:29

◆ integerRequest()

void NpcDialog::integerRequest ( const int  defaultValue,
const int  min,
const int  max 
)

Requests a interger from the user.

Definition at line 778 of file npcdialog.cpp.

References buildLayout(), NpcActionState::INPUT, NpcInputState::INTEGER, mActionState, mDefaultInt, mInputState, mIntField, IntTextField::setRange(), and IntTextField::setValue().

Referenced by Ea::NpcRecv::processNpcIntInput().

781 {
784  mDefaultInt = defaultValue;
785  mIntField->setRange(min, max);
786  mIntField->setValue(defaultValue);
787  buildLayout();
788 }
void setValue(const int value)
NpcActionStateT mActionState
Definition: npcdialog.h:312
IntTextField * mIntField
Definition: npcdialog.h:293
void buildLayout()
Definition: npcdialog.cpp:1051
void setRange(const int minimum, const int maximum)
int mDefaultInt
Definition: npcdialog.h:273
NpcInputStateT mInputState
Definition: npcdialog.h:311

◆ isActive()

static bool NpcDialog::isActive ( )
inlinestatic

Returns true if any instances exist.

Definition at line 190 of file npcdialog.h.

References A_WARN_UNUSED, clearRows(), closeAll(), destroyAll(), getActive(), instances, logic(), mousePressed(), refocus(), restoreCamera(), saveCamera(), setAvatarAction(), setAvatarDirection(), and showAvatar().

Referenced by PlayerInfo::isTalking().

191  { return !instances.empty(); }
static DialogList instances
Definition: npcdialog.h:247

◆ isAnyInputFocused()

bool NpcDialog::isAnyInputFocused ( )
static

Definition at line 767 of file npcdialog.cpp.

References FOR_EACH, and instances.

Referenced by InputManager::updateConditionMask().

768 {
769  FOR_EACH (DialogList::const_iterator, it, instances)
770  {
771  if (((*it) != nullptr) && (*it)->isInputFocused())
772  return true;
773  }
774 
775  return false;
776 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
static DialogList instances
Definition: npcdialog.h:247

◆ isCloseState()

int NpcDialog::isCloseState ( ) const
inline

Definition at line 227 of file npcdialog.h.

References addCraftItem(), NpcActionState::CLOSE, ServerCommandType::item, mActionState, and setSkin().

Referenced by Actions::closeMoveNpcDialog().

228  { return static_cast<int>(mActionState == NpcActionState::CLOSE); }
NpcActionStateT mActionState
Definition: npcdialog.h:312

◆ isInputFocused()

bool NpcDialog::isInputFocused ( ) const

Definition at line 761 of file npcdialog.cpp.

References Widget::isFocused(), mIntField, mItemList, and mTextField.

762 {
763  return mTextField->isFocused() || mIntField->isFocused()
764  || mItemList->isFocused();
765 }
virtual bool isFocused() const
Definition: widget.cpp:183
IntTextField * mIntField
Definition: npcdialog.h:293
ExtendedListBox * mItemList
Definition: npcdialog.h:285
TextField * mTextField
Definition: npcdialog.h:292

◆ isTextInputFocused()

bool NpcDialog::isTextInputFocused ( ) const

Definition at line 756 of file npcdialog.cpp.

References Widget::isFocused(), and mTextField.

757 {
758  return mTextField->isFocused();
759 }
virtual bool isFocused() const
Definition: widget.cpp:183
TextField * mTextField
Definition: npcdialog.h:292

◆ itemCraftRequest()

void NpcDialog::itemCraftRequest ( const int  size)

◆ itemIndexRequest()

void NpcDialog::itemIndexRequest ( const int  size)

◆ itemRequest()

void NpcDialog::itemRequest ( const int  size)

Definition at line 790 of file npcdialog.cpp.

References buildLayout(), NpcActionState::INPUT, NpcInputState::ITEM, mActionState, mInputState, mInventory, and Inventory::resize().

Referenced by Ea::NpcRecv::processNpcCommand().

791 {
795  buildLayout();
796 }
void resize(const unsigned int newSize)
Definition: inventory.cpp:396
NpcActionStateT mActionState
Definition: npcdialog.h:312
void buildLayout()
Definition: npcdialog.cpp:1051
Inventory * mInventory
Definition: npcdialog.h:306
NpcInputStateT mInputState
Definition: npcdialog.h:311

◆ logic()

void NpcDialog::logic ( )
virtual

Called for all widgets in the gui each time Gui::logic is called. You can do logic stuff here like playing an animation.

See also
Gui::logic

Reimplemented from BasicContainer.

Definition at line 1190 of file npcdialog.cpp.

References BLOCK_END, BLOCK_START, buildLayout(), CAST_S32, Sprite::getHeight(), Window::getPadding(), Sprite::getWidth(), Widget::getWidth(), BasicContainer::logic(), Being::logic(), mAvatarBeing, mPlayerBox, mShowAvatar, CompoundSprite::mSprites, Widget::setHeight(), and Widget::setWidth().

Referenced by isActive().

1191 {
1192  BLOCK_START("NpcDialog::logic")
1193  Window::logic();
1194  if (mShowAvatar && (mAvatarBeing != nullptr))
1195  {
1196  mAvatarBeing->logic();
1197  if (mPlayerBox->getWidth() < CAST_S32(3 * getPadding()))
1198  {
1199  const Sprite *const sprite = mAvatarBeing->mSprites[0];
1200  if (sprite != nullptr)
1201  {
1202  mPlayerBox->setWidth(sprite->getWidth() + 2 * getPadding());
1203  mPlayerBox->setHeight(sprite->getHeight() + 2 * getPadding());
1204  buildLayout();
1205  }
1206  }
1207  }
1208  BLOCK_END("NpcDialog::logic")
1209 }
int getWidth() const
Definition: widget.h:220
void setWidth(const int width)
Definition: widget.cpp:132
Definition: sprite.h:32
Definition: window.h:98
#define BLOCK_START(name)
Definition: perfomance.h:78
if(!vert) return
#define BLOCK_END(name)
Definition: perfomance.h:79
void buildLayout()
Definition: npcdialog.cpp:1051
#define CAST_S32
Definition: cast.h:29
void logic()
Definition: npcdialog.cpp:1190
virtual int getHeight() const =0
std::vector< Sprite * > mSprites
Being * mAvatarBeing
Definition: npcdialog.h:316
virtual int getWidth() const =0
void setHeight(const int height)
Definition: widget.cpp:139
bool mShowAvatar
Definition: npcdialog.h:322
void logic()
Definition: being.cpp:1833
PlayerBox * mPlayerBox
Definition: npcdialog.h:315
int getPadding() const
Definition: window.h:503

◆ mousePressed()

void NpcDialog::mousePressed ( MouseEvent event)
virtual

Starts window resizing when appropriate.

Reimplemented from Window.

Definition at line 1228 of file npcdialog.cpp.

References MouseEvent::getButton(), Viewport::mMouseX, Viewport::mMouseY, mNpcId, Window::mousePressed(), mTextBox, popupMenu, MouseButton::RIGHT, PopupMenu::showNpcDialogPopup(), and viewport.

Referenced by isActive().

1229 {
1230  Window::mousePressed(event);
1231  if (event.getButton() == MouseButton::RIGHT
1232  && event.getSource() == mTextBox)
1233  {
1234  event.consume();
1235  if (popupMenu != nullptr)
1236  {
1238  viewport->mMouseX,
1239  viewport->mMouseY);
1240  }
1241  }
1242 }
void showNpcDialogPopup(const BeingId npcId, const int x, const int y)
Definition: popupmenu.cpp:2244
BeingId mNpcId
Definition: npcdialog.h:271
MouseButtonT getButton() const
Definition: mouseevent.h:115
int mMouseX
Definition: viewport.h:153
BrowserBox * mTextBox
Definition: npcdialog.h:277
PopupMenu * popupMenu
Definition: popupmenu.cpp:102
int mMouseY
Definition: viewport.h:154
void mousePressed(MouseEvent &event)
Definition: window.cpp:835
Viewport * viewport
Definition: viewport.cpp:35

◆ move()

void NpcDialog::move ( const int  amount)

Definition at line 814 of file npcdialog.cpp.

References ListBox::getSelected(), IntTextField::getValue(), NpcActionState::INPUT, NpcInputState::INTEGER, NpcInputState::ITEM, NpcInputState::ITEM_CRAFT, NpcInputState::ITEM_INDEX, NpcInputState::LIST, mActionState, mInputState, mIntField, mItemList, NpcInputState::NONE, ListBox::setSelected(), IntTextField::setValue(), and NpcInputState::STRING.

815 {
817  return;
818 
819  switch (mInputState)
820  {
822  mIntField->setValue(mIntField->getValue() + amount);
823  break;
824  case NpcInputState::LIST:
826  break;
827  case NpcInputState::NONE:
829  case NpcInputState::ITEM:
832  default:
833  break;
834  }
835 }
void setSelected(const int selected)
Definition: listbox.cpp:398
void setValue(const int value)
NpcActionStateT mActionState
Definition: npcdialog.h:312
IntTextField * mIntField
Definition: npcdialog.h:293
int getSelected() const
Definition: listbox.h:167
int getValue() const
NpcInputStateT mInputState
Definition: npcdialog.h:311
ExtendedListBox * mItemList
Definition: npcdialog.h:285

◆ nextDialog()

void NpcDialog::nextDialog ( )

Notifies the server that client has performed a next action.

Definition at line 659 of file npcdialog.cpp.

References mNpcId, Net::NpcHandler::nextDialog(), and npcHandler.

Referenced by action().

660 {
662 }
BeingId mNpcId
Definition: npcdialog.h:271
virtual void nextDialog(const BeingId npcId) const =0
Net::NpcHandler * npcHandler
Definition: net.cpp:90

◆ optionChanged()

void NpcDialog::optionChanged ( const std::string &  name)
virtual

Called when an option changed. The config listener will have to be registered to the option name first.

Implements ConfigListener.

Definition at line 845 of file npcdialog.cpp.

References config, Configuration::getBoolValue(), and mLogInteraction.

846 {
847  if (name == "logNpcInGui")
848  mLogInteraction = config.getBoolValue("logNpcInGui");
849 }
Configuration config
bool getBoolValue(const std::string &key) const
bool mLogInteraction
Definition: npcdialog.h:323

◆ parseListItems()

void NpcDialog::parseListItems ( const std::string &  itemString)

Fills the options list for an NPC dialog.

Parameters
itemStringA string with the options separated with colons.

Definition at line 705 of file npcdialog.cpp.

References Loader::getImage(), Configuration::getStringValue(), mImages, mItemList, mItems, pathJoin(), paths, Widget::requestFocus(), and ListBox::setSelected().

Referenced by Ea::NpcRecv::processNpcChoice().

706 {
707  std::istringstream iss(itemString);
708  std::string tmp;
709  const std::string path = paths.getStringValue("guiIcons");
710  while (getline(iss, tmp, ':'))
711  {
712  if (tmp.empty())
713  continue;
714  const size_t pos = tmp.find('|');
715  if (pos == std::string::npos)
716  {
717  mItems.push_back(tmp);
718  mImages.push_back(nullptr);
719  }
720  else
721  {
722  mItems.push_back(tmp.substr(pos + 1));
723  Image *const img = Loader::getImage(pathJoin(path,
724  std::string(tmp.substr(0, pos)).append(".png")));
725  mImages.push_back(img);
726  }
727  }
728 
729  if (!mItems.empty())
730  {
733  }
734  else
735  {
736  mItemList->setSelected(-1);
737  }
738 }
std::string getStringValue(const std::string &key) const
void setSelected(const int selected)
Definition: listbox.cpp:398
std::string pathJoin(std::string str1, const std::string &str2)
StringVect mItems
Definition: npcdialog.h:283
virtual void requestFocus()
Definition: widget.cpp:203
Image * getImage(const std::string &idPath)
Definition: imageloader.cpp:85
std::vector< Image * > mImages
Definition: npcdialog.h:284
ExtendedListBox * mItemList
Definition: npcdialog.h:285
Configuration paths
Definition: image.h:61

◆ placeIntInputControls()

void NpcDialog::placeIntInputControls ( )
private

Definition at line 968 of file npcdialog.cpp.

References mButton, mClearButton, mIntField, mMinusButton, mPlayerBox, mPlusButton, mResetButton, mScrollArea, mShowAvatar, and Window::place().

Referenced by buildLayout().

969 {
970  if (mShowAvatar)
971  {
972  place(0, 0, mPlayerBox, 1, 1);
973  place(1, 0, mScrollArea, 6, 3);
974  place(1, 3, mMinusButton, 1, 1);
975  place(2, 3, mIntField, 4, 1);
976  place(6, 3, mPlusButton, 1, 1);
977  place(1, 4, mResetButton, 2, 1);
978  place(3, 4, mClearButton, 2, 1);
979  place(5, 4, mButton, 2, 1);
980  }
981  else
982  {
983  place(0, 0, mScrollArea, 6, 3);
984  place(0, 3, mMinusButton, 1, 1);
985  place(1, 3, mIntField, 4, 1);
986  place(5, 3, mPlusButton, 1, 1);
987  place(0, 4, mResetButton, 2, 1);
988  place(2, 4, mClearButton, 2, 1);
989  place(4, 4, mButton, 2, 1);
990  }
991 }
LayoutCell & place(const int x, const int y, Widget *const wg, const int w, const int h)
Definition: window.cpp:1383
ScrollArea * mScrollArea
Definition: npcdialog.h:278
Button * mResetButton
Definition: npcdialog.h:304
IntTextField * mIntField
Definition: npcdialog.h:293
Button * mClearButton
Definition: npcdialog.h:296
bool mShowAvatar
Definition: npcdialog.h:322
Button * mMinusButton
Definition: npcdialog.h:295
Button * mButton
Definition: npcdialog.h:299
PlayerBox * mPlayerBox
Definition: npcdialog.h:315
Button * mPlusButton
Definition: npcdialog.h:294

◆ placeItemInputControls()

void NpcDialog::placeItemInputControls ( )
private

Definition at line 993 of file npcdialog.cpp.

References NpcInventoryInfo::cell, NpcInventoryInfo::columns, NpcDialogInfo::hideText, NpcDialogInfo::inventory, NpcInputState::ITEM_CRAFT, mButton, mButton3, mClearButton, mComplexInventory, mDialogInfo, mInputState, mInventory, mItemContainer, mItemScrollArea, mPlayerBox, mScrollArea, mShowAvatar, Window::place(), ItemContainer::setCellBackgroundImage(), ItemContainer::setInventory(), and ItemContainer::setMaxColumns().

Referenced by buildLayout().

994 {
995  if (mDialogInfo != nullptr)
996  {
999  }
1000  else
1001  {
1002  mItemContainer->setCellBackgroundImage("inventory_cell.xml");
1003  mItemContainer->setMaxColumns(10000);
1004  }
1005 
1008  else
1010 
1011  if ((mDialogInfo != nullptr) && mDialogInfo->hideText)
1012  {
1013  if (mShowAvatar)
1014  {
1015  place(0, 0, mPlayerBox, 1, 1);
1016  place(1, 0, mItemScrollArea, 7, 3);
1017  place(1, 3, mButton3, 2, 1);
1018  place(3, 3, mClearButton, 2, 1);
1019  place(5, 3, mButton, 2, 1);
1020  }
1021  else
1022  {
1023  place(0, 0, mItemScrollArea, 6, 3);
1024  place(0, 3, mButton3, 2, 1);
1025  place(2, 3, mClearButton, 2, 1);
1026  place(4, 3, mButton, 2, 1);
1027  }
1028  }
1029  else
1030  {
1031  if (mShowAvatar)
1032  {
1033  place(0, 0, mPlayerBox, 1, 1);
1034  place(1, 0, mScrollArea, 6, 3);
1035  place(0, 3, mItemScrollArea, 7, 3);
1036  place(1, 6, mButton3, 2, 1);
1037  place(3, 6, mClearButton, 2, 1);
1038  place(5, 6, mButton, 2, 1);
1039  }
1040  else
1041  {
1042  place(0, 0, mScrollArea, 6, 3);
1043  place(0, 3, mItemScrollArea, 6, 3);
1044  place(0, 6, mButton3, 2, 1);
1045  place(2, 6, mClearButton, 2, 1);
1046  place(4, 6, mButton, 2, 1);
1047  }
1048  }
1049 }
LayoutCell & place(const int x, const int y, Widget *const wg, const int w, const int h)
Definition: window.cpp:1383
ComplexInventory * mComplexInventory
Definition: npcdialog.h:307
ItemContainer * mItemContainer
Definition: npcdialog.h:308
ScrollArea * mScrollArea
Definition: npcdialog.h:278
Button * mButton3
Definition: npcdialog.h:301
void setCellBackgroundImage(const std::string &xmlName)
NpcInventoryInfo inventory
Definition: npcdialoginfo.h:42
const NpcDialogInfo * mDialogInfo
Definition: npcdialog.h:317
void setMaxColumns(const int maxColumns)
void setInventory(Inventory *const inventory)
Button * mClearButton
Definition: npcdialog.h:296
Inventory * mInventory
Definition: npcdialog.h:306
NpcInputStateT mInputState
Definition: npcdialog.h:311
bool mShowAvatar
Definition: npcdialog.h:322
ScrollArea * mItemScrollArea
Definition: npcdialog.h:309
Button * mButton
Definition: npcdialog.h:299
PlayerBox * mPlayerBox
Definition: npcdialog.h:315

◆ placeMenuControls()

void NpcDialog::placeMenuControls ( )
private

Definition at line 891 of file npcdialog.cpp.

References mButton, mButton2, mClearButton, mListScrollArea, mPlayerBox, mScrollArea, mShowAvatar, and Window::place().

Referenced by buildLayout().

892 {
893  if (mShowAvatar)
894  {
895  place(0, 0, mPlayerBox, 1, 1);
896  place(1, 0, mScrollArea, 6, 3);
897  place(0, 3, mListScrollArea, 7, 3);
898  place(1, 6, mButton2, 2, 1);
899  place(3, 6, mClearButton, 2, 1);
900  place(5, 6, mButton, 2, 1);
901  }
902  else
903  {
904  place(0, 0, mScrollArea, 6, 3);
905  place(0, 3, mListScrollArea, 6, 3);
906  place(0, 6, mButton2, 2, 1);
907  place(2, 6, mClearButton, 2, 1);
908  place(4, 6, mButton, 2, 1);
909  }
910 }
LayoutCell & place(const int x, const int y, Widget *const wg, const int w, const int h)
Definition: window.cpp:1383
Button * mButton2
Definition: npcdialog.h:300
ScrollArea * mScrollArea
Definition: npcdialog.h:278
Button * mClearButton
Definition: npcdialog.h:296
bool mShowAvatar
Definition: npcdialog.h:322
Button * mButton
Definition: npcdialog.h:299
ScrollArea * mListScrollArea
Definition: npcdialog.h:286
PlayerBox * mPlayerBox
Definition: npcdialog.h:315

◆ placeNormalControls()

void NpcDialog::placeNormalControls ( )
private

Definition at line 874 of file npcdialog.cpp.

References mButton, mClearButton, mPlayerBox, mScrollArea, mShowAvatar, and Window::place().

Referenced by buildLayout().

875 {
876  if (mShowAvatar)
877  {
878  place(0, 0, mPlayerBox, 1, 1);
879  place(1, 0, mScrollArea, 5, 3);
880  place(4, 3, mClearButton, 1, 1);
881  place(5, 3, mButton, 1, 1);
882  }
883  else
884  {
885  place(0, 0, mScrollArea, 5, 3);
886  place(3, 3, mClearButton, 1, 1);
887  place(4, 3, mButton, 1, 1);
888  }
889 }
LayoutCell & place(const int x, const int y, Widget *const wg, const int w, const int h)
Definition: window.cpp:1383
ScrollArea * mScrollArea
Definition: npcdialog.h:278
Button * mClearButton
Definition: npcdialog.h:296
bool mShowAvatar
Definition: npcdialog.h:322
Button * mButton
Definition: npcdialog.h:299
PlayerBox * mPlayerBox
Definition: npcdialog.h:315

◆ placeSkinControls()

void NpcDialog::placeSkinControls ( )
private

Definition at line 912 of file npcdialog.cpp.

References createSkinControls(), NpcDialogInfo::hideText, mButton2, mDialogInfo, mPlayerBox, mScrollArea, mShowAvatar, mSkinScrollArea, and Window::place().

Referenced by buildLayout().

913 {
915  if ((mDialogInfo != nullptr) && mDialogInfo->hideText)
916  {
917  if (mShowAvatar)
918  {
919  place(0, 0, mPlayerBox, 1, 1);
920  place(1, 0, mSkinScrollArea, 7, 3);
921  place(1, 3, mButton2, 2, 1);
922  }
923  else
924  {
925  place(0, 0, mSkinScrollArea, 6, 3);
926  place(0, 3, mButton2, 2, 1);
927  }
928  }
929  else
930  {
931  if (mShowAvatar)
932  {
933  place(0, 0, mPlayerBox, 1, 1);
934  place(1, 0, mScrollArea, 6, 3);
935  place(0, 3, mSkinScrollArea, 7, 3);
936  place(1, 6, mButton2, 2, 1);
937  }
938  else
939  {
940  place(0, 0, mScrollArea, 6, 3);
941  place(0, 3, mSkinScrollArea, 6, 3);
942  place(0, 6, mButton2, 2, 1);
943  }
944  }
945 }
LayoutCell & place(const int x, const int y, Widget *const wg, const int w, const int h)
Definition: window.cpp:1383
Button * mButton2
Definition: npcdialog.h:300
ScrollArea * mScrollArea
Definition: npcdialog.h:278
const NpcDialogInfo * mDialogInfo
Definition: npcdialog.h:317
void createSkinControls()
Definition: npcdialog.cpp:1274
ScrollArea * mSkinScrollArea
Definition: npcdialog.h:288
bool mShowAvatar
Definition: npcdialog.h:322
PlayerBox * mPlayerBox
Definition: npcdialog.h:315

◆ placeTextInputControls()

void NpcDialog::placeTextInputControls ( )
private

Definition at line 947 of file npcdialog.cpp.

References mButton, mClearButton, mPlayerBox, mResetButton, mScrollArea, mShowAvatar, mTextField, and Window::place().

Referenced by buildLayout().

948 {
949  if (mShowAvatar)
950  {
951  place(0, 0, mPlayerBox, 1, 1);
952  place(1, 0, mScrollArea, 6, 3);
953  place(1, 3, mTextField, 6, 1);
954  place(1, 4, mResetButton, 2, 1);
955  place(3, 4, mClearButton, 2, 1);
956  place(5, 4, mButton, 2, 1);
957  }
958  else
959  {
960  place(0, 0, mScrollArea, 6, 3);
961  place(0, 3, mTextField, 6, 1);
962  place(0, 4, mResetButton, 2, 1);
963  place(2, 4, mClearButton, 2, 1);
964  place(4, 4, mButton, 2, 1);
965  }
966 }
LayoutCell & place(const int x, const int y, Widget *const wg, const int w, const int h)
Definition: window.cpp:1383
ScrollArea * mScrollArea
Definition: npcdialog.h:278
Button * mResetButton
Definition: npcdialog.h:304
Button * mClearButton
Definition: npcdialog.h:296
bool mShowAvatar
Definition: npcdialog.h:322
Button * mButton
Definition: npcdialog.h:299
PlayerBox * mPlayerBox
Definition: npcdialog.h:315
TextField * mTextField
Definition: npcdialog.h:292

◆ postInit()

void NpcDialog::postInit ( )
virtual

Reimplemented from Window.

Definition at line 223 of file npcdialog.cpp.

References actorManager, Configuration::addListener(), config, Window::enableVisibleSound(), ActorManager::findBeing(), fromInt, NPCDB::getAvatarFor(), Being::getName(), Being::getSubType(), mNpcId, SoundManager::playGuiSound(), Window::postInit(), Widget::requestFocus(), Window::setCaption(), setVisible(), showAvatar(), SOUND_SHOW_WINDOW, soundManager, and Visible_true.

224 {
227  requestFocus();
228  enableVisibleSound(true);
230 
231  if (actorManager != nullptr)
232  {
233  const Being *const being = actorManager->findBeing(mNpcId);
234  if (being != nullptr)
235  {
237  being->getSubType(), BeingTypeId)));
238  setCaption(being->getName());
239  }
240  }
241 
242  config.addListener("logNpcInGui", this);
243 }
const bool Visible_true
Definition: visible.h:29
#define fromInt(val, name)
Definition: intdefines.h:45
BeingId mNpcId
Definition: npcdialog.h:271
SoundManager soundManager
Configuration config
void setVisible(Visible visible)
Definition: npcdialog.cpp:837
void addListener(const std::string &key, ConfigListener *const listener)
BeingTypeId getAvatarFor(const BeingTypeId id)
Definition: npcdb.cpp:200
virtual void requestFocus()
Definition: widget.cpp:203
Being * findBeing(const BeingId id) const
void showAvatar(const BeingTypeId avatarId)
Definition: npcdialog.cpp:1129
const std::string & getName() const
Definition: being.h:231
void enableVisibleSound(bool b)
Definition: window.h:480
static const std::string SOUND_SHOW_WINDOW
Definition: sound.h:36
void setCaption(const std::string &caption)
Definition: window.h:530
int BeingTypeId
Definition: beingtypeid.h:29
Definition: being.h:93
BeingTypeId getSubType() const
Definition: being.h:399
void postInit()
Definition: window.cpp:248
ActorManager * actorManager
void playGuiSound(const std::string &name)

◆ refocus()

void NpcDialog::refocus ( )

Definition at line 740 of file npcdialog.cpp.

References mItemList, mItems, and ListBox::refocus().

Referenced by Actions::closeMoveNpcDialog(), and isActive().

741 {
742  if (!mItems.empty())
743  mItemList->refocus();
744 }
StringVect mItems
Definition: npcdialog.h:283
void refocus()
Definition: listbox.cpp:364
ExtendedListBox * mItemList
Definition: npcdialog.h:285

◆ restoreCamera()

void NpcDialog::restoreCamera ( )

Definition at line 1114 of file npcdialog.cpp.

References Settings::cameraMode, CAST_S32, mCameraMode, mCameraX, mCameraY, Viewport::setCameraRelativeX(), Viewport::setCameraRelativeY(), settings, Viewport::toggleCameraMode(), and viewport.

Referenced by closeDialog(), TmwAthena::NpcHandler::getNpc(), EAthena::NpcHandler::getNpc(), isActive(), and Ea::NpcRecv::processNpcCommand().

1115 {
1116  if ((viewport == nullptr) || mCameraMode == -1)
1117  return;
1118 
1121  if (mCameraMode != 0)
1122  {
1125  }
1126  mCameraMode = -1;
1127 }
void setCameraRelativeY(const int n)
Definition: viewport.h:148
void toggleCameraMode()
Definition: viewport.cpp:254
Settings settings
Definition: settings.cpp:31
#define CAST_S32
Definition: cast.h:29
int mCameraX
Definition: npcdialog.h:320
int mCameraY
Definition: npcdialog.h:321
unsigned int cameraMode
Definition: settings.h:142
int mCameraMode
Definition: npcdialog.h:319
void setCameraRelativeX(const int n)
Definition: viewport.h:145
Viewport * viewport
Definition: viewport.cpp:35

◆ restoreVirtuals()

void NpcDialog::restoreVirtuals ( )
private

Definition at line 1343 of file npcdialog.cpp.

References PlayerInfo::getInventory(), and Inventory::restoreVirtuals().

Referenced by action().

1344 {
1345  Inventory *const inventory = PlayerInfo::getInventory();
1346  if (inventory != nullptr)
1347  inventory->restoreVirtuals();
1348 }
void restoreVirtuals()
Definition: inventory.cpp:499
Inventory * getInventory()
Definition: playerinfo.cpp:193

◆ saveCamera()

void NpcDialog::saveCamera ( )

Definition at line 1104 of file npcdialog.cpp.

References Settings::cameraMode, CAST_S32, Viewport::getCameraRelativeX(), Viewport::getCameraRelativeY(), mCameraMode, mCameraX, mCameraY, settings, and viewport.

Referenced by TmwAthena::NpcHandler::getNpc(), EAthena::NpcHandler::getNpc(), and isActive().

1105 {
1106  if ((viewport == nullptr) || mCameraMode >= 0)
1107  return;
1108 
1112 }
int getCameraRelativeY() const
Definition: viewport.h:142
Settings settings
Definition: settings.cpp:31
#define CAST_S32
Definition: cast.h:29
int mCameraX
Definition: npcdialog.h:320
int mCameraY
Definition: npcdialog.h:321
unsigned int cameraMode
Definition: settings.h:142
int mCameraMode
Definition: npcdialog.h:319
int getCameraRelativeX() const
Definition: viewport.h:139
Viewport * viewport
Definition: viewport.cpp:35

◆ setAvatarAction()

void NpcDialog::setAvatarAction ( const int  actionId)

Definition at line 1183 of file npcdialog.cpp.

References PlayerBox::getBeing(), mPlayerBox, and Being::setAction().

Referenced by isActive(), and Ea::NpcRecv::processNpcCommand().

1184 {
1185  Being *const being = mPlayerBox->getBeing();
1186  if (being != nullptr)
1187  being->setAction(static_cast<BeingActionT>(actionId), 0);
1188 }
virtual void setAction(const BeingActionT &action, const int attackId)
Definition: being.cpp:1553
Definition: being.h:93
PlayerBox * mPlayerBox
Definition: npcdialog.h:315
Being * getBeing()
Definition: playerbox.h:91

◆ setAvatarDirection()

void NpcDialog::setAvatarDirection ( const uint8_t  direction)

Definition at line 1176 of file npcdialog.cpp.

References PlayerBox::getBeing(), mPlayerBox, and Being::setDirection().

Referenced by isActive(), and Ea::NpcRecv::processNpcCommand().

1177 {
1178  Being *const being = mPlayerBox->getBeing();
1179  if (being != nullptr)
1180  being->setDirection(direction);
1181 }
virtual void setDirection(const uint8_t direction)
Definition: being.cpp:1689
Definition: being.h:93
PlayerBox * mPlayerBox
Definition: npcdialog.h:315
Being * getBeing()
Definition: playerbox.h:91

◆ setSkin()

void NpcDialog::setSkin ( const std::string &  skin)

Definition at line 1250 of file npcdialog.cpp.

References NpcDialogDB::getDialog(), Logger::log(), logger, mDialogInfo, and mSkinName.

Referenced by isCloseState(), and EAthena::NpcRecv::processNpcSkin().

1251 {
1252  if (skin.empty())
1253  {
1254  mSkinName = skin;
1255  mDialogInfo = nullptr;
1256  return;
1257  }
1258  const NpcDialogInfo *const dialog = NpcDialogDB::getDialog(skin);
1259  if (dialog == nullptr)
1260  {
1261  logger->log("Error: creating controls for not existing npc dialog %s",
1262  skin.c_str());
1263  return;
1264  }
1265  mSkinName = skin;
1266  mDialogInfo = dialog;
1267 }
Logger * logger
Definition: logger.cpp:88
NpcDialogInfo * getDialog(const std::string &name)
const NpcDialogInfo * mDialogInfo
Definition: npcdialog.h:317
std::string mSkinName
Definition: npcdialog.h:314
void log(const char *const log_text,...)
Definition: logger.cpp:264

◆ setVisible()

void NpcDialog::setVisible ( Visible  visible)
virtual

Overloads window setVisible by Guichan to allow sticky window handling.

Reimplemented from Window.

Definition at line 837 of file npcdialog.cpp.

References Window::scheduleDelete(), Window::setVisible(), and Visible_false.

Referenced by postInit().

838 {
839  Window::setVisible(visible);
840 
841  if (visible == Visible_false)
842  scheduleDelete();
843 }
const bool Visible_false
Definition: visible.h:29
virtual void scheduleDelete()
Definition: window.cpp:830
virtual void setVisible(Visible visible)
Definition: window.cpp:777

◆ showAvatar()

void NpcDialog::showAvatar ( const BeingTypeId  avatarId)

Definition at line 1129 of file npcdialog.cpp.

References ActorType::Avatar, BeingId_zero, BeingTypeId_zero, buildLayout(), Being::createBeing(), delete2, AvatarDB::get(), Sprite::getHeight(), BeingInfo::getHeight(), Sprite::getWidth(), BeingInfo::getWidth(), Actions::info(), Being::logic(), mAvatarBeing, Window::mPadding, mPlayerBox, mShowAvatar, CompoundSprite::mSprites, Widget::setHeight(), PlayerBox::setPlayer(), and Widget::setWidth().

Referenced by isActive(), postInit(), and Ea::NpcRecv::processNpcCommand().

1130 {
1131  const bool needShow = (avatarId != BeingTypeId_zero);
1132  if (needShow)
1133  {
1134  delete mAvatarBeing;
1137  avatarId,
1138  nullptr);
1140  if (!mAvatarBeing->mSprites.empty())
1141  {
1142  mAvatarBeing->logic();
1143  const BeingInfo *const info = AvatarDB::get(avatarId);
1144  const int pad2 = 2 * mPadding;
1145  int width = 0;
1146  if (info != nullptr)
1147  {
1148  width = info->getWidth();
1149  mPlayerBox->setWidth(width + pad2);
1150  mPlayerBox->setHeight(info->getHeight() + pad2);
1151  }
1152  const Sprite *const sprite = mAvatarBeing->mSprites[0];
1153  if ((sprite != nullptr) && (width == 0))
1154  {
1155  mPlayerBox->setWidth(sprite->getWidth() + pad2);
1156  mPlayerBox->setHeight(sprite->getHeight() + pad2);
1157  }
1158  }
1159  }
1160  else
1161  {
1163  mPlayerBox->setPlayer(nullptr);
1164  }
1165  if (needShow != mShowAvatar)
1166  {
1167  mShowAvatar = needShow;
1168  buildLayout();
1169  }
1170  else
1171  {
1172  mShowAvatar = needShow;
1173  }
1174 }
void setPlayer(Being *being)
Definition: playerbox.h:73
int getWidth() const
Definition: beinginfo.h:203
void setWidth(const int width)
Definition: widget.cpp:132
int mPadding
Definition: window.h:617
Definition: sprite.h:32
const BeingTypeId BeingTypeId_zero
Definition: beingtypeid.h:29
int getHeight() const
Definition: beinginfo.h:206
#define delete2(var)
Definition: delete2.h:24
static Being * createBeing(const BeingId id, const ActorTypeT type, const BeingTypeId subtype, Map *const map)
Definition: being.cpp:5575
void buildLayout()
Definition: npcdialog.cpp:1051
virtual int getHeight() const =0
bool info(InputEvent &event)
Definition: commands.cpp:56
std::vector< Sprite * > mSprites
Being * mAvatarBeing
Definition: npcdialog.h:316
virtual int getWidth() const =0
void setHeight(const int height)
Definition: widget.cpp:139
bool mShowAvatar
Definition: npcdialog.h:322
BeingInfo * get(const BeingTypeId id)
Definition: avatardb.cpp:140
void logic()
Definition: being.cpp:1833
const BeingId BeingId_zero
Definition: beingid.h:29
PlayerBox * mPlayerBox
Definition: npcdialog.h:315

◆ showCloseButton()

void NpcDialog::showCloseButton ( )

When called, the widget will show a "Close" button and will close the dialog when clicked.

Definition at line 312 of file npcdialog.cpp.

References buildLayout(), NpcActionState::CLOSE, and mActionState.

Referenced by Ea::NpcRecv::processNpcClose().

313 {
315  buildLayout();
316 }
NpcActionStateT mActionState
Definition: npcdialog.h:312
void buildLayout()
Definition: npcdialog.cpp:1051

◆ showNextButton()

void NpcDialog::showNextButton ( )

When called, the widget will show a "Next" button.

Definition at line 306 of file npcdialog.cpp.

References buildLayout(), mActionState, and NpcActionState::NEXT.

Referenced by Ea::NpcRecv::processNpcNext().

307 {
309  buildLayout();
310 }
NpcActionStateT mActionState
Definition: npcdialog.h:312
void buildLayout()
Definition: npcdialog.cpp:1051

◆ textRequest()

void NpcDialog::textRequest ( const std::string &  defaultText)

Requests a text string from the user.

Definition at line 746 of file npcdialog.cpp.

References buildLayout(), NpcActionState::INPUT, mActionState, mDefaultString, mInputState, mTextField, TextField::setText(), and NpcInputState::STRING.

Referenced by Ea::NpcRecv::processNpcStrInput().

747 {
750  mDefaultString = defaultText;
751  mTextField->setText(defaultText);
752 
753  buildLayout();
754 }
NpcActionStateT mActionState
Definition: npcdialog.h:312
std::string mDefaultString
Definition: npcdialog.h:274
void setText(const std::string &text)
Definition: textfield.cpp:802
void buildLayout()
Definition: npcdialog.cpp:1051
NpcInputStateT mInputState
Definition: npcdialog.h:311
TextField * mTextField
Definition: npcdialog.h:292

Field Documentation

◆ instances

NpcDialog::DialogList NpcDialog::instances
staticprivate

Definition at line 247 of file npcdialog.h.

Referenced by closeAll(), getActive(), isActive(), isAnyInputFocused(), NpcDialog(), and ~NpcDialog().

◆ mActionState

NpcActionStateT NpcDialog::mActionState
private

◆ mAvatarBeing

Being* NpcDialog::mAvatarBeing
private

Definition at line 316 of file npcdialog.h.

Referenced by logic(), and showAvatar().

◆ mButton

Button* NpcDialog::mButton
private

◆ mButton2

Button* NpcDialog::mButton2
private

Definition at line 300 of file npcdialog.h.

Referenced by placeMenuControls(), placeSkinControls(), and ~NpcDialog().

◆ mButton3

Button* NpcDialog::mButton3
private

Definition at line 301 of file npcdialog.h.

Referenced by placeItemInputControls(), and ~NpcDialog().

◆ mCameraMode

int NpcDialog::mCameraMode
private

Definition at line 319 of file npcdialog.h.

Referenced by restoreCamera(), and saveCamera().

◆ mCameraX

int NpcDialog::mCameraX
private

Definition at line 320 of file npcdialog.h.

Referenced by restoreCamera(), and saveCamera().

◆ mCameraY

int NpcDialog::mCameraY
private

Definition at line 321 of file npcdialog.h.

Referenced by restoreCamera(), and saveCamera().

◆ mClearButton

Button* NpcDialog::mClearButton
private

◆ mComplexInventory

ComplexInventory* NpcDialog::mComplexInventory
private

◆ mDefaultInt

int NpcDialog::mDefaultInt
private

Definition at line 273 of file npcdialog.h.

Referenced by action(), and integerRequest().

◆ mDefaultString

std::string NpcDialog::mDefaultString
private

Definition at line 274 of file npcdialog.h.

Referenced by action(), and textRequest().

◆ mDialogInfo

const NpcDialogInfo* NpcDialog::mDialogInfo
private

◆ mImages

std::vector<Image *> NpcDialog::mImages
private

Definition at line 284 of file npcdialog.h.

Referenced by addChoice(), choiceRequest(), getImageAt(), parseListItems(), and ~NpcDialog().

◆ mInputState

NpcInputStateT NpcDialog::mInputState
private

◆ mIntField

IntTextField* NpcDialog::mIntField
private

◆ mInventory

Inventory* NpcDialog::mInventory
private

◆ mItemContainer

ItemContainer* NpcDialog::mItemContainer
private

Definition at line 308 of file npcdialog.h.

Referenced by placeItemInputControls(), and ~NpcDialog().

◆ mItemLinkHandler

ItemLinkHandler* NpcDialog::mItemLinkHandler
private

Definition at line 289 of file npcdialog.h.

Referenced by createSkinControls(), NpcDialog(), and ~NpcDialog().

◆ mItemList

ExtendedListBox* NpcDialog::mItemList
private

◆ mItems

StringVect NpcDialog::mItems
private

◆ mItemScrollArea

ScrollArea* NpcDialog::mItemScrollArea
private

Definition at line 309 of file npcdialog.h.

Referenced by NpcDialog(), placeItemInputControls(), and ~NpcDialog().

◆ mLastNextTime

int NpcDialog::mLastNextTime
private

Definition at line 318 of file npcdialog.h.

◆ mListScrollArea

ScrollArea* NpcDialog::mListScrollArea
private

Definition at line 286 of file npcdialog.h.

Referenced by NpcDialog(), placeMenuControls(), and ~NpcDialog().

◆ mLogInteraction

bool NpcDialog::mLogInteraction
private

Definition at line 323 of file npcdialog.h.

Referenced by action(), addText(), and optionChanged().

◆ mMinusButton

Button* NpcDialog::mMinusButton
private

Definition at line 295 of file npcdialog.h.

Referenced by placeIntInputControls(), and ~NpcDialog().

◆ mNewText

std::string NpcDialog::mNewText
private

Definition at line 280 of file npcdialog.h.

Referenced by action(), and addText().

◆ mNpcDialogs

NpcDialogs NpcDialog::mNpcDialogs
static

◆ mNpcId

BeingId NpcDialog::mNpcId
private

Definition at line 271 of file npcdialog.h.

Referenced by action(), closeDialog(), mousePressed(), nextDialog(), and postInit().

◆ mPlayerBox

PlayerBox* NpcDialog::mPlayerBox
private

◆ mPlusButton

Button* NpcDialog::mPlusButton
private

Definition at line 294 of file npcdialog.h.

Referenced by placeIntInputControls(), and ~NpcDialog().

◆ mResetButton

Button* NpcDialog::mResetButton
private

Definition at line 304 of file npcdialog.h.

Referenced by placeIntInputControls(), placeTextInputControls(), and ~NpcDialog().

◆ mScrollArea

ScrollArea* NpcDialog::mScrollArea
private

◆ mShowAvatar

bool NpcDialog::mShowAvatar
private

◆ mSkinContainer

Container* NpcDialog::mSkinContainer
private

Definition at line 287 of file npcdialog.h.

Referenced by createSkinControls(), and deleteSkinControls().

◆ mSkinControls

std::vector<Widget*> NpcDialog::mSkinControls
private

Definition at line 313 of file npcdialog.h.

◆ mSkinName

std::string NpcDialog::mSkinName
private

Definition at line 314 of file npcdialog.h.

Referenced by setSkin().

◆ mSkinScrollArea

ScrollArea* NpcDialog::mSkinScrollArea
private

Definition at line 288 of file npcdialog.h.

Referenced by NpcDialog(), placeSkinControls(), and ~NpcDialog().

◆ mText

std::string NpcDialog::mText
private

Definition at line 279 of file npcdialog.h.

Referenced by addText().

◆ mTextBox

BrowserBox* NpcDialog::mTextBox
private

◆ mTextField

TextField* NpcDialog::mTextField
private

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