shadow-over-bishkek001/src/dialogue/DialogueSystem.h
2026-06-05 21:17:51 +03:00

53 lines
1.8 KiB
C++

#pragma once
#include "dialogue/DialogueOverlay.h"
#include "dialogue/DialogueRuntime.h"
#include "quest/QuestJournal.h"
#include <SDL.h>
#include <functional>
#include <string>
namespace ZL::Dialogue {
class DialogueSystem {
public:
bool init(Renderer& renderer, const std::string& zipFile = "");
bool loadDatabase(const std::string& path);
void update(int deltaMs);
void draw(Renderer& renderer);
bool handleKeyDown(SDL_Keycode key);
void handlePointerDown(float x, float y);
void handlePointerMoved(float x, float y);
bool handlePointerReleased(float x, float y);
bool startDialogue(const std::string& dialogueId);
bool startCutscene(const std::string& cutsceneId);
void setOnCutsceneFinished(std::function<void(const std::string&)> cb);
void setOnDialogueLineStarted(std::function<void(const std::string&)> cb);
void setOnCutsceneLineStarted(std::function<void(const std::string&)> cb);
void setOnCutsceneFadeInComplete(std::function<void(const std::string&)> cb);
void setOnChatBubbleReady(std::function<void(const std::string&, bool)> cb);
void setOnDialogueAdvanced(std::function<void()> cb);
void stopDialogue();
bool isActive() const { return runtime.isActive(); }
bool blocksGameplayInput() const { return runtime.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 setGlobalFlagStore(std::unordered_map<std::string, int>* store) { runtime.setGlobalFlagStore(store); }
void setQuestJournal(Quest::QuestJournal* journal) { runtime.setQuestJournal(journal); }
private:
DialogueDatabase database;
DialogueRuntime runtime;
DialogueOverlay overlay;
std::function<void()> onDialogueAdvancedCallback;
};
} // namespace ZL::Dialogue