File tree Expand file tree Collapse file tree 4 files changed +30
-12
lines changed Expand file tree Collapse file tree 4 files changed +30
-12
lines changed Original file line number Diff line number Diff line change @@ -96,6 +96,11 @@ impl RunnerInfo {
96
96
}
97
97
98
98
pub trait Runner {
99
+ /// Get the Wine runner associated with this runner
100
+ ///
101
+ /// This is possible because all runners are built on top of Wine
102
+ fn wine ( & self ) -> & Wine ;
103
+
99
104
/// Get the common runner information
100
105
fn info ( & self ) -> & RunnerInfo ;
101
106
Original file line number Diff line number Diff line change 1
- use super :: { Runner , RunnerInfo } ;
1
+ use super :: { Runner , RunnerInfo , Wine } ;
2
2
use std:: path:: { Path , PathBuf } ;
3
3
4
4
// TODO: These need to be set to use proton outside steam
@@ -7,6 +7,7 @@ use std::path::{Path, PathBuf};
7
7
#[ derive( Debug ) ]
8
8
pub struct Proton {
9
9
info : RunnerInfo ,
10
+ wine : Wine ,
10
11
}
11
12
12
13
impl TryFrom < & Path > for Proton {
@@ -15,11 +16,16 @@ impl TryFrom<&Path> for Proton {
15
16
fn try_from ( path : & Path ) -> Result < Self , Self :: Error > {
16
17
let executable = PathBuf :: from ( "./proton" ) ;
17
18
let info = RunnerInfo :: try_from ( path, & executable) ?;
18
- Ok ( Proton { info } )
19
+ let mut wine = Wine :: try_from ( path. join ( "files" ) . as_path ( ) ) ?;
20
+ Ok ( Proton { wine, info } )
19
21
}
20
22
}
21
23
22
24
impl Runner for Proton {
25
+ fn wine ( & self ) -> & Wine {
26
+ & self . wine
27
+ }
28
+
23
29
fn info ( & self ) -> & RunnerInfo {
24
30
& self . info
25
31
}
Original file line number Diff line number Diff line change 1
- use super :: { Runner , RunnerInfo } ;
1
+ use super :: { Proton , Runner , RunnerInfo , Wine } ;
2
2
use std:: path:: { Path , PathBuf } ;
3
3
4
4
#[ derive( Debug ) ]
5
5
pub struct UMU {
6
6
info : RunnerInfo ,
7
- proton_path : Option < PathBuf > ,
7
+ proton : Option < Proton > ,
8
8
}
9
9
10
- impl TryFrom < & Path > for UMU {
11
- type Error = Box < dyn std:: error:: Error > ;
12
-
13
- fn try_from ( path : & Path ) -> Result < Self , Self :: Error > {
10
+ impl UMU {
11
+ pub fn try_from (
12
+ path : & Path ,
13
+ proton : Option < Proton > ,
14
+ ) -> Result < Self , Box < dyn std:: error:: Error > > {
14
15
let executable = PathBuf :: from ( "./umu-run" ) ;
15
16
let mut info = RunnerInfo :: try_from ( path, & executable) ?;
16
17
let pretty_version = info
@@ -20,14 +21,16 @@ impl TryFrom<&Path> for UMU {
20
21
. unwrap_or ( "unknown" )
21
22
. to_string ( ) ;
22
23
info. version = pretty_version;
23
- Ok ( UMU {
24
- info,
25
- proton_path : None ,
26
- } )
24
+ Ok ( UMU { info, proton } )
27
25
}
28
26
}
29
27
30
28
impl Runner for UMU {
29
+ fn wine ( & self ) -> & Wine {
30
+ // TODO: Make sure an unwrap is possible
31
+ self . proton . as_ref ( ) . unwrap ( ) . wine ( )
32
+ }
33
+
31
34
fn info ( & self ) -> & RunnerInfo {
32
35
& self . info
33
36
}
Original file line number Diff line number Diff line change @@ -28,6 +28,10 @@ impl TryFrom<&Path> for Wine {
28
28
}
29
29
30
30
impl Runner for Wine {
31
+ fn wine ( & self ) -> & Wine {
32
+ self
33
+ }
34
+
31
35
fn info ( & self ) -> & RunnerInfo {
32
36
& self . info
33
37
}
You can’t perform that action at this time.
0 commit comments