47#include <guichan/font.hpp>
49#define CAPTION_WAITING _("Waiting for server")
50#define CAPTION_NEXT _("Next")
51#define CAPTION_CLOSE _("Close")
52#define CAPTION_SUBMIT _("Submit")
94 mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
95 mScrollArea->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_ALWAYS);
103 mListScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
170 for (
const std::string &row : text)
200 if (event.getId() ==
"ok")
213 std::string printText;
217 int selectedIndex =
mItemList->getSelected();
219 if (selectedIndex >= (
int)
mItems.size() || selectedIndex < 0)
222 printText =
mItems[selectedIndex];
248 else if (event.getId() ==
"reset")
259 else if (event.getId() ==
"inc")
263 else if (event.getId() ==
"dec")
267 else if (event.getId() ==
"clear")
334 if (dialog->isInputFocused())
381 if (mouseEvent.getSource() ==
mItemList &&
400 if (dialog->isFocused())
509 int count =
event.getInt(
"choiceCount");
510 for (
int i = 1; i <= count; i++)
518 int defaultValue =
event.getInt(
"default", 0);
519 int min =
event.getInt(
"min", 0);
520 int max =
event.getInt(
"max", 2147483647);
539 int id =
event.getInt(
"id");
542 dialog->showNextButton();
553 int id =
event.getInt(
"id");
556 dialog->showCloseButton();
591 dialog = diag->second;
A simple browser box able to handle links and forward events to the parent conteiner.
void setEnableKeys(bool enable)
Enable or disable the replacement of keys.
void addRow(std::string_view row)
Adds a text row to the browser.
void setLinkHandler(LinkHandler *handler)
Sets the handler for links.
void clearRows()
Remove all rows.
@ AUTO_WRAP
Maybe it needs a fix or to be redone.
void setWrapIndent(int indent)
Sets the wrap indent for the browser box.
void listen(Event::Channel channel)
TextBox which only accepts numbers as input.
void setRange(int minimum, int maximum)
Sets the minimum and maximum values of the text box.
int getValue()
Returns the value in the text box.
void setValue(int value)
Set the value of the text box to the specified value.
void setRowHeight(int n, int h)
This class is an helper for setting the position of widgets.
@ AUTO_SET
Uses the share as the new size.
A list box, meant to be used inside a scroll area.
virtual void closeDialog(int npcId)=0
virtual void menuSelect(int npcId, int choice)=0
virtual void integerInput(int npcId, int value)=0
virtual void stringInput(int npcId, const std::string &value)=0
virtual void nextDialog(int npcId)=0
static bool isAnyInputFocused()
void initChoiceSelection()
Put focus on the first choice.
void addChoice(const std::string &)
Adds a choice to the list box.
gcn::ScrollArea * mScrollArea
static DialogList instances
void action(const gcn::ActionEvent &event) override
Called when receiving actions from the widgets.
void setVisible(bool visible) override
Overloads window setVisible by Guichan to allow sticky window handling.
void integerRequest(int defaultValue, int min, int max)
Requests an integer from the user.
void nextDialog()
Notifies the server that client has performed a next action.
bool isWaitingForTheServer() const
bool isTextInputFocused() const
static NpcDialog * getActive()
Returns the first active instance.
std::unique_ptr< ItemLinkHandler > mItemLinkHandler
std::vector< std::string > mNewText
void choiceRequest()
Makes this dialog request a choice selection from the user.
std::list< NpcDialog * > DialogList
NpcActionState mActionState
void showNextButton()
When called, the widget will show a "Next" button.
bool isInputFocused() const
std::vector< std::string > mItems
std::string mDefaultString
void setText(const std::vector< std::string > &string)
Sets the text shows in the dialog.
void showCloseButton()
When called, the widget will show a "Close" button and will close the dialog when clicked.
std::string getElementAt(int i) override
Returns the name of item number i of the choices list.
void mouseClicked(gcn::MouseEvent &mouseEvent) override
void textRequest(const std::string &defaultText=std::string())
Requests a text string from the user.
void addText(const std::string &string, bool save=true)
Adds the text to the text shows in the dialog.
static void closeAll()
Closes all instances.
void close() override
Notifies the server that the client has performed a close action.
gcn::ScrollArea * mListScrollArea
NpcInputState mInputState
int getNumberOfElements() override
Returns the number of items in the choices list.
void removeDialog(int id)
NpcDialog * getDialog(int id, bool make=true)
void event(Event::Channel channel, const Event &event) override
std::map< int, NpcDialog * > mNpcDialogs
void center()
Positions the window in the center of it's parent.
virtual void setVisible(bool visible)
Overloads window setVisible by Guichan to allow sticky window handling.
void setMinHeight(int height)
Sets the minimum height of the window.
virtual void close()
Overrideable functionality for when the window is to close.
void clearLayout()
Clears the window's layout (useful for redesigning the window).
void setContentSize(int width, int height)
Sets the size of this window.
Layout & getLayout()
Gets the layout handler for this window.
void setWindowName(const std::string &name)
Sets the name of the window.
void setResizable(bool resize)
Sets whether or not the window can be resized.
LayoutCell & place(int x, int y, gcn::Widget *, int w=1, int h=1)
Adds a widget to the window and sets it at given cell.
void scheduleDelete()
Schedule this window for deletion.
void setCloseButton(bool flag)
Sets whether or not the window has a close button.
void setDefaultSize()
Set the default win pos and size to the current ones.
void loadWindowState()
Reads the position (and the size for resizable windows) in the configuration based on the given strin...
void setMinWidth(int width)
Sets the minimum width of the window.
Config config
Global settings (config.xml)
bool isDoubleClick(int selected)
Returns whether this call and the last call were done for the same selected index and within a short ...
NpcHandler * getNpcHandler()
void setNPCInteractionCount(int count)
Sets the number of currently open NPC interaction windows.
int getNPCInteractionCount()
Returns the number of currently open NPC interaction windows.
std::string strprintf(char const *format,...)
A safe version of sprintf that returns a std::string of the result.
std::string toString(const T &arg)
Converts the given value to a string using std::stringstream.