1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 17:19:50 +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:
Manolis Papadeas 2021-11-17 19:59:14 +02:00
parent 0081aa365a
commit f4c903771d
8 changed files with 27 additions and 32 deletions

View file

@ -71,28 +71,29 @@ var alt := false
func _ready() -> void:
_tool_buttons = Global.control.find_node("ToolButtons")
yield(get_tree(), "idle_frame")
_slots[BUTTON_LEFT] = Slot.new("Left tool")
_slots[BUTTON_RIGHT] = Slot.new("Right tool")
_panels[BUTTON_LEFT] = Global.control.find_node("LeftPanelContainer", 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")
if not value in _tools:
value = "Pencil"
set_tool(value, BUTTON_LEFT)
value = Global.config_cache.get_value(_slots[BUTTON_RIGHT].kname, "tool", "Eraser")
if not value in _tools:
value = "Eraser"
set_tool(value, 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)
var tool_name : String = Global.config_cache.get_value(_slots[BUTTON_LEFT].kname, "tool", "Pencil")
if not tool_name in _tools:
tool_name = "Pencil"
set_tool(tool_name, BUTTON_LEFT)
tool_name = Global.config_cache.get_value(_slots[BUTTON_RIGHT].kname, "tool", "Eraser")
if not tool_name in _tools:
tool_name = "Eraser"
set_tool(tool_name, BUTTON_RIGHT)
update_tool_buttons()
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:
var slot = _slots[button]

View file

@ -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.
func _ready() -> void:
var alternate_transparent_background = ColorRect.new()
var alternate_transparent_background := ColorRect.new()
add_child(alternate_transparent_background)
move_child(alternate_transparent_background,0)
alternate_transparent_background.visible = false
@ -66,10 +66,6 @@ func _ready() -> void:
zstd_checkbox.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
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()
# If the user wants to run Pixelorama with arguments in terminal mode
@ -81,6 +77,8 @@ func _ready() -> void:
if OS.get_name() == "Android":
OS.request_permissions()
show_splash_screen()
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)
@ -240,9 +238,14 @@ func setup_application_window_size() -> void:
func show_splash_screen() -> void:
# Wait for the window to adjust itself, so the popup is correctly centered
yield(get_tree().create_timer(0.2), "timeout")
if not Global.config_cache.has_section_key("preferences", "startup"):
Global.config_cache.set_value("preferences", "startup", true)
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
modulate = Color(0.5, 0.5, 0.5)
else:

View file

@ -12,7 +12,6 @@ func _ready() -> void:
kname = name.replace(" ", "_").to_lower()
$Label.text = tool_slot.name
yield(get_tree(), "idle_frame")
load_config()
$PixelPerfect.pressed = tool_slot.pixel_perfect
$Mirror/Horizontal.pressed = tool_slot.horizontal_mirror

View file

@ -23,7 +23,7 @@ onready var previews = $Previews
func _ready() -> void:
var frame : Frame = new_empty_frame(true)
Global.current_project.frames.append(frame)
yield(get_tree().create_timer(0.2), "timeout")
yield(get_tree(), "idle_frame")
camera_zoom()

View file

@ -17,13 +17,11 @@ func _ready() -> void:
modulate.a = 0.5
func _input(_event : InputEvent):
func _input(_event : InputEvent) -> void:
var tmp_transform = get_canvas_transform().affine_inverse()
var tmp_position = Global.main_viewport.get_local_mouse_position()
mouse_pos = tmp_transform.basis_xform(tmp_position) + tmp_transform.origin
if points.size() < 2:
return
var point0 := points[0]
var point1 := points[1]
if type == Types.HORIZONTAL:

View file

@ -10,7 +10,6 @@ func _ready() -> void:
texture = _texture
texture_mode = Line2D.LINE_TEXTURE_TILE
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
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)
project.x_symmetry_point = points[0].x * 2 - 1
yield(get_tree().create_timer(0.01), "timeout")
func outside_canvas() -> bool:
return false

View file

@ -45,9 +45,7 @@ margin_top = 6.0
margin_right = 25.0
margin_bottom = 13.0
[node name="ColorSwitch" type="TextureButton" parent="ColorPickersHorizontal/ColorButtonsVertical/ColorSwitchCenter" groups=[
"UIButtons",
]]
[node name="ColorSwitch" type="TextureButton" parent="ColorPickersHorizontal/ColorButtonsVertical/ColorSwitchCenter" groups=["UIButtons"]]
margin_right = 25.0
margin_bottom = 7.0
mouse_default_cursor_shape = 2

View file

@ -20,7 +20,6 @@ func _ready() -> void:
tag_scroll_container = find_node("TagScroll")
fps_spinbox = find_node("FPSValue")
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
fps_spinbox.value = Global.current_project.fps