Merge pull request #41 from Spythere/development

chore: updated vehicle data for 2024.3.1 simulator version
This commit is contained in:
Spythere
2024-12-23 16:24:16 +01:00
committed by GitHub
6 changed files with 91 additions and 9 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

+17 -6
View File
@@ -4,7 +4,7 @@
<div class="image-wrapper"> <div class="image-wrapper">
<img <img
:src="getThumbnailURL(store.chosenVehicle.type, 'small')" :src="getThumbnailURL(store.chosenVehicle.type, 'small')"
:data-preview-active="store.chosenVehicle !== null" :data-preview-available="isDataPreviewAvailable"
:data-sponsor-only=" :data-sponsor-only="
store.chosenVehicle.sponsorOnlyTimestamp && store.chosenVehicle.sponsorOnlyTimestamp &&
store.chosenVehicle.sponsorOnlyTimestamp > Date.now() store.chosenVehicle.sponsorOnlyTimestamp > Date.now()
@@ -111,30 +111,41 @@ export default defineComponent({
}; };
}, },
computed: {
isDataPreviewAvailable() {
return this.imageStatus == 'loaded' && this.store.chosenVehicle != null;
},
},
methods: { methods: {
isTractionUnit, isTractionUnit,
onImageError(e: Event) { onImageError(e: Event) {
const el = e.target as HTMLImageElement; const el = e.target as HTMLImageElement;
if (el.src == '/images/placeholder.jpg') return; if (el.src == '/images/no-vehicle-image.png') return;
el.src = '/images/placeholder.jpg'; el.src = '/images/no-vehicle-image.png';
this.imageStatus = 'error'; this.imageStatus = 'error';
}, },
onImageLoad(e: Event) { onImageLoad(e: Event) {
if (this.imageStatus == 'error') return;
this.imageStatus = 'loaded'; this.imageStatus = 'loaded';
}, },
onImageClick(e: Event) { onImageClick(e: Event) {
const target = e.target as HTMLElement; const target = e.target as HTMLImageElement;
const chosenVehicle = this.store.chosenVehicle; const chosenVehicle = this.store.chosenVehicle;
if (!chosenVehicle) return; if (!chosenVehicle) return;
this.store.lastFocusedElement = target; this.store.lastFocusedElement = target;
this.store.vehiclePreviewSrc = this.getThumbnailURL(chosenVehicle.type, 'large');
if (this.isDataPreviewAvailable) {
this.store.vehiclePreviewSrc = this.getThumbnailURL(chosenVehicle.type, 'large');
}
}, },
}, },
}); });
@@ -161,7 +172,7 @@ export default defineComponent({
img { img {
width: 100%; width: 100%;
&[data-preview-active='true'] { &[data-preview-available='true'] {
border: 1px solid white; border: 1px solid white;
cursor: zoom-in; cursor: zoom-in;
} }
+13 -1
View File
@@ -60,7 +60,12 @@
@keydown.enter="onVehicleSelect(vehicle)" @keydown.enter="onVehicleSelect(vehicle)"
tabindex="0" tabindex="0"
> >
<img loading="lazy" width="120" :src="getThumbnailURL(vehicle.type, 'small')" /> <img
loading="lazy"
width="120"
:src="getThumbnailURL(vehicle.type, 'small')"
@error="onThumbnailImageError"
/>
<span> <span>
<span <span
@@ -163,6 +168,13 @@ export default defineComponent({
methods: { methods: {
isTractionUnit, isTractionUnit,
onThumbnailImageError(e: Event) {
const el = e.target as HTMLImageElement;
if (el.src == '/images/no-vehicle-image.png') return;
el.src = '/images/no-vehicle-image.png';
},
onVehicleSelect(vehicle: IVehicle) { onVehicleSelect(vehicle: IVehicle) {
if (this.store.chosenVehicle?.type === vehicle.type) this.addVehicle(vehicle); if (this.store.chosenVehicle?.type === vehicle.type) this.addVehicle(vehicle);
this.previewVehicle(vehicle); this.previewVehicle(vehicle);
@@ -5,7 +5,7 @@
@keydown.esc="store.vehiclePreviewSrc = ''" @keydown.esc="store.vehiclePreviewSrc = ''"
tabindex="0" tabindex="0"
> >
<img :src="store.vehiclePreviewSrc" alt="preview" /> <img :src="store.vehiclePreviewSrc" alt="preview" @error="onImageError" />
</div> </div>
</template> </template>
@@ -23,6 +23,14 @@ export default defineComponent({
mounted() { mounted() {
this.$el.focus(); this.$el.focus();
}, },
methods: {
onImageError(event: Event) {
if(!event.target || !(event.target instanceof HTMLImageElement)) return
event.target.src = '/images/no-vehicle-image.png';
},
},
}); });
</script> </script>
+51
View File
@@ -98,5 +98,56 @@
"2400000": 20 "2400000": 20
}, },
"none": 90 "none": 90
},
"M62": {
"passenger": {
"500000": 100,
"800000": 80,
"1200000": 60,
"2000000": 40,
"3000000": 20
},
"cargo": {
"500000": 100,
"800000": 80,
"1200000": 60,
"2000000": 40,
"3000000": 20
},
"none": 100
},
"ST44": {
"passenger": {
"500000": 100,
"800000": 80,
"1200000": 60,
"2000000": 40,
"3000000": 20
},
"cargo": {
"500000": 100,
"800000": 80,
"1200000": 60,
"2000000": 40,
"3000000": 20
},
"none": 100
},
"CTLR4C": {
"passenger": {
"500000": 100,
"800000": 80,
"1200000": 60,
"2000000": 40,
"3000000": 20
},
"cargo": {
"500000": 100,
"800000": 80,
"1200000": 60,
"2000000": 40,
"3000000": 20
},
"none": 100
} }
} }
+1 -1
View File
@@ -57,7 +57,7 @@ export const useStore = defineStore({
lastFocusedElement: null as HTMLElement | null, lastFocusedElement: null as HTMLElement | null,
compatibleSimulatorVersion: '2024.2.1', compatibleSimulatorVersion: '2024.3.1',
}), }),
getters: { getters: {