1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-02-20 12:33:14 +00:00

Merge remote-tracking branch 'upstream/master'

This commit is contained in:
CheetoHead 2019-12-19 12:10:23 -05:00
commit 73f550f723
15 changed files with 337 additions and 253 deletions

385
Main.tscn

File diff suppressed because one or more lines are too long

View file

@ -1,8 +1,9 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://Themes & Styles/Main Theme.tres" type="Theme" id=1]
[ext_resource path="res://Themes & Styles/Main Theme/Main Theme.tres" type="Theme" id=1]
[ext_resource path="res://Scripts/NotificationLabel.gd" type="Script" id=2]
[node name="NotificationLabel" type="Label"]
margin_right = 116.0
margin_bottom = 14.0

View file

@ -18,80 +18,96 @@ margin_right = 92.0
margin_bottom = 34.0
[node name="OptionsContainer" type="GridContainer" parent="VBoxContainer"]
margin_right = 184.0
margin_bottom = 23.0
margin_right = 218.0
margin_bottom = 44.0
columns = 2
[node name="LanguageLabel" type="Label" parent="VBoxContainer/OptionsContainer"]
margin_top = 4.0
margin_right = 57.0
margin_bottom = 19.0
margin_top = 3.0
margin_right = 63.0
margin_bottom = 17.0
text = "Language:"
[node name="LanguageOption" type="OptionButton" parent="VBoxContainer/OptionsContainer"]
margin_left = 57.0
margin_right = 176.0
margin_bottom = 23.0
margin_left = 67.0
margin_right = 218.0
margin_bottom = 20.0
text = "System Language"
items = [ "System Language", null, false, 0, null, "Deutsch [de]", null, false, 1, null, "Ελληνικά [el]", null, false, 2, null, "English [en]", null, false, 3, null, "Français [fr]", null, false, 4, null, "Polski [pl]", null, false, 5, null, "Русский [ru]", null, false, 6, null, "繁體中文 [zh_TW]", null, false, 7, null ]
selected = 0
[node name="GridOptionsLabel" type="Label" parent="VBoxContainer"]
[node name="ThemeLabel" type="Label" parent="VBoxContainer/OptionsContainer"]
margin_top = 27.0
margin_right = 184.0
margin_bottom = 42.0
margin_right = 63.0
margin_bottom = 41.0
text = "Theme:"
[node name="ThemeOption" type="OptionButton" parent="VBoxContainer/OptionsContainer"]
margin_left = 67.0
margin_top = 24.0
margin_right = 218.0
margin_bottom = 44.0
text = "Dark Theme"
items = [ "Main Theme", null, false, 0, null, "Dark Theme", null, false, 1, null ]
selected = 1
[node name="GridOptionsLabel" type="Label" parent="VBoxContainer"]
margin_top = 48.0
margin_right = 218.0
margin_bottom = 62.0
text = "Grid options"
[node name="GridOptions" type="GridContainer" parent="VBoxContainer"]
margin_top = 46.0
margin_right = 184.0
margin_bottom = 103.0
margin_top = 66.0
margin_right = 218.0
margin_bottom = 142.0
columns = 2
[node name="WidthLabel" type="Label" parent="VBoxContainer/GridOptions"]
margin_top = 1.0
margin_right = 39.0
margin_bottom = 16.0
margin_top = 5.0
margin_right = 46.0
margin_bottom = 19.0
text = "Width:"
[node name="GridWidthValue" type="SpinBox" parent="VBoxContainer/GridOptions"]
margin_left = 39.0
margin_right = 103.0
margin_bottom = 17.0
margin_left = 50.0
margin_right = 124.0
margin_bottom = 24.0
min_value = 1.0
max_value = 16384.0
value = 1.0
suffix = "px"
[node name="Height" type="Label" parent="VBoxContainer/GridOptions"]
margin_top = 19.0
margin_right = 39.0
margin_bottom = 33.0
margin_top = 33.0
margin_right = 46.0
margin_bottom = 47.0
text = "Height:"
[node name="GridHeightValue" type="SpinBox" parent="VBoxContainer/GridOptions"]
margin_left = 39.0
margin_top = 19.0
margin_right = 103.0
margin_bottom = 34.0
margin_left = 50.0
margin_top = 28.0
margin_right = 124.0
margin_bottom = 52.0
min_value = 1.0
max_value = 16384.0
value = 1.0
suffix = "px"
[node name="GridColorLabel" type="Label" parent="VBoxContainer/GridOptions"]
margin_top = 42.0
margin_right = 39.0
margin_bottom = 53.0
margin_top = 59.0
margin_right = 46.0
margin_bottom = 73.0
text = "Color:"
[node name="GridColor" type="ColorPickerButton" parent="VBoxContainer/GridOptions"]
margin_left = 39.0
margin_top = 38.0
margin_right = 103.0
margin_bottom = 57.0
margin_left = 50.0
margin_top = 56.0
margin_right = 124.0
margin_bottom = 76.0
rect_min_size = Vector2( 64, 20 )
[connection signal="item_selected" from="VBoxContainer/OptionsContainer/LanguageOption" to="." method="_on_LanguageOption_item_selected"]
[connection signal="item_selected" from="VBoxContainer/OptionsContainer/ThemeOption" to="." method="_on_ThemeOption_item_selected"]
[connection signal="value_changed" from="VBoxContainer/GridOptions/GridWidthValue" to="." method="_on_GridWidthValue_value_changed"]
[connection signal="value_changed" from="VBoxContainer/GridOptions/GridHeightValue" to="." method="_on_GridHeightValue_value_changed"]
[connection signal="color_changed" from="VBoxContainer/GridOptions/GridColor" to="." method="_on_GridColor_color_changed"]

