Choose save data location
This commit is contained in:
+25
-1
@@ -1,9 +1,10 @@
|
||||
use anyhow::Result;
|
||||
use bytemuck::NoUninit;
|
||||
use clap::{Parser, ValueEnum};
|
||||
use egui::{Color32, Pos2, Vec2};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{emulator::SimId, persistence::Persistence, window::DisplayMode};
|
||||
use crate::{emulator::SimId, filesystem::Persistence, window::DisplayMode};
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Parser)]
|
||||
@@ -53,6 +54,9 @@ pub struct CliArgs {
|
||||
/// Set a preference for whether to use a low-power or high-performance GPU adapter
|
||||
#[arg(long)]
|
||||
pub wgpu_power_preference: Option<PowerPreferenceWrapper>,
|
||||
/// Choose whether save files are kept in the rom or the data directory
|
||||
#[arg(long)]
|
||||
pub save_data_location: Option<SaveDataLocation>,
|
||||
}
|
||||
|
||||
#[derive(ValueEnum, Clone, Copy)]
|
||||
@@ -90,12 +94,27 @@ const fn default_power_preference() -> wgpu::PowerPreference {
|
||||
wgpu::PowerPreference::LowPower
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Copy, PartialEq, Eq, ValueEnum, Debug, NoUninit)]
|
||||
#[repr(usize)]
|
||||
pub enum SaveDataLocation {
|
||||
/// The same directory as the ROM
|
||||
RomDirectory,
|
||||
/// This application's data directory
|
||||
DataDirectory,
|
||||
}
|
||||
|
||||
const fn default_save_data_location() -> SaveDataLocation {
|
||||
SaveDataLocation::RomDirectory
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq)]
|
||||
pub struct AppConfig {
|
||||
#[serde(default = "default_power_preference")]
|
||||
pub power_preference: wgpu::PowerPreference,
|
||||
#[serde(default)]
|
||||
pub force_fallback: bool,
|
||||
#[serde(default = "default_save_data_location")]
|
||||
pub save_data_location: SaveDataLocation,
|
||||
}
|
||||
|
||||
impl AppConfig {
|
||||
@@ -106,6 +125,7 @@ impl AppConfig {
|
||||
Self {
|
||||
power_preference: default_power_preference(),
|
||||
force_fallback: false,
|
||||
save_data_location: default_save_data_location(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,6 +143,10 @@ impl AppConfig {
|
||||
self.force_fallback = force_fallback;
|
||||
updated = true;
|
||||
}
|
||||
if let Some(save_data_location) = args.save_data_location {
|
||||
self.save_data_location = save_data_location;
|
||||
updated = true;
|
||||
}
|
||||
updated
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user