mirror of
https://github.com/szymon-jozef/checkers.git
synced 2026-10-27 19:20:44 +01:00
fix: highlight destroyed on dimension reshape
This commit is contained in:
@@ -142,7 +142,7 @@ impl Board {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_state(&mut self) {
|
pub fn update_dimensions(&mut self) {
|
||||||
self.fields.clear();
|
self.fields.clear();
|
||||||
|
|
||||||
let field_size = self.rect.w / self.board_view.size as f32;
|
let field_size = self.rect.w / self.board_view.size as f32;
|
||||||
@@ -172,6 +172,8 @@ impl Board {
|
|||||||
color: if is_field_black { BLACK } else { WHITE },
|
color: if is_field_black { BLACK } else { WHITE },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.highlight_current_moves(); // we rehighlithg as changing dimensions will destroy this
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw(&self) {
|
pub fn draw(&self) {
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ impl GameClient {
|
|||||||
|
|
||||||
ServerMessage::BroadcastBoardState { board } => {
|
ServerMessage::BroadcastBoardState { board } => {
|
||||||
self.board.update_board_view(board);
|
self.board.update_board_view(board);
|
||||||
self.board.update_state();
|
self.board.update_dimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerMessage::BroadcastCurrentTurn { active_player } => {
|
ServerMessage::BroadcastCurrentTurn { active_player } => {
|
||||||
@@ -313,7 +313,7 @@ impl GameClient {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if self.board.update_board_rect(self.board_area) {
|
if self.board.update_board_rect(self.board_area) {
|
||||||
self.board.update_state();
|
self.board.update_dimensions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user