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=true)
 
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=0, const int min=0, const int max=2147483647)
 
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="Window", const Modal modal=Modal_false, Window *const parent=0, std::string skin="")
 
virtual ~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=0, int offsetY=0)
 
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=0, const int offsetY=0)
 
virtual void resetToDefaultSize ()
 
void adjustPositionAfterResize (const int oldScreenWidth, const int oldScreenHeight)
 
LayoutgetLayout ()
 
void clearLayout ()
 
void reflowLayout (int w=0, int h=0)
 
LayoutCellplace (const int x, const int y, Widget *const wg, const int w=1, const int h=1)
 
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)
 
virtual ~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)
 
virtual ~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)
 
virtual ~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=255U) 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=0) const
 
bool getOptionBool (const std::string &name, const bool def=false) 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 244 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"), Opaque),
108  "npc_textbackground.xml")),
109  mText(),
110  mNewText(),
111  mItems(),
112  mImages(),
114  this, this, "extendedlistbox.xml")),
116  fromBool(getOptionBool("showlistbackground"), Opaque),
117  "npc_listbackground.xml")),
118  mSkinContainer(new Container(this)),
120  fromBool(getOptionBool("showlistbackground"), Opaque),
121  "npc_listbackground.xml")),
123  mTextField(new TextField(this, "")),
124  mIntField(new IntTextField(this)),
125  // TRANSLATORS: npc dialog button
126  mPlusButton(new Button(this, _("+"), "inc", this)),
127  // TRANSLATORS: npc dialog button
128  mMinusButton(new Button(this, _("-"), "dec", this)),
129  // TRANSLATORS: npc dialog button
130  mClearButton(new Button(this, _("Clear"), "clear", this)),
131  mButton(new Button(this, "", "ok", this)),
132  // TRANSLATORS: npc dialog button
133  mButton2(new Button(this, _("Close"), "close", this)),
134  // TRANSLATORS: npc dialog button
135  mButton3(new Button(this, _("Add"), "add", this)),
136  // TRANSLATORS: npc dialog button
137  mResetButton(new Button(this, _("Reset"), "reset", this)),
141  10000, ShowEmptyRows_true)),
143  fromBool(getOptionBool("showitemsbackground"), Opaque),
144  "npc_listbackground.xml")),
147  mSkinControls(),
148  mSkinName(),
149  mPlayerBox(new PlayerBox(nullptr)),
150  mAvatarBeing(nullptr),
151  mDialogInfo(nullptr),
152  mLastNextTime(0),
153  mCameraMode(-1),
154  mCameraX(0),
155  mCameraY(0),
156  mShowAvatar(false),
157  mLogInteraction(config.getBoolValue("logNpcInGui"))
158 {
159  // Basic Window Setup
160  setWindowName("NpcText");
161  setResizable(true);
162  setFocusable(true);
163  setStickyButtonLock(true);
164 
165  setMinWidth(200);
166  setMinHeight(150);
167 
169 
170  mPlayerBox->setWidth(70);
171  mPlayerBox->setHeight(100);
172 
173  // Setup output text box
175  mTextBox->setMaxRow(config.getIntValue("ChatLogLength"));
177  mTextBox->setProcessVars(true);
179  mTextBox->setEnableKeys(true);
180  mTextBox->setEnableTabs(true);
181  mTextBox->setEnableImages(true);
182 
185 
186  // Setup listbox
192  if (gui->getNpcFont()->getHeight() < 20)
193  mItemList->setRowHeight(20);
194  else
196 
197  setContentSize(260, 175);
205 
206  const Font *const fnt = mButton->getFont();
207  int width = std::max(fnt->getWidth(CAPTION_WAITING),
208  fnt->getWidth(CAPTION_NEXT));
209  width = std::max(width, fnt->getWidth(CAPTION_CLOSE));
210  width = std::max(width, fnt->getWidth(CAPTION_SUBMIT));
211  mButton->setWidth(8 + width);
212 
213  // Place widgets
214  buildLayout();
215 
216  center();
217  loadWindowState();
218 
219  instances.push_back(this);
220 }
Font * getFont() const
Definition: widget.cpp:330
void setDefaultSize()
Definition: window.cpp:1186
#define _(s)
Definition: gettext.h:34
const bool ShowEmptyRows_true
Definition: showemptyrows.h:29
void setEnableKeys(const bool n)
Definition: browserbox.h:137
void setWidth(const int width)
Definition: widget.cpp:132
Button * mButton2
Definition: npcdialog.h:298
NpcActionStateT mActionState
Definition: npcdialog.h:310
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:1075
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:251
void setVisible(Visible visible)
Definition: widget.cpp:224
BeingId mNpcId
Definition: npcdialog.h:269
void setScrollPolicy(const ScrollPolicy hPolicy, const ScrollPolicy vPolicy)
ComplexInventory * mComplexInventory
Definition: npcdialog.h:305
void setMinWidth(const int width)
Definition: window.cpp:579
std::string mDefaultString
Definition: npcdialog.h:272
StringVect mItems
Definition: npcdialog.h:281
ItemContainer * mItemContainer
Definition: npcdialog.h:306
Definition: button.h:94
Configuration config
bool getOptionBool(const std::string &name, const bool def=false) const
Definition: window.cpp:1454
ScrollArea * mScrollArea
Definition: npcdialog.h:276
Button * mButton3
Definition: npcdialog.h:299
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
Button * mResetButton
Definition: npcdialog.h:302
void setVerticalScrollPolicy(const ScrollPolicy vPolicy)
IntTextField * mIntField
Definition: npcdialog.h:291
void buildLayout()
Definition: npcdialog.cpp:1048
void setContentSize(int width, int height)
Definition: window.cpp:484
bool getBoolValue(const std::string &key) const
void setWrappingEnabled(const bool wrappingEnabled)
Definition: listbox.h:222
int mCameraX
Definition: npcdialog.h:318
#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:275
const NpcDialogInfo * mDialogInfo
Definition: npcdialog.h:315
void setProcessVars(const bool n)
Definition: browserbox.h:131
void setEnableTabs(const bool n)
Definition: browserbox.h:140
std::vector< Image * > mImages
Definition: npcdialog.h:282
const bool Opaque_false
Definition: opaque.h:29
Being * mAvatarBeing
Definition: npcdialog.h:314
std::string mSkinName
Definition: npcdialog.h:312
std::string mText
Definition: npcdialog.h:277
int mCameraY
Definition: npcdialog.h:319
int mLastNextTime
Definition: npcdialog.h:316
void setMinHeight(const int height)
Definition: window.cpp:592
Button * mClearButton
Definition: npcdialog.h:294
Inventory * mInventory
Definition: npcdialog.h:304
ScrollArea * mSkinScrollArea
Definition: npcdialog.h:286
int mDefaultInt
Definition: npcdialog.h:271
NpcInputStateT mInputState
Definition: npcdialog.h:309
static DialogList instances
Definition: npcdialog.h:245
void setHeight(const int height)
Definition: widget.cpp:139
ExtendedListBox * mItemList
Definition: npcdialog.h:283
bool mShowAvatar
Definition: npcdialog.h:320
Container * mSkinContainer
Definition: npcdialog.h:285
void setMaxRow(unsigned max)
Definition: browserbox.h:80
void setFocusable(const bool focusable)
Definition: widget.cpp:191
void center()
Definition: window.cpp:1405
std::string mNewText
Definition: npcdialog.h:278
void setLinkHandler(LinkHandler *linkHandler)
Definition: browserbox.cpp:160
void setFont(Font *const font)
Definition: widget.cpp:348
void setEnableImages(const bool n)
Definition: browserbox.h:134
int mCameraMode
Definition: npcdialog.h:317
const bool Opaque_true
Definition: opaque.h:29
ItemLinkHandler * mItemLinkHandler
Definition: npcdialog.h:287
int getWidth(const std::string &text) const
Definition: font.cpp:333
ScrollArea * mItemScrollArea
Definition: npcdialog.h:307
Font * getNpcFont() const
Definition: gui.h:177
void setOpaque(Opaque opaque)
Definition: browserbox.h:74
void setResizable(const bool resize)
Definition: window.cpp:615
void setStickyButtonLock(const bool sticky)
Definition: window.cpp:760
std::vector< Widget * > mSkinControls
Definition: npcdialog.h:311
#define CREATEWIDGETR(type,...)
Definition: createwidget.h:35
Window(const std::string &caption="Window", const Modal modal=Modal_false, Window *const parent=0, std::string skin="")
Definition: window.cpp:108
int getHeight() const
Definition: font.cpp:360
Button * mMinusButton
Definition: npcdialog.h:293
Button * mButton
Definition: npcdialog.h:297
#define CAPTION_SUBMIT
Definition: npcdialog.cpp:90
ScrollArea * mListScrollArea
Definition: npcdialog.h:284
PlayerBox * mPlayerBox
Definition: npcdialog.h:313
TextField * mTextField
Definition: npcdialog.h:290
void setRowHeight(unsigned int n)
Definition: listbox.h:158
bool mLogInteraction
Definition: npcdialog.h:321
Button * mPlusButton
Definition: npcdialog.h:292
void setWindowName(const std::string &name)
Definition: window.h:353
void setHorizontalScrollPolicy(const ScrollPolicy hPolicy)

