diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index 05ad272..c31055a 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -32,7 +32,8 @@ jobs: cargo build --release - name: Zip file run: | - zip -rj build.zip ./target/release/ladose-caller ./font/ + zip -r build.zip config.toml ./assets/* + zip -j build.zip ./target/release/ladose-caller - name: Upload Artifact uses: actions/upload-artifact@v3 with: diff --git a/Cargo.lock b/Cargo.lock index d218d01..9ca620f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -107,15 +107,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" -[[package]] -name = "cmake" -version = "0.1.54" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7caa3f9de89ddbe2c607f4101924c5abec803763ae9534e4f4d7d8f84aa81f0" -dependencies = [ - "cc", -] - [[package]] name = "cynic" version = "3.10.0" @@ -1074,7 +1065,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "951deab27af08ed9c6068b7b0d05a93c91f0a8eb16b6b816a5e73452a43521d3" dependencies = [ "cfg-if", - "cmake", "libc", "version-compare", ] diff --git a/assets/fonts/achemine_bold.ttf b/assets/fonts/achemine_bold.ttf new file mode 100644 index 0000000..0aa810e Binary files /dev/null and b/assets/fonts/achemine_bold.ttf differ diff --git a/assets/fonts/achemine_italic.ttf b/assets/fonts/achemine_italic.ttf new file mode 100644 index 0000000..a6fde88 Binary files /dev/null and b/assets/fonts/achemine_italic.ttf differ diff --git a/assets/fonts/achemine_regular.ttf b/assets/fonts/achemine_regular.ttf new file mode 100644 index 0000000..84be0af Binary files /dev/null and b/assets/fonts/achemine_regular.ttf differ diff --git a/assets/fonts/vcr.ttf b/assets/fonts/vcr.ttf new file mode 100644 index 0000000..dcca687 Binary files /dev/null and b/assets/fonts/vcr.ttf differ diff --git a/assets/images/xsb_white.png b/assets/images/xsb_white.png new file mode 100644 index 0000000..cff5e26 Binary files /dev/null and b/assets/images/xsb_white.png differ diff --git a/config.toml b/config.toml index 3933416..78ef555 100644 --- a/config.toml +++ b/config.toml @@ -1,9 +1,12 @@ tournament = 'tournoi-kiouze-test' update = 2 -fullscreen = true +fullscreen = false +tournament_image = './assets/images/xsb_white.png' +font = './assets/fonts/achemine_regular.ttf' +font_departure = './assets/fonts/achemine_bold.ttf' font_size = 40 font_size_departure = 60 smash_key = 'Bearer API_KEY' margin = 10 -w = 1920 -h = 1080 +w = 800 +h = 600 diff --git a/src/main.rs b/src/main.rs index 2ba7b33..2d43e18 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,6 +24,8 @@ pub struct Config { update: Option, fullscreen: Option, smash_key: String, + font: String, + font_departure: String, font_size: u16, font_size_departure : u16, margin: u32, @@ -42,7 +44,7 @@ struct Line<'a> { impl Config { fn new() -> Self { - Self { tournament: String::new(), update: Some(1),fullscreen:Some(false), smash_key: String::new(), font_size: 30 , font_size_departure : 45, margin: 10,tournament_image: None , w : 1920, h: 1080} + Self { tournament: String::new(), update: Some(1),fullscreen:Some(false), smash_key: String::new(), font_size: 30 , font_size_departure : 45, margin: 10,tournament_image: None , w : 1920, h: 1080, font: String::from("./assets/fonts/achemine_regular.ttf"), font_departure: String::from("./assets/fonts/achemine_bold.ttf"),} } } @@ -63,15 +65,25 @@ pub fn render(canvas : &mut Canvas , queues : &Vec::new(); + + //Departure ! + let d_surface = font_departure.render("Départ / Departure").blended(Color::RGBA(130, 218, 255, 255)).map_err(|e| e.to_string()).unwrap(); + let d_text = texture_creator.create_texture_from_surface(&d_surface).unwrap(); + let d_textq : TextureQuery = d_text.query(); + let angle : f64 = f64::from(-90.0); + let d_x = canvas.viewport().width() as i32 - d_textq.height as i32 - 10 ; + let d_y = canvas.viewport().height() as i32 -10 ; + let dst = Rect::new(d_x, d_y,d_textq.width,d_textq.height); + + + //Parse the Queue for sq in queues { let surface: sdl2::surface::Surface<'_> = font.render(sq.name.as_str()).blended(Color::RGBA(255, 255, 0, 255)).map_err(|e| e.to_string()).unwrap(); let text = texture_creator.create_texture_from_surface(&surface).unwrap(); let textq : TextureQuery = text.query(); let _ = canvas.copy(&text, None, Rect::new(0, y.try_into().map_err(|_| 0).unwrap(), textq.width, textq.height)); - - y += textq.height+config.margin * 2; - + y += textq.height + config.margin; //compute line for current_match in &sq.matches { @@ -89,40 +101,30 @@ pub fn render(canvas : &mut Canvas , queues : &Vec Result<(), Box> { let box_config : Box = if config_file.is_ok() { Box::new(toml::from_str(&config_file.unwrap()).unwrap()) } else { - Box::new(Config::new()) + panic!("Error No config file!") }; let update_timer = match box_config.update { Some(v) => v, @@ -174,13 +176,10 @@ pub fn main() -> Result<(), Box> { let mut canvas: Canvas = window.into_canvas().build().unwrap(); let ttf_context = sdl2::ttf::init().unwrap(); - let font : sdl2::ttf::Font<'_, '_> = ttf_context.load_font("font/achemine_bold.ttf", box_config.font_size).unwrap(); - let font_departure : sdl2::ttf::Font<'_, '_> = ttf_context.load_font("font/achemine_bold.ttf", box_config.font_size_departure).unwrap(); - + let font : sdl2::ttf::Font<'_, '_> = ttf_context.load_font(&box_config.font, box_config.font_size).unwrap(); + let font_departure : sdl2::ttf::Font<'_, '_> = ttf_context.load_font(&box_config.font_departure, box_config.font_size_departure).unwrap(); let timer = sdl_context.timer()?; - let test_clone = Arc::clone(&test); - let callback = Box::new(|| { println!("Smash!"); let data = smashrequest::get_matches(box_config.tournament.as_str(), box_config.smash_key.as_str());