Skip to content

Commit

Permalink
fix: if select hat and go back to fish select, remember hat.
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxCWhitehead committed Nov 2, 2024
1 parent f82f175 commit aa5b451
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/ui/main_menu/player_select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ pub enum PlayerSlot {
SelectingPlayer {
control_source: PlayerSlotControlSource,
current_player: Handle<PlayerMeta>,
current_hat: Option<Handle<HatMeta>>,
},
SelectingHat {
control_source: PlayerSlotControlSource,
Expand Down Expand Up @@ -152,7 +153,8 @@ impl PlayerSlot {

pub fn selected_hat(&self) -> Option<Handle<HatMeta>> {
match self {
Self::Empty | Self::SelectingLocalControlSource | Self::SelectingPlayer { .. } => None,
Self::Empty | Self::SelectingLocalControlSource => None,
Self::SelectingPlayer { current_hat, .. } => *current_hat,
Self::SelectingHat { current_hat, .. } => *current_hat,
Self::Ready { selected_hat, .. } => *selected_hat,
}
Expand Down Expand Up @@ -365,6 +367,7 @@ pub fn widget(
control_source: PlayerSlotControlSource::Remote,
// Use default player until we get a message from them on change in selection
current_player: state.players[0],
current_hat: None,
};
}
}
Expand Down Expand Up @@ -669,13 +672,15 @@ fn player_select_panel(
next_state = new_player_join.map(|control_source| PlayerSlot::SelectingPlayer {
control_source: PlayerSlotControlSource::User(control_source),
current_player: state.players[0],
current_hat: None,
});
}
}

PlayerSlot::SelectingPlayer {
control_source: control_source @ PlayerSlotControlSource::User(src),
current_player,
current_hat,
} => {
let Some(player_control) = controls.get(&src) else {
return;
Expand All @@ -684,7 +689,7 @@ fn player_select_panel(
next_state = Some(PlayerSlot::SelectingHat {
control_source,
selected_player: current_player,
current_hat: None,
current_hat,
});
} else if player_control.menu_back_just_pressed && !is_network {
next_state = Some(PlayerSlot::Empty);
Expand All @@ -709,6 +714,7 @@ fn player_select_panel(
next_state = Some(PlayerSlot::SelectingPlayer {
control_source,
current_player: next_player,
current_hat,
});
}
}
Expand All @@ -733,6 +739,7 @@ fn player_select_panel(
next_state = Some(PlayerSlot::SelectingPlayer {
control_source,
current_player: selected_player,
current_hat,
});
} else if player_control.just_moved {
let current_hat_handle_idx = state
Expand Down

0 comments on commit aa5b451

Please sign in to comment.