diff --git a/README.md b/README.md index 46000d9..d8adac7 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,6 @@ fix bag tiles only counting power in one direction at once tooltips lock tile types for early levels to make it less overwhelming make a gui alternative to pressing R to rotate between tile variants -scroll blueprint list make marble movement more consistent (`>o o<` depends on internal marble order) decide on marble data size (u32 or byte?) blueprint rotation? diff --git a/src/editor.rs b/src/editor.rs index 731e74a..17de297 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -55,6 +55,7 @@ pub struct Editor { score: Option, blueprints: Vec, selected_blueprint: usize, + blueprint_scroll: usize, } #[derive(Debug, PartialEq)] @@ -123,6 +124,7 @@ impl Editor { score: solution.score, blueprints: get_blueprints(), selected_blueprint: usize::MAX, + blueprint_scroll: 0, } } @@ -358,11 +360,17 @@ impl Editor { } } - if rl.get_mouse_wheel_move() > 0. { - self.zoom_in(rl); - } - if rl.get_mouse_wheel_move() < 0. { - self.zoom_out(rl); + let mouse_pos = rl.get_mouse_position(); + if self.active_tool != Tool::Blueprint + || self.sim_state != SimState::Editing + || mouse_pos.x > SIDEBAR_WIDTH as f32 + { + if rl.get_mouse_wheel_move() > 0. { + self.zoom_in(rl); + } + if rl.get_mouse_wheel_move() < 0. { + self.zoom_out(rl); + } } if rl.is_mouse_button_down(MouseButton::MOUSE_BUTTON_MIDDLE) { self.view_offset += rl.get_mouse_delta(); @@ -423,7 +431,16 @@ impl Editor { ); d.draw_text("Blueprints", 10, HEADER_HEIGHT + 30, 20, Color::WHITE); let mut y = HEADER_HEIGHT + 60; - for (i, b) in self.blueprints.iter_mut().enumerate() { + let blueprints_shown = (sidebar_height as usize - 45) / 37; + let end = self + .blueprints + .len() + .min(blueprints_shown + self.blueprint_scroll); + for (i, b) in self.blueprints[self.blueprint_scroll..end] + .iter_mut() + .enumerate() + { + let i = i + self.blueprint_scroll; if simple_button(d, 5, y, 32, 32) { b.remove_file(); self.blueprints.remove(i); @@ -793,6 +810,7 @@ impl Editor { fn board_overlay(&mut self, d: &mut RaylibDrawHandle, textures: &Textures) { let footer_top = (d.get_screen_height() - FOOTER_HEIGHT) as f32; let mouse_pos = d.get_mouse_position(); + let scroll_delta = d.get_mouse_wheel_move(); let tile_scale = (1 << self.zoom) as f32; let tile_size = 16 << self.zoom; if self.sim_state == SimState::Editing { @@ -936,6 +954,15 @@ impl Editor { offset += view_offset; bp.convert_board().draw(d, textures, offset, self.zoom); } + if mouse_pos.x < SIDEBAR_WIDTH as f32 { + if scroll_delta < 0. + && self.blueprint_scroll < self.blueprints.len().saturating_sub(5) + { + self.blueprint_scroll += 1; + } else if scroll_delta > 0. && self.blueprint_scroll > 0 { + self.blueprint_scroll -= 1; + } + } } } // draw selection