Skip to content

Commit f4b79f7

Browse files
authored
feat(diagnostics): Updated stat names to not be all lowercase (#116)
Much nicer labels ![image](https://github.com/user-attachments/assets/603698b7-a384-41b3-91b1-0a026be03f5c)
1 parent c067632 commit f4b79f7

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

src/StatsProvider2.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
export interface StatData {
44
name: string;
5+
parent_name: string;
56
id: string;
67
full_id: string;
78
parent_id: string;
@@ -42,6 +43,7 @@ export class StatsProvider2 {
4243
...stat,
4344
id: statId,
4445
full_id: parent !== undefined ? parent.full_id + '_' + statId : statId,
46+
parent_name: parent !== undefined ? parent.name : '',
4547
parent_id: parent !== undefined ? parent.id : '',
4648
parent_full_id: parent !== undefined ? parent.full_id : '',
4749
values: stat.values ?? [],

src/panels/MinecraftDiagnostics.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export class MinecraftDiagnosticsPanel {
3434
values: stat.values,
3535
id: stat.id,
3636
name: stat.name,
37+
group_name: stat.parent_name,
3738
group: stat.parent_id,
3839
full_id: stat.full_id,
3940
time: stat.tick,

webview-ui/src/diagnostics_panel/StatisticProvider.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export interface StatisticUpdatedMessage {
88
group: string;
99
full_id: string;
1010
group_full_id: string;
11+
group_name: string;
1112
time: number;
1213
}
1314

webview-ui/src/diagnostics_panel/StatisticResolver.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function AbsoluteStatResolver(
4444
}
4545

4646
const tickOffset = msg.values.length - i - 1;
47-
result.push({ value: value, time: msg.time - tickOffset, absoluteValue: value, category: msg.id });
47+
result.push({ value: value, time: msg.time - tickOffset, absoluteValue: value, category: msg.name });
4848
}
4949

5050
// Sort oldest to newest
@@ -85,7 +85,7 @@ function DifferenceStatResolver(
8585
value: newValue,
8686
time: msg.time - tickOffset,
8787
absoluteValue: absoluteValue,
88-
category: msg.id,
88+
category: msg.name,
8989
});
9090
}
9191

@@ -107,6 +107,7 @@ export function NestedStatResolver(
107107
): (statUpdate: StatisticUpdatedMessage, previousValues: TrackedStat[]) => TrackedStat[] {
108108
return (msg: StatisticUpdatedMessage, previousValues: TrackedStat[]): TrackedStat[] => {
109109
msg.id = `${msg.group} - ${msg.id}`;
110+
msg.name = `${msg.group_name} - ${msg.name}`;
110111
return resolver(msg, previousValues);
111112
};
112113
}
@@ -117,6 +118,7 @@ export function ParentNameStatResolver(
117118
): (statUpdate: StatisticUpdatedMessage, previousValues: TrackedStat[]) => TrackedStat[] {
118119
return (msg: StatisticUpdatedMessage, previousValues: TrackedStat[]): TrackedStat[] => {
119120
msg.id = msg.group;
121+
msg.name = msg.group_name;
120122
return resolver(msg, previousValues);
121123
};
122124
}

0 commit comments

Comments
 (0)