feat: colorize the ui based on the app color

This commit is contained in:
2025-12-28 23:54:23 +01:00
parent 22c9fe2742
commit dafdbdc533
20 changed files with 194 additions and 30 deletions

View File

@@ -0,0 +1,63 @@
<script setup lang="ts">
const props = withDefaults(
defineProps<{
yOffset?: number;
opacity?: number;
title?: string | undefined;
}>(),
{
yOffset: 0,
opacity: 1,
title: undefined,
},
);
const app = useAppStore();
const { assets } = useAssets();
const BAR_WIDTH = 256;
const BAR_HEIGHT = 24;
const TITLE_Y = 5;
useRender((ctx) => {
ctx.globalAlpha = props.opacity;
// top bar
ctx.drawImage(
assets.common.barsSheet,
0,
(app.color.row * 4 + app.color.col) * BAR_HEIGHT,
BAR_WIDTH,
BAR_HEIGHT,
0,
-props.yOffset,
BAR_WIDTH,
BAR_HEIGHT,
);
if (props.title) {
ctx.fillStyle = "#000000";
ctx.font = "10px NDS10";
fillTextCentered(ctx, props.title, 0, TITLE_Y - props.yOffset, 256);
}
ctx.scale(1, -1);
// bottom bar
ctx.drawImage(
assets.common.barsSheet,
0,
(app.color.row * 4 + app.color.col) * BAR_HEIGHT,
BAR_WIDTH,
BAR_HEIGHT,
0,
-192 - props.yOffset,
BAR_WIDTH,
BAR_HEIGHT,
);
});
defineOptions({
render: () => null,
});
</script>

View File

@@ -9,9 +9,11 @@ const props = withDefaults(
}, },
); );
const app = useAppStore();
const { assets } = useAssets(); const { assets } = useAssets();
const ANIMATION_SPEED = 0.25; const ANIMATION_SPEED = 0.25;
const CORNER_SIZE = 11;
let [currentX, currentY, currentWidth, currentHeight] = props.rect; let [currentX, currentY, currentWidth, currentHeight] = props.rect;
@@ -43,21 +45,67 @@ useRender((ctx) => {
ctx.globalAlpha = props.opacity; ctx.globalAlpha = props.opacity;
ctx.drawImage(assets.common.selectorCorner, x, y); const spriteY = (app.color.row * 4 + app.color.col) * CORNER_SIZE;
// Top-left corner
ctx.drawImage(
assets.common.selectorCornersSheet,
0,
spriteY,
CORNER_SIZE,
CORNER_SIZE,
x,
y,
CORNER_SIZE,
CORNER_SIZE,
);
// Top-right corner
ctx.save(); ctx.save();
ctx.scale(-1, 1); ctx.scale(-1, 1);
ctx.drawImage(assets.common.selectorCorner, -(x + w), y); ctx.drawImage(
assets.common.selectorCornersSheet,
0,
spriteY,
CORNER_SIZE,
CORNER_SIZE,
-(x + w),
y,
CORNER_SIZE,
CORNER_SIZE,
);
ctx.restore(); ctx.restore();
// Bottom-left corner
ctx.save(); ctx.save();
ctx.scale(1, -1); ctx.scale(1, -1);
ctx.drawImage(assets.common.selectorCorner, x, -(y + h)); ctx.drawImage(
assets.common.selectorCornersSheet,
0,
spriteY,
CORNER_SIZE,
CORNER_SIZE,
x,
-(y + h),
CORNER_SIZE,
CORNER_SIZE,
);
ctx.restore(); ctx.restore();
// Bottom-right corner
ctx.save(); ctx.save();
ctx.scale(-1, -1); ctx.scale(-1, -1);
ctx.drawImage(assets.common.selectorCorner, -(x + w), -(y + h)); ctx.drawImage(
assets.common.selectorCornersSheet,
0,
spriteY,
CORNER_SIZE,
CORNER_SIZE,
-(x + w),
-(y + h),
CORNER_SIZE,
CORNER_SIZE,
);
ctx.restore(); ctx.restore();
}); });

View File

