From d66e0ba1e6afc4595d730cf929659fd2a38ccc3f Mon Sep 17 00:00:00 2001 From: atenfyr Date: Fri, 20 Dec 2024 05:30:33 -0600 Subject: [PATCH 1/3] update deps --- unreal_mod_manager/Cargo.toml | 6 +++--- unreal_mod_manager/src/app.rs | 31 +++++++++++++++++-------------- unreal_mod_manager/src/lib.rs | 25 ++++++++++++------------- 3 files changed, 32 insertions(+), 30 deletions(-) diff --git a/unreal_mod_manager/Cargo.toml b/unreal_mod_manager/Cargo.toml index 0bd5a8bf..c0e36ea4 100644 --- a/unreal_mod_manager/Cargo.toml +++ b/unreal_mod_manager/Cargo.toml @@ -32,8 +32,8 @@ unreal_mod_metadata.workspace = true unreal_pak.workspace = true directories = "4.0.1" -eframe = "0.21.3" -egui_extras = "0.21.0" +eframe = "0.29.1" +egui_extras = "0.29.1" lazy_static.workspace = true log.workspace = true open = "3.2.0" @@ -48,7 +48,7 @@ steamlocate = "1.1.1" sha2 = "0.10.6" tempfile = { version = "3.4.0", optional = true } hex = "0.4.3" -egui_commonmark = { version = "0.7.0", git = "https://github.com/localcc/egui_commonmark", branch = "rescale_fix" } +egui_commonmark = "0.18.0" [target.'cfg(windows)'.dependencies] winreg = "0.11.0" diff --git a/unreal_mod_manager/src/app.rs b/unreal_mod_manager/src/app.rs index 47e969b5..f0d7079b 100644 --- a/unreal_mod_manager/src/app.rs +++ b/unreal_mod_manager/src/app.rs @@ -17,6 +17,7 @@ use log::info; use parking_lot::Mutex; use semver::Version; +use crate::egui::ViewportCommand; use crate::background_work::BackgroundThreadMessage; use crate::error::{ModLoaderError, ModLoaderWarning}; use crate::game_mod::{GameMod, SelectedVersion}; @@ -234,6 +235,16 @@ impl App for ModLoaderApp { } } + if ctx.input(|i| i.viewport().close_requested()) { + let _ = self.background_tx.send(BackgroundThreadMessage::Exit); + + if self.ready_exit.load(Ordering::Acquire) { + info!("Exiting..."); + } + + self.ready_exit.load(Ordering::Acquire); + } + if darken_background { self.darken_background(ctx); } @@ -253,18 +264,8 @@ impl App for ModLoaderApp { // when background thread is ready to exit kill app by ending main thread if self.ready_exit.load(Ordering::Acquire) { - frame.close(); - } - } - - fn on_close_event(&mut self) -> bool { - let _ = self.background_tx.send(BackgroundThreadMessage::Exit); - - if self.ready_exit.load(Ordering::Acquire) { - info!("Exiting..."); + ctx.send_viewport_cmd(ViewportCommand::Close); } - - self.ready_exit.load(Ordering::Acquire) } } @@ -685,7 +686,8 @@ impl ModLoaderApp { strip.cell(|ui| { ui.heading("Changelog"); - CommonMarkViewer::new("update_viewer").show_scrollable( + CommonMarkViewer::new().show_scrollable( + "update_viewer", ui, &mut self.markdown_cache, &newer_update.changelog, @@ -754,7 +756,7 @@ impl ModLoaderApp { ui.with_layout(egui::Layout::right_to_left(egui::Align::Min), |ui| { ui.style_mut().spacing.button_padding = egui::vec2(6.0, 6.0); if ui.button("Quit").clicked() { - frame.close(); + ctx.send_viewport_cmd(ViewportCommand::Close); } }); }); @@ -1019,7 +1021,8 @@ impl ModLoaderApp { }); egui::CentralPanel::default().show_inside(ui, |ui| { - CommonMarkViewer::new("viewer").show_scrollable( + CommonMarkViewer::new().show_scrollable( + "viewer", ui, &mut self.markdown_cache, &self.about_text, diff --git a/unreal_mod_manager/src/lib.rs b/unreal_mod_manager/src/lib.rs index ef90c574..f9e5e55f 100644 --- a/unreal_mod_manager/src/lib.rs +++ b/unreal_mod_manager/src/lib.rs @@ -215,23 +215,18 @@ where error!("Failed to start background thread"); panic!(); }); + // run the GUI app - let icon_data = match icon_data { - Some(data) => Some(eframe::IconData { - rgba: data.data.to_vec(), - width: data.width, - height: data.height, - }), - None => None, - }; + let icon_data_unwrapped = icon_data.unwrap(); - // run the GUI app eframe::run_native( app.window_title.clone().as_str(), eframe::NativeOptions { - follow_system_theme: true, - initial_window_size: Some(eframe::egui::vec2(660.0, 600.0)), - icon_data, + viewport: egui::ViewportBuilder::default().with_icon(egui::IconData { + rgba: icon_data_unwrapped.data.to_vec(), + width: icon_data_unwrapped.width, + height: icon_data_unwrapped.height, + }).with_inner_size([660.0, 600.0]), ..eframe::NativeOptions::default() }, Box::new(|cc| { @@ -243,7 +238,11 @@ where cc.egui_ctx.set_style(egui::Style::default()); - Box::new(app) + cc.egui_ctx.options_mut(|options| { + options.theme_preference = crate::egui::ThemePreference::System; + }); + + Ok(Box::new(app)) }), ) .unwrap_or_else(|_| { From 2c50ed65e0b861adc9c25025ac18deff0c4bec90 Mon Sep 17 00:00:00 2001 From: atenfyr Date: Fri, 20 Dec 2024 05:46:29 -0600 Subject: [PATCH 2/3] clippy fixes... --- unreal_asset/unreal_asset_base/src/lib.rs | 1 + unreal_asset/unreal_asset_base/src/unversioned/mod.rs | 1 + unreal_mod_integrator/build.rs | 2 ++ unreal_mod_manager/src/app.rs | 3 ++- 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/unreal_asset/unreal_asset_base/src/lib.rs b/unreal_asset/unreal_asset_base/src/lib.rs index 03eb6b3e..d7edf158 100644 --- a/unreal_asset/unreal_asset_base/src/lib.rs +++ b/unreal_asset/unreal_asset_base/src/lib.rs @@ -1,5 +1,6 @@ #![deny(missing_docs)] #![allow(non_upper_case_globals)] +#![allow(unexpected_cfgs)] //! unreal_asset crate base members diff --git a/unreal_asset/unreal_asset_base/src/unversioned/mod.rs b/unreal_asset/unreal_asset_base/src/unversioned/mod.rs index af9e4f6e..b1864361 100644 --- a/unreal_asset/unreal_asset_base/src/unversioned/mod.rs +++ b/unreal_asset/unreal_asset_base/src/unversioned/mod.rs @@ -174,6 +174,7 @@ impl Usmap { } /// Gets all usmap mappings for a given schema + #[allow(elided_named_lifetimes)] pub fn get_all_properties<'name>( &'name self, mut schema_name: &'name str, diff --git a/unreal_mod_integrator/build.rs b/unreal_mod_integrator/build.rs index 06c54651..6ef53e67 100644 --- a/unreal_mod_integrator/build.rs +++ b/unreal_mod_integrator/build.rs @@ -1,3 +1,5 @@ +#![allow(unexpected_cfgs)] + use std::env; use std::fs::{self, OpenOptions}; use std::path::{Path, PathBuf}; diff --git a/unreal_mod_manager/src/app.rs b/unreal_mod_manager/src/app.rs index f0d7079b..b646e541 100644 --- a/unreal_mod_manager/src/app.rs +++ b/unreal_mod_manager/src/app.rs @@ -439,7 +439,7 @@ impl ModLoaderApp { // this is just an associated function to avoid upsetting the borrow checker fn show_version_select(ui: &mut egui::Ui, game_mod: &mut GameMod) { - egui::ComboBox::from_id_source(&game_mod.name) + egui::ComboBox::from_id_salt(&game_mod.name) .selected_text(format!("{}", game_mod.selected_version)) .width(112.0) .show_ui(ui, |ui| { @@ -739,6 +739,7 @@ impl ModLoaderApp { }); } + #[allow(unused_variables)] fn show_error(&self, ctx: &egui::Context, frame: &mut Frame, error: &ModLoaderError) { egui::Window::new("Critical Error") .resizable(false) From b04e5586235e211a8de776756978b6197955d27d Mon Sep 17 00:00:00 2001 From: atenfyr Date: Fri, 20 Dec 2024 06:08:52 -0600 Subject: [PATCH 3/3] clippy fixes x2 --- dll_injector/src/lib.rs | 2 ++ unreal_asset/src/lib.rs | 2 ++ unreal_asset/unreal_asset_base/src/lib.rs | 2 ++ unreal_asset/unreal_asset_base/src/types/mod.rs | 4 ++-- unreal_asset/unreal_asset_base/src/unversioned/mod.rs | 1 - unreal_asset/unreal_asset_registry/src/lib.rs | 3 +++ unreal_mod_manager/src/lib.rs | 5 +++++ 7 files changed, 16 insertions(+), 3 deletions(-) diff --git a/dll_injector/src/lib.rs b/dll_injector/src/lib.rs index 31d35361..40a4cc8a 100644 --- a/dll_injector/src/lib.rs +++ b/dll_injector/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::missing_transmute_annotations)] + #[cfg(windows)] use std::mem::{size_of, transmute}; #[cfg(windows)] diff --git a/unreal_asset/src/lib.rs b/unreal_asset/src/lib.rs index 72945b5e..591d639f 100644 --- a/unreal_asset/src/lib.rs +++ b/unreal_asset/src/lib.rs @@ -1,5 +1,7 @@ #![deny(missing_docs)] #![allow(non_upper_case_globals)] +#![allow(elided_named_lifetimes)] +#![allow(clippy::needless_lifetimes)] //! This crate is used for parsing Unreal Engine uasset files //! diff --git a/unreal_asset/unreal_asset_base/src/lib.rs b/unreal_asset/unreal_asset_base/src/lib.rs index d7edf158..baba369f 100644 --- a/unreal_asset/unreal_asset_base/src/lib.rs +++ b/unreal_asset/unreal_asset_base/src/lib.rs @@ -1,6 +1,8 @@ #![deny(missing_docs)] #![allow(non_upper_case_globals)] #![allow(unexpected_cfgs)] +#![allow(elided_named_lifetimes)] +#![allow(clippy::needless_lifetimes)] //! unreal_asset crate base members diff --git a/unreal_asset/unreal_asset_base/src/types/mod.rs b/unreal_asset/unreal_asset_base/src/types/mod.rs index f202f243..78041f94 100644 --- a/unreal_asset/unreal_asset_base/src/types/mod.rs +++ b/unreal_asset/unreal_asset_base/src/types/mod.rs @@ -122,13 +122,13 @@ impl std::fmt::Display for PackageIndex { } } -/// Create a Guid from 4 u32 values +// /// Create a Guid from 4 u32 values // #[rustfmt::skip] // pub const fn new_guid(a: u32, b: u32, c: u32, d: u32) -> Guid { // Guid // } -/// Create a default Guid filled with all zeros +// /// Create a default Guid filled with all zeros // pub fn default_guid() -> Guid { // new_guid(0, 0, 0, 0) // } diff --git a/unreal_asset/unreal_asset_base/src/unversioned/mod.rs b/unreal_asset/unreal_asset_base/src/unversioned/mod.rs index b1864361..af9e4f6e 100644 --- a/unreal_asset/unreal_asset_base/src/unversioned/mod.rs +++ b/unreal_asset/unreal_asset_base/src/unversioned/mod.rs @@ -174,7 +174,6 @@ impl Usmap { } /// Gets all usmap mappings for a given schema - #[allow(elided_named_lifetimes)] pub fn get_all_properties<'name>( &'name self, mut schema_name: &'name str, diff --git a/unreal_asset/unreal_asset_registry/src/lib.rs b/unreal_asset/unreal_asset_registry/src/lib.rs index 49045d82..44065fa7 100644 --- a/unreal_asset/unreal_asset_registry/src/lib.rs +++ b/unreal_asset/unreal_asset_registry/src/lib.rs @@ -1,5 +1,7 @@ #![deny(missing_docs)] #![allow(non_upper_case_globals)] +#![allow(elided_named_lifetimes)] +#![allow(clippy::needless_lifetimes)] //! Unreal Asset Registry //! @@ -310,6 +312,7 @@ impl AssetRegistryState { for name in name_map.get_ref().get_name_map_index_list() { writer.write_fstring(Some(name))?; + #[allow(clippy::single_match)] match writer.get_object_version() >= ObjectVersion::VER_UE4_NAME_HASHES_SERIALIZED { true => { let hash = crc::generate_hash(name); diff --git a/unreal_mod_manager/src/lib.rs b/unreal_mod_manager/src/lib.rs index f9e5e55f..186e6477 100644 --- a/unreal_mod_manager/src/lib.rs +++ b/unreal_mod_manager/src/lib.rs @@ -1,3 +1,8 @@ +#![allow(unexpected_cfgs)] +#![allow(elided_named_lifetimes)] +#![allow(clippy::needless_lifetimes)] +#![allow(clippy::zombie_processes)] + use std::collections::BTreeMap; use std::fmt::Write; use std::path::PathBuf;