Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new default boat profile #1419

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 78 additions & 6 deletions src/assets/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -541,12 +541,50 @@ export const widgetProfiles: Profile[] = [
visible: true,
widgets: [
{
hash: '6439e791-3031-4928-aff2-8bd9af713798',
hash: '2f32cbb5-7031-42a1-b26e-8c110f5cfc0b',
name: 'VirtualHorizon',
component: WidgetType.VirtualHorizon,
position: {
x: 0.8470340414647122,
y: 0.030779937236477317,
},
size: {
width: 0.06129068105944188,
height: 0.11777527653033051,
},
options: {},
},
{
hash: 'c00ae733-0290-48be-93e3-cba986d9b19a',
name: 'Compass',
component: WidgetType.Compass,
position: {
x: 0.7791262675380712,
y: 0.030779937236477317,
},
size: {
width: 0.06129068105944188,
height: 0.11777527653033051,
},
options: {
headingStyle: 'North Up',
},
},
{
hash: 'd18e02c2-96ba-43fa-9135-7b4feedee580',
name: 'Main Map',
component: WidgetType.Map,
position: { x: 0, y: 0 },
size: { width: 1, height: 1 },
options: {},
position: {
x: 0,
y: 0,
},
size: {
width: 1,
height: 1,
},
options: {
showVehiclePath: true,
},
},
],
miniWidgetContainers: [
Expand All @@ -561,8 +599,42 @@ export const widgetProfiles: Profile[] = [
},
],
},
{ name: 'Bottom-center container', widgets: [] },
{ name: 'Bottom-right container', widgets: [] },
{
name: 'Bottom-center container',
widgets: [
{
component: MiniWidgetType.ArmerButton,
name: 'ArmerButton',
options: {},
hash: 'ecb8299e-8a98-4e95-a399-aa01ddf3d7b5',
},
{
component: MiniWidgetType.VeryGenericIndicator,
name: 'Speed (GPS)',
options: {
displayName: 'Speed (GPS)',
variableName: 'VFR_HUD/groundspeed',
iconName: 'mdi-car-speed-limiter',
variableUnit: 'm/s',
variableMultiplier: 1,
decimalPlaces: 1,
widgetWidth: 160,
},
hash: 'dfa95e38-47e0-4656-b863-c22029b89862',
},
],
},
{
name: 'Bottom-right container',
widgets: [
{
component: MiniWidgetType.ModeSelector,
name: 'ModeSelector',
options: {},
hash: 'da8ad20e-e38c-4250-ad28-57b777c04a98',
},
],
},
],
},
],
Expand Down
65 changes: 59 additions & 6 deletions src/components/mini-widgets/VeryGenericIndicator.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
<template>
<div class="h-12 p-1 text-white transition-all w-[8.5rem] relative scroll-container">
<div
class="h-12 p-1 min-w-[8.5rem] text-white transition-all relative scroll-container"
:class="{
'border-[1px] border-dashed border-[#FFFFFF55]': widgetStore.miniWidgetManagerVars(miniWidget.hash)
.configMenuOpen,
}"
:style="{ width: miniWidget.options.widgetWidth + 'px' }"
>
<span class="h-full left-[0.5rem] bottom-[5%] absolute mdi text-[2.25rem]" :class="[miniWidget.options.iconName]" />
<div class="absolute left-[3rem] h-full select-none font-semibold scroll-container w-[5.5rem]">
<div class="absolute left-[3rem] h-full select-none font-semibold scroll-container w-full">
<div class="w-full" :class="{ 'scroll-text': valueIsOverflowing }">
<span class="font-mono text-xl leading-6">{{ parsedState }}</span>
<span class="text-xl leading-6"> {{ String.fromCharCode(0x20) }} {{ miniWidget.options.variableUnit }} </span>
Expand Down Expand Up @@ -38,9 +45,19 @@
</v-card-title>

