Preferences (File menu): theme, grid, perspective, auto-project face edges, body selection; all kept between runs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AS5Tn3xieewUSg3uxrMVdL
This commit is contained in:
1 parent
967bee179a
commit
7a0cc85392
3 files changed
+63
-8
No files matched your search
@@ -159,16 +159,35 @@ impl SolveApp {
|
||||
|
||||
/// Preferences kept between runs (JSON), for the host to store.
|
||||
pub fn prefs(&self) -> String {
|
||||
json!({ "dark": self.ui.dark }).to_string()
|
||||
json!({
|
||||
"dark": self.ui.dark,
|
||||
"grid": self.ui.show_grid,
|
||||
"perspective": self.ui.perspective,
|
||||
"pick_bodies": self.ui.pick_bodies,
|
||||
"auto_project": self.session.auto_project,
|
||||
})
|
||||
.to_string()
|
||||
}
|
||||
|
||||
/// Restore preferences saved with [`SolveApp::prefs`].
|
||||
pub fn load_prefs(&mut self, prefs: &str) {
|
||||
if let Ok(v) = serde_json::from_str::<Value>(prefs)
|
||||
&& let Some(d) = v.get("dark").and_then(Value::as_bool)
|
||||
{
|
||||
let Ok(v) = serde_json::from_str::<Value>(prefs) else { return };
|
||||
let flag = |k: &str| v.get(k).and_then(Value::as_bool);
|
||||
if let Some(d) = flag("dark") {
|
||||
self.ui.dark = d;
|
||||
}
|
||||
if let Some(g) = flag("grid") {
|
||||
self.ui.show_grid = g;
|
||||
}
|
||||
if let Some(p) = flag("perspective") {
|
||||
self.ui.perspective = p;
|
||||
}
|
||||
if let Some(b) = flag("pick_bodies") {
|
||||
self.ui.pick_bodies = b;
|
||||
}
|
||||
if let Some(a) = flag("auto_project") {
|
||||
self.session.auto_project = a;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_control(mut self, rx: Receiver<ControlRequest>) -> Self {
|
||||
|
||||
Reference in new issue
Block a user