Compare commits
7 Commits
0892415ab9
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| ea2d61e233 | |||
| dab05cf6c8 | |||
| b74831cdff | |||
| 4e58d9a50e | |||
| afde731409 | |||
| 8086bb586c | |||
| f3f0d74fec |
@@ -8,13 +8,15 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Update
|
- name: Update
|
||||||
run: |
|
run: |
|
||||||
|
cat /etc/apt/sources.list
|
||||||
|
# TODO : Add from previous file
|
||||||
sudo apt-get update -y -qq || true
|
sudo apt-get update -y -qq || true
|
||||||
sudo apt-get install -y build-essential git make zip libsdl2-dev libsdl2-2.0-0 libsdl2-net-dev libsdl2-mixer-dev libsdl2-image-dev libsdl2-gfx-dev libsdl2-ttf-dev gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu libssl-dev
|
sudo apt-get install -y build-essential git make zip libsdl2-dev libsdl2-2.0-0 libsdl2-net-dev libsdl2-mixer-dev libsdl2-image-dev libsdl2-gfx-dev libsdl2-ttf-dev gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu
|
||||||
|
#ARM64
|
||||||
#sudo apt install -y libssl-dev:arm64 libasound2-dev:arm64
|
#sudo apt install -y libssl-dev:arm64 libasound2-dev:arm64
|
||||||
sudo sh -c "echo '192.168.1.253 descartes.local' >> /etc/hosts"
|
sudo sh -c "echo '192.168.1.253 descartes.local' >> /etc/hosts"
|
||||||
sudo sh -c "echo '192.168.1.253 build.ladose.net' >> /etc/hosts"
|
sudo sh -c "echo '192.168.1.253 build.ladose.net' >> /etc/hosts"
|
||||||
sudo curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
sudo curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
||||||
sudo -E $HOME/.cargo/bin/rustup target add aarch64-unknown-linux-gnu
|
|
||||||
|
|
||||||
- name: GetDNS
|
- name: GetDNS
|
||||||
run: |
|
run: |
|
||||||
@@ -28,18 +30,20 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
. "$HOME/.cargo/env"
|
. "$HOME/.cargo/env"
|
||||||
cargo build --release
|
cargo build --release
|
||||||
cargo build --release --target=aarch64-unknown-linux-gnu
|
|
||||||
- name: Zip file
|
- name: Zip file
|
||||||
run: |
|
run: |
|
||||||
zip -rj build.zip ./target/release/
|
zip -r build.zip config.toml ./assets/*
|
||||||
zip -rj build-Aarch64.zip ./target/release/
|
zip -j build.zip ./target/release/ladose-caller
|
||||||
- name: Upload Artifact
|
- name: Upload Artifact
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
path: build-linux64.zip
|
path: build.zip
|
||||||
name: build-linux64.zip
|
name: build.zip
|
||||||
retention-days: 30
|
retention-days: 30
|
||||||
overwrite: true
|
overwrite: true
|
||||||
|
- name: Get current date
|
||||||
|
id: date
|
||||||
|
run: echo "date=$(echo $(date +'%Y-%m-%d'))" >> $GITHUB_OUTPUT
|
||||||
- name: Release
|
- name: Release
|
||||||
if: github.ref_name == 'master'
|
if: github.ref_name == 'master'
|
||||||
uses: akkuman/gitea-release-action@v1
|
uses: akkuman/gitea-release-action@v1
|
||||||
@@ -47,6 +51,5 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
tag_name: release-${{ steps.date.outputs.date }}
|
tag_name: release-${{ steps.date.outputs.date }}
|
||||||
files: |-
|
files: |-
|
||||||
build-winx64.zip
|
build.zip
|
||||||
build-linux64.zip
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,4 +16,5 @@ cynic-codegen = { version = "3" }
|
|||||||
[dependencies.sdl2]
|
[dependencies.sdl2]
|
||||||
version = "0.37"
|
version = "0.37"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["ttf","image","gfx","mixer"]
|
features = ["ttf","image","gfx"]
|
||||||
|
|
||||||
|
|||||||
14
Dockerfile
Normal file
14
Dockerfile
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
FROM rust:latest
|
||||||
|
|
||||||
|
RUN dpkg --add-architecture arm64
|
||||||
|
RUN apt update && apt upgrade -y
|
||||||
|
RUN apt install -y g++-aarch64-linux-gnu libc6-dev-arm64-cross
|
||||||
|
RUN apt-get install -y libsdl2-dev:arm64 libsdl2-2.0-0:arm64 libsdl2-net-dev:arm64 libsdl2-mixer-dev:arm64 libsdl2-image-dev:arm64 libsdl2-gfx-dev:arm64 libsdl2-ttf-dev:arm64
|
||||||
|
RUN rustup target add aarch64-unknown-linux-gnu
|
||||||
|
RUN rustup toolchain add stable-aarch64-unknown-linux-gnu --force-non-host
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++
|
||||||
|
|
||||||
|
CMD ["cargo", "build", "--target", "aarch64-unknown-linux-gnu","-r"]
|
||||||
BIN
assets/fonts/achemine_bold.ttf
Normal file
BIN
assets/fonts/achemine_bold.ttf
Normal file
Binary file not shown.
BIN
assets/fonts/achemine_italic.ttf
Normal file
BIN
assets/fonts/achemine_italic.ttf
Normal file
Binary file not shown.
BIN
assets/fonts/achemine_regular.ttf
Normal file
BIN
assets/fonts/achemine_regular.ttf
Normal file
Binary file not shown.
BIN
assets/fonts/vcr.ttf
Normal file
BIN
assets/fonts/vcr.ttf
Normal file
Binary file not shown.
BIN
assets/images/xsb_white.png
Normal file
BIN
assets/images/xsb_white.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 46 KiB |
12
buildaarch64.sh
Executable file
12
buildaarch64.sh
Executable file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
echo "build podman image"
|
||||||
|
podman build . -t cross_compile/rust_aarch64
|
||||||
|
echo "run build"
|
||||||
|
podman run --rm -v .:/app cross_compile/rust_aarch64
|
||||||
|
|
||||||
|
|
||||||
|
ssh tom@raspberrypi.local -f 'sudo systemctl stop lightdm'
|
||||||
|
ssh tom@raspberrypi.local -f 'killall ladose-caller'
|
||||||
|
scp ./target/aarch64-unknown-linux-gnu/release/ladose-caller tom@raspberrypi.local:
|
||||||
|
|
||||||
|
ssh tom@raspberrypi.local -f 'sudo systemctl start lightdm'
|
||||||
12
config.toml
Normal file
12
config.toml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
tournament = 'tournoi-kiouze-test'
|
||||||
|
update = 2
|
||||||
|
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 = 800
|
||||||
|
h = 600
|
||||||
61
src/main.rs
61
src/main.rs
@@ -19,9 +19,13 @@ use serde::Deserialize;
|
|||||||
#[derive(Deserialize,Clone)]
|
#[derive(Deserialize,Clone)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
tournament: String,
|
tournament: String,
|
||||||
|
w : u32,
|
||||||
|
h : u32,
|
||||||
update: Option<u32>,
|
update: Option<u32>,
|
||||||
fullscreen: Option<bool>,
|
fullscreen: Option<bool>,
|
||||||
smash_key: String,
|
smash_key: String,
|
||||||
|
font: String,
|
||||||
|
font_departure: String,
|
||||||
font_size: u16,
|
font_size: u16,
|
||||||
font_size_departure : u16,
|
font_size_departure : u16,
|
||||||
margin: u32,
|
margin: u32,
|
||||||
@@ -40,7 +44,7 @@ struct Line<'a> {
|
|||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
fn new() -> Self {
|
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 }
|
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"),}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,15 +65,25 @@ 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();
|
||||||
|
|
||||||
|
//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 {
|
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 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 text = texture_creator.create_texture_from_surface(&surface).unwrap();
|
||||||
let textq : TextureQuery = text.query();
|
let textq : TextureQuery = text.query();
|
||||||
let _ = canvas.copy(&text, None, Rect::new(0, y.try_into().map_err(|_| 0).unwrap(), textq.width, textq.height));
|
let _ = canvas.copy(&text, None, Rect::new(0, y.try_into().map_err(|_| 0).unwrap(), textq.width, textq.height));
|
||||||
|
y += textq.height + config.margin;
|
||||||
y += textq.height+config.margin * 2;
|
|
||||||
|
|
||||||
//compute line
|
//compute line
|
||||||
for current_match in &sq.matches {
|
for current_match in &sq.matches {
|
||||||
|
|
||||||
@@ -87,39 +101,29 @@ pub fn render(canvas : &mut Canvas<sdl2::video::Window> , queues : &Vec<smashreq
|
|||||||
players : var_name,
|
players : var_name,
|
||||||
texture : texture_creator.create_texture_from_surface(&surface).unwrap(),
|
texture : texture_creator.create_texture_from_surface(&surface).unwrap(),
|
||||||
alt_color : switch_col,
|
alt_color : switch_col,
|
||||||
y: 0
|
y: y
|
||||||
};
|
};
|
||||||
|
|
||||||
|
y += line.height + (config.margin*2);
|
||||||
lines.push(line);
|
lines.push(line);
|
||||||
|
|
||||||
}
|
}
|
||||||
let prev_y = y;
|
}
|
||||||
|
|
||||||
// background
|
// background
|
||||||
for l in &lines {
|
for l in &lines {
|
||||||
if l.alt_color {
|
if l.alt_color {
|
||||||
let _ = canvas.copy(&backline_text, None, Rect::new(0, y as i32 - config.margin as i32 , canvas.viewport().width(), l.height + config.margin ));
|
let _ = canvas.copy(&backline_text, None, Rect::new(0, l.y as i32 , canvas.viewport().width(), l.height + config.margin ));
|
||||||
}
|
}
|
||||||
y += l.height + (config.margin*2);
|
|
||||||
}
|
}
|
||||||
// depart !
|
|
||||||
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.width as i32/2) - d_textq.height as i32;
|
|
||||||
let d_y = canvas.viewport().height() as i32 - ( d_textq.width as i32 /2) - d_textq.height as i32;
|
|
||||||
let dst = Rect::new(d_x, d_y,d_textq.width,d_textq.height);
|
|
||||||
let _ = canvas.copy_ex(&d_text, None, dst,angle,None,false,false).unwrap();// d_textq.width, d_textq.height));
|
|
||||||
|
|
||||||
|
let _ = canvas.copy_ex(&d_text, None, dst,angle,sdl2::rect::Point::new(0,0),false,false).unwrap();// d_textq.width, d_textq.height));
|
||||||
|
|
||||||
// foreground
|
// foreground
|
||||||
y = prev_y;
|
|
||||||
for l in &lines {
|
for l in &lines {
|
||||||
let _ = canvas.copy(&l.texture, None, Rect::new(10, y as i32 - config.margin as i32/2 , 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));
|
||||||
y += l.height + (config.margin *2) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,7 +136,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
let box_config : Box<Config> = if config_file.is_ok() {
|
let box_config : Box<Config> = if config_file.is_ok() {
|
||||||
Box::new(toml::from_str(&config_file.unwrap()).unwrap())
|
Box::new(toml::from_str(&config_file.unwrap()).unwrap())
|
||||||
} else {
|
} else {
|
||||||
Box::new(Config::new())
|
panic!("Error No config file!")
|
||||||
};
|
};
|
||||||
let update_timer = match box_config.update {
|
let update_timer = match box_config.update {
|
||||||
Some(v) => v,
|
Some(v) => v,
|
||||||
@@ -159,7 +163,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
let sdl_context = sdl2::init().unwrap();
|
let sdl_context = sdl2::init().unwrap();
|
||||||
let video_subsystem = sdl_context.video().unwrap();
|
let video_subsystem = sdl_context.video().unwrap();
|
||||||
|
|
||||||
let mut build = video_subsystem.window("LaDOSE-SNCF", 1280, 720);
|
let mut build = video_subsystem.window("LaDOSE-SNCF", box_config.w, box_config.h);
|
||||||
if fullscreen {
|
if fullscreen {
|
||||||
build.fullscreen();
|
build.fullscreen();
|
||||||
}
|
}
|
||||||
@@ -172,13 +176,10 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
|
|
||||||
let mut canvas: Canvas<sdl2::video::Window> = window.into_canvas().build().unwrap();
|
let mut canvas: Canvas<sdl2::video::Window> = window.into_canvas().build().unwrap();
|
||||||
let ttf_context = sdl2::ttf::init().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 : 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("font/achemine_bold.ttf", box_config.font_size_departure).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 timer = sdl_context.timer()?;
|
||||||
|
|
||||||
let test_clone = Arc::clone(&test);
|
let test_clone = Arc::clone(&test);
|
||||||
|
|
||||||
let callback = Box::new(|| {
|
let callback = Box::new(|| {
|
||||||
println!("Smash!");
|
println!("Smash!");
|
||||||
let data = smashrequest::get_matches(box_config.tournament.as_str(), box_config.smash_key.as_str());
|
let data = smashrequest::get_matches(box_config.tournament.as_str(), box_config.smash_key.as_str());
|
||||||
@@ -217,6 +218,6 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
canvas.present();
|
canvas.present();
|
||||||
::std::thread::sleep(Duration::new(0, 1_000_000_000u32 / 60));
|
::std::thread::sleep(Duration::new(0, 1_000_000_000u32 / 30));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user