Skip to content

Commit

Permalink
Merge pull request #108 from atenfyr/main
Browse files Browse the repository at this point in the history
Update dependencies for unreal_mod_manager: eframe/egui_extras to 0.29.1, egui_commonmark to 0.18.0
  • Loading branch information
atenfyr authored Dec 20, 2024
2 parents dd1f783 + b04e558 commit a2a39b8
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 33 deletions.
2 changes: 2 additions & 0 deletions dll_injector/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::missing_transmute_annotations)]

#[cfg(windows)]
use std::mem::{size_of, transmute};
#[cfg(windows)]
Expand Down
2 changes: 2 additions & 0 deletions unreal_asset/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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
//!
Expand Down
3 changes: 3 additions & 0 deletions unreal_asset/unreal_asset_base/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +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
Expand Down
4 changes: 2 additions & 2 deletions unreal_asset/unreal_asset_base/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
// }
Expand Down
3 changes: 3 additions & 0 deletions unreal_asset/unreal_asset_registry/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#![deny(missing_docs)]
#![allow(non_upper_case_globals)]
#![allow(elided_named_lifetimes)]
#![allow(clippy::needless_lifetimes)]

//! Unreal Asset Registry
//!
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions unreal_mod_integrator/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(unexpected_cfgs)]

use std::env;
use std::fs::{self, OpenOptions};
use std::path::{Path, PathBuf};
Expand Down
6 changes: 3 additions & 3 deletions unreal_mod_manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
34 changes: 19 additions & 15 deletions unreal_mod_manager/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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);
}
Expand All @@ -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)
}
}

Expand Down Expand Up @@ -438,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| {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -737,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)
Expand All @@ -754,7 +757,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);
}
});
});
Expand Down Expand Up @@ -1019,7 +1022,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,
Expand Down
30 changes: 17 additions & 13 deletions unreal_mod_manager/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -215,23 +220,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| {
Expand All @@ -243,7 +243,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(|_| {
Expand Down

0 comments on commit a2a39b8

Please sign in to comment.