use std::path::PathBuf;

use crate::settings::{UserSettings,load_user_settings};

pub struct Directories{
	pub settings:PathBuf,
	pub maps:PathBuf,
	pub replays:PathBuf,
}
impl Directories{
	pub fn settings(&self)->UserSettings{
		load_user_settings(&self.settings)
	}
	pub fn user()->Option<Self>{
		let dirs=directories::ProjectDirs::from("net.strafes","StrafesNET","Strafe Client")?;
		Some(Self{
			settings:dirs.config_dir().join("settings.conf"),
			maps:dirs.cache_dir().join("maps"),
			// separate directory for remote downloaded replays (cache)
			// bots:dirs.cache_dir().join("bots"),
			replays:dirs.data_local_dir().join("replays"),
		})
	}
	pub fn portable()->Result<Self,std::io::Error>{
		let current_dir=std::env::current_dir()?;
		Ok(Self{
			settings:current_dir.join("settings.conf"),
			maps:current_dir.join("maps"),
			replays:current_dir.join("replays"),
		})
	}
}
