add info box and disable some ui while a popup is active
This commit is contained in:
parent
b9f76bb486
commit
6fc41bdb17
4 changed files with 280 additions and 151 deletions
26
src/main.rs
26
src/main.rs
|
@ -123,19 +123,16 @@ impl Game {
|
|||
let level_list_width = (d.get_screen_width() / 3).min(400);
|
||||
let screen_height = d.get_screen_height();
|
||||
d.draw_rectangle(0, 0, level_list_width, screen_height, BG_MEDIUM);
|
||||
|
||||
let clicked = d.is_mouse_button_pressed(MouseButton::MOUSE_BUTTON_LEFT);
|
||||
let mouse_pos = d.get_mouse_position();
|
||||
let scroll_delta = d.get_mouse_wheel_move();
|
||||
let mouse = MouseInput::get(d);
|
||||
|
||||
const ENTRY_SPACING: i32 = 65;
|
||||
let fit_on_screen = (d.get_screen_height() / ENTRY_SPACING) as usize;
|
||||
let max_scroll = self.levels.len().saturating_sub(fit_on_screen);
|
||||
if mouse_pos.x < level_list_width as f32 {
|
||||
if scroll_delta < 0. && self.level_scroll < max_scroll {
|
||||
if mouse.pos().x < level_list_width as f32 {
|
||||
if mouse.scroll() == Some(Scroll::Down) && self.level_scroll < max_scroll {
|
||||
self.level_scroll += 1;
|
||||
}
|
||||
if scroll_delta > 0. && self.level_scroll > 0 {
|
||||
if mouse.scroll() == Some(Scroll::Up) && self.level_scroll > 0 {
|
||||
self.level_scroll -= 1;
|
||||
}
|
||||
}
|
||||
|
@ -149,7 +146,7 @@ impl Game {
|
|||
width: level_list_width as f32 - 10.,
|
||||
height: ENTRY_SPACING as f32 - 5.,
|
||||
};
|
||||
let clicked_this = clicked && bounds.check_collision_point_rec(mouse_pos);
|
||||
let clicked_this = mouse.left_click() && mouse.is_over(bounds);
|
||||
match level {
|
||||
LevelListEntry::Chapter(title, level_count) => {
|
||||
d.draw_rectangle_rec(bounds, BG_DARK);
|
||||
|
@ -242,7 +239,14 @@ impl Game {
|
|||
}
|
||||
|
||||
let next_id = get_free_id(solutions, Solution::id);
|
||||
if simple_button(d, level_list_width + 10, solution_y, entry_width, 30) {
|
||||
if simple_button(
|
||||
d,
|
||||
&mouse,
|
||||
level_list_width + 10,
|
||||
solution_y,
|
||||
entry_width,
|
||||
30,
|
||||
) {
|
||||
self.selected_solution = solutions.len();
|
||||
solutions.push(Solution::new(level, next_id));
|
||||
}
|
||||
|
@ -270,7 +274,7 @@ impl Game {
|
|||
let id_text = format!("{}", solution.id());
|
||||
d.draw_text(&id_text, column_x, y + 35, 10, Color::GRAY);
|
||||
|
||||
if simple_button(d, column_x, y + 50, 220, 30) {
|
||||
if simple_button(d, &mouse, column_x, y + 50, 220, 30) {
|
||||
let cloned = solution.new_copy(next_id);
|
||||
self.selected_solution = solutions.len();
|
||||
solutions.push(cloned);
|
||||
|
@ -278,7 +282,7 @@ impl Game {
|
|||
}
|
||||
d.draw_text("clone", column_x + 5, y + 55, 20, Color::WHITE);
|
||||
|
||||
if simple_button(d, column_x, y + 85, 220, 30) {
|
||||
if simple_button(d, &mouse, column_x, y + 85, 220, 30) {
|
||||
let mut editor = Editor::new(solution.clone(), level.clone());
|
||||
editor.center_view(d);
|
||||
self.open_editor = Some(editor);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue