-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Code refactored for better scoreboard lifecycle management and to improve maintainability * Added contest number setting * Added contest data storage and export
- Loading branch information
Iker Ruiz de Infante Gonzalez
authored
Mar 12, 2023
1 parent
5683e4a
commit 8e81002
Showing
68 changed files
with
3,190 additions
and
1,522 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* Scoreboard program for taekwondo competition | ||
* Copyright (C) 2022-2023 Iker Ruiz de Infante Gonzalez <contact@irzinfante.eu> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
use fltk::{prelude::*, frame, enums::Align}; | ||
use crate::constants::COPYRIGHT; | ||
|
||
pub fn copyright(_screen_width: f64, screen_height: f64) -> frame::Frame { | ||
let mut copyright = frame::Frame::default() | ||
.with_pos(0, screen_height as i32) | ||
.with_align(Align::RightBottom) | ||
.with_label(&format!("v{} - {}", env!("CARGO_PKG_VERSION"), COPYRIGHT)); | ||
copyright.set_label_size(10); | ||
return copyright; | ||
} | ||
|
||
pub fn contest_number(screen_width: f64, screen_height: f64) -> frame::Frame { | ||
let mut contest_number = frame::Frame::default() | ||
.with_pos(screen_width as i32, screen_height as i32) | ||
.with_align(Align::LeftBottom); | ||
contest_number.set_label_size(15); | ||
return contest_number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/** | ||
* Scoreboard program for taekwondo competition | ||
* Copyright (C) 2022-2023 Iker Ruiz de Infante Gonzalez <contact@irzinfante.eu> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
use std::hash::{Hash, Hasher}; | ||
use std::collections::hash_map::DefaultHasher; | ||
use fltk::prelude::*; | ||
use crate::{Scoreboard, constants::CONTEST_NUMBER_SIGN}; | ||
|
||
pub mod labels; | ||
|
||
pub fn scale_size(size: f64, width: f64, height: f64) -> i32 { | ||
(size * (width.powf(2.) + height.powf(2.)).sqrt() / 2000.) as i32 | ||
} | ||
|
||
#[derive(Hash)] | ||
struct GamJeons { | ||
cheong_gam_jeon_count: u8, | ||
hong_gam_jeon_count: u8 | ||
} | ||
|
||
fn hash<T: Hash>(obj: T) -> u64 { | ||
let mut hasher = DefaultHasher::new(); | ||
obj.hash(&mut hasher); | ||
hasher.finish() | ||
} | ||
|
||
impl Scoreboard { | ||
pub fn gam_jeons_hash(&self) -> u64{ | ||
hash(GamJeons { | ||
cheong_gam_jeon_count: self.cheong_gam_jeon_count, | ||
hong_gam_jeon_count: self.hong_gam_jeon_count | ||
}) | ||
} | ||
|
||
pub fn show_contest_number(&mut self) { | ||
let contest_number = self.settings.contest_number_input.value(); | ||
|
||
self.display.contest_number_lbl.set_label(&format!("{}{}", CONTEST_NUMBER_SIGN, contest_number)); | ||
self.display.contest_number_lbl.show(); | ||
|
||
self.screen.contest_number_lbl.set_label(&format!("{}{}", CONTEST_NUMBER_SIGN, contest_number)); | ||
self.screen.contest_number_lbl.show(); | ||
} | ||
|
||
pub fn hide_contest_number(&mut self) { | ||
self.display.contest_number_lbl.hide(); | ||
self.screen.contest_number_lbl.hide(); | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* Scoreboard program for taekwondo competition | ||
* Copyright (C) 2022-2023 Iker Ruiz de Infante Gonzalez <contact@irzinfante.eu> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
use fltk::{prelude::*, button}; | ||
use crate::constants::CLEAR_SCOREBOARD; | ||
|
||
pub fn clear_scoreboard_btn(screen_width: f64, screen_height: f64) -> button::Button { | ||
let mut clear_scoreboard_btn = button::Button::default() | ||
.with_pos((screen_width * 23./54.) as i32, (screen_height * 14./16.) as i32) | ||
.with_size((screen_width * 4./27.) as i32, (screen_height * 1./16.) as i32) | ||
.with_label(CLEAR_SCOREBOARD); | ||
clear_scoreboard_btn.deactivate(); | ||
clear_scoreboard_btn.hide(); | ||
return clear_scoreboard_btn; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Scoreboard program for taekwondo competition | ||
* Copyright (C) 2022-2023 Iker Ruiz de Infante Gonzalez <contact@irzinfante.eu> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
use fltk::{prelude::*, frame, enums::FrameType, enums::Color}; | ||
|
||
pub fn contest_winner_display_lbl(screen_width: f64, screen_height: f64) -> frame::Frame { | ||
let mut contest_winner_display_lbl = frame::Frame::default() | ||
.with_pos((screen_width * 9./48.) as i32, (screen_height * 9./16.) as i32) | ||
.with_size((screen_width * 15./24.) as i32, (screen_width * 3./24.) as i32); | ||
contest_winner_display_lbl.set_frame(FrameType::FlatBox); | ||
contest_winner_display_lbl.set_label_color(Color::White); | ||
contest_winner_display_lbl.hide(); | ||
return contest_winner_display_lbl; | ||
} | ||
|
||
pub fn contest_winner_screen_lbl(screen_width: f64, screen_height: f64) -> frame::Frame { | ||
let mut contest_winner_screen_lbl = frame::Frame::default() | ||
.with_pos((screen_width * 1./3.) as i32, (screen_height * 11./16.) as i32) | ||
.with_size((screen_width * 1./3.) as i32, (screen_height * 4./16.) as i32); | ||
contest_winner_screen_lbl.set_frame(FrameType::FlatBox); | ||
contest_winner_screen_lbl.set_label_color(Color::White); | ||
contest_winner_screen_lbl.hide(); | ||
return contest_winner_screen_lbl; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* Scoreboard program for taekwondo competition | ||
* Copyright (C) 2022-2023 Iker Ruiz de Infante Gonzalez <contact@irzinfante.eu> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
use fltk::{prelude::*, enums::Color}; | ||
use crate::{ | ||
Scoreboard, | ||
enums::Winner, | ||
constants::{CHEONG_NL_SEUNG, CHEONG_SEUNG, HONG_NL_SEUNG, HONG_SEUNG} | ||
}; | ||
|
||
pub mod labels; | ||
pub mod buttons; | ||
|
||
impl Scoreboard { | ||
pub fn show_contest_winner(&mut self, winner: Winner) { | ||
match winner { | ||
Winner::Cheong => { | ||
self.display.contest_winner_lbl.set_label(CHEONG_SEUNG); | ||
self.display.contest_winner_lbl.set_color(Color::Blue); | ||
self.screen.contest_winner_lbl.set_label(CHEONG_NL_SEUNG); | ||
self.screen.contest_winner_lbl.set_color(Color::Blue); | ||
}, | ||
Winner::Hong => { | ||
self.display.contest_winner_lbl.set_label(HONG_SEUNG); | ||
self.display.contest_winner_lbl.set_color(Color::Red); | ||
self.screen.contest_winner_lbl.set_label(HONG_NL_SEUNG); | ||
self.screen.contest_winner_lbl.set_color(Color::Red); | ||
}, | ||
Winner::None => () | ||
} | ||
self.display.contest_winner_lbl.show(); | ||
self.screen.contest_winner_lbl.show(); | ||
|
||
self.controls.clear_scoreboard_btn.show(); | ||
self.controls.clear_scoreboard_btn.activate(); | ||
} | ||
|
||
pub fn hide_contest_winner(&mut self) { | ||
self.display.contest_winner_lbl.hide(); | ||
self.screen.contest_winner_lbl.hide(); | ||
|
||
self.controls.clear_scoreboard_btn.hide(); | ||
} | ||
} |
Oops, something went wrong.