Differenitiating between hires and lores iamges

This commit is contained in:
Neshura 2023-08-21 03:45:41 +02:00
parent 94e9b8f0ba
commit a3d43a7742
Signed by: Neshura
GPG key ID: B6983AAA6B9A7A6C
2 changed files with 9 additions and 7 deletions

View file

@ -76,6 +76,7 @@ export type Species = {
}
export type Portrait = {
imageLink: string,
hires: string,
lores: string,
}

View file

@ -6,7 +6,7 @@ import { createChellarisInfo, type ChellarisGame, createChellarisGame, createChe
import type { LayoutLoad } from "./$types";
import type { Ethic } from '../../lib/types/stellaris';
export const load: LayoutLoad = async () => {
export const load: LayoutLoad = async ({ fetch }) => {
let store: string | null;
const apiBaseUrl = 'https://www.chellaris.net/api/v2';
const chellarisData = createChellarisInfo();
@ -101,7 +101,8 @@ export const load: LayoutLoad = async () => {
const portraits: {
id: number,
href: string,
hires: string,
lores: string,
group_id: number
}[] = await (await fetch(apiBaseUrl + '/portraits')).json();
@ -111,7 +112,7 @@ export const load: LayoutLoad = async () => {
const portraitGroupData = chellarisData.species.get(portrait.group_id);
if (typeof portraitGroupData !== "undefined") {
const newPortraitData = { imageLink: portrait.href };
const newPortraitData = { hires: portrait.hires, lores: portrait.lores };
portraitGroupData.portraits.set(portrait.id, newPortraitData);
}
@ -129,11 +130,11 @@ export const load: LayoutLoad = async () => {
// Game Selection
store = localStorage.getItem('gameSelection');
let selectedGame = 0;
if (typeof store == 'string') {
let selectedGame = 1;
if (typeof store == 'string' && store != "\"\"") {
selectedGame = JSON.parse(store);
SelectedGameStore.set(selectedGame);
}
SelectedGameStore.set(selectedGame);
// Game Groups Selection
store = localStorage.getItem('gameGroupSelection');