1
1
use crate :: app:: App ;
2
2
use projectm_rs:: core:: Projectm ;
3
+ use std:: path:: Path ;
3
4
4
5
pub type FrameRate = u32 ;
5
6
@@ -25,11 +26,28 @@ pub struct Config {
25
26
26
27
impl Default for Config {
27
28
fn default ( ) -> Self {
28
- // default preset path
29
+ // get paths to presets and textures
30
+ // TODO: get from config file or env
31
+ //
32
+ // use /usr/local/share/projectM if it exists, otherwise use local paths
33
+ let resource_dir = "/usr/local/share/projectM" ;
34
+ let dir_exists = Path :: new ( & resource_dir) . exists ( ) ;
35
+ let preset_path = if dir_exists {
36
+ String :: from ( resource_dir) + "/presets"
37
+ } else {
38
+ // just test presets
39
+ "./presets" . to_owned ( )
40
+ } ;
41
+ let texture_path = if dir_exists {
42
+ String :: from ( resource_dir) + "/textures"
43
+ } else {
44
+ // doesn't exist
45
+ "./textures" . to_owned ( )
46
+ } ;
47
+
29
48
Self {
30
- // TODO: load from home dir or w/e
31
- preset_path : Some ( "/usr/local/share/projectM/presets" . to_owned ( ) ) ,
32
- texture_path : Some ( "/usr/local/share/projectM/textures" . to_owned ( ) ) ,
49
+ preset_path : Path :: new ( & preset_path) . exists ( ) . then ( || preset_path) ,
50
+ texture_path : Path :: new ( & texture_path) . exists ( ) . then ( || texture_path) ,
33
51
frame_rate : Some ( 60 ) ,
34
52
beat_sensitivity : Some ( 1.0 ) ,
35
53
preset_duration : Some ( 10.0 ) ,
@@ -67,6 +85,9 @@ impl App {
67
85
if let Some ( preset_duration) = config. preset_duration {
68
86
Projectm :: set_preset_duration ( pm, preset_duration) ;
69
87
}
88
+
89
+ // set preset shuffle mode
90
+ // self.playlist.set_shuffle(true);
70
91
}
71
92
72
93
pub fn get_frame_rate ( & self ) -> FrameRate {
0 commit comments