mirror of
https://github.com/Spythere/pojazdownik.git
synced 2026-05-03 05:18:10 +00:00
added double manning checkbox & support
This commit is contained in:
@@ -79,11 +79,20 @@
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="stock_cold-start">
|
||||
<label>
|
||||
<input type="checkbox" v-model="store.isColdStart" :disabled="!locoSupportsColdStart(store.stockList[0]?.constructionType || '')" />
|
||||
<div class="stock_spawn-settings">
|
||||
<label v-if="store.stockSupportsColdStart">
|
||||
<input type="checkbox" v-model="store.isColdStart" />
|
||||
{{ $t('stocklist.coldstart-info') }}
|
||||
</label>
|
||||
|
||||
<label v-if="store.stockSupportsDoubleManning">
|
||||
<input type="checkbox" v-model="store.isDoubleManned" />
|
||||
{{ $t('stocklist.doublemanning-info') }}
|
||||
</label>
|
||||
<!-- <label v-if="store.stockList.length > 0 && locoSupportsDoubleManning(store.stockList[0].constructionType)">
|
||||
<input type="checkbox" v-model="store.isDoubleManned" />
|
||||
{{ $t('stocklist.coldstart-info') }}
|
||||
</label> -->
|
||||
</div>
|
||||
|
||||
<div class="stock_warnings" v-if="stockHasWarnings">
|
||||
@@ -158,7 +167,6 @@ import { defineComponent } from 'vue';
|
||||
|
||||
import { useStore } from '../../store';
|
||||
|
||||
import { locoSupportsColdStart } from '../../utils/locoUtils';
|
||||
import warningsMixin from '../../mixins/warningsMixin';
|
||||
import imageMixin from '../../mixins/imageMixin';
|
||||
import stockPreviewMixin from '../../mixins/stockPreviewMixin';
|
||||
@@ -188,12 +196,19 @@ export default defineComponent({
|
||||
|
||||
computed: {
|
||||
stockString() {
|
||||
if (this.store.stockList.length == 0) return '';
|
||||
|
||||
const includeColdStart = this.store.isColdStart && this.store.stockSupportsColdStart;
|
||||
const includeDoubleManned = this.store.isDoubleManned && this.store.stockSupportsDoubleManning;
|
||||
|
||||
return this.store.stockList
|
||||
.map((stock, i) => {
|
||||
let stockTypeStr = stock.isLoco || !stock.cargo ? stock.type : `${stock.type}:${stock.cargo.id}`;
|
||||
let coldStart = i == 0 && this.store.isColdStart && locoSupportsColdStart(stock.constructionType || '') ? ',c' : '';
|
||||
|
||||
return stockTypeStr + coldStart;
|
||||
if (i == 0 && (includeColdStart || includeDoubleManned))
|
||||
return `${stockTypeStr},${includeColdStart ? 'c' : ''}${includeDoubleManned ? 'd' : ''}`;
|
||||
|
||||
return stockTypeStr;
|
||||
})
|
||||
.join(';');
|
||||
},
|
||||
@@ -212,8 +227,6 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
methods: {
|
||||
locoSupportsColdStart,
|
||||
|
||||
copyToClipboard() {
|
||||
navigator.clipboard.writeText(this.stockString);
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
|
||||
<td v-if="currentFilterMode == 'carriages'">{{ !isLocomotive(vehicle) ? vehicle.cargoList.length : '---' }}</td>
|
||||
<td v-if="currentFilterMode == 'tractions'">
|
||||
{{ isLocomotive(vehicle) ? (locoSupportsColdStart(vehicle.constructionType) ? `✓` : '✗') : '---' }}
|
||||
{{ isLocomotive(vehicle) ? (vehicle.coldStart ? `✓` : '✗') : '---' }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -86,7 +86,6 @@ import { Vehicle } from '../../types';
|
||||
import { isLocomotive } from '../../utils/vehicleUtils';
|
||||
import stockMixin from '../../mixins/stockMixin';
|
||||
import imageMixin from '../../mixins/imageMixin';
|
||||
import { locoSupportsColdStart } from '../../utils/locoUtils';
|
||||
|
||||
type SorterID = 'type' | 'constructionType' | 'image' | 'length' | 'mass' | 'maxSpeed' | 'cargoCount' | 'group' | 'coldStart';
|
||||
|
||||
@@ -143,7 +142,6 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
methods: {
|
||||
locoSupportsColdStart,
|
||||
isLocomotive,
|
||||
|
||||
toggleFilter(name: typeof this.currentFilterMode) {
|
||||
@@ -180,7 +178,10 @@ export default defineComponent({
|
||||
);
|
||||
|
||||
case 'coldStart':
|
||||
return (locoSupportsColdStart(row1.vehicle.constructionType) > locoSupportsColdStart(row2.vehicle.constructionType) ? 1 : -1) * direction;
|
||||
return (
|
||||
((isLocomotive(row1.vehicle) && row1.vehicle.coldStart ? 1 : -1) - (isLocomotive(row2.vehicle) && row2.vehicle.coldStart ? 1 : -1)) *
|
||||
direction
|
||||
);
|
||||
|
||||
default:
|
||||
break;
|
||||
@@ -200,8 +201,6 @@ export default defineComponent({
|
||||
(this.currentFilterMode == 'all' ||
|
||||
(this.currentFilterMode == 'tractions' && isLocomotive(vehicle)) ||
|
||||
(this.currentFilterMode == 'carriages' && !isLocomotive(vehicle))),
|
||||
|
||||
// ((this.filters.tractions && isLocomotive(vehicle)) || (this.filters.carriages && !isLocomotive(vehicle))),
|
||||
}))
|
||||
.sort((a, b) => this.sortTableRows(a, b));
|
||||
},
|
||||
|
||||
+2
-1
@@ -64,7 +64,8 @@
|
||||
"mass-accepted": "accepted",
|
||||
"length": "Length",
|
||||
"vmax": "vMax",
|
||||
"coldstart-info": "Cold start heading locomotive (only locos 303E & 203E type)",
|
||||
"coldstart-info": "Locomotive cold start",
|
||||
"doublemanning-info": "Double manning",
|
||||
"list-empty": "Stock list is empty!",
|
||||
"warning-not-suitable": "EP07 & EP08 type locomotives are designed for passenger traffic only!",
|
||||
"warning-passenger-too-long": "Maximum length of a passenger train may not be greater than 350m!",
|
||||
|
||||
+4
-3
@@ -29,7 +29,7 @@
|
||||
"title": "PODGLĄD WYBRANEGO POJAZDU",
|
||||
"loading": "ŁADOWANIE OBRAZU...",
|
||||
"desc": "Wybierz pojazd lub wagon, aby zobaczyć jego podgląd powyżej",
|
||||
"sponsor-only": "* TYLKO DLA SPONSORÓW DO {0}",
|
||||
"sponsor-only": "* TYLKO DLA SPONSORÓW DO {0}",
|
||||
"loco-e": "ELEKTROWÓZ",
|
||||
"loco-s": "SPALINOWÓZ",
|
||||
"loco-ezt": "EZT",
|
||||
@@ -64,7 +64,8 @@
|
||||
"mass-accepted": "dopuszczalna",
|
||||
"length": "Długość",
|
||||
"vmax": "vMax",
|
||||
"coldstart-info": "Zimny start lokomotywy czołowej (tylko elektrowozy typów 303E i 203E)",
|
||||
"coldstart-info": "Zimny start",
|
||||
"doublemanning-info": "Podwójna obsada",
|
||||
"list-empty": "Lista pojazdów jest pusta!",
|
||||
"warning-not-suitable": "Lokomotywy EP07 i EP08 są przeznaczone jedynie do ruchu pasażerskiego!",
|
||||
"warning-passenger-too-long": "Maksymalna długość składów pasażerskich nie może przekraczać 350m!",
|
||||
@@ -141,7 +142,7 @@
|
||||
"loco-s": "Spalinowóz",
|
||||
"loco-e": "Elektrowóz",
|
||||
"car-passenger": "Wagon pasażerski",
|
||||
"car-cargo": "Wagon towarowy"
|
||||
"car-cargo": "Wagon towarowy"
|
||||
},
|
||||
"realstock": {
|
||||
"title": "ZESTAWIENIA REALNE by",
|
||||
|
||||
@@ -22,6 +22,7 @@ export const useStore = defineStore({
|
||||
chosenVehicle: null,
|
||||
|
||||
isColdStart: false,
|
||||
isDoubleManned: false,
|
||||
|
||||
showSupporter: false,
|
||||
imageLoading: false,
|
||||
@@ -61,6 +62,24 @@ export const useStore = defineStore({
|
||||
isTrainPassenger: (state) => isTrainPassenger(state),
|
||||
chosenRealStock: (state) => chosenRealStock(state),
|
||||
acceptableMass: (state) => acceptableMass(state),
|
||||
|
||||
stockSupportsColdStart: (state) => {
|
||||
if (state.stockList.length == 0) return false;
|
||||
if (!state.stockList[0].isLoco) return false;
|
||||
|
||||
const headingLoco = state.stockList[0];
|
||||
|
||||
return state.stockData?.props.find((stock) => stock.type == headingLoco.constructionType)?.coldStart ?? false;
|
||||
},
|
||||
|
||||
stockSupportsDoubleManning: (state) => {
|
||||
if (state.stockList.length == 0) return false;
|
||||
if (!state.stockList[0].isLoco) return false;
|
||||
|
||||
const headingLoco = state.stockList[0];
|
||||
|
||||
return state.stockData?.props.find((stock) => stock.type == headingLoco.constructionType)?.doubleManned ?? false;
|
||||
},
|
||||
},
|
||||
|
||||
actions: {
|
||||
|
||||
+6
-3
@@ -8,6 +8,7 @@ export interface IStore {
|
||||
chosenVehicle: Vehicle | null;
|
||||
|
||||
isColdStart: boolean;
|
||||
isDoubleManned: boolean;
|
||||
|
||||
showSupporter: boolean;
|
||||
imageLoading: boolean;
|
||||
@@ -41,7 +42,9 @@ export interface IStockProps {
|
||||
type: string;
|
||||
length: number;
|
||||
mass: number;
|
||||
cargo: string;
|
||||
cargo?: string | null;
|
||||
coldStart?: boolean;
|
||||
doubleManned?: boolean;
|
||||
}
|
||||
|
||||
export interface IStockData {
|
||||
@@ -64,8 +67,6 @@ export interface IStockData {
|
||||
};
|
||||
|
||||
props: IStockProps[];
|
||||
|
||||
usage: { [key: string]: string };
|
||||
}
|
||||
|
||||
export interface ILocomotive {
|
||||
@@ -81,6 +82,8 @@ export interface ILocomotive {
|
||||
|
||||
mass: number;
|
||||
length: number;
|
||||
coldStart: boolean;
|
||||
doubleManned: boolean;
|
||||
}
|
||||
|
||||
export interface ICarWagon {
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
const supportedConstructions = ["303e", "203e"];
|
||||
|
||||
export function locoSupportsColdStart(constructionType: string) {
|
||||
return new RegExp(`(${supportedConstructions.join("|")})`).test(
|
||||
constructionType,
|
||||
);
|
||||
}
|
||||
@@ -16,5 +16,7 @@ export function calculateSpeedLimit(locoType: SpeedLimitLocoType, stockMass: num
|
||||
}
|
||||
|
||||
export function calculateMassLimit(locoType: MassLimitLocoType, isTrainPassenger: boolean) {
|
||||
if(massLimits[locoType] === undefined) return 0;
|
||||
|
||||
return massLimits[locoType][isTrainPassenger ? 0 : 1] || 0;
|
||||
}
|
||||
|
||||
@@ -33,8 +33,11 @@ export function locoDataList(state: IStore) {
|
||||
sponsorsOnlyTimestamp: Number(sponsorsTimestamp),
|
||||
imageSrc: '',
|
||||
|
||||
length: locoProps?.length && type.startsWith('2EN') ? locoProps.length * 2 : locoProps?.length || 0,
|
||||
mass: locoProps?.mass && type.startsWith('2EN') ? 253 : locoProps?.mass || 0,
|
||||
length: locoProps?.length && type.startsWith('2EN') ? locoProps.length * 2 : locoProps?.length ?? 0,
|
||||
mass: locoProps?.mass && type.startsWith('2EN') ? 253 : locoProps?.mass ?? 0,
|
||||
|
||||
coldStart: locoProps?.coldStart ?? false,
|
||||
doubleManned: locoProps?.doubleManned ?? false,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -70,12 +73,10 @@ export function carDataList(state: IStore) {
|
||||
maxSpeed: Number(maxSpeed),
|
||||
imageSrc: '',
|
||||
cargoList:
|
||||
!carPropsData || carPropsData.cargo === null
|
||||
? []
|
||||
: carPropsData.cargo.split(';').map((cargo) => ({
|
||||
id: cargo.split(':')[0],
|
||||
totalMass: Number(cargo.split(':')[1]),
|
||||
})),
|
||||
carPropsData?.cargo?.split(';').map((cargo) => ({
|
||||
id: cargo.split(':')[0],
|
||||
totalMass: Number(cargo.split(':')[1]),
|
||||
})) || [],
|
||||
|
||||
mass: carPropsData?.mass || 0,
|
||||
length: carPropsData?.length || 0,
|
||||
|
||||
+2
-2
@@ -32,7 +32,7 @@ export default defineConfig({
|
||||
runtimeCaching: [
|
||||
{
|
||||
urlPattern: /^https:\/\/rj.td2.info.pl\/dist\/img\/thumbnails\/.*/i,
|
||||
handler: 'CacheFirst',
|
||||
handler: 'NetworkFirst',
|
||||
options: {
|
||||
cacheName: 'swdr-images-cache',
|
||||
expiration: {
|
||||
@@ -46,7 +46,7 @@ export default defineConfig({
|
||||
},
|
||||
{
|
||||
urlPattern: /^https:\/\/spythere.github.io\/api\/td2\/.*/i,
|
||||
handler: 'CacheFirst',
|
||||
handler: 'NetworkFirst',
|
||||
options: {
|
||||
cacheName: 'spythere-api-cache',
|
||||
expiration: {
|
||||
|
||||
Reference in New Issue
Block a user