mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-06-25 17:24:44 -04:00
Edit palette fixes
- If the palette has colors, automatically select the first one - When adding a new color button, take the color currently selected on the picker instead of white - Fixes issues with drag&dropping color buttons. The color that was dragged remains selected.
This commit is contained in:
parent
4a2c0eb291
commit
9b73e4f661
9 changed files with 20 additions and 19 deletions
|
@ -12,13 +12,12 @@ var comments : String = ""
|
|||
var editable : bool = true
|
||||
|
||||
func insert_color(index : int, new_color : Color, _name : String = "no name") -> void:
|
||||
if index < colors.size():
|
||||
if index <= colors.size():
|
||||
var c := PaletteColor.new(new_color, _name)
|
||||
colors.insert(index, c)
|
||||
|
||||
func add_color(new_color : Color, _name : String = "no name") -> void:
|
||||
var c := PaletteColor.new(new_color, _name)
|
||||
|
||||
colors.push_back(c)
|
||||
|
||||
func remove_color(index : int) -> void:
|
||||
|
@ -101,7 +100,7 @@ func deserialize(input_string : String) -> Palette:
|
|||
var result = get_script().new()
|
||||
|
||||
var result_json = JSON.parse(input_string)
|
||||
#
|
||||
|
||||
if result_json.error != OK: # If parse has errors
|
||||
print("Error: ", result_json.error)
|
||||
print("Error Line: ", result_json.error_line)
|
||||
|
@ -109,7 +108,7 @@ func deserialize(input_string : String) -> Palette:
|
|||
result = null
|
||||
else: # If parse OK
|
||||
var data = result_json.result
|
||||
if data.has("name"): #If data is 'valid' palette file
|
||||
if data.has("name"): # If data is 'valid' palette file
|
||||
result = get_script().new()
|
||||
result.name = data.name
|
||||
if data.has("comments"):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue