Refactoring cutscenes

This commit is contained in:
Vladislav Khorev committed 2026-06-06 22:04:42 +03:00
1 parent 7011bbb754
commit 2e5988f8f4
20 files changed
+1913 -1881

No files matched your search

+29 -9
View File
@@ -2,6 +2,9 @@
#include "dialogue/DialogueOverlay.h"
#include "dialogue/DialogueRuntime.h"
#include "cutscene/CutsceneDatabase.h"
#include "cutscene/CutsceneOverlay.h"
#include "cutscene/CutsceneRuntime.h"
#include "quest/QuestJournal.h"
#include <SDL.h>
#include <functional>
@@ -12,7 +15,9 @@ namespace ZL::Dialogue {
class DialogueSystem {
public:
bool init(Renderer& renderer, const std::string& zipFile = "");
bool loadDatabase(const std::string& path);
bool loadCutsceneDatabase(const std::string& path);
void update(int deltaMs);
void draw(Renderer& renderer);
@@ -25,6 +30,7 @@ public:
bool startDialogue(const std::string& dialogueId);
bool startCutscene(const std::string& cutsceneId);
void skipCutscene();
void setOnCutsceneStarted(std::function<void()> cb);
void setOnCutsceneFinished(std::function<void(const std::string&)> cb);
void setOnCutsceneFinishedExtra(std::function<void(const std::string&)> cb);
@@ -35,24 +41,38 @@ public:
void setOnDialogueAdvanced(std::function<void()> cb);
void stopDialogue();
bool isActive() const { return runtime.isActive(); }
bool blocksGameplayInput() const { return runtime.isActive(); }
bool isActive() const { return dialogueRuntime.isActive() || cutsceneRuntime.isActive(); }
bool blocksGameplayInput() const { return isActive(); }
void setFlag(const std::string& name, int value) { runtime.setFlag(name, value); }
int getFlag(const std::string& name) const { return runtime.getFlag(name); }
void setFlag(const std::string& name, int value) { dialogueRuntime.setFlag(name, value); }
int getFlag(const std::string& name) const { return dialogueRuntime.getFlag(name); }
void setGlobalFlagStore(std::unordered_map<std::string, int>* store) { runtime.setGlobalFlagStore(store); }
void setQuestJournal(Quest::QuestJournal* journal) { runtime.setQuestJournal(journal); }
void setGlobalFlagStore(std::unordered_map<std::string, int>* store) {
dialogueRuntime.setGlobalFlagStore(store);
}
void setQuestJournal(Quest::QuestJournal* journal) {
dialogueRuntime.setQuestJournal(journal);
cutsceneRuntime.setQuestJournal(journal);
}
private:
DialogueDatabase database;
DialogueRuntime runtime;
DialogueOverlay overlay;
DialogueRuntime dialogueRuntime;
DialogueOverlay dialogueOverlay;
ZL::Cutscene::CutsceneDatabase cutsceneDatabase;
ZL::Cutscene::CutsceneRuntime cutsceneRuntime;
ZL::Cutscene::CutsceneOverlay cutsceneOverlay;
std::function<void()> onDialogueAdvancedCallback;
std::function<void()> onCutsceneStartedCallback;
std::function<void(const std::string&)> onCutsceneFinishedCallback;
std::function<void(const std::string&)> onCutsceneFinishedExtraCallback;
// Pending node to resume after an inline cutscene finishes.
std::string pendingNodeAfterCutscene;
void onCutsceneFinishedInternal(const std::string& id);
};
} // namespace ZL::Dialogue