feat: hex patches

This commit is contained in:
2025-04-21 22:05:37 +00:00
parent b75cc8f240
commit e569d57788
9 changed files with 96 additions and 4 deletions

View File

@ -1,5 +1,7 @@
<script setup lang="ts">
import { computed } from 'vue';
import InputNumber from 'primevue/inputnumber';
import InputText from 'primevue/inputtext';
import ToggleSwitch from 'primevue/toggleswitch';
import OptionRow from './OptionRow.vue';
import { usePrfStore } from '../stores';
@ -23,9 +25,26 @@ const setNumber = (key: string, val: number) => {
}
};
defineProps({
const props = defineProps({
patch: Object as () => Patch,
});
// One day, I will repent
const hexModel = computed({
get() {
const hex = (prf.current!.data.patches[props.patch!.id!] as any)?.hex;
if (hex !== undefined) {
return new TextDecoder().decode(new Int8Array(hex).buffer);
} else {
return 'FREE PLAY';
}
},
set(value: string) {
(prf.current!.data.patches[props.patch!.id!] as any) = {
hex: new TextEncoder().encode(value),
};
},
});
</script>
<template>
@ -50,5 +69,6 @@ defineProps({
:max="patch?.max"
:placeholder="(patch?.default ?? 0).toString()"
/>
<InputText v-else-if="patch?.type === 'hex'" v-model="hexModel" />
</OptionRow>
</template>