Skip to content

Commit 5af135f

Browse files
committed
feat: Basic NGA trophy display
1 parent 07d76a2 commit 5af135f

File tree

5 files changed

+63
-0
lines changed

5 files changed

+63
-0
lines changed

extensions/core-nga/rslib.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export default defineConfig({
2525
'./NgScore': './src/components/NgScore.tsx',
2626
'./NgViews': './src/components/NgViews.tsx',
2727
'./NgRatingSearchableSelect': './src/components/NgRatingSearchableSelect.tsx',
28+
'./NgTrophies': './src/components/NgTrophies.tsx',
2829
},
2930
shared: {
3031
react: { singleton: true, requiredVersion: dependencies.react },

extensions/core-nga/src/components/Initializer.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export default function Initializer() {
1010
'nga/NgScore',
1111
'nga/NgFaves',
1212
'nga/NgCredits',
13+
'nga/NgTrophies',
1314
];
1415

1516
// Insert below alt titles
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { GameComponentProps } from 'flashpoint-launcher-renderer';
2+
import { ExtData } from './types';
3+
import { FaTrophy } from 'react-icons/fa';
4+
5+
export default function NgTrophies(props: GameComponentProps) {
6+
const extData: ExtData | undefined = props.game.extData?.nga;
7+
const trophies = extData?.trophies || [];
8+
9+
if (trophies.length === 0) {
10+
return <></>;
11+
}
12+
13+
return (
14+
<div className='ng-trophies'>
15+
<p>Trophies:</p>
16+
{trophies.map((trophy, index) => (
17+
<div key={index} className='ng-trophy'>
18+
<div className='ng-trophy__icon'>
19+
<FaTrophy/>
20+
</div>
21+
<div className='ng-trophy__info'>
22+
<div className='ng-trophy__name'>{trophy[0]}</div>
23+
<div className='ng-trophy__date'>{trophy[1]}</div>
24+
</div>
25+
</div>
26+
))}
27+
</div>
28+
);
29+
}

extensions/core-nga/src/components/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ export type Credit = {
33
roles?: string[];
44
}
55

6+
export type Trophy = string[];
7+
68
export type ExtData = {
79
score?: number;
810
rating?: string;
911
views?: number;
1012
faves?: number;
1113
credits?: Credit[];
14+
trophies?: Trophy[];
1215
}

extensions/core-nga/static/nga.css

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,32 @@
4242
.nga-credit-icon {
4343
margin: 0.1em 0.3em 0em 0em;
4444
}
45+
46+
47+
.ng-trophies {
48+
display: flex;
49+
flex-direction: column;
50+
}
51+
52+
.ng-trophies__header {
53+
font-weight: bold;
54+
}
55+
56+
.ng-trophy {
57+
display: flex;
58+
flex-direction: row;
59+
}
60+
61+
.ng-trophy__icon {
62+
align-self: center;
63+
margin-right: 0.5rem;
64+
}
65+
66+
.ng-trophy__info {
67+
display: flex;
68+
flex-direction: column;
69+
}
70+
71+
.ng-trophy__name {
72+
font-weight: bold;
73+
}

0 commit comments

Comments
 (0)