33 readServerToolConstants ,
44 requireServerConstant ,
55} from "../../../../src/api/server-api-client.js" ;
6+ import { getSessionCurrent } from "../../../../src/api/session-api-client.js" ;
67
78const constants = readServerToolConstants ( "game-configuration" ) ;
89
@@ -32,25 +33,41 @@ const elements = {
3233 form : document . querySelector ( "[data-game-configuration-form]" ) ,
3334 formCard : document . querySelector ( "[data-game-configuration-form-card]" ) ,
3435 gameBasics : document . querySelector ( "[data-game-configuration-game-basics]" ) ,
36+ gameDetails : document . querySelector ( "[data-game-configuration-game-details]" ) ,
37+ gameName : document . querySelector ( "[data-game-configuration-game-name]" ) ,
3538 gameRules : document . querySelector ( "[data-game-configuration-game-rules]" ) ,
39+ gameType : document . querySelector ( "[data-game-configuration-game-type]" ) ,
3640 handoffContext : document . querySelector ( "[data-game-configuration-handoff-context]" ) ,
3741 handoffOverlay : document . querySelector ( "[data-game-configuration-handoff-overlay]" ) ,
3842 missingItems : document . querySelector ( "[data-game-configuration-output-missing]" ) ,
3943 objectSetup : document . querySelector ( "[data-game-configuration-object-setup]" ) ,
4044 outputCapability : document . querySelector ( "[data-game-configuration-output-capability]" ) ,
45+ outputDetails : document . querySelector ( "[data-game-configuration-output-details]" ) ,
46+ outputGameType : document . querySelector ( "[data-game-configuration-output-game-type]" ) ,
47+ outputName : document . querySelector ( "[data-game-configuration-output-name]" ) ,
4148 outputNextStep : document . querySelector ( "[data-game-configuration-output-next-step]" ) ,
49+ outputPlatforms : document . querySelector ( "[data-game-configuration-output-platforms]" ) ,
4250 outputPlayerMode : document . querySelector ( "[data-game-configuration-output-player-mode]" ) ,
4351 outputReadiness : document . querySelector ( "[data-game-configuration-output-readiness]" ) ,
52+ outputResolution : document . querySelector ( "[data-game-configuration-output-resolution]" ) ,
53+ outputStartup : document . querySelector ( "[data-game-configuration-output-startup]" ) ,
4454 outputSummary : document . querySelector ( "[data-game-configuration-output-summary]" ) ,
55+ outputVersion : document . querySelector ( "[data-game-configuration-output-version]" ) ,
56+ outputVisibility : document . querySelector ( "[data-game-configuration-output-visibility]" ) ,
57+ platforms : document . querySelector ( "[data-game-configuration-platforms]" ) ,
4558 playerSetup : document . querySelector ( "[data-game-configuration-player-setup]" ) ,
4659 progressCurrentFocus : document . querySelector ( "[data-game-configuration-current-focus]" ) ,
4760 progressGame : document . querySelector ( "[data-game-configuration-game-progress]" ) ,
4861 progressPublishing : document . querySelector ( "[data-game-configuration-publishing-progress]" ) ,
4962 progressRecommended : document . querySelectorAll ( "[data-game-configuration-recommended-tool]" ) ,
63+ resolution : document . querySelector ( "[data-game-configuration-resolution]" ) ,
5064 statusLog : document . querySelector ( "[data-game-configuration-log]" ) ,
65+ startupSettings : document . querySelector ( "[data-game-configuration-startup-settings]" ) ,
5166 testReadiness : document . querySelector ( "[data-game-configuration-test-readiness]" ) ,
5267 validationList : document . querySelector ( "[data-game-configuration-validation-list]" ) ,
5368 validationOverlay : document . querySelector ( "[data-game-configuration-validation-overlay]" ) ,
69+ version : document . querySelector ( "[data-game-configuration-version]" ) ,
70+ visibility : document . querySelector ( "[data-game-configuration-visibility]" ) ,
5471 worldSetup : document . querySelector ( "[data-game-configuration-world-setup]" )
5572} ;
5673
@@ -75,10 +92,16 @@ function readForm() {
7592 return {
7693 audioSetup : elements . audioSetup ?. value ,
7794 gameBasics : elements . gameBasics ?. value ,
95+ gameDetails : elements . gameDetails ?. value ,
7896 gameRules : elements . gameRules ?. value ,
7997 objectSetup : elements . objectSetup ?. value ,
98+ platforms : elements . platforms ?. value ,
8099 playerSetup : elements . playerSetup ?. value ,
100+ resolution : elements . resolution ?. value ,
101+ startupSettings : elements . startupSettings ?. value ,
81102 testReadiness : elements . testReadiness ?. value ,
103+ version : elements . version ?. value ,
104+ visibility : elements . visibility ?. value ,
82105 worldSetup : elements . worldSetup ?. value
83106 } ;
84107}
@@ -106,6 +129,23 @@ function applyConfigurationToForm(configuration) {
106129 } ) ;
107130}
108131
132+ function currentSession ( ) {
133+ try {
134+ return getSessionCurrent ( ) ;
135+ } catch {
136+ return { authenticated : false } ;
137+ }
138+ }
139+
140+ function redirectGuestSaveAction ( ) {
141+ if ( currentSession ( ) ?. authenticated === true ) {
142+ return false ;
143+ }
144+ setText ( elements . statusLog , "Sign in before saving Game Configuration." ) ;
145+ window . location . href = new URL ( "/account/sign-in.html" , window . location . href ) . href ;
146+ return true ;
147+ }
148+
109149function renderValidation ( validation ) {
110150 if ( ! elements . validationList || ! elements . validationOverlay ) {
111151 return ;
@@ -141,16 +181,36 @@ function renderHandoff(snapshot) {
141181 }
142182}
143183
184+ function inheritedGameName ( snapshot ) {
185+ return snapshot . handoff . activeProject ?. name || snapshot . handoff . activeGame ?. name || "" ;
186+ }
187+
188+ function inheritedGameType ( snapshot ) {
189+ return snapshot . handoff . activeProject ?. gameType || snapshot . handoff . activeDesign ?. gameType || snapshot . handoff . activeProject ?. purpose || "" ;
190+ }
191+
144192function renderOutput ( snapshot ) {
145193 const configuration = snapshot . configuration ;
146194 const validation = snapshot . validation ;
195+ const gameName = configuration ?. gameName || inheritedGameName ( snapshot ) ;
196+ const gameType = inheritedGameType ( snapshot ) ;
147197 const missing = validation . findings . map ( ( finding ) => finding . label ) . join ( ", " ) ;
148198 const summary = configuration ?. gameBasics || "No configuration summary saved yet." ;
149199 const activeGame = snapshot . handoff . activeGame || snapshot . handoff . activeProject ;
150200 const capability = activeGame ?. purpose === "Capability Demo"
151201 ? `${ activeGame . name } remains a game-owned capability demo.`
152202 : "Standard game configuration." ;
153203
204+ setText ( elements . gameName , gameName || "From Game Hub" ) ;
205+ setText ( elements . gameType , gameType || "From Game Hub" ) ;
206+ setText ( elements . outputName , gameName || "No game name saved yet." ) ;
207+ setText ( elements . outputGameType , gameType || "No game type inherited yet." ) ;
208+ setText ( elements . outputDetails , configuration ?. gameDetails || "No game details saved yet." ) ;
209+ setText ( elements . outputVersion , configuration ?. version || "No version saved yet." ) ;
210+ setText ( elements . outputResolution , configuration ?. resolution || "No resolution saved yet." ) ;
211+ setText ( elements . outputPlatforms , configuration ?. platforms || "No platforms saved yet." ) ;
212+ setText ( elements . outputVisibility , configuration ?. visibility || "No visibility saved yet." ) ;
213+ setText ( elements . outputStartup , configuration ?. startupSettings || "No startup settings saved yet." ) ;
154214 setText ( elements . outputSummary , summary ) ;
155215 setText ( elements . outputPlayerMode , configuration ?. playerMode || snapshot . handoff . activeDesign ?. playerMode || "1 Player" ) ;
156216 setText ( elements . outputReadiness , snapshot . progressHandoff . readinessStatus ) ;
@@ -199,9 +259,13 @@ elements.form?.addEventListener("submit", (event) => {
199259 return ;
200260 }
201261
262+ if ( redirectGuestSaveAction ( ) ) {
263+ return ;
264+ }
265+
202266 const configuration = repository . updateConfiguration ( projectId , readForm ( ) ) ;
203267 const nextSnapshot = repository . getSnapshot ( ) ;
204- const message = configuration ?. status === "Ready"
268+ const message = configuration ?. status === "Ready" || nextSnapshot . progressHandoff . readinessStatus === "Ready"
205269 ? "Saved Game Configuration as ready. Assets is the recommended next tool."
206270 : `Saved Game Configuration with ${ nextSnapshot . validation . findings . length } missing item${ nextSnapshot . validation . findings . length === 1 ? "" : "s" } .` ;
207271
0 commit comments