@@ -17,6 +17,7 @@ use log::info;
1717use parking_lot:: Mutex ;
1818use semver:: Version ;
1919
20+ use crate :: egui:: ViewportCommand ;
2021use crate :: background_work:: BackgroundThreadMessage ;
2122use crate :: error:: { ModLoaderError , ModLoaderWarning } ;
2223use 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
@@ -438,7 +439,7 @@ impl ModLoaderApp {
438439
439440 // this is just an associated function to avoid upsetting the borrow checker
440441 fn show_version_select ( ui : & mut egui:: Ui , game_mod : & mut GameMod ) {
441- egui:: ComboBox :: from_id_source ( & game_mod. name )
442+ egui:: ComboBox :: from_id_salt ( & game_mod. name )
442443 . selected_text ( format ! ( "{}" , game_mod. selected_version) )
443444 . width ( 112.0 )
444445 . show_ui ( ui, |ui| {
@@ -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 ,
@@ -737,6 +739,7 @@ impl ModLoaderApp {
737739 } ) ;
738740 }
739741
742+ #[ allow( unused_variables) ]
740743 fn show_error ( & self , ctx : & egui:: Context , frame : & mut Frame , error : & ModLoaderError ) {
741744 egui:: Window :: new ( "Critical Error" )
742745 . resizable ( false )
@@ -754,7 +757,7 @@ impl ModLoaderApp {
754757 ui. with_layout ( egui:: Layout :: right_to_left ( egui:: Align :: Min ) , |ui| {
755758 ui. style_mut ( ) . spacing . button_padding = egui:: vec2 ( 6.0 , 6.0 ) ;
756759 if ui. button ( "Quit" ) . clicked ( ) {
757- frame . close ( ) ;
760+ ctx . send_viewport_cmd ( ViewportCommand :: Close ) ;
758761 }
759762 } ) ;
760763 } ) ;
@@ -1019,7 +1022,8 @@ impl ModLoaderApp {
10191022 } ) ;
10201023
10211024 egui:: CentralPanel :: default ( ) . show_inside ( ui, |ui| {
1022- CommonMarkViewer :: new ( "viewer" ) . show_scrollable (
1025+ CommonMarkViewer :: new ( ) . show_scrollable (
1026+ "viewer" ,
10231027 ui,
10241028 & mut self . markdown_cache ,
10251029 & self . about_text ,
0 commit comments