93 lines
2.3 KiB
Vue
93 lines
2.3 KiB
Vue
<script setup lang="ts">
|
|
import NOTIFICATION_IMAGE from "/assets/images/settings/top-screen/notification.webp";
|
|
import SETTINGS_IMAGE from "/assets/images/settings/top-screen/settings.webp";
|
|
import OPTIONS_IMAGE from "/assets/images/settings/top-screen/options/options.webp";
|
|
import CLOCK_IMAGE from "/assets/images/settings/top-screen/clock/clock.webp";
|
|
import USER_IMAGE from "/assets/images/settings/top-screen/user/user.webp";
|
|
import TOUCH_SCREEN_IMAGE from "/assets/images/settings/top-screen/touch_screen/touch-screen.webp";
|
|
|
|
const store = useSettingsStore();
|
|
|
|
const [
|
|
notificationImage,
|
|
settingsImage,
|
|
optionsImage,
|
|
clockImage,
|
|
userImage,
|
|
touchScreenImage,
|
|
] = useImages(
|
|
NOTIFICATION_IMAGE,
|
|
SETTINGS_IMAGE,
|
|
OPTIONS_IMAGE,
|
|
CLOCK_IMAGE,
|
|
USER_IMAGE,
|
|
TOUCH_SCREEN_IMAGE,
|
|
);
|
|
|
|
const activeMenu = computed(() => {
|
|
if (!store.activeMenu) return null;
|
|
|
|
if (/^options[A-Z]/.test(store.activeMenu)) {
|
|
return { id: "options", image: optionsImage };
|
|
}
|
|
if (/^clock[A-Z]/.test(store.activeMenu)) {
|
|
return { id: "clock", image: clockImage };
|
|
}
|
|
if (/^user[A-Z]/.test(store.activeMenu)) {
|
|
return { id: "user", image: userImage };
|
|
}
|
|
if (/^touchScreen[A-Z]/.test(store.activeMenu)) {
|
|
return { id: "touchScreen", image: touchScreenImage };
|
|
}
|
|
|
|
return null;
|
|
});
|
|
|
|
const renderNotification = (
|
|
ctx: CanvasRenderingContext2D,
|
|
image: HTMLImageElement,
|
|
title: string,
|
|
description: string,
|
|
) => {
|
|
ctx.drawImage(notificationImage!, 0, 0);
|
|
ctx.drawImage(image, 2, 2);
|
|
|
|
ctx.font = "10px NDS10";
|
|
ctx.fillStyle = "#282828";
|
|
ctx.fillText(title, 52, 13);
|
|
|
|
ctx.fillStyle = "#fbfbfb";
|
|
const lines = description.split("\n");
|
|
const textY = lines.length === 1 ? 36 : 28;
|
|
for (let i = 0; i < lines.length; i += 1) {
|
|
ctx.fillText(lines[i]!, 52, textY + 14 * i);
|
|
}
|
|
};
|
|
|
|
useRender((ctx) => {
|
|
ctx.translate(0, activeMenu.value ? 144 - 16 : 144);
|
|
|
|
renderNotification(
|
|
ctx,
|
|
settingsImage!,
|
|
$t(`settings.title`),
|
|
$t(`settings.description`),
|
|
);
|
|
|
|
if (activeMenu.value) {
|
|
ctx.translate(0, 16);
|
|
|
|
renderNotification(
|
|
ctx,
|
|
activeMenu.value.image!,
|
|
$t(`settings.${activeMenu.value.id}.title`),
|
|
$t(`settings.${activeMenu.value.id}.description`),
|
|
);
|
|
}
|
|
});
|
|
|
|
defineOptions({
|
|
render: () => null,
|
|
});
|
|
</script>
|