Skip to content

Commit 4ad6a44

Browse files
committed
fixes for dep update breaking changes
1 parent 8fc2015 commit 4ad6a44

File tree

2 files changed

+29
-27
lines changed

2 files changed

+29
-27
lines changed

unreal_mod_manager/src/app.rs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use log::info;
1717
use parking_lot::Mutex;
1818
use semver::Version;
1919

20+
use crate::egui::ViewportCommand;
2021
use crate::background_work::BackgroundThreadMessage;
2122
use crate::error::{ModLoaderError, ModLoaderWarning};
2223
use crate::game_mod::{GameMod, SelectedVersion};
@@ -234,6 +235,16 @@ impl App for ModLoaderApp {
234235
}
235236
}
236237

238+
if ctx.input(|i| i.viewport().close_requested()) {
239+
let _ = self.background_tx.send(BackgroundThreadMessage::Exit);
240+
241+
if self.ready_exit.load(Ordering::Acquire) {
242+
info!("Exiting...");
243+
}
244+
245+
self.ready_exit.load(Ordering::Acquire);
246+
}
247+
237248
if darken_background {
238249
self.darken_background(ctx);
239250
}
@@ -253,18 +264,8 @@ impl App for ModLoaderApp {
253264

254265
// when background thread is ready to exit kill app by ending main thread
255266
if self.ready_exit.load(Ordering::Acquire) {
256-
frame.close();
257-
}
258-
}
259-
260-
fn on_close_event(&mut self) -> bool {
261-
let _ = self.background_tx.send(BackgroundThreadMessage::Exit);
262-
263-
if self.ready_exit.load(Ordering::Acquire) {
264-
info!("Exiting...");
267+
ctx.send_viewport_cmd(ViewportCommand::Close);
265268
}
266-
267-
self.ready_exit.load(Ordering::Acquire)
268269
}
269270
}
270271

@@ -685,7 +686,8 @@ impl ModLoaderApp {
685686

686687
strip.cell(|ui| {
687688
ui.heading("Changelog");
688-
CommonMarkViewer::new("update_viewer").show_scrollable(
689+
CommonMarkViewer::new().show_scrollable(
690+
"update_viewer",
689691
ui,
690692
&mut self.markdown_cache,
691693
&newer_update.changelog,
@@ -754,7 +756,7 @@ impl ModLoaderApp {
754756
ui.with_layout(egui::Layout::right_to_left(egui::Align::Min), |ui| {
755757
ui.style_mut().spacing.button_padding = egui::vec2(6.0, 6.0);
756758
if ui.button("Quit").clicked() {
757-
frame.close();
759+
ctx.send_viewport_cmd(ViewportCommand::Close);
758760
}
759761
});
760762
});
@@ -1019,7 +1021,8 @@ impl ModLoaderApp {
10191021
});
10201022

10211023
egui::CentralPanel::default().show_inside(ui, |ui| {
1022-
CommonMarkViewer::new("viewer").show_scrollable(
1024+
CommonMarkViewer::new().show_scrollable(
1025+
"viewer",
10231026
ui,
10241027
&mut self.markdown_cache,
10251028
&self.about_text,

unreal_mod_manager/src/lib.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -215,23 +215,18 @@ where
215215
error!("Failed to start background thread");
216216
panic!();
217217
});
218+
// run the GUI app
218219

219-
let icon_data = match icon_data {
220-
Some(data) => Some(eframe::IconData {
221-
rgba: data.data.to_vec(),
222-
width: data.width,
223-
height: data.height,
224-
}),
225-
None => None,
226-
};
220+
let icon_data_unwrapped = icon_data.unwrap();
227221

228-
// run the GUI app
229222
eframe::run_native(
230223
app.window_title.clone().as_str(),
231224
eframe::NativeOptions {
232-
follow_system_theme: true,
233-
initial_window_size: Some(eframe::egui::vec2(660.0, 600.0)),
234-
icon_data,
225+
viewport: egui::ViewportBuilder::default().with_icon(egui::IconData {
226+
rgba: icon_data_unwrapped.data.to_vec(),
227+
width: icon_data_unwrapped.width,
228+
height: icon_data_unwrapped.height,
229+
}).with_inner_size([660.0, 600.0]),
235230
..eframe::NativeOptions::default()
236231
},
237232
Box::new(|cc| {
@@ -243,7 +238,11 @@ where
243238

244239
cc.egui_ctx.set_style(egui::Style::default());
245240

246-
Box::new(app)
241+
cc.egui_ctx.options_mut(|options| {
242+
options.theme_preference = crate::egui::ThemePreference::System;
243+
});
244+
245+
Ok(Box::new(app))
247246
}),
248247
)
249248
.unwrap_or_else(|_| {

0 commit comments

Comments
 (0)