@@ -42,12 +42,13 @@ pub mod auto_steam {
42
42
43
43
pub ( super ) trait MyPrivateRegTraits {
44
44
fn get_running_appid ( & self ) -> u32 ;
45
+ fn get_current_userid ( & self ) -> u32 ;
45
46
fn get_steam_pid ( & self ) -> usize ;
46
47
fn get_app_running_value ( & self , app_reg : & RegKey ) -> u32 ;
47
48
fn get_app_updating_value ( & self , app_reg : & RegKey ) -> u32 ;
48
49
fn get_app_installed_value ( & self , app_reg : & RegKey ) -> u32 ;
49
50
fn get_app_name_value ( & self , app_reg : & RegKey ) -> u32 ;
50
- fn create_new_command ( & self ) -> Command ;
51
+ fn create_new_steam_command ( & self ) -> Command ;
51
52
fn handle_a_game_is_already_running ( & self ) ;
52
53
}
53
54
}
@@ -58,6 +59,11 @@ pub mod auto_steam {
58
59
return running;
59
60
}
60
61
62
+ fn get_current_userid ( & self ) -> u32 {
63
+ let userid: u32 = self . active_process_reg_key . get_value ( "ActiveUser" ) . unwrap ( ) ;
64
+ return userid;
65
+ }
66
+
61
67
fn get_steam_pid ( & self ) -> usize {
62
68
let pid: u32 = self . active_process_reg_key . get_value ( "pid" ) . unwrap ( ) ;
63
69
return pid as usize ;
@@ -83,7 +89,7 @@ pub mod auto_steam {
83
89
return name;
84
90
}
85
91
86
- fn create_new_command ( & self ) -> Command {
92
+ fn create_new_steam_command ( & self ) -> Command {
87
93
let mut command = Command :: new ( & self . steam_path ) ;
88
94
command. stdin ( Stdio :: null ( ) )
89
95
. stdout ( Stdio :: null ( ) )
@@ -107,6 +113,7 @@ pub mod auto_steam {
107
113
}
108
114
109
115
pub trait MyRegTraits {
116
+ fn wait_for_login ( & self ) -> bool ;
110
117
fn wait_for_game_start ( & self , app_id : & str ) -> bool ;
111
118
fn wait_for_game_exit ( & self , app_id : & str ) -> ( ) ;
112
119
fn list_installed_and_choose ( & self ) -> String ;
@@ -118,6 +125,17 @@ pub mod auto_steam {
118
125
}
119
126
120
127
impl MyRegTraits for MyRegVars {
128
+ fn wait_for_login ( & self ) -> bool {
129
+ if self . get_current_userid ( ) != 0 { return true ; }
130
+
131
+ let now = Instant :: now ( ) ;
132
+ loop {
133
+ watch_reg ( & self . active_process_reg_key , 3000 ) ;
134
+ if self . get_current_userid ( ) != 0 { return true ; }
135
+ if now. elapsed ( ) . as_secs ( ) > 60 { return false ; }
136
+ }
137
+ }
138
+
121
139
fn wait_for_game_start ( & self , appid : & str ) -> bool {
122
140
let app_reg_key = self . apps_reg_key
123
141
. open_subkey ( appid)
@@ -193,7 +211,7 @@ pub mod auto_steam {
193
211
}
194
212
195
213
fn shut_down_steam ( & self ) -> Child {
196
- return self . create_new_command ( )
214
+ return self . create_new_steam_command ( )
197
215
. arg ( "-shutdown" )
198
216
. spawn ( )
199
217
. expect ( "Something went wrong when shutting down steam.exe" ) ;
@@ -222,21 +240,14 @@ pub mod auto_steam {
222
240
}
223
241
224
242
fn start_steam_login ( & self , user : & str , pass : & str , appid : & str ) -> Child {
225
- return self . create_new_command ( )
226
- . args ( [
227
- "-silent" ,
228
- "-login" ,
229
- user,
230
- pass,
231
- "-applaunch" ,
232
- appid
233
- ] )
243
+ return self . create_new_steam_command ( )
244
+ . args ( [ "-silent" , "-login" , user, pass, "-applaunch" , appid] )
234
245
. spawn ( )
235
246
. expect ( "Something went wrong when starting steam.exe" ) ;
236
247
}
237
248
238
249
fn start_steam ( & self ) -> Child {
239
- return self . create_new_command ( )
250
+ return self . create_new_steam_command ( )
240
251
. spawn ( )
241
252
. expect ( "Something went wrong when starting steam.exe" ) ;
242
253
}
0 commit comments