Skip to content

Commit c438aeb

Browse files
committed
dreamlab pro
1 parent 6b42ed0 commit c438aeb

5 files changed

Lines changed: 15 additions & 7 deletions

File tree

client/src/auth.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export type AuthToken = {
88
playerId: string;
99
token: string;
1010
guest?: boolean;
11+
isPro?: boolean;
1112
};
1213

1314
const authToken = async (): Promise<AuthToken> => {
@@ -55,6 +56,7 @@ const TokenSchema = z.object({
5556
instance_id: z.uuid(),
5657
nickname: z.string(),
5758
player_id: z.string(),
59+
is_pro: z.boolean().optional(),
5860

5961
// this is not functional currently
6062
// world: z.string(),
@@ -67,6 +69,7 @@ const decodeToken = (token: string): AuthToken => {
6769
token,
6870
nickname: claims.nickname,
6971
playerId: claims.player_id,
72+
isPro: claims.is_pro,
7073
};
7174
};
7275

@@ -75,7 +78,7 @@ const devAuth = (nickname: string): AuthToken => {
7578
const playerId = window.localStorage.getItem(PLAYER_ID) ?? createId("ply");
7679
window.localStorage.setItem(PLAYER_ID, playerId);
7780

78-
return { nickname, playerId, token: "" } satisfies AuthToken;
81+
return { nickname, playerId, token: "", isPro: true } satisfies AuthToken;
7982
};
8083

8184
export const generateMigrateUrl = (guestPlayerId: string): string => {

client/src/init.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ export const init = async () => {
139139
}
140140

141141
const info = await auth(nickname);
142+
142143
if (info.guest) {
143144
const span = document.createElement("span");
144145
span.textContent = "Guest User ";
@@ -188,7 +189,8 @@ export const init = async () => {
188189

189190
const gameName = (
190191
<div id="game-info">
191-
<code data-instance={game.instanceId}>{game.worldId.split('/').at(1)}</code> {serverButton}
192+
<code data-instance={game.instanceId}>{game.worldId.split("/").at(1)}</code>{" "}
193+
{serverButton}
192194
</div>
193195
);
194196

editor/client/main.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import { UndoRedoManager } from "./undo-redo.ts";
4444

4545
const nickname = "Player" + Math.floor(Math.random() * 999) + 1;
4646
const info = await auth(nickname);
47+
const isPro = info.isPro ?? false;
4748

4849
const urlParams = new URLSearchParams(window.location.search);
4950
const isPopout = urlParams.get("popout") === "true";
@@ -369,7 +370,7 @@ if (editModeFlag) {
369370
const appMenu = new AppMenu(uiRoot, games);
370371
appMenu.setup(inspector);
371372

372-
const bottomTabs = new BottomTabs(games);
373+
const bottomTabs = new BottomTabs(games, isPro);
373374
bottomTabs.setup(inspector);
374375
bottomTabs.show(uiRoot);
375376
}

editor/client/ui/assistant/assistant.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ export class Assistant {
77
game: ClientGame;
88
container: HTMLElement;
99
ui: InspectorUI | undefined;
10+
isPro: boolean;
1011

11-
constructor(game: ClientGame, container: HTMLElement) {
12+
constructor(game: ClientGame, container: HTMLElement, isPro: boolean) {
1213
this.game = game;
1314
this.container = container;
15+
this.isPro = isPro;
1416
}
1517

1618
setup(ui: InspectorUI) {
@@ -28,7 +30,7 @@ export class Assistant {
2830

2931
const iframeUrl = `${chatbotUIUrl}/?directory=${decodeURIComponent(
3032
serviceId,
31-
)}&baseUrl=${coderBaseUrl}`;
33+
)}&baseUrl=${coderBaseUrl}&isPro=${this.isPro}`;
3234

3335
// 5. Create an iframe to show that coder instance
3436
const iframe = document.createElement("iframe");

editor/client/ui/bottom-tabs.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class BottomTabs implements InspectorUIWidget {
2121
#assistantContent: HTMLElement;
2222
#tilemapContent: HTMLElement;
2323

24-
constructor(games: { edit: ClientGame; play?: ClientGame }) {
24+
constructor(games: { edit: ClientGame; play?: ClientGame }, isPro: boolean) {
2525
this.#container = elem("div", { className: "bottom-tabs" });
2626

2727
this.#logContent = elem("div", { id: "log-viewer-content" });
@@ -31,7 +31,7 @@ export class BottomTabs implements InspectorUIWidget {
3131

3232
this.#logViewer = new LogViewer(this.#logContent, games);
3333
this.#prefabViewer = new PrefabViewer(games.edit, this.#prefabContent);
34-
this.#assistant = new Assistant(games.edit, this.#assistantContent);
34+
this.#assistant = new Assistant(games.edit, this.#assistantContent, isPro);
3535
this.#tilemapViewer = new TileMapViewer(games.edit, this.#tilemapContent);
3636
}
3737

0 commit comments

Comments
 (0)