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