39 #include "gui/viewport.h"
85 #define CAPTION_WAITING _("Stop waiting")
87 #define CAPTION_NEXT _("Next")
89 #define CAPTION_CLOSE _("Close")
91 #define CAPTION_SUBMIT _("Submit")
109 "npc_textbackground.xml")),
115 this, this,
"extendedlistbox.xml", 13)),
118 "npc_listbackground.xml")),
122 "npc_listbackground.xml")),
146 "npc_listbackground.xml")),
159 mLogInteraction(
config.getBoolValue(
"logNpcInGui"))
235 if (being !=
nullptr)
295 if (
mText.size() > 5000)
321 const std::string &eventId =
event.getId();
341 std::string printText;
360 unsigned char choice =
CAST_U8(
362 printText =
mItems[selectedIndex];
417 for (
int f = 1; f < sz; f ++)
464 for (
int f = 1; f < sz; f ++)
500 for (
int f = 1; f < sz; f ++)
532 else if (eventId ==
"reset")
555 else if (eventId ==
"inc")
559 else if (eventId ==
"dec")
563 else if (eventId ==
"clear")
583 else if (eventId ==
"close")
612 else if (eventId ==
"add")
618 if (inventory !=
nullptr)
633 else if (eventId.find(
"skin_") == 0)
635 const std::string cmd = eventId.substr(5);
636 std::string printText;
708 std::istringstream iss(itemString);
711 while (getline(iss, tmp,
':'))
715 const size_t pos = tmp.find(
'|');
716 if (pos == std::string::npos)
723 mItems.push_back(tmp.substr(pos + 1));
725 std::string(tmp.substr(0, pos)).append(
".png")));
772 if (((*it) !=
nullptr) && (*it)->isInputFocused())
848 if (name ==
"logNpcInGui")
859 if (((*it) !=
nullptr) && (*it)->isFocused())
1147 if (
info !=
nullptr)
1149 width =
info->getWidth();
1154 if ((sprite !=
nullptr) && (width == 0))
1180 if (being !=
nullptr)
1187 if (being !=
nullptr)
1201 if (sprite !=
nullptr)
1220 const NpcDialogs::iterator it_end =
mNpcDialogs.end();
1221 while (it != it_end)
1223 delete (*it).second;
1260 if (dialog ==
nullptr)
1262 logger->
log(
"Error: creating controls for not existing npc dialog %s",
1282 FOR_EACH (STD_VECTOR<NpcImageInfo*>::const_iterator,
1288 if (image !=
nullptr)
1295 FOR_EACH (STD_VECTOR<NpcTextInfo*>::const_iterator,
1322 FOR_EACH (STD_VECTOR<NpcButtonInfo*>::const_iterator,
1333 if (!
info->image.empty())
1347 if (inventory !=
nullptr)
1354 if (item !=
nullptr)
1356 const STD_VECTOR<Item*> &items = item->
getChilds();
1357 const size_t sz = items.size();
1361 const Item *item2 = items[0];
1366 for (
size_t f = 1; f < sz; f ++)
1391 if (inventory ==
nullptr)
ActorManager * actorManager
const bool AutoRelease_true
BeingAction ::T BeingActionT
const BeingId BeingId_zero
const BeingTypeId BeingTypeId_zero
#define fromBool(val, name)
Being * findBeing(const BeingId id) const
virtual void add(Widget *const widget)
virtual void setDirection(const uint8_t direction)
virtual void setAction(const BeingActionT &action, const int attackId)
BeingTypeId getSubType() const
const std::string & getName() const
static Being * createBeing(const BeingId id, const ActorTypeT type, const BeingTypeId subtype, Map *const map)
std::string getTextAtPos(const int x, const int y) const
void setMaxRow(unsigned max)
void setEnableTabs(const bool n)
void addRow(const std::string &row, const bool atTop)
void setLinkHandler(LinkHandler *linkHandler)
void setEnableImages(const bool n)
void setEnableKeys(const bool n)
void setOpaque(Opaque opaque)
void setProcessVars(const bool n)
bool addVirtualItem(const Item *const item, int index, const int amount)
const std::vector< Item * > & getChilds() const
std::vector< Sprite * > mSprites
bool getBoolValue(const std::string &key) const
std::string getStringValue(const std::string &key) const
void addListener(const std::string &key, ConfigListener *const listener)
void removeListeners(ConfigListener *const listener)
int getIntValue(const std::string &key) const
Widget * getSource() const
int getWidth(const std::string &text) const
Font * getNpcFont() const
void setValue(const int value)
void setRange(const int minimum, const int maximum)
Item * getSelectedItem() const
void virtualRemove(Item *const item, const int amount)
Item * getItem(const int index) const
virtual bool addVirtualItem(const Item *const item, int index, const int amount)
void resize(const unsigned int newSize)
void setCellBackgroundImage(const std::string &xmlName)
void setInventory(Inventory *const inventory)
void setMaxColumns(const int maxColumns)
ItemColor getColor() const
void setRowHeight(const int n, const int h)
void setDistributeMousePressed(const bool b)
void setRowHeight(unsigned int n)
void setSelected(const int selected)
void setWrappingEnabled(const bool wrappingEnabled)
void log(const char *const log_text,...)
MouseButtonT getButton() const
virtual void closeDialog(const BeingId npcId)=0
virtual void stringInput(const BeingId npcId, const std::string &value) const =0
virtual void listInput(const BeingId npcId, const unsigned char value) const =0
virtual void integerInput(const BeingId npcId, const int value) const =0
virtual void nextDialog(const BeingId npcId) const =0
static bool isAnyInputFocused()
void itemRequest(const int size)
void placeIntInputControls()
void addChoice(const std::string &)
std::string getElementAt(int i)
void copyToClipboard(const int x, const int y) const
ExtendedListBox * mItemList
static DialogList instances
void textRequest(const std::string &defaultText)
void deleteSkinControls()
void placeNormalControls()
void setSkin(const std::string &skin)
std::list< NpcDialog * > DialogList
void addText(const std::string &string, const bool save)
void createSkinControls()
void placeTextInputControls()
bool isTextInputFocused() const
void itemCraftRequest(const int size)
void addCraftItem(Item *const item, const int amount, const int slot)
ScrollArea * mItemScrollArea
static std::string complexItemToStr(const ComplexItem *const item)
void itemIndexRequest(const int size)
ComplexInventory * mComplexInventory
const NpcDialogInfo * mDialogInfo
static NpcDialog * getActive()
void parseListItems(const std::string &itemString)
NpcDialog(const BeingId npcId)
ItemLinkHandler * mItemLinkHandler
void mousePressed(MouseEvent &event)
void placeItemInputControls()
void move(const int amount)
void setAvatarAction(const int actionId)
void setVisible(Visible visible)
ScrollArea * mListScrollArea
bool isInputFocused() const
std::vector< Image * > mImages
void showAvatar(const BeingTypeId avatarId)
ScrollArea * mSkinScrollArea
NpcInputStateT mInputState
std::string mDefaultString
int getNumberOfElements()
void setAvatarDirection(const uint8_t direction)
static NpcDialogs mNpcDialogs
static void restoreVirtuals()
NpcActionStateT mActionState
static void clearDialogs()
void optionChanged(const std::string &name)
ItemContainer * mItemContainer
Container * mSkinContainer
void action(const ActionEvent &event)
const Image * getImageAt(int i)
void integerRequest(const int defaultValue, const int min, const int max)
void setPlayer(Being *being)
void playGuiSound(const std::string &name)
virtual int getHeight() const =0
virtual int getWidth() const =0
const std::string & getText() const
void setText(const std::string &text)
static Image * getImageFromTheme(const std::string &path)
void setCameraRelativeX(const int n)
void setCameraRelativeY(const int n)
int getCameraRelativeY() const
int getCameraRelativeX() const
void setResizable(const bool resize)
virtual void setVisible(Visible visible)
void setContentSize(int width, int height)
void setWindowName(const std::string &name)
void setCaption(const std::string &caption)
void setMinHeight(const int height)
void setMinWidth(const int width)
void mousePressed(MouseEvent &event)
void enableVisibleSound(bool b)
virtual void scheduleDelete()
void setStickyButtonLock(const bool sticky)
LayoutCell & place(const int x, const int y, Widget *const wg, const int w, const int h)
bool sendBuffer(const std::string &text)
CutInWindow * cutInWindow
const bool ForceQuantity_false
#define FOR_EACH(type, iter, array)
#define fromInt(val, name)
InventoryWindow * inventoryWindow
const bool LoseFocusOnTab_true
bool info(InputEvent &event)
BeingInfo * get(const BeingTypeId id)
Image * getImage(const std::string &idPath)
BeingTypeId getAvatarFor(const BeingTypeId id)
NpcDialogInfo * getDialog(const std::string &name)
bool limitPackets(const PacketTypeT type)
Inventory * getInventory()
Net::NpcHandler * npcHandler
std::vector< Image * >::iterator ImageVectorIter
std::map< BeingId, NpcDialog * > NpcDialogs
#define BLOCK_START(name)
const bool ShowEmptyRows_true
static const std::string SOUND_SHOW_WINDOW
SoundManager soundManager
std::string strprintf(const char *const format,...)
void splitToStringVector(StringVect &tokens, const std::string &text, const char separator)
std::string pathJoin(std::string str1, const std::string &str2)
StringVect::const_iterator StringVectCIter
std::vector< std::string > StringVect
NpcInventoryInfo inventory