Select newly created character automatically

This commit is contained in:
timokoesters 2020-03-17 16:22:34 +01:00
parent 08b44db1fc
commit d6929ae0ea
2 changed files with 11 additions and 7 deletions

View File

@ -720,12 +720,12 @@ impl CharSelectionUi {
.set(self.ids.create_button, ui_widgets) .set(self.ids.create_button, ui_widgets)
.was_clicked() .was_clicked()
{ {
// TODO: Save character. global_state.meta.selected_character =
global_state.meta.add_character(CharacterData { global_state.meta.add_character(CharacterData {
name: name.clone(), name: name.clone(),
body: comp::Body::Humanoid(body.clone()), body: comp::Body::Humanoid(body.clone()),
tool: tool.map(|tool| tool.to_string()), tool: tool.map(|tool| tool.to_string()),
}); });
to_select = true; to_select = true;
} }
// Character Name Input // Character Name Input

View File

@ -28,7 +28,11 @@ impl Meta {
} }
} }
pub fn add_character(&mut self, data: CharacterData) { self.characters.push(data); } pub fn add_character(&mut self, data: CharacterData) -> usize {
self.characters.push(data);
// return new character's index
self.characters.len() - 1
}
pub fn load() -> Self { pub fn load() -> Self {
let path = Self::get_meta_path(); let path = Self::get_meta_path();