Skip to content

Commit

Permalink
feat(CutsceneLibrary): add setter for the nested message in blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
lmichaelis committed Nov 2, 2024
1 parent aa46ddb commit c2eecf8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/zenkit/CutsceneLibrary.hh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ namespace zenkit {
std::variant<std::shared_ptr<CutsceneAtomicBlock>, std::shared_ptr<CutsceneBlock>> block;

[[nodiscard]] std::shared_ptr<ConversationMessageEvent> get_message() const;
void set_message(std::shared_ptr<ConversationMessageEvent> msg);

ZKAPI void load(ReadArchive& r, GameVersion version) override;
ZKAPI void save(WriteArchive& w, GameVersion version) const override;
Expand Down
12 changes: 12 additions & 0 deletions src/CutsceneLibrary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ namespace zenkit {
return std::get<std::shared_ptr<CutsceneAtomicBlock>>(cur->block)->message;
}

void CutsceneBlock::set_message(std::shared_ptr<ConversationMessageEvent> msg) {
auto const* cur = this;
while (std::holds_alternative<std::shared_ptr<CutsceneBlock>>(cur->block)) {
cur = std::get<std::shared_ptr<CutsceneBlock>>(cur->block).get();
if (cur == nullptr) {
return;
}
}

std::get<std::shared_ptr<CutsceneAtomicBlock>>(cur->block)->message = std::move(msg);
}

void CutsceneBlock::load(ReadArchive& r, GameVersion version) {
this->name = r.read_string(); // blockName

Expand Down

0 comments on commit c2eecf8

Please sign in to comment.