Skip to content

Make Supersonic RC's title screen load#71

Closed
zdimension wants to merge 30 commits intoigorlira:mainfrom
zdimension:main
Closed

Make Supersonic RC's title screen load#71
zdimension wants to merge 30 commits intoigorlira:mainfrom
zdimension:main

Conversation

@zdimension
Copy link
Contributor

@zdimension zdimension commented Mar 9, 2026

  • Replaces most web_sys::console uses with log crate calls
  • Makes the title screen of Lego Supersonic RC load and be useable. Game doesn't work though. Subfixes:
    • Exposed the editable property of sprites
    • Made invalid props on script instances resolve to VOID
    • Add rawNew handler on scripts

@zdimension zdimension changed the title Replace most web_sys::console uses with log crate calls Make Supersonic RC's title screen load Mar 9, 2026
Comment on lines -83 to +89
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
}))
Copy link
Owner

@igorlira igorlira Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, didn't know that. I'll add a check, thanks!

Comment on lines +53 to +88
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'));
});
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

@zdimension
Copy link
Contributor Author

Closing in favor of #74

@zdimension zdimension closed this Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants