Mana
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members

The npc dialog. More...

#include <npcdialog.h>

Inheritance diagram for NpcDialog:
Window

Public Member Functions

 NpcDialog (int npcId)
 
 ~NpcDialog () override
 
void action (const gcn::ActionEvent &event) override
 Called when receiving actions from the widgets.
 
void setText (const std::vector< std::string > &string)
 Sets the text shows in the dialog.
 
void addText (const std::string &string, bool save=true)
 Adds the text to the text shows in the dialog.
 
void showNextButton ()
 When called, the widget will show a "Next" button.
 
void showCloseButton ()
 When called, the widget will show a "Close" button and will close the dialog when clicked.
 
void nextDialog ()
 Notifies the server that client has performed a next action.
 
void close () override
 Notifies the server that the client has performed a close action.
 
int getNumberOfElements () override
 Returns the number of items in the choices list.
 
std::string getElementAt (int i) override
 Returns the name of item number i of the choices list.
 
void choiceRequest ()
 Makes this dialog request a choice selection from the user.
 
void addChoice (const std::string &)
 Adds a choice to the list box.
 
void initChoiceSelection ()
 Put focus on the first choice.
 
void textRequest (const std::string &defaultText=std::string())
 Requests a text string from the user.
 
bool isInputFocused () const
 
bool isTextInputFocused () const
 
void integerRequest (int defaultValue, int min, int max)
 Requests an integer from the user.
 
void move (int amount)
 
void setVisible (bool visible) override
 Overloads window setVisible by Guichan to allow sticky window handling.
 
void mouseClicked (gcn::MouseEvent &mouseEvent) override
 
bool isWaitingForTheServer () const
 
- Public Member Functions inherited from Window
 Window (const std::string &caption="Window", bool modal=false, Window *parent=nullptr)
 Constructor.
 
 Window (SkinType skinType, const std::string &caption="Window", bool modal=false, Window *parent=nullptr)
 Constructor that allows customizing the SkinType used by the window.
 
 ~Window () override
 Destructor.
 
void draw (gcn::Graphics *graphics) override
 Draws the window contents.
 
void drawFrame (gcn::Graphics *graphics) override
 Draws the window frame.
 
void setContentSize (int width, int height)
 Sets the size of this window.
 
void setMinimumContentSize (int width, int height)
 Sets the minimum size of the window content.
 
void setLocationRelativeTo (gcn::Widget *widget)
 Sets the location relative to the given widget.
 
void setResizable (bool resize)
 Sets whether or not the window can be resized.
 
void redraw ()
 
void widgetResized (const gcn::Event &event) override
 Called whenever the widget changes size.
 
void widgetHidden (const gcn::Event &event) override
 Called whenever the widget is hidden.
 
void setCloseButton (bool flag)
 Sets whether or not the window has a close button.
 
bool isResizable () const
 Returns whether the window can be resized.
 
void setMinWidth (int width)
 Sets the minimum width of the window.
 
int getMinWidth () const
 
void setMinHeight (int height)
 Sets the minimum height of the window.
 
int getMinHeight () const
 
void setMaxWidth (int width)
 Sets the maximum width of the window.
 
int getMaxWidth () const
 
void setMaxHeight (int height)
 Sets the minimum height of the window.
 
int getMaxHeight () const
 
void setShowTitle (bool flag)
 Sets flag to show a title or not.
 
void setStickyButton (bool flag)
 Sets whether or not the window has a sticky button.
 
void setSticky (bool sticky)
 Sets whether the window is sticky.
 
bool isSticky () const
 Returns whether the window is sticky.
 
void setVisible (bool visible, bool forceSticky)
 Overloads window setVisible by Guichan to allow sticky window handling, or not, if you force the sticky state.
 
bool isDefaultVisible () const
 Returns whether the window is visible by default.
 
void setDefaultVisible (bool save)
 Sets whether the window is visible by default.
 
bool willSaveVisible () const
 Returns whether the window will save it's visibility.
 
