mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-02-21 13:03:13 +00:00
Merge branch 'master' into master
This commit is contained in:
commit
c32ad873a6
17 changed files with 1074 additions and 522 deletions
|
@ -18,5 +18,6 @@
|
|||
{ "data" : "#FF007899", "name" : "no name" },
|
||||
{ "data" : "#FF002859", "name" : "no name" },
|
||||
],
|
||||
"comments": "by PineTreePizza - https://twitter.com/PineTreePizza"
|
||||
"comments": "by PineTreePizza - https://twitter.com/PineTreePizza",
|
||||
"editable": false
|
||||
}
|
|
@ -33,5 +33,7 @@
|
|||
{ "data" : "#FFd77bba", "name" : "no name" },
|
||||
{ "data" : "#FF8f974a", "name" : "no name" },
|
||||
{ "data" : "#FF8a6f30", "name" : "no name" }
|
||||
]
|
||||
],
|
||||
"comments": "Aseprite default palette",
|
||||
"editable": false
|
||||
}
|
BIN
Assets/Graphics/Palette/swatch_drag_preview.png
Normal file
BIN
Assets/Graphics/Palette/swatch_drag_preview.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 111 B |
34
Assets/Graphics/Palette/swatch_drag_preview.png.import
Normal file
34
Assets/Graphics/Palette/swatch_drag_preview.png.import
Normal file
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/swatch_drag_preview.png-4e3b034338643b2d9a5d7daa883dd850.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Assets/Graphics/Palette/swatch_drag_preview.png"
|
||||
dest_files=[ "res://.import/swatch_drag_preview.png-4e3b034338643b2d9a5d7daa883dd850.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=false
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=false
|
||||
svg/scale=1.0
|
608
Main.tscn
608
Main.tscn
File diff suppressed because one or more lines are too long
|
@ -1,27 +1,7 @@
|
|||
[gd_scene load_steps=5 format=2]
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://Scripts/FrameButton.gd" type="Script" id=1]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=1]
|
||||
bg_color = Color( 0.337255, 0.32549, 0.388235, 1 )
|
||||
corner_radius_top_left = 2
|
||||
corner_radius_top_right = 2
|
||||
corner_radius_bottom_right = 2
|
||||
corner_radius_bottom_left = 2
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=2]
|
||||
bg_color = Color( 0.211765, 0.2, 0.247059, 1 )
|
||||
corner_radius_top_left = 2
|
||||
corner_radius_top_right = 2
|
||||
corner_radius_bottom_right = 2
|
||||
corner_radius_bottom_left = 2
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=3]
|
||||
bg_color = Color( 0.270588, 0.258824, 0.305882, 1 )
|
||||
corner_radius_top_left = 2
|
||||
corner_radius_top_right = 2
|
||||
corner_radius_bottom_right = 2
|
||||
corner_radius_bottom_left = 2
|
||||
[ext_resource path="res://Themes & Styles/Main Theme.tres" type="Theme" id=1]
|
||||
[ext_resource path="res://Scripts/FrameButton.gd" type="Script" id=2]
|
||||
|
||||
[node name="Frame" type="VBoxContainer"]
|
||||
margin_right = 32.0
|
||||
|
@ -34,12 +14,10 @@ rect_min_size = Vector2( 36, 36 )
|
|||
mouse_default_cursor_shape = 2
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 0
|
||||
custom_styles/hover = SubResource( 1 )
|
||||
custom_styles/pressed = SubResource( 2 )
|
||||
custom_styles/normal = SubResource( 3 )
|
||||
theme = ExtResource( 1 )
|
||||
toggle_mode = true
|
||||
button_mask = 3
|
||||
script = ExtResource( 1 )
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="FrameTexture" type="TextureRect" parent="FrameButton"]
|
||||
margin_left = 2.0
|
||||
|
|
|
@ -1,26 +1,16 @@
|
|||
[gd_scene load_steps=6 format=2]
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://Scripts/LayerContainer.gd" type="Script" id=1]
|
||||
[ext_resource path="res://Assets/Graphics/Layers/layer_visible.png" type="Texture" id=2]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=1]
|
||||
bg_color = Color( 0.337255, 0.32549, 0.388235, 1 )
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=2]
|
||||
bg_color = Color( 0.211765, 0.2, 0.247059, 1 )
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=3]
|
||||
bg_color = Color( 0.270588, 0.258824, 0.305882, 1 )
|
||||
[ext_resource path="res://Themes & Styles/Main Theme.tres" type="Theme" id=1]
|
||||
[ext_resource path="res://Scripts/LayerContainer.gd" type="Script" id=2]
|
||||
[ext_resource path="res://Assets/Graphics/Layers/layer_visible.png" type="Texture" id=3]
|
||||
|
||||
[node name="LayerContainer" type="Button"]
|
||||
margin_right = 160.0
|
||||
margin_bottom = 42.0
|
||||
rect_min_size = Vector2( 160, 42 )
|
||||
custom_styles/hover = SubResource( 1 )
|
||||
custom_styles/pressed = SubResource( 2 )
|
||||
custom_styles/normal = SubResource( 3 )
|
||||
theme = ExtResource( 1 )
|
||||
toggle_mode = true
|
||||
script = ExtResource( 1 )
|
||||
script = ExtResource( 2 )
|
||||
__meta__ = {
|
||||
"_edit_horizontal_guides_": [ ]
|
||||
}
|
||||
|
@ -34,7 +24,7 @@ hint_tooltip = "LAYERVISIBILITY_HT"
|
|||
mouse_default_cursor_shape = 2
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 4
|
||||
texture_normal = ExtResource( 2 )
|
||||
texture_normal = ExtResource( 3 )
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
||||
anchor_left = 0.5
|
||||
|
@ -57,8 +47,8 @@ stretch_mode = 6
|
|||
|
||||
[node name="Label" type="Label" parent="HBoxContainer"]
|
||||
margin_left = 36.0
|
||||
margin_top = 9.0
|
||||
margin_right = 82.0
|
||||
margin_top = 8.0
|
||||
margin_right = 75.0
|
||||
margin_bottom = 23.0
|
||||
text = "Layer 0"
|
||||
align = 1
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
[gd_scene load_steps=6 format=2]
|
||||
[gd_scene load_steps=8 format=2]
|
||||
|
||||
[ext_resource path="res://Themes & Styles/StyleBoxes/palette_stylebox_hover.tres" type="StyleBox" id=1]
|
||||
[ext_resource path="res://Themes & Styles/StyleBoxes/palette_stylebox_pressedr.tres" type="StyleBox" id=2]
|
||||
[ext_resource path="res://Themes & Styles/StyleBoxes/palette_stylebox_normal.tres" type="StyleBox" id=3]
|
||||
[ext_resource path="res://Assets/Graphics/Palette/palette_button_fill.png" type="Texture" id=4]
|
||||
[ext_resource path="res://Themes & Styles/StyleBoxes/palette_stylebox_focus.tres" type="StyleBox" id=3]
|
||||
[ext_resource path="res://Themes & Styles/StyleBoxes/palette_stylebox_normal.tres" type="StyleBox" id=4]
|
||||
[ext_resource path="res://Scripts/PaletteButton.gd" type="Script" id=5]
|
||||
[ext_resource path="res://Assets/Graphics/Palette/palette_button_fill.png" type="Texture" id=6]
|
||||
|
||||
[sub_resource type="ImageTexture" id=1]
|
||||
|
||||
|
@ -14,9 +16,11 @@ rect_min_size = Vector2( 26, 26 )
|
|||
hint_tooltip = "Color Name"
|
||||
custom_styles/hover = ExtResource( 1 )
|
||||
custom_styles/pressed = ExtResource( 2 )
|
||||
custom_styles/normal = ExtResource( 3 )
|
||||
custom_styles/focus = ExtResource( 3 )
|
||||
custom_styles/normal = ExtResource( 4 )
|
||||
button_mask = 3
|
||||
icon = SubResource( 1 )
|
||||
script = ExtResource( 5 )
|
||||
|
||||
[node name="NinePatchRect" type="NinePatchRect" parent="."]
|
||||
anchor_right = 1.0
|
||||
|
@ -27,7 +31,7 @@ margin_right = -1.0
|
|||
margin_bottom = -1.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
texture = ExtResource( 4 )
|
||||
texture = ExtResource( 6 )
|
||||
patch_margin_left = 2
|
||||
patch_margin_top = 2
|
||||
patch_margin_right = 2
|
||||
|
|
120
Scripts/EditPalettePopup.gd
Normal file
120
Scripts/EditPalettePopup.gd
Normal file
|
@ -0,0 +1,120 @@
|
|||
extends WindowDialog
|
||||
|
||||
onready var palette_grid = $VBoxContainer/HBoxContainer/Panel/EditPaletteGridContainer
|
||||
onready var color_name_edit = $VBoxContainer/HBoxContainer3/EditPaletteColorNameLineEdit
|
||||
onready var color_picker = $VBoxContainer/HBoxContainer/EditPaletteColorPicker
|
||||
|
||||
var palette_button = preload("res://Prefabs/PaletteButton.tscn");
|
||||
|
||||
var current_palette : String
|
||||
var current_swatch := -1
|
||||
var working_palette : Dictionary
|
||||
|
||||
|
||||
func open(palette : String) -> void:
|
||||
current_palette = palette
|
||||
if Global.palettes.has(palette):
|
||||
working_palette = Global.palettes[palette].duplicate()
|
||||
|
||||
_display_palette()
|
||||
|
||||
self.popup_centered()
|
||||
pass
|
||||
|
||||
func _display_palette() -> void:
|
||||
_clear_swatches()
|
||||
var index := 0
|
||||
|
||||
for color_data in working_palette.colors:
|
||||
var color = Color(color_data.data)
|
||||
var new_button = palette_button.instance()
|
||||
|
||||
new_button.color = color
|
||||
new_button.get_child(0).modulate = color
|
||||
new_button.hint_tooltip = color_data.data.to_upper() + " " + color_data.name
|
||||
new_button.draggable = true
|
||||
new_button.index = index
|
||||
new_button.connect("on_drop_data", self, "on_move_swatch")
|
||||
new_button.connect("pressed", self, "on_swatch_select", [index])
|
||||
|
||||
palette_grid.add_child(new_button)
|
||||
index += 1
|
||||
|
||||
func _clear_swatches() -> void:
|
||||
for child in palette_grid.get_children():
|
||||
if child is BaseButton:
|
||||
child.disconnect("on_drop_data", self, "on_move_swatch")
|
||||
child.queue_free()
|
||||
|
||||
func on_swatch_select(index : int) -> void:
|
||||
current_swatch = index
|
||||
color_name_edit.text = working_palette.colors[index].name
|
||||
color_picker.color = working_palette.colors[index].data
|
||||
pass
|
||||
|
||||
func on_move_swatch(from : int, to : int) -> void:
|
||||
var color_to_move = working_palette.colors[from]
|
||||
working_palette.colors.remove(from)
|
||||
working_palette.colors.insert(to, color_to_move)
|
||||
|
||||
palette_grid.move_child(palette_grid.get_child(from), to)
|
||||
|
||||
# Re-index swatches with new order
|
||||
var index := 0
|
||||
for child in palette_grid.get_children():
|
||||
child.index = index
|
||||
index += 1
|
||||
pass
|
||||
|
||||
func _on_AddSwatchButton_pressed() -> void:
|
||||
var color = Color.white
|
||||
var color_data = {}
|
||||
color_data.data = color.to_html(true)
|
||||
color_data.name = "no name"
|
||||
working_palette.colors.push_back(color_data)
|
||||
var new_button = palette_button.instance()
|
||||
|
||||
new_button.color = color
|
||||
new_button.get_child(0).modulate = color
|
||||
new_button.hint_tooltip = color_data.data.to_upper() + " " + color_data.name
|
||||
new_button.draggable = true
|
||||
var index : int = palette_grid.get_child_count()
|
||||
new_button.index = index
|
||||
new_button.connect("on_drop_data", self, "on_move_swatch")
|
||||
new_button.connect("pressed", self, "on_swatch_select", [index])
|
||||
|
||||
palette_grid.add_child(new_button)
|
||||
pass # Replace with function body.
|
||||
|
||||
func _on_RemoveSwatchButton_pressed() -> void:
|
||||
working_palette.colors.remove(current_swatch)
|
||||
palette_grid.remove_child(palette_grid.get_child(current_swatch))
|
||||
pass # Replace with function body.
|
||||
|
||||
func _on_EditPaletteSaveButton_pressed() -> void:
|
||||
Global.palettes[current_palette] = working_palette
|
||||
Global.palette_container.on_palette_select(current_palette)
|
||||
Global.palette_container.save_palette(current_palette, working_palette.name + ".json")
|
||||
self.hide()
|
||||
pass # Replace with function body.
|
||||
|
||||
func _on_EditPaletteCancelButton_pressed() -> void:
|
||||
self.hide()
|
||||
pass # Replace with function body.
|
||||
|
||||
func _on_EditPaletteColorNameLineEdit_text_changed(new_text) -> void:
|
||||
if current_swatch > 0 && current_swatch < working_palette.colors.size():
|
||||
working_palette.colors[current_swatch].name = new_text
|
||||
_refresh_hint_tooltip(current_swatch)
|
||||
pass
|
||||
|
||||
func _on_EditPaletteColorPicker_color_changed(color) -> void:
|
||||
if current_swatch > 0 && current_swatch < working_palette.colors.size():
|
||||
palette_grid.get_child(current_swatch).get_child(0).modulate = color
|
||||
working_palette.colors[current_swatch].data = color.to_html(true)
|
||||
_refresh_hint_tooltip(current_swatch)
|
||||
pass
|
||||
|
||||
func _refresh_hint_tooltip(index : int):
|
||||
palette_grid.get_child(current_swatch).hint_tooltip = working_palette.colors[current_swatch].data.to_upper() + " " + working_palette.colors[current_swatch].name
|
||||
pass
|
|
@ -187,6 +187,11 @@ var remove_palette_button : TextureButton
|
|||
var palette_option_button : OptionButton
|
||||
var edit_palette_button : BaseButton
|
||||
var palette_container : GridContainer
|
||||
var edit_palette_popup : WindowDialog
|
||||
var new_palette_dialog : ConfirmationDialog
|
||||
var new_palette_name_line_edit : LineEdit
|
||||
|
||||
var error_dialog : AcceptDialog
|
||||
|
||||
func _ready() -> void:
|
||||
undo_redo = UndoRedo.new()
|
||||
|
@ -275,6 +280,11 @@ func _ready() -> void:
|
|||
palette_option_button = find_node_by_name(root, "PaletteOptionButton")
|
||||
edit_palette_button = find_node_by_name(root, "EditPalette")
|
||||
palette_container = find_node_by_name(root, "PaletteContainer")
|
||||
edit_palette_popup = find_node_by_name(root, "EditPalettePopup")
|
||||
new_palette_dialog = find_node_by_name(root, "NewPaletteDialog")
|
||||
new_palette_name_line_edit = find_node_by_name(new_palette_dialog, "NewPaletteNameLineEdit")
|
||||
|
||||
error_dialog = find_node_by_name(root, "ErrorDialog")
|
||||
|
||||
#Thanks to https://godotengine.org/qa/17524/how-to-find-an-instanced-scene-by-its-name
|
||||
func find_node_by_name(root, node_name) -> Node:
|
||||
|
@ -439,7 +449,7 @@ func update_left_custom_brush() -> void:
|
|||
custom_brush.copy_from(custom_brushes[custom_left_brush_index])
|
||||
var custom_brush_size = custom_brush.get_size()
|
||||
custom_brush.resize(custom_brush_size.x * left_brush_size, custom_brush_size.y * left_brush_size, Image.INTERPOLATE_NEAREST)
|
||||
custom_left_brush_image = blend_image_with_color(custom_brush, left_color_picker.color, left_interpolate_slider.value)
|
||||
custom_left_brush_image = blend_image_with_color(custom_brush, left_color_picker.color, left_interpolate_slider.value / 100)
|
||||
custom_left_brush_texture.create_from_image(custom_left_brush_image, 0)
|
||||
|
||||
left_brush_type_button.get_child(0).texture = custom_left_brush_texture
|
||||
|
@ -455,7 +465,7 @@ func update_right_custom_brush() -> void:
|
|||
custom_brush.copy_from(custom_brushes[custom_right_brush_index])
|
||||
var custom_brush_size = custom_brush.get_size()
|
||||
custom_brush.resize(custom_brush_size.x * right_brush_size, custom_brush_size.y * right_brush_size, Image.INTERPOLATE_NEAREST)
|
||||
custom_right_brush_image = blend_image_with_color(custom_brush, right_color_picker.color, right_interpolate_slider.value)
|
||||
custom_right_brush_image = blend_image_with_color(custom_brush, right_color_picker.color, right_interpolate_slider.value / 100)
|
||||
custom_right_brush_texture.create_from_image(custom_right_brush_image, 0)
|
||||
|
||||
right_brush_type_button.get_child(0).texture = custom_right_brush_texture
|
||||
|
|
|
@ -14,9 +14,9 @@ func _process(delta : float) -> void:
|
|||
update()
|
||||
var mouse_pos := get_local_mouse_position()
|
||||
if mouse_pos.x < RULER_WIDTH: #For double guides
|
||||
mouse_default_cursor_shape = Control.CURSOR_BDIAGSIZE
|
||||
mouse_default_cursor_shape = Control.CURSOR_FDIAGSIZE
|
||||
else:
|
||||
mouse_default_cursor_shape = Control.CURSOR_HSPLIT
|
||||
mouse_default_cursor_shape = Control.CURSOR_VSPLIT
|
||||
|
||||
#Code taken and modified from Godot's source code
|
||||
func _draw() -> void:
|
||||
|
|
|
@ -1012,12 +1012,12 @@ func _on_RightFillAreaOptions_item_selected(ID : int) -> void:
|
|||
func _on_LeftLightenDarken_item_selected(ID : int) -> void:
|
||||
Global.left_ld = ID
|
||||
func _on_LeftLDAmountSpinbox_value_changed(value : float) -> void:
|
||||
Global.left_ld_amount = value
|
||||
Global.left_ld_amount = value / 100
|
||||
|
||||
func _on_RightLightenDarken_item_selected(ID : int) -> void:
|
||||
Global.right_ld = ID
|
||||
func _on_RightLDAmountSpinbox_value_changed(value : float) -> void:
|
||||
Global.right_ld_amount = value
|
||||
Global.right_ld_amount = value / 100
|
||||
|
||||
func _on_LeftHorizontalMirroring_toggled(button_pressed) -> void:
|
||||
Global.left_horizontal_mirror = button_pressed
|
||||
|
@ -1047,3 +1047,16 @@ func _exit_tree() -> void:
|
|||
func _on_PaletteOptionButton_item_selected(ID) -> void:
|
||||
var palette_name = Global.palette_option_button.get_item_metadata(ID)
|
||||
Global.palette_container.on_palette_select(palette_name)
|
||||
|
||||
func _on_EditPalette_pressed() -> void:
|
||||
Global.palette_container.on_edit_palette()
|
||||
pass
|
||||
|
||||
func _on_RemovePalette_pressed() -> void:
|
||||
Global.palette_container.remove_current_palette()
|
||||
pass
|
||||
|
||||
func _on_NewPaletteDialog_confirmed() -> void:
|
||||
Global.palette_container.on_new_palette_confirmed()
|
||||
pass
|
||||
|
||||
|
|
26
Scripts/PaletteButton.gd
Normal file
26
Scripts/PaletteButton.gd
Normal file
|
@ -0,0 +1,26 @@
|
|||
extends Button
|
||||
signal on_drop_data
|
||||
|
||||
export var index := 0;
|
||||
export var color : Color = Color.white
|
||||
export var draggable := false
|
||||
|
||||
var drag_preview_texture = preload("res://Assets/Graphics/Palette/swatch_drag_preview.png")
|
||||
|
||||
func get_drag_data(position):
|
||||
var data = null;
|
||||
if(draggable):
|
||||
#print(String(get_instance_id()) + ": Drag Start");
|
||||
data = {source_index = index};
|
||||
var drag_icon = TextureRect.new();
|
||||
drag_icon.texture = drag_preview_texture;
|
||||
drag_icon.modulate = color
|
||||
set_drag_preview(drag_icon);
|
||||
return data;
|
||||
|
||||
func can_drop_data(position, data):
|
||||
return true;
|
||||
|
||||
func drop_data(position, data):
|
||||
emit_signal("on_drop_data", data.source_index, index);
|
||||
pass;
|
|
@ -3,46 +3,13 @@ extends GridContainer
|
|||
var palette_button = preload("res://Prefabs/PaletteButton.tscn");
|
||||
|
||||
var current_palette = "Default"
|
||||
|
||||
var default_palette = [
|
||||
Color("#FF000000"),
|
||||
Color("#FF222034"),
|
||||
Color("#FF45283c"),
|
||||
Color("#FF663931"),
|
||||
Color("#FF8f563b"),
|
||||
Color("#FFdf7126"),
|
||||
Color("#FFd9a066"),
|
||||
Color("#FFeec39a"),
|
||||
Color("#FFfbf236"),
|
||||
Color("#FF99e550"),
|
||||
Color("#FF6abe30"),
|
||||
Color("#FF37946e"),
|
||||
Color("#FF4b692f"),
|
||||
Color("#FF524b24"),
|
||||
Color("#FF323c39"),
|
||||
Color("#FF3f3f74"),
|
||||
Color("#FF306082"),
|
||||
Color("#FF5b6ee1"),
|
||||
Color("#FF639bff"),
|
||||
Color("#FF5fcde4"),
|
||||
Color("#FFcbdbfc"),
|
||||
Color("#FFffffff"),
|
||||
Color("#FF9badb7"),
|
||||
Color("#FF847e87"),
|
||||
Color("#FF696a6a"),
|
||||
Color("#FF595652"),
|
||||
Color("#FF76428a"),
|
||||
Color("#FFac3232"),
|
||||
Color("#FFd95763"),
|
||||
Color("#FFd77bba"),
|
||||
Color("#FF8f974a"),
|
||||
Color("#FF8a6f30")
|
||||
]
|
||||
var from_palette : = {}
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
_load_palettes()
|
||||
|
||||
#Select default palette "Default"
|
||||
on_palette_select(current_palette)
|
||||
|
||||
func _clear_swatches() -> void:
|
||||
|
@ -53,25 +20,93 @@ func _clear_swatches() -> void:
|
|||
|
||||
func on_palette_select(palette_name : String) -> void:
|
||||
_clear_swatches()
|
||||
if Global.palettes.has(palette_name): #Palette exists in memory
|
||||
current_palette = palette_name
|
||||
if Global.palettes.has(palette_name):
|
||||
_display_palette(Global.palettes[palette_name])
|
||||
else:
|
||||
var palette : Dictionary = Global.palettes[palette_name]
|
||||
|
||||
Global.remove_palette_button.disabled = true # Cannot remove by default
|
||||
if palette.has("editable"):
|
||||
if palette.editable:
|
||||
Global.remove_palette_button.disabled = false # Can remove if custom palette
|
||||
|
||||
_display_palette(palette)
|
||||
else: #Use default on fail
|
||||
current_palette = "Default"
|
||||
_display_palette(Global.palettes["Default"])
|
||||
|
||||
func _display_palette(palette : Array) -> void:
|
||||
func on_edit_palette() -> void:
|
||||
var palette : Dictionary = Global.palettes[current_palette]
|
||||
|
||||
var create_new_palette := true # Create new palette by default
|
||||
if palette.has("editable"):
|
||||
if palette.editable:
|
||||
create_new_palette = false # Edit if already a custom palette
|
||||
|
||||
if create_new_palette:
|
||||
from_palette = Global.palettes[current_palette]
|
||||
Global.new_palette_name_line_edit.text = "Custom_" + current_palette
|
||||
Global.new_palette_dialog.popup_centered()
|
||||
else:
|
||||
from_palette = {}
|
||||
Global.edit_palette_popup.open(current_palette)
|
||||
|
||||
func on_new_palette_confirmed() -> void:
|
||||
var new_palette_name : String = Global.new_palette_name_line_edit.text
|
||||
var result : String = create_new_palette(new_palette_name, from_palette)
|
||||
if not result.empty():
|
||||
Global.error_dialog.set_text(result);
|
||||
Global.error_dialog.popup_centered()
|
||||
|
||||
func create_new_palette(name : String, from_palette : Dictionary = {}) -> String: # Returns empty string, else error string
|
||||
var new_palette : Dictionary = {}
|
||||
|
||||
# Check if new name is valid
|
||||
if name.empty():
|
||||
return "Error: Palette must have a valid name."
|
||||
if Global.palettes.has(name):
|
||||
return "Error: Palette '" + name + "' already exists!"
|
||||
|
||||
new_palette.name = name
|
||||
|
||||
# Check if source palette has data
|
||||
if from_palette.has("name"):
|
||||
new_palette = from_palette.duplicate()
|
||||
new_palette.name = name
|
||||
new_palette.editable = true
|
||||
else:
|
||||
new_palette.colors = []
|
||||
new_palette.comments = ""
|
||||
new_palette.editable = true
|
||||
|
||||
# Add palette to Global and options
|
||||
Global.palettes[name] = new_palette
|
||||
Global.palette_option_button.add_item(name)
|
||||
var index := Global.palette_option_button.get_item_count() - 1
|
||||
Global.palette_option_button.set_item_metadata(index, name)
|
||||
Global.palette_option_button.select(index)
|
||||
|
||||
save_palette(name, name + ".json")
|
||||
|
||||
on_palette_select(name)
|
||||
return ""
|
||||
|
||||
func _display_palette(palette : Dictionary) -> void:
|
||||
var index := 0
|
||||
for color_data in palette:
|
||||
|
||||
for color_data in palette.colors:
|
||||
var color = Color(color_data.data)
|
||||
var new_button = palette_button.instance()
|
||||
|
||||
new_button.get_child(0).modulate = color
|
||||
new_button.hint_tooltip = color_data.data.to_upper() + " " + color_data.name
|
||||
new_button.connect("pressed", self, "on_color_select", [index])
|
||||
|
||||
add_child(new_button)
|
||||
index += 1
|
||||
|
||||
func on_color_select(index : int) -> void:
|
||||
var color = Color(Global.palettes[current_palette][index].data)
|
||||
var color = Color(Global.palettes[current_palette].colors[index].data)
|
||||
|
||||
if Input.is_action_just_released("left_mouse"):
|
||||
Global.left_color_picker.color = color
|
||||
Global.update_left_custom_brush()
|
||||
|
@ -80,28 +115,21 @@ func on_color_select(index : int) -> void:
|
|||
Global.update_right_custom_brush()
|
||||
|
||||
func _load_palettes() -> void:
|
||||
var files := []
|
||||
|
||||
var file := File.new()
|
||||
var dir := Directory.new()
|
||||
|
||||
if not dir.dir_exists("user://palettes"):
|
||||
dir.make_dir("user://palettes");
|
||||
if not dir.dir_exists("user://palettes/custom"):
|
||||
dir.make_dir("user://palettes/custom")
|
||||
if not file.file_exists("user://palettes/default_palette.json"):
|
||||
dir.copy("res://Assets/Graphics/Palette/default_palette.json","user://palettes/default_palette.json");
|
||||
if not file.file_exists("user://palettes/bubblegum16.json"):
|
||||
dir.copy("res://Assets/Graphics/Palette/bubblegum16.json","user://palettes/bubblegum16.json");
|
||||
|
||||
dir.open("user://palettes")
|
||||
dir.list_dir_begin()
|
||||
var palette_files : Array = get_palette_files("user://palettes")
|
||||
|
||||
while true:
|
||||
var file_name = dir.get_next()
|
||||
if file_name == "":
|
||||
break
|
||||
elif not file_name.begins_with(".") && file_name.to_lower().ends_with("json"):
|
||||
files.append(file_name)
|
||||
|
||||
dir.list_dir_end()
|
||||
|
||||
for file_name in files:
|
||||
for file_name in palette_files:
|
||||
var result : String = load_palette("user://palettes/" + file_name)
|
||||
if result:
|
||||
Global.palette_option_button.add_item(result)
|
||||
|
@ -110,10 +138,36 @@ func _load_palettes() -> void:
|
|||
if result == "Default":
|
||||
Global.palette_option_button.select(index)
|
||||
|
||||
for item in Global.palette_option_button.items:
|
||||
print(item)
|
||||
dir.open("user://palettes/custom")
|
||||
var custom_palette_files : Array = get_palette_files("user://palettes/custom")
|
||||
|
||||
for file_name in custom_palette_files:
|
||||
var result : String = load_palette("user://palettes/custom/" + file_name)
|
||||
if result:
|
||||
Global.palette_option_button.add_item(result)
|
||||
var index := Global.palette_option_button.get_item_count() - 1
|
||||
Global.palette_option_button.set_item_metadata(index, result)
|
||||
|
||||
func get_palette_files(path : String) -> Array:
|
||||
var dir := Directory.new()
|
||||
var results = []
|
||||
|
||||
dir.open(path)
|
||||
dir.list_dir_begin()
|
||||
|
||||
while true:
|
||||
var file_name = dir.get_next()
|
||||
if file_name == "":
|
||||
break
|
||||
elif not file_name.begins_with(".") && file_name.to_lower().ends_with("json"):
|
||||
results.append(file_name)
|
||||
|
||||
dir.list_dir_end()
|
||||
|
||||
return results
|
||||
|
||||
func load_palette(path : String) -> String:
|
||||
# Open file for reading
|
||||
var file := File.new()
|
||||
file.open(path, File.READ)
|
||||
|
||||
|
@ -121,7 +175,7 @@ func load_palette(path : String) -> String:
|
|||
var result_json = JSON.parse(text)
|
||||
var result = {}
|
||||
|
||||
var palette_name = null
|
||||
var palette_name = null # Default error condition
|
||||
|
||||
if result_json.error != OK: # If parse has errors
|
||||
print("Error: ", result_json.error)
|
||||
|
@ -129,21 +183,36 @@ func load_palette(path : String) -> String:
|
|||
print("Error String: ", result_json.error_string)
|
||||
else: # If parse OK
|
||||
var data = result_json.result
|
||||
if data.has("name"):
|
||||
if data.has("name"): #If data is 'valid' palette file
|
||||
palette_name = data.name
|
||||
Global.palettes[data.name] = data.colors
|
||||
Global.palettes[data.name] = data
|
||||
|
||||
file.close()
|
||||
|
||||
return palette_name
|
||||
|
||||
func _save_palette(palette : Array, name : String, path : String) -> void:
|
||||
func remove_current_palette() -> void:
|
||||
if Global.palettes[current_palette].has("editable"):
|
||||
if Global.palettes[current_palette].editable:
|
||||
_delete_palette_file(current_palette + ".json")
|
||||
Global.palettes.erase(current_palette)
|
||||
var selected_index := Global.palette_option_button.selected
|
||||
Global.palette_option_button.remove_item(selected_index)
|
||||
if(selected_index - 1 >= 0):
|
||||
Global.palette_option_button.select(selected_index - 1)
|
||||
on_palette_select(Global.palette_option_button.get_item_metadata(selected_index - 1))
|
||||
pass
|
||||
|
||||
func _delete_palette_file(file_name : String) -> void:
|
||||
var dir = Directory.new()
|
||||
dir.remove("user://palettes/custom/" + file_name)
|
||||
|
||||
func save_palette(palette_name : String, filename : String) -> void:
|
||||
var palette_data = Global.palettes[palette_name]
|
||||
# Open file for writing
|
||||
var file := File.new()
|
||||
file.open(path, File.WRITE)
|
||||
file.open("user://palettes/custom/" + filename, File.WRITE)
|
||||
|
||||
var data := {}
|
||||
data.name = name
|
||||
data.colors = palette
|
||||
|
||||
file.store_string(JSON.print(data))
|
||||
# Write palette data to file
|
||||
file.store_string(JSON.print(palette_data))
|
||||
file.close()
|
||||
|
|
|
@ -1,8 +1,170 @@
|
|||
[gd_resource type="Theme" load_steps=2 format=2]
|
||||
[gd_resource type="Theme" load_steps=14 format=2]
|
||||
|
||||
[ext_resource path="res://Assets/Fonts/Roboto-Regular.tres" type="DynamicFont" id=1]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=1]
|
||||
bg_color = Color( 0.517647, 0.517647, 0.517647, 1 )
|
||||
border_width_left = 6
|
||||
border_width_top = 4
|
||||
border_width_right = 6
|
||||
border_width_bottom = 4
|
||||
border_color = Color( 0.517647, 0.517647, 0.517647, 1 )
|
||||
corner_radius_top_left = 4
|
||||
corner_radius_top_right = 4
|
||||
corner_radius_bottom_right = 4
|
||||
corner_radius_bottom_left = 4
|
||||
anti_aliasing = false
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=2]
|
||||
bg_color = Color( 0.321569, 0.321569, 0.321569, 1 )
|
||||
border_width_left = 6
|
||||
border_width_top = 4
|
||||
border_width_right = 6
|
||||
border_width_bottom = 4
|
||||
border_color = Color( 0.321569, 0.321569, 0.321569, 1 )
|
||||
corner_radius_top_left = 4
|
||||
corner_radius_top_right = 4
|
||||
corner_radius_bottom_right = 4
|
||||
corner_radius_bottom_left = 4
|
||||
anti_aliasing = false
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=3]
|
||||
bg_color = Color( 0.2, 0.2, 0.2, 1 )
|
||||
border_width_left = 6
|
||||
border_width_top = 4
|
||||
border_width_right = 6
|
||||
border_width_bottom = 4
|
||||
border_color = Color( 0.2, 0.2, 0.2, 1 )
|
||||
corner_radius_top_left = 4
|
||||
corner_radius_top_right = 4
|
||||
corner_radius_bottom_right = 4
|
||||
corner_radius_bottom_left = 4
|
||||
anti_aliasing = false
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=4]
|
||||
bg_color = Color( 0.6, 0.6, 0.6, 0 )
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=5]
|
||||
bg_color = Color( 0.6, 0.6, 0.6, 0 )
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=6]
|
||||
bg_color = Color( 0.6, 0.6, 0.6, 0 )
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=7]
|
||||
bg_color = Color( 0.6, 0.6, 0.6, 0 )
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=8]
|
||||
bg_color = Color( 0.321569, 0.321569, 0.321569, 1 )
|
||||
border_width_left = 8
|
||||
border_width_top = 1
|
||||
border_width_right = 4
|
||||
border_width_bottom = 1
|
||||
border_color = Color( 0.321569, 0.321569, 0.321569, 1 )
|
||||
corner_radius_top_left = 4
|
||||
corner_radius_top_right = 4
|
||||
corner_radius_bottom_right = 4
|
||||
corner_radius_bottom_left = 4
|
||||
anti_aliasing = false
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=9]
|
||||
bg_color = Color( 0.321569, 0.321569, 0.321569, 1 )
|
||||
border_width_left = 5
|
||||
border_width_top = 10
|
||||
border_width_right = 5
|
||||
border_width_bottom = 5
|
||||
border_color = Color( 0.321569, 0.321569, 0.321569, 1 )
|
||||
corner_radius_top_left = 4
|
||||
corner_radius_top_right = 4
|
||||
corner_radius_bottom_right = 4
|
||||
corner_radius_bottom_left = 4
|
||||
anti_aliasing = false
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=10]
|
||||
bg_color = Color( 0.2, 0.2, 0.2, 1 )
|
||||
border_width_left = 10
|
||||
border_width_top = 6
|
||||
border_width_right = 10
|
||||
border_width_bottom = 8
|
||||
border_color = Color( 0.2, 0.2, 0.2, 1 )
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=11]
|
||||
bg_color = Color( 0.145098, 0.145098, 0.164706, 1 )
|
||||
border_width_left = 10
|
||||
border_width_top = 6
|
||||
border_width_right = 10
|
||||
border_width_bottom = 8
|
||||
border_color = Color( 0.145098, 0.145098, 0.164706, 1 )
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=12]
|
||||
bg_color = Color( 0.321569, 0.321569, 0.321569, 1 )
|
||||
border_width_left = 10
|
||||
border_width_top = 6
|
||||
border_width_right = 10
|
||||
border_width_bottom = 8
|
||||
border_color = Color( 0.321569, 0.321569, 0.321569, 1 )
|
||||
|
||||
[resource]
|
||||
default_font = ExtResource( 1 )
|
||||
Button/colors/font_color = Color( 0.878431, 0.878431, 0.878431, 1 )
|
||||
Button/colors/font_color_disabled = Color( 0.9, 0.9, 0.9, 0.2 )
|
||||
Button/colors/font_color_hover = Color( 0.941176, 0.941176, 0.941176, 1 )
|
||||
Button/colors/font_color_pressed = Color( 1, 1, 1, 1 )
|
||||
Button/constants/hseparation = 2
|
||||
Button/fonts/font = null
|
||||
Button/styles/disabled = null
|
||||
Button/styles/focus = null
|
||||
Button/styles/hover = SubResource( 1 )
|
||||
Button/styles/normal = SubResource( 2 )
|
||||
Button/styles/pressed = SubResource( 3 )
|
||||
CheckBox/colors/font_color = Color( 0.878431, 0.878431, 0.878431, 1 )
|
||||
CheckBox/colors/font_color_disabled = Color( 0.9, 0.9, 0.9, 0.2 )
|
||||
CheckBox/colors/font_color_hover = Color( 0.941176, 0.941176, 0.941176, 1 )
|
||||
CheckBox/colors/font_color_hover_pressed = Color( 1, 1, 1, 1 )
|
||||
CheckBox/colors/font_color_pressed = Color( 1, 1, 1, 1 )
|
||||
CheckBox/constants/check_vadjust = 0
|
||||
CheckBox/constants/hseparation = 4
|
||||
CheckBox/fonts/font = null
|
||||
CheckBox/icons/checked = null
|
||||
CheckBox/icons/radio_checked = null
|
||||
CheckBox/icons/radio_unchecked = null
|
||||
CheckBox/icons/unchecked = null
|
||||
CheckBox/styles/disabled = null
|
||||
CheckBox/styles/focus = null
|
||||
CheckBox/styles/hover = SubResource( 4 )
|
||||
CheckBox/styles/hover_pressed = SubResource( 5 )
|
||||
CheckBox/styles/normal = SubResource( 6 )
|
||||
CheckBox/styles/pressed = SubResource( 7 )
|
||||
GridContainer/constants/hseparation = 0
|
||||
GridContainer/constants/vseparation = 0
|
||||
LineEdit/colors/clear_button_color = Color( 0.878431, 0.878431, 0.878431, 1 )
|
||||
LineEdit/colors/clear_button_color_pressed = Color( 1, 1, 1, 1 )
|
||||
LineEdit/colors/cursor_color = Color( 0.941176, 0.941176, 0.941176, 1 )
|
||||
LineEdit/colors/font_color = Color( 0.878431, 0.878431, 0.878431, 1 )
|
||||
LineEdit/colors/font_color_selected = Color( 0, 0, 0, 1 )
|
||||
LineEdit/colors/selection_color = Color( 0.490196, 0.490196, 0.490196, 1 )
|
||||
LineEdit/constants/minimum_spaces = 12
|
||||
LineEdit/fonts/font = null
|
||||
LineEdit/icons/clear = null
|
||||
LineEdit/styles/focus = null
|
||||
LineEdit/styles/normal = SubResource( 8 )
|
||||
LineEdit/styles/read_only = null
|
||||
TabContainer/colors/font_color_bg = Color( 0.690196, 0.690196, 0.690196, 1 )
|
||||
TabContainer/colors/font_color_disabled = Color( 0.9, 0.9, 0.9, 0.2 )
|
||||
TabContainer/colors/font_color_fg = Color( 0.941176, 0.941176, 0.941176, 1 )
|
||||
TabContainer/constants/hseparation = 4
|
||||
TabContainer/constants/label_valign_bg = 2
|
||||
TabContainer/constants/label_valign_fg = 0
|
||||
TabContainer/constants/side_margin = 8
|
||||
TabContainer/constants/top_margin = 24
|
||||
TabContainer/fonts/font = null
|
||||
TabContainer/icons/decrement = null
|
||||
TabContainer/icons/decrement_highlight = null
|
||||
TabContainer/icons/increment = null
|
||||
TabContainer/icons/increment_highlight = null
|
||||
TabContainer/icons/menu = null
|
||||
TabContainer/icons/menu_highlight = null
|
||||
TabContainer/styles/panel = SubResource( 9 )
|
||||
TabContainer/styles/tab_bg = SubResource( 10 )
|
||||
TabContainer/styles/tab_disabled = SubResource( 11 )
|
||||
TabContainer/styles/tab_fg = SubResource( 12 )
|
||||
VBoxContainer/constants/separation = 4
|
||||
|
|
11
Themes & Styles/StyleBoxes/palette_stylebox_focus.tres
Normal file
11
Themes & Styles/StyleBoxes/palette_stylebox_focus.tres
Normal file
|
@ -0,0 +1,11 @@
|
|||
[gd_resource type="StyleBoxTexture" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://Assets/Graphics/Palette/palette_button.png" type="Texture" id=1]
|
||||
|
||||
[resource]
|
||||
texture = ExtResource( 1 )
|
||||
region_rect = Rect2( 0, 0, 8, 8 )
|
||||
margin_left = 2.0
|
||||
margin_right = 2.0
|
||||
margin_top = 2.0
|
||||
margin_bottom = 2.0
|
|
@ -81,7 +81,7 @@ Brush: Pixel,Brush: Pixel,Πινέλο: Εικονοστοιχείο,Brosse : Pi
|
|||
Custom brush,Custom brush,Προσαρμοσμένο πινέλο,Brosse personnalisée,Benutzerdefinierter Pinsel,Niestandardowy pędzel,Текущая кисть
|
||||
Brush size:,Brush size:,Μέγεθος πινέλου:,Taille de la brosse :,Pinselgröße:,Rozmiar pędzla:,Размер кисти:
|
||||
Brush color from,Brush color from,Χρώμα πινέλου από,Couleur de la brosse depuis,Pinselfarbe von,Nadpisywanie koloru pędzla,Цвет кисти
|
||||
COLORFROM_HT,"0: Color from the brush itself, 1: the currently selected color","0: Χρώμα από το πινέλο, 1: επιλεγμένο χρώμα","0 : Couleur depuis la brosse elle-même, 1 : la couleur actuellement sélectionnée","0: Farbe von dem Pinsel selbst, 1: die aktuell ausgewählte Farbe","0: Kolor pochodzący z samego pędzla, 1: Obecnie wybrany kolor rysowania","0: Собственный цвет кисти, 1: Выбранный цвет"
|
||||
COLORFROM_HT,"0: Color from the brush itself, 100: the currently selected color","0: Χρώμα από το πινέλο, 100: επιλεγμένο χρώμα","0 : Couleur depuis la brosse elle-même, 100 : la couleur actuellement sélectionnée","0: Farbe von dem Pinsel selbst, 100: die aktuell ausgewählte Farbe","0: Kolor pochodzący z samego pędzla, 100: Obecnie wybrany kolor rysowania","0: Собственный цвет кисти, 100: Выбранный цвет"
|
||||
Fill area:,Fill area:,Περιοχή γεμίσματος:,Remplissage de zone :,Fülle Bereich,Wypełnij przestrzeń:,Залить область:
|
||||
Area of the same color,Area of the same color,Περιοχή ίδιου χρώματος,Zone de la même couleur,Bereich mit der selben Farbe,Przestrzeń o takim samym kolorze,Область того же цвета
|
||||
All pixels of the same color,All pixels of the same color,Όλα τα πίξελ ίδιου χρώματος,Tous les pixels de la même couleur,Alle Pixel mit der selben Farbe,Wszystkie piksele tego samego koloru,Все точки такого же цвета
|
||||
|
|
|
Loading…
Add table
Reference in a new issue