space-game001/src/dialogue/DialogueDatabase.h

39 lines
1.1 KiB
C++

#pragma once
#include "dialogue/DialogueTypes.h"
#include "external/nlohmann/json.hpp"
#include <string>
#include <unordered_map>
namespace ZL::Dialogue {
class DialogueDatabase {
public:
using json = nlohmann::json;
bool loadFromFile(const std::string& path);
const DialogueDefinition* findDialogue(const std::string& id) const;
const StaticCutsceneDefinition* findCutscene(const std::string& id) const;
private:
std::unordered_map<std::string, DialogueDefinition> dialogues;
std::unordered_map<std::string, StaticCutsceneDefinition> cutscenes;
static NodeType parseNodeType(const std::string& value);
static ChoiceKind parseChoiceKind(const std::string& value);
static ComparisonOp parseComparisonOp(const std::string& value);
static Condition parseCondition(const json& j);
static Effect parseEffect(const json& j);
static Choice parseChoice(const json& j);
static Node parseNode(const json& j);
static DialogueDefinition parseDialogue(const json& j);
static CutsceneLine parseCutsceneLine(const json& j);
static StaticCutsceneDefinition parseCutscene(const json& j);
};
} // namespace ZL::Dialogue