Skip to content

Commit

Permalink
Pan bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrlabs committed Aug 31, 2024
1 parent a47c817 commit 3274199
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 25 deletions.
9 changes: 4 additions & 5 deletions lorien/InfiniteCanvas/PanZoomCamera.gd
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ func do_center(screen_space_center_point: Vector2) -> void:
func tool_event(event: InputEvent) -> void:
if _is_input_enabled:
if event is InputEventKey:
if Utils.event_pressed_bug_workaround("canvas_pan_key", event):
_pan_active = event.is_pressed()
else:
_pan_active = event.is_pressed()

if Utils.is_action_pressed("canvas_pan_key", event):
_pan_active = true
if Utils.is_action_released("canvas_pan_key", event):
_pan_active = false
if event is InputEventMouseButton:

# Scroll wheel up/down to zoom
Expand Down
6 changes: 3 additions & 3 deletions lorien/InfiniteCanvas/Tools/SelectionTool.gd
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ func _ready() -> void:

# ------------------------------------------------------------------------------------------------
func tool_event(event: InputEvent) -> void:
var duplicate_pressed := Utils.event_pressed_bug_workaround("duplicate_strokes", event)
var copy_pressed := Utils.event_pressed_bug_workaround("copy_strokes", event)
var paste_pressed := Utils.event_pressed_bug_workaround("paste_strokes", event)
var duplicate_pressed := Utils.is_action_pressed("duplicate_strokes", event)
var copy_pressed := Utils.is_action_pressed("copy_strokes", event)
var paste_pressed := Utils.is_action_pressed("paste_strokes", event)

if copy_pressed || duplicate_pressed:
var strokes := get_selected_strokes()
Expand Down
32 changes: 16 additions & 16 deletions lorien/Main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -137,39 +137,39 @@ func _process(delta: float) -> void:
# -------------------------------------------------------------------------------------------------
func _unhandled_input(event: InputEvent) -> void:
if !is_dialog_open():
if Utils.event_pressed_bug_workaround("toggle_player", event):
if Utils.is_action_pressed("toggle_player", event):
_toggle_player()

if !_player_enabled:
if Utils.event_pressed_bug_workaround("shortcut_new_project", event):
if Utils.is_action_pressed("shortcut_new_project", event):
_on_create_new_project()
elif Utils.event_pressed_bug_workaround("shortcut_open_project", event):
elif Utils.is_action_pressed("shortcut_open_project", event):
_toolbar._on_OpenFileButton_pressed()
elif Utils.event_pressed_bug_workaround("shortcut_save_project", event):
elif Utils.is_action_pressed("shortcut_save_project", event):
_on_save_project()
elif Utils.event_pressed_bug_workaround("shortcut_export_project", event):
elif Utils.is_action_pressed("shortcut_export_project", event):
_export_svg()
elif Utils.event_pressed_bug_workaround("shortcut_quit", event):
elif Utils.is_action_pressed("shortcut_quit", event):
_quit()
elif Utils.event_pressed_bug_workaround("shortcut_undo", event):
elif Utils.is_action_pressed("shortcut_undo", event):
_on_undo_action()
elif Utils.event_pressed_bug_workaround("shortcut_redo", event):
elif Utils.is_action_pressed("shortcut_redo", event):
_on_redo_action()
elif Utils.event_pressed_bug_workaround("shortcut_brush_tool", event):
elif Utils.is_action_pressed("shortcut_brush_tool", event):
_toolbar.enable_tool(Types.Tool.BRUSH)
elif Utils.event_pressed_bug_workaround("shortcut_rectangle_tool", event):
elif Utils.is_action_pressed("shortcut_rectangle_tool", event):
_toolbar.enable_tool(Types.Tool.RECTANGLE)
elif Utils.event_pressed_bug_workaround("shortcut_circle_tool", event):
elif Utils.is_action_pressed("shortcut_circle_tool", event):
_toolbar.enable_tool(Types.Tool.CIRCLE)
elif Utils.event_pressed_bug_workaround("shortcut_line_tool", event):
elif Utils.is_action_pressed("shortcut_line_tool", event):
_toolbar.enable_tool(Types.Tool.LINE)
elif Utils.event_pressed_bug_workaround("shortcut_eraser_tool", event):
elif Utils.is_action_pressed("shortcut_eraser_tool", event):
_toolbar.enable_tool(Types.Tool.ERASER)
elif Utils.event_pressed_bug_workaround("shortcut_select_tool", event):
elif Utils.is_action_pressed("shortcut_select_tool", event):
_toolbar.enable_tool(Types.Tool.SELECT)
elif Utils.event_pressed_bug_workaround("toggle_zen_mode", event):
elif Utils.is_action_pressed("toggle_zen_mode", event):
_toggle_zen_mode()
elif Utils.event_pressed_bug_workaround("toggle_fullscreen", event):
elif Utils.is_action_pressed("toggle_fullscreen", event):
_toggle_fullscreen()

# -------------------------------------------------------------------------------------------------
Expand Down
6 changes: 5 additions & 1 deletion lorien/Misc/Utils.gd
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,13 @@ func translate_action(action_name: String) -> String:
# ------------------------------------------------------------------------------------------------
# See: https://github.com/mbrlabs/Lorien/pull/168#discussion_r908251372 for details
# Does an _exact_ match for the given key stroke.
func event_pressed_bug_workaround(action_name: String, event: InputEvent) -> bool:
func is_action_pressed(action_name: String, event: InputEvent) -> bool:
return InputMap.action_has_event(action_name, event) && event.is_pressed() && !event.is_echo()

# -------------------------------------------------------------------------------------------------
func is_action_released(action_name: String, event: InputEvent) -> bool:
return InputMap.action_has_event(action_name, event) && event.is_released() && !event.is_echo()

# -------------------------------------------------------------------------------------------------
func cubic_bezier(p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2, t: float) -> Vector2:
var q0 := p0.lerp(p1, t)
Expand Down

0 comments on commit 3274199

Please sign in to comment.