Clean up UI, work on tutorial
This commit is contained in:
1 parent
cfbd29d5b1
commit
619de45221
79 files changed
+5122
-316
No files matched your search
@@ -113,16 +113,21 @@ bool QuestJournal::unlockQuest(const std::string& questId) {
|
||||
if (!quest) return false;
|
||||
if (quest->status == QuestStatus::Hidden) {
|
||||
quest->status = QuestStatus::Available;
|
||||
if (onQuestUnlocked) onQuestUnlocked(questId);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QuestJournal::completeQuest(const std::string& questId) {
|
||||
return setStatus(questId, QuestStatus::Completed);
|
||||
bool changed = setStatus(questId, QuestStatus::Completed);
|
||||
if (changed && onQuestCompleted) onQuestCompleted(questId);
|
||||
return changed;
|
||||
}
|
||||
|
||||
bool QuestJournal::failQuest(const std::string& questId) {
|
||||
return setStatus(questId, QuestStatus::Failed);
|
||||
bool changed = setStatus(questId, QuestStatus::Failed);
|
||||
if (changed && onQuestFailed) onQuestFailed(questId);
|
||||
return changed;
|
||||
}
|
||||
|
||||
bool QuestJournal::setObjectiveCompleted(const std::string& questId, const std::string& objectiveId, bool completed) {
|
||||
@@ -133,13 +138,19 @@ bool QuestJournal::setObjectiveCompleted(const std::string& questId, const std::
|
||||
if (objective.id == objectiveId) {
|
||||
objective.completed = completed;
|
||||
|
||||
if (completed) {
|
||||
if (onObjectiveCompleted) onObjectiveCompleted(questId, objectiveId);
|
||||
}
|
||||
|
||||
if (completed && quest->definition.autoComplete && quest->status == QuestStatus::Available) {
|
||||
const bool allDone = std::all_of(
|
||||
quest->definition.objectives.begin(),
|
||||
quest->definition.objectives.end(),
|
||||
[](const QuestObjective& o) { return o.completed; });
|
||||
if (allDone)
|
||||
if (allDone) {
|
||||
quest->status = QuestStatus::Completed;
|
||||
if (onQuestCompleted) onQuestCompleted(questId);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
|
||||
namespace ZL::Quest {
|
||||
|
||||
@@ -11,6 +12,12 @@ class QuestJournal {
|
||||
public:
|
||||
bool loadFromFile(const std::string& path, const std::string& zipFile = "");
|
||||
|
||||
// Event callbacks — set by the owner (MenuManager) to receive notifications.
|
||||
std::function<void(const std::string& questId)> onQuestUnlocked;
|
||||
std::function<void(const std::string& questId)> onQuestCompleted;
|
||||
std::function<void(const std::string& questId)> onQuestFailed;
|
||||
std::function<void(const std::string& questId, const std::string& objectiveId)> onObjectiveCompleted;
|
||||
|
||||
bool unlockQuest(const std::string& questId);
|
||||
bool completeQuest(const std::string& questId);
|
||||
bool failQuest(const std::string& questId);
|
||||
|
||||
Reference in new issue
Block a user