Skip to content

Commit 0082692

Browse files
committed
feat: collected petals display
1 parent 95c2c7e commit 0082692

4 files changed

Lines changed: 151 additions & 2 deletions

File tree

src/infoHud/InfoHud.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import SuperPanelGroup from "@/infoHud/super/SuperPanelGroup.vue";
1111
import GoalPanel from "@/infoHud/goal/GoalPanel.vue";
1212
import SettingsPanel from "@/infoHud/settings/SettingsPanel.vue";
1313
import CraftGroup from "@/infoHud/craft/CraftGroup.vue";
14+
import CollectPanel from "@/infoHud/goal/CollectPanel.vue";
1415
1516
const { webSocketService } = defineProps<{
1617
webSocketService: WebSocketService,
@@ -43,11 +44,12 @@ eventBus.on("showSettings", ()=>{
4344
/>
4445
</transition-group>
4546
<CraftGroup/>
47+
<CollectPanel/>
4648
<GoalPanel/>
4749
<transition name="slide-down">
4850
<SwitcherPanel v-show="showSwitcher"/>
4951
</transition>
50-
<SummaryPanel :webSocketService="webSocketService" :switcherOptions="{ showSwitcher }"/>
52+
<SummaryPanel :webSocketService="webSocketService"/>
5153
</div>
5254
</template>
5355

src/infoHud/goal/CollectPanel.vue

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
<script lang="ts" setup>
2+
import {onMounted, onUnmounted, ref} from 'vue';
3+
import {petalCountLogger, type Detail} from '@/petalCountLogger';
4+
import {getImageUrl} from "@/florr/image.ts";
5+
import {useI18n} from "vue-i18n";
6+
7+
interface Item {
8+
rarity: number
9+
petal: number
10+
count: number
11+
key: string
12+
imgUrl: string
13+
}
14+
15+
const { t } = useI18n();
16+
17+
let firstRetrieve = true;
18+
let firstDetail: Detail | undefined;
19+
const items = ref<Item[]>([]);
20+
21+
function updateItems() {
22+
const detail = petalCountLogger?.getDetail();
23+
if (!detail) return;
24+
25+
if (firstRetrieve) {
26+
firstDetail = detail;
27+
firstRetrieve = false;
28+
return;
29+
}
30+
31+
const updates: Item[] = [];
32+
33+
for (const rarity in detail) {
34+
for (const petal in detail[rarity]) {
35+
const count =
36+
detail[rarity][petal]! - (firstDetail?.[rarity]?.[petal] ?? 0);
37+
if (count > 0) {
38+
updates.push({
39+
rarity: parseInt(rarity),
40+
petal: parseInt(petal),
41+
count,
42+
key: `${petal}|${rarity}`,
43+
imgUrl: getImageUrl(parseInt(petal), parseInt(rarity))!,
44+
});
45+
}
46+
}
47+
}
48+
49+
updates.sort((a, b) => {
50+
return (b.rarity - a.rarity) || t(`petalDisplay.${a.petal}`).localeCompare(t(`petalDisplay.${b.petal}`));
51+
});
52+
53+
items.value = updates.slice(0, 20);
54+
}
55+
56+
onMounted(() => {
57+
const interval = setInterval(updateItems, 50);
58+
onUnmounted(() => clearInterval(interval));
59+
})
60+
</script>
61+
62+
<template>
63+
<div class="card">
64+
<span class="title">{{$t('collect.title')}}</span>
65+
<div class="grid" id="popup-grid">
66+
<div
67+
v-for="item in items"
68+
:key="item.key"
69+
class="item scale-in"
70+
:data-key="item.key"
71+
>
72+
<img :src="item.imgUrl" :alt="$t(`petal.${item.petal}`)" />
73+
<div v-if="item.count > 1" class="count-badge">x{{ item.count }}</div>
74+
</div>
75+
</div>
76+
</div>
77+
</template>
78+
79+
<style scoped>
80+
.card {
81+
display: flex;
82+
align-items: center;
83+
flex-direction: column;
84+
background-color: rgba(0, 0, 0, 0.4);
85+
color: #fff;
86+
border-radius: calc(var(--unit) * 0.6);
87+
padding: calc(var(--unit) * 1);
88+
width: calc(var(--unit) * 25);
89+
margin: calc(var(--unit) * 0.8);
90+
font-size: calc(var(--unit) * 1.5);
91+
}
92+
93+
.title {
94+
font-size: 1.2em;
95+
text-align: left;
96+
margin: 0.2em 0.2em 0.6em;
97+
}
98+
99+
.grid {
100+
display: grid;
101+
grid-template-columns: repeat(5, calc(var(--unit) * 4));
102+
gap: calc(var(--unit) * 0.8);
103+
justify-content: start;
104+
}
105+
106+
.item {
107+
position: relative;
108+
width: calc(var(--unit) * 4);
109+
height: calc(var(--unit) * 4);
110+
}
111+
112+
.item img {
113+
width: 100%;
114+
height: 100%;
115+
object-fit: contain;
116+
}
117+
118+
.count-badge {
119+
position: absolute;
120+
top: 0;
121+
right: 0;
122+
color: white;
123+
font-size: calc(var(--unit) * 1.5);
124+
height: 20%;
125+
rotate: 30deg;
126+
paint-order: stroke fill;
127+
-webkit-text-stroke: 0.1em black;
128+
}
129+
130+
.scale-in {
131+
animation: scaleIn 0.6s ease-out;
132+
}
133+
134+
@keyframes scaleIn {
135+
0% {
136+
transform: scale(0.3);
137+
opacity: 0;
138+
}
139+
100% {
140+
transform: scale(1);
141+
opacity: 1;
142+
}
143+
}
144+
</style>

src/locales/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,5 +322,8 @@
322322
},
323323
"craft": {
324324
"title": "Craft Result"
325+
},
326+
"collect": {
327+
"title": "Collected Petals"
325328
}
326329
}

src/petalCountLogger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type {Petal, Utils} from "./florr";
22
import {ref} from "vue";
33

44
export type Summary = Partial<Record<number, number>>;
5-
export type Detail = Partial<Record<number, Record<string, number>>>;
5+
export type Detail = Record<number, Record<string, number>>;
66
let florrioUtils!: Utils;
77
let petals!: Petal[];
88
let petalSids!: number[];

0 commit comments

Comments
 (0)