1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-31 07:29:49 +00:00

Rename palettes on EditPalettePopup, removed "Custom" subfolder

This commit is contained in:
OverloadedOrama 2019-12-31 01:24:56 +02:00
parent 129885ddfc
commit 20d643b4ca
7 changed files with 74 additions and 96 deletions

1
Palettes/Default.json Normal file
View file

@ -0,0 +1 @@
{"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"}],"comments":"","editable":true}

View file

@ -1,37 +0,0 @@
{
"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" }
]
}

View file

@ -25,17 +25,17 @@ size_flags_horizontal = 3
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
margin_right = 580.0
margin_bottom = 478.0
margin_bottom = 462.0
size_flags_vertical = 3
[node name="EditPaletteColorPicker" type="ColorPicker" parent="VBoxContainer/HBoxContainer"]
margin_right = 290.0
margin_bottom = 478.0
margin_bottom = 462.0
[node name="Panel" type="Panel" parent="VBoxContainer/HBoxContainer"]
margin_left = 294.0
margin_right = 556.0
margin_bottom = 478.0
margin_bottom = 462.0
size_flags_horizontal = 3
[node name="EditPaletteGridContainer" type="GridContainer" parent="VBoxContainer/HBoxContainer/Panel"]
@ -45,78 +45,95 @@ size_flags_horizontal = 3
size_flags_vertical = 3
columns = 8
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/HBoxContainer"]
[node name="ColorButtons" type="VBoxContainer" parent="VBoxContainer/HBoxContainer"]
margin_left = 560.0
margin_right = 580.0
margin_bottom = 478.0
margin_bottom = 462.0
[node name="AddSwatchButton" type="TextureButton" parent="VBoxContainer/HBoxContainer/VBoxContainer"]
[node name="AddSwatchButton" type="TextureButton" parent="VBoxContainer/HBoxContainer/ColorButtons"]
margin_right = 20.0
margin_bottom = 20.0
texture_normal = ExtResource( 2 )
texture_hover = ExtResource( 3 )
[node name="RemoveSwatchButton" type="TextureButton" parent="VBoxContainer/HBoxContainer/VBoxContainer"]
[node name="RemoveSwatchButton" type="TextureButton" parent="VBoxContainer/HBoxContainer/ColorButtons"]
margin_top = 24.0
margin_right = 20.0
margin_bottom = 44.0
texture_normal = ExtResource( 4 )
texture_hover = ExtResource( 5 )
[node name="HBoxContainer3" type="HBoxContainer" parent="VBoxContainer"]
margin_top = 482.0
[node name="ColorNameContainer" type="HBoxContainer" parent="VBoxContainer"]
margin_top = 466.0
margin_right = 580.0
margin_bottom = 506.0
margin_bottom = 490.0
[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer3"]
[node name="Label" type="Label" parent="VBoxContainer/ColorNameContainer"]
margin_top = 5.0
margin_right = 79.0
margin_bottom = 19.0
text = "Color Name:"
[node name="EditPaletteColorNameLineEdit" type="LineEdit" parent="VBoxContainer/HBoxContainer3"]
[node name="EditPaletteColorNameLineEdit" type="LineEdit" parent="VBoxContainer/ColorNameContainer"]
margin_left = 83.0
margin_right = 580.0
margin_bottom = 24.0
size_flags_horizontal = 3
[node name="HBoxContainer2" type="HBoxContainer" parent="VBoxContainer"]
margin_top = 510.0
[node name="PaletteNameContainer" type="HBoxContainer" parent="VBoxContainer"]
margin_top = 494.0
margin_right = 580.0
margin_bottom = 530.0
margin_bottom = 518.0
[node name="Label" type="Label" parent="VBoxContainer/PaletteNameContainer"]
margin_top = 5.0
margin_right = 91.0
margin_bottom = 19.0
text = "Palette Name:"
[node name="EditPaletteNameLineEdit" type="LineEdit" parent="VBoxContainer/PaletteNameContainer"]
margin_left = 95.0
margin_right = 580.0
margin_bottom = 24.0
size_flags_horizontal = 3
[node name="SpacerControl" type="Control" parent="VBoxContainer/HBoxContainer2"]
[node name="WindowOptionsContainer" type="HBoxContainer" parent="VBoxContainer"]
margin_top = 522.0
margin_right = 580.0
margin_bottom = 542.0
size_flags_horizontal = 3
[node name="SpacerControl" type="Control" parent="VBoxContainer/WindowOptionsContainer"]
margin_right = 156.0
margin_bottom = 20.0
size_flags_horizontal = 3
[node name="EditPaletteSaveButton" type="Button" parent="VBoxContainer/HBoxContainer2"]
[node name="EditPaletteSaveButton" type="Button" parent="VBoxContainer/WindowOptionsContainer"]
margin_left = 160.0
margin_right = 201.0
margin_bottom = 20.0
text = "Save"
[node name="SpacerControl2" type="Control" parent="VBoxContainer/HBoxContainer2"]
[node name="SpacerControl2" type="Control" parent="VBoxContainer/WindowOptionsContainer"]
margin_left = 205.0
margin_right = 361.0
margin_bottom = 20.0
size_flags_horizontal = 3
[node name="EditPaletteCancelButton" type="Button" parent="VBoxContainer/HBoxContainer2"]
[node name="EditPaletteCancelButton" type="Button" parent="VBoxContainer/WindowOptionsContainer"]
margin_left = 365.0
margin_right = 419.0
margin_bottom = 20.0
text = "Cancel"
[node name="SpacerControl3" type="Control" parent="VBoxContainer/HBoxContainer2"]
[node name="SpacerControl3" type="Control" parent="VBoxContainer/WindowOptionsContainer"]
margin_left = 423.0
margin_right = 580.0
margin_bottom = 20.0
size_flags_horizontal = 3
[connection signal="color_changed" from="VBoxContainer/HBoxContainer/EditPaletteColorPicker" to="." method="_on_EditPaletteColorPicker_color_changed"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer/VBoxContainer/AddSwatchButton" to="." method="_on_AddSwatchButton_pressed"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer/VBoxContainer/RemoveSwatchButton" to="." method="_on_RemoveSwatchButton_pressed"]
[connection signal="text_changed" from="VBoxContainer/HBoxContainer3/EditPaletteColorNameLineEdit" to="." method="_on_EditPaletteColorNameLineEdit_text_changed"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer2/EditPaletteSaveButton" to="." method="_on_EditPaletteSaveButton_pressed"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer2/EditPaletteCancelButton" to="." method="_on_EditPaletteCancelButton_pressed"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer/ColorButtons/AddSwatchButton" to="." method="_on_AddSwatchButton_pressed"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer/ColorButtons/RemoveSwatchButton" to="." method="_on_RemoveSwatchButton_pressed"]
[connection signal="text_changed" from="VBoxContainer/ColorNameContainer/EditPaletteColorNameLineEdit" to="." method="_on_EditPaletteColorNameLineEdit_text_changed"]
[connection signal="pressed" from="VBoxContainer/WindowOptionsContainer/EditPaletteSaveButton" to="." method="_on_EditPaletteSaveButton_pressed"]
[connection signal="pressed" from="VBoxContainer/WindowOptionsContainer/EditPaletteCancelButton" to="." method="_on_EditPaletteCancelButton_pressed"]

View file

@ -1,8 +1,9 @@
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
onready var palette_grid = $VBoxContainer/HBoxContainer/Panel/EditPaletteGridContainer
onready var color_name_edit = $VBoxContainer/ColorNameContainer/EditPaletteColorNameLineEdit
onready var palette_name_edit = $VBoxContainer/PaletteNameContainer/EditPaletteNameLineEdit
var palette_button = preload("res://Prefabs/PaletteButton.tscn");
@ -12,11 +13,10 @@ var working_palette : Palette
func open(palette : String) -> void:
current_palette = palette
palette_name_edit.text = current_palette
if Global.palettes.has(palette):
working_palette = Global.palettes[palette].duplicate()
_display_palette()
self.popup_centered()
func _display_palette() -> void:
@ -98,6 +98,19 @@ func re_index_swatches() -> void:
index += 1
func _on_EditPaletteSaveButton_pressed() -> void:
if palette_name_edit.text != current_palette:
Global.palettes.erase(current_palette)
var dir := Directory.new()
dir.open(".")
dir.rename("Palettes".plus_file(current_palette + ".json"), "Palettes".plus_file(palette_name_edit.text + ".json"))
current_palette = palette_name_edit.text
working_palette.name = current_palette
var optionbutton_index = Global.palette_option_button.selected
Global.palette_option_button.set_item_text(optionbutton_index, current_palette)
Global.palette_option_button.set_item_metadata(optionbutton_index, current_palette)
Global.palette_option_button.text = current_palette
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")
@ -106,7 +119,7 @@ func _on_EditPaletteSaveButton_pressed() -> void:
func _on_EditPaletteCancelButton_pressed() -> void:
self.hide()
func _on_EditPaletteColorNameLineEdit_text_changed(new_text) -> void:
func _on_EditPaletteColorNameLineEdit_text_changed(new_text : String) -> void:
if current_swatch >= 0 && current_swatch < working_palette.colors.size():
working_palette.set_color_name(current_swatch, new_text)
_refresh_hint_tooltip(current_swatch)
@ -117,5 +130,5 @@ func _on_EditPaletteColorPicker_color_changed(color : Color) -> void:
working_palette.set_color(current_swatch, color)
_refresh_hint_tooltip(current_swatch)
func _refresh_hint_tooltip(_index : int):
func _refresh_hint_tooltip(_index : int) -> void:
palette_grid.get_child(current_swatch).hint_tooltip = "#" + working_palette.get_color_data(current_swatch).to_upper() + " " + working_palette.get_color_name(current_swatch)

View file

@ -94,7 +94,7 @@ func _serialize() -> String:
result = JSON.print(serialize_data)
return result;
return result
func deserialize(input_string : String) -> Palette:
var result = get_script().new()

View file

@ -8,18 +8,17 @@ 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;
var data = null
if draggable:
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;
set_drag_preview(drag_icon)
return data
func can_drop_data(_position, _data):
return true;
return true
func drop_data(_position, data):
emit_signal("on_drop_data", data.source_index, index);
emit_signal("on_drop_data", data.source_index, index)

View file

@ -2,7 +2,6 @@ extends GridContainer
const palette_button = preload("res://Prefabs/PaletteButton.tscn");
const palettes_path := "Palettes"
const custom_palettes_path := "Palettes/Custom"
var current_palette = "Default"
var from_palette : Palette
@ -91,7 +90,6 @@ func create_new_palette(name : String, _from_palette : Palette) -> String: # Ret
return "Error: Palette '" + name + "' already exists!"
new_palette.name = name
# Check if source palette has data
if _from_palette:
new_palette = _from_palette.duplicate()
@ -139,8 +137,6 @@ func _load_palettes() -> void:
dir.open(".")
if not dir.dir_exists(palettes_path):
dir.make_dir(palettes_path)
if not dir.dir_exists(custom_palettes_path):
dir.make_dir(custom_palettes_path)
var palette_files : Array = get_palette_files(palettes_path)
@ -154,17 +150,6 @@ func _load_palettes() -> void:
if palette.name == "Default":
Global.palette_option_button.select(index)
dir.open(custom_palettes_path)
var custom_palette_files : Array = get_palette_files(custom_palettes_path)
for file_name in custom_palette_files:
var palette : Palette = Palette.new().load_from_file(custom_palettes_path.plus_file(file_name))
if palette:
Global.palettes[palette.name] = palette
Global.palette_option_button.add_item(palette.name)
var index: int = Global.palette_option_button.get_item_count() - 1
Global.palette_option_button.set_item_metadata(index, palette.name)
if not "Default" in Global.palettes && Global.palettes.size() > 0:
Global.control._on_PaletteOptionButton_item_selected(0)
@ -187,4 +172,4 @@ func get_palette_files(path : String) -> Array:
func save_palette(palette_name : String, filename : String) -> void:
var palette = Global.palettes[palette_name]
palette.save_to_file(custom_palettes_path.plus_file(filename))
palette.save_to_file(palettes_path.plus_file(filename))