mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-31 07:29:49 +00:00
Better signal representation (#971)
* Update 3DShapeEdit.tscn Change the menu button to flat to indicate that it is a button that you can press and not a label * Changed Signal names to make sense Note: I did not change functions in the ExtensionsAPI Changed signals in Global.gd (and everywhere else they are referenced) from *_changed to *_switched * Bonus Signal Added a signal in Global.gd that gets emitted just before the project is changed. Added project_changed to Global.gd which also emits what project was changed by an action (not switched). * Formatting
This commit is contained in:
parent
ae9449500a
commit
f373dae714
|
@ -713,8 +713,8 @@ class SignalsAPI:
|
||||||
var _last_cel: BaseCel
|
var _last_cel: BaseCel
|
||||||
|
|
||||||
func _init() -> void:
|
func _init() -> void:
|
||||||
Global.project_changed.connect(_update_texture_signal)
|
Global.project_switched.connect(_update_texture_signal)
|
||||||
Global.cel_changed.connect(_update_texture_signal)
|
Global.cel_switched.connect(_update_texture_signal)
|
||||||
|
|
||||||
func _update_texture_signal():
|
func _update_texture_signal():
|
||||||
if _last_cel:
|
if _last_cel:
|
||||||
|
@ -760,12 +760,12 @@ class SignalsAPI:
|
||||||
## connects/disconnects a signal to [param callable], that emits
|
## connects/disconnects a signal to [param callable], that emits
|
||||||
## whenever you switch to some other project.
|
## whenever you switch to some other project.
|
||||||
func signal_project_changed(callable: Callable, is_disconnecting := false):
|
func signal_project_changed(callable: Callable, is_disconnecting := false):
|
||||||
_connect_disconnect(Global.project_changed, callable, is_disconnecting)
|
_connect_disconnect(Global.project_switched, callable, is_disconnecting)
|
||||||
|
|
||||||
## connects/disconnects a signal to [param callable], that emits
|
## connects/disconnects a signal to [param callable], that emits
|
||||||
## whenever you select a different cel.
|
## whenever you select a different cel.
|
||||||
func signal_cel_changed(callable: Callable, is_disconnecting := false):
|
func signal_cel_changed(callable: Callable, is_disconnecting := false):
|
||||||
_connect_disconnect(Global.cel_changed, callable, is_disconnecting)
|
_connect_disconnect(Global.cel_switched, callable, is_disconnecting)
|
||||||
|
|
||||||
# TOOL RELATED SIGNALS
|
# TOOL RELATED SIGNALS
|
||||||
## connects/disconnects a signal to [param callable], that emits
|
## connects/disconnects a signal to [param callable], that emits
|
||||||
|
|
|
@ -8,8 +8,10 @@ extends Node
|
||||||
signal pixelorama_opened ## Emitted as soon as Pixelorama fully opens up.
|
signal pixelorama_opened ## Emitted as soon as Pixelorama fully opens up.
|
||||||
signal pixelorama_about_to_close ## Emitted just before Pixelorama is about to close.
|
signal pixelorama_about_to_close ## Emitted just before Pixelorama is about to close.
|
||||||
signal project_created(Project) ## Emitted when a new project class is initialized.
|
signal project_created(Project) ## Emitted when a new project class is initialized.
|
||||||
signal project_changed ## Emitted whenever you switch to some other project tab.
|
signal project_about_to_switch ## Emitted before a project is about to be switched
|
||||||
signal cel_changed ## Emitted whenever you select a different cel.
|
signal project_switched ## Emitted whenever you switch to some other project tab.
|
||||||
|
signal cel_switched ## Emitted whenever you select a different cel.
|
||||||
|
signal project_changed(Project) ## Emitted whenever a project is changed.
|
||||||
|
|
||||||
enum LayerTypes { PIXEL, GROUP, THREE_D }
|
enum LayerTypes { PIXEL, GROUP, THREE_D }
|
||||||
enum GridTypes { CARTESIAN, ISOMETRIC, ALL }
|
enum GridTypes { CARTESIAN, ISOMETRIC, ALL }
|
||||||
|
@ -95,11 +97,12 @@ var current_project_index := 0:
|
||||||
return
|
return
|
||||||
canvas.selection.transform_content_confirm()
|
canvas.selection.transform_content_confirm()
|
||||||
current_project_index = value
|
current_project_index = value
|
||||||
|
project_about_to_switch.emit()
|
||||||
current_project = projects[value]
|
current_project = projects[value]
|
||||||
project_changed.connect(current_project.change_project)
|
project_switched.connect(current_project.change_project)
|
||||||
project_changed.emit()
|
project_switched.emit()
|
||||||
project_changed.disconnect(current_project.change_project)
|
project_switched.disconnect(current_project.change_project)
|
||||||
cel_changed.emit()
|
cel_switched.emit()
|
||||||
|
|
||||||
# Canvas related stuff
|
# Canvas related stuff
|
||||||
## Tells if the user allowed to draw on the canvas. Usually it is temporarily set to
|
## Tells if the user allowed to draw on the canvas. Usually it is temporarily set to
|
||||||
|
@ -544,7 +547,7 @@ func _ready() -> void:
|
||||||
current_project.fill_color = default_fill_color
|
current_project.fill_color = default_fill_color
|
||||||
|
|
||||||
await get_tree().process_frame
|
await get_tree().process_frame
|
||||||
project_changed.emit()
|
project_switched.emit()
|
||||||
|
|
||||||
|
|
||||||
func _initialize_keychain() -> void:
|
func _initialize_keychain() -> void:
|
||||||
|
@ -774,9 +777,9 @@ func undo_or_redo(
|
||||||
second_viewport.get_child(0).get_node("CanvasPreview").queue_redraw()
|
second_viewport.get_child(0).get_node("CanvasPreview").queue_redraw()
|
||||||
canvas_preview_container.canvas_preview.queue_redraw()
|
canvas_preview_container.canvas_preview.queue_redraw()
|
||||||
if !project.has_changed:
|
if !project.has_changed:
|
||||||
project.has_changed = true
|
|
||||||
if project == current_project:
|
if project == current_project:
|
||||||
main_window.title = main_window.title + "(*)"
|
main_window.title = main_window.title + "(*)"
|
||||||
|
project.has_changed = true
|
||||||
|
|
||||||
|
|
||||||
func _renderer_changed(value: int) -> void:
|
func _renderer_changed(value: int) -> void:
|
||||||
|
|
|
@ -220,8 +220,8 @@ func open_pxo_file(path: String, untitled_backup := false, replace_empty := true
|
||||||
|
|
||||||
if empty_project:
|
if empty_project:
|
||||||
new_project.change_project()
|
new_project.change_project()
|
||||||
Global.project_changed.emit()
|
Global.project_switched.emit()
|
||||||
Global.cel_changed.emit()
|
Global.cel_switched.emit()
|
||||||
else:
|
else:
|
||||||
Global.projects.append(new_project)
|
Global.projects.append(new_project)
|
||||||
Global.tabs.current_tab = Global.tabs.get_tab_count() - 1
|
Global.tabs.current_tab = Global.tabs.get_tab_count() - 1
|
||||||
|
|
|
@ -297,7 +297,7 @@ class Slot:
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
Global.cel_changed.connect(_cel_changed)
|
Global.cel_switched.connect(_cel_switched)
|
||||||
_tool_buttons = Global.control.find_child("ToolButtons")
|
_tool_buttons = Global.control.find_child("ToolButtons")
|
||||||
for t in tools:
|
for t in tools:
|
||||||
add_tool_button(tools[t])
|
add_tool_button(tools[t])
|
||||||
|
@ -558,7 +558,7 @@ func get_alpha_dynamic(strength := 1.0) -> float:
|
||||||
return strength
|
return strength
|
||||||
|
|
||||||
|
|
||||||
func _cel_changed() -> void:
|
func _cel_switched() -> void:
|
||||||
var layer: BaseLayer = Global.current_project.layers[Global.current_project.current_layer]
|
var layer: BaseLayer = Global.current_project.layers[Global.current_project.current_layer]
|
||||||
var layer_type := layer.get_layer_type()
|
var layer_type := layer.get_layer_type()
|
||||||
# Do not make any changes when its the same type of layer, or a group layer
|
# Do not make any changes when its the same type of layer, or a group layer
|
||||||
|
|
|
@ -23,6 +23,7 @@ var has_changed := false:
|
||||||
set(value):
|
set(value):
|
||||||
has_changed = value
|
has_changed = value
|
||||||
if value:
|
if value:
|
||||||
|
Global.project_changed.emit(self)
|
||||||
Global.tabs.set_tab_title(Global.tabs.current_tab, name + "(*)")
|
Global.tabs.set_tab_title(Global.tabs.current_tab, name + "(*)")
|
||||||
else:
|
else:
|
||||||
Global.tabs.set_tab_title(Global.tabs.current_tab, name)
|
Global.tabs.set_tab_title(Global.tabs.current_tab, name)
|
||||||
|
@ -541,7 +542,7 @@ func change_cel(new_frame: int, new_layer := -1) -> void:
|
||||||
|
|
||||||
order_layers()
|
order_layers()
|
||||||
Global.transparent_checker.update_rect()
|
Global.transparent_checker.update_rect()
|
||||||
Global.cel_changed.emit()
|
Global.cel_switched.emit()
|
||||||
if get_current_cel() is Cel3D:
|
if get_current_cel() is Cel3D:
|
||||||
await RenderingServer.frame_post_draw
|
await RenderingServer.frame_post_draw
|
||||||
await RenderingServer.frame_post_draw
|
await RenderingServer.frame_post_draw
|
||||||
|
|
|
@ -89,8 +89,8 @@ func _input(_event: InputEvent) -> void:
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
super._ready()
|
super._ready()
|
||||||
Global.cel_changed.connect(_cel_changed)
|
Global.cel_switched.connect(_cel_switched)
|
||||||
_cel_changed()
|
_cel_switched()
|
||||||
var new_object_popup := new_object_menu_button.get_popup()
|
var new_object_popup := new_object_menu_button.get_popup()
|
||||||
for object in _object_names:
|
for object in _object_names:
|
||||||
new_object_popup.add_item(_object_names[object], object)
|
new_object_popup.add_item(_object_names[object], object)
|
||||||
|
@ -214,7 +214,7 @@ func _on_ObjectOptionButton_item_selected(index: int) -> void:
|
||||||
_cel.selected = object
|
_cel.selected = object
|
||||||
|
|
||||||
|
|
||||||
func _cel_changed() -> void:
|
func _cel_switched() -> void:
|
||||||
if not Global.current_project.get_current_cel() is Cel3D:
|
if not Global.current_project.get_current_cel() is Cel3D:
|
||||||
get_child(0).visible = false # Just to ensure that the content of the tool is hidden
|
get_child(0).visible = false # Just to ensure that the content of the tool is hidden
|
||||||
return
|
return
|
||||||
|
|
|
@ -31,7 +31,7 @@ var layer_metadata_texture := ImageTexture.new()
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
material.set_shader_parameter("layers", layer_texture_array)
|
material.set_shader_parameter("layers", layer_texture_array)
|
||||||
material.set_shader_parameter("metadata", layer_metadata_texture)
|
material.set_shader_parameter("metadata", layer_metadata_texture)
|
||||||
Global.project_changed.connect(queue_redraw)
|
Global.project_switched.connect(queue_redraw)
|
||||||
onion_past.type = onion_past.PAST
|
onion_past.type = onion_past.PAST
|
||||||
onion_past.blue_red_color = Global.onion_skinning_past_color
|
onion_past.blue_red_color = Global.onion_skinning_past_color
|
||||||
onion_future.type = onion_future.FUTURE
|
onion_future.type = onion_future.FUTURE
|
||||||
|
|
|
@ -26,7 +26,7 @@ var frame_index := 0:
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
Global.cel_changed.connect(_cel_changed)
|
Global.cel_switched.connect(_cel_switched)
|
||||||
material = Global.canvas.material
|
material = Global.canvas.material
|
||||||
|
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ func _on_AnimationTimer_timeout() -> void:
|
||||||
queue_redraw()
|
queue_redraw()
|
||||||
|
|
||||||
|
|
||||||
func _cel_changed() -> void:
|
func _cel_switched() -> void:
|
||||||
queue_redraw()
|
queue_redraw()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ var tool_count := 0:
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
updated.connect(queue_redraw)
|
updated.connect(queue_redraw)
|
||||||
Global.project_changed.connect(reset)
|
Global.project_switched.connect(reset)
|
||||||
mode = Global.config_cache.get_value("preferences", "crop_mode", 0)
|
mode = Global.config_cache.get_value("preferences", "crop_mode", 0)
|
||||||
locked_size = Global.config_cache.get_value("preferences", "crop_locked_size", false)
|
locked_size = Global.config_cache.get_value("preferences", "crop_locked_size", false)
|
||||||
reset()
|
reset()
|
||||||
|
|
|
@ -33,7 +33,7 @@ var gizmo_rot_z := PackedVector2Array()
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
set_process_input(false)
|
set_process_input(false)
|
||||||
Global.cel_changed.connect(_cel_changed)
|
Global.cel_switched.connect(_cel_switched)
|
||||||
Global.camera.zoom_changed.connect(queue_redraw)
|
Global.camera.zoom_changed.connect(queue_redraw)
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ func get_hovering_gizmo(pos: Vector2) -> int:
|
||||||
return Cel3DObject.Gizmos.NONE
|
return Cel3DObject.Gizmos.NONE
|
||||||
|
|
||||||
|
|
||||||
func _cel_changed() -> void:
|
func _cel_switched() -> void:
|
||||||
queue_redraw()
|
queue_redraw()
|
||||||
set_process_input(Global.current_project.get_current_cel() is Cel3D)
|
set_process_input(Global.current_project.get_current_cel() is Cel3D)
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ extends Node2D
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
Global.project_changed.connect(queue_redraw)
|
Global.project_switched.connect(queue_redraw)
|
||||||
|
|
||||||
|
|
||||||
func _draw() -> void:
|
func _draw() -> void:
|
||||||
|
|
|
@ -10,7 +10,7 @@ var last: Vector2
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
Global.project_changed.connect(queue_redraw)
|
Global.project_switched.connect(queue_redraw)
|
||||||
|
|
||||||
|
|
||||||
func _gui_input(event: InputEvent) -> void:
|
func _gui_input(event: InputEvent) -> void:
|
||||||
|
|
|
@ -10,7 +10,7 @@ var last: Vector2
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
Global.project_changed.connect(queue_redraw)
|
Global.project_switched.connect(queue_redraw)
|
||||||
|
|
||||||
|
|
||||||
func _gui_input(event: InputEvent) -> void:
|
func _gui_input(event: InputEvent) -> void:
|
||||||
|
|
|
@ -9,8 +9,8 @@ extends ConfirmationDialog
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
Global.project_changed.connect(change_mask)
|
Global.project_switched.connect(change_mask)
|
||||||
Global.cel_changed.connect(change_mask)
|
Global.cel_switched.connect(change_mask)
|
||||||
await get_tree().process_frame
|
await get_tree().process_frame
|
||||||
change_mask()
|
change_mask()
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ func _ready() -> void:
|
||||||
# emit signals that were supposed to be emitted (Check if it's still required in godot 4)
|
# emit signals that were supposed to be emitted (Check if it's still required in godot 4)
|
||||||
%PastPlacement.item_selected.emit(0 if past_above else 1)
|
%PastPlacement.item_selected.emit(0 if past_above else 1)
|
||||||
%FuturePlacement.item_selected.emit(0 if future_above else 1)
|
%FuturePlacement.item_selected.emit(0 if future_above else 1)
|
||||||
Global.cel_changed.connect(_cel_changed)
|
Global.cel_switched.connect(_cel_switched)
|
||||||
# Makes sure that the frame and tag scroll bars are in the right place:
|
# Makes sure that the frame and tag scroll bars are in the right place:
|
||||||
Global.layer_vbox.emit_signal.call_deferred("resized")
|
Global.layer_vbox.emit_signal.call_deferred("resized")
|
||||||
|
|
||||||
|
@ -1015,7 +1015,7 @@ func _on_onion_skinning_settings_visibility_changed() -> void:
|
||||||
# Methods to update the UI in response to changes in the current project
|
# Methods to update the UI in response to changes in the current project
|
||||||
|
|
||||||
|
|
||||||
func _cel_changed() -> void:
|
func _cel_switched() -> void:
|
||||||
_toggle_frame_buttons()
|
_toggle_frame_buttons()
|
||||||
_toggle_layer_buttons()
|
_toggle_layer_buttons()
|
||||||
var project := Global.current_project
|
var project := Global.current_project
|
||||||
|
|
Loading…
Reference in a new issue