Skip to content

Commit

Permalink
Version 2.0.0 (#10)
Browse files Browse the repository at this point in the history
* 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
Show file tree
Hide file tree
Showing 68 changed files with 3,190 additions and 1,522 deletions.
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tkd-scoreboard"
version = "1.2.0"
version = "2.0.0"
edition = "2021"
authors = ["irzinfante <contact@irzinfante.eu>"]
repository = "https://github.com/irzinfante/tkd-scoreboard/"
Expand All @@ -10,3 +10,6 @@ license = "GPL-3.0"

[dependencies]
fltk = { version = "^1.2", features = ["fltk-bundled"] }
chrono = { version = "0.2.16" }
directories = { version = "4.0.1" }
cacache = { version = "11.3.0" }
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# tkd-scoreboard

[![rust](https://img.shields.io/badge/rust-2021-dea584)](https://doc.rust-lang.org/edition-guide/rust-2021/index.html)
[![fltk-rs](https://img.shields.io/badge/fltk--rs-%5E1.2-6f71b5)](https://github.com/fltk-rs/fltk-rs)
[![fltk-rs](https://img.shields.io/badge/fltk-%5E1.2-6f71b5)](https://crates.io/crates/fltk)
[![fltk-rs](https://img.shields.io/badge/chrono-0.2.16-9978a3)](https://crates.io/crates/chrono)
[![fltk-rs](https://img.shields.io/badge/directories-4.0.1-b57d96)](https://crates.io/crates/directories)
[![fltk-rs](https://img.shields.io/badge/cacache-11.3.0-de8383)](https://crates.io/crates/cacache)

This project aims to provide a simple taekwondo scoreboard program for the best of 3 rounds kyorugi contest system, with the World Taekwondo competition rules in force as of the 1st of September of 2022.

Expand All @@ -24,23 +27,27 @@ Categories=Game;Utility;

Put the Unix-like binary from releases downloads in `~/.local/bin` (remember to modify its permissions to allow execution) and the [icon file](assets/tkd-scoreboard.svg) in `~/.icons` to make them available for the desktop entry file.

## Lifecycle flowchart

![lifecycle.png](lifecycle.png)

## Screenshots

| ![new-execution.png](screenshots/new-execution.png) |
| ![new-execution.png](screenshots/display_Settings.png) |
|:--:|
| *On new program execution round time and rest time can be configured for the contest. Selected values remain the same in consecutive contests.* |
| *Before each contest, contest settings can be configured. Data from already finalized contest can be exported and deleted..* |

| <table><tbody><tr><td style="width:400px">![scoreboard-1.png](screenshots/scoreboard-1.png)</td><td style="width:400px">![scoreboard-2.png](screenshots/scoreboard-2.png)</td></tr><tr><td style="width:400px">![scoreboard-3.png](screenshots/scoreboard-3.png)</td><td style="width:400px">![scoreboard-4.png](screenshots/scoreboard-4.png)</td></tr><tr><td style="width:400px">![scoreboard-5.png](screenshots/scoreboard-5.png)</td><td style="width:400px">![scoreboard-6.png](screenshots/scoreboard-6.png)</td></tr></tbody></table> |
| <table><tbody><tr><td style="width:400px">![display_CallContestants.png](screenshots/display_CallContestants.png)</td><td style="width:400px">![display_Round.png](screenshots/display_Round.png)</td></tr><tr><td style="width:400px">![display_Timeout.png](screenshots/display_Timeout.png)</td><td style="width:400px">![display_MedicalTimeout.png](screenshots/display_MedicalTimeout.png)</td></tr><tr><td style="width:400px">![display_KeumanCondition.png](screenshots/display_KeumanCondition.png)</td><td style="width:400px">![display_EndContest.png](screenshots/display_EndContest.png)</td></tr><tr><td style="width:400px">![display_RestFirstPart.png](screenshots/display_RestFirstPart.png)</td><td style="width:400px">![display_RestSecondPart.png](screenshots/display_RestSecondPart.png)</td></tr><tr><td style="width:400px">![display_SuperiorityDecision.png](screenshots/display_SuperiorityDecision.png)</td><td style="width:400px">![display_ContestWinner.png](screenshots/display_ContestWinner.png)</td></tr></tbody></table> |
|:--:|
| *Different stages of the contest from start to the end of the match.* |

| <table><tbody><tr><td style="width:400px">![screen-1.png](screenshots/screen-1.png)</td><td style="width:400px">![screen-2.png](screenshots/screen-2.png)</td></tr><tr><td style="width:400px">![screen-3.png](screenshots/screen-3.png)</td><td style="width:400px">![screen-4.png](screenshots/screen-4.png)</td></tr><tr><td style="width:400px">![screen-5.png](screenshots/screen-5.png)</td><td style="width:400px">![screen-6.png](screenshots/screen-6.png)</td></tr></tbody></table> |
| <table><tbody><tr><td style="width:400px">![screen_CallContestants.png](screenshots/screen_CallContestants.png)</td><td style="width:400px">![screen_Round.png](screenshots/screen_Round.png)</td></tr><tr><td style="width:400px">![screen_Timeout.png](screenshots/screen_Timeout.png)</td><td style="width:400px">![screen_MedicalTimeout.png](screenshots/screen_MedicalTimeout.png)</td></tr><tr><td style="width:400px">![screen_KeumanCondition.png](screenshots/screen_KeumanCondition.png)</td><td style="width:400px">![screen_EndContest.png](screenshots/screen_EndContest.png)</td></tr><tr><td style="width:400px">![screen_RestFirstPart.png](screenshots/screen_RestFirstPart.png)</td><td style="width:400px">![screen_RestSecondPart.png](screenshots/screen_RestSecondPart.png)</td></tr><tr><td style="width:400px">![screen_SuperiorityDecision.png](screenshots/screen_SuperiorityDecision.png)</td><td style="width:400px">![screen_ContestWinner.png](screenshots/display_ContestWinner.png)</td></tr></tbody></table> |
|:--:|
| *Same as previous but from the screen view.* |

## License

Copyright (C) 2022 Iker Ruiz de Infante Gonzalez contact@irzinfante.eu
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.

Expand Down
Binary file added lifecycle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/display_CallContestants.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/display_ContestWinner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/display_EndContest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/display_KeumanCondition.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/display_MedicalTimeout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/display_RestFirstPart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/display_RestSecondPart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/display_Round.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/display_Settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/display_SuperiorityDecision.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/display_Timeout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed screenshots/new-execution.png
Binary file not shown.
Binary file removed screenshots/scoreboard-1.png
Binary file not shown.
Binary file removed screenshots/scoreboard-2.png
Binary file not shown.
Binary file removed screenshots/scoreboard-3.png
Binary file not shown.
Binary file removed screenshots/scoreboard-4.png
Binary file not shown.
Binary file removed screenshots/scoreboard-5.png
Binary file not shown.
Binary file removed screenshots/scoreboard-6.png
Binary file not shown.
Binary file removed screenshots/screen-1.png
Binary file not shown.
Binary file removed screenshots/screen-2.png
Binary file not shown.
Binary file removed screenshots/screen-3.png
Binary file not shown.
Binary file removed screenshots/screen-4.png
Binary file not shown.
Binary file removed screenshots/screen-5.png
Binary file not shown.
Binary file removed screenshots/screen-6.png
Binary file not shown.
Binary file added screenshots/screen_CallContestants.png
Binary file added screenshots/screen_ContestWinner.png
Binary file added screenshots/screen_EndContest.png
Binary file added screenshots/screen_KeumanCondition.png
Binary file added screenshots/screen_MedicalTimeout.png
Binary file added screenshots/screen_RestFirstPart.png
Binary file added screenshots/screen_RestSecondPart.png
Binary file added screenshots/screen_Round.png
Binary file added screenshots/screen_Settings.png
Binary file added screenshots/screen_SuperiorityDecision.png
Binary file added screenshots/screen_Timeout.png
37 changes: 37 additions & 0 deletions src/common/labels.rs
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;
}
64 changes: 64 additions & 0 deletions src/common/mod.rs
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();
}
}
83 changes: 83 additions & 0 deletions src/constants/mod.rs

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions src/contest_winner/buttons.rs
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;
}
39 changes: 39 additions & 0 deletions src/contest_winner/labels.rs
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;
}
59 changes: 59 additions & 0 deletions src/contest_winner/mod.rs
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();
}
}
Loading

0 comments on commit 8e81002

Please sign in to comment.