Skip to content

Commit 0bcefcd

Browse files
committed
fix: show icon from config on shelf
1 parent de613ee commit 0bcefcd

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

apps/player-desktop/src/app/open-game-button.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ export const OpenGameButton: React.FC = () => {
2020
try {
2121
const imported = await importDesktop(filePath as string);
2222
for (const entry of imported) {
23-
if (!games$.value[entry.id]) {
24-
games$.actions.add(entry.id, entry);
25-
}
23+
games$.actions.add(entry.id, entry);
2624
}
2725
goToGame(imported[0].id);
2826
} catch (err) {

apps/player/src/app/open-game-button.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@ export const OpenGameButton: React.FC = () => {
1414
const content = evt.target?.result as ArrayBuffer;
1515
try {
1616
const imported = await importFile(file.name, content);
17+
console.log(imported);
1718
for (const entry of imported) {
18-
if (!games$.value[entry.id]) {
19-
games$.actions.add(entry.id, entry);
20-
}
19+
games$.actions.add(entry.id, entry);
2120
}
2221
const toRun = imported[0].id;
2322
toRun && goToGame(toRun);

libs/game-shelf/src/components/main.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ h6 {
336336
align-items: center;
337337
}
338338
.game-shelf__card-title img {
339-
max-width: 120px;
339+
max-width: 60px;
340340
margin-right: var(--spacer--sm);
341341
}
342342
.game-shelf__card-content {

libs/game-state/src/importer/archive-importer.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ export async function importArchive(
4444
return Promise.all(
4545
games.map(async (game) => {
4646
const file = game.file.slice(game.file.lastIndexOf('/') + 1);
47+
const loadConfig = await storage.prepareLoadConfig(game.id, file);
48+
let icon = game.resources?.icon;
49+
if (icon) {
50+
icon = `${loadConfig.url}${icon}`;
51+
}
4752
return {
4853
id: game.id,
4954
mode: game.mode,
@@ -52,8 +57,9 @@ export async function importArchive(
5257
ported_by: game.ported_by,
5358
version: game.version,
5459
description: game.description,
60+
icon,
5561
loadConfig: {
56-
...(await storage.prepareLoadConfig(game.id, file)),
62+
...loadConfig,
5763
descriptor: game,
5864
},
5965
};
@@ -69,6 +75,11 @@ export async function importArchive(
6975
const descriptorContent = stringify({ game: [rootDescriptor] } as unknown as JsonMap);
7076
await storage$.value?.addGameResource(game_id, GAME_DESCRIPTOR_NAME, new TextEncoder().encode(descriptorContent));
7177
}
78+
const loadConfig = await storage.prepareLoadConfig(game_id, filename);
79+
let icon = rootDescriptor?.resources?.icon;
80+
if (icon) {
81+
icon = `${loadConfig.url}${icon}`;
82+
}
7283
return [
7384
{
7485
id: game_id,
@@ -78,7 +89,8 @@ export async function importArchive(
7889
ported_by: rootDescriptor?.ported_by,
7990
version: rootDescriptor?.version,
8091
description: rootDescriptor?.description,
81-
loadConfig: await storage.prepareLoadConfig(game_id, filename),
92+
icon,
93+
loadConfig,
8294
},
8395
];
8496
}

0 commit comments

Comments
 (0)