@@ -18,15 +18,17 @@ var logger := Log.get_logger("GameLaunchMenu")
1818
1919@export var launch_item : LibraryLaunchItem
2020
21- @onready var banner : TextureRect = $% BannerTexture
22- @onready var logo : TextureRect = $% LogoTexture
23- @onready var launch_button := $% LaunchButton
24- @onready var loading : Control = $% LoadingAnimation
25- @onready var player := $% AnimationPlayer
26- @onready var progress_container := $% ProgressContainer
27- @onready var progress_bar : ProgressBar = $% ProgressBar
28- @onready var delete_container := $% DeleteContainer
29- @onready var delete_button := $% DeleteButton
21+ @onready var banner := $% BannerTexture as TextureRect
22+ @onready var logo := $% LogoTexture as TextureRect
23+ @onready var launch_button := $% LaunchButton as CardButton
24+ @onready var loading := $% LoadingAnimation as Control
25+ @onready var player := $% AnimationPlayer as AnimationPlayer
26+ @onready var progress_container := $% ProgressContainer as MarginContainer
27+ @onready var progress_bar := $% ProgressBar as ProgressBar
28+ @onready var delete_container := $% DeleteContainer as MarginContainer
29+ @onready var delete_button := $% DeleteButton as CardIconButton
30+ @onready var location_menu := $% InstallLocationDialog as InstallLocationDialog
31+ @onready var options_menu := $% InstallOptionsDialog as InstallOptionDialog
3032
3133
3234# Called when the node enters the scene tree for the first time.
@@ -55,7 +57,11 @@ func _process(_delta: float) -> void:
5557func _on_state_entered (_from : State ) -> void :
5658 # Fade in the banner texture
5759 player .play ("fade_in" )
58-
60+
61+ # Ensure dialogs are hidden
62+ location_menu .visible = false
63+ options_menu .visible = false
64+
5965 # Focus the first entry on state change
6066 launch_button .grab_focus .call_deferred ()
6167
@@ -96,11 +102,11 @@ func _on_state_entered(_from: State) -> void:
96102
97103 # Load the banner for the game
98104 var logo_texture = await (
99- BoxArtManager . get_boxart_or_placeholder (library_item , BoxArtProvider .LAYOUT .LOGO )
105+ BoxArtManager . get_boxart_or_placeholder (library_item , BoxArtProvider .LAYOUT .LOGO )
100106 )
101107 logo .texture = logo_texture
102108 var banner_texture = await (
103- BoxArtManager . get_boxart_or_placeholder (library_item , BoxArtProvider .LAYOUT .BANNER )
109+ BoxArtManager . get_boxart_or_placeholder (library_item , BoxArtProvider .LAYOUT .BANNER )
104110 )
105111 banner .texture = banner_texture
106112
@@ -119,15 +125,15 @@ func _update_launch_button() -> void:
119125 if not launch_item :
120126 return
121127 if launch_item .installed :
122- launch_button .text = "Play Now"
128+ launch_button .text = tr ( "Play Now" )
123129 else :
124- launch_button .text = "Install"
130+ launch_button .text = tr ( "Install" )
125131 if LaunchManager .is_running (launch_item .name ):
126- launch_button .text = "Resume"
132+ launch_button .text = tr ( "Resume" )
127133 if InstallManager .is_queued (launch_item ):
128- launch_button .text = "Queued"
134+ launch_button .text = tr ( "Queued" )
129135 if InstallManager .is_installing (launch_item ):
130- launch_button .text = "Installing"
136+ launch_button .text = tr ( "Installing" )
131137
132138
133139func _update_uninstall_button () -> void :
@@ -162,16 +168,50 @@ func _on_install() -> void:
162168 # Do nothing if we're already installing
163169 if InstallManager .is_queued_or_installing (launch_item ):
164170 return
165- var notify := Notification .new ("Installing " + launch_item .name )
166- NotificationManager .show (notify )
167171
168- # Create an install request
172+ # Get the library provider for this launch item
169173 var provider := LibraryManager .get_library_by_id (launch_item ._provider_id )
170- var install_req := InstallManager .Request .new (provider , launch_item )
174+
175+ # If multiple install locations are available, ask the user where to
176+ # install.
177+ var location : Library .InstallLocation = null
178+ var locations := await provider .get_available_install_locations (launch_item )
179+ if locations .size () > 0 :
180+ # Open the install location menu and wait for the user to select an
181+ # install location.
182+ location_menu .open (launch_button , locations )
183+ var result := await location_menu .choice_selected as Array
184+ var accepted := result [0 ] as bool
185+ var choice := result [1 ] as Library .InstallLocation
186+ if not accepted :
187+ return
188+ location = choice
189+
190+ # If install options are available for this library item, ask the user
191+ # to select from the options.
192+ var options := {}
193+ var available_options := await provider .get_install_options (launch_item )
194+ if available_options .size () > 0 :
195+ # Open the install option menu and wait for the user to select install
196+ # options.
197+ options_menu .open (launch_button , available_options )
198+ var result := await options_menu .choice_selected as Array
199+ var accepted := result [0 ] as bool
200+ var choices := result [1 ] as Dictionary
201+ if not accepted :
202+ return
203+ options = choices
204+
205+ # Create an install request
206+ var install_req := InstallManager .Request .new (provider , launch_item , location , options )
171207
172208 # Update the progress bar with install progress of the request
173209 progress_bar .value = 0
174210
211+ # Display a notification
212+ var notify := Notification .new ("Installing " + launch_item .name )
213+ NotificationManager .show (notify )
214+
175215 # Start the install
176216 InstallManager .install (install_req )
177217
0 commit comments