Skip to content

Commit

Permalink
fix(ui): hide input box when phase is changed
Browse files Browse the repository at this point in the history
  • Loading branch information
ja-ko committed Jun 3, 2024
1 parent 2bf3638 commit d3afe84
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub struct Player {
pub user_type: UserType,
}

#[derive(Debug, PartialEq)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum GamePhase {
Playing,
Revealed,
Expand Down
14 changes: 8 additions & 6 deletions src/ui/voting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ pub enum InputMode {
pub struct VotingPage {
pub input_mode: InputMode,
pub input_buffer: Option<String>,
last_phase: GamePhase
}

impl VotingPage {
pub fn new() -> Self {
Self {
input_mode: InputMode::Menu,
input_buffer: None,
last_phase: GamePhase::Playing,
}
}

Expand Down Expand Up @@ -363,14 +365,14 @@ impl Page for VotingPage {

let vote_view = chunks[0];
let log = chunks[1];

if app.room.phase == GamePhase::Playing && self.input_mode == InputMode::ResetConfirm {
self.input_mode = InputMode::Menu;
} else if app.room.phase == GamePhase::Revealed && self.input_mode == InputMode::RevealConfirm {
self.input_mode = InputMode::Menu;

if app.room.phase != self.last_phase {
if self.input_mode != InputMode::Name {
self.input_mode = InputMode::Menu;
}
self.last_phase = app.room.phase;
}


self.render_own_vote(app, vote_view, frame);
self.render_log(app, log, frame);
self.render_votes(app, left_side, frame);
Expand Down

0 comments on commit d3afe84

Please sign in to comment.