From e6c064d15d8e768b8bb434900c9eb60a8494f4e8 Mon Sep 17 00:00:00 2001 From: Spythere Date: Thu, 13 Feb 2025 18:38:32 +0100 Subject: [PATCH] fix: reworked train stop statuses descriptions and their tooltip styles --- .../SceneryView/SceneryTimetable.vue | 13 ++--- .../SceneryView/ScheduledTrainStatus.vue | 52 ++++++++++++------- src/components/SceneryView/typings.ts | 11 ++-- src/components/Tooltip/HtmlTooltip.vue | 39 ++++++++++++++ src/components/Tooltip/Tooltip.vue | 10 +++- src/locales/en.json | 13 ++--- src/locales/pl.json | 13 ++--- src/store/tooltipStore.ts | 3 +- 8 files changed, 106 insertions(+), 48 deletions(-) create mode 100644 src/components/Tooltip/HtmlTooltip.vue diff --git a/src/components/SceneryView/SceneryTimetable.vue b/src/components/SceneryView/SceneryTimetable.vue index 3dc53d0..36824a7 100644 --- a/src/components/SceneryView/SceneryTimetable.vue +++ b/src/components/SceneryView/SceneryTimetable.vue @@ -130,7 +130,7 @@ - {{ row.arrivingLine }} + {{ row.currentElement.arrivalRouteExt }} @@ -139,7 +139,7 @@ - {{ row.departureLine }} + {{ row.currentElement.departureRouteExt }} @@ -279,12 +279,9 @@ export default defineComponent({ return { checkpointStop: ct.checkpointStop, train: ct.train, - prevDepartureLine: ct.previousSceneryElement?.departureRouteExt ?? null, - nextArrivalLine: ct.nextSceneryElement?.arrivalRouteExt ?? null, - departureLine: ct.timetablePathElement.departureRouteExt ?? null, - arrivingLine: ct.timetablePathElement.arrivalRouteExt ?? null, - prevStationName: ct.previousSceneryElement?.stationName ?? null, - nextStationName: ct.nextSceneryElement?.stationName ?? null, + prevElement: ct.previousSceneryElement, + nextElement: ct.nextSceneryElement, + currentElement: ct.timetablePathElement, status: trainStopStatus }; }) diff --git a/src/components/SceneryView/ScheduledTrainStatus.vue b/src/components/SceneryView/ScheduledTrainStatus.vue index f315400..90755f6 100644 --- a/src/components/SceneryView/ScheduledTrainStatus.vue +++ b/src/components/SceneryView/ScheduledTrainStatus.vue @@ -2,7 +2,9 @@
{{ computedScheduledTrain.stopStatusIndicator }} @@ -24,16 +26,16 @@ export default defineComponent({ computed: { computedScheduledTrain() { - const { prevDepartureLine, prevStationName, nextArrivalLine, nextStationName, status } = - this.sceneryTimetableRow; + const { status, prevElement, currentElement, nextElement } = this.sceneryTimetableRow; - const prevDepartureIndicator = prevDepartureLine - ? `(${prevDepartureLine}) ${prevStationName}` - : '---'; - const nextArrivalIndicator = nextArrivalLine - ? `(${nextArrivalLine}) ${nextStationName}` + const prevDepartureIndicator = prevElement?.departureRouteExt + ? `(${prevElement.departureRouteExt}) ${prevElement.stationName}` : '---'; + const nextArrivalIndicator = nextElement?.arrivalRouteExt + ? `(${nextElement.arrivalRouteExt}) ${nextElement.stationName}` + : `${currentElement.stationName}`; + let stopStatusDescription = '', stopStatusIndicator = ''; @@ -41,34 +43,45 @@ export default defineComponent({ case StopStatus.ARRIVING: stopStatusIndicator = `${this.$t('timetables.from')}: ${prevDepartureIndicator}`; stopStatusDescription = this.$t('timetables.desc-arriving', { - prevStationName, - prevDepartureLine + prevStationName: prevElement?.stationName ?? '', + prevDepartureLine: prevElement?.departureRouteExt ?? '' }); break; case StopStatus.ONLINE: case StopStatus.STOPPED: - stopStatusIndicator = nextArrivalLine + stopStatusIndicator = nextElement?.arrivalRouteExt ? `${this.$t('timetables.to')}: ${nextArrivalIndicator}` : `${this.$t('timetables.desc-end')}`; - stopStatusDescription = nextArrivalLine - ? this.$t(`timetables.desc-${status}`, { nextStationName, nextArrivalLine }) + stopStatusDescription = nextElement?.arrivalRouteExt + ? this.$t(`timetables.desc-${status}`, { + nextStationName: nextElement?.stationName, + nextArrivalLine: nextElement?.arrivalRouteExt + }) : ''; break; case StopStatus.DEPARTED: stopStatusIndicator = `${this.$t('timetables.to')}: ${nextArrivalIndicator}`; - stopStatusDescription = this.$t('timetables.desc-departed', { - nextStationName, - nextArrivalLine - }); + + if (!nextElement?.stationName) { + stopStatusDescription = this.$t('timetables.desc-departed-ends', { + nextStationName: currentElement.stationName + }); + } else { + stopStatusDescription = this.$t('timetables.desc-departed', { + nextStationName: nextElement?.stationName ?? currentElement.stationName, + nextArrivalLine: nextElement?.arrivalRouteExt + }); + } + break; case StopStatus.DEPARTED_AWAY: stopStatusIndicator = `${this.$t('timetables.to')}: ${nextArrivalIndicator}`; stopStatusDescription = this.$t('timetables.desc-departed-away', { - nextStationName, - nextArrivalLine + nextStationName: nextElement?.stationName, + nextArrivalLine: nextElement?.arrivalRouteExt }); break; @@ -93,6 +106,7 @@ export default defineComponent({ diff --git a/src/components/Tooltip/Tooltip.vue b/src/components/Tooltip/Tooltip.vue index 029fe26..300e4fe 100644 --- a/src/components/Tooltip/Tooltip.vue +++ b/src/components/Tooltip/Tooltip.vue @@ -12,11 +12,19 @@ import VehiclePreviewTooltip from './VehiclePreviewTooltip.vue'; import BaseTooltip from './BaseTooltip.vue'; import SpawnsTooltip from './SpawnsTooltip.vue'; import UsersTooltip from './UsersTooltip.vue'; +import HtmlTooltip from './HtmlTooltip.vue'; const BOX_PADDING_PX = 20; export default defineComponent({ - components: { DonatorTooltip, VehiclePreviewTooltip, BaseTooltip, SpawnsTooltip, UsersTooltip }, + components: { + DonatorTooltip, + VehiclePreviewTooltip, + BaseTooltip, + SpawnsTooltip, + UsersTooltip, + HtmlTooltip + }, data() { return { diff --git a/src/locales/en.json b/src/locales/en.json index f669954..f018ac2 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -543,12 +543,13 @@ "terminates": "TERMINATES\nHERE", "from": "FROM", "to": "TO", - "desc-arriving": "The train is not here yet. It's going to come from: {prevStationName} (szlak {prevDepartureLine})", - "desc-online": "The train is at the station. It's going to leave to: {nextStationName} (szlak {nextArrivalLine})", - "desc-stopped": "The train is at the station and is stopped. It's going to leave towards: {nextStationName} (szlak {nextArrivalLine})", - "desc-next-arrival": "Leaves towards: {nextStationName} (szlak {nextArrivalLine})", - "desc-departed": "The train is at the station and it's been departed. Leaves towards: {nextStationName} (szlak {nextArrivalLine})", - "desc-departed-away": "The train has been departed to: {nextStationName} (szlak {nextArrivalLine})", + "desc-arriving": "The train is not here yet.\nIt's going to come from: {prevStationName} (route {prevDepartureLine})", + "desc-online": "The train is at the station.\nIt's going to leave to: {nextStationName} (route {nextArrivalLine})", + "desc-stopped": "The train is at the station and is stopped.\nIt's going to leave towards: {nextStationName} (route {nextArrivalLine})", + "desc-next-arrival": "Leaves towards: {nextStationName} (route {nextArrivalLine})", + "desc-departed": "The train is at the station and it's been departed.\nLeaves towards: {nextStationName} (route {nextArrivalLine})", + "desc-departed-ends": "The train is at the station and it's been departed.\nLeaves towards station: {nextStationName}", + "desc-departed-away": "The train has been departed to:\n{nextStationName} (route {nextArrivalLine})", "desc-end": "The train terminates here", "desc-terminated": "The train has been terminated" }, diff --git a/src/locales/pl.json b/src/locales/pl.json index e7a1b15..db33f06 100644 --- a/src/locales/pl.json +++ b/src/locales/pl.json @@ -529,12 +529,13 @@ "terminates": "KOŃCZY BIEG", "from": "Z", "to": "DO", - "desc-arriving": "Pociągu nie ma jeszcze na tej scenerii. Przyjedzie z: {prevStationName} (szlak {prevDepartureLine})", - "desc-online": "Pociąg jest na tej scenerii. Odjedzie do: {nextStationName} (szlak {nextArrivalLine})", - "desc-stopped": "Pociąg jest na tej scenerii i odbywa postój. Odjedzie do: {nextStationName} (szlak {nextArrivalLine})", - "desc-next-arrival": "Odjeżdża do: {nextStationName} (szlak {nextArrivalLine})", - "desc-departed": "Pociąg jest na tej scenerii i został odprawiony. Odjeżdża do: {nextStationName} (szlak {nextArrivalLine})", - "desc-departed-away": "Pociąg został odprawiony i odjechał do: {nextStationName} (szlak {nextArrivalLine})", + "desc-arriving": "Pociągu nie ma jeszcze na tej scenerii.\nPrzyjedzie z: {prevStationName} (szlak {prevDepartureLine})", + "desc-online": "Pociąg jest na tej scenerii.\nOdjedzie w kierunku: {nextStationName} (szlak {nextArrivalLine})", + "desc-stopped": "Pociąg jest na tej scenerii i odbywa postój.\nOdjedzie w kierunku: {nextStationName} (szlak {nextArrivalLine})", + "desc-next-arrival": "Odjeżdża do:\n{nextStationName} (szlak {nextArrivalLine})", + "desc-departed": "Pociąg jest na tej scenerii i został odprawiony.\nOdjeżdża w kierunku: {nextStationName} (szlak {nextArrivalLine})", + "desc-departed-ends": "Pociąg jest na tej scenerii i został odprawiony.\nOdjechał w kierunku stacji: {nextStationName}", + "desc-departed-away": "Pociąg został odprawiony i odjechał do:\n{nextStationName} (szlak {nextArrivalLine})", "desc-end": "Pociąg kończy bieg", "desc-terminated": "Pociąg skończył bieg" }, diff --git a/src/store/tooltipStore.ts b/src/store/tooltipStore.ts index 7ac18f4..48c6364 100644 --- a/src/store/tooltipStore.ts +++ b/src/store/tooltipStore.ts @@ -7,7 +7,8 @@ export const tooltipKeys = [ 'BaseTooltip', 'VehiclePreviewTooltip', 'SpawnsTooltip', - 'UsersTooltip' + 'UsersTooltip', + 'HtmlTooltip' ] as const; export type TooltipType = (typeof tooltipKeys)[number];