mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-31 07:29:49 +00:00
Remove some unneeded yield() calls
And minor changes to make the code a tiny bit more clean. I tested this PR, but it still might be a bit risky.
This commit is contained in:
parent
0081aa365a
commit
f4c903771d
|
@ -71,28 +71,29 @@ var alt := false
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
_tool_buttons = Global.control.find_node("ToolButtons")
|
_tool_buttons = Global.control.find_node("ToolButtons")
|
||||||
yield(get_tree(), "idle_frame")
|
|
||||||
_slots[BUTTON_LEFT] = Slot.new("Left tool")
|
_slots[BUTTON_LEFT] = Slot.new("Left tool")
|
||||||
_slots[BUTTON_RIGHT] = Slot.new("Right tool")
|
_slots[BUTTON_RIGHT] = Slot.new("Right tool")
|
||||||
_panels[BUTTON_LEFT] = Global.control.find_node("LeftPanelContainer", true, false)
|
_panels[BUTTON_LEFT] = Global.control.find_node("LeftPanelContainer", true, false)
|
||||||
_panels[BUTTON_RIGHT] = Global.control.find_node("RightPanelContainer", true, false)
|
_panels[BUTTON_RIGHT] = Global.control.find_node("RightPanelContainer", true, false)
|
||||||
|
|
||||||
var value = Global.config_cache.get_value(_slots[BUTTON_LEFT].kname, "tool", "Pencil")
|
var tool_name : String = Global.config_cache.get_value(_slots[BUTTON_LEFT].kname, "tool", "Pencil")
|
||||||
if not value in _tools:
|
if not tool_name in _tools:
|
||||||
value = "Pencil"
|
tool_name = "Pencil"
|
||||||
set_tool(value, BUTTON_LEFT)
|
set_tool(tool_name, BUTTON_LEFT)
|
||||||
value = Global.config_cache.get_value(_slots[BUTTON_RIGHT].kname, "tool", "Eraser")
|
tool_name = Global.config_cache.get_value(_slots[BUTTON_RIGHT].kname, "tool", "Eraser")
|
||||||
if not value in _tools:
|
if not tool_name in _tools:
|
||||||
value = "Eraser"
|
tool_name = "Eraser"
|
||||||
set_tool(value, BUTTON_RIGHT)
|
set_tool(tool_name, BUTTON_RIGHT)
|
||||||
value = Global.config_cache.get_value(_slots[BUTTON_LEFT].kname, "color", Color.black)
|
|
||||||
assign_color(value, BUTTON_LEFT, false)
|
|
||||||
value = Global.config_cache.get_value(_slots[BUTTON_RIGHT].kname, "color", Color.white)
|
|
||||||
assign_color(value, BUTTON_RIGHT, false)
|
|
||||||
|
|
||||||
update_tool_buttons()
|
update_tool_buttons()
|
||||||
update_tool_cursors()
|
update_tool_cursors()
|
||||||
|
|
||||||
|
yield(get_tree(), "idle_frame") # Necessary for the color picker nodes to update their color values
|
||||||
|
var color_value : Color = Global.config_cache.get_value(_slots[BUTTON_LEFT].kname, "color", Color.black)
|
||||||
|
assign_color(color_value, BUTTON_LEFT, false)
|
||||||
|
color_value = Global.config_cache.get_value(_slots[BUTTON_RIGHT].kname, "color", Color.white)
|
||||||
|
assign_color(color_value, BUTTON_RIGHT, false)
|
||||||
|
|
||||||
|
|
||||||
func set_tool(name : String, button : int) -> void:
|
func set_tool(name : String, button : int) -> void:
|
||||||
var slot = _slots[button]
|
var slot = _slots[button]
|
||||||
|
|
17
src/Main.gd
17
src/Main.gd
|
@ -21,7 +21,7 @@ onready var scroll_container := $MenuAndUI/UI/RightPanel/MarginContainer/Preview
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
var alternate_transparent_background = ColorRect.new()
|
var alternate_transparent_background := ColorRect.new()
|
||||||
add_child(alternate_transparent_background)
|
add_child(alternate_transparent_background)
|
||||||
move_child(alternate_transparent_background,0)
|
move_child(alternate_transparent_background,0)
|
||||||
alternate_transparent_background.visible = false
|
alternate_transparent_background.visible = false
|
||||||
|
@ -66,10 +66,6 @@ func _ready() -> void:
|
||||||
zstd_checkbox.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
|
zstd_checkbox.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
|
||||||
Global.save_sprites_dialog.get_vbox().add_child(zstd_checkbox)
|
Global.save_sprites_dialog.get_vbox().add_child(zstd_checkbox)
|
||||||
|
|
||||||
if not Global.config_cache.has_section_key("preferences", "startup"):
|
|
||||||
Global.config_cache.set_value("preferences", "startup", true)
|
|
||||||
show_splash_screen()
|
|
||||||
|
|
||||||
handle_backup()
|
handle_backup()
|
||||||
|
|
||||||
# If the user wants to run Pixelorama with arguments in terminal mode
|
# If the user wants to run Pixelorama with arguments in terminal mode
|
||||||
|
@ -81,6 +77,8 @@ func _ready() -> void:
|
||||||
if OS.get_name() == "Android":
|
if OS.get_name() == "Android":
|
||||||
OS.request_permissions()
|
OS.request_permissions()
|
||||||
|
|
||||||
|
show_splash_screen()
|
||||||
|
|
||||||
|
|
||||||
func handle_resize() -> void:
|
func handle_resize() -> void:
|
||||||
var aspect_ratio = get_viewport_rect().size.x/(0.00001 if get_viewport_rect().size.y == 0 else get_viewport_rect().size.y)
|
var aspect_ratio = get_viewport_rect().size.x/(0.00001 if get_viewport_rect().size.y == 0 else get_viewport_rect().size.y)
|
||||||
|
@ -240,9 +238,14 @@ func setup_application_window_size() -> void:
|
||||||
|
|
||||||
|
|
||||||
func show_splash_screen() -> void:
|
func show_splash_screen() -> void:
|
||||||
# Wait for the window to adjust itself, so the popup is correctly centered
|
if not Global.config_cache.has_section_key("preferences", "startup"):
|
||||||
yield(get_tree().create_timer(0.2), "timeout")
|
Global.config_cache.set_value("preferences", "startup", true)
|
||||||
|
|
||||||
if Global.config_cache.get_value("preferences", "startup"):
|
if Global.config_cache.get_value("preferences", "startup"):
|
||||||
|
if OS.window_size != Vector2(1280, 720):
|
||||||
|
# Wait for the window to adjust itself, so the popup is correctly centered
|
||||||
|
yield(get_tree(), "screen_resized")
|
||||||
|
|
||||||
$Dialogs/SplashDialog.popup_centered() # Splash screen
|
$Dialogs/SplashDialog.popup_centered() # Splash screen
|
||||||
modulate = Color(0.5, 0.5, 0.5)
|
modulate = Color(0.5, 0.5, 0.5)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -12,7 +12,6 @@ func _ready() -> void:
|
||||||
kname = name.replace(" ", "_").to_lower()
|
kname = name.replace(" ", "_").to_lower()
|
||||||
$Label.text = tool_slot.name
|
$Label.text = tool_slot.name
|
||||||
|
|
||||||
yield(get_tree(), "idle_frame")
|
|
||||||
load_config()
|
load_config()
|
||||||
$PixelPerfect.pressed = tool_slot.pixel_perfect
|
$PixelPerfect.pressed = tool_slot.pixel_perfect
|
||||||
$Mirror/Horizontal.pressed = tool_slot.horizontal_mirror
|
$Mirror/Horizontal.pressed = tool_slot.horizontal_mirror
|
||||||
|
|
|
@ -23,7 +23,7 @@ onready var previews = $Previews
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
var frame : Frame = new_empty_frame(true)
|
var frame : Frame = new_empty_frame(true)
|
||||||
Global.current_project.frames.append(frame)
|
Global.current_project.frames.append(frame)
|
||||||
yield(get_tree().create_timer(0.2), "timeout")
|
yield(get_tree(), "idle_frame")
|
||||||
camera_zoom()
|
camera_zoom()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,13 +17,11 @@ func _ready() -> void:
|
||||||
modulate.a = 0.5
|
modulate.a = 0.5
|
||||||
|
|
||||||
|
|
||||||
func _input(_event : InputEvent):
|
func _input(_event : InputEvent) -> void:
|
||||||
var tmp_transform = get_canvas_transform().affine_inverse()
|
var tmp_transform = get_canvas_transform().affine_inverse()
|
||||||
var tmp_position = Global.main_viewport.get_local_mouse_position()
|
var tmp_position = Global.main_viewport.get_local_mouse_position()
|
||||||
mouse_pos = tmp_transform.basis_xform(tmp_position) + tmp_transform.origin
|
mouse_pos = tmp_transform.basis_xform(tmp_position) + tmp_transform.origin
|
||||||
|
|
||||||
if points.size() < 2:
|
|
||||||
return
|
|
||||||
var point0 := points[0]
|
var point0 := points[0]
|
||||||
var point1 := points[1]
|
var point1 := points[1]
|
||||||
if type == Types.HORIZONTAL:
|
if type == Types.HORIZONTAL:
|
||||||
|
|
|
@ -10,7 +10,6 @@ func _ready() -> void:
|
||||||
texture = _texture
|
texture = _texture
|
||||||
texture_mode = Line2D.LINE_TEXTURE_TILE
|
texture_mode = Line2D.LINE_TEXTURE_TILE
|
||||||
width = Global.camera.zoom.x * 4
|
width = Global.camera.zoom.x * 4
|
||||||
yield(get_tree().create_timer(0.01), "timeout")
|
|
||||||
# Add a subtle difference to the normal guide color by mixing in some blue
|
# Add a subtle difference to the normal guide color by mixing in some blue
|
||||||
default_color = Global.guide_color.linear_interpolate(Color(0.2 , 0.2, .65), .6)
|
default_color = Global.guide_color.linear_interpolate(Color(0.2 , 0.2, .65), .6)
|
||||||
|
|
||||||
|
@ -26,8 +25,6 @@ func _input(_event : InputEvent) -> void:
|
||||||
points[1].x = clamp(points[1].x, 0, Global.current_project.size.x)
|
points[1].x = clamp(points[1].x, 0, Global.current_project.size.x)
|
||||||
project.x_symmetry_point = points[0].x * 2 - 1
|
project.x_symmetry_point = points[0].x * 2 - 1
|
||||||
|
|
||||||
yield(get_tree().create_timer(0.01), "timeout")
|
|
||||||
|
|
||||||
|
|
||||||
func outside_canvas() -> bool:
|
func outside_canvas() -> bool:
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -45,9 +45,7 @@ margin_top = 6.0
|
||||||
margin_right = 25.0
|
margin_right = 25.0
|
||||||
margin_bottom = 13.0
|
margin_bottom = 13.0
|
||||||
|
|
||||||
[node name="ColorSwitch" type="TextureButton" parent="ColorPickersHorizontal/ColorButtonsVertical/ColorSwitchCenter" groups=[
|
[node name="ColorSwitch" type="TextureButton" parent="ColorPickersHorizontal/ColorButtonsVertical/ColorSwitchCenter" groups=["UIButtons"]]
|
||||||
"UIButtons",
|
|
||||||
]]
|
|
||||||
margin_right = 25.0
|
margin_right = 25.0
|
||||||
margin_bottom = 7.0
|
margin_bottom = 7.0
|
||||||
mouse_default_cursor_shape = 2
|
mouse_default_cursor_shape = 2
|
||||||
|
|
|
@ -20,7 +20,6 @@ func _ready() -> void:
|
||||||
tag_scroll_container = find_node("TagScroll")
|
tag_scroll_container = find_node("TagScroll")
|
||||||
fps_spinbox = find_node("FPSValue")
|
fps_spinbox = find_node("FPSValue")
|
||||||
timeline_scroll.get_h_scrollbar().connect("value_changed", self, "_h_scroll_changed")
|
timeline_scroll.get_h_scrollbar().connect("value_changed", self, "_h_scroll_changed")
|
||||||
yield(get_tree(), "idle_frame")
|
|
||||||
Global.animation_timer.wait_time = 1 / Global.current_project.fps
|
Global.animation_timer.wait_time = 1 / Global.current_project.fps
|
||||||
fps_spinbox.value = Global.current_project.fps
|
fps_spinbox.value = Global.current_project.fps
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue