move conf file name to common.rs

This commit is contained in:
yuni 2024-05-13 01:42:14 +02:00
parent 6ab89615b7
commit 585fa7d3f4
2 changed files with 5 additions and 3 deletions

View file

@ -17,6 +17,7 @@ pub use std::f32::consts::PI as PI32;
pub use std::f64::consts::PI;
pub const WINDOW_TITLE: &str = "OutFly";
pub const CONF_FILE: &str = "outfly.toml";
pub const FONT: &str = "fonts/Yupiter-Regular.ttf";
pub const EPSILON32: f32 = 1e-9;

View file

@ -11,6 +11,7 @@
// This module manages variables, settings, as well as evaluating
// "if"-conditions in chats.
use crate::prelude::*;
use bevy::window::WindowMode;
use bevy::prelude::*;
use std::collections::HashMap;
@ -317,17 +318,17 @@ fn file_is_readable(file_path: &str) -> bool {
}
fn get_prefs_path() -> Option<String> {
let test = "outfly.toml";
let test = CONF_FILE;
if file_is_readable(test) {
return Some(test.to_string());
}
if let Ok(basedir) = env::var("XDG_CONFIG_HOME") {
let test = basedir.to_string() + "/outfly/outfly.toml";
let test = basedir.to_string() + "/outfly/" + CONF_FILE;
if file_is_readable(test.as_str()) {
return Some(test);
}
} else if let Ok(basedir) = env::var("HOME") {
let test = basedir.to_string() + ".config/outfly/outfly.toml";
let test = basedir.to_string() + ".config/outfly/" + CONF_FILE;
if file_is_readable(test.as_str()) {
return Some(test);
}