Dialog box cutscene management

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent 50103f7032
commit a89540ab70
  1. BIN
      C++ProjectTemplate
  2. 25
      cutscene.h
  3. 21
      main.cpp

Binary file not shown.

@ -18,6 +18,7 @@ enum class ActionType{
CLEANUP, CLEANUP,
SET_FLAG_WHEN_CUTSCENE_ENDS, SET_FLAG_WHEN_CUTSCENE_ENDS,
FADE, FADE,
DIALOG,
}; };
class CutsceneAction{ class CutsceneAction{
@ -96,7 +97,7 @@ class Fade:public CutsceneAction{
double fadeSpd=0; double fadeSpd=0;
public: public:
//If false, it fades out instead. //If false, it fades out instead.
Fade(bool fadeIn=false,double fadeSpd=1) { Fade(bool fadeIn=false,double fadeSpd=4) {
this->fadeIn=fadeIn; this->fadeIn=fadeIn;
this->fadeSpd=fadeSpd; 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. To use this class, specify multiple actions back-to-back, filling their appropriate arguments.

@ -183,15 +183,17 @@ public:
TestCutscene=new Cutscene({ TestCutscene=new Cutscene({
(CutsceneAction*)new Fade(), (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({ (CutsceneAction*)new CreateObjects({
new Object(PLAYER,"player",{64,64},ANIMATIONS["player.png"],{1,1},MAGENTA), 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",{136,136},ANIMATIONS["player.png"],{1,1},RED),
new Object(PLAYER,"player",{96,96},ANIMATIONS["player.png"],{1,1},DARK_GREEN), 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! /*DisplayMessageBox(R"(Hello World!
This is a rather long message, but I hope it reaches you well 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; }break;
case ActionType::DIALOG:{
if (!((DialogBox*)CurrentCutscene->GetAction())->MessageHasBeenShown()) {
DisplayMessageBox(((DialogBox*)CurrentCutscene->GetAction())->GetMessage());
((DialogBox*)CurrentCutscene->GetAction())->SetMessageBoxVisible();
} else
if (!messageBoxVisible) {
CurrentCutscene->AdvanceAction();
}
}break;
} }

Loading…
Cancel
Save