@@ -4,7 +4,6 @@
import Background from "./Background.vue"; import Background from "./Background.vue";
import Buttons from "./Buttons.vue"; import Buttons from "./Buttons.vue";
import ButtonSelector from "~/components/Common/ButtonSelector.vue"; import ButtonSelector from "~/components/Common/ButtonSelector.vue";
import Bars from "./Bars.vue";
const store = useContactStore(); const store = useContactStore();
const { open: openModal, state: modalState } = useConfirmationModal(); const { open: openModal, state: modalState } = useConfirmationModal();
@@ -105,16 +104,24 @@ useKeyDown((key) => {
" "
/> />
<Bars /> <CommonBars
title="Choose a Chat Room to join."
:opacity="
store.isIntro ? store.intro.stage3Opacity : store.outro.stage2Opacity
"
:y-offset="store.isIntro ? store.intro.barOffsetY : 0"
/>
<CommonConfirmationModal /> <CommonConfirmationModal />
<CommonButtons <CommonButtons
:y-offset=" :y-offset="
store.isIntro store.isIntro ? store.intro.barOffsetY : modalState.buttonsYOffset
? store.intro.bottomBarY - (SCREEN_HEIGHT - 24)
: modalState.buttonsYOffset
" "
:opacity=" :opacity="
store.isIntro ? store.intro.stage3Opacity : store.outro.stage2Opacity store.isIntro
? store.intro.stage3Opacity
: store.isOutro
? store.outro.stage2Opacity
: 1
" "
b-label="Quit" b-label="Quit"
:a-label="ACTIONS[selectedButton][0]" :a-label="ACTIONS[selectedButton][0]"

View File

@@ -1,5 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
// NOTE: calendar background is handled by TopScreenBackground // NOTE: calendar background is handled by TopScreenBackground
const app = useAppStore();
const store = useHomeStore(); const store = useHomeStore();
const { assets } = useAssets(); const { assets } = useAssets();
@@ -12,6 +13,7 @@ useRender((ctx) => {
const CALENDAR_ROWS = 5; const CALENDAR_ROWS = 5;
const CALENDAR_LEFT = 128; const CALENDAR_LEFT = 128;
const CALENDAR_TOP = 64; const CALENDAR_TOP = 64;
const SELECTOR_SIZE = 13;
ctx.fillStyle = "#343434"; ctx.fillStyle = "#343434";
@@ -61,9 +63,15 @@ useRender((ctx) => {
if (now.getDate() === day) { if (now.getDate() === day) {
ctx.drawImage( ctx.drawImage(
assets.home.topScreen.calendar.daySelector, assets.home.topScreen.calendar.daySelectorsSheet,
cellLeft, 0,
cellTop, (app.color.row * 4 + app.color.col) * SELECTOR_SIZE,
SELECTOR_SIZE,
SELECTOR_SIZE,
cellLeft + 1,
cellTop + 1,
SELECTOR_SIZE,
SELECTOR_SIZE,
); );
} }

View File

@@ -2,6 +2,7 @@
const CENTER_X = 63; const CENTER_X = 63;
const CENTER_Y = 95; const CENTER_Y = 95;
const app = useAppStore();
const store = useHomeStore(); const store = useHomeStore();
const { assets } = useAssets(); const { assets } = useAssets();
@@ -86,7 +87,7 @@ useRender((ctx) => {
23, 23,
2, 2,
); );
renderHand(now.getSeconds() / 60, "#49db8a", 35, 2); renderHand(now.getSeconds() / 60, app.color.hex, 35, 2);
ctx.fillStyle = "#494949"; ctx.fillStyle = "#494949";
ctx.fillRect(CENTER_X - 2, CENTER_Y - 2, 5, 5); ctx.fillRect(CENTER_X - 2, CENTER_Y - 2, 5, 5);

View File

@@ -1,8 +1,12 @@
<script setup lang="ts"> <script setup lang="ts">
const app = useAppStore();
const store = useHomeStore(); const store = useHomeStore();
const { assets } = useAssets(); const { assets } = useAssets();
const BAR_WIDTH = 256;
const BAR_HEIGHT = 16;
useRender((ctx) => { useRender((ctx) => {
const TEXT_Y = 11; const TEXT_Y = 11;
@@ -10,7 +14,17 @@ useRender((ctx) => {
ctx.globalAlpha = ctx.globalAlpha =
store.isOutro && store.outro.animateTop ? store.outro.stage2Opacity : 1; store.isOutro && store.outro.animateTop ? store.outro.stage2Opacity : 1;
ctx.drawImage(assets.home.topScreen.statusBar.statusBar, 0, 0); ctx.drawImage(
assets.home.topScreen.statusBar.statusBarsSheet,
0,
(app.color.row * 4 + app.color.col) * BAR_HEIGHT,
BAR_WIDTH,
BAR_HEIGHT,
0,
0,
BAR_WIDTH,
BAR_HEIGHT,
);
ctx.fillStyle = "#ffffff"; ctx.fillStyle = "#ffffff";
ctx.font = "7px NDS7"; ctx.font = "7px NDS7";

View File

@@ -3,8 +3,6 @@ const { assets } = useAssets();
useRender((ctx) => { useRender((ctx) => {
ctx.drawImage(assets.home.bottomScreen.background, 0, 0); ctx.drawImage(assets.home.bottomScreen.background, 0, 0);
ctx.drawImage(assets.settings.bottomScreen.topBar, 0, 0);
ctx.drawImage(assets.settings.bottomScreen.bottomBar, 0, 168);
}); });
defineOptions({ defineOptions({

View File

@@ -5,5 +5,6 @@ import Menus from "./Menus/Menus.vue";
<template> <template>
<Background /> <Background />
<CommonBars />
<Menus /> <Menus />
</template> </template>

View File

@@ -1,4 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
const app = useAppStore();
const { assets } = useAssets(); const { assets } = useAssets();
useRender((ctx) => { useRender((ctx) => {
@@ -11,6 +12,7 @@ useRender((ctx) => {
const CALENDAR_ROWS = 5; const CALENDAR_ROWS = 5;
const CALENDAR_LEFT = 128; const CALENDAR_LEFT = 128;
const CALENDAR_TOP = 64; const CALENDAR_TOP = 64;
const SELECTOR_SIZE = 13;
ctx.fillStyle = "#343434"; ctx.fillStyle = "#343434";
@@ -50,9 +52,15 @@ useRender((ctx) => {
if (now.getDate() === day) { if (now.getDate() === day) {
ctx.drawImage( ctx.drawImage(
assets.home.topScreen.calendar.daySelector, assets.home.topScreen.calendar.daySelectorsSheet,
cellLeft, 0,
cellTop, (app.color.row * 4 + app.color.col) * SELECTOR_SIZE,
SELECTOR_SIZE,
SELECTOR_SIZE,
cellLeft + 1,
cellTop + 1,
SELECTOR_SIZE,
SELECTOR_SIZE,
); );
} }

View File

@@ -2,6 +2,7 @@
const CENTER_X = 63; const CENTER_X = 63;
const CENTER_Y = 95; const CENTER_Y = 95;
const app = useAppStore();
const { assets } = useAssets(); const { assets } = useAssets();
function drawLine( function drawLine(
@@ -76,7 +77,7 @@ useRender((ctx) => {
23, 23,
2, 2,
); );
renderHand(now.getSeconds() / 60, "#49db8a", 35, 2); renderHand(now.getSeconds() / 60, app.color.hex, 35, 2);
ctx.fillStyle = "#494949"; ctx.fillStyle = "#494949";
ctx.fillRect(CENTER_X - 2, CENTER_Y - 2, 5, 5); ctx.fillRect(CENTER_X - 2, CENTER_Y - 2, 5, 5);

View File

@@ -1,10 +1,24 @@
<script setup lang="ts"> <script setup lang="ts">
const app = useAppStore();
const { assets } = useAssets(); const { assets } = useAssets();
const BAR_WIDTH = 256;
const BAR_HEIGHT = 16;
useRender((ctx) => { useRender((ctx) => {
const TEXT_Y = 11; const TEXT_Y = 11;
ctx.drawImage(assets.home.topScreen.statusBar.statusBar, 0, 0); ctx.drawImage(
assets.home.topScreen.statusBar.statusBarsSheet,
0,
(app.color.row * 4 + app.color.col) * BAR_HEIGHT,
BAR_WIDTH,
BAR_HEIGHT,
0,
0,
BAR_WIDTH,
BAR_HEIGHT,
);
ctx.fillStyle = "#ffffff"; ctx.fillStyle = "#ffffff";
ctx.font = "7px NDS7"; ctx.font = "7px NDS7";

View File

@@ -9,8 +9,7 @@ export const useContactStore = defineStore("contact", {
titleY: SCREEN_HEIGHT, titleY: SCREEN_HEIGHT,
topBarY: -20, barOffsetY: 20,
bottomBarY: SCREEN_HEIGHT + 20,
}, },
outro: { outro: {
@@ -60,13 +59,11 @@ export const useContactStore = defineStore("contact", {
this.intro, this.intro,
{ {
stage3Opacity: 0, stage3Opacity: 0,
topBarY: -20, barOffsetY: 20,
bottomBarY: SCREEN_HEIGHT - 4,
}, },
{ {
stage3Opacity: 1, stage3Opacity: 1,
topBarY: 0, barOffsetY: 0,
bottomBarY: SCREEN_HEIGHT - 24,
duration: 0.1, duration: 0.1,
ease: "none", ease: "none",
}, },
@@ -93,7 +90,6 @@ export const useContactStore = defineStore("contact", {
const timeline = gsap.timeline({ const timeline = gsap.timeline({
onComplete: () => { onComplete: () => {
setTimeout(() => { setTimeout(() => {
this.isOutro = false;
const router = useRouter(); const router = useRouter();
router.push({ query: {} }); router.push({ query: {} });
}, 2000); }, 2000);

View File

@@ -29,7 +29,12 @@
}, },
"user": { "user": {
"title": "User", "title": "User",
"description": "Enter user informations." "description": "Enter user informations.",
"color": {
"title": "Color",
"description": "Select your favorite color."
}
}, },
"touchScreen": { "touchScreen": {
"title": "Touch Screen", "title": "Touch Screen",

Binary file not shown.

After

Width:  |  Height:  |  Size: 770 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 160 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 468 B