Make Supersonic RC's title screen load#71
Conversation
This fixes Supersonic RC's title screen only working some of the time
| if let Some(member) = member { | ||
| Ok(player.alloc_datum(Datum::CastMember(member.to_owned()))) | ||
| } else { | ||
| Ok(player.alloc_datum(Datum::CastMember(INVALID_CAST_MEMBER_REF))) | ||
| } | ||
|
|
||
| Ok(player.alloc_datum(match member { | ||
| Some(r) => Datum::CastMember(r), | ||
| None => Datum::Void | ||
| })) |
There was a problem hiding this comment.
This behavior depends on the value of _player.scriptExecutionStyle. There are two possible values, 9 (returns INVALID_CAST_MEMBER_REF) and 10 (returns Void), the default depends on which version of Director the movie was built with. It seems like your movie works with the behavior of 10, but this breaks other movies we've been testing against. Can you check what version your file is and possibly add a check so we support both modes?
You should be able to find the file version in the chunks inspector:
There was a problem hiding this comment.
Oh, didn't know that. I'll add a check, thanks!
| function openRecentMoviesDb(): Promise<IDBDatabase> { | ||
| if (recentMoviesDbPromise) { | ||
| return recentMoviesDbPromise; | ||
| } | ||
|
|
||
| recentMoviesDbPromise = new Promise((resolve, reject) => { | ||
| const request = window.indexedDB.open(RECENT_MOVIES_DB_NAME, RECENT_MOVIES_DB_VERSION); | ||
|
|
||
| request.onupgradeneeded = () => { | ||
| const db = request.result; | ||
| if (!db.objectStoreNames.contains(RECENT_MOVIES_STORE_NAME)) { | ||
| db.createObjectStore(RECENT_MOVIES_STORE_NAME, { keyPath: 'id' }); | ||
| } | ||
| }; | ||
|
|
||
| request.onsuccess = () => resolve(request.result); | ||
| request.onerror = () => reject(request.error ?? new Error('Failed to open IndexedDB')); | ||
| }); | ||
|
|
||
| return recentMoviesDbPromise; | ||
| } | ||
|
|
||
| async function loadRecentMoviesIndexedDb(): Promise<RecentMovie[]> { | ||
| try { | ||
| const raw = window.localStorage.getItem(RECENT_MOVIES_KEY); | ||
| return raw ? JSON.parse(raw) : []; | ||
| const db = await openRecentMoviesDb(); | ||
| return await new Promise((resolve, reject) => { | ||
| const tx = db.transaction(RECENT_MOVIES_STORE_NAME, 'readonly'); | ||
| const store = tx.objectStore(RECENT_MOVIES_STORE_NAME); | ||
| const request = store.get(RECENT_MOVIES_RECORD_ID); | ||
|
|
||
| request.onsuccess = () => { | ||
| const result = request.result as { id: string; movies: RecentMovie[] } | undefined; | ||
| resolve(result?.movies ?? []); | ||
| }; | ||
| request.onerror = () => reject(request.error ?? new Error('Failed to read recent movies')); | ||
| }); |
There was a problem hiding this comment.
This is an improvement over storing the recent movies in a flat JSON in the session storage. However, this will reset everyone's recent movie list. We rely on it to reuse external params that take some time to set up, so it would be disruptive to completely reset it. Can you add a way to migrate the our existing recent movie list to the new store?
|
Closing in favor of #74 |
editableproperty of spritesVOIDrawNewhandler on scripts