support zimnego startu lokomotyw

This commit is contained in:
2023-07-13 17:51:09 +02:00
parent 7362d4ffbd
commit cbe983f96c
11 changed files with 108 additions and 81 deletions
+2 -18
View File
@@ -107,10 +107,8 @@
<script lang="ts">
import { defineComponent } from 'vue';
import { IStock } from '../../types';
import imageMixin from '../../mixins/imageMixin';
import { useStore } from '../../store';
import { isLocomotive } from '../../utils/vehicleUtils';
import stockPreviewMixin from '../../mixins/stockPreviewMixin';
import stockMixin from '../../mixins/stockMixin';
@@ -197,22 +195,8 @@ export default defineComponent({
if (!vehicle) return;
const stockObj: IStock = {
id: `${Date.now()}`,
useType: isLocomotive(vehicle) ? vehicle.power : vehicle.useType,
type: vehicle.type,
length: vehicle.length,
mass: vehicle.mass,
maxSpeed: vehicle.maxSpeed,
isLoco: isLocomotive(vehicle),
cargo:
!isLocomotive(vehicle) && vehicle.loadable && this.store.chosenCargo ? this.store.chosenCargo : undefined,
count: 1,
imgSrc: vehicle.imageSrc,
supportersOnly: vehicle.supportersOnly,
};
this.store.stockList[this.store.chosenStockListIndex] = stockObj;
const stockObject = this.getStockObject(vehicle, this.store.chosenCargo);
this.store.stockList[this.store.chosenStockListIndex] = stockObject;
},
},
});
+1 -3
View File
@@ -49,12 +49,10 @@ const sectionKeyIndexes: { [key: number]: SectionMode } = {
};
onMounted(() => {
console.log(sectionButtonRefs.value);
window.addEventListener('keydown', (e) => {
if (e.target instanceof HTMLInputElement) return;
if (e.key == '1' || e.key == '2' || e.key == '3' || e.key == '4') {
if (/[1234]/.test(e.key)) {
const keyNum = Number(e.key);
store.stockSectionMode = sectionKeyIndexes[keyNum];
(sectionButtonRefs.value[keyNum - 1] as HTMLButtonElement).focus();