diff --git a/C++ProjectTemplate b/C++ProjectTemplate index 38d0972..ac4d319 100755 Binary files a/C++ProjectTemplate and b/C++ProjectTemplate differ diff --git a/cutscene.h b/cutscene.h index ebd18b5..2e4946e 100644 --- a/cutscene.h +++ b/cutscene.h @@ -18,6 +18,7 @@ enum class ActionType{ CLEANUP, SET_FLAG_WHEN_CUTSCENE_ENDS, FADE, + DIALOG, }; class CutsceneAction{ @@ -96,7 +97,7 @@ class Fade:public CutsceneAction{ double fadeSpd=0; public: //If false, it fades out instead. - Fade(bool fadeIn=false,double fadeSpd=1) { + Fade(bool fadeIn=false,double fadeSpd=4) { this->fadeIn=fadeIn; this->fadeSpd=fadeSpd; } @@ -110,6 +111,28 @@ class Fade:public CutsceneAction{ } }; +class DialogBox:public CutsceneAction{ + private: + std::string message; + bool messageBoxVisible=false; + public: + //If false, it fades out instead. + DialogBox(std::string message) { + this->message=message; + } + ActionType GetActionType() override{return ActionType::DIALOG;} + //If false, then it means we need to fade out instead. + std::string GetMessage() { + return message; + } + void SetMessageBoxVisible() { + this->messageBoxVisible=true; + } + bool MessageHasBeenShown() { + return messageBoxVisible; + } + }; + /* To use this class, specify multiple actions back-to-back, filling their appropriate arguments. diff --git a/main.cpp b/main.cpp index ee5f82c..4407c57 100644 --- a/main.cpp +++ b/main.cpp @@ -183,15 +183,17 @@ public: TestCutscene=new Cutscene({ (CutsceneAction*)new Fade(), - (CutsceneAction*)new Fade(true), - (CutsceneAction*)new SetFlagWhenCutsceneEnds(Flag::TEST_FLAG1), - (CutsceneAction*)new PanCamera({128,128},BOTH), - (CutsceneAction*)new PanCamera({128,0},BOTH), (CutsceneAction*)new CreateObjects({ new Object(PLAYER,"player",{64,64},ANIMATIONS["player.png"],{1,1},MAGENTA), new Object(PLAYER,"player",{136,136},ANIMATIONS["player.png"],{1,1},RED), new Object(PLAYER,"player",{96,96},ANIMATIONS["player.png"],{1,1},DARK_GREEN), - }),}); + }), + (CutsceneAction*)new Fade(true), + (CutsceneAction*)new SetFlagWhenCutsceneEnds(Flag::TEST_FLAG1), + (CutsceneAction*)new PanCamera({128,128},BOTH), + (CutsceneAction*)new PanCamera({64,0},BOTH), + (CutsceneAction*)new DialogBox(R"(Hello! +This is a test message that lets us trigger straight from a cutscene! Cool!)"),}); /*DisplayMessageBox(R"(Hello World! This is a rather long message, but I hope it reaches you well @@ -307,6 +309,15 @@ goes on a very long time, I hope you can understand this is only for testing pur } } }break; + case ActionType::DIALOG:{ + if (!((DialogBox*)CurrentCutscene->GetAction())->MessageHasBeenShown()) { + DisplayMessageBox(((DialogBox*)CurrentCutscene->GetAction())->GetMessage()); + ((DialogBox*)CurrentCutscene->GetAction())->SetMessageBoxVisible(); + } else + if (!messageBoxVisible) { + CurrentCutscene->AdvanceAction(); + } + }break; }