◆ ~NpcDialog()

NpcDialog::~NpcDialog ( )

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

245 {
246  config.removeListeners(this);
248  clearLayout();
249 
250  if (mPlayerBox != nullptr)
251  {
252  delete mPlayerBox->getBeing();
253  delete mPlayerBox;
254  }
255 
257 
258  delete2(mTextBox);
260  delete2(mButton);
261  delete2(mButton2);
262  delete2(mButton3);
277 
279  {
280  if (*it != nullptr)
281  (*it)->decRef();
282  }
283 
284  mImages.clear();
285 
286  instances.remove(this);
287 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
void deleteSkinControls()
Definition: npcdialog.cpp:1266
Button * mButton2
Definition: npcdialog.h:298
ComplexInventory * mComplexInventory
Definition: npcdialog.h:305
ItemContainer * mItemContainer
Definition: npcdialog.h:306
Configuration config
ScrollArea * mScrollArea
Definition: npcdialog.h:276
Button * mButton3
Definition: npcdialog.h:299
#define delete2(var)
Definition: delete2.h:24
Button * mResetButton
Definition: npcdialog.h:302
IntTextField * mIntField
Definition: npcdialog.h:291
BrowserBox * mTextBox
Definition: npcdialog.h:275
std::vector< Image * > mImages
Definition: npcdialog.h:282
Button * mClearButton
Definition: npcdialog.h:294
Inventory * mInventory
Definition: npcdialog.h:304
ScrollArea * mSkinScrollArea
Definition: npcdialog.h:286
static DialogList instances
Definition: npcdialog.h:245
ExtendedListBox * mItemList
Definition: npcdialog.h:283
void removeListeners(ConfigListener *const listener)
ItemLinkHandler * mItemLinkHandler
Definition: npcdialog.h:287
ScrollArea * mItemScrollArea
Definition: npcdialog.h:307
#define CHECKLISTENERS
Definition: localconsts.h:305
Button * mMinusButton
Definition: npcdialog.h:293
Button * mButton
Definition: npcdialog.h:297
void clearLayout()
Definition: window.cpp:1360
ScrollArea * mListScrollArea
Definition: npcdialog.h:284
PlayerBox * mPlayerBox
Definition: npcdialog.h:313
TextField * mTextField
Definition: npcdialog.h:290
std::vector< Image * >::iterator ImageVectorIter
Definition: npcdialog.cpp:95
Button * mPlusButton
Definition: npcdialog.h:292
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 316 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.

317 {
318  const std::string &eventId = event.getId();
319  if (eventId == "ok")
320  {
322  {
324  return;
325 
326  nextDialog();
327  addText(std::string(), false);
328  }
331  {
332  if (cutInWindow != nullptr)
333  cutInWindow->hide();
334  closeDialog();
335  }
337  {
338  std::string printText; // Text that will get printed
339  // in the textbox
340  switch (mInputState)
341  {
342  case NpcInputState::LIST:
343  {
344  if (mDialogInfo != nullptr)
345  return;
346  if (gui != nullptr)
347  gui->resetClickCount();
348  const int selectedIndex = mItemList->getSelected();
349 
350  if (selectedIndex >= CAST_S32(mItems.size())
351  || selectedIndex < 0
354  {
355  return;
356  }
357  unsigned char choice = CAST_U8(
358  selectedIndex + 1);
359  printText = mItems[selectedIndex];
360 
361  npcHandler->listInput(mNpcId, choice);
362  break;
363  }
365  {
368  {
369  return;
370  }
371  printText = mTextField->getText();
372  npcHandler->stringInput(mNpcId, printText);
373  break;
374  }
376  {
379  {
380  return;
381  }
382  printText = strprintf("%d", mIntField->getValue());
385  break;
386  }
387  case NpcInputState::ITEM:
388  {
389  restoreVirtuals();
392  {
393  return;
394  }
395 
396  std::string str;
397  const int sz = mInventory->getSize();
398  if (sz == 0)
399  {
400  str = "0,0";
401  }
402  else
403  {
404  const Item *item = mInventory->getItem(0);
405  if (item != nullptr)
406  {
407  str = strprintf("%d,%d", item->getId(),
408  toInt(item->getColor(), int));
409  }
410  else
411  {
412  str = "0,0";
413  }
414  for (int f = 1; f < sz; f ++)
415  {
416  str.append(";");
417  item = mInventory->getItem(f);
418  if (item != nullptr)
419  {
420  str.append(strprintf("%d,%d", item->getId(),
421  toInt(item->getColor(), int)));
422  }
423  else
424  {
425  str.append("0,0");
426  }
427  }
428  }
429 
430  // need send selected item
432  mInventory->clear();
433  break;
434  }
436  {
437  restoreVirtuals();
440  {
441  return;
442  }
443 
444  std::string str;
445  const int sz = mInventory->getSize();
446  if (sz == 0)
447  {
448  str = "-1";
449  }
450  else
451  {
452  const Item *item = mInventory->getItem(0);
453  if (item != nullptr)
454  {
455  str = strprintf("%d", item->getTag());
456  }
457  else
458  {
459  str = "-1";
460  }
461  for (int f = 1; f < sz; f ++)
462  {
463  str.append(";");
464  item = mInventory->getItem(f);
465  if (item != nullptr)
466  str.append(strprintf("%d", item->getTag()));
467  else
468  str.append("-1");
469  }
470  }
471 
472  // need send selected item
474  mInventory->clear();
475  break;
476  }
478  {
479  restoreVirtuals();
482  {
483  return;
484  }
485 
486  std::string str;
487  const int sz = mComplexInventory->getSize();
488  if (sz == 0)
489  {
490  str.clear();
491  }
492  else
493  {
494  const ComplexItem *item = dynamic_cast<ComplexItem*>(
496  str = complexItemToStr(item);
497  for (int f = 1; f < sz; f ++)
498  {
499  str.append("|");
500  item = dynamic_cast<ComplexItem*>(
502  str.append(complexItemToStr(item));
503  }
504  }
505 
506  // need send selected item
508  mInventory->clear();
509  break;
510  }
511 
512  case NpcInputState::NONE:
513  default:
514  break;
515  }
519  {
520  // addText will auto remove the input layout
521  addText(strprintf("> \"%s\"", printText.c_str()), false);
522  }
523  mNewText.clear();
524  }
525 
526  if (!mLogInteraction)
527  mTextBox->clearRows();
528  }
529  else if (eventId == "reset")
530  {
531  switch (mInputState)
532  {
535  break;
538  break;
539  case NpcInputState::ITEM:
541  mInventory->clear();
542  break;
545  break;
546  case NpcInputState::NONE:
547  case NpcInputState::LIST:
548  default:
549  break;
550  }
551  }
552  else if (eventId == "inc")
553  {
555  }
556  else if (eventId == "dec")
557  {
559  }
560  else if (eventId == "clear")
561  {
562  switch (mInputState)
563  {
564  case NpcInputState::ITEM:
566  mInventory->clear();
567  break;
570  break;
573  case NpcInputState::LIST:
574  case NpcInputState::NONE:
575  default:
576  clearRows();
577  break;
578  }
579  }
580  else if (eventId == "close")
581  {
582  restoreVirtuals();
584  {
585  switch (mInputState)
586  {
587  case NpcInputState::ITEM:
588  npcHandler->stringInput(mNpcId, "0,0");
589  break;
591  npcHandler->stringInput(mNpcId, "-1");
592  break;
595  break;
598  case NpcInputState::NONE:
599  case NpcInputState::LIST:
600  default:
601  npcHandler->listInput(mNpcId, 255);
602  break;
603  }
604  if (cutInWindow != nullptr)
605  cutInWindow->hide();
606  closeDialog();
607  }
608  }
609  else if (eventId == "add")
610  {
611  if (inventoryWindow != nullptr)
612  {
613  Item *const item = inventoryWindow->getSelectedItem();
614  Inventory *const inventory = PlayerInfo::getInventory();
615  if (inventory != nullptr)
616  {
618  {
619  if (mComplexInventory->addVirtualItem(item, -1, 1))
620  inventory->virtualRemove(item, 1);
621  }
622  else
623  {
624  if (mInventory->addVirtualItem(item, -1, 1))
625  inventory->virtualRemove(item, 1);
626  }
627  }
628  }
629  }
630  else if (eventId.find("skin_") == 0)
631  {
632  const std::string cmd = eventId.substr(5);
633  std::string printText;
634  int cnt = 0;
636  {
637  if (cmd == *it)
638  {
639  npcHandler->listInput(mNpcId, CAST_U8(cnt + 1));
640  printText = mItems[cnt];
641 
645  {
646  // addText will auto remove the input layout
647  addText(strprintf("> \"%s\"", printText.c_str()), false);
648  }
649  mNewText.clear();
650  break;
651  }
652  cnt ++;
653  }
654  }
655 }
#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
NpcActionStateT mActionState
Definition: npcdialog.h:310
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:1345
BeingId mNpcId
Definition: npcdialog.h:269
ComplexInventory * mComplexInventory
Definition: npcdialog.h:305
Inventory * getInventory()
Definition: playerinfo.cpp:207
void restoreVirtuals()
Definition: npcdialog.cpp:1338
std::string mDefaultString
Definition: npcdialog.h:272
StringVect mItems
Definition: npcdialog.h:281
void addText(const std::string &string, const bool save=true)
Definition: npcdialog.cpp:289
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:799
void clear()
Definition: inventory.cpp:237
IntTextField * mIntField
Definition: npcdialog.h:291
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:657
void clearRows()
Definition: npcdialog.cpp:1208
#define CAST_S32
Definition: cast.h:29
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
BrowserBox * mTextBox
Definition: npcdialog.h:275
const NpcDialogInfo * mDialogInfo
Definition: npcdialog.h:315
void closeDialog()
Definition: npcdialog.cpp:662
ItemColor getColor() const
Definition: item.h:180
void resetClickCount()
Definition: gui.cpp:968
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:304
int mDefaultInt
Definition: npcdialog.h:271
NpcInputStateT mInputState
Definition: npcdialog.h:309
ExtendedListBox * mItemList
Definition: npcdialog.h:283
int getId() const
Definition: item.h:80
Item * getSelectedItem() const
std::string mNewText
Definition: npcdialog.h:278
Net::NpcHandler * npcHandler
Definition: net.cpp:86
Item * getItem(const int index) const
Definition: inventory.cpp:82
void clearRows()
Definition: browserbox.cpp:352
const std::string & getText() const
Definition: textfield.h:225
TextField * mTextField
Definition: npcdialog.h:290
bool mLogInteraction
Definition: npcdialog.h:321
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 697 of file npcdialog.cpp.

References mImages, and mItems.

698 {
699  mItems.push_back(choice);
700  mImages.push_back(nullptr);
701 }
StringVect mItems
Definition: npcdialog.h:281
std::vector< Image * > mImages
Definition: npcdialog.h:282

◆ addCraftItem()

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

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

1379 {
1381  return;
1382 
1383  Inventory *const inventory = PlayerInfo::getInventory();
1384 
1385  if (inventory == nullptr)
1386  return;
1387 
1389  item,
1390  slot,
1391  amount))
1392  {
1393  inventory->virtualRemove(item, amount);
1394  }
1395 }
bool addVirtualItem(const Item *const item, int index, const int amount)
ComplexInventory * mComplexInventory
Definition: npcdialog.h:305
Inventory * getInventory()
Definition: playerinfo.cpp:207
void virtualRemove(Item *const item, const int amount)
Definition: inventory.cpp:484
NpcInputStateT mInputState
Definition: npcdialog.h:309

◆ addText()

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

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

290 {
291  if (save || mLogInteraction)
292  {
293  if (mText.size() > 5000)
294  mText.clear();
295 
296  mNewText.append(text);
297  mTextBox->addRow(text);
298  }
301  buildLayout();
302 }
NpcActionStateT mActionState
Definition: npcdialog.h:310
ScrollArea * mScrollArea
Definition: npcdialog.h:276
void setVerticalScrollAmount(const int vScroll)
int getVerticalMaxScroll()
void buildLayout()
Definition: npcdialog.cpp:1048
BrowserBox * mTextBox
Definition: npcdialog.h:275
std::string mText
Definition: npcdialog.h:277
std::string mNewText
Definition: npcdialog.h:278
void addRow(const std::string &row, const bool atTop=false)
Definition: browserbox.cpp:165
bool mLogInteraction
Definition: npcdialog.h:321

◆ buildLayout()

void NpcDialog::buildLayout ( )
private

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

1049 {
1050  clearLayout();
1051 
1053  {
1056  else if (mActionState == NpcActionState::NEXT)
1058  else if (mActionState == NpcActionState::CLOSE)
1061  }
1062  else if (mInputState != NpcInputState::NONE)
1063  {
1065  switch (mInputState)
1066  {
1067  case NpcInputState::LIST:
1068  if (mDialogInfo == nullptr)
1070  else
1072  mItemList->setSelected(-1);
1073  break;
1074 
1075  case NpcInputState::STRING:
1077  break;
1078 
1081  break;
1082 
1083  case NpcInputState::ITEM:
1087  break;
1088 
1089  case NpcInputState::NONE:
1090  default:
1091  break;
1092  }
1093  }
1094 
1095  Layout &layout = getLayout();
1096  layout.setRowHeight(1, LayoutType::SET);
1097  redraw();
1099 }
void redraw()
Definition: window.cpp:1394
void setSelected(const int selected)
Definition: listbox.cpp:392
void placeNormalControls()
Definition: npcdialog.cpp:871
NpcActionStateT mActionState
Definition: npcdialog.h:310
#define CAPTION_CLOSE
Definition: npcdialog.cpp:88
ScrollArea * mScrollArea
Definition: npcdialog.h:276
void setVerticalScrollAmount(const int vScroll)
void placeTextInputControls()
Definition: npcdialog.cpp:944
int getVerticalMaxScroll()
void placeMenuControls()
Definition: npcdialog.cpp:888
void setCaption(const std::string &caption)
Definition: button.h:214
void placeSkinControls()
Definition: npcdialog.cpp:909
#define CAPTION_WAITING
Definition: npcdialog.cpp:84
#define CAPTION_NEXT
Definition: npcdialog.cpp:86
const NpcDialogInfo * mDialogInfo
Definition: npcdialog.h:315
Layout & getLayout()
Definition: window.cpp:1353
NpcInputStateT mInputState
Definition: npcdialog.h:309
ExtendedListBox * mItemList
Definition: npcdialog.h:283
void placeIntInputControls()
Definition: npcdialog.cpp:965
void placeItemInputControls()
Definition: npcdialog.cpp:990
Definition: layout.h:43
Button * mButton
Definition: npcdialog.h:297
#define CAPTION_SUBMIT
Definition: npcdialog.cpp:90
void clearLayout()
Definition: window.cpp:1360
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 683 of file npcdialog.cpp.

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

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

684 {
685  mItems.clear();
687  {
688  if (*it != nullptr)
689  (*it)->decRef();
690  }
691  mImages.clear();
694  buildLayout();
695 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
NpcActionStateT mActionState
Definition: npcdialog.h:310
StringVect mItems
Definition: npcdialog.h:281
void buildLayout()
Definition: npcdialog.cpp:1048
std::vector< Image * > mImages
Definition: npcdialog.h:282
NpcInputStateT mInputState
Definition: npcdialog.h:309
std::vector< Image * >::iterator ImageVectorIter
Definition: npcdialog.cpp:95

◆ clearDialogs()

void NpcDialog::clearDialogs ( )
static

Definition at line 1213 of file npcdialog.cpp.

References mNpcDialogs.

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

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

◆ clearRows()

void NpcDialog::clearRows ( )

Definition at line 1208 of file npcdialog.cpp.

References BrowserBox::clearRows(), and mTextBox.

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

1209 {
1210  mTextBox->clearRows();
1211 }
BrowserBox * mTextBox
Definition: npcdialog.h:275
void clearRows()
Definition: browserbox.cpp:352

◆ closeAll()

void NpcDialog::closeAll ( )
static

Closes all instances.

Definition at line 862 of file npcdialog.cpp.

References FOR_EACH, and instances.

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

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

◆ closeDialog()

void NpcDialog::closeDialog ( )

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

Definition at line 662 of file npcdialog.cpp.

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

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

663 {
664  restoreCamera();
666 }
BeingId mNpcId
Definition: npcdialog.h:269
void restoreCamera()
Definition: npcdialog.cpp:1111
Net::NpcHandler * npcHandler
Definition: net.cpp:86
virtual void closeDialog(const BeingId npcId)=0

◆ complexItemToStr()

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

Definition at line 1345 of file npcdialog.cpp.

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

Referenced by action().

1346 {
1347  std::string str;
1348  if (item != nullptr)
1349  {
1350  const STD_VECTOR<Item*> &items = item->getChilds();
1351  const size_t sz = items.size();
1352  if (sz == 0u)
1353  return str;
1354 
1355  const Item *item2 = items[0];
1356 
1357  str = strprintf("%d,%d",
1358  item2->getInvIndex(),
1359  item2->getQuantity());
1360  for (size_t f = 1; f < sz; f ++)
1361  {
1362  str.append(";");
1363  item2 = items[f];
1364  str.append(strprintf("%d,%d",
1365  item2->getInvIndex(),
1366  item2->getQuantity()));
1367  }
1368  }
1369  else
1370  {
1371  str.clear();
1372  }
1373  return str;
1374 }
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 1241 of file npcdialog.cpp.

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

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

1242 {
1243  std::string str = mTextBox->getTextAtPos(x, y);
1244  sendBuffer(str);
1245 }
bool sendBuffer(const std::string &text)
Definition: copynpaste.cpp:517
std::string getTextAtPos(const int x, const int y) const
Definition: browserbox.cpp:863
BrowserBox * mTextBox
Definition: npcdialog.h:275

◆ createSkinControls()

void NpcDialog::createSkinControls ( )
private

Definition at line 1271 of file npcdialog.cpp.

References BasicContainer2::add(), Widget::addActionListener(), BrowserBox::addRow(), Button::adjustSize(), AutoRelease_true, 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().

1272 {
1274 
1275  if (mDialogInfo == nullptr)
1276  return;
1277 
1278  FOR_EACH (STD_VECTOR<NpcImageInfo*>::const_iterator,
1279  it,
1281  {
1282  const NpcImageInfo *const info = *it;
1283  Image *const image = Theme::getImageFromTheme(info->name);
1284  if (image != nullptr)
1285  {
1286  Icon *const icon = new Icon(this, image, AutoRelease_true);
1287  icon->setPosition(info->x, info->y);
1288  mSkinContainer->add(icon);
1289  }
1290  }
1291  FOR_EACH (STD_VECTOR<NpcTextInfo*>::const_iterator,
1292  it,
1294  {
1295  const NpcTextInfo *const info = *it;
1296  BrowserBox *box = new BrowserBox(this,
1297  Opaque_true,
1298  "browserbox.xml");
1299  box->setOpaque(Opaque_false);
1300  box->setMaxRow(config.getIntValue("ChatLogLength"));
1302  box->setProcessVars(true);
1303  box->setFont(gui->getNpcFont());
1304  box->setEnableKeys(true);
1305  box->setEnableTabs(true);
1306  box->setPosition(info->x, info->y);
1307  mSkinContainer->add(box);
1308  box->setWidth(info->width);
1309  box->setHeight(info->height);
1310  StringVect parts;
1311  splitToStringVector(parts, info->text, '\n');
1312  FOR_EACH (StringVectCIter, it2, parts)
1313  {
1314  box->addRow(*it2);
1315  }
1316  }
1317  FOR_EACH (STD_VECTOR<NpcButtonInfo*>::const_iterator,
1318  it,
1320  {
1321  const NpcButtonInfo *const info = *it;
1322  Button *const button = new Button(this);
1323  button->setCaption(info->name);
1324  button->setActionEventId("skin_" + info->value);
1325  button->addActionListener(this);
1326  button->setPosition(info->x, info->y);
1327  if (!info->image.empty())
1328  {
1329  button->setImageWidth(info->imageWidth);
1330  button->setImageHeight(info->imageHeight);
1331  button->loadImageSet(info->image);
1332  }
1333  mSkinContainer->add(button);
1334  button->adjustSize();
1335  }
1336 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
void deleteSkinControls()
Definition: npcdialog.cpp:1266
std::string value
Definition: npcbuttoninfo.h:44
void loadImageSet(const std::string &imageName)
Definition: button.cpp:417
void setEnableKeys(const bool n)
Definition: browserbox.h:137
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:261
Definition: button.h:94
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:821
std::string image
Definition: npcbuttoninfo.h:45
void setCaption(const std::string &caption)
Definition: button.h:214
Definition: icon.h:39
std::string text
Definition: npctextinfo.h:41
bool info(InputEvent &event)
Definition: commands.cpp:56
const NpcDialogInfo * mDialogInfo
Definition: npcdialog.h:315
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:131
void setEnableTabs(const bool n)
Definition: browserbox.h:140
const bool Opaque_false
Definition: opaque.h:29
void setImageWidth(const int width)
Definition: button.h:258
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:285
void setMaxRow(unsigned max)
Definition: browserbox.h:80
void setLinkHandler(LinkHandler *linkHandler)
Definition: browserbox.cpp:160
void setFont(Font *const font)
Definition: widget.cpp:348
const bool Opaque_true
Definition: opaque.h:29
ItemLinkHandler * mItemLinkHandler
Definition: npcdialog.h:287
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
void addRow(const std::string &row, const bool atTop=false)
Definition: browserbox.cpp:165
std::string name
Definition: npcimageinfo.h:39

◆ deleteSkinControls()

void NpcDialog::deleteSkinControls ( )
private

Definition at line 1266 of file npcdialog.cpp.

References mSkinContainer, and Container::removeControls().

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

1267 {
1269 }
void removeControls()
Definition: container.cpp:42
Container * mSkinContainer
Definition: npcdialog.h:285

◆ 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 848 of file npcdialog.cpp.

References FOR_EACH, and instances.

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

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

◆ getElementAt()

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

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

Implements ListModel.

Definition at line 673 of file npcdialog.cpp.

References mItems.

674 {
675  return mItems[i];
676 }
StringVect mItems
Definition: npcdialog.h:281

◆ getImageAt()

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

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

Implements ExtendedListModel.

Definition at line 678 of file npcdialog.cpp.

References mImages.

679 {
680  return mImages[i];
681 }
std::vector< Image * > mImages
Definition: npcdialog.h:282

◆ getInputState()

NpcInputStateT NpcDialog::getInputState ( )
inline

Definition at line 234 of file npcdialog.h.

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

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

235  { return mInputState; }
NpcInputStateT mInputState
Definition: npcdialog.h:309

◆ getNumberOfElements()

int NpcDialog::getNumberOfElements ( )
virtual

Returns the number of items in the choices list.

Implements ListModel.

Definition at line 668 of file npcdialog.cpp.

References CAST_S32, and mItems.

669 {
670  return CAST_S32(mItems.size());
671 }
StringVect mItems
Definition: npcdialog.h:281
#define CAST_S32
Definition: cast.h:29

◆ integerRequest()

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

Requests a interger from the user.

Definition at line 776 of file npcdialog.cpp.

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

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

778 {
781  mDefaultInt = defaultValue;
782  mIntField->setRange(min, max);
783  mIntField->setValue(defaultValue);
784  buildLayout();
785 }
void setValue(const int value)
NpcActionStateT mActionState
Definition: npcdialog.h:310
IntTextField * mIntField
Definition: npcdialog.h:291
void buildLayout()
Definition: npcdialog.cpp:1048
void setRange(const int minimum, const int maximum)
int mDefaultInt
Definition: npcdialog.h:271
NpcInputStateT mInputState
Definition: npcdialog.h:309

◆ isActive()

static bool NpcDialog::isActive ( )
inlinestatic

Returns true if any instances exist.

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

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

◆ isAnyInputFocused()

bool NpcDialog::isAnyInputFocused ( )
static

Definition at line 765 of file npcdialog.cpp.

References FOR_EACH, and instances.

Referenced by InputManager::updateConditionMask().

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

◆ isCloseState()

int NpcDialog::isCloseState ( ) const
inline

Definition at line 225 of file npcdialog.h.

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

Referenced by Actions::closeMoveNpcDialog().

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

◆ isInputFocused()

bool NpcDialog::isInputFocused ( ) const

Definition at line 759 of file npcdialog.cpp.

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

760 {
761  return mTextField->isFocused() || mIntField->isFocused()
762  || mItemList->isFocused();
763 }
virtual bool isFocused() const
Definition: widget.cpp:183
IntTextField * mIntField
Definition: npcdialog.h:291
ExtendedListBox * mItemList
Definition: npcdialog.h:283
TextField * mTextField
Definition: npcdialog.h:290

◆ isTextInputFocused()

bool NpcDialog::isTextInputFocused ( ) const

Definition at line 754 of file npcdialog.cpp.

References Widget::isFocused(), and mTextField.

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

◆ itemCraftRequest()

void NpcDialog::itemCraftRequest ( const int  size)

◆ itemIndexRequest()

void NpcDialog::itemIndexRequest ( const int  size)

◆ itemRequest()

void NpcDialog::itemRequest ( const int  size)

Definition at line 787 of file npcdialog.cpp.

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

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

788 {
792  buildLayout();
793 }
void resize(const unsigned int newSize)
Definition: inventory.cpp:396
NpcActionStateT mActionState
Definition: npcdialog.h:310
void buildLayout()
Definition: npcdialog.cpp:1048
Inventory * mInventory
Definition: npcdialog.h:304
NpcInputStateT mInputState
Definition: npcdialog.h:309

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

1188 {
1189  BLOCK_START("NpcDialog::logic")
1190  Window::logic();
1191  if (mShowAvatar && (mAvatarBeing != nullptr))
1192  {
1193  mAvatarBeing->logic();
1194  if (mPlayerBox->getWidth() < CAST_S32(3 * getPadding()))
1195  {
1196  const Sprite *const sprite = mAvatarBeing->mSprites[0];
1197  if (sprite != nullptr)
1198  {
1199  mPlayerBox->setWidth(sprite->getWidth() + 2 * getPadding());
1200  mPlayerBox->setHeight(sprite->getHeight() + 2 * getPadding());
1201  buildLayout();
1202  }
1203  }
1204  }
1205  BLOCK_END("NpcDialog::logic")
1206 }
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:1048
#define CAST_S32
Definition: cast.h:29
void logic()
Definition: npcdialog.cpp:1187
virtual int getHeight() const =0
std::vector< Sprite * > mSprites
Being * mAvatarBeing
Definition: npcdialog.h:314
virtual int getWidth() const =0
void setHeight(const int height)
Definition: widget.cpp:139
bool mShowAvatar
Definition: npcdialog.h:320
void logic()
Definition: being.cpp:1793
PlayerBox * mPlayerBox
Definition: npcdialog.h:313
int getPadding() const
Definition: window.h:496

◆ mousePressed()

void NpcDialog::mousePressed ( MouseEvent event)
virtual

Starts window resizing when appropriate.

Reimplemented from Window.

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

1226 {
1227  Window::mousePressed(event);
1228  if (event.getButton() == MouseButton::RIGHT
1229  && event.getSource() == mTextBox)
1230  {
1231  event.consume();
1232  if (popupMenu != nullptr)
1233  {
1235  viewport->mMouseX,
1236  viewport->mMouseY);
1237  }
1238  }
1239 }
void showNpcDialogPopup(const BeingId npcId, const int x, const int y)
Definition: popupmenu.cpp:2226
BeingId mNpcId
Definition: npcdialog.h:269
MouseButtonT getButton() const
Definition: mouseevent.h:113
int mMouseX
Definition: viewport.h:153
BrowserBox * mTextBox
Definition: npcdialog.h:275
PopupMenu * popupMenu
Definition: popupmenu.cpp:102
int mMouseY
Definition: viewport.h:154
void mousePressed(MouseEvent &event)
Definition: window.cpp:824
Viewport * viewport
Definition: viewport.cpp:35

◆ move()

void NpcDialog::move ( const int  amount)

Definition at line 811 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.

812 {
814  return;
815 
816  switch (mInputState)
817  {
819  mIntField->setValue(mIntField->getValue() + amount);
820  break;
821  case NpcInputState::LIST:
823  break;
824  case NpcInputState::NONE:
826  case NpcInputState::ITEM:
829  default:
830  break;
831  }
832 }
void setSelected(const int selected)
Definition: listbox.cpp:392
void setValue(const int value)
NpcActionStateT mActionState
Definition: npcdialog.h:310
IntTextField * mIntField
Definition: npcdialog.h:291
int getSelected() const
Definition: listbox.h:167
int getValue() const
NpcInputStateT mInputState
Definition: npcdialog.h:309
ExtendedListBox * mItemList
Definition: npcdialog.h:283

◆ nextDialog()

void NpcDialog::nextDialog ( )

Notifies the server that client has performed a next action.

Definition at line 657 of file npcdialog.cpp.

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

Referenced by action().

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

◆ 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 842 of file npcdialog.cpp.

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

843 {
844  if (name == "logNpcInGui")
845  mLogInteraction = config.getBoolValue("logNpcInGui");
846 }
Configuration config
bool getBoolValue(const std::string &key) const
bool mLogInteraction
Definition: npcdialog.h:321

◆ 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 703 of file npcdialog.cpp.

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

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

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

◆ placeIntInputControls()

void NpcDialog::placeIntInputControls ( )
private

Definition at line 965 of file npcdialog.cpp.

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

Referenced by buildLayout().

966 {
967  if (mShowAvatar)
968  {
969  place(0, 0, mPlayerBox);
970  place(1, 0, mScrollArea, 6, 3);
971  place(1, 3, mMinusButton, 1);
972  place(2, 3, mIntField, 4);
973  place(6, 3, mPlusButton, 1);
974  place(1, 4, mResetButton, 2);
975  place(3, 4, mClearButton, 2);
976  place(5, 4, mButton, 2);
977  }
978  else
979  {
980  place(0, 0, mScrollArea, 6, 3);
981  place(0, 3, mMinusButton, 1);
982  place(1, 3, mIntField, 4);
983  place(5, 3, mPlusButton, 1);
984  place(0, 4, mResetButton, 2);
985  place(2, 4, mClearButton, 2);
986  place(4, 4, mButton, 2);
987  }
988 }
ScrollArea * mScrollArea
Definition: npcdialog.h:276
Button * mResetButton
Definition: npcdialog.h:302
IntTextField * mIntField
Definition: npcdialog.h:291
LayoutCell & place(const int x, const int y, Widget *const wg, const int w=1, const int h=1)
Definition: window.cpp:1372
Button * mClearButton
Definition: npcdialog.h:294
bool mShowAvatar
Definition: npcdialog.h:320
Button * mMinusButton
Definition: npcdialog.h:293
Button * mButton
Definition: npcdialog.h:297
PlayerBox * mPlayerBox
Definition: npcdialog.h:313
Button * mPlusButton
Definition: npcdialog.h:292

◆ placeItemInputControls()

void NpcDialog::placeItemInputControls ( )
private

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

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

◆ placeMenuControls()

void NpcDialog::placeMenuControls ( )
private

Definition at line 888 of file npcdialog.cpp.

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

Referenced by buildLayout().

889 {
890  if (mShowAvatar)
891  {
892  place(0, 0, mPlayerBox);
893  place(1, 0, mScrollArea, 6, 3);
894  place(0, 3, mListScrollArea, 7, 3);
895  place(1, 6, mButton2, 2);
896  place(3, 6, mClearButton, 2);
897  place(5, 6, mButton, 2);
898  }
899  else
900  {
901  place(0, 0, mScrollArea, 6, 3);
902  place(0, 3, mListScrollArea, 6, 3);
903  place(0, 6, mButton2, 2);
904  place(2, 6, mClearButton, 2);
905  place(4, 6, mButton, 2);
906  }
907 }
Button * mButton2
Definition: npcdialog.h:298
ScrollArea * mScrollArea
Definition: npcdialog.h:276
LayoutCell & place(const int x, const int y, Widget *const wg, const int w=1, const int h=1)
Definition: window.cpp:1372
Button * mClearButton
Definition: npcdialog.h:294
bool mShowAvatar
Definition: npcdialog.h:320
Button * mButton
Definition: npcdialog.h:297
ScrollArea * mListScrollArea
Definition: npcdialog.h:284
PlayerBox * mPlayerBox
Definition: npcdialog.h:313

◆ placeNormalControls()

void NpcDialog::placeNormalControls ( )
private

Definition at line 871 of file npcdialog.cpp.

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

Referenced by buildLayout().

872 {
873  if (mShowAvatar)
874  {
875  place(0, 0, mPlayerBox);
876  place(1, 0, mScrollArea, 5, 3);
877  place(4, 3, mClearButton);
878  place(5, 3, mButton);
879  }
880  else
881  {
882  place(0, 0, mScrollArea, 5, 3);
883  place(3, 3, mClearButton);
884  place(4, 3, mButton);
885  }
886 }
ScrollArea * mScrollArea
Definition: npcdialog.h:276
LayoutCell & place(const int x, const int y, Widget *const wg, const int w=1, const int h=1)
Definition: window.cpp:1372
Button * mClearButton
Definition: npcdialog.h:294
bool mShowAvatar
Definition: npcdialog.h:320
Button * mButton
Definition: npcdialog.h:297
PlayerBox * mPlayerBox
Definition: npcdialog.h:313

◆ placeSkinControls()

void NpcDialog::placeSkinControls ( )
private

Definition at line 909 of file npcdialog.cpp.

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

Referenced by buildLayout().

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

◆ placeTextInputControls()

void NpcDialog::placeTextInputControls ( )
private

Definition at line 944 of file npcdialog.cpp.

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

Referenced by buildLayout().

945 {
946  if (mShowAvatar)
947  {
948  place(0, 0, mPlayerBox);
949  place(1, 0, mScrollArea, 6, 3);
950  place(1, 3, mTextField, 6);
951  place(1, 4, mResetButton, 2);
952  place(3, 4, mClearButton, 2);
953  place(5, 4, mButton, 2);
954  }
955  else
956  {
957  place(0, 0, mScrollArea, 6, 3);
958  place(0, 3, mTextField, 6);
959  place(0, 4, mResetButton, 2);
960  place(2, 4, mClearButton, 2);
961  place(4, 4, mButton, 2);
962  }
963 }
ScrollArea * mScrollArea
Definition: npcdialog.h:276
Button * mResetButton
Definition: npcdialog.h:302
LayoutCell & place(const int x, const int y, Widget *const wg, const int w=1, const int h=1)
Definition: window.cpp:1372
Button * mClearButton
Definition: npcdialog.h:294
bool mShowAvatar
Definition: npcdialog.h:320
Button * mButton
Definition: npcdialog.h:297
PlayerBox * mPlayerBox
Definition: npcdialog.h:313
TextField * mTextField
Definition: npcdialog.h:290

◆ postInit()

void NpcDialog::postInit ( )
virtual

Reimplemented from Window.

Definition at line 222 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.

223 {
226  requestFocus();
227  enableVisibleSound(true);
229 
230  if (actorManager != nullptr)
231  {
232  const Being *const being = actorManager->findBeing(mNpcId);
233  if (being != nullptr)
234  {
236  being->getSubType(), BeingTypeId)));
237  setCaption(being->getName());
238  }
239  }
240 
241  config.addListener("logNpcInGui", this);
242 }
const bool Visible_true
Definition: visible.h:29
#define fromInt(val, name)
Definition: intdefines.h:45
BeingId mNpcId
Definition: npcdialog.h:269
SoundManager soundManager
Configuration config
void setVisible(Visible visible)
Definition: npcdialog.cpp:834
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:1126
const std::string & getName() const
Definition: being.h:233
void enableVisibleSound(bool b)
Definition: window.h:473
static const std::string SOUND_SHOW_WINDOW
Definition: sound.h:34
void setCaption(const std::string &caption)
Definition: window.h:523
int BeingTypeId
Definition: beingtypeid.h:29
Definition: being.h:93
BeingTypeId getSubType() const
Definition: being.h:395
void postInit()
Definition: window.cpp:241
ActorManager * actorManager
void playGuiSound(const std::string &name)

◆ refocus()

void NpcDialog::refocus ( )

Definition at line 738 of file npcdialog.cpp.

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

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

739 {
740  if (!mItems.empty())
741  mItemList->refocus();
742 }
StringVect mItems
Definition: npcdialog.h:281
void refocus()
Definition: listbox.cpp:358
ExtendedListBox * mItemList
Definition: npcdialog.h:283

◆ restoreCamera()

void NpcDialog::restoreCamera ( )

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

1112 {
1113  if ((viewport == nullptr) || mCameraMode == -1)
1114  return;
1115 
1118  if (mCameraMode != 0)
1119  {
1122  }
1123  mCameraMode = -1;
1124 }
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:318
int mCameraY
Definition: npcdialog.h:319
unsigned int cameraMode
Definition: settings.h:142
int mCameraMode
Definition: npcdialog.h:317
void setCameraRelativeX(const int n)
Definition: viewport.h:145
Viewport * viewport
Definition: viewport.cpp:35

◆ restoreVirtuals()

void NpcDialog::restoreVirtuals ( )
private

Definition at line 1338 of file npcdialog.cpp.

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

Referenced by action().

1339 {
1340  Inventory *const inventory = PlayerInfo::getInventory();
1341  if (inventory != nullptr)
1342  inventory->restoreVirtuals();
1343 }
void restoreVirtuals()
Definition: inventory.cpp:499
Inventory * getInventory()
Definition: playerinfo.cpp:207

◆ saveCamera()

void NpcDialog::saveCamera ( )

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

1102 {
1103  if ((viewport == nullptr) || mCameraMode >= 0)
1104  return;
1105 
1109 }
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:318
int mCameraY
Definition: npcdialog.h:319
unsigned int cameraMode
Definition: settings.h:142
int mCameraMode
Definition: npcdialog.h:317
int getCameraRelativeX() const
Definition: viewport.h:139
Viewport * viewport
Definition: viewport.cpp:35

◆ setAvatarAction()

void NpcDialog::setAvatarAction ( const int  actionId)

Definition at line 1180 of file npcdialog.cpp.

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

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

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

◆ setAvatarDirection()

void NpcDialog::setAvatarDirection ( const uint8_t  direction)

Definition at line 1173 of file npcdialog.cpp.

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

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

1174 {
1175  Being *const being = mPlayerBox->getBeing();
1176  if (being != nullptr)
1177  being->setDirection(direction);
1178 }
virtual void setDirection(const uint8_t direction)
Definition: being.cpp:1649
Definition: being.h:93
PlayerBox * mPlayerBox
Definition: npcdialog.h:313
Being * getBeing()
Definition: playerbox.h:91

◆ setSkin()

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

Definition at line 1247 of file npcdialog.cpp.

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

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

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

◆ setVisible()

void NpcDialog::setVisible ( Visible  visible)
virtual

Overloads window setVisible by Guichan to allow sticky window handling.

Reimplemented from Window.

Definition at line 834 of file npcdialog.cpp.

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

Referenced by postInit().

835 {
836  Window::setVisible(visible);
837 
838  if (visible == Visible_false)
839  scheduleDelete();
840 }
const bool Visible_false
Definition: visible.h:29
virtual void scheduleDelete()
Definition: window.cpp:819
virtual void setVisible(Visible visible)
Definition: window.cpp:766

◆ showAvatar()

void NpcDialog::showAvatar ( const BeingTypeId  avatarId)

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

1127 {
1128  const bool needShow = (avatarId != BeingTypeId_zero);
1129  if (needShow)
1130  {
1131  delete mAvatarBeing;
1134  avatarId,
1135  nullptr);
1137  if (!mAvatarBeing->mSprites.empty())
1138  {
1139  mAvatarBeing->logic();
1140  const BeingInfo *const info = AvatarDB::get(avatarId);
1141  const int pad2 = 2 * mPadding;
1142  int width = 0;
1143  if (info != nullptr)
1144  {
1145  width = info->getWidth();
1146  mPlayerBox->setWidth(width + pad2);
1147  mPlayerBox->setHeight(info->getHeight() + pad2);
1148  }
1149  const Sprite *const sprite = mAvatarBeing->mSprites[0];
1150  if ((sprite != nullptr) && (width == 0))
1151  {
1152  mPlayerBox->setWidth(sprite->getWidth() + pad2);
1153  mPlayerBox->setHeight(sprite->getHeight() + pad2);
1154  }
1155  }
1156  }
1157  else
1158  {
1160  mPlayerBox->setPlayer(nullptr);
1161  }
1162  if (needShow != mShowAvatar)
1163  {
1164  mShowAvatar = needShow;
1165  buildLayout();
1166  }
1167  else
1168  {
1169  mShowAvatar = needShow;
1170  }
1171 }
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:610
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:5493
void buildLayout()
Definition: npcdialog.cpp:1048
virtual int getHeight() const =0
bool info(InputEvent &event)
Definition: commands.cpp:56
std::vector< Sprite * > mSprites
Being * mAvatarBeing
Definition: npcdialog.h:314
virtual int getWidth() const =0
void setHeight(const int height)
Definition: widget.cpp:139
bool mShowAvatar
Definition: npcdialog.h:320
BeingInfo * get(const BeingTypeId id)
Definition: avatardb.cpp:140
void logic()
Definition: being.cpp:1793
const BeingId BeingId_zero
Definition: beingid.h:29
PlayerBox * mPlayerBox
Definition: npcdialog.h:313

◆ showCloseButton()

void NpcDialog::showCloseButton ( )

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

Definition at line 310 of file npcdialog.cpp.

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

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

311 {
313  buildLayout();
314 }
NpcActionStateT mActionState
Definition: npcdialog.h:310
void buildLayout()
Definition: npcdialog.cpp:1048

◆ showNextButton()

void NpcDialog::showNextButton ( )

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

Definition at line 304 of file npcdialog.cpp.

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

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

305 {
307  buildLayout();
308 }
NpcActionStateT mActionState
Definition: npcdialog.h:310
void buildLayout()
Definition: npcdialog.cpp:1048

◆ textRequest()

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

Requests a text string from the user.

Definition at line 744 of file npcdialog.cpp.

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

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

745 {
748  mDefaultString = defaultText;
749  mTextField->setText(defaultText);
750 
751  buildLayout();
752 }
NpcActionStateT mActionState
Definition: npcdialog.h:310
std::string mDefaultString
Definition: npcdialog.h:272
void setText(const std::string &text)
Definition: textfield.cpp:799
void buildLayout()
Definition: npcdialog.cpp:1048
NpcInputStateT mInputState
Definition: npcdialog.h:309
TextField * mTextField
Definition: npcdialog.h:290

Field Documentation

◆ instances

NpcDialog::DialogList NpcDialog::instances
staticprivate

Definition at line 245 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 314 of file npcdialog.h.

Referenced by logic(), and showAvatar().

◆ mButton

Button* NpcDialog::mButton
private

◆ mButton2

Button* NpcDialog::mButton2
private

Definition at line 298 of file npcdialog.h.

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

◆ mButton3

Button* NpcDialog::mButton3
private

Definition at line 299 of file npcdialog.h.

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

◆ mCameraMode

int NpcDialog::mCameraMode
private

Definition at line 317 of file npcdialog.h.

Referenced by restoreCamera(), and saveCamera().

◆ mCameraX

int NpcDialog::mCameraX
private

Definition at line 318 of file npcdialog.h.

Referenced by restoreCamera(), and saveCamera().

◆ mCameraY

int NpcDialog::mCameraY
private

Definition at line 319 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 271 of file npcdialog.h.

Referenced by action(), and integerRequest().

◆ mDefaultString

std::string NpcDialog::mDefaultString
private

Definition at line 272 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 282 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 306 of file npcdialog.h.

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

◆ mItemLinkHandler

ItemLinkHandler* NpcDialog::mItemLinkHandler
private

Definition at line 287 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 307 of file npcdialog.h.

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

◆ mLastNextTime

int NpcDialog::mLastNextTime
private

Definition at line 316 of file npcdialog.h.

◆ mListScrollArea

ScrollArea* NpcDialog::mListScrollArea
private

Definition at line 284 of file npcdialog.h.

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

◆ mLogInteraction

bool NpcDialog::mLogInteraction
private

Definition at line 321 of file npcdialog.h.

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

◆ mMinusButton

Button* NpcDialog::mMinusButton
private

Definition at line 293 of file npcdialog.h.

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

◆ mNewText

std::string NpcDialog::mNewText
private

Definition at line 278 of file npcdialog.h.

Referenced by action(), and addText().

◆ mNpcDialogs

NpcDialogs NpcDialog::mNpcDialogs
static

◆ mNpcId

BeingId NpcDialog::mNpcId
private

Definition at line 269 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 292 of file npcdialog.h.

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

◆ mResetButton

Button* NpcDialog::mResetButton
private

Definition at line 302 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 285 of file npcdialog.h.

Referenced by createSkinControls(), and deleteSkinControls().

◆ mSkinControls

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

Definition at line 311 of file npcdialog.h.

◆ mSkinName

std::string NpcDialog::mSkinName
private

Definition at line 312 of file npcdialog.h.

Referenced by setSkin().

◆ mSkinScrollArea

ScrollArea* NpcDialog::mSkinScrollArea
private

Definition at line 286 of file npcdialog.h.

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

◆ mText

std::string NpcDialog::mText
private

Definition at line 277 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: