1 Commits

Author SHA1 Message Date
2c21fd726a Test
Some checks failed
Build App / Build (push) Has been cancelled
2025-06-14 14:00:49 +02:00
2 changed files with 32 additions and 10 deletions

View File

@@ -2,12 +2,13 @@ extern crate sdl2;
mod smashquery;
mod smashrequest;
use sdl2::render::Texture;
use sdl2::image::LoadTexture;
use sdl2::pixels::{Color, PixelFormatEnum};
use sdl2::event::Event;
use sdl2::keyboard::Keycode;
use sdl2::rect::Rect;
use sdl2::render::{Canvas, TextureQuery};
use sdl2::render::{Canvas, TextureCreator, TextureQuery};
use smashrequest::SmashQueue;
use std::sync::{Arc, Mutex};
@@ -32,6 +33,12 @@ pub struct Config {
tournament_image: Option<String>
}
#[warn(dead_code)]
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, font: String::from("./assets/fonts/achemine_regular.ttf"), font_departure: String::from("./assets/fonts/achemine_bold.ttf"),}
}
}
struct Line<'a> {
height : u32,
@@ -42,13 +49,12 @@ struct Line<'a> {
y: u32
}
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, font: String::from("./assets/fonts/achemine_regular.ttf"), font_departure: String::from("./assets/fonts/achemine_bold.ttf"),}
}
struct Asset<'a> {
height: i32,
width: i32,
data : Box<sdl2::render::Texture<'a>>
}
pub fn render(canvas : &mut Canvas<sdl2::video::Window> , queues : &Vec<smashrequest::SmashQueue>,font : &sdl2::ttf::Font<'_, '_> , font_departure : &sdl2::ttf::Font<'_, '_>, config : &Config ){
@@ -65,7 +71,7 @@ pub fn render(canvas : &mut Canvas<sdl2::video::Window> , queues : &Vec<smashreq
let mut y : u32 = 0;
let mut index = 0;
let mut lines = Vec::<Line>::new();
let mut texture_tournament : Option<sdl2::render::Texture> = None;
//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();
@@ -75,6 +81,12 @@ pub fn render(canvas : &mut Canvas<sdl2::video::Window> , queues : &Vec<smashreq
let d_y = canvas.viewport().height() as i32 -10 ;
let dst = Rect::new(d_x, d_y,d_textq.width,d_textq.height);
match &config.tournament_image {
Some(img_path) => {
texture_tournament = Some(texture_creator.load_texture(img_path).unwrap());
},
_ => {}
}
//Parse the Queue
for sq in queues {
@@ -121,7 +133,17 @@ pub fn render(canvas : &mut Canvas<sdl2::video::Window> , queues : &Vec<smashreq
// foreground
for l in &lines {
match &texture_tournament {
Some(t) => {
let _ = canvas.copy(&t, None, Rect::new(5,l.y as i32,100,l.height));
let _ = canvas.copy(&l.texture, None, Rect::new(100, l.y as i32 + (config.margin/2) as i32 , l.width, l.height));
},
_ => {
let _ = canvas.copy(&l.texture, None, Rect::new(10, l.y as i32 + (config.margin/2) as i32 , l.width, l.height));
},
}
//let _ = canvas.copy(&l.texture, None, Rect::new(10, l.y as i32 + (config.margin/2) as i32 , l.width, l.height));
}

View File

@@ -48,7 +48,7 @@ fn request_stream_queue(tournament :&str, key : &str ) -> GraphQlResponse<MyQuer
slug:Some(tournament)
} );
println!("{}", key);
let resp = reqwest::blocking::Client::new().post(URL_SMASH).header("Authorization", key).json(&query).send().unwrap();
return resp.json().unwrap();