mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-30 23:19:49 +00:00
Lazy load create & edit palette dialogs
This commit is contained in:
parent
07fa1266d3
commit
fd4c7078b2
|
@ -69,7 +69,7 @@ func toggle_ok_button_disability(disable: bool) -> void:
|
|||
|
||||
|
||||
func _on_CreatePaletteDialog_visibility_changed() -> void:
|
||||
Global.dialog_open(false)
|
||||
Global.dialog_open(visible)
|
||||
|
||||
|
||||
func _on_CreatePaletteDialog_confirmed() -> void:
|
||||
|
|
|
@ -30,6 +30,7 @@ var old_name := ""
|
|||
|
||||
|
||||
func _ready() -> void:
|
||||
export_file_dialog.use_native_dialog = Global.use_native_file_dialogs
|
||||
# Add delete and export buttons to edit palette dialog
|
||||
add_button(tr("Delete"), false, DELETE_ACTION)
|
||||
add_button(tr("Export"), false, EXPORT_ACTION)
|
||||
|
@ -79,7 +80,7 @@ func toggle_already_exists_warning(to_show: bool) -> void:
|
|||
|
||||
|
||||
func _on_EditPaletteDialog_visibility_changed() -> void:
|
||||
Global.dialog_open(false)
|
||||
Global.dialog_open(visible)
|
||||
|
||||
|
||||
func _on_EditPaletteDialog_confirmed() -> void:
|
||||
|
|
|
@ -1,12 +1,32 @@
|
|||
class_name PalettePanel
|
||||
extends Container
|
||||
|
||||
const CREATE_PALETTE_SCENE_PATH := "res://src/Palette/CreatePaletteDialog.tscn"
|
||||
const EDIT_PALETTE_SCENE_PATH := "res://src/Palette/EditPaletteDialog.tscn"
|
||||
|
||||
var palettes_path_id := {}
|
||||
var palettes_id_path := {}
|
||||
|
||||
var edited_swatch_index := -1
|
||||
var edited_swatch_color := Color.TRANSPARENT
|
||||
|
||||
var create_palette_dialog: ConfirmationDialog:
|
||||
get:
|
||||
if not is_instance_valid(create_palette_dialog):
|
||||
create_palette_dialog = load(CREATE_PALETTE_SCENE_PATH).instantiate()
|
||||
create_palette_dialog.saved.connect(_on_create_palette_dialog_saved)
|
||||
add_child(create_palette_dialog)
|
||||
return create_palette_dialog
|
||||
var edit_palette_dialog: ConfirmationDialog:
|
||||
get:
|
||||
if not is_instance_valid(edit_palette_dialog):
|
||||
edit_palette_dialog = load(EDIT_PALETTE_SCENE_PATH).instantiate()
|
||||
edit_palette_dialog.deleted.connect(_on_edit_palette_dialog_deleted)
|
||||
edit_palette_dialog.exported.connect(_on_edit_palette_dialog_exported)
|
||||
edit_palette_dialog.saved.connect(_on_edit_palette_dialog_saved)
|
||||
add_child(edit_palette_dialog)
|
||||
return edit_palette_dialog
|
||||
|
||||
@onready var palette_select := $"%PaletteSelect"
|
||||
@onready var palette_grid := $"%PaletteGrid" as PaletteGrid
|
||||
@onready var palette_scroll := $"%PaletteScroll"
|
||||
|
@ -16,9 +36,6 @@ var edited_swatch_color := Color.TRANSPARENT
|
|||
@onready var sort_button := %Sort as MenuButton
|
||||
@onready var sort_button_popup := sort_button.get_popup()
|
||||
|
||||
@onready var edit_palette_dialog := $"%EditPaletteDialog"
|
||||
@onready var create_palette_dialog := $"%CreatePaletteDialog"
|
||||
|
||||
## This color picker button itself is hidden, but its popup is used to edit color swatches.
|
||||
@onready var hidden_color_picker := $"%HiddenColorPickerButton" as ColorPickerButton
|
||||
|
||||
|
@ -166,7 +183,7 @@ func sort_pressed(id: Palettes.SortOptions) -> void:
|
|||
redraw_current_palette()
|
||||
|
||||
|
||||
func _on_CreatePaletteDialog_saved(
|
||||
func _on_create_palette_dialog_saved(
|
||||
preset: int,
|
||||
palette_name: String,
|
||||
comment: String,
|
||||
|
@ -182,7 +199,7 @@ func _on_CreatePaletteDialog_saved(
|
|||
redraw_current_palette()
|
||||
|
||||
|
||||
func _on_EditPaletteDialog_saved(
|
||||
func _on_edit_palette_dialog_saved(
|
||||
palette_name: String, comment: String, width: int, height: int
|
||||
) -> void:
|
||||
Palettes.current_palette_edit(palette_name, comment, width, height)
|
||||
|
@ -242,7 +259,7 @@ func _on_HiddenColorPickerButton_popup_closed() -> void:
|
|||
Palettes.current_palette_set_color(edited_swatch_index, edited_swatch_color)
|
||||
|
||||
|
||||
func _on_EditPaletteDialog_deleted(permanent: bool) -> void:
|
||||
func _on_edit_palette_dialog_deleted(permanent: bool) -> void:
|
||||
Palettes.current_palete_delete(permanent)
|
||||
setup_palettes_selector()
|
||||
redraw_current_palette()
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
[gd_scene load_steps=15 format=3 uid="uid://wplk62pbgih4"]
|
||||
[gd_scene load_steps=13 format=3 uid="uid://wplk62pbgih4"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://c0p84w7umxwt1" path="res://src/Palette/EditPaletteDialog.tscn" id="1"]
|
||||
[ext_resource type="Texture2D" uid="uid://biyn51upnlxle" path="res://assets/graphics/palette/edit.png" id="2"]
|
||||
[ext_resource type="Texture2D" uid="uid://d1urikaf1lxwl" path="res://assets/graphics/timeline/new_frame.png" id="2_j1lig"]
|
||||
[ext_resource type="Texture2D" uid="uid://b7ydn1tt37rcl" path="res://assets/graphics/palette/add.png" id="3"]
|
||||
[ext_resource type="Texture2D" uid="uid://bt72662c3gp2f" path="res://assets/graphics/timeline/remove_frame.png" id="3_0e27e"]
|
||||
[ext_resource type="PackedScene" uid="uid://68aakj2l6ee1" path="res://src/Palette/CreatePaletteDialog.tscn" id="4"]
|
||||
[ext_resource type="Texture2D" uid="uid://db4i3w3yencxg" path="res://assets/graphics/palette/sort.png" id="4_hcsuy"]
|
||||
[ext_resource type="Script" path="res://src/Palette/PaletteGrid.gd" id="5"]
|
||||
[ext_resource type="Script" path="res://src/Palette/PaletteScroll.gd" id="6"]
|
||||
|
@ -218,12 +216,6 @@ step = 1.0
|
|||
page = 8.0
|
||||
custom_step = 1.0
|
||||
|
||||
[node name="EditPaletteDialog" parent="." instance=ExtResource("1")]
|
||||
unique_name_in_owner = true
|
||||
|
||||
[node name="CreatePaletteDialog" parent="." instance=ExtResource("4")]
|
||||
unique_name_in_owner = true
|
||||
|
||||
[node name="HiddenColorPickerButton" type="ColorPickerButton" parent="."]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
|
@ -242,9 +234,5 @@ layout_mode = 2
|
|||
[connection signal="swatch_pressed" from="PaletteVBoxContainer/SwatchesContainer/PaletteScroll/HBoxContainer/VBoxContainer/ScrollContainer/PaletteGrid" to="." method="_on_PaletteGrid_swatch_pressed"]
|
||||
[connection signal="value_changed" from="PaletteVBoxContainer/SwatchesContainer/PaletteScroll/HBoxContainer/VBoxContainer/HScrollBar" to="PaletteVBoxContainer/SwatchesContainer/PaletteScroll" method="_on_HSlider_value_changed"]
|
||||
[connection signal="value_changed" from="PaletteVBoxContainer/SwatchesContainer/PaletteScroll/HBoxContainer/MarginContainer/VScrollBar" to="PaletteVBoxContainer/SwatchesContainer/PaletteScroll" method="_on_VSlider_value_changed"]
|
||||
[connection signal="deleted" from="EditPaletteDialog" to="." method="_on_EditPaletteDialog_deleted"]
|
||||
[connection signal="exported" from="EditPaletteDialog" to="." method="_on_edit_palette_dialog_exported"]
|
||||
[connection signal="saved" from="EditPaletteDialog" to="." method="_on_EditPaletteDialog_saved"]
|
||||
[connection signal="saved" from="CreatePaletteDialog" to="." method="_on_CreatePaletteDialog_saved"]
|
||||
[connection signal="color_changed" from="HiddenColorPickerButton" to="." method="_on_ColorPicker_color_changed"]
|
||||
[connection signal="popup_closed" from="HiddenColorPickerButton" to="." method="_on_HiddenColorPickerButton_popup_closed"]
|
||||
|
|
Loading…
Reference in a new issue