void setSaveVisible (bool save)
 Sets whether the window will save it's visibility.
 
WindowgetParentWindow () const
 Returns the parent window.
 
void scheduleDelete ()
 Schedule this window for deletion.
 
void mousePressed (gcn::MouseEvent &event) override
 Starts window resizing when appropriate.
 
void mouseDragged (gcn::MouseEvent &event) override
 Implements window resizing and makes sure the window is not dragged/resized outside of the screen.
 
void mouseMoved (gcn::MouseEvent &event) override
 Implements custom cursor image changing context, based on mouse relative position.
 
void mouseReleased (gcn::MouseEvent &event) override
 When the mouse button has been let go, this ensures that the mouse custom cursor is restored back to it's standard image.
 
void mouseExited (gcn::MouseEvent &event) override
 When the mouse leaves the window this ensures that the custom cursor is restored back to it's standard image.
 
void setWindowName (const std::string &name)
 Sets the name of the window.
 
const std::string & getWindowName () const
 Returns the name of the window.
 
void loadWindowState ()
 Reads the position (and the size for resizable windows) in the configuration based on the given string.
 
void saveWindowState () const
 Saves the window state so that when the window is reloaded, it'll maintain its previous state and location.
 
void setDefaultSize (int defaultX, int defaultY, int defaultWidth, int defaultHeight)
 Set the default win pos and size.
 
void setDefaultSize ()
 Set the default win pos and size to the current ones.
 
void setDefaultSize (int defaultWidth, int defaultHeight, WindowAlignment alignment, int offsetx=0, int offsetY=0)
 Set the default win pos and size.
 
virtual void resetToDefaultSize ()
 Reset the win pos and size to default.
 
void adjustPositionAfterResize (int oldScreenWidth, int oldScreenHeight)
 Adjusts the window position after the application window has been resized.
 
LayoutgetLayout ()
 Gets the layout handler for this window.
 
void clearLayout ()
 Clears the window's layout (useful for redesigning the window).
 
void reflowLayout (int w=0, int h=0)
 Computes the position of the widgets according to the current layout.
 
LayoutCellplace (int x, int y, gcn::Widget *, int w=1, int h=1)
 Adds a widget to the window and sets it at given cell.
 
ContainerPlacer getPlacer (int x, int y)
 Returns a proxy for adding widgets in an inner table of the layout.
 
void center ()
 Positions the window in the center of it's parent.
 
const SkingetSkin () const
 Returns the Skin used by this window.
 

Static Public Member Functions

static bool isAnyInputFocused ()
 
static NpcDialoggetActive ()
 Returns the first active instance.
 
static void closeAll ()
 Closes all instances.
 
static void setup ()
 
- Static Public Member Functions inherited from Window
static void setWindowContainer (WindowContainer *windowContainer)
 Sets the window container to be used by new windows.
 
static int getGuiAlpha ()
 Gets the alpha value used by the window, in a Guichan usable format.
 

Private Types

enum  NpcInputState { NPC_INPUT_NONE , NPC_INPUT_LIST , NPC_INPUT_STRING , NPC_INPUT_INTEGER }
 
enum  NpcActionState { NPC_ACTION_WAIT , NPC_ACTION_NEXT , NPC_ACTION_INPUT , NPC_ACTION_CLOSE }
 
using DialogList = std::list< NpcDialog * >
 

Private Member Functions

void buildLayout ()
 

Private Attributes

int mNpcId
 
int mDefaultInt = 0
 
std::string mDefaultString
 
gcn::ScrollArea * mScrollArea
 
BrowserBoxmTextBox
 
std::vector< std::string > mNewText
 
std::unique_ptr< ItemLinkHandlermItemLinkHandler
 
ListBoxmItemList
 
gcn::ScrollArea * mListScrollArea
 
std::vector< std::string > mItems
 
TextFieldmTextField
 
IntTextFieldmIntField
 
ButtonmPlusButton
 
ButtonmMinusButton
 
ButtonmClearButton
 
ButtonmNextButton
 
ButtonmResetButton
 
NpcInputState mInputState = NPC_INPUT_NONE
 
NpcActionState mActionState = NPC_ACTION_WAIT
 

Static Private Attributes

static DialogList instances
 

Additional Inherited Members

- Static Protected Attributes inherited from Window
static int mouseResize = 0
 Active resize handles.
 

Detailed Description

The npc dialog.

Definition at line 46 of file npcdialog.h.

Member Typedef Documentation

◆ DialogList

using NpcDialog::DialogList = std::list<NpcDialog *>
private

Definition at line 161 of file npcdialog.h.

Member Enumeration Documentation

◆ NpcActionState

Enumerator
NPC_ACTION_WAIT 
NPC_ACTION_NEXT 
NPC_ACTION_INPUT 
NPC_ACTION_CLOSE 

Definition at line 205 of file npcdialog.h.

◆ NpcInputState

Enumerator
NPC_INPUT_NONE 
NPC_INPUT_LIST 
NPC_INPUT_STRING 
NPC_INPUT_INTEGER 

Definition at line 197 of file npcdialog.h.

Constructor & Destructor Documentation

◆ NpcDialog()

NpcDialog::NpcDialog ( int  npcId)

Definition at line 71 of file npcdialog.cpp.

◆ ~NpcDialog()

NpcDialog::~NpcDialog ( )
override

Definition at line 147 of file npcdialog.cpp.

Member Function Documentation

◆ action()

void NpcDialog::action ( const gcn::ActionEvent &  event)
override

Called when receiving actions from the widgets.

Definition at line 198 of file npcdialog.cpp.

◆ addChoice()

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

Adds a choice to the list box.

Definition at line 302 of file npcdialog.cpp.

◆ addText()

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

Adds the text to the text shows in the dialog.

Also adds a newline to the end.

Parameters
stringThe text to add.

Definition at line 174 of file npcdialog.cpp.

◆ buildLayout()

void NpcDialog::buildLayout ( )
private

Definition at line 422 of file npcdialog.cpp.

◆ choiceRequest()

void NpcDialog::choiceRequest ( )

Makes this dialog request a choice selection from the user.

Definition at line 294 of file npcdialog.cpp.

◆ close()

void NpcDialog::close ( )
overridevirtual

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

@overrides Window::close()

Reimplemented from Window.

Definition at line 278 of file npcdialog.cpp.

◆ closeAll()

void NpcDialog::closeAll ( )
static

Closes all instances.

Definition at line 406 of file npcdialog.cpp.

◆ getActive()

NpcDialog * NpcDialog::getActive ( )
static

Returns the first active instance.

Useful for pushing user interaction.

Definition at line 394 of file npcdialog.cpp.

◆ getElementAt()

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

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

Definition at line 289 of file npcdialog.cpp.

◆ getNumberOfElements()

int NpcDialog::getNumberOfElements ( )
override

Returns the number of items in the choices list.

Definition at line 284 of file npcdialog.cpp.

◆ initChoiceSelection()

void NpcDialog::initChoiceSelection ( )

Put focus on the first choice.

Definition at line 307 of file npcdialog.cpp.

◆ integerRequest()

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

Requests an integer from the user.

Definition at line 340 of file npcdialog.cpp.

◆ isAnyInputFocused()

bool NpcDialog::isAnyInputFocused ( )
static

Definition at line 331 of file npcdialog.cpp.

◆ isInputFocused()

bool NpcDialog::isInputFocused ( ) const

Definition at line 326 of file npcdialog.cpp.

◆ isTextInputFocused()

bool NpcDialog::isTextInputFocused ( ) const

Definition at line 321 of file npcdialog.cpp.

◆ isWaitingForTheServer()

bool NpcDialog::isWaitingForTheServer ( ) const
inline

Definition at line 150 of file npcdialog.h.

◆ mouseClicked()

