diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4ca69ae..466b378 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,10 +22,10 @@ jobs: image: ghcr.io/jggr/f-value-builder:latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Cache cargo - uses: actions/cache@v4 + uses: actions/cache@v5 with: path: | target @@ -39,7 +39,7 @@ jobs: run: cargo build - name: Upload artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: f_value-debug-linux path: target/debug/f_value diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f73aad..e9188a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +## [0.1.6-rc.1] - Unreleased + +### Changed + +- Drop `app::controller::{write_temp_style_file, load_style_from_memory}` + - Use `raylib::prelude::RaylibGuiState::gui_load_style_from_memory` +- Bump `raylib` to `6.0.0-rc.2` +- Bump `pdf-writer` to `0.15.0` +- Drop `uuid` dep + ## [0.1.5] - 2026-05-15 ### Added diff --git a/Cargo.lock b/Cargo.lock index bdaa9bd..af9e71b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -26,12 +26,6 @@ dependencies = [ "libc", ] -[[package]] -name = "anyhow" -version = "1.0.102" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" - [[package]] name = "atk-sys" version = "0.18.2" @@ -52,9 +46,9 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "bindgen" -version = "0.71.1" +version = "0.72.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f58bf3d7db68cfbac37cfc485a8d711e87e064c3d0fe0435b92f7a407f9d6b3" +checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895" dependencies = [ "bitflags", "cexpr", @@ -271,7 +265,7 @@ dependencies = [ [[package]] name = "f_value" -version = "0.1.5" +version = "0.1.6-rc.1" dependencies = [ "chrono", "dirs", @@ -282,7 +276,6 @@ dependencies = [ "png", "raylib", "rfd", - "uuid", ] [[package]] @@ -304,12 +297,6 @@ dependencies = [ "miniz_oxide 0.8.9", ] -[[package]] -name = "foldhash" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" - [[package]] name = "foldhash" version = "0.2.0" @@ -357,19 +344,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "getrandom" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" -dependencies = [ - "cfg-if", - "libc", - "r-efi", - "wasip2", - "wasip3", -] - [[package]] name = "gio-sys" version = "0.18.1" @@ -383,15 +357,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "glam" -version = "0.30.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b46b9ca4690308844c644e7c634d68792467260e051c8543e0c7871662b3ba7" -dependencies = [ - "mint", -] - [[package]] name = "glib-sys" version = "0.18.1" @@ -437,15 +402,6 @@ dependencies = [ "system-deps", ] -[[package]] -name = "hashbrown" -version = "0.15.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" -dependencies = [ - "foldhash 0.1.5", -] - [[package]] name = "hashbrown" version = "0.16.1" @@ -458,7 +414,7 @@ version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" dependencies = [ - "foldhash 0.2.0", + "foldhash", "serde", "serde_core", ] @@ -492,12 +448,6 @@ dependencies = [ "cc", ] -[[package]] -name = "id-arena" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" - [[package]] name = "indexmap" version = "2.13.1" @@ -506,8 +456,6 @@ checksum = "45a8a2b9cb3e0b0c1803dbb0758ffac5de2f425b23c28f518faabd9d805342ff" dependencies = [ "equivalent", "hashbrown 0.16.1", - "serde", - "serde_core", ] [[package]] @@ -550,12 +498,6 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -[[package]] -name = "leb128fmt" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" - [[package]] name = "libc" version = "0.2.164" @@ -641,12 +583,6 @@ dependencies = [ "adler2", ] -[[package]] -name = "mint" -version = "0.5.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e53debba6bda7a793e5f99b8dacf19e626084f525f7829104ba9898f367d85ff" - [[package]] name = "nom" version = "7.1.3" @@ -776,9 +712,9 @@ checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "pdf-writer" -version = "0.14.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92a79477295a713c2ed425aa82a8b5d20cec3fdee203706cbe6f3854880c1c81" +checksum = "f5e456864a7a304047bff84977dc6fb162bd956475d40ba50b2dcecaada7f753" dependencies = [ "bitflags", "itoa", @@ -845,12 +781,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "r-efi" -version = "6.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" - [[package]] name = "raw-window-handle" version = "0.6.2" @@ -859,10 +789,9 @@ checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" [[package]] name = "raylib" -version = "5.7.0" -source = "git+https://github.com/raylib-rs/raylib-rs.git#c7227f666187ab8c35be7162ced718205489aec2" +version = "6.0.0-rc.2" +source = "git+https://github.com/jgabaut/raylib-rs.git?branch=work%2Fopaque-mingw-ldbl-type#94f92e2debb4f8641054151c511ef0b4fd4ca54e" dependencies = [ - "glam", "paste", "raylib-sys", "seq-macro", @@ -871,13 +800,12 @@ dependencies = [ [[package]] name = "raylib-sys" -version = "5.7.0" -source = "git+https://github.com/raylib-rs/raylib-rs.git#c7227f666187ab8c35be7162ced718205489aec2" +version = "6.0.0-rc.2" +source = "git+https://github.com/jgabaut/raylib-rs.git?branch=work%2Fopaque-mingw-ldbl-type#94f92e2debb4f8641054151c511ef0b4fd4ca54e" dependencies = [ "bindgen", "cc", "cmake", - "mint", ] [[package]] @@ -886,7 +814,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd6f9d3d47bdd2ad6945c5015a226ec6155d0bcdfd8f7cd29f86b71f8de99d2b" dependencies = [ - "getrandom 0.2.15", + "getrandom", "libredox", "thiserror", ] @@ -965,12 +893,6 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" -[[package]] -name = "semver" -version = "1.0.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" - [[package]] name = "seq-macro" version = "0.3.6" @@ -1007,19 +929,6 @@ dependencies = [ "syn", ] -[[package]] -name = "serde_json" -version = "1.0.149" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" -dependencies = [ - "itoa", - "memchr", - "serde", - "serde_core", - "zmij", -] - [[package]] name = "serde_spanned" version = "0.6.9" @@ -1137,23 +1046,6 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" -[[package]] -name = "unicode-xid" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" - -[[package]] -name = "uuid" -version = "1.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddd74a9687298c6858e9b88ec8935ec45d22e8fd5e6394fa1bd4e99a87789c76" -dependencies = [ - "getrandom 0.4.2", - "js-sys", - "wasm-bindgen", -] - [[package]] name = "version-compare" version = "0.2.1" @@ -1166,24 +1058,6 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" -[[package]] -name = "wasip2" -version = "1.0.2+wasi-0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" -dependencies = [ - "wit-bindgen", -] - -[[package]] -name = "wasip3" -version = "0.4.0+wasi-0.3.0-rc-2026-01-06" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" -dependencies = [ - "wit-bindgen", -] - [[package]] name = "wasm-bindgen" version = "0.2.105" @@ -1242,40 +1116,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "wasm-encoder" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" -dependencies = [ - "leb128fmt", - "wasmparser", -] - -[[package]] -name = "wasm-metadata" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" -dependencies = [ - "anyhow", - "indexmap", - "wasm-encoder", - "wasmparser", -] - -[[package]] -name = "wasmparser" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" -dependencies = [ - "bitflags", - "hashbrown 0.15.5", - "indexmap", - "semver", -] - [[package]] name = "web-sys" version = "0.3.82" @@ -1404,97 +1244,3 @@ checksum = "df79d97927682d2fd8adb29682d1140b343be4ac0f08fd68b7765d9c059d3945" dependencies = [ "memchr", ] - -[[package]] -name = "wit-bindgen" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" -dependencies = [ - "wit-bindgen-rust-macro", -] - -[[package]] -name = "wit-bindgen-core" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" -dependencies = [ - "anyhow", - "heck", - "wit-parser", -] - -[[package]] -name = "wit-bindgen-rust" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" -dependencies = [ - "anyhow", - "heck", - "indexmap", - "prettyplease", - "syn", - "wasm-metadata", - "wit-bindgen-core", - "wit-component", -] - -[[package]] -name = "wit-bindgen-rust-macro" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" -dependencies = [ - "anyhow", - "prettyplease", - "proc-macro2", - "quote", - "syn", - "wit-bindgen-core", - "wit-bindgen-rust", -] - -[[package]] -name = "wit-component" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" -dependencies = [ - "anyhow", - "bitflags", - "indexmap", - "log", - "serde", - "serde_derive", - "serde_json", - "wasm-encoder", - "wasm-metadata", - "wasmparser", - "wit-parser", -] - -[[package]] -name = "wit-parser" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" -dependencies = [ - "anyhow", - "id-arena", - "indexmap", - "log", - "semver", - "serde", - "serde_derive", - "serde_json", - "unicode-xid", - "wasmparser", -] - -[[package]] -name = "zmij" -version = "1.0.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/Cargo.toml b/Cargo.toml index 167c230..2bb59d0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "f_value" -version = "0.1.5" +version = "0.1.6-rc.1" edition = "2021" description = "Tool for NISECI and HFBI calc" license = "GPL-3.0-only" @@ -26,10 +26,9 @@ dirs = "6.0.0" esox = "0.1.6" locale_config = "0.3.0" miniz_oxide = "0.9.1" -pdf-writer = "0.14.0" +pdf-writer = "0.15.0" png = "0.18.1" -raylib = { git = "https://github.com/raylib-rs/raylib-rs.git", features = [ +raylib = { git = "https://github.com/jgabaut/raylib-rs.git", branch = "work/opaque-mingw-ldbl-type", features = [ "raygui", ] } rfd = { version = "0.17.2", default-features = false } -uuid = { version = "1.23.1", features = ["v4"] } diff --git a/src/app/controller.rs b/src/app/controller.rs index 1910dc1..fdc9cae 100644 --- a/src/app/controller.rs +++ b/src/app/controller.rs @@ -25,17 +25,15 @@ use raylib::consts::GuiControl::DEFAULT; use raylib::consts::GuiControlProperty::TEXT_COLOR_NORMAL; use raylib::consts::GuiDefaultProperty::{BACKGROUND_COLOR, TEXT_SIZE, TEXT_SPACING}; use raylib::consts::KeyboardKey::*; +use raylib::error::LoadStyleFromMemoryError; +use raylib::prelude::RaylibGuiState; use raylib::RaylibHandle; -use std::fs::File; -use std::io::Write; -use std::path::PathBuf; -use uuid::Uuid; pub(crate) fn update_main( rl: &mut RaylibHandle, actions: &mut Vec, main_state: &mut MainState, -) { +) -> Result<(), LoadStyleFromMemoryError> { main_state.should_quit = rl.window_should_close(); main_state.frame_counter += 1; @@ -69,7 +67,7 @@ pub(crate) fn update_main( main_state.current_font_height = main_state.default_font_height; rl.gui_set_style(DEFAULT, TEXT_SIZE, main_state.current_font_height); main_state.gui_theme_combobox_active = GuiTheme::Light as i32; - GuiTheme::load_and_set(&GuiTheme::Light, rl, main_state); + GuiTheme::load_and_set(&GuiTheme::Light, rl, main_state)?; let locale = get_locale(); main_state.locale_combobox_active = locale as i32; main_state.locale = locale; @@ -107,7 +105,7 @@ pub(crate) fn update_main( match >::try_from(theme_idx) { Ok(t) => { main_state.gui_theme_combobox_active = theme_idx; - t.load_and_set(rl, main_state); + t.load_and_set(rl, main_state)?; } Err(_) => eprintln!("unknown number in current theme check"), } @@ -133,76 +131,50 @@ pub(crate) fn update_main( if rl.is_key_pressed(KEY_F7) { main_state.showing_info_box = true; } -} - -fn write_temp_style_file(data: &[u8]) -> Result<(String, PathBuf), Box> { - // We employ a UUID to randomise the filename, as required - // to avoid insecure temporary files vulnerabilities - // See: https://doc.rust-lang.org/nightly/std/env/fn.temp_dir.html - let mut temp_path = std::env::temp_dir(); - let id = Uuid::new_v4(); - temp_path.push(format!("{}.rgs", id)); - - let mut file = File::create(&temp_path)?; - file.write_all(data)?; - - let string = String::from(temp_path.to_string_lossy()); - Ok((string, temp_path)) -} - -fn load_style_from_memory(rl: &mut RaylibHandle, data: &[u8]) { - // Al momento, raylib-rs non espone una funzione gui_load_style_from_memory(). - // Qui simuliamo la disponibilità runtime di un file .rgs, partendo dai byte - // di include_bytes!(). Non la migliore idea, ma sembra funzionare. - - // Write the data to a temporary file - let (temp_file_cstring, temp_file_path) = - write_temp_style_file(data).expect("Failed to write temp style file"); - - // Load the style - rl.gui_load_style(temp_file_cstring.as_str()); - - // Remove the temp file after loading the style - std::fs::remove_file(temp_file_path).expect("Failed to delete temp style file"); + Ok(()) } impl GuiTheme { - fn load_and_set(&self, rl: &mut RaylibHandle, main_state: &mut MainState) { + fn load_and_set( + &self, + rl: &mut RaylibHandle, + main_state: &mut MainState, + ) -> Result<(), LoadStyleFromMemoryError> { match self { GuiTheme::Dark => { - load_style_from_memory(rl, DARK_THEME_DATA); + rl.gui_load_style_from_memory(DARK_THEME_DATA)?; main_state.theme = GuiTheme::Dark; } GuiTheme::Bluish => { - load_style_from_memory(rl, BLUISH_THEME_DATA); + rl.gui_load_style_from_memory(BLUISH_THEME_DATA)?; main_state.theme = GuiTheme::Bluish; } GuiTheme::Candy => { - load_style_from_memory(rl, CANDY_THEME_DATA); + rl.gui_load_style_from_memory(CANDY_THEME_DATA)?; main_state.theme = GuiTheme::Candy; } GuiTheme::Cherry => { - load_style_from_memory(rl, CHERRY_THEME_DATA); + rl.gui_load_style_from_memory(CHERRY_THEME_DATA)?; main_state.theme = GuiTheme::Cherry; } GuiTheme::Cyber => { - load_style_from_memory(rl, CYBER_THEME_DATA); + rl.gui_load_style_from_memory(CYBER_THEME_DATA)?; main_state.theme = GuiTheme::Cyber; } GuiTheme::Jungle => { - load_style_from_memory(rl, JUNGLE_THEME_DATA); + rl.gui_load_style_from_memory(JUNGLE_THEME_DATA)?; main_state.theme = GuiTheme::Jungle; } GuiTheme::Lavanda => { - load_style_from_memory(rl, LAVANDA_THEME_DATA); + rl.gui_load_style_from_memory(LAVANDA_THEME_DATA)?; main_state.theme = GuiTheme::Lavanda; } GuiTheme::Terminal => { - load_style_from_memory(rl, TERMINAL_THEME_DATA); + rl.gui_load_style_from_memory(TERMINAL_THEME_DATA)?; main_state.theme = GuiTheme::Terminal; } GuiTheme::Ashes => { - load_style_from_memory(rl, ASHES_THEME_DATA); + rl.gui_load_style_from_memory(ASHES_THEME_DATA)?; main_state.theme = GuiTheme::Ashes; } GuiTheme::Light => { @@ -229,5 +201,6 @@ impl GuiTheme { main_state.colors.default_txt_color = Color::get_color(txt_color_int); main_state.colors.default_bg_color = Color::get_color(bg_color_int); main_state.current_font = rl.gui_get_font(); + Ok(()) } } diff --git a/src/app/core.rs b/src/app/core.rs index ac64035..ab1252b 100644 --- a/src/app/core.rs +++ b/src/app/core.rs @@ -519,7 +519,12 @@ impl App { let mut main_actions = Vec::::new(); while !self.main_state.should_quit { // Base update step - update_main(&mut self.rl, &mut main_actions, &mut self.main_state); + if let Err(load_style_error) = + update_main(&mut self.rl, &mut main_actions, &mut self.main_state) + { + eprintln!("Error while loading theme: {load_style_error}"); + // TODO: print error in GUI console too and put user there? + } self.controllers.update( &mut self.rl, diff --git a/src/views/output.rs b/src/views/output.rs index 695fbba..0bbf7dd 100644 --- a/src/views/output.rs +++ b/src/views/output.rs @@ -121,7 +121,10 @@ impl View for ProduzioneOutputView { d.gui_unlock(); } - d.gui_panel(rrect(panel_x, panel_y, panel_width, panel_height), "Output"); + d.gui_panel( + rrect(panel_x, panel_y, panel_width, panel_height), + Some("Output"), + ); let y_spacing = main_state.current_font_height + propwidth(d, 5); let output_start_y = panel_y + propwidth(d, 15);