feat: centralize all screen related callbacks in useScreen

This commit is contained in:
2025-12-29 21:01:19 +01:00
parent 4960bef2fc
commit d77d595370
42 changed files with 184 additions and 128 deletions

View File

@@ -1,4 +1,10 @@
<script setup lang="ts">
const { onRender, onClick } = useScreen();
const app = useAppStore();
const store = useSettingsStore();
const { assets } = useAssets();
const GRID_SIZE = 4;
const GRID_START_X = 32;
const GRID_START_Y = 40;
@@ -6,10 +12,6 @@ const CELL_SIZE = 16;
const SPACING = 16;
const ANIMATION_SPEED = 475;
const app = useAppStore();
const store = useSettingsStore();
const { assets } = useAssets();
const originalSelectedCol = app.color.col;
const originalSelectedRow = app.color.row;
@@ -41,7 +43,7 @@ useKeyDown((key) => {
}
});
useScreenClick((x, y) => {
onClick((x, y) => {
const relativeX = x - GRID_START_X;
const relativeY = y - GRID_START_Y;
@@ -59,7 +61,7 @@ useScreenClick((x, y) => {
}
});
useRender((ctx, deltaTime) => {
onRender((ctx, deltaTime) => {
ctx.drawImage(assets.settings.bottomScreen.user.colorPalette, 16, 32);
// animate
@@ -109,7 +111,6 @@ const handleConfirm = () => {
app.save();
openModal({
text: "hey",
showButtons: false,
});
setTimeout(() => {
closeModal();

View File

@@ -4,6 +4,8 @@ const props = defineProps<{
y: number;
}>();
const { onRender } = useScreen();
const settingsStore = useSettingsStore();
const menusContext = inject<{
isSubmenuSelected: ComputedRef<boolean>;
@@ -27,7 +29,7 @@ const isAnyOtherMenuOpen = computed(() => {
const animation = useMenuAnimation("user", isOpen);
useRender((ctx) => {
onRender((ctx) => {
ctx.translate(props.x, props.y);
if (isOpen.value || animation.playing) {