diff --git a/src/game.rs b/src/game.rs index e1b80d1..44607e7 100644 --- a/src/game.rs +++ b/src/game.rs @@ -548,6 +548,17 @@ impl Game { new_id } + /// adds a dialogue safely and returns the new dialogue ID + #[inline] + pub fn add_dialogue(&mut self, mut dialogue: Dialogue) -> String { + let new_id = try_id(self.dialogue_ids(), dialogue.id.clone()); + if new_id != dialogue.id { + dialogue.id = new_id.clone(); + } + self.dialogues.push(dialogue); + new_id + } + #[inline] fn version_line(&self) -> String { if self.version.is_some() {