Skip to content

Commit

Permalink
Use construction time set up of the GameUI nodes because we can preve…
Browse files Browse the repository at this point in the history
…nt race conditions now completely
  • Loading branch information
RevoluPowered committed Jun 26, 2024
1 parent ed4f1f1 commit 85428b4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var _id_to_slot_map: Dictionary = {}

func _ready() -> void:
super()
await GameUI.ui_ready()
await GameUI.instance.ready
GameUI.instance.login_ui.login_succeeded.connect(Net.asset_client.get_recent_assets)
Net.asset_client.asset_received.connect(_on_net_asset_received)
Expand Down
51 changes: 7 additions & 44 deletions mirror-godot-app/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,6 @@ global_script_class_icons={
"ZoneClient": ""
}

[app_protocol]

enable_app_protocol=true
protocol_name="themirror"
socket_name=".themirror-prod.socket"

[application]

config/name="The Mirror"
Expand All @@ -102,12 +96,12 @@ driver/enable_input=true

[autoload]

VRManager="*res://scripts/autoload/vr_manager.gd"
Analytics="*res://scripts/autoload/analytics/analytics.gd"
AnalyticsV2="*res://scripts/autoload/analytics/analytics_v2.gd"
Zone="*res://prefabs/autoload/zone/zone.tscn"
Firebase="*res://addons/godot-firebase/firebase/firebase.tscn"
Net="*res://scripts/autoload/net.gd"
VRManager="*res://scripts/autoload/vr_manager.gd"
Deeplinking="*res://scripts/autoload/deeplinking.gd"
DamageMaster="*res://scripts/autoload/damage_master.gd"
PriorityInput="*res://scripts/autoload/priority_input.gd"
Expand All @@ -129,11 +123,6 @@ Util="*res://scripts/autoload/util_funcs.gd"

gdscript/warnings/static_called_on_instance=0
gdscript/warnings/redundant_await=0
shader_language/warnings/enable=false

[debug_flags]

show_web_socket_debug=false

[display]

Expand Down Expand Up @@ -580,21 +569,6 @@ base_volume_multiplier=3.0
random_pitch=0.2
mass_pitch_multiplier=0.8
use_server_camera=false
env_name="official"
auto_updater_bucket_uri="https://storage.googleapis.com/mirror_native_client_builds_prod/AutoUpdater"
integration_test_ids={}
base_url="https://in.themirror.space"
connection_server="https://mirror-web-server-mirror-official-pkmrhxu4na-uc.a.run.app"
connection_server_ws="wss://mirror-web-server-mirror-official-pkmrhxu4na-uc.a.run.app"
landing_page_url="https://themirror.space"
posthog_api_key="phc_wO5tr7Hle88gRKsDoQIybFqekqTctZ8nXmbokNsCv9b"
mixpanel_api_key="c5e82051367277731c1b1cf0d46d9d57"
asset_bucket=""
zone_server_port=27015

[mirror_secrets]

WSS_SECRET=""

[physics]

Expand All @@ -605,31 +579,20 @@ common/enable_pause_aware_picking=true
[rendering]

renderer/rendering_method="mobile"
textures/vram_compression/import_s3tc_bptc=true
textures/vram_compression/import_etc2_astc=true
lights_and_shadows/directional_shadow/size=512
lights_and_shadows/directional_shadow/size.mobile=512
lights_and_shadows/directional_shadow/soft_shadow_filter_quality=0
lights_and_shadows/positional_shadow/soft_shadow_filter_quality=0
shader_compiler/shader_cache/strip_debug=true
driver/depth_prepass/disable_for_vendors=""
camera/depth_of_field/depth_of_field_bokeh_quality=2
environment/ssao/quality=0
environment/ssil/quality=0
environment/glow/upscale_mode=0
global_illumination/sdfgi/frames_to_converge=0
environment/volumetric_fog/volume_size=128
environment/volumetric_fog/volume_depth=128
environment/volumetric_fog/use_filter=0
environment/defaults/default_clear_color=Color(0.0235294, 0.00392157, 0.121569, 1)
anti_aliasing/quality/msaa_2d=1
anti_aliasing/quality/msaa_3d=1
vrs/mode=2
lights_and_shadows/positional_shadow/atlas_size=512
lights_and_shadows/positional_shadow/atlas_size.mobile=512
anti_aliasing/quality/msaa=1
shadows/directional_shadow/soft_shadow_quality=0
environment/default_clear_color=Color(0.0235294, 0.00392157, 0.121569, 1)
environment/default_environment="res://art/default_env.tres"
quality/godrays/sample_number=50
quality/godrays/use_pcf5=false
quality/godrays/dither_amount=1.0
shadows/directional_shadow/size=256

