Skip to content

Commit 5492295

Browse files
authored
Change default openpal3.toml and yaobow-assets path for linux (#57)
* set opeanpal3.toml default at ~/.config on linux * allow yaobow-assets at /usr/share/yaobow/ on linux
1 parent e1646a2 commit 5492295

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

yaobow/shared/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ thiserror = "1.0"
4343
uuid = "0.8"
4444
wavefront_obj = "5.1.0"
4545
xxtea = "0.2.0"
46+
shellexpand = "3.1"
4647

4748
[target.'cfg(target_os = "android")'.dependencies]
4849
ndk-glue = "0.5.0"

yaobow/shared/src/config.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ impl YaobowConfig {
1111

1212
let mut builder = config::Config::builder();
1313

14-
if std::path::PathBuf::from(config_name).exists() {
15-
builder = builder.add_source(config::File::new(config_name, config::FileFormat::Toml));
14+
if let Ok(expanded) = shellexpand::full(config_name) {
15+
let path = std::path::PathBuf::from(expanded.as_ref());
16+
if path.exists() {
17+
builder = builder.add_source(config::File::new(expanded.as_ref(), config::FileFormat::Toml));
18+
}
1619
}
1720

1821
let cfg = ydirs::config_dir().join(config_name);

yaobow/yaobow/src/application/director.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ impl TitleSelectionDirector {
144144
let zip = PathBuf::from(ASSET_PATH);
145145
let local1 = PathBuf::from("./yaobow/yaobow-assets");
146146
let local2 = PathBuf::from("../yaobow-assets");
147+
let local3 = PathBuf::from("/usr/share/yaobow/yaobow-assets");
147148

148149
if Path::exists(&zip) {
149150
let local = ZipFs::new(std::fs::File::open(zip).unwrap());
@@ -157,6 +158,10 @@ impl TitleSelectionDirector {
157158
let local = LocalFs::new(&local2);
158159
vfs = vfs.mount(PathBuf::from("/"), local);
159160
Some(Rc::new(vfs))
161+
} else if Path::exists(&local3) {
162+
let local = LocalFs::new(&local3);
163+
vfs = vfs.mount(PathBuf::from("/"), local);
164+
Some(Rc::new(vfs))
160165
} else {
161166
None
162167
}

yaobow/yaobow/src/application/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ impl YaobowApplicationLoader {
7373
pub fn new(app: ComRc<IApplication>) -> Self {
7474
Self {
7575
app,
76+
#[cfg(linux)]
77+
config: YaobowConfig::load("~/.config/openpal3.toml", "OPENPAL3"),
78+
#[cfg(not(linux))]
7679
config: YaobowConfig::load("openpal3.toml", "OPENPAL3"),
7780
selected_game: Rc::new(RefCell::new(None)),
7881
}

0 commit comments

Comments
 (0)