mirror of
https://github.com/lobomfz/VIctory-xmem.git
synced 2026-12-06 05:48:38 +00:00
presets: the preset files in presets/
run.<preset>.conf becomes presets/<preset>.conf; run.sh, the menu and the docs follow. VICTORY_PRESET is used as before. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -87,7 +87,7 @@ shell line before `run.sh` are cleared; put them after the mode instead:
|
||||
## Presets
|
||||
|
||||
`VICTORY_PRESET=potato|low|medium|high|ultra` applies one of the presets in
|
||||
`run.<preset>.conf`. The F1 menu lists the same five. Settings in `run.conf`,
|
||||
`presets/<preset>.conf`. The F1 menu lists the same five. Settings in `run.conf`,
|
||||
`local/menu.conf` or after the mode on the command line override the preset:
|
||||
|
||||
```bash
|
||||
|
||||
@ -147,7 +147,7 @@ pub fn enabled() -> bool {
|
||||
pub struct Menu {
|
||||
pub settings: Vec<Setting>,
|
||||
values: Vec<Option<String>>,
|
||||
/// `run.<preset>.conf` values, by preset name.
|
||||
/// `presets/<preset>.conf` values, by preset name.
|
||||
presets: Vec<(String, Vec<(String, String)>)>,
|
||||
/// Settings the game turned off at this start, and why.
|
||||
pub attention: Vec<(String, String)>,
|
||||
@ -349,7 +349,7 @@ impl Menu {
|
||||
}
|
||||
}
|
||||
|
||||
/// Reads `run.<preset>.conf` next to `run.conf.default` for each choice of
|
||||
/// Reads `presets/<preset>.conf` next to `run.conf.default` for each choice of
|
||||
/// `VICTORY_PRESET`.
|
||||
fn load_presets(defs: &Path, settings: &[Setting]) -> Vec<(String, Vec<(String, String)>)> {
|
||||
let Some(choice) = settings.iter().find(|s| s.name == "VICTORY_PRESET") else {
|
||||
@ -360,7 +360,8 @@ fn load_presets(defs: &Path, settings: &[Setting]) -> Vec<(String, Vec<(String,
|
||||
.choices
|
||||
.iter()
|
||||
.filter_map(|name| {
|
||||
let text = std::fs::read_to_string(dir.join(format!("run.{name}.conf"))).ok()?;
|
||||
let text =
|
||||
std::fs::read_to_string(dir.join("presets").join(format!("{name}.conf"))).ok()?;
|
||||
Some((name.clone(), parse(settings, &text)))
|
||||
})
|
||||
.collect()
|
||||
@ -457,12 +458,17 @@ mod tests {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let defs = dir.path().join("run.conf.default");
|
||||
std::fs::write(&defs, PRESETS).unwrap();
|
||||
std::fs::create_dir(dir.path().join("presets")).unwrap();
|
||||
std::fs::write(
|
||||
dir.path().join("run.potato.conf"),
|
||||
dir.path().join("presets/potato.conf"),
|
||||
"VICTORY_LOD_SCALE=0.05\nVICTORY_SMALL_CULL=16.0\n",
|
||||
)
|
||||
.unwrap();
|
||||
std::fs::write(dir.path().join("run.low.conf"), "VICTORY_LOD_SCALE=0.1\n").unwrap();
|
||||
std::fs::write(
|
||||
dir.path().join("presets/low.conf"),
|
||||
"VICTORY_LOD_SCALE=0.1\n",
|
||||
)
|
||||
.unwrap();
|
||||
let settings = parse_defs(PRESETS);
|
||||
let presets = load_presets(&defs, &settings);
|
||||
assert_eq!(presets.len(), 2);
|
||||
|
||||
@ -29,7 +29,7 @@ VICTORY_KBM_PC=
|
||||
VICTORY_FRAME_INTERVAL_MS=
|
||||
|
||||
# Settings preset: potato, low, medium, high or ultra. Rows below override it;
|
||||
# changing the preset resets the preset's rows. See run.<preset>.conf.
|
||||
# changing the preset resets the preset's rows. See presets/<preset>.conf.
|
||||
# choices: potato|low|medium|high|ultra
|
||||
VICTORY_PRESET=
|
||||
|
||||
|
||||
6
run.sh
6
run.sh
@ -57,13 +57,13 @@ for kv in "$@"; do case "$kv" in VICTORY_PRESET=*) preset=${kv#VICTORY_PRESET=};
|
||||
case "$preset" in
|
||||
"") ;;
|
||||
potato|low|medium|high|ultra)
|
||||
if [ -f "$root/run.$preset.conf" ]; then
|
||||
if [ -f "$root/presets/$preset.conf" ]; then
|
||||
set -a
|
||||
source "$root/run.$preset.conf"
|
||||
source "$root/presets/$preset.conf"
|
||||
set +a
|
||||
echo "preset: $preset"
|
||||
else
|
||||
echo "warning: preset '$preset' has no run.$preset.conf" >&2
|
||||
echo "warning: preset '$preset' has no presets/$preset.conf" >&2
|
||||
fi
|
||||
;;
|
||||
*) echo "warning: unknown preset '$preset' (potato, low, medium, high, ultra)" >&2;;
|
||||
|
||||
Reference in New Issue
Block a user