forked from akanyan/STARTLINER
feat: hex patches
This commit is contained in:
@ -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>
|
||||
|
Reference in New Issue
Block a user