generated from sigonasr2/CPlusPlusProjectTemplate
Dialog box cutscene management
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
50103f7032
commit
a89540ab70
Binary file not shown.
25
cutscene.h
25
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.
|
||||
|
||||
|
21
main.cpp
21
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;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user