<div v-if="currentTab === 'custom'" class="flex flex-col items-center justify-around">
<div class="flex flex-col items-center justify-between w-full mt-3">
<span class="w-full mb-1 text-sm text-slate-100/50">Display name</span>
<input v-model="miniWidget.options.displayName" class="w-full px-2 py-1 rounded-md bg-[#FFFFFF12]" />
<div class="flex w-full gap-x-10">
<div class="flex flex-col items-center justify-between w-3/4 mt-3">
<span class="w-full mb-1 text-sm text-slate-100/50">Display name</span>
<input v-model="miniWidget.options.displayName" class="w-full px-2 py-1 rounded-md bg-[#FFFFFF12]" />
</div>
<div class="flex flex-col items-center justify-between w-1/4 mt-3">
<span class="w-full text-sm text-slate-100/50">Display Width</span>
<input
v-model="miniWidget.options.widgetWidth"
type="number"
class="w-full px-2 py-1 rounded-md bg-[#FFFFFF12]"
/>
</div>
</div>
<div class="flex flex-col items-center justify-between w-full mt-3">
<span class="w-full mb-1 text-sm text-slate-100/50">Variable</span>
Expand All @@ -58,6 +75,7 @@
/>
</div>
</div>

<Transition>
<div v-if="showVariableChooseModal" class="flex flex-col justify-center w-full mx-1 my-3 align-center">
<input
Expand Down Expand Up @@ -86,6 +104,17 @@
<span class="w-full mb-1 text-sm text-slate-100/50">Multiplier</span>
<input v-model="miniWidget.options.variableMultiplier" class="w-full px-2 py-1 rounded-md bg-[#FFFFFF12]" />
</div>
<div class="flex flex-col items-center justify-between w-full mx-5">
<span class="w-full mb-1 text-sm text-slate-100/50">Decimal Places</span>
<input
v-model="miniWidget.options.decimalPlaces"
type="number"
min="0"
max="5"
placeholder="Auto-formatting"
class="w-full px-2 py-1 rounded-md bg-[#FFFFFF12]"
/>
</div>
</div>
<div class="flex flex-col items-center justify-between w-full mt-3">
<span class="w-full mb-1 text-sm text-slate-100/50">Icon</span>
Expand Down Expand Up @@ -184,14 +213,15 @@ const props = defineProps<{
const miniWidget = toRefs(props).miniWidget

onBeforeMount(() => {
// Set initial widget options if they don't exist
if (Object.keys(miniWidget.value.options).length === 0) {
Object.assign(miniWidget.value.options, {
displayName: '',
variableName: '',
iconName: 'mdi-help-box',
variableUnit: '%',
variableMultiplier: 1,
decimalPlaces: null,
widgetWidth: 136,
})
}

Expand All @@ -206,12 +236,18 @@ const widgetStore = useWidgetManagerStore()
const currentState = ref<unknown>(0)

const finalValue = computed(() => Number(miniWidget.value.options.variableMultiplier) * Number(currentState.value))

const parsedState = computed(() => {
if (currentState.value === undefined) {
return '--'
}
const value = finalValue.value

const decimalPlaces = miniWidget.value.options.decimalPlaces
if (decimalPlaces !== null && !isNaN(decimalPlaces)) {
return value.toFixed(decimalPlaces)
}

if (value < 0 && value > -10) return value.toFixed(1)
if (value <= -10 && value > -100) return value.toFixed(1)
if (value <= -100 && value > -1000) return value.toFixed(0)
Expand Down Expand Up @@ -280,6 +316,22 @@ const logCurrentState = (): void => {
}
}

watch(
() => miniWidget.value.options.decimalPlaces,
(newVal) => {
if (newVal === '' || newVal === null || newVal === undefined) {
miniWidget.value.options.decimalPlaces = null
} else {
const num = Number(newVal)
if (!isNaN(num) && num >= 0 && Number.isInteger(num)) {
miniWidget.value.options.decimalPlaces = num
} else {
miniWidget.value.options.decimalPlaces = null
}
}
}
)

watch(
finalValue,
() => {
Expand All @@ -291,6 +343,7 @@ watch(
)

watch(store.genericVariables, () => updateVariableState())

watch(
() => store.availableGenericVariables,
() => updateGenericVariablesNames(),
Expand Down
Loading