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:
OverloadedOrama 2019-12-26 02:01:04 +02:00
parent 4a2c0eb291
commit 9b73e4f661
9 changed files with 20 additions and 19 deletions

View file

@ -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"):