11use std:: path;
2-
32use frontend:: render;
43use frontend:: input:: EventMapper ;
54use frontend:: input:: GamepadEventLoop ;
@@ -11,6 +10,7 @@ use frontend::gfx_window_glutin;
1110use conrod;
1211
1312use core:: resource:: filesystem:: ResourceLoaderBuilder ;
13+ use core:: resource:: filesystem:: ResourceLoader ;
1414use core:: math:: Directional ;
1515use core:: clock:: { seconds, SecondsValue , Hourglass , SystemTimer } ;
1616use ctrlc;
@@ -22,7 +22,19 @@ use winit::{self, WindowEvent, VirtualKeyCode, KeyboardInput};
2222use glutin;
2323use glutin:: GlContext ;
2424
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 > ) {
2638 const WIDTH : u32 = 1280 ;
2739 const HEIGHT : u32 = 1024 ;
2840
@@ -56,15 +68,13 @@ pub fn main_loop(minion_gene_pool: &str, world_file: Option<String>, fullscreen:
5668
5769 let mut encoder = factory. create_command_buffer ( ) . into ( ) ;
5870
59- let res = ResourceLoaderBuilder :: new ( )
60- . add ( path:: Path :: new ( "resources" ) )
61- . build ( ) ;
71+ let res = make_resource_loader ( & config_home) ;
6272
6373 let renderer = & mut render:: ForwardRenderer :: new ( & mut factory, & mut encoder, & res, & frame_buffer) . unwrap ( ) ;
6474 let mapper = app:: WinitEventMapper :: new ( ) ;
6575
6676 // 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) ;
6878
6979 let mut ui = ui:: conrod_ui:: Ui :: new ( & res,
7080 & mut factory,
@@ -163,14 +173,12 @@ pub fn main_loop(minion_gene_pool: &str, world_file: Option<String>, fullscreen:
163173 } ;
164174}
165175
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 > ) {
167177 const WIDTH : u32 = 1024 ;
168178 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) ;
172180
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) ;
174182 let mut no_audio = ui:: NullAlertPlayer :: new ( ) ;
175183 app. init ( app:: SystemMode :: Batch ) ;
176184
0 commit comments