mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'xvar/fix-charselect-bug' into 'master'
Fixed handling of deleted characters on character select screen Closes #1560 See merge request veloren/veloren!3408
This commit is contained in:
commit
d56e0de392
@ -400,15 +400,29 @@ impl Controls {
|
|||||||
ref mut yes_button,
|
ref mut yes_button,
|
||||||
ref mut no_button,
|
ref mut no_button,
|
||||||
} => {
|
} => {
|
||||||
// If no character is selected then select the first one
|
match self.selected {
|
||||||
// Note: we don't need to persist this because it is the default
|
Some(character_id) => {
|
||||||
if self.selected.is_none() {
|
// If the selected character no longer exists, deselect it.
|
||||||
self.selected = client
|
if !client
|
||||||
.character_list()
|
.character_list()
|
||||||
.characters
|
.characters
|
||||||
.get(0)
|
.iter()
|
||||||
.and_then(|i| i.character.id);
|
.any(|char| char.character.id.map_or(false, |id| id == character_id))
|
||||||
|
{
|
||||||
|
self.selected = None;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
None => {
|
||||||
|
// If no character is selected then select the first one
|
||||||
|
// Note: we don't need to persist this because it is the default
|
||||||
|
self.selected = client
|
||||||
|
.character_list()
|
||||||
|
.characters
|
||||||
|
.get(0)
|
||||||
|
.and_then(|i| i.character.id);
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the index of the selected character
|
// Get the index of the selected character
|
||||||
let selected = self.selected.and_then(|id| {
|
let selected = self.selected.and_then(|id| {
|
||||||
client
|
client
|
||||||
@ -1725,7 +1739,10 @@ impl CharSelectionUi {
|
|||||||
|
|
||||||
if self.enter_pressed {
|
if self.enter_pressed {
|
||||||
self.enter_pressed = false;
|
self.enter_pressed = false;
|
||||||
messages.push(Message::EnterWorld);
|
messages.push(match self.controls.mode {
|
||||||
|
Mode::Select { .. } => Message::EnterWorld,
|
||||||
|
Mode::CreateOrEdit { .. } => Message::CreateCharacter,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(id) = self.select_character.take() {
|
if let Some(id) = self.select_character.take() {
|
||||||
|
Loading…
Reference in New Issue
Block a user