fix: adds control node to ESCGame for UI that must be populated, along with Escoria-only UI methods; this helps to avoid display issues on startup

This commit is contained in:
Duncan Brown
2022-04-23 16:25:16 -04:00
committed by Julian Murgia
parent 6afff99e7c
commit eeb7042d11
4 changed files with 30 additions and 10 deletions

View File

@@ -113,7 +113,6 @@ func change_scene(room_path: String, enable_automatic_transitions: bool) -> void
var game_parent = escoria.game_scene.get_parent()
game_parent.remove_child(escoria.game_scene)
#escoria.game_scene.hide_ui()
room_scene.add_child(escoria.game_scene)
room_scene.move_child(escoria.game_scene, 0)
room_scene.game = escoria.game_scene

View File

@@ -31,6 +31,9 @@ export(float) var mouse_tooltip_margin = 50.0
export(EDITOR_GAME_DEBUG_DISPLAY) var editor_debug_mode = \
EDITOR_GAME_DEBUG_DISPLAY.NONE setget _set_editor_debug_mode
# The Control node underneath which all UI must be placed.
# This should be a Control node and NOT a CanvasLayer (or any other type of) node.
export(NodePath) var ui_parent_control_node
# A reference to the node handling tooltips
var tooltip_node: Object
@@ -421,3 +424,26 @@ func show_crash_popup(files: Array = []) -> void:
yield(crash_popup, "confirmed")
emit_signal("crash_popup_confirmed")
# *** FOR USE BY ESCORIA CORE ONLY ***
# Hides everything under the UI Control node.
func escoria_hide_ui():
if ui_parent_control_node != null and not ui_parent_control_node.is_empty():
(get_node(ui_parent_control_node) as Control).visible = false
else:
escoria.logger.report_warnings(
"esc_game.gd#escoria_hide_ui",
["UI parent Control node not defined!"]
)
# *** FOR USE BY ESCORIA CORE ONLY ***
# Show everything under the UI Control node.
func escoria_show_ui():
if ui_parent_control_node != null and not ui_parent_control_node.is_empty():
(get_node(ui_parent_control_node) as Control).visible = true
else:
escoria.logger.report_warnings(
"esc_game.gd#escoria_show_ui",
["UI parent Control node not defined!"]
)

View File

@@ -172,6 +172,9 @@ func _notification(what):
# Usually you'll want to show some logos animations before spawning the main
# menu in the escoria/main/game_start_script 's :init event
func init():
# Don't show the UI until we're ready in order to avoid a sometimes-noticeable
# blink. The UI will be "shown" later via a visibility update to the first room.
escoria.game_scene.escoria_hide_ui()
run_event_from_script(start_script, self.event_manager.EVENT_INIT)

View File

@@ -16,6 +16,7 @@ bg_color = Color( 0.6, 0.6, 0.6, 0.5 )
script = ExtResource( 5 )
main_menu = NodePath("ui/main_menu")
pause_menu = NodePath("ui/pause_menu")
ui_parent_control_node = NodePath("ui/Control")
[node name="dialog_layer" type="CanvasLayer" parent="."]
@@ -143,15 +144,6 @@ margin_bottom = 200.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="hover_stack" type="Label" parent="ui"]
margin_left = 1085.0
margin_top = 2.81912
margin_right = 1283.0
margin_bottom = 107.819
__meta__ = {
"_edit_use_anchors_": false
}
[node name="main_menu" parent="ui" instance=ExtResource( 7 )]
visible = false