Add optional ambient occlusion and graphics quality presets (#1135)
Thanks @CypherNaught-0x.
This commit is contained in:
+22
-19
@@ -4,7 +4,7 @@
|
||||
//! label, id and toolbar place. It comes only from SolidCraft's command registry
|
||||
//! (`solidcraft-cli commands`), so it can't drift from what the program does; it compares with
|
||||
//! nothing else. Planned commands (registered, not built yet) are listed as planned, with their
|
||||
//! issue, and are not counted.
|
||||
//! issue. Counts are omitted so unrelated command additions do not edit shared headers.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
@@ -61,25 +61,18 @@ pub fn page(cmds: &[Value]) -> String {
|
||||
order.push((p.clone(), format!("`{p}.*`")));
|
||||
}
|
||||
let planned = |c: &Value| c["planned"].as_str().map(str::to_string);
|
||||
let built = cmds.iter().filter(|c| planned(c).is_none()).count();
|
||||
let later = match cmds.len() - built {
|
||||
0 => String::new(),
|
||||
n => format!(" Planned (registered, not built yet): {n}."),
|
||||
};
|
||||
let mut md = format!(
|
||||
// Counts made every command addition edit the same header, even across unrelated areas.
|
||||
// Keep generated text local to each command so parallel branches merge cleanly more often.
|
||||
let mut md = String::from(
|
||||
"# Features\n\nSolidCraft's commands by area, generated by `cargo xtask features` from the command registry \
|
||||
(`solidcraft-cli commands`). **{built} commands.**{later} Every command runs the same way from the toolbar, a script, \
|
||||
(`solidcraft-cli commands`). Planned commands are marked in their rows. Every command runs the same way from the toolbar, a script, \
|
||||
`solidcraft-cli exec <id> '<json>'`, the control channel and MCP; parameters are in the \
|
||||
[command reference](book/src/reference/commands.md) (`cargo xtask book`). Status and plans: [ROADMAP](../ROADMAP.md).\n"
|
||||
[command reference](book/src/reference/commands.md) (`cargo xtask book`). Status and plans: [ROADMAP](../ROADMAP.md).\n",
|
||||
);
|
||||
for (prefix, heading) in &order {
|
||||
let in_area: Vec<&Value> = cmds.iter().filter(|c| area(&s(c, "id")) == prefix).collect();
|
||||
let n = in_area.iter().filter(|c| planned(c).is_none()).count();
|
||||
let count = match in_area.len() - n {
|
||||
0 => n.to_string(),
|
||||
p => format!("{n}, {p} planned"),
|
||||
};
|
||||
md += &format!("\n## {heading} ({count})\n\n| Command | Id | Toolbar |\n|---|---|---|\n");
|
||||
let mut in_area: Vec<&Value> = cmds.iter().filter(|c| area(&s(c, "id")) == prefix).collect();
|
||||
in_area.sort_by_key(|c| s(c, "id"));
|
||||
md += &format!("\n## {heading}\n\n| Command | Id | Toolbar |\n|---|---|---|\n");
|
||||
for c in in_area {
|
||||
let place = match (s(c, "tab"), s(c, "panel")) {
|
||||
(t, _) if t.is_empty() => "–".to_string(),
|
||||
@@ -108,12 +101,22 @@ mod tests {
|
||||
)
|
||||
.unwrap();
|
||||
let md = page(cmds.as_array().unwrap());
|
||||
assert!(md.contains("**3 commands.** Planned (registered, not built yet): 1."));
|
||||
let (sk, so, other) =
|
||||
(md.find("## Sketch (1)").unwrap(), md.find("## Solid modelling (1, 1 planned)").unwrap(), md.find("## `view.*` (1)").unwrap());
|
||||
assert!(md.contains("Planned commands are marked in their rows."));
|
||||
let (sk, so, other) = (md.find("## Sketch").unwrap(), md.find("## Solid modelling").unwrap(), md.find("## `view.*`").unwrap());
|
||||
assert!(sk < so && so < other);
|
||||
assert!(md.contains("| Extrude (E) | `solid.extrude` | SOLID › CREATE |"));
|
||||
assert!(md.contains("| Fit | `view.fit` | – |"));
|
||||
assert!(md.contains("| Knit *(planned: [#9](https://github.com/bherbruck/solidcraft/issues/9))* | `solid.knit` | SOLID › CREATE |"));
|
||||
}
|
||||
#[test]
|
||||
fn unrelated_additions_do_not_rewrite_existing_lines_and_order_is_stable() {
|
||||
let commands = vec![serde_json::json!({"id":"view.zoom","label":"Zoom"}), serde_json::json!({"id":"view.fit","label":"Fit"})];
|
||||
let before = page(&commands);
|
||||
let mut reordered = commands.clone();
|
||||
reordered.reverse();
|
||||
assert_eq!(before, page(&reordered));
|
||||
reordered.push(serde_json::json!({"id":"view.pan","label":"Pan"}));
|
||||
let after = page(&reordered);
|
||||
assert_eq!(before, after.lines().filter(|l| !l.contains("`view.pan`")).collect::<Vec<_>>().join("\n") + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user