2019-12-20 15:22:52 -05:00
|
|
|
class_name PaletteColor
|
2020-02-11 00:06:24 +02:00
|
|
|
extends Reference
|
2019-12-24 04:08:16 +02:00
|
|
|
|
2019-12-20 15:22:52 -05:00
|
|
|
|
|
|
|
var color : Color = Color.black setget _set_color
|
|
|
|
var data : String = "" setget _set_data
|
|
|
|
var name : String = "no name"
|
|
|
|
|
2020-05-01 20:47:10 +03:00
|
|
|
|
|
|
|
func get_class() -> String:
|
|
|
|
return "PaletteColor"
|
|
|
|
|
|
|
|
|
|
|
|
func is_class(_name : String) -> bool:
|
|
|
|
return _name == "PaletteColor" or .is_class(_name)
|
|
|
|
|
|
|
|
|
|
|
|
func _init(new_color : Color = Color.black, new_name : String = "no name") -> void:
|
2019-12-20 15:22:52 -05:00
|
|
|
self.color = new_color
|
|
|
|
self.name = new_name
|
|
|
|
|
2020-05-01 20:47:10 +03:00
|
|
|
|
2019-12-20 15:22:52 -05:00
|
|
|
func _set_color(new_value : Color) -> void:
|
|
|
|
color = new_value
|
|
|
|
data = color.to_html(true)
|
|
|
|
|
2020-05-01 20:47:10 +03:00
|
|
|
|
2019-12-20 15:22:52 -05:00
|
|
|
func _set_data(new_value : String) -> void:
|
|
|
|
data = new_value
|
|
|
|
color = Color(data)
|
|
|
|
|
2020-05-01 20:47:10 +03:00
|
|
|
|
2019-12-20 15:22:52 -05:00
|
|
|
func toDict() -> Dictionary:
|
|
|
|
var result = {
|
|
|
|
"data" : data,
|
|
|
|
"name" : name
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
|
2020-05-01 20:47:10 +03:00
|
|
|
|
2020-02-04 17:33:34 +02:00
|
|
|
func fromDict(input_dict : Dictionary): # -> PaletteColor
|
2019-12-20 15:22:52 -05:00
|
|
|
var result = get_script().new()
|
2019-12-24 04:08:16 +02:00
|
|
|
|
2019-12-20 15:22:52 -05:00
|
|
|
result.data = input_dict.data
|
|
|
|
result.name = input_dict.name
|
2019-12-24 04:08:16 +02:00
|
|
|
|
2019-12-20 15:22:52 -05:00
|
|
|
return result
|
|
|
|
|
2020-05-01 20:47:10 +03:00
|
|
|
|
2020-02-04 17:33:34 +02:00
|
|
|
func duplicate(): # -> PaletteColor
|
|
|
|
var copy = get_script().new() # : PaletteColor
|
2019-12-20 15:22:52 -05:00
|
|
|
copy.data = data
|
|
|
|
copy.name = name
|
2020-02-04 17:33:34 +02:00
|
|
|
return copy
|