Skip to content

Commit 8c96544

Browse files
committed
hide tutorial after you completed it
1 parent 8560e5b commit 8c96544

1 file changed

Lines changed: 29 additions & 5 deletions

File tree

editor/client/ui/tutorial-host.tsx

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ export class TutorialHost implements InspectorUIWidget {
345345
private contentEl!: HTMLDivElement;
346346
private counterEl!: HTMLSpanElement;
347347
private polling: number | null = null;
348+
private projectId: string = "";
348349

349350
static maskSections(sectionIds: string[]): void {
350351
createSectionOverlay(sectionIds);
@@ -354,6 +355,18 @@ export class TutorialHost implements InspectorUIWidget {
354355
removeSectionOverlay(sectionIds);
355356
}
356357

358+
private getTutorialStorageKey(): string {
359+
return `tutorial_completed_${this.projectId}`;
360+
}
361+
362+
private isTutorialCompleted(): boolean {
363+
return localStorage.getItem(this.getTutorialStorageKey()) === "true";
364+
}
365+
366+
private markTutorialCompleted(): void {
367+
localStorage.setItem(this.getTutorialStorageKey(), "true");
368+
}
369+
357370
private reposition = (): void => {
358371
if (!this.card) return;
359372
const toolbar = document.getElementById("toolbar");
@@ -367,15 +380,18 @@ export class TutorialHost implements InspectorUIWidget {
367380
constructor(_game: ClientGame) {
368381
if (TutorialHost.didLoad) return;
369382
TutorialHost.didLoad = true;
370-
const projectId = _game.worldId;
371-
if (projectId.includes("TutorialInteractive")) {
383+
this.projectId = _game.worldId;
384+
if (this.projectId.includes("TutorialInteractive")) {
372385
try {
373-
const projectName = projectId.split("/")[1];
386+
const projectName = this.projectId.split("/")[1];
374387
const tutorialNumber = parseInt(projectName.split("_")[0].split(".")[1]);
375388
if (tutorialNumber === 1) {
376389
tutorial = tutorial1;
377-
console.log("loading tutorial 1");
378-
setTimeout(() => this.runTutorial(), 1);
390+
if (!this.isTutorialCompleted()) {
391+
setTimeout(() => this.runTutorial(), 1);
392+
} else {
393+
console.log("Tutorial already completed.");
394+
}
379395
}
380396
} catch (_) {}
381397
}
@@ -396,7 +412,15 @@ export class TutorialHost implements InspectorUIWidget {
396412

397413
const next = (): void => {
398414
if (i >= tutorial.length) {
415+
this.markTutorialCompleted();
399416
this.hideCard();
417+
TutorialHost.unmaskSections([
418+
"scene-graph",
419+
"file-tree",
420+
"properties",
421+
"behavior-panel",
422+
]);
423+
console.log("Tutorial completed!");
400424
return;
401425
}
402426

0 commit comments

Comments
 (0)