refactor: Move get_internal_path() out of savegame feature
This commit is contained in:
@@ -1,23 +1,12 @@
|
||||
use crate::prelude::*;
|
||||
use directories::ProjectDirs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Resource)]
|
||||
pub struct SavegamePath(pub PathBuf);
|
||||
|
||||
impl SavegamePath {
|
||||
pub fn get_project_path() -> Option<PathBuf> {
|
||||
let project_dirs = ProjectDirs::from("de", "demenik", "pomomon-garden");
|
||||
|
||||
if let Some(dirs) = project_dirs {
|
||||
Some(dirs.data_local_dir().to_path_buf())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(name: &str) -> Self {
|
||||
let base_path = Self::get_project_path().unwrap_or_else(|| {
|
||||
let base_path = get_internal_path().unwrap_or_else(|| {
|
||||
println!(
|
||||
"Could not determine platform-specific save directory. Falling back to `./saves/"
|
||||
);
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
pub mod features;
|
||||
pub mod prelude;
|
||||
pub mod utils;
|
||||
|
||||
@@ -15,6 +15,7 @@ pub use crate::features::{
|
||||
savegame::components::SavegamePath,
|
||||
ui::components::*,
|
||||
};
|
||||
pub use crate::utils::path::get_internal_path;
|
||||
pub use bevy::prelude::*;
|
||||
pub use bevy_aseprite_ultra::prelude::*;
|
||||
pub use serde::{Deserialize, Serialize};
|
||||
|
||||
1
src/utils/mod.rs
Normal file
1
src/utils/mod.rs
Normal file
@@ -0,0 +1 @@
|
||||
pub mod path;
|
||||
12
src/utils/path.rs
Normal file
12
src/utils/path.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
use directories::ProjectDirs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub fn get_internal_path() -> Option<PathBuf> {
|
||||
let project_dirs = ProjectDirs::from("de", "demenik", "pomomon-garden");
|
||||
|
||||
if let Some(dirs) = project_dirs {
|
||||
Some(dirs.data_local_dir().to_path_buf())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user