diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-03-25 22:50:59 +0100 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-03-25 22:50:59 +0100 |
commit | cc79f0fe21e1a2ef73cbe987d54e848b9a47142d (patch) | |
tree | edd316eb6094f0c02d6d014385865dcd88a2bc56 /src/gui/npcstringdialog.cpp | |
parent | b0df784f1be44a657ca8092069488602270629b7 (diff) | |
parent | 99e8a3fd77b63a029fe02dcf771b6af1aad252ed (diff) | |
download | mana-cc79f0fe21e1a2ef73cbe987d54e848b9a47142d.tar.gz mana-cc79f0fe21e1a2ef73cbe987d54e848b9a47142d.tar.bz2 mana-cc79f0fe21e1a2ef73cbe987d54e848b9a47142d.tar.xz mana-cc79f0fe21e1a2ef73cbe987d54e848b9a47142d.zip |
Merge branch 'eathena/master'
Conflicts:
A lot of files.
Diffstat (limited to 'src/gui/npcstringdialog.cpp')
-rw-r--r-- | src/gui/npcstringdialog.cpp | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/src/gui/npcstringdialog.cpp b/src/gui/npcstringdialog.cpp index d9bf5682..c84de015 100644 --- a/src/gui/npcstringdialog.cpp +++ b/src/gui/npcstringdialog.cpp @@ -28,16 +28,29 @@ #include "../npc.h" +#include "../net/messageout.h" +#ifdef EATHENA_SUPPORT +#include "../net/ea/protocol.h" +#endif + #include "../utils/gettext.h" #include "../utils/strprintf.h" -extern NpcTextDialog *npcTextDialog; - -NpcStringDialog::NpcStringDialog(): - Window(_("NPC Text Request")) +#ifdef TMWSERV_SUPPORT +NpcStringDialog::NpcStringDialog() +#else +NpcStringDialog::NpcStringDialog(Network *network) +#endif + : Window(_("NPC Text Request")) +#ifdef EATHENA_SUPPORT + , mNetwork(network) +#endif { + setWindowName("NPCString"); mValueField = new TextField(""); + setDefaultSize(175, 75, ImageRect::CENTER); + gcn::Button *okButton = new Button(_("OK"), "ok", this); gcn::Button *cancelButton = new Button(_("Cancel"), "cancel", this); @@ -46,7 +59,9 @@ NpcStringDialog::NpcStringDialog(): place(2, 1, okButton); reflowLayout(175, 0); - setLocationRelativeTo(getParent()); + center(); + setDefaultSize(); + loadWindowState(); } std::string NpcStringDialog::getValue() @@ -74,8 +89,19 @@ void NpcStringDialog::action(const gcn::ActionEvent &event) } setVisible(false); - current_npc->stringInput(mValueField->getText()); + NPC::isTalking = false; + + std::string text = mValueField->getText(); mValueField->setText(""); + +#ifdef EATHENA_SUPPORT + MessageOut outMsg(mNetwork); + outMsg.writeInt16(CMSG_NPC_STR_RESPONSE); + outMsg.writeInt16(text.length() + 9); + outMsg.writeInt32(current_npc); + outMsg.writeString(text, text.length()); + outMsg.writeInt8(0); +#endif } bool NpcStringDialog::isInputFocused() @@ -87,3 +113,13 @@ void NpcStringDialog::requestFocus() { mValueField->requestFocus(); } + +void NpcStringDialog::setVisible(bool visible) +{ + if (visible) { + npcTextDialog->setVisible(true); + requestFocus(); + } + + Window::setVisible(visible); +} |