diff --git a/C++ProjectTemplate b/C++ProjectTemplate index c75a219..0a326a8 100755 Binary files a/C++ProjectTemplate and b/C++ProjectTemplate differ diff --git a/main.cpp b/main.cpp index 9ebcd08..a9a9e76 100644 --- a/main.cpp +++ b/main.cpp @@ -171,6 +171,7 @@ int MESSAGE_BOX_DIALOG_CHOICES_MADE=0; std::vector MESSAGE_BOX_CHOICE_LIST={}; bool waitingForChoice=false; int MESSAGE_BOX_DIALOG_CHOICE_CURSOR=0; +Object*INTERACTING_WITH=nullptr; /* [Choice1,Choice2,Choice3] @@ -800,16 +801,19 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"), messageBoxMarker++; int counter=0; while (messageBoxFinalText[messageBoxMarker]-'0'!=MESSAGE_BOX_DIALOG_CHOICE_CURSOR) { - while(messageBoxFinalText[messageBoxMarker]!='>'&&messageBoxFinalText[messageBoxMarker]!='<') { + while(messageBoxFinalText[messageBoxMarker]!='>'&&messageBoxFinalText[messageBoxMarker]!='<'&&messageBoxFinalText[messageBoxMarker]!='\t') { messageBoxMarker++; } messageBoxMarker++; } messageBoxMarker+=2; } - while (messageBoxFinalText[messageBoxMarker]!='<'&&messageBoxFinalText[messageBoxMarker]!='>') { + while (messageBoxFinalText[messageBoxMarker]!='<'&&messageBoxFinalText[messageBoxMarker]!='>'&&messageBoxFinalText[messageBoxMarker]!='\t') { responseText+=messageBoxFinalText[messageBoxMarker++]; } + if (INTERACTING_WITH!=nullptr) { + INTERACTING_WITH->ChoiceMade(MESSAGE_BOX_DIALOG_CHOICE_CURSOR); + } DisplayMessageBox(""); targetText=responseText; } @@ -1267,6 +1271,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"), } if (closest!=nullptr) { //Run the Interaction for this object. + INTERACTING_WITH=closest; Interaction interaction = closest->Interact(); if (interaction.messages.size()>0) { INTERACTION_MESSAGES=interaction.messages; diff --git a/object.h b/object.h index 22be1c7..bbb163f 100644 --- a/object.h +++ b/object.h @@ -58,6 +58,7 @@ class Object{ virtual Object* CreateType(int id,std::string name,vd2d pos,Animation*spr,vd2d scale={1,1},Pixel color=WHITE,int animationSpd=1,bool temp=false)=0; //When the player tries to interact with this object. virtual Interaction Interact()=0; + virtual void ChoiceMade(int choice)=0; void SetScale(vd2d scale) { this->scale=scale; if (spr!=nullptr) { @@ -171,6 +172,7 @@ class Object{ class Standard_Obj : public Object{ DynamicObject(Standard_Obj) Interaction Interact()override{return {};} + void ChoiceMade(int choice)override{} }; class TrashCan_Obj : public Object{ @@ -178,6 +180,7 @@ class TrashCan_Obj : public Object{ Interaction Interact()override{ frameIndex=1; return {{"You dig around the trash can.","Nope! Just looks like plain ol' trash."}};} + void ChoiceMade(int choice)override{} }; extern int MESSAGE_BOX_DIALOG_ANSWER; @@ -191,15 +194,25 @@ class Shopkeeper_Obj : public Object{ >1:What would you like to sell?\ >2:Are you okay?<"; Interaction Interact()override{ - if (GAME_FLAGS[(int)Flag::SHOPKEER_BRANCH1]&&MESSAGE_BOX_DIALOG_ANSWER==2) { - MESSAGE_BOX_DIALOG_ANSWER=0; + if (GAME_FLAGS[(int)Flag::SHOPKEER_BRANCH1]) { GAME_FLAGS[(int)Flag::SHOPKEER_BRANCH1]=false; - return {{"No! Stay away! [Okay,Ignore]\ - >0:Yeah I thought so.\ - >1:...<"}}; + switch (MESSAGE_BOX_DIALOG_ANSWER) { + case 2:{ + return {{"No! Stay away! [Okay,Ignore]\ + >0:Yeah I thought so.\ + >1:...<"}}; + }break; + } } else { return {{welcomeMessage},flag:Flag::SHOPKEER_BRANCH1}; } } + void ChoiceMade(int choice)override{ + if (GAME_FLAGS[(int)Flag::SHOPKEER_BRANCH1]) { + if (choice!=2) { + GAME_FLAGS[(int)Flag::SHOPKEER_BRANCH1]=false; + } + } + } }; #endif \ No newline at end of file