mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00:00
Merging layer & saving sprite now uses custom blend_rect method
Also added CameraMovement.gd to the preview window camera and fixed a cursor problem where it always remained as the default arrow cursor outside the canvas
This commit is contained in:
parent
5613c3d7ef
commit
2369243cfc
|
@ -1,6 +1,6 @@
|
|||
[gd_scene load_steps=48 format=2]
|
||||
|
||||
[ext_resource path="res://Main Theme.tres" type="Theme" id=1]
|
||||
[ext_resource path="res://Themes & Styles/Main Theme.tres" type="Theme" id=1]
|
||||
[ext_resource path="res://Scripts/Main.gd" type="Script" id=2]
|
||||
[ext_resource path="res://Assets/Graphics/Tools/RectSelect.png" type="Texture" id=3]
|
||||
[ext_resource path="res://Assets/Graphics/Tools/ColorPicker.png" type="Texture" id=4]
|
||||
|
@ -11,7 +11,7 @@
|
|||
[ext_resource path="res://Assets/Graphics/Color switch.png" type="Texture" id=9]
|
||||
[ext_resource path="res://Assets/Graphics/Color defaults.png" type="Texture" id=10]
|
||||
[ext_resource path="res://Assets/Graphics/Brush_button.png" type="Texture" id=11]
|
||||
[ext_resource path="res://Styles/RulerStyle.tres" type="StyleBox" id=12]
|
||||
[ext_resource path="res://Themes & Styles/RulerStyle.tres" type="StyleBox" id=12]
|
||||
[ext_resource path="res://Scripts/HorizontalRuler.gd" type="Script" id=13]
|
||||
[ext_resource path="res://Scripts/VerticalRuler.gd" type="Script" id=14]
|
||||
[ext_resource path="res://Prefabs/Canvas.tscn" type="PackedScene" id=15]
|
||||
|
@ -1114,6 +1114,7 @@ script = ExtResource( 18 )
|
|||
offset = Vector2( 32, 32 )
|
||||
current = true
|
||||
zoom = Vector2( 0.15, 0.15 )
|
||||
script = ExtResource( 16 )
|
||||
|
||||
[node name="LayerLabel" type="Label" parent="MenuAndUI/UI/LayerPanel/LayersAndMisc"]
|
||||
margin_top = 167.0
|
||||
|
|
|
@ -16,7 +16,7 @@ func _input(event : InputEvent) -> void:
|
|||
elif event.is_action_released("camera_drag"):
|
||||
drag = false
|
||||
|
||||
if Global.can_draw && Global.has_focus && Rect2(Vector2.ZERO, viewport_size).has_point(mouse_pos):
|
||||
if Global.can_draw && Rect2(Vector2.ZERO, viewport_size).has_point(mouse_pos):
|
||||
if event.is_action_pressed("zoom_in"): # Wheel Up Event
|
||||
zoom_camera(-1)
|
||||
elif event.is_action_pressed("zoom_out"): # Wheel Down Event
|
||||
|
|
|
@ -12,6 +12,7 @@ var frame_texture_rect : TextureRect
|
|||
|
||||
var current_pixel := Vector2.ZERO #pretty much same as mouse_pos, but can be accessed externally
|
||||
var previous_mouse_pos := Vector2.ZERO
|
||||
var cursor_inside_canvas := false
|
||||
var previous_action := "None"
|
||||
var mouse_inside_canvas := false #used for undo
|
||||
var sprite_changed_this_frame := false #for optimization purposes
|
||||
|
@ -105,6 +106,8 @@ func _process(delta : float) -> void:
|
|||
if Global.current_frame == frame:
|
||||
if mouse_in_canvas && Global.has_focus:
|
||||
Global.cursor_position_label.text = "[%s×%s] %s, %s" % [size.x, size.y, mouse_pos_floored.x, mouse_pos_floored.y]
|
||||
if !cursor_inside_canvas:
|
||||
cursor_inside_canvas = true
|
||||
if Global.current_left_tool == "Bucket":
|
||||
Input.set_custom_mouse_cursor(preload("res://Assets/Graphics/Tools/Bucket_Cursor.png"), 0, Vector2(6, 27))
|
||||
elif Global.current_left_tool == "ColorPicker":
|
||||
|
@ -116,8 +119,10 @@ func _process(delta : float) -> void:
|
|||
if mouse_inside_canvas:
|
||||
mouse_inside_canvas = false
|
||||
Global.cursor_position_label.text = "[%s×%s]" % [size.x, size.y]
|
||||
Input.set_custom_mouse_cursor(null)
|
||||
if cursor_inside_canvas:
|
||||
cursor_inside_canvas = false
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
Input.set_custom_mouse_cursor(null)
|
||||
|
||||
|
||||
#Handle Undo/Redo
|
||||
|
|
|
@ -43,8 +43,8 @@ func _ready() -> void:
|
|||
"Save..." : KEY_MASK_CTRL + KEY_S,
|
||||
"Save as..." : KEY_MASK_SHIFT + KEY_MASK_CTRL + KEY_S,
|
||||
"Import..." : KEY_MASK_CTRL + KEY_I,
|
||||
"Export..." : KEY_MASK_CTRL + KEY_E,
|
||||
"Export as..." : KEY_MASK_SHIFT + KEY_MASK_CTRL + KEY_E,
|
||||
"Export PNG..." : KEY_MASK_CTRL + KEY_E,
|
||||
"Export PNG as..." : KEY_MASK_SHIFT + KEY_MASK_CTRL + KEY_E,
|
||||
"Quit" : KEY_MASK_CTRL + KEY_Q
|
||||
}
|
||||
var edit_menu_items := {
|
||||
|
@ -527,8 +527,9 @@ func export_project() -> void:
|
|||
func save_sprite(canvas : Canvas, path : String) -> void:
|
||||
var whole_image := Image.new()
|
||||
whole_image.create(canvas.size.x, canvas.size.y, false, Image.FORMAT_RGBA8)
|
||||
whole_image.lock()
|
||||
for layer in canvas.layers:
|
||||
whole_image.blend_rect(layer[0], Rect2(canvas.position, canvas.size), Vector2.ZERO)
|
||||
canvas.blend_rect(whole_image, layer[0], Rect2(canvas.position, canvas.size), Vector2.ZERO)
|
||||
layer[0].lock()
|
||||
var err = whole_image.save_png(path)
|
||||
if err != OK:
|
||||
|
@ -553,10 +554,11 @@ func save_spritesheet() -> void:
|
|||
height = canvas.size.y
|
||||
var whole_image := Image.new()
|
||||
whole_image.create(width, height, false, Image.FORMAT_RGBA8)
|
||||
whole_image.lock()
|
||||
var dst := Vector2.ZERO
|
||||
for canvas in Global.canvases:
|
||||
for layer in canvas.layers:
|
||||
whole_image.blend_rect(layer[0], Rect2(canvas.position, canvas.size), dst)
|
||||
canvas.blend_rect(whole_image, layer[0], Rect2(canvas.position, canvas.size), dst)
|
||||
layer[0].lock()
|
||||
if export_vertical_spritesheet.pressed:
|
||||
dst += Vector2(0, canvas.size.y)
|
||||
|
@ -744,7 +746,8 @@ func _on_MergeLayer_pressed() -> void:
|
|||
|
||||
var new_layer := Image.new()
|
||||
new_layer.copy_from(Global.canvas.layers[Global.canvas.current_layer_index - 1][0])
|
||||
new_layer.blend_rect(selected_layer, Rect2(Global.canvas.position, Global.canvas.size), Vector2.ZERO)
|
||||
new_layer.lock()
|
||||
Global.canvas.blend_rect(new_layer, selected_layer, Rect2(Global.canvas.position, Global.canvas.size), Vector2.ZERO)
|
||||
|
||||
Global.undos += 1
|
||||
Global.undo_redo.create_action("Merge Layer")
|
||||
|
|
Loading…
Reference in a new issue