mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-19 14:06:09 +00:00
3D (Classic): Reset all keeps Map Art and its options
Reset all in the classic 3D dialogs reset mapArt to its empty default, which removed every map, and turned Shade Artwork and Invisible Geometry off. Like the mapped graphics and the render settings, Map Art, mapShade and mapInvisible now stay; the shape, view and lighting still reset.
This commit is contained in:
@@ -37,12 +37,19 @@ pub(super) fn body(app: &VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) {
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
let id = d.str("__effect");
|
||||
let defaults = vectorcraft_effects::default_params(&id).unwrap_or(json!({}));
|
||||
// Reset all resets the shape, view and light; the mapped graphics and the render
|
||||
// settings stay.
|
||||
// Reset all resets the shape, view and light; the mapped graphics, Map Art with its
|
||||
// options and the render settings stay.
|
||||
let defaults = match defaults {
|
||||
Value::Object(mut m) => {
|
||||
m.remove(vectorcraft_effects::GRAPHICS);
|
||||
m.remove(vectorcraft_effects::RENDER);
|
||||
for key in [
|
||||
vectorcraft_effects::GRAPHICS,
|
||||
vectorcraft_effects::RENDER,
|
||||
vectorcraft_effects::MAP_ART,
|
||||
vectorcraft_effects::MAP_SHADE,
|
||||
vectorcraft_effects::MAP_INVISIBLE,
|
||||
] {
|
||||
m.remove(key);
|
||||
}
|
||||
Value::Object(m)
|
||||
}
|
||||
other => other,
|
||||
|
||||
@@ -771,6 +771,27 @@ fn every_3d_dialog_has_color_and_reset_all_restores_white() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reset_all_keeps_map_art_and_its_options() {
|
||||
for effect in [CLASSIC_EXTRUDE, CLASSIC_REVOLVE] {
|
||||
let mut h = Harness::with("M100 100L200 100L200 200L100 200Z", effect, vec2(1280.0, 900.0));
|
||||
h.settle();
|
||||
let maps = json!([{"surface": 1, "symbol": "Mark"}]);
|
||||
let d = h.app.ui.dialog.as_mut().unwrap();
|
||||
d.fields.insert("mapArt".into(), maps.clone());
|
||||
d.fields.insert("mapShade".into(), json!(true));
|
||||
d.fields.insert("mapInvisible".into(), json!(true));
|
||||
d.fields.insert("rotationX".into(), json!(40.0));
|
||||
h.settle();
|
||||
h.click(h.response("revolve-reset-all").center());
|
||||
let d = h.app.ui.dialog.as_ref().unwrap();
|
||||
assert_eq!(d.f64("rotationX", 0.0), -21.88, "{effect}: the view is reset");
|
||||
assert_eq!(d.fields.get("mapArt"), Some(&maps), "{effect}: the maps stay");
|
||||
assert!(d.bool("mapShade") && d.bool("mapInvisible"), "{effect}: Shade Artwork and Invisible Geometry stay");
|
||||
dialogs::cancel(&mut h.app);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn light_list_add_select_edit_delete_and_reset_keep_each_light_independent() {
|
||||
for effect in [REVOLVE, EXTRUDE, INFLATE, vectorcraft_effects::ROTATE] {
|
||||
|
||||
Reference in New Issue
Block a user