View file

@ -20,6 +20,7 @@ var sprite_changed_this_frame := false #for optimization purposes
var lighten_darken_pixels := [] #Cleared after mouse release
var is_making_line := false
var made_line := false
var is_making_selection := "None"
var line_2d : Line2D
@ -130,7 +131,7 @@ func _process(delta : float) -> void:
Input.set_custom_mouse_cursor(null)
#Handle Undo/Redo
var can_handle : bool = mouse_in_canvas && Global.can_draw && Global.has_focus
var can_handle : bool = mouse_in_canvas && Global.can_draw && Global.has_focus && !made_line
var mouse_pressed : bool = (Input.is_action_just_pressed("left_mouse") && !Input.is_action_pressed("right_mouse")) || (Input.is_action_just_pressed("right_mouse") && !Input.is_action_pressed("left_mouse"))
#If we're already pressing a mouse button and we haven't handled undo yet,...
@ -148,6 +149,7 @@ func _process(delta : float) -> void:
else:
handle_undo("Draw")
elif (Input.is_action_just_released("left_mouse") && !Input.is_action_pressed("right_mouse")) || (Input.is_action_just_released("right_mouse") && !Input.is_action_pressed("left_mouse")):
made_line = false
lighten_darken_pixels.clear()
if (can_handle || Global.undos == Global.undo_redo.get_version()) && Global.current_frame == frame:
if previous_action != "None" && previous_action != "RectSelect" && current_action != "ColorPicker":
@ -248,7 +250,7 @@ func _process(delta : float) -> void:
Global.right_color_picker.color = pixel_color
Global.update_right_custom_brush()
if Input.is_action_just_pressed("shift") and (["Pencil", "Eraser"].has(Global.current_left_tool) or ["Pencil", "Eraser"].has(Global.current_right_tool)):
if Global.can_draw && Global.has_focus && Input.is_action_just_pressed("shift") && (["Pencil", "Eraser", "LightenDarken"].has(Global.current_left_tool) || ["Pencil", "Eraser", "LightenDarken"].has(Global.current_right_tool)):
line_2d = Line2D.new()
line_2d.width = 0.5
line_2d.default_color = Color.darkgray
@ -260,9 +262,20 @@ func _process(delta : float) -> void:
is_making_line = false
if is_instance_valid(line_2d):
line_2d.queue_free()
if is_making_line:
line_2d.set_point_position(1, mouse_pos)
if is_making_line:
var point0 : Vector2 = line_2d.points[0]
var angle := stepify(rad2deg(mouse_pos.angle_to_point(point0)), 0.01)
if Input.is_action_pressed("ctrl"):
angle = round(angle / 15) * 15
var distance : float = point0.distance_to(mouse_pos)
line_2d.set_point_position(1, point0 + Vector2.RIGHT.rotated(deg2rad(angle)) * distance)
else:
line_2d.set_point_position(1, mouse_pos)
if angle < 0:
angle = 360 + angle
Global.cursor_position_label.text += " %s°" % str(angle)
if is_making_selection != "None": #If we're making a selection
if Input.is_action_just_released(is_making_selection): #Finish selection when button is released
@ -471,8 +484,12 @@ func generate_layer_panels() -> void:
Global.vbox_layer_container.add_child(layer_container)
func pencil_and_eraser(mouse_pos : Vector2, color : Color, current_mouse_button : String, current_action := "None") -> void:
if made_line:
return
if is_making_line:
fill_gaps(mouse_pos, previous_mouse_pos_for_lines, color, current_mouse_button, current_action)
fill_gaps(line_2d.points[1], previous_mouse_pos_for_lines, color, current_mouse_button, current_action)
draw_pixel(line_2d.points[1], color, current_mouse_button, current_action)
made_line = true
else:
if point_in_rectangle(mouse_pos, location, location + size):
mouse_inside_canvas = true
@ -537,13 +554,13 @@ func draw_pixel(pos : Vector2, color : Color, current_mouse_button : String, cur
if point_in_rectangle(Vector2(cur_pos_x, cur_pos_y), Vector2(west_limit - 1, north_limit - 1), Vector2(east_limit, south_limit)):
var pos_floored := Vector2(cur_pos_x, cur_pos_y).floor()
#Don't draw the same pixel over and over and don't re-lighten/darken it
var current_pixel : Color = layers[current_layer_index][0].get_pixel(cur_pos_x, cur_pos_y)
if current_pixel != color && !(pos_floored in lighten_darken_pixels):
var current_pixel_color : Color = layers[current_layer_index][0].get_pixel(cur_pos_x, cur_pos_y)
if current_pixel_color != color && !(pos_floored in lighten_darken_pixels):
if current_action == "LightenDarken":
if ld == 0: #Lighten
color = current_pixel.lightened(ld_amount)
color = current_pixel_color.lightened(ld_amount)
else:
color = current_pixel.darkened(ld_amount)
color = current_pixel_color.darkened(ld_amount)
lighten_darken_pixels.append(pos_floored)
layers[current_layer_index][0].set_pixel(cur_pos_x, cur_pos_y, color)
@ -553,37 +570,37 @@ func draw_pixel(pos : Vector2, color : Color, current_mouse_button : String, cur
var mirror_x := east_limit + west_limit - cur_pos_x - 1
var mirror_y := south_limit + north_limit - cur_pos_y - 1
if horizontal_mirror:
current_pixel = layers[current_layer_index][0].get_pixel(mirror_x, cur_pos_y)
if current_pixel != color: #don't draw the same pixel over and over
current_pixel_color = layers[current_layer_index][0].get_pixel(mirror_x, cur_pos_y)
if current_pixel_color != color: #don't draw the same pixel over and over
if current_action == "LightenDarken":
if ld == 0: #Lighten
color = current_pixel.lightened(ld_amount)
color = current_pixel_color.lightened(ld_amount)
else:
color = current_pixel.darkened(ld_amount)
color = current_pixel_color.darkened(ld_amount)
lighten_darken_pixels.append(pos_floored)
layers[current_layer_index][0].set_pixel(mirror_x, cur_pos_y, color)
sprite_changed_this_frame = true
if vertical_mirror:
current_pixel = layers[current_layer_index][0].get_pixel(cur_pos_x, mirror_y)
if current_pixel != color: #don't draw the same pixel over and over
current_pixel_color = layers[current_layer_index][0].get_pixel(cur_pos_x, mirror_y)
if current_pixel_color != color: #don't draw the same pixel over and over
if current_action == "LightenDarken":
if ld == 0: #Lighten
color = current_pixel.lightened(ld_amount)
color = current_pixel_color.lightened(ld_amount)
else:
color = current_pixel.darkened(ld_amount)
color = current_pixel_color.darkened(ld_amount)
lighten_darken_pixels.append(pos_floored)
layers[current_layer_index][0].set_pixel(cur_pos_x, mirror_y, color)
sprite_changed_this_frame = true
if horizontal_mirror && vertical_mirror:
current_pixel = layers[current_layer_index][0].get_pixel(mirror_x, mirror_y)
if current_pixel != color: #don't draw the same pixel over and over
current_pixel_color = layers[current_layer_index][0].get_pixel(mirror_x, mirror_y)
if current_pixel_color != color: #don't draw the same pixel over and over
if current_action == "LightenDarken":
if ld == 0: #Lighten
color = current_pixel.lightened(ld_amount)
color = current_pixel_color.lightened(ld_amount)
else:
color = current_pixel.darkened(ld_amount)
color = current_pixel_color.darkened(ld_amount)
lighten_darken_pixels.append(pos_floored)
layers[current_layer_index][0].set_pixel(mirror_x, mirror_y, color)
@ -654,7 +671,7 @@ func draw_pixel(pos : Vector2, color : Color, current_mouse_button : String, cur
layers[current_layer_index][0].lock()
sprite_changed_this_frame = true
previous_mouse_pos_for_lines = current_pixel
previous_mouse_pos_for_lines = pos.floor() + Vector2(0.5, 0.5)
previous_mouse_pos_for_lines.x = clamp(previous_mouse_pos_for_lines.x, location.x, location.x + size.x)
previous_mouse_pos_for_lines.y = clamp(previous_mouse_pos_for_lines.y, location.y, location.y + size.y)
if is_making_line:

View file

@ -114,6 +114,7 @@ var palettes := {}
#Nodes
var control : Node
var top_menu_container : Panel
var left_cursor : Sprite
var right_cursor : Sprite
var canvas : Canvas
@ -203,6 +204,7 @@ func _ready() -> void:
var root = get_tree().get_root()
control = find_node_by_name(root, "Control")
top_menu_container = find_node_by_name(control, "TopMenuContainer")
left_cursor = find_node_by_name(root, "LeftCursor")
right_cursor = find_node_by_name(root, "RightCursor")
canvas = find_node_by_name(root, "Canvas")

View file

@ -60,7 +60,7 @@ func _ready() -> void:
}
var edit_menu_items := {
"Undo" : KEY_MASK_CMD + KEY_Z,
"Redo" : KEY_MASK_SHIFT + KEY_MASK_CMD + KEY_Z,
"Redo" : KEY_MASK_CMD + KEY_Y,
"Scale Image" : 0,
"Crop Image" : 0,
"Clear Selection" : 0,
@ -72,7 +72,7 @@ func _ready() -> void:
"Tile Mode" : KEY_MASK_CMD + KEY_T,
"Show Grid" : KEY_MASK_CMD + KEY_G,
"Show Rulers" : KEY_MASK_CMD + KEY_R,
"Show Guides" : KEY_MASK_CMD + KEY_Y
"Show Guides" : KEY_MASK_CMD + KEY_F
}
var help_menu_items := {
"About Pixelorama" : 0
@ -187,6 +187,11 @@ func _input(event : InputEvent) -> void:
if event.is_action_pressed("toggle_fullscreen"):
OS.window_fullscreen = !OS.window_fullscreen
if event.is_action_pressed("redo_secondary"): #Shift + Ctrl + Z
redone = true
Global.undo_redo.redo()
redone = false
if Global.has_focus:
for t in tools: #Handle tool shortcuts
if event.is_action_pressed(t[2]): #Shortcut for right button (with Alt)

View file

@ -13,6 +13,30 @@ func _on_LanguageOption_item_selected(ID : int) -> void:
Global.config_cache.set_value("preferences", "locale", TranslationServer.get_locale())
Global.config_cache.save("user://cache.ini")
func _on_ThemeOption_item_selected(ID : int) -> void:
var main_theme
var top_menu_style
var ruler_style
if ID == 0: #Main Theme
main_theme = preload("res://Themes & Styles/Main Theme/Main Theme.tres")
top_menu_style = preload("res://Themes & Styles/Main Theme/TopMenuStyle.tres")
ruler_style = preload("res://Themes & Styles/Main Theme/RulerStyle.tres")
elif ID == 1: #Dark Theme
main_theme = preload("res://Themes & Styles/Dark Theme/Dark Theme.tres")
top_menu_style = preload("res://Themes & Styles/Dark Theme/DarkTopMenuStyle.tres")
ruler_style = preload("res://Themes & Styles/Dark Theme/DarkRulerStyle.tres")
Global.control.theme = main_theme
Global.top_menu_container.add_stylebox_override("panel", top_menu_style)
Global.horizontal_ruler.add_stylebox_override("normal", ruler_style)
Global.horizontal_ruler.add_stylebox_override("pressed", ruler_style)
Global.horizontal_ruler.add_stylebox_override("hover", ruler_style)
Global.horizontal_ruler.add_stylebox_override("focus", ruler_style)
Global.vertical_ruler.add_stylebox_override("normal", ruler_style)
Global.vertical_ruler.add_stylebox_override("pressed", ruler_style)
Global.vertical_ruler.add_stylebox_override("hover", ruler_style)
Global.vertical_ruler.add_stylebox_override("focus", ruler_style)
func _on_GridWidthValue_value_changed(value : float) -> void:
Global.grid_width = value
@ -20,4 +44,4 @@ func _on_GridHeightValue_value_changed(value : float) -> void:
Global.grid_height = value
func _on_GridColor_color_changed(color : Color) -> void:
Global.grid_color = color
Global.grid_color = color

View file

@ -21,7 +21,7 @@ func _draw() -> void:
var minor_subdivide := Transform2D()
var fps = Global.control.fps
var horizontal_scroll = get_parent().get_node("FrameAndButtonContainer").get_node("ScrollContainer").scroll_horizontal
var starting_pos := Vector2(26, 26)
var starting_pos := Vector2(10, 10)
transform.x = Vector2(fps, fps) / 2.52
transform.origin = starting_pos - Vector2(horizontal_scroll, horizontal_scroll)

View file

@ -0,0 +1,4 @@
[gd_resource type="StyleBoxFlat" format=2]
[resource]
bg_color = Color( 0.0823529, 0.0823529, 0.0823529, 1 )

View file

@ -0,0 +1,4 @@
[gd_resource type="StyleBoxFlat" format=2]
[resource]
bg_color = Color( 0.223529, 0.223529, 0.243137, 1 )

View file

@ -185,6 +185,16 @@ shift={
"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":16777237,"unicode":0,"echo":false,"script":null)
]
}
ctrl={
"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":16777238,"unicode":0,"echo":false,"script":null)
]
}
redo_secondary={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":true,"control":true,"meta":false,"command":true,"pressed":false,"scancode":90,"unicode":0,"echo":false,"script":null)
]
}
[locale]