summaryrefslogtreecommitdiff
path: root/src/npc.cpp
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-01-07 15:22:44 +0000
committerJared Adams <jaxad0127@gmail.com>2009-01-18 10:24:58 +0000
commitccef6c4284a9cc250da72c5835501ae03c2c513f (patch)
tree0edc78d5572fe8a407884f772031bf6f1cac4ec2 /src/npc.cpp
parent5340364ee4b91d5d26358d1ec131016946f2998b (diff)
downloadmana-ccef6c4284a9cc250da72c5835501ae03c2c513f.tar.gz
mana-ccef6c4284a9cc250da72c5835501ae03c2c513f.tar.bz2
mana-ccef6c4284a9cc250da72c5835501ae03c2c513f.tar.xz
mana-ccef6c4284a9cc250da72c5835501ae03c2c513f.zip
Add dialogs to input text and numbers for scripts
Diffstat (limited to 'src/npc.cpp')
-rw-r--r--src/npc.cpp36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/npc.cpp b/src/npc.cpp
index 66048005..b107445a 100644
--- a/src/npc.cpp
+++ b/src/npc.cpp
@@ -80,14 +80,12 @@ void NPC::setName(const std::string &name)
gcn::Color(200, 200, 255));
}
-Being::Type
-NPC::getType() const
+Being::Type NPC::getType() const
{
return Being::NPC;
}
-void
-NPC::talk()
+void NPC::talk()
{
MessageOut outMsg(mNetwork);
outMsg.writeInt16(CMSG_NPC_TALK);
@@ -96,16 +94,14 @@ NPC::talk()
current_npc = this;
}
-void
-NPC::nextDialog()
+void NPC::nextDialog()
{
MessageOut outMsg(mNetwork);
outMsg.writeInt16(CMSG_NPC_NEXT_REQUEST);
outMsg.writeInt32(mId);
}
-void
-NPC::dialogChoice(char choice)
+void NPC::dialogChoice(char choice)
{
MessageOut outMsg(mNetwork);
outMsg.writeInt16(CMSG_NPC_LIST_CHOICE);
@@ -113,12 +109,29 @@ NPC::dialogChoice(char choice)
outMsg.writeInt8(choice);
}
+void NPC::integerInput(int value)
+{
+ MessageOut outMsg(mNetwork);
+ outMsg.writeInt16(CMSG_NPC_INT_RESPONSE);
+ outMsg.writeInt32(mId);
+ outMsg.writeInt32(value);
+}
+
+void NPC::stringInput(const std::string &value)
+{
+ MessageOut outMsg(mNetwork);
+ outMsg.writeInt16(CMSG_NPC_STR_RESPONSE);
+ outMsg.writeInt16(value.length() + 8);
+ outMsg.writeInt32(mId);
+ outMsg.writeString(value, value.length());
+ outMsg.writeInt8(0); // Just to be safe
+}
+
/*
* TODO Unify the buy() and sell() methods, without sacrificing readability of
* the code calling the method. buy(bool buySell) would be bad...
*/
-void
-NPC::buy()
+void NPC::buy()
{
MessageOut outMsg(mNetwork);
outMsg.writeInt16(CMSG_NPC_BUY_SELL_REQUEST);
@@ -126,8 +139,7 @@ NPC::buy()
outMsg.writeInt8(0);
}
-void
-NPC::sell()
+void NPC::sell()
{
MessageOut outMsg(mNetwork);
outMsg.writeInt16(CMSG_NPC_BUY_SELL_REQUEST);