From 48e871586ca133e6008c95b64622b7eef09f247c Mon Sep 17 00:00:00 2001 From: OverloadedOrama <35376950+OverloadedOrama@users.noreply.github.com> Date: Thu, 9 Jan 2020 20:49:27 +0200 Subject: [PATCH 1/3] Added space for panning - Closes #110 --- Changelog.md | 5 +++-- Scripts/CameraMovement.gd | 4 ++-- Scripts/Canvas.gd | 9 ++++++++- Scripts/Dialogs/AboutDialog.gd | 1 + project.godot | 7 ++++++- 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Changelog.md b/Changelog.md index d323eae..c0c6bc8 100644 --- a/Changelog.md +++ b/Changelog.md @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Added - Italian localization - thanks to Marco Galli! +- In addition to the middle mouse button, you can now use `Space` to pan around the canvas. ### Changed - More translatable strings, updates to Greek & Brazilian Portuguese (thanks to YeldhamDev) localizations. @@ -14,10 +15,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Added a VSplitContainer for Palettes and Layers. - Added a ScrollContainer for the palette buttons on the Edit Palette popup. - Made Palette .json files more readable, and made "comments" on top of the color data. -- THe grid options are now being updated realtime when they're being changed from the preferences. +- The grid options are now being updated realtime when they're being changed from the preferences. ### Fixed -- Crash that occured when trying to delete contents of a selection, that were outside the canvas. +- Fixed crash that occured when trying to delete contents of a selection, that were outside the canvas. - Fixed .gpl palettes not being imported correctly - Issue #112 - Fixed crash that occured when pressing the play buttons on the timeline, on Godot 3.2 - Issue #111 diff --git a/Scripts/CameraMovement.gd b/Scripts/CameraMovement.gd index 313894a..8094d65 100644 --- a/Scripts/CameraMovement.gd +++ b/Scripts/CameraMovement.gd @@ -11,9 +11,9 @@ func _ready() -> void: func _input(event : InputEvent) -> void: var mouse_pos := viewport_container.get_local_mouse_position() var viewport_size := viewport_container.rect_size - if event.is_action_pressed("camera_drag"): + if event.is_action_pressed("camera_drag") || event.is_action_pressed("space"): drag = true - elif event.is_action_released("camera_drag"): + elif event.is_action_released("camera_drag") || event.is_action_released("space"): drag = false if Global.can_draw && Rect2(Vector2.ZERO, viewport_size).has_point(mouse_pos): diff --git a/Scripts/Canvas.gd b/Scripts/Canvas.gd index 767e46f..005a271 100644 --- a/Scripts/Canvas.gd +++ b/Scripts/Canvas.gd @@ -91,11 +91,18 @@ func _input(event : InputEvent) -> void: else: return + current_pixel = get_local_mouse_position() + location if Global.current_frame == frame && Global.has_focus: update() + # We don't want to draw when pressing space, because it's used for panning + if Input.is_action_pressed("space"): + previous_mouse_pos = current_pixel + previous_mouse_pos.x = clamp(previous_mouse_pos.x, location.x, location.x + size.x) + previous_mouse_pos.y = clamp(previous_mouse_pos.y, location.y, location.y + size.y) + return + sprite_changed_this_frame = false - current_pixel = get_local_mouse_position() + location var mouse_pos := current_pixel var mouse_pos_floored := mouse_pos.floor() var mouse_pos_ceiled := mouse_pos.ceil() diff --git a/Scripts/Dialogs/AboutDialog.gd b/Scripts/Dialogs/AboutDialog.gd index bda6979..1f98c97 100644 --- a/Scripts/Dialogs/AboutDialog.gd +++ b/Scripts/Dialogs/AboutDialog.gd @@ -24,6 +24,7 @@ func _ready() -> void: contributors.create_item(contributor_root).set_text(0, " Subhang Nanduri") contributors.create_item(contributor_root).set_text(0, " danielnaoexiste") contributors.create_item(contributor_root).set_text(0, " huskee") + contributors.create_item(contributor_root).set_text(0, " Gaarco") var donors_root := donors.create_item() donors.create_item(donors_root).set_text(0, " pcmxms") diff --git a/project.godot b/project.godot index 7debd2b..adeb14e 100644 --- a/project.godot +++ b/project.godot @@ -45,12 +45,12 @@ _global_script_class_icons={ [application] config/name="Pixelorama" -config/description="A free & open-source 2D sprite editor" run/main_scene="res://Main.tscn" run/low_processor_mode=true boot_splash/image="res://splash.png" boot_splash/bg_color=Color( 0.145098, 0.145098, 0.164706, 1 ) config/icon="res://icon.png" +config/description="A free & open-source 2D sprite editor" config/Version="v0.6.1" [autoload] @@ -214,6 +214,11 @@ delete={ "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777224,"unicode":0,"echo":false,"script":null) ] } +space={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"unicode":0,"echo":false,"script":null) + ] +} [locale] From 16e92b0e9f9ccae2dfe4e79750ab5a3e4e151b32 Mon Sep 17 00:00:00 2001 From: OverloadedOrama <35376950+OverloadedOrama@users.noreply.github.com> Date: Thu, 9 Jan 2020 20:51:03 +0200 Subject: [PATCH 2/3] Removed uneccesary code from Canvas.gd that prevented _input() from executing if Space was being pressed --- Scripts/Canvas.gd | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Scripts/Canvas.gd b/Scripts/Canvas.gd index 005a271..887e977 100644 --- a/Scripts/Canvas.gd +++ b/Scripts/Canvas.gd @@ -95,13 +95,6 @@ func _input(event : InputEvent) -> void: if Global.current_frame == frame && Global.has_focus: update() - # We don't want to draw when pressing space, because it's used for panning - if Input.is_action_pressed("space"): - previous_mouse_pos = current_pixel - previous_mouse_pos.x = clamp(previous_mouse_pos.x, location.x, location.x + size.x) - previous_mouse_pos.y = clamp(previous_mouse_pos.y, location.y, location.y + size.y) - return - sprite_changed_this_frame = false var mouse_pos := current_pixel var mouse_pos_floored := mouse_pos.floor() From cc03b356502aeedc0230e4596ba320fd3356c803 Mon Sep 17 00:00:00 2001 From: OverloadedOrama <35376950+OverloadedOrama@users.noreply.github.com> Date: Fri, 10 Jan 2020 00:12:36 +0200 Subject: [PATCH 3/3] Grid & Guides preferences now get saved in the config cache file --- Scripts/Dialogs/PreferencesDialog.gd | 35 ++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Scripts/Dialogs/PreferencesDialog.gd b/Scripts/Dialogs/PreferencesDialog.gd index 77ddd4e..d4b99a0 100644 --- a/Scripts/Dialogs/PreferencesDialog.gd +++ b/Scripts/Dialogs/PreferencesDialog.gd @@ -6,6 +6,11 @@ onready var languages = $HSplitContainer/ScrollContainer/VBoxContainer/Languages onready var themes = $HSplitContainer/ScrollContainer/VBoxContainer/Themes onready var grid_guides = $"HSplitContainer/ScrollContainer/VBoxContainer/Grid&Guides" +onready var grid_width_value = $"HSplitContainer/ScrollContainer/VBoxContainer/Grid&Guides/GridOptions/GridWidthValue" +onready var grid_height_value = $"HSplitContainer/ScrollContainer/VBoxContainer/Grid&Guides/GridOptions/GridHeightValue" +onready var grid_color = $"HSplitContainer/ScrollContainer/VBoxContainer/Grid&Guides/GridOptions/GridColor" +onready var guide_color = $"HSplitContainer/ScrollContainer/VBoxContainer/Grid&Guides/GridOptions/GuideColor" + func _ready() -> void: for child in languages.get_children(): if child is Button: @@ -23,6 +28,28 @@ func _ready() -> void: change_theme(0) themes.get_child(1).pressed = true + + # Set default values for Grid & Guide options + if Global.config_cache.has_section_key("preferences", "grid_size"): + var grid_size = Global.config_cache.get_value("preferences", "grid_size") + print(Global.grid_width) + Global.grid_width = int(grid_size.x) + Global.grid_height = int(grid_size.y) + grid_width_value.value = grid_size.x + grid_height_value.value = grid_size.y + + if Global.config_cache.has_section_key("preferences", "grid_color"): + Global.grid_color = Global.config_cache.get_value("preferences", "grid_color") + grid_color.color = Global.grid_color + + if Global.config_cache.has_section_key("preferences", "guide_color"): + Global.guide_color = Global.config_cache.get_value("preferences", "guide_color") + for canvas in Global.canvases: + for guide in canvas.get_children(): + if guide is Guide: + guide.default_color = Global.guide_color + guide_color.color = Global.guide_color + func _on_PreferencesDialog_about_to_show() -> void: var root := tree.create_item() var language_button := tree.create_item(root) @@ -173,14 +200,20 @@ func change_theme(ID : int) -> void: func _on_GridWidthValue_value_changed(value : float) -> void: Global.grid_width = value Global.canvas.update() + Global.config_cache.set_value("preferences", "grid_size", Vector2(value, grid_height_value.value)) + Global.config_cache.save("user://cache.ini") func _on_GridHeightValue_value_changed(value : float) -> void: Global.grid_height = value Global.canvas.update() + Global.config_cache.set_value("preferences", "grid_size", Vector2(grid_width_value.value, value)) + Global.config_cache.save("user://cache.ini") func _on_GridColor_color_changed(color : Color) -> void: Global.grid_color = color Global.canvas.update() + Global.config_cache.set_value("preferences", "grid_color", color) + Global.config_cache.save("user://cache.ini") func _on_GuideColor_color_changed(color : Color) -> void: Global.guide_color = color @@ -188,3 +221,5 @@ func _on_GuideColor_color_changed(color : Color) -> void: for guide in canvas.get_children(): if guide is Guide: guide.default_color = color + Global.config_cache.set_value("preferences", "guide_color", color) + Global.config_cache.save("user://cache.ini")