feat(intro): play home intro once in the intro screen instead of having weird boolean in app store

This commit is contained in:
2026-01-14 11:59:13 +01:00
parent 91d8b6db3b
commit 7e815328eb
8 changed files with 23 additions and 33 deletions

View File

@@ -1,16 +1,8 @@
<script setup lang="ts"> <script setup lang="ts">
const { onRender } = useScreen(); const { onRender } = useScreen();
const app = useAppStore();
const store = useHomeStore();
const { assets } = useAssets(); const { assets } = useAssets();
onRender((ctx) => { onRender((ctx) => {
ctx.fillStyle = "#fbfbfb"
ctx.fillRect(0, 0, LOGICAL_WIDTH, LOGICAL_HEIGHT);
ctx.globalAlpha = store.isIntro && !app.homeIntroPlayed ? store.intro.stage1Opacity : 1;
assets.images.home.bottomScreen.background.draw(ctx, 0, 0); assets.images.home.bottomScreen.background.draw(ctx, 0, 0);
}); });

View File

@@ -1,15 +1,8 @@
<script setup lang="ts"> <script setup lang="ts">
const { onRender } = useScreen(); const { onRender } = useScreen();
const app = useAppStore();
const store = useHomeStore();
const { assets } = useAssets(); const { assets } = useAssets();
onRender((ctx) => { onRender((ctx) => {
ctx.fillStyle = "#fbfbfb"
ctx.fillRect(0, 0, LOGICAL_WIDTH, LOGICAL_HEIGHT);
ctx.globalAlpha = store.isIntro && !app.homeIntroPlayed ? store.intro.stage1Opacity : 1;
assets.images.home.topScreen.background.draw(ctx, 0, 0); assets.images.home.topScreen.background.draw(ctx, 0, 0);
}); });

View File

@@ -1,7 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import gsap from "gsap"; import gsap from "gsap";
const app = useAppStore();
const store = useIntroStore(); const store = useIntroStore();
const { onRender, onClick } = useScreen(); const { onRender, onClick } = useScreen();
const { assets } = useAssets(); const { assets } = useAssets();
@@ -36,7 +35,9 @@ onRender((ctx) => {
ctx.font = "12px NDS12 Bold"; ctx.font = "12px NDS12 Bold";
ctx.letterSpacing = "1px"; ctx.letterSpacing = "1px";
const { actualBoundingBoxRight: width } = ctx.measureText($t("intro.copyright")); const { actualBoundingBoxRight: width } = ctx.measureText(
$t("intro.copyright"),
);
const logoWidth = assets.images.intro.warning.rect.width; const logoWidth = assets.images.intro.warning.rect.width;
const logoX = Math.floor(LOGICAL_WIDTH / 2 - (width + logoWidth + 3) / 2); const logoX = Math.floor(LOGICAL_WIDTH / 2 - (width + logoWidth + 3) / 2);
@@ -65,13 +66,10 @@ onRender((ctx) => {
: store.isOutro : store.isOutro
? store.outro.textOpacity ? store.outro.textOpacity
: hintTextOpacity.value; : hintTextOpacity.value;
fillTextHCentered( fillTextHCentered(ctx, $t("intro.hint"), 0, HINT_Y, LOGICAL_WIDTH);
ctx,
$t("intro.hint"), ctx.globalAlpha = store.isOutro ? store.outro.backgroundOpacity : 0;
0, assets.images.home.topScreen.background.draw(ctx, 0, 0);
HINT_Y,
LOGICAL_WIDTH,
);
}); });
onClick(() => { onClick(() => {

View File

@@ -27,6 +27,9 @@ onRender((ctx) => {
const frame = assets.images.intro.logoAnimated[frameKey]; const frame = assets.images.intro.logoAnimated[frameKey];
frame.draw(ctx, 0, 0); frame.draw(ctx, 0, 0);
ctx.globalAlpha = store.isOutro ? store.outro.backgroundOpacity : 0;
assets.images.home.topScreen.background.draw(ctx, 0, 0);
}); });
</script> </script>

View File

@@ -70,7 +70,8 @@ useKeyUp((key) => {
<div :style="{ visibility: ENABLE_3D ? 'hidden' : 'visible' }"> <div :style="{ visibility: ENABLE_3D ? 'hidden' : 'visible' }">
<div> <div>
<Screen ref="topScreen"> <Screen ref="topScreen">
<HomeTopScreen v-if="app.screen === 'home'" /> <IntroTopScreen v-if="!app.booted" />
<HomeTopScreen v-else-if="app.screen === 'home'" />
<ContactTopScreen v-else-if="app.screen === 'contact'" /> <ContactTopScreen v-else-if="app.screen === 'contact'" />
<ProjectsTopScreen v-else-if="app.screen === 'projects'" /> <ProjectsTopScreen v-else-if="app.screen === 'projects'" />
<SettingsTopScreen v-else-if="app.screen === 'settings'" /> <SettingsTopScreen v-else-if="app.screen === 'settings'" />
@@ -79,7 +80,8 @@ useKeyUp((key) => {
</div> </div>
<div> <div>
<Screen ref="bottomScreen"> <Screen ref="bottomScreen">
<HomeBottomScreen v-if="app.screen === 'home'" /> <IntroBottomScreen v-if="!app.booted" />
<HomeBottomScreen v-else-if="app.screen === 'home'" />
<ContactBottomScreen v-else-if="app.screen === 'contact'" /> <ContactBottomScreen v-else-if="app.screen === 'contact'" />
<ProjectsBottomScreen v-else-if="app.screen === 'projects'" /> <ProjectsBottomScreen v-else-if="app.screen === 'projects'" />
<SettingsBottomScreen v-else-if="app.screen === 'settings'" /> <SettingsBottomScreen v-else-if="app.screen === 'settings'" />

View File

@@ -28,8 +28,6 @@ export const useAppStore = defineStore("app", {
return { return {
booted: false, booted: false,
// shitty but who cares
homeIntroPlayed: false,
settings, settings,
screen: "home" as AppScreen, screen: "home" as AppScreen,
camera: null as THREE.Camera | null, camera: null as THREE.Camera | null,

View File

@@ -25,9 +25,6 @@ export const useHomeStore = defineStore("home", {
const timeline = gsap.timeline({ const timeline = gsap.timeline({
onComplete: () => { onComplete: () => {
this.isIntro = false; this.isIntro = false;
const app = useAppStore();
app.homeIntroPlayed = true;
}, },
}); });
@@ -40,7 +37,7 @@ export const useHomeStore = defineStore("home", {
duration: 0.5, duration: 0.5,
ease: "none", ease: "none",
}, },
0.5, 0,
) )
.fromTo( .fromTo(
this.intro, this.intro,
@@ -50,7 +47,7 @@ export const useHomeStore = defineStore("home", {
duration: 0.15, duration: 0.15,
ease: "none", ease: "none",
}, },
0.85, 0.35,
); );
}, },

View File

@@ -9,6 +9,7 @@ export const useIntroStore = defineStore("intro", {
outro: { outro: {
textOpacity: 1, textOpacity: 1,
backgroundOpacity: 0,
}, },
isIntro: true, isIntro: true,
@@ -59,6 +60,12 @@ export const useIntroStore = defineStore("intro", {
duration: 0.25, duration: 0.25,
ease: "none", ease: "none",
}) })
.to(this.outro, {
backgroundOpacity: 1,
duration: 0.5,
delay: 0.5,
ease: "none",
})
.call(() => { .call(() => {
const app = useAppStore(); const app = useAppStore();
app.booted = true; app.booted = true;