[shader_globals]

Expand Down Expand Up @@ -661,7 +624,7 @@ world_map_max_height_offset_01={
[xr]

openxr/enabled=true
openxr/environment_blend_mode=2
openxr/environment_blend_mode=0
openxr/foveation_level=3
openxr/foveation_dynamic=true
openxr/startup_alert=false
Expand Down
2 changes: 1 addition & 1 deletion mirror-godot-app/scripts/autoload/vr_manager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func _ready() -> void:
if not vr_interface.initialize():
print("OpenXR: Failed to initialize")
vr_initialised = false
GameUI.setup_game_ui(get_parent(), vr_initialised)
GameUI.setup_game_ui(self, vr_initialised)
if not vr_initialised:
return
vr_interface.connect("session_focussed", _on_vr_enter)
Expand Down
18 changes: 8 additions & 10 deletions mirror-godot-app/ui/game/game_ui_static.gd
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ static var _sub_viewport: SubViewport = null
static var _vr_controller_menu: VRControllerMenu = null
static var instance:
get:
await ui_ready()
assert(_internal_instance != null)
assert(_internal_instance.get_parent() != null)
return _internal_instance
Expand All @@ -36,9 +35,7 @@ static func get_sub_viewport() -> SubViewport:


static func ui_ready() -> void:
if _internal_instance != null and _internal_instance.get_parent() != null:
return
while _internal_instance.get_parent() == null or _root_node == null:
while not is_instance_valid(_internal_instance) or _internal_instance.get_parent() == null or _root_node == null:
await _root_node.get_tree().create_timer(0.1).timeout
await _internal_instance.wait_till_ready()
if not _vr_decided:
Expand All @@ -57,6 +54,7 @@ static func set_game_ui_visibility(state: bool) -> void:

## Called when booting the app when we know if the app is VR or non-VR
static func setup_game_ui(root_node: Node, is_vr: bool):
assert(root_node)
_root_node = root_node
if _internal_instance == null:
# read the node, and add it to the root of the game
Expand All @@ -71,22 +69,22 @@ static func setup_game_ui(root_node: Node, is_vr: bool):
root_node.add_child.call_deferred(vr_player_for_menu)
## Add the subviewport for the VR Headset's UI
_sub_viewport = SubViewport.new()
_sub_viewport.render_target_update_mode = SubViewport.UPDATE_WHEN_VISIBLE
_sub_viewport.render_target_update_mode = SubViewport.UPDATE_ALWAYS
#_sub_viewport.disable_3d = true
_sub_viewport.transparent_bg = false
#_sub_viewport.msaa_2d = Viewport.MSAA_4X
#_sub_viewport.msaa_3d = Viewport.MSAA_4X
_sub_viewport.size = Vector2i(1920, 1050)
# _sub_viewport.use_xr = true
var viewport: Viewport = Zone.get_viewport()
viewport.use_xr = true
viewport.vrs_mode = Viewport.VRS_XR
DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_DISABLED)
_sub_viewport.set_name("VRSubViewport")
_sub_viewport.add_child.call_deferred(_internal_instance)
root_node.add_child.call_deferred(_sub_viewport)
_sub_viewport.add_child(_internal_instance)
root_node.add_child(_sub_viewport)
_vr_controller_menu = vr_player_for_menu
else:
root_node.add_child.call_deferred(_internal_instance)
while _internal_instance.get_parent() == null:
await root_node.get_tree().create_timer(0.1).timeout
root_node.add_child(_internal_instance)
VRManager.vr_decision_made.emit()
_vr_decided = true
1 change: 1 addition & 0 deletions mirror-godot-app/ui/login/login_ui.gd
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ func _guest_signup_succeeded(acc: Dictionary) -> void:
## I recommend you call it exactly like this:
## await LoginUI.wait_till_login(get_tree())
static func wait_till_login(scene_tree: SceneTree):
await GameUI.ui_ready()
# it is possible you use the code in this UI in a place where it may not be fully loaded
# we ensure we have all the autoloads, and instances configured
if not Firebase or not Firebase.Auth or not GameUI.instance.login_ui:
Expand Down

0 comments on commit 85428b4

Please sign in to comment.