1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-19 01:29:49 +00:00

Load preferences from the config file before waiting for process_frame

This commit is contained in:
Emmanouil Papadeas 2024-04-02 00:02:20 +03:00
parent 53e4ebc668
commit 183bee6a0f
3 changed files with 45 additions and 23 deletions

View file

@ -261,6 +261,8 @@ var left_tool_color := Color("0086cf"):
if value == left_tool_color: if value == left_tool_color:
return return
left_tool_color = value left_tool_color = value
if not is_instance_valid(Tools._tool_buttons):
await get_tree().process_frame
for child in Tools._tool_buttons.get_children(): for child in Tools._tool_buttons.get_children():
var background: NinePatchRect = child.get_node("BackgroundLeft") var background: NinePatchRect = child.get_node("BackgroundLeft")
background.modulate = value background.modulate = value
@ -271,6 +273,8 @@ var right_tool_color := Color("fd6d14"):
if value == right_tool_color: if value == right_tool_color:
return return
right_tool_color = value right_tool_color = value
if not is_instance_valid(Tools._tool_buttons):
await get_tree().process_frame
for child in Tools._tool_buttons.get_children(): for child in Tools._tool_buttons.get_children():
var background: NinePatchRect = child.get_node("BackgroundRight") var background: NinePatchRect = child.get_node("BackgroundRight")
background.modulate = value background.modulate = value
@ -288,6 +292,7 @@ var grid_type := GridTypes.CARTESIAN:
if value == grid_type: if value == grid_type:
return return
grid_type = value grid_type = value
if is_instance_valid(canvas.grid):
canvas.grid.queue_redraw() canvas.grid.queue_redraw()
## Found in Preferences. The size of rectangular grid. ## Found in Preferences. The size of rectangular grid.
var grid_size := Vector2i(2, 2): var grid_size := Vector2i(2, 2):
@ -295,6 +300,7 @@ var grid_size := Vector2i(2, 2):
if value == grid_size: if value == grid_size:
return return
grid_size = value grid_size = value
if is_instance_valid(canvas.grid):
canvas.grid.queue_redraw() canvas.grid.queue_redraw()
## Found in Preferences. The size of isometric grid. ## Found in Preferences. The size of isometric grid.
var isometric_grid_size := Vector2i(16, 8): var isometric_grid_size := Vector2i(16, 8):
@ -302,6 +308,7 @@ var isometric_grid_size := Vector2i(16, 8):
if value == isometric_grid_size: if value == isometric_grid_size:
return return
isometric_grid_size = value isometric_grid_size = value
if is_instance_valid(canvas.grid):
canvas.grid.queue_redraw() canvas.grid.queue_redraw()
## Found in Preferences. The grid offset from top-left corner of the canvas. ## Found in Preferences. The grid offset from top-left corner of the canvas.
var grid_offset := Vector2i.ZERO: var grid_offset := Vector2i.ZERO:
@ -309,6 +316,7 @@ var grid_offset := Vector2i.ZERO:
if value == grid_offset: if value == grid_offset:
return return
grid_offset = value grid_offset = value
if is_instance_valid(canvas.grid):
canvas.grid.queue_redraw() canvas.grid.queue_redraw()
## Found in Preferences. If [code]true[/code], The grid draws over the area extended by ## Found in Preferences. If [code]true[/code], The grid draws over the area extended by
## tile-mode as well. ## tile-mode as well.
@ -317,6 +325,7 @@ var grid_draw_over_tile_mode := false:
if value == grid_draw_over_tile_mode: if value == grid_draw_over_tile_mode:
return return
grid_draw_over_tile_mode = value grid_draw_over_tile_mode = value
if is_instance_valid(canvas.grid):
canvas.grid.queue_redraw() canvas.grid.queue_redraw()
## Found in Preferences. The color of grid. ## Found in Preferences. The color of grid.
var grid_color := Color.BLACK: var grid_color := Color.BLACK:
@ -324,6 +333,7 @@ var grid_color := Color.BLACK:
if value == grid_color: if value == grid_color:
return return
grid_color = value grid_color = value
if is_instance_valid(canvas.grid):
canvas.grid.queue_redraw() canvas.grid.queue_redraw()
## Found in Preferences. The minimum zoom after which pixel grid gets drawn if enabled. ## Found in Preferences. The minimum zoom after which pixel grid gets drawn if enabled.
var pixel_grid_show_at_zoom := 1500.0: # percentage var pixel_grid_show_at_zoom := 1500.0: # percentage
@ -331,6 +341,7 @@ var pixel_grid_show_at_zoom := 1500.0: # percentage
if value == pixel_grid_show_at_zoom: if value == pixel_grid_show_at_zoom:
return return
pixel_grid_show_at_zoom = value pixel_grid_show_at_zoom = value
if is_instance_valid(canvas.pixel_grid):
canvas.pixel_grid.queue_redraw() canvas.pixel_grid.queue_redraw()
## Found in Preferences. The color of pixel grid. ## Found in Preferences. The color of pixel grid.
var pixel_grid_color := Color("21212191"): var pixel_grid_color := Color("21212191"):
@ -338,6 +349,7 @@ var pixel_grid_color := Color("21212191"):
if value == pixel_grid_color: if value == pixel_grid_color:
return return
pixel_grid_color = value pixel_grid_color = value
if is_instance_valid(canvas.pixel_grid):
canvas.pixel_grid.queue_redraw() canvas.pixel_grid.queue_redraw()
## Found in Preferences. The color of guides. ## Found in Preferences. The color of guides.
var guide_color := Color.PURPLE: var guide_color := Color.PURPLE:
@ -389,6 +401,7 @@ var tilemode_opacity := 1.0:
if value == tilemode_opacity: if value == tilemode_opacity:
return return
tilemode_opacity = value tilemode_opacity = value
if is_instance_valid(canvas.tile_mode):
canvas.tile_mode.queue_redraw() canvas.tile_mode.queue_redraw()
## Found in Preferences. If [code]true[/code], layers get selected when their buttons are pressed. ## Found in Preferences. If [code]true[/code], layers get selected when their buttons are pressed.
@ -399,6 +412,7 @@ var onion_skinning_past_color := Color.RED:
if value == onion_skinning_past_color: if value == onion_skinning_past_color:
return return
onion_skinning_past_color = value onion_skinning_past_color = value
if is_instance_valid(canvas.onion_past):
canvas.onion_past.blue_red_color = value canvas.onion_past.blue_red_color = value
canvas.onion_past.queue_redraw() canvas.onion_past.queue_redraw()
## Found in Preferences. The onion color of future frames. ## Found in Preferences. The onion color of future frames.
@ -407,6 +421,7 @@ var onion_skinning_future_color := Color.BLUE:
if value == onion_skinning_future_color: if value == onion_skinning_future_color:
return return
onion_skinning_future_color = value onion_skinning_future_color = value
if is_instance_valid(canvas.onion_future):
canvas.onion_future.blue_red_color = value canvas.onion_future.blue_red_color = value
canvas.onion_future.queue_redraw() canvas.onion_future.queue_redraw()
@ -416,6 +431,7 @@ var selection_animated_borders := true:
if value == selection_animated_borders: if value == selection_animated_borders:
return return
selection_animated_borders = value selection_animated_borders = value
if is_instance_valid(canvas.selection):
var marching_ants: Sprite2D = canvas.selection.marching_ants_outline var marching_ants: Sprite2D = canvas.selection.marching_ants_outline
marching_ants.material.set_shader_parameter("animated", selection_animated_borders) marching_ants.material.set_shader_parameter("animated", selection_animated_borders)
## Found in Preferences. The first color of border. ## Found in Preferences. The first color of border.
@ -424,6 +440,7 @@ var selection_border_color_1 := Color.WHITE:
if value == selection_border_color_1: if value == selection_border_color_1:
return return
selection_border_color_1 = value selection_border_color_1 = value
if is_instance_valid(canvas.selection):
var marching_ants: Sprite2D = canvas.selection.marching_ants_outline var marching_ants: Sprite2D = canvas.selection.marching_ants_outline
marching_ants.material.set_shader_parameter("first_color", selection_border_color_1) marching_ants.material.set_shader_parameter("first_color", selection_border_color_1)
canvas.selection.queue_redraw() canvas.selection.queue_redraw()
@ -433,6 +450,7 @@ var selection_border_color_2 := Color.BLACK:
if value == selection_border_color_2: if value == selection_border_color_2:
return return
selection_border_color_2 = value selection_border_color_2 = value
if is_instance_valid(canvas.selection):
var marching_ants: Sprite2D = canvas.selection.marching_ants_outline var marching_ants: Sprite2D = canvas.selection.marching_ants_outline
marching_ants.material.set_shader_parameter("second_color", selection_border_color_2) marching_ants.material.set_shader_parameter("second_color", selection_border_color_2)
canvas.selection.queue_redraw() canvas.selection.queue_redraw()
@ -670,14 +688,14 @@ func _ready() -> void:
current_project = projects[0] current_project = projects[0]
current_project.fill_color = default_fill_color current_project.fill_color = default_fill_color
await get_tree().process_frame
project_switched.emit()
# Load preferences from the config file # Load preferences from the config file
for pref in config_cache.get_section_keys("preferences"): for pref in config_cache.get_section_keys("preferences"):
if get(pref) == null: if get(pref) == null:
continue continue
var value = config_cache.get_value("preferences", pref) var value = config_cache.get_value("preferences", pref)
set(pref, value) set(pref, value)
await get_tree().process_frame
project_switched.emit()
func _initialize_keychain() -> void: func _initialize_keychain() -> void:

View file

@ -798,6 +798,8 @@ func set_new_imported_tab(project: Project, path: String) -> void:
func update_autosave() -> void: func update_autosave() -> void:
if not is_instance_valid(autosave_timer):
return
autosave_timer.stop() autosave_timer.stop()
# Interval parameter is in minutes, wait_time is seconds # Interval parameter is in minutes, wait_time is seconds
autosave_timer.wait_time = Global.autosave_interval * 60 autosave_timer.wait_time = Global.autosave_interval * 60

View file

@ -461,6 +461,8 @@ func get_mirrored_positions(
func set_button_size(button_size: int) -> void: func set_button_size(button_size: int) -> void:
var size := Vector2(24, 24) if button_size == Global.ButtonSize.SMALL else Vector2(32, 32) var size := Vector2(24, 24) if button_size == Global.ButtonSize.SMALL else Vector2(32, 32)
if not is_instance_valid(_tool_buttons):
await get_tree().process_frame
for t in _tool_buttons.get_children(): for t in _tool_buttons.get_children():
t.custom_minimum_size = size t.custom_minimum_size = size