Working on dialog editor, on dialogs, on phone
This commit is contained in:
1 parent
0e27521bea
commit
8f7797789d
63 files changed
+9502
-1459
No files matched your search
@@ -307,12 +307,17 @@ void DialogueRuntime::skipCurrentCutscene() {
|
||||
}
|
||||
|
||||
void DialogueRuntime::setFlag(const std::string& name, int value) {
|
||||
flags[name] = value;
|
||||
if (flagStore) (*flagStore)[name] = value;
|
||||
}
|
||||
|
||||
int DialogueRuntime::getFlag(const std::string& name) const {
|
||||
auto it = flags.find(name);
|
||||
return (it != flags.end()) ? it->second : 0;
|
||||
if (!flagStore) return 0;
|
||||
auto it = flagStore->find(name);
|
||||
return (it != flagStore->end()) ? it->second : 0;
|
||||
}
|
||||
|
||||
void DialogueRuntime::setGlobalFlagStore(std::unordered_map<std::string, int>* store) {
|
||||
flagStore = store;
|
||||
}
|
||||
|
||||
void DialogueRuntime::setQuestJournal(Quest::QuestJournal* journal) {
|
||||
@@ -368,10 +373,10 @@ void DialogueRuntime::applyEffects(const std::vector<Effect>& effects) {
|
||||
continue;
|
||||
}
|
||||
if (effect.relative) {
|
||||
flags[effect.flag] += effect.value;
|
||||
setFlag(effect.flag, getFlag(effect.flag) + effect.value);
|
||||
}
|
||||
else {
|
||||
flags[effect.flag] = effect.value;
|
||||
setFlag(effect.flag, effect.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -424,6 +429,8 @@ bool DialogueRuntime::enterNode(const std::string& nodeId) {
|
||||
return true;
|
||||
|
||||
case NodeType::End:
|
||||
if (!node.luaCallback.empty() && onDialogueLineStarted)
|
||||
onDialogueLineStarted(node.luaCallback);
|
||||
stop();
|
||||
return true;
|
||||
|
||||
@@ -907,7 +914,7 @@ int DialogueRuntime::computeCameraTrackDurationMs(const StaticCutsceneDefinition
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
/*
|
||||
DialogueRuntime::json DialogueRuntime::buildSaveState() const {
|
||||
json result;
|
||||
result["active"] = isActive();
|
||||
@@ -917,7 +924,6 @@ DialogueRuntime::json DialogueRuntime::buildSaveState() const {
|
||||
result["selectedChoice"] = selectedChoice;
|
||||
result["currentCutsceneLine"] = currentCutsceneLine;
|
||||
result["cutsceneTimerMs"] = cutsceneTimerMs;
|
||||
result["flags"] = flags;
|
||||
result["consumedChoices"] = consumedChoices;
|
||||
return result;
|
||||
}
|
||||
@@ -930,10 +936,7 @@ bool DialogueRuntime::restoreSaveState(const json& state) {
|
||||
flags.clear();
|
||||
consumedChoices.clear();
|
||||
|
||||
if (state.contains("flags")) {
|
||||
flags = state["flags"].get<std::unordered_map<std::string, int>>();
|
||||
}
|
||||
if (state.contains("consumedChoices")) {
|
||||
if (state.contains("consumedChoices")) {
|
||||
consumedChoices = state["consumedChoices"].get<std::unordered_set<std::string>>();
|
||||
}
|
||||
|
||||
@@ -963,5 +966,5 @@ bool DialogueRuntime::restoreSaveState(const json& state) {
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
*/
|
||||
} // namespace ZL::Dialogue
|
||||
@@ -43,10 +43,12 @@ public:
|
||||
void setFlag(const std::string& name, int value);
|
||||
int getFlag(const std::string& name) const;
|
||||
|
||||
void setGlobalFlagStore(std::unordered_map<std::string, int>* store);
|
||||
|
||||
void setQuestJournal(Quest::QuestJournal* journal);
|
||||
|
||||
json buildSaveState() const;
|
||||
bool restoreSaveState(const json& state);
|
||||
//json buildSaveState() const;
|
||||
//bool restoreSaveState(const json& state);
|
||||
|
||||
private:
|
||||
enum class Mode {
|
||||
@@ -69,7 +71,7 @@ private:
|
||||
const DialogueDefinition* activeDialogue = nullptr;
|
||||
const StaticCutsceneDefinition* activeCutscene = nullptr;
|
||||
|
||||
std::unordered_map<std::string, int> flags;
|
||||
std::unordered_map<std::string, int>* flagStore = nullptr;
|
||||
std::unordered_set<std::string> consumedChoices;
|
||||
|
||||
std::string currentNodeId;
|
||||
|
||||
@@ -38,6 +38,8 @@ public:
|
||||
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:
|
||||
|
||||
Reference in new issue
Block a user