void NpcDialog::mouseClicked ( gcn::MouseEvent &  mouseEvent)
override

Definition at line 379 of file npcdialog.cpp.

◆ move()

void NpcDialog::move ( int  amount)

Definition at line 350 of file npcdialog.cpp.

◆ nextDialog()

void NpcDialog::nextDialog ( )

Notifies the server that client has performed a next action.

Definition at line 273 of file npcdialog.cpp.

◆ setText()

void NpcDialog::setText ( const std::vector< std::string > &  string)

Sets the text shows in the dialog.

Parameters
stringThe new text.

Definition at line 167 of file npcdialog.cpp.

◆ setup()

void NpcDialog::setup ( )
static

Definition at line 412 of file npcdialog.cpp.

◆ setVisible()

void NpcDialog::setVisible ( bool  visible)
overridevirtual

Overloads window setVisible by Guichan to allow sticky window handling.

Reimplemented from Window.

Definition at line 369 of file npcdialog.cpp.

◆ showCloseButton()

void NpcDialog::showCloseButton ( )

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

Definition at line 192 of file npcdialog.cpp.

◆ showNextButton()

void NpcDialog::showNextButton ( )

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

Definition at line 186 of file npcdialog.cpp.

◆ textRequest()

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

Requests a text string from the user.

Definition at line 312 of file npcdialog.cpp.

Member Data Documentation

◆ instances

NpcDialog::DialogList NpcDialog::instances
staticprivate

Definition at line 162 of file npcdialog.h.

◆ mActionState

NpcActionState NpcDialog::mActionState = NPC_ACTION_WAIT
private

Definition at line 214 of file npcdialog.h.

◆ mClearButton

Button* NpcDialog::mClearButton
private

Definition at line 189 of file npcdialog.h.

◆ mDefaultInt

int NpcDialog::mDefaultInt = 0
private

Definition at line 168 of file npcdialog.h.

◆ mDefaultString

std::string NpcDialog::mDefaultString
private

Definition at line 169 of file npcdialog.h.

◆ mInputState

NpcInputState NpcDialog::mInputState = NPC_INPUT_NONE
private

Definition at line 213 of file npcdialog.h.

◆ mIntField

IntTextField* NpcDialog::mIntField
private

Definition at line 185 of file npcdialog.h.

◆ mItemLinkHandler

std::unique_ptr<ItemLinkHandler> NpcDialog::mItemLinkHandler
private

Definition at line 176 of file npcdialog.h.

◆ mItemList

ListBox* NpcDialog::mItemList
private

Definition at line 179 of file npcdialog.h.

◆ mItems

std::vector<std::string> NpcDialog::mItems
private

Definition at line 181 of file npcdialog.h.

◆ mListScrollArea

gcn::ScrollArea* NpcDialog::mListScrollArea
private

Definition at line 180 of file npcdialog.h.

◆ mMinusButton

Button* NpcDialog::mMinusButton
private

Definition at line 187 of file npcdialog.h.

◆ mNewText

std::vector<std::string> NpcDialog::mNewText
private

Definition at line 174 of file npcdialog.h.

◆ mNextButton

Button* NpcDialog::mNextButton
private

Definition at line 192 of file npcdialog.h.

◆ mNpcId

int NpcDialog::mNpcId
private

Definition at line 166 of file npcdialog.h.

◆ mPlusButton

Button* NpcDialog::mPlusButton
private

Definition at line 186 of file npcdialog.h.

◆ mResetButton

Button* NpcDialog::mResetButton
private

Definition at line 195 of file npcdialog.h.

◆ mScrollArea

gcn::ScrollArea* NpcDialog::mScrollArea
private

Definition at line 172 of file npcdialog.h.

◆ mTextBox

BrowserBox* NpcDialog::mTextBox
private

Definition at line 173 of file npcdialog.h.

◆ mTextField

TextField* NpcDialog::mTextField
private

Definition at line 184 of file npcdialog.h.


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