From 24f5a87e200cd44adf81858ce96d9b854cf8f44e Mon Sep 17 00:00:00 2001 From: Paris DOUADY Date: Thu, 25 Jan 2024 17:57:00 +0100 Subject: [PATCH] allow resizing lotbrush with wheel --- native_app/src/gui/tools/lotbrush.rs | 10 +++++++++- native_app/src/gui/topgui.rs | 22 ---------------------- 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/native_app/src/gui/tools/lotbrush.rs b/native_app/src/gui/tools/lotbrush.rs index ee70cc08..36e93d80 100644 --- a/native_app/src/gui/tools/lotbrush.rs +++ b/native_app/src/gui/tools/lotbrush.rs @@ -16,7 +16,7 @@ pub struct LotBrushResource { /// Allows to build houses on lots pub fn lotbrush(sim: &Simulation, uiworld: &mut UiWorld) { profiling::scope!("gui::lotbrush"); - let res = uiworld.read::(); + let mut res = uiworld.write::(); let tool = *uiworld.read::(); let inp = uiworld.read::(); let mut draw = uiworld.write::(); @@ -27,6 +27,14 @@ pub fn lotbrush(sim: &Simulation, uiworld: &mut UiWorld) { return; } + if inp.just_act.contains(&InputAction::SizeUp) { + res.radius *= 1.1; + } + if inp.just_act.contains(&InputAction::SizeDown) { + res.radius /= 1.1; + } + res.radius = res.radius.clamp(1.0, 300.0); + let kind = res.kind; let mut col = match kind { diff --git a/native_app/src/gui/topgui.rs b/native_app/src/gui/topgui.rs index 77c5b240..62036b9e 100644 --- a/native_app/src/gui/topgui.rs +++ b/native_app/src/gui/topgui.rs @@ -21,7 +21,6 @@ use simulation::Simulation; use crate::gui::bulldozer::BulldozerState; use crate::gui::chat::chat; use crate::gui::inspect::inspector; -use crate::gui::lotbrush::LotBrushResource; use crate::gui::roadeditor::RoadEditorResource; use crate::gui::specialbuilding::{SpecialBuildKind, SpecialBuildingResource}; use crate::gui::terraforming::TerraformingResource; @@ -473,27 +472,6 @@ impl Gui { }); } - if matches!(*uiworld.read::(), Tab::Housebrush) { - let lbw = 120.0; - Window::new("House Brush") - .fixed_size([lbw, 50.0]) - .fixed_pos([w - toolbox_w - lbw - 10.0, h * 0.5 - 30.0]) - .hscroll(false) - .title_bar(true) - .collapsible(false) - .resizable(false) - .show(ui, |ui| { - let mut cur_brush = uiworld.write::(); - - ui.horizontal(|ui| { - egui::DragValue::new(&mut cur_brush.radius) - .clamp_range(10.0..=300.0f32) - .ui(ui); - ui.label("radius"); - }) - }); - } - if matches!(*uiworld.read::(), Tab::Bulldozer) { let lbw = 120.0; Window::new("Bulldozer")