Skip to content

Commit

Permalink
feat: move screen always when mouse in border
Browse files Browse the repository at this point in the history
  • Loading branch information
buxx committed Apr 6, 2024
1 parent 9165290 commit 05f8361
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
23 changes: 10 additions & 13 deletions battle_gui/src/engine/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,16 @@ impl Engine {
messages.push(EngineMessage::GuiState(GuiStateMessage::PushUIEvent(
UIEvent::ImmobileCursorSince(cursor_immobile_since),
)));

if !self.gui_state.pending_order().is_empty() || self.gui_state.dragged_squad().is_some() {
if let Some(border) =
self.point_in_border(ctx, self.gui_state.current_cursor_window_point())
{
let (x, y) = border.modifier();
messages.push(EngineMessage::GuiState(
GuiStateMessage::ApplyOnDisplaySceneOffset(Offset::new(
-x as f32 * BORDER_MOVE_FACTOR,
-y as f32 * BORDER_MOVE_FACTOR,
)),
));
}
if let Some(border) =
self.point_in_border(ctx, self.gui_state.current_cursor_window_point())
{
let (x, y) = border.modifier();
messages.push(EngineMessage::GuiState(
GuiStateMessage::ApplyOnDisplaySceneOffset(Offset::new(
-x as f32 * BORDER_MOVE_FACTOR * self.gui_state.zoom.factor(),
-y as f32 * BORDER_MOVE_FACTOR * self.gui_state.zoom.factor(),
)),
));
}

messages
Expand Down
2 changes: 1 addition & 1 deletion battle_gui/src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ pub mod hud;
pub mod menu;

pub const BORDER_SIZE: f32 = 30.;
pub const BORDER_MOVE_FACTOR: f32 = 3.;
pub const BORDER_MOVE_FACTOR: f32 = 5.;

0 comments on commit 05f8361

Please sign in to comment.