mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 09:09:47 +00:00
commit
2d97bb6e65
22
Assets/Graphics/Palette/bubblegum16.json
Normal file
22
Assets/Graphics/Palette/bubblegum16.json
Normal file
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"name": "BubbleGum16",
|
||||
"colors" : [
|
||||
{ "data" : "#FF000000", "name" : "no name" },
|
||||
{ "data" : "#FF7f0622", "name" : "no name" },
|
||||
{ "data" : "#FFd62411", "name" : "no name" },
|
||||
{ "data" : "#FFff8426", "name" : "no name" },
|
||||
{ "data" : "#FFffd100", "name" : "no name" },
|
||||
{ "data" : "#FFfafdff", "name" : "no name" },
|
||||
{ "data" : "#FFff80a4", "name" : "no name" },
|
||||
{ "data" : "#FFff2674", "name" : "no name" },
|
||||
{ "data" : "#FF94216a", "name" : "no name" },
|
||||
{ "data" : "#FF430067", "name" : "no name" },
|
||||
{ "data" : "#FF234975", "name" : "no name" },
|
||||
{ "data" : "#FF68aed4", "name" : "no name" },
|
||||
{ "data" : "#FFbfff3c", "name" : "no name" },
|
||||
{ "data" : "#FF10d275", "name" : "no name" },
|
||||
{ "data" : "#FF007899", "name" : "no name" },
|
||||
{ "data" : "#FF002859", "name" : "no name" },
|
||||
],
|
||||
"comments": "by PineTreePizza - https://twitter.com/PineTreePizza"
|
||||
}
|
37
Assets/Graphics/Palette/default_palette.json
Normal file
37
Assets/Graphics/Palette/default_palette.json
Normal file
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
"name": "Default",
|
||||
"colors" : [
|
||||
{ "data" : "#FF000000", "name" : "no name" },
|
||||
{ "data" : "#FF222034", "name" : "no name" },
|
||||
{ "data" : "#FF45283c", "name" : "no name" },
|
||||
{ "data" : "#FF663931", "name" : "no name" },
|
||||
{ "data" : "#FF8f563b", "name" : "no name" },
|
||||
{ "data" : "#FFdf7126", "name" : "no name" },
|
||||
{ "data" : "#FFd9a066", "name" : "no name" },
|
||||
{ "data" : "#FFeec39a", "name" : "no name" },
|
||||
{ "data" : "#FFfbf236", "name" : "no name" },
|
||||
{ "data" : "#FF99e550", "name" : "no name" },
|
||||
{ "data" : "#FF6abe30", "name" : "no name" },
|
||||
{ "data" : "#FF37946e", "name" : "no name" },
|
||||
{ "data" : "#FF4b692f", "name" : "no name" },
|
||||
{ "data" : "#FF524b24", "name" : "no name" },
|
||||
{ "data" : "#FF323c39", "name" : "no name" },
|
||||
{ "data" : "#FF3f3f74", "name" : "no name" },
|
||||
{ "data" : "#FF306082", "name" : "no name" },
|
||||
{ "data" : "#FF5b6ee1", "name" : "no name" },
|
||||
{ "data" : "#FF639bff", "name" : "no name" },
|
||||
{ "data" : "#FF5fcde4", "name" : "no name" },
|
||||
{ "data" : "#FFcbdbfc", "name" : "no name" },
|
||||
{ "data" : "#FFffffff", "name" : "no name" },
|
||||
{ "data" : "#FF9badb7", "name" : "no name" },
|
||||
{ "data" : "#FF847e87", "name" : "no name" },
|
||||
{ "data" : "#FF696a6a", "name" : "no name" },
|
||||
{ "data" : "#FF595652", "name" : "no name" },
|
||||
{ "data" : "#FF76428a", "name" : "no name" },
|
||||
{ "data" : "#FFac3232", "name" : "no name" },
|
||||
{ "data" : "#FFd95763", "name" : "no name" },
|
||||
{ "data" : "#FFd77bba", "name" : "no name" },
|
||||
{ "data" : "#FF8f974a", "name" : "no name" },
|
||||
{ "data" : "#FF8a6f30", "name" : "no name" }
|
||||
]
|
||||
}
|
96
Main.tscn
96
Main.tscn
|
@ -133,14 +133,12 @@ anchor_bottom = 1.0
|
|||
custom_constants/separation = 0
|
||||
|
||||
[node name="MenuContainer" type="Panel" parent="MenuAndUI"]
|
||||
editor/display_folded = true
|
||||
margin_right = 1152.0
|
||||
margin_bottom = 28.0
|
||||
rect_min_size = Vector2( 0, 28 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
|
||||
[node name="MenuItems" type="HBoxContainer" parent="MenuAndUI/MenuContainer"]
|
||||
editor/display_folded = true
|
||||
margin_left = 2.0
|
||||
margin_top = 4.0
|
||||
margin_right = 1010.0
|
||||
|
@ -770,7 +768,6 @@ mouse_default_cursor_shape = 2
|
|||
text = "Vertical"
|
||||
|
||||
[node name="CanvasAndTimeline" type="VBoxContainer" parent="MenuAndUI/UI"]
|
||||
editor/display_folded = true
|
||||
margin_left = 224.0
|
||||
margin_right = 928.0
|
||||
margin_bottom = 620.0
|
||||
|
@ -804,7 +801,6 @@ enabled_focus_mode = 0
|
|||
script = ExtResource( 13 )
|
||||
|
||||
[node name="ViewportandVerticalRuler" type="HBoxContainer" parent="MenuAndUI/UI/CanvasAndTimeline/HViewportContainer/ViewportAndRulers"]
|
||||
editor/display_folded = true
|
||||
margin_top = 16.0
|
||||
margin_right = 704.0
|
||||
margin_bottom = 478.0
|
||||
|
@ -1158,7 +1154,7 @@ margin_bottom = 199.0
|
|||
[node name="LayerVBoxContainer" type="VBoxContainer" parent="MenuAndUI/UI/LayerPanel/LayersAndMisc"]
|
||||
margin_top = 203.0
|
||||
margin_right = 224.0
|
||||
margin_bottom = 388.0
|
||||
margin_bottom = 384.0
|
||||
size_flags_vertical = 3
|
||||
custom_constants/separation = 6
|
||||
|
||||
|
@ -1230,7 +1226,7 @@ texture_disabled = ExtResource( 38 )
|
|||
editor/display_folded = true
|
||||
margin_top = 38.0
|
||||
margin_right = 224.0
|
||||
margin_bottom = 185.0
|
||||
margin_bottom = 181.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
|
@ -1238,29 +1234,33 @@ size_flags_vertical = 3
|
|||
margin_right = 224.0
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="PaletteLabel" type="Label" parent="MenuAndUI/UI/LayerPanel/LayersAndMisc"]
|
||||
margin_top = 392.0
|
||||
[node name="HSeparator2" type="HSeparator" parent="MenuAndUI/UI/LayerPanel/LayersAndMisc"]
|
||||
margin_top = 388.0
|
||||
margin_right = 224.0
|
||||
margin_bottom = 407.0
|
||||
margin_bottom = 392.0
|
||||
|
||||
[node name="PaletteLabel" type="Label" parent="MenuAndUI/UI/LayerPanel/LayersAndMisc"]
|
||||
margin_top = 396.0
|
||||
margin_right = 224.0
|
||||
margin_bottom = 411.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 0
|
||||
text = "Palette"
|
||||
align = 1
|
||||
|
||||
[node name="HSeparator2" type="HSeparator" parent="MenuAndUI/UI/LayerPanel/LayersAndMisc"]
|
||||
margin_top = 411.0
|
||||
[node name="HSeparator4" type="HSeparator" parent="MenuAndUI/UI/LayerPanel/LayersAndMisc"]
|
||||
margin_top = 415.0
|
||||
margin_right = 224.0
|
||||
margin_bottom = 415.0
|
||||
margin_bottom = 419.0
|
||||
|
||||
[node name="PaletteVBoxContainer" type="VBoxContainer" parent="MenuAndUI/UI/LayerPanel/LayersAndMisc"]
|
||||
margin_top = 419.0
|
||||
margin_top = 423.0
|
||||
margin_right = 224.0
|
||||
margin_bottom = 604.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="PaletteButtons" type="HBoxContainer" parent="MenuAndUI/UI/LayerPanel/LayersAndMisc/PaletteVBoxContainer"]
|
||||
editor/display_folded = true
|
||||
margin_right = 224.0
|
||||
margin_bottom = 32.0
|
||||
size_flags_horizontal = 3
|
||||
|
@ -1276,7 +1276,7 @@ margin_right = 68.0
|
|||
margin_bottom = 32.0
|
||||
texture_normal = ExtResource( 30 )
|
||||
|
||||
[node name="OptionButton" type="OptionButton" parent="MenuAndUI/UI/LayerPanel/LayersAndMisc/PaletteVBoxContainer/PaletteButtons"]
|
||||
[node name="PaletteOptionButton" type="OptionButton" parent="MenuAndUI/UI/LayerPanel/LayersAndMisc/PaletteVBoxContainer/PaletteButtons"]
|
||||
margin_left = 72.0
|
||||
margin_right = 187.0
|
||||
margin_bottom = 32.0
|
||||
|
@ -1291,7 +1291,7 @@ text = "Edit"
|
|||
[node name="ScrollPalette" type="ScrollContainer" parent="MenuAndUI/UI/LayerPanel/LayersAndMisc/PaletteVBoxContainer"]
|
||||
margin_top = 36.0
|
||||
margin_right = 224.0
|
||||
margin_bottom = 185.0
|
||||
margin_bottom = 181.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
|
@ -1432,8 +1432,8 @@ resizable = true
|
|||
mode = 0
|
||||
access = 2
|
||||
filters = PoolStringArray( "*.pxo ; Pixelorama Project" )
|
||||
current_dir = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama"
|
||||
current_path = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama/"
|
||||
current_dir = "D:/GitHub/Pixelorama"
|
||||
current_path = "D:/GitHub/Pixelorama/"
|
||||
|
||||
[node name="SaveSprite" type="FileDialog" parent="."]
|
||||
anchor_left = 0.5
|
||||
|
@ -1448,8 +1448,8 @@ window_title = "Save Sprite as .pxo"
|
|||
resizable = true
|
||||
access = 2
|
||||
filters = PoolStringArray( "*.pxo ; Pixelorama Project" )
|
||||
current_dir = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama"
|
||||
current_path = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama/"
|
||||
current_dir = "D:/GitHub/Pixelorama"
|
||||
current_path = "D:/GitHub/Pixelorama/"
|
||||
|
||||
[node name="ImportSprites" type="FileDialog" parent="."]
|
||||
margin_right = 515.0
|
||||
|
@ -1459,8 +1459,8 @@ resizable = true
|
|||
mode = 1
|
||||
access = 2
|
||||
filters = PoolStringArray( "*.bmp ; BMP Image", "*.hdr ; Radiance HDR Image", "*.jpg,*.jpeg ; JPEG Image", "*.png ; PNG Image", "*.svg ; SVG Image", "*.tga ; TGA Image", "*.webp ; WebP Image" )
|
||||
current_dir = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama"
|
||||
current_path = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama/"
|
||||
current_dir = "D:/GitHub/Pixelorama"
|
||||
current_path = "D:/GitHub/Pixelorama/"
|
||||
|
||||
[node name="ExportSprites" type="FileDialog" parent="."]
|
||||
anchor_left = 0.5
|
||||
|
@ -1475,8 +1475,8 @@ window_title = "Export Sprite"
|
|||
resizable = true
|
||||
access = 2
|
||||
filters = PoolStringArray( "*.png ; PNG Image" )
|
||||
current_dir = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama"
|
||||
current_path = "C:/Users/Overloaded/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama/"
|
||||
current_dir = "D:/GitHub/Pixelorama"
|
||||
current_path = "D:/GitHub/Pixelorama/"
|
||||
|
||||
[node name="ScaleImage" type="ConfirmationDialog" parent="."]
|
||||
editor/display_folded = true
|
||||
|
@ -1557,13 +1557,13 @@ resizable = true
|
|||
[node name="VBoxContainer" type="VBoxContainer" parent="PreferencesDialog"]
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
margin_left = -97.5
|
||||
margin_left = -92.0
|
||||
margin_top = 8.0
|
||||
margin_right = 97.5
|
||||
margin_bottom = 123.0
|
||||
margin_right = 92.0
|
||||
margin_bottom = 33.0
|
||||
|
||||
[node name="OptionsContainer" type="GridContainer" parent="PreferencesDialog/VBoxContainer"]
|
||||
margin_right = 195.0
|
||||
margin_right = 184.0
|
||||
margin_bottom = 21.0
|
||||
columns = 2
|
||||
|
||||
|
@ -1574,8 +1574,8 @@ margin_bottom = 18.0
|
|||
text = "Language:"
|
||||
|
||||
[node name="LanguageOption" type="OptionButton" parent="PreferencesDialog/VBoxContainer/OptionsContainer"]
|
||||
margin_left = 57.0
|
||||
margin_right = 195.0
|
||||
margin_left = 61.0
|
||||
margin_right = 142.0
|
||||
margin_bottom = 21.0
|
||||
text = "System Language"
|
||||
items = [ "System Language", null, false, 0, null, "German [de]", null, false, 1, null, "Greek [el]", null, false, 2, null, "English [en]", null, false, 3, null, "French [fr]", null, false, 4, null ]
|
||||
|
@ -1583,14 +1583,14 @@ selected = 0
|
|||
|
||||
[node name="GridOptionsLabel" type="Label" parent="PreferencesDialog/VBoxContainer"]
|
||||
margin_top = 25.0
|
||||
margin_right = 195.0
|
||||
margin_right = 184.0
|
||||
margin_bottom = 40.0
|
||||
text = "Grid options"
|
||||
|
||||
[node name="GridOptions" type="GridContainer" parent="PreferencesDialog/VBoxContainer"]
|
||||
margin_top = 44.0
|
||||
margin_right = 195.0
|
||||
margin_bottom = 115.0
|
||||
margin_right = 184.0
|
||||
margin_bottom = 123.0
|
||||
columns = 2
|
||||
|
||||
[node name="WidthLabel" type="Label" parent="PreferencesDialog/VBoxContainer/GridOptions"]
|
||||
|
@ -1600,8 +1600,8 @@ margin_bottom = 20.0
|
|||
text = "Width:"
|
||||
|
||||
[node name="GridWidthValue" type="SpinBox" parent="PreferencesDialog/VBoxContainer/GridOptions"]
|
||||
margin_left = 39.0
|
||||
margin_right = 103.0
|
||||
margin_left = 43.0
|
||||
margin_right = 107.0
|
||||
margin_bottom = 25.0
|
||||
min_value = 1.0
|
||||
max_value = 16384.0
|
||||
|
@ -1609,32 +1609,32 @@ value = 1.0
|
|||
suffix = "px"
|
||||
|
||||
[node name="Height" type="Label" parent="PreferencesDialog/VBoxContainer/GridOptions"]
|
||||
margin_top = 30.0
|
||||
margin_top = 34.0
|
||||
margin_right = 39.0
|
||||
margin_bottom = 45.0
|
||||
margin_bottom = 49.0
|
||||
text = "Height:"
|
||||
|
||||
[node name="GridHeightValue" type="SpinBox" parent="PreferencesDialog/VBoxContainer/GridOptions"]
|
||||
margin_left = 39.0
|
||||
margin_top = 25.0
|
||||
margin_right = 103.0
|
||||
margin_bottom = 50.0
|
||||
margin_left = 43.0
|
||||
margin_top = 29.0
|
||||
margin_right = 107.0
|
||||
margin_bottom = 54.0
|
||||
min_value = 1.0
|
||||
max_value = 16384.0
|
||||
value = 1.0
|
||||
suffix = "px"
|
||||
|
||||
[node name="GridColorLabel" type="Label" parent="PreferencesDialog/VBoxContainer/GridOptions"]
|
||||
margin_top = 53.0
|
||||
margin_top = 61.0
|
||||
margin_right = 39.0
|
||||
margin_bottom = 68.0
|
||||
margin_bottom = 76.0
|
||||
text = "Color:"
|
||||
|
||||
[node name="GridColor" type="ColorPickerButton" parent="PreferencesDialog/VBoxContainer/GridOptions"]
|
||||
margin_left = 39.0
|
||||
margin_top = 50.0
|
||||
margin_right = 103.0
|
||||
margin_bottom = 71.0
|
||||
margin_left = 43.0
|
||||
margin_top = 58.0
|
||||
margin_right = 107.0
|
||||
margin_bottom = 79.0
|
||||
rect_min_size = Vector2( 64, 20 )
|
||||
|
||||
[node name="AboutDialog" type="AcceptDialog" parent="."]
|
||||
|
@ -1764,6 +1764,8 @@ visible = false
|
|||
[connection signal="pressed" from="MenuAndUI/UI/LayerPanel/LayersAndMisc/LayerVBoxContainer/CenterLayerButtons/LayerButtons/MoveDownLayer" to="." method="change_layer_order" binds= [ -1 ]]
|
||||
[connection signal="pressed" from="MenuAndUI/UI/LayerPanel/LayersAndMisc/LayerVBoxContainer/CenterLayerButtons/LayerButtons/CloneLayer" to="." method="add_layer" binds= [ false ]]
|
||||
[connection signal="pressed" from="MenuAndUI/UI/LayerPanel/LayersAndMisc/LayerVBoxContainer/CenterLayerButtons/LayerButtons/MergeDownLayer" to="." method="_on_MergeLayer_pressed"]
|
||||
[connection signal="pressed" from="MenuAndUI/UI/LayerPanel/LayersAndMisc/PaletteVBoxContainer/PaletteButtons/AddPalette" to="." method="_on_AddPalette_pressed"]
|
||||
[connection signal="item_selected" from="MenuAndUI/UI/LayerPanel/LayersAndMisc/PaletteVBoxContainer/PaletteButtons/PaletteOptionButton" to="." method="_on_PaletteOptionButton_item_selected"]
|
||||
[connection signal="toggled" from="SplitScreenButton" to="." method="_on_SplitScreenButton_toggled"]
|
||||
[connection signal="confirmed" from="CreateNewImage" to="." method="_on_CreateNewImage_confirmed"]
|
||||
[connection signal="popup_hide" from="CreateNewImage" to="." method="_can_draw_true"]
|
||||
|
|
|
@ -8,9 +8,10 @@
|
|||
[sub_resource type="ImageTexture" id=1]
|
||||
|
||||
[node name="PaletteButton" type="Button"]
|
||||
margin_right = 22.0
|
||||
margin_bottom = 22.0
|
||||
rect_min_size = Vector2( 22, 22 )
|
||||
margin_right = 26.0
|
||||
margin_bottom = 26.0
|
||||
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 )
|
||||
|
|
|
@ -103,6 +103,10 @@ var custom_left_brush_texture := ImageTexture.new()
|
|||
# warning-ignore:unused_class_variable
|
||||
var custom_right_brush_texture := ImageTexture.new()
|
||||
|
||||
#Palettes
|
||||
# warning-ignore:unused_class_variable
|
||||
var palettes := {}
|
||||
|
||||
#Nodes
|
||||
var control : Node
|
||||
var left_cursor : Sprite
|
||||
|
@ -176,6 +180,12 @@ var move_up_layer_button : BaseButton
|
|||
var move_down_layer_button : BaseButton
|
||||
var merge_down_layer_button : BaseButton
|
||||
|
||||
var add_palette_button : TextureButton
|
||||
var remove_palette_button : TextureButton
|
||||
var palette_option_button : OptionButton
|
||||
var edit_palette_button : BaseButton
|
||||
var palette_container : GridContainer
|
||||
|
||||
func _ready() -> void:
|
||||
undo_redo = UndoRedo.new()
|
||||
image_clipboard = Image.new()
|
||||
|
@ -257,6 +267,12 @@ func _ready() -> void:
|
|||
move_up_layer_button = find_node_by_name(root, "MoveUpLayer")
|
||||
move_down_layer_button = find_node_by_name(root, "MoveDownLayer")
|
||||
merge_down_layer_button = find_node_by_name(root, "MergeDownLayer")
|
||||
|
||||
add_palette_button = find_node_by_name(root, "AddPalette")
|
||||
remove_palette_button = find_node_by_name(root, "RemovePalette")
|
||||
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")
|
||||
|
||||
#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:
|
||||
|
|
|
@ -13,7 +13,7 @@ func _ready() -> void:
|
|||
changed_selection()
|
||||
|
||||
func _input(event : InputEvent):
|
||||
if event.is_action_released("ui_accept") && line_edit.visible:
|
||||
if event.is_action_released("ui_accept") && line_edit.visible && event.scancode != KEY_SPACE:
|
||||
label.visible = true
|
||||
line_edit.visible = false
|
||||
line_edit.editable = false
|
||||
|
|
|
@ -1034,3 +1034,8 @@ func _exit_tree() -> void:
|
|||
config_cache.set_value("window", "position", OS.window_position)
|
||||
config_cache.set_value("window", "size", OS.window_size)
|
||||
config_cache.save("user://cache.ini")
|
||||
|
||||
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)
|
||||
pass
|
||||
|
|
|
@ -2,6 +2,8 @@ extends GridContainer
|
|||
|
||||
var palette_button = preload("res://Prefabs/PaletteButton.tscn");
|
||||
|
||||
var current_palette = "Default"
|
||||
|
||||
var default_palette = [
|
||||
Color("#FF000000"),
|
||||
Color("#FF222034"),
|
||||
|
@ -39,18 +41,122 @@ var default_palette = [
|
|||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
#Global.palettes["Default"] = default_palette
|
||||
|
||||
_load_palettes()
|
||||
|
||||
on_palette_select(current_palette)
|
||||
pass # Replace with function body.
|
||||
|
||||
func _clear_swatches() -> void:
|
||||
for child in get_children():
|
||||
if child is BaseButton:
|
||||
child.disconnect("pressed", self, "on_color_select")
|
||||
child.queue_free()
|
||||
pass
|
||||
|
||||
func on_palette_select(palette_name : String) -> void:
|
||||
_clear_swatches()
|
||||
if Global.palettes.has(palette_name):
|
||||
_display_palette(Global.palettes[palette_name])
|
||||
else:
|
||||
_display_palette(Global.palettes["Default"])
|
||||
pass
|
||||
|
||||
func _display_palette(palette : Array) -> void:
|
||||
var index := 0
|
||||
for color in default_palette:
|
||||
for color_data in palette:
|
||||
var color = Color(color_data.data)
|
||||
var new_button = palette_button.instance()
|
||||
new_button.get_child(0).modulate = color
|
||||
new_button.connect("pressed", self, "_on_color_select", [index])
|
||||
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
|
||||
pass
|
||||
|
||||
func _on_color_select(index : int) -> void:
|
||||
func on_color_select(index : int) -> void:
|
||||
var color = Color(Global.palettes[current_palette][index].data)
|
||||
if Input.is_action_just_released("left_mouse"):
|
||||
Global.left_color_picker.color = default_palette[index]
|
||||
Global.left_color_picker.color = color
|
||||
Global.update_left_custom_brush()
|
||||
elif Input.is_action_just_released("right_mouse"):
|
||||
Global.right_color_picker.color = default_palette[index]
|
||||
Global.right_color_picker.color = color
|
||||
Global.update_right_custom_brush()
|
||||
pass
|
||||
|
||||
func _load_palettes() -> void:
|
||||
var files := []
|
||||
|
||||
var dir := Directory.new()
|
||||
|
||||
if not dir.dir_exists("user://palettes"):
|
||||
dir.make_dir("user://palettes");
|
||||
dir.copy("res://Assets/Graphics/Palette/default_palette.json","user://palettes/default_palette.json");
|
||||
dir.copy("res://Assets/Graphics/Palette/bubblegum16.json","user://palettes/bubblegum16.json");
|
||||
|
||||
dir.open("user://palettes")
|
||||
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"):
|
||||
files.append(file_name)
|
||||
|
||||
dir.list_dir_end()
|
||||
|
||||
for file_name in files:
|
||||
var result : String = load_palette("user://palettes/" + 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)
|
||||
if result == "Default":
|
||||
Global.palette_option_button.select(index)
|
||||
|
||||
for item in Global.palette_option_button.items:
|
||||
print(item)
|
||||
pass
|
||||
|
||||
func load_palette(path : String) -> String:
|
||||
var file := File.new()
|
||||
file.open(path, File.READ)
|
||||
|
||||
var text = file.get_as_text()
|
||||
var result_json = JSON.parse(text)
|
||||
var result = {}
|
||||
|
||||
var palette_name = null
|
||||
|
||||
if result_json.error != OK: # If parse has errors
|
||||
print("Error: ", result_json.error)
|
||||
print("Error Line: ", result_json.error_line)
|
||||
print("Error String: ", result_json.error_string)
|
||||
else: # If parse OK
|
||||
var data = result_json.result
|
||||
if data.has("name"):
|
||||
palette_name = data.name
|
||||
Global.palettes[data.name] = data.colors
|
||||
|
||||
file.close()
|
||||
|
||||
return palette_name
|
||||
|
||||
func _save_palette(palette : Array, name : String, path : String):
|
||||
var file := File.new()
|
||||
file.open(path, File.WRITE)
|
||||
|
||||
var data := {}
|
||||
data.name = name
|
||||
data.colors = palette
|
||||
|
||||
file.store_string(JSON.print(data))
|
||||
file.close()
|
||||
|
||||
pass
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta):
|
||||
# pass
|
||||
|
|
Loading…
Reference in a new issue