Differenitiating between hires and lores iamges
This commit is contained in:
parent
94e9b8f0ba
commit
a3d43a7742
2 changed files with 9 additions and 7 deletions
|
@ -76,6 +76,7 @@ export type Species = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Portrait = {
|
export type Portrait = {
|
||||||
imageLink: string,
|
hires: string,
|
||||||
|
lores: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { createChellarisInfo, type ChellarisGame, createChellarisGame, createChe
|
||||||
import type { LayoutLoad } from "./$types";
|
import type { LayoutLoad } from "./$types";
|
||||||
import type { Ethic } from '../../lib/types/stellaris';
|
import type { Ethic } from '../../lib/types/stellaris';
|
||||||
|
|
||||||
export const load: LayoutLoad = async () => {
|
export const load: LayoutLoad = async ({ fetch }) => {
|
||||||
let store: string | null;
|
let store: string | null;
|
||||||
const apiBaseUrl = 'https://www.chellaris.net/api/v2';
|
const apiBaseUrl = 'https://www.chellaris.net/api/v2';
|
||||||
const chellarisData = createChellarisInfo();
|
const chellarisData = createChellarisInfo();
|
||||||
|
@ -101,7 +101,8 @@ export const load: LayoutLoad = async () => {
|
||||||
|
|
||||||
const portraits: {
|
const portraits: {
|
||||||
id: number,
|
id: number,
|
||||||
href: string,
|
hires: string,
|
||||||
|
lores: string,
|
||||||
group_id: number
|
group_id: number
|
||||||
}[] = await (await fetch(apiBaseUrl + '/portraits')).json();
|
}[] = await (await fetch(apiBaseUrl + '/portraits')).json();
|
||||||
|
|
||||||
|
@ -111,7 +112,7 @@ export const load: LayoutLoad = async () => {
|
||||||
const portraitGroupData = chellarisData.species.get(portrait.group_id);
|
const portraitGroupData = chellarisData.species.get(portrait.group_id);
|
||||||
|
|
||||||
if (typeof portraitGroupData !== "undefined") {
|
if (typeof portraitGroupData !== "undefined") {
|
||||||
const newPortraitData = { imageLink: portrait.href };
|
const newPortraitData = { hires: portrait.hires, lores: portrait.lores };
|
||||||
|
|
||||||
portraitGroupData.portraits.set(portrait.id, newPortraitData);
|
portraitGroupData.portraits.set(portrait.id, newPortraitData);
|
||||||
}
|
}
|
||||||
|
@ -129,11 +130,11 @@ export const load: LayoutLoad = async () => {
|
||||||
// Game Selection
|
// Game Selection
|
||||||
store = localStorage.getItem('gameSelection');
|
store = localStorage.getItem('gameSelection');
|
||||||
|
|
||||||
let selectedGame = 0;
|
let selectedGame = 1;
|
||||||
if (typeof store == 'string') {
|
if (typeof store == 'string' && store != "\"\"") {
|
||||||
selectedGame = JSON.parse(store);
|
selectedGame = JSON.parse(store);
|
||||||
SelectedGameStore.set(selectedGame);
|
|
||||||
}
|
}
|
||||||
|
SelectedGameStore.set(selectedGame);
|
||||||
|
|
||||||
// Game Groups Selection
|
// Game Groups Selection
|
||||||
store = localStorage.getItem('gameGroupSelection');
|
store = localStorage.getItem('gameGroupSelection');
|
||||||
|
|
Reference in a new issue