1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-30 23:19: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:
TheLsbt 2024-01-09 00:22:56 +02:00 committed by GitHub
parent ae9449500a
commit f373dae714
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 37 additions and 33 deletions

View file

@ -713,8 +713,8 @@ class SignalsAPI:
var _last_cel: BaseCel
func _init() -> void:
Global.project_changed.connect(_update_texture_signal)
Global.cel_changed.connect(_update_texture_signal)
Global.project_switched.connect(_update_texture_signal)
Global.cel_switched.connect(_update_texture_signal)
func _update_texture_signal():
if _last_cel:
@ -760,12 +760,12 @@ class SignalsAPI:
## connects/disconnects a signal to [param callable], that emits
## whenever you switch to some other project.
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
## whenever you select a different cel.
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
## connects/disconnects a signal to [param callable], that emits

View file

@ -8,8 +8,10 @@ extends Node
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 project_created(Project) ## Emitted when a new project class is initialized.
signal project_changed ## Emitted whenever you switch to some other project tab.
signal cel_changed ## Emitted whenever you select a different cel.
signal project_about_to_switch ## Emitted before a project is about to be switched
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 GridTypes { CARTESIAN, ISOMETRIC, ALL }
@ -95,11 +97,12 @@ var current_project_index := 0:
return
canvas.selection.transform_content_confirm()
current_project_index = value
project_about_to_switch.emit()
current_project = projects[value]
project_changed.connect(current_project.change_project)
project_changed.emit()
project_changed.disconnect(current_project.change_project)
cel_changed.emit()
project_switched.connect(current_project.change_project)
project_switched.emit()
project_switched.disconnect(current_project.change_project)
cel_switched.emit()
# Canvas related stuff
## 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
await get_tree().process_frame
project_changed.emit()
project_switched.emit()
func _initialize_keychain() -> void:
@ -774,9 +777,9 @@ func undo_or_redo(
second_viewport.get_child(0).get_node("CanvasPreview").queue_redraw()
canvas_preview_container.canvas_preview.queue_redraw()
if !project.has_changed:
project.has_changed = true
if project == current_project:
main_window.title = main_window.title + "(*)"
project.has_changed = true
func _renderer_changed(value: int) -> void:

View file

@ -220,8 +220,8 @@ func open_pxo_file(path: String, untitled_backup := false, replace_empty := true
if empty_project:
new_project.change_project()
Global.project_changed.emit()
Global.cel_changed.emit()
Global.project_switched.emit()
Global.cel_switched.emit()
else:
Global.projects.append(new_project)
Global.tabs.current_tab = Global.tabs.get_tab_count() - 1

View file

@ -297,7 +297,7 @@ class Slot:
func _ready() -> void:
Global.cel_changed.connect(_cel_changed)
Global.cel_switched.connect(_cel_switched)
_tool_buttons = Global.control.find_child("ToolButtons")
for t in tools:
add_tool_button(tools[t])
@ -558,7 +558,7 @@ func get_alpha_dynamic(strength := 1.0) -> float:
return strength
func _cel_changed() -> void:
func _cel_switched() -> void:
var layer: BaseLayer = Global.current_project.layers[Global.current_project.current_layer]
var layer_type := layer.get_layer_type()
# Do not make any changes when its the same type of layer, or a group layer

View file

@ -23,6 +23,7 @@ var has_changed := false:
set(value):
has_changed = value
if value:
Global.project_changed.emit(self)
Global.tabs.set_tab_title(Global.tabs.current_tab, name + "(*)")
else:
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()
Global.transparent_checker.update_rect()
Global.cel_changed.emit()
Global.cel_switched.emit()
if get_current_cel() is Cel3D:
await RenderingServer.frame_post_draw
await RenderingServer.frame_post_draw

View file

@ -89,8 +89,8 @@ func _input(_event: InputEvent) -> void:
func _ready() -> void:
super._ready()
Global.cel_changed.connect(_cel_changed)
_cel_changed()
Global.cel_switched.connect(_cel_switched)
_cel_switched()
var new_object_popup := new_object_menu_button.get_popup()
for object in _object_names:
new_object_popup.add_item(_object_names[object], object)
@ -214,7 +214,7 @@ func _on_ObjectOptionButton_item_selected(index: int) -> void:
_cel.selected = object
func _cel_changed() -> void:
func _cel_switched() -> void:
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
return

View file

@ -31,7 +31,7 @@ var layer_metadata_texture := ImageTexture.new()
func _ready() -> void:
material.set_shader_parameter("layers", layer_texture_array)
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.blue_red_color = Global.onion_skinning_past_color
onion_future.type = onion_future.FUTURE

View file

@ -26,7 +26,7 @@ var frame_index := 0:
func _ready() -> void:
Global.cel_changed.connect(_cel_changed)
Global.cel_switched.connect(_cel_switched)
material = Global.canvas.material
@ -130,7 +130,7 @@ func _on_AnimationTimer_timeout() -> void:
queue_redraw()
func _cel_changed() -> void:
func _cel_switched() -> void:
queue_redraw()

View file

@ -28,7 +28,7 @@ var tool_count := 0:
func _ready() -> void:
updated.connect(queue_redraw)
Global.project_changed.connect(reset)
Global.project_switched.connect(reset)
mode = Global.config_cache.get_value("preferences", "crop_mode", 0)
locked_size = Global.config_cache.get_value("preferences", "crop_locked_size", false)
reset()

View file

@ -33,7 +33,7 @@ var gizmo_rot_z := PackedVector2Array()
func _ready() -> void:
set_process_input(false)
Global.cel_changed.connect(_cel_changed)
Global.cel_switched.connect(_cel_switched)
Global.camera.zoom_changed.connect(queue_redraw)
@ -68,7 +68,7 @@ func get_hovering_gizmo(pos: Vector2) -> int:
return Cel3DObject.Gizmos.NONE
func _cel_changed() -> void:
func _cel_switched() -> void:
queue_redraw()
set_process_input(Global.current_project.get_current_cel() is Cel3D)

View file

@ -2,7 +2,7 @@ extends Node2D
func _ready() -> void:
Global.project_changed.connect(queue_redraw)
Global.project_switched.connect(queue_redraw)
func _draw() -> void:

View file

@ -10,7 +10,7 @@ var last: Vector2
func _ready() -> void:
Global.project_changed.connect(queue_redraw)
Global.project_switched.connect(queue_redraw)
func _gui_input(event: InputEvent) -> void:

View file

@ -10,7 +10,7 @@ var last: Vector2
func _ready() -> void:
Global.project_changed.connect(queue_redraw)
Global.project_switched.connect(queue_redraw)
func _gui_input(event: InputEvent) -> void:

View file

@ -9,8 +9,8 @@ extends ConfirmationDialog
func _ready() -> void:
Global.project_changed.connect(change_mask)
Global.cel_changed.connect(change_mask)
Global.project_switched.connect(change_mask)
Global.cel_switched.connect(change_mask)
await get_tree().process_frame
change_mask()

View file

@ -106,7 +106,7 @@ func _ready() -> void:
# 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)
%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:
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
func _cel_changed() -> void:
func _cel_switched() -> void:
_toggle_frame_buttons()
_toggle_layer_buttons()
var project := Global.current_project