Compare commits
1 Commits
release-20
...
aurele
| Author | SHA1 | Date | |
|---|---|---|---|
| 2c21fd726a |
40
src/main.rs
40
src/main.rs
@@ -2,12 +2,13 @@ extern crate sdl2;
|
|||||||
mod smashquery;
|
mod smashquery;
|
||||||
mod smashrequest;
|
mod smashrequest;
|
||||||
|
|
||||||
|
use sdl2::render::Texture;
|
||||||
|
use sdl2::image::LoadTexture;
|
||||||
use sdl2::pixels::{Color, PixelFormatEnum};
|
use sdl2::pixels::{Color, PixelFormatEnum};
|
||||||
use sdl2::event::Event;
|
use sdl2::event::Event;
|
||||||
use sdl2::keyboard::Keycode;
|
use sdl2::keyboard::Keycode;
|
||||||
use sdl2::rect::Rect;
|
use sdl2::rect::Rect;
|
||||||
use sdl2::render::{Canvas, TextureQuery};
|
use sdl2::render::{Canvas, TextureCreator, TextureQuery};
|
||||||
use smashrequest::SmashQueue;
|
use smashrequest::SmashQueue;
|
||||||
|
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
@@ -32,6 +33,12 @@ pub struct Config {
|
|||||||
tournament_image: Option<String>
|
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> {
|
struct Line<'a> {
|
||||||
height : u32,
|
height : u32,
|
||||||
@@ -42,13 +49,12 @@ struct Line<'a> {
|
|||||||
y: u32
|
y: u32
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
struct Asset<'a> {
|
||||||
fn new() -> Self {
|
height: i32,
|
||||||
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"),}
|
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 ){
|
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 y : u32 = 0;
|
||||||
let mut index = 0;
|
let mut index = 0;
|
||||||
let mut lines = Vec::<Line>::new();
|
let mut lines = Vec::<Line>::new();
|
||||||
|
let mut texture_tournament : Option<sdl2::render::Texture> = None;
|
||||||
//Departure !
|
//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_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_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 d_y = canvas.viewport().height() as i32 -10 ;
|
||||||
let dst = Rect::new(d_x, d_y,d_textq.width,d_textq.height);
|
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
|
//Parse the Queue
|
||||||
for sq in queues {
|
for sq in queues {
|
||||||
@@ -121,7 +133,17 @@ pub fn render(canvas : &mut Canvas<sdl2::video::Window> , queues : &Vec<smashreq
|
|||||||
|
|
||||||
// foreground
|
// foreground
|
||||||
for l in &lines {
|
for l in &lines {
|
||||||
let _ = canvas.copy(&l.texture, None, Rect::new(10, l.y as i32 + (config.margin/2) as i32 , l.width, l.height));
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ fn request_stream_queue(tournament :&str, key : &str ) -> GraphQlResponse<MyQuer
|
|||||||
slug:Some(tournament)
|
slug:Some(tournament)
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
println!("{}", key);
|
||||||
let resp = reqwest::blocking::Client::new().post(URL_SMASH).header("Authorization", key).json(&query).send().unwrap();
|
let resp = reqwest::blocking::Client::new().post(URL_SMASH).header("Authorization", key).json(&query).send().unwrap();
|
||||||
return resp.json().unwrap();
|
return resp.json().unwrap();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user