1
1
use std:: path;
2
-
3
2
use frontend:: render;
4
3
use frontend:: input:: EventMapper ;
5
4
use frontend:: input:: GamepadEventLoop ;
@@ -11,6 +10,7 @@ use frontend::gfx_window_glutin;
11
10
use conrod;
12
11
13
12
use core:: resource:: filesystem:: ResourceLoaderBuilder ;
13
+ use core:: resource:: filesystem:: ResourceLoader ;
14
14
use core:: math:: Directional ;
15
15
use core:: clock:: { seconds, SecondsValue , Hourglass , SystemTimer } ;
16
16
use ctrlc;
@@ -22,7 +22,19 @@ use winit::{self, WindowEvent, VirtualKeyCode, KeyboardInput};
22
22
use glutin;
23
23
use glutin:: GlContext ;
24
24
25
- pub fn main_loop ( minion_gene_pool : & str , world_file : Option < String > , fullscreen : Option < usize > , width : Option < u32 > , height : Option < u32 > , audio_device : Option < usize > ) {
25
+ pub fn make_resource_loader ( config_home : & path:: Path ) -> ResourceLoader {
26
+ let res = ResourceLoaderBuilder :: new ( )
27
+ . add ( path:: Path :: new ( "./resources" ) )
28
+ . add ( config_home. join ( "resources" ) . as_path ( ) )
29
+ . add ( config_home. join ( "saved_state" ) . as_path ( ) )
30
+ . add ( path:: Path :: new ( "/usr/local/share/rust-oids/resources" ) )
31
+ . add ( path:: Path :: new ( "/usr/share/rust-oids/resources" ) )
32
+ . build ( ) ;
33
+
34
+ res
35
+ }
36
+
37
+ pub fn main_loop ( minion_gene_pool : & str , config_home : path:: PathBuf , world_file : Option < String > , fullscreen : Option < usize > , width : Option < u32 > , height : Option < u32 > , audio_device : Option < usize > ) {
26
38
const WIDTH : u32 = 1280 ;
27
39
const HEIGHT : u32 = 1024 ;
28
40
@@ -56,15 +68,13 @@ pub fn main_loop(minion_gene_pool: &str, world_file: Option<String>, fullscreen:
56
68
57
69
let mut encoder = factory. create_command_buffer ( ) . into ( ) ;
58
70
59
- let res = ResourceLoaderBuilder :: new ( )
60
- . add ( path:: Path :: new ( "resources" ) )
61
- . build ( ) ;
71
+ let res = make_resource_loader ( & config_home) ;
62
72
63
73
let renderer = & mut render:: ForwardRenderer :: new ( & mut factory, & mut encoder, & res, & frame_buffer) . unwrap ( ) ;
64
74
let mapper = app:: WinitEventMapper :: new ( ) ;
65
75
66
76
// Create a new game and run it.
67
- let mut app = app:: App :: new ( w as u32 , h as u32 , 100.0 , & res, minion_gene_pool, world_file) ;
77
+ let mut app = app:: App :: new ( w as u32 , h as u32 , 100.0 , config_home , & res, minion_gene_pool, world_file) ;
68
78
69
79
let mut ui = ui:: conrod_ui:: Ui :: new ( & res,
70
80
& mut factory,
@@ -163,14 +173,12 @@ pub fn main_loop(minion_gene_pool: &str, world_file: Option<String>, fullscreen:
163
173
} ;
164
174
}
165
175
166
- pub fn main_loop_headless ( minion_gene_pool : & str , world_file : Option < String > ) {
176
+ pub fn main_loop_headless ( minion_gene_pool : & str , config_home : path :: PathBuf , world_file : Option < String > ) {
167
177
const WIDTH : u32 = 1024 ;
168
178
const HEIGHT : u32 = 1024 ;
169
- let res = ResourceLoaderBuilder :: new ( )
170
- . add ( path:: Path :: new ( "resources" ) )
171
- . build ( ) ;
179
+ let res = make_resource_loader ( & config_home) ;
172
180
173
- let mut app = app:: App :: new ( WIDTH , HEIGHT , 100.0 , & res, minion_gene_pool, world_file) ;
181
+ let mut app = app:: App :: new ( WIDTH , HEIGHT , 100.0 , config_home , & res, minion_gene_pool, world_file) ;
174
182
let mut no_audio = ui:: NullAlertPlayer :: new ( ) ;
175
183
app. init ( app:: SystemMode :: Batch ) ;
176
184
0 commit comments