Skip to content

Commit

Permalink
fixes for dep update breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
atenfyr committed Dec 20, 2024
1 parent 8fc2015 commit 4ad6a44
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 27 deletions.
31 changes: 17 additions & 14 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 @@ -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 @@ -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);
}
});
});
Expand Down Expand Up @@ -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,
Expand Down
25 changes: 12 additions & 13 deletions unreal_mod_manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand All @@ -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(|_| {
Expand Down

0 comments on commit 4ad6a44

Please sign in to comment.