feature: info o elektryfikacji spawnu na scenerii

This commit is contained in:
2023-06-15 15:28:12 +02:00
parent d59ead87e6
commit 1f376085f2
3 changed files with 68 additions and 54 deletions
@@ -9,8 +9,9 @@
<span v-if="station.onlineInfo">
<span
class="badge spawn"
v-for="(spawn, i) in station.onlineInfo.spawns"
v-for="(spawn, i) in sortedSpawns"
:key="spawn.spawnName + station.onlineInfo?.dispatcherName + i"
:data-electrified="spawn.isElectrified"
>
<span class="spawn_name">{{ spawn.spawnName }}</span>
<span class="spawn_length">{{ spawn.spawnLength }}m</span>
@@ -37,6 +38,12 @@ export default defineComponent({
default: {},
},
},
computed: {
sortedSpawns() {
return this.station.onlineInfo?.spawns.sort((s1, s2) => (s1.spawnLength < s2.spawnLength ? 1 : -1));
},
},
});
</script>
@@ -44,9 +51,15 @@ export default defineComponent({
@import '../../../styles/variables.scss';
.spawn {
color: white;
&_length {
background: $accentCol;
color: black;
background-color: #404040;
color: #cfcfcf;
}
&[data-electrified='true'] > &_name {
background-color: #007599;
}
}
</style>
+1 -1
View File
@@ -41,7 +41,7 @@ export default interface Station {
maxUsers: number;
currentUsers: number;
spawns: { spawnName: string; spawnLength: number }[];
spawns: { spawnName: string; spawnLength: number; isElectrified: boolean }[];
dispatcherRate: number;
dispatcherName: string;
dispatcherExp: number;
+2 -1
View File
@@ -66,8 +66,9 @@ export const parseSpawns = (spawnString: string) => {
const spawnArray = spawn.split(',');
const spawnName = spawnArray[6] ? spawnArray[6] : spawnArray[0];
const spawnLength = parseInt(spawnArray[2]);
const isElectrified = spawnArray[3] == 'True';
return { spawnName, spawnLength };
return { spawnName, spawnLength, isElectrified };
});
};