mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-03-12 22:35:18 +00:00
Fixed variable shadowing warnings in some palette scripts
This commit is contained in:
parent
27ab9d14d7
commit
014afc47fb
4 changed files with 20 additions and 26 deletions
|
@ -18,7 +18,6 @@ func open(palette : String) -> void:
|
|||
_display_palette()
|
||||
|
||||
self.popup_centered()
|
||||
pass
|
||||
|
||||
func _display_palette() -> void:
|
||||
_clear_swatches()
|
||||
|
@ -49,7 +48,6 @@ func on_swatch_select(index : int) -> void:
|
|||
current_swatch = index
|
||||
color_name_edit.text = working_palette.get_color_name(index)
|
||||
color_picker.color = working_palette.get_color(index)
|
||||
pass
|
||||
|
||||
func on_move_swatch(from : int, to : int) -> void:
|
||||
working_palette.move_color(from, to)
|
||||
|
@ -61,13 +59,12 @@ func on_move_swatch(from : int, to : int) -> void:
|
|||
for child in palette_grid.get_children():
|
||||
child.index = index
|
||||
index += 1
|
||||
pass
|
||||
|
||||
func _on_AddSwatchButton_pressed() -> void:
|
||||
var color = Color.white
|
||||
var new_index : int = working_palette.colors.size()
|
||||
working_palette.add_color(color)
|
||||
|
||||
|
||||
var new_button = palette_button.instance()
|
||||
|
||||
new_button.color = color
|
||||
|
@ -80,37 +77,30 @@ func _on_AddSwatchButton_pressed() -> void:
|
|||
new_button.connect("pressed", self, "on_swatch_select", [index])
|
||||
|
||||
palette_grid.add_child(new_button)
|
||||
pass # Replace with function body.
|
||||
|
||||
func _on_RemoveSwatchButton_pressed() -> void:
|
||||
working_palette.remove_color(current_swatch)
|
||||
palette_grid.remove_child(palette_grid.get_child(current_swatch))
|
||||
pass # Replace with function body.
|
||||
|
||||
func _on_EditPaletteSaveButton_pressed() -> void:
|
||||
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")
|
||||
self.hide()
|
||||
pass # Replace with function body.
|
||||
|
||||
func _on_EditPaletteCancelButton_pressed() -> void:
|
||||
self.hide()
|
||||
pass # Replace with function body.
|
||||
|
||||
func _on_EditPaletteColorNameLineEdit_text_changed(new_text) -> 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)
|
||||
pass
|
||||
|
||||
func _on_EditPaletteColorPicker_color_changed(color) -> void:
|
||||
if current_swatch >= 0 && current_swatch < working_palette.colors.size():
|
||||
palette_grid.get_child(current_swatch).get_child(0).modulate = color
|
||||
working_palette.set_color(current_swatch, color)
|
||||
_refresh_hint_tooltip(current_swatch)
|
||||
pass
|
||||
|
||||
func _refresh_hint_tooltip(index : int):
|
||||
palette_grid.get_child(current_swatch).hint_tooltip = "#" + working_palette.get_color_data(current_swatch).to_upper() + " " + working_palette.get_color_name(current_swatch)
|
||||
pass
|
||||
|
|
|
@ -1,21 +1,23 @@
|
|||
extends Reference
|
||||
|
||||
class_name Palette
|
||||
func get_class(): return "Palette"
|
||||
func is_class(name): return name == "Palette" or .is_class(name)
|
||||
|
||||
func get_class():
|
||||
return "Palette"
|
||||
func is_class(_name):
|
||||
return _name == "Palette" or .is_class(_name)
|
||||
|
||||
var name : String = "Custom_Palette"
|
||||
var colors : Array = []
|
||||
var comments : String = ""
|
||||
var editable : bool = true
|
||||
|
||||
func insert_color(index : int, new_color : Color, name : String = "no name") -> void:
|
||||
func insert_color(index : int, new_color : Color, _name : String = "no name") -> void:
|
||||
if index < colors.size():
|
||||
var c := PaletteColor.new(new_color, name)
|
||||
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)
|
||||
func add_color(new_color : Color, _name : String = "no name") -> void:
|
||||
var c := PaletteColor.new(new_color, _name)
|
||||
|
||||
colors.push_back(c)
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
extends Reference
|
||||
|
||||
class_name PaletteColor
|
||||
func get_class(): return "PaletteColor"
|
||||
func is_class(name): return name == "PaletteColor" or .is_class(name)
|
||||
|
||||
func get_class():
|
||||
return "PaletteColor"
|
||||
func is_class(_name):
|
||||
return _name == "PaletteColor" or .is_class(_name)
|
||||
|
||||
var color : Color = Color.black setget _set_color
|
||||
var data : String = "" setget _set_data
|
||||
|
@ -29,10 +31,10 @@ func toDict() -> Dictionary:
|
|||
|
||||
func fromDict(input_dict : Dictionary) -> PaletteColor:
|
||||
var result = get_script().new()
|
||||
|
||||
|
||||
result.data = input_dict.data
|
||||
result.name = input_dict.name
|
||||
|
||||
|
||||
return result
|
||||
|
||||
func duplicate() -> PaletteColor:
|
||||
|
|
|
@ -92,7 +92,7 @@ func on_new_palette_confirmed() -> void:
|
|||
Global.error_dialog.set_text(result);
|
||||
Global.error_dialog.popup_centered()
|
||||
|
||||
func create_new_palette(name : String, from_palette : Palette) -> String: # Returns empty string, else error string
|
||||
func create_new_palette(name : String, _from_palette : Palette) -> String: # Returns empty string, else error string
|
||||
var new_palette : Palette = Palette.new()
|
||||
|
||||
# Check if new name is valid
|
||||
|
@ -104,8 +104,8 @@ func create_new_palette(name : String, from_palette : Palette) -> String: # Retu
|
|||
new_palette.name = name
|
||||
|
||||
# Check if source palette has data
|
||||
if from_palette:
|
||||
new_palette = from_palette.duplicate()
|
||||
if _from_palette:
|
||||
new_palette = _from_palette.duplicate()
|
||||
new_palette.name = name
|
||||
new_palette.editable = true
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue