Skip to content

Commit

Permalink
feat: panel positions are now consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
Tormak9970 committed Oct 29, 2023
1 parent fafa86a commit 398e5d7
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/components/core/filters/Options.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { SettingsManager } from "../../../lib/utils/SettingsManager";
import { LogController } from "../../../lib/controllers/LogController";
import Divider from "../Divider.svelte";
import { dbFilters, gridType, theme } from "../../../stores/AppState";
import { dbFilters, gridType, optionsSize, theme } from "../../../stores/AppState";
import Spacer from "../../layout/Spacer.svelte";
import PaddedScrollContainer from "../../layout/PaddedScrollContainer.svelte";
Expand Down Expand Up @@ -51,7 +51,7 @@
}
</script>

<Pane minSize={15} size={16}>
<Pane minSize={15} size={$optionsSize}>
<div class="inner">
<SectionTitle title="Options" />

Expand Down
4 changes: 2 additions & 2 deletions src/components/core/games/Games.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { onDestroy, onMount } from "svelte";
import { Pane } from "svelte-splitpanes";
import type { Unsubscriber } from "svelte/store";
import { Platforms, currentPlatform, hiddenGameIds, loadingGames, manualSteamGames, nonSteamGames, renderGamesInList, showHidden, steamGames } from "../../../stores/AppState";
import { Platforms, currentPlatform, gamesSize, hiddenGameIds, loadingGames, manualSteamGames, nonSteamGames, renderGamesInList, showHidden, steamGames } from "../../../stores/AppState";
import SearchBar from "../../interactables/SearchBar.svelte";
import Toggle from "../../interactables/Toggle.svelte";
import SectionTitle from "../SectionTitle.svelte";
Expand Down Expand Up @@ -143,7 +143,7 @@

<svelte:window on:keydown={overwriteCtrlF} />

<Pane minSize={20}>
<Pane minSize={20} size={$gamesSize}>
<SectionTitle title="Games" />

<div class="content">
Expand Down
4 changes: 2 additions & 2 deletions src/components/core/grids/Grids.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import type { Unsubscriber } from "svelte/store";
import { AppController } from "../../../lib/controllers/AppController";
import type { SGDBGame, SGDBImage } from "../../../lib/models/SGDB";
import { dbFilters, gridType, GridTypes, isOnline, needsSGDBAPIKey, selectedGameAppId, selectedGameName, steamGridDBKey, type DBFilters, currentPlatform, selectedSteamGridGameId, steamGridSearchCache, Platforms, selectedResultPage, appLibraryCache, manualSteamGames, customGameNames, steamGames, nonSteamGames } from "../../../stores/AppState";
import { dbFilters, gridType, GridTypes, isOnline, needsSGDBAPIKey, selectedGameAppId, selectedGameName, steamGridDBKey, type DBFilters, currentPlatform, selectedSteamGridGameId, steamGridSearchCache, Platforms, selectedResultPage, appLibraryCache, manualSteamGames, customGameNames, steamGames, nonSteamGames, gridsSize } from "../../../stores/AppState";
import SectionTitle from "../SectionTitle.svelte";
import Grid from "./Grid.svelte";
import DropDown from "../../interactables/DropDown.svelte";
Expand Down Expand Up @@ -258,7 +258,7 @@

<svelte:window on:resize={debouncedWidthUpdate} />

<Pane minSize={20}>
<Pane minSize={20} size={$gridsSize}>
<div class="inner">
<SectionTitle title="Grids" />

Expand Down
6 changes: 5 additions & 1 deletion src/lib/controllers/AppController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { ToastController } from "./ToastController";
import { SettingsManager } from "../utils/SettingsManager";
import { LogController } from "./LogController";
import { get } from "svelte/store";
import { GridTypes, Platforms, activeUserId, appLibraryCache, canSave, currentPlatform, customGameNames, dbFilters, gridType, hiddenGameIds, isOnline, loadingGames, manualSteamGames, needsSGDBAPIKey, needsSteamKey, nonSteamGames, originalAppLibraryCache, originalLogoPositions, originalSteamShortcuts, renderGamesInList, selectedGameAppId, selectedGameName, showHidden, steamGames, steamGridDBKey, steamKey, steamLogoPositions, steamShortcuts, steamUsers, theme } from "../../stores/AppState";
import { GridTypes, Platforms, activeUserId, appLibraryCache, canSave, currentPlatform, customGameNames, dbFilters, gamesSize, gridType, gridsSize, hiddenGameIds, isOnline, loadingGames, manualSteamGames, needsSGDBAPIKey, needsSteamKey, nonSteamGames, optionsSize, originalAppLibraryCache, originalLogoPositions, originalSteamShortcuts, renderGamesInList, selectedGameAppId, selectedGameName, showHidden, steamGames, steamGridDBKey, steamKey, steamLogoPositions, steamShortcuts, steamUsers, theme } from "../../stores/AppState";
import { cleanConflicts, gameSearchModalCancel, gameSearchModalDefault, gameSearchModalSelect, gridModalInfo, showCleanConflictDialog, showGameSearchModal, showGridModal, showSettingsModal } from "../../stores/Modals";
import { CacheController } from "./CacheController";
import { RustInterop } from "./RustInterop";
Expand Down Expand Up @@ -73,6 +73,10 @@ export class AppController {
showHidden.set(settings.showHiddenGames);
dbFilters.set(settings.filters);

optionsSize.set(settings.panels.options);
gamesSize.set(settings.panels.games);
gridsSize.set(settings.panels.grids);

await findSteamPath(settings.steamInstallPath);

const users = await RustInterop.getSteamUsers();
Expand Down
7 changes: 6 additions & 1 deletion src/lib/utils/SettingsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ const DEFAULT_SETTINGS = `{
"theme": 0,
"gameViewType": 0,
"showHiddenGames": false,
"filters": ${JSON.stringify(DEFAULT_FILTERS, null, "\t")}
"filters": ${JSON.stringify(DEFAULT_FILTERS, null, "\t")},
"panels": {
"options": 16,
"games": 42,
"grids": 42
}
}`;

/**
Expand Down
3 changes: 3 additions & 0 deletions src/stores/AppState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export enum Theme {

export const theme = writable(Theme.DARK);
export const renderGamesInList = writable(false);
export const optionsSize = writable(16);
export const gamesSize = writable(42);
export const gridsSize = writable(42);

export const requestTimeoutLength = writable(5000);

Expand Down
7 changes: 6 additions & 1 deletion src/types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ type AppSettings = {
theme: number,
gameViewType: number,
showHiddenGames: boolean,
filters: any
filters: any,
panels: {
options: number,
games: number,
grids: number
}
};

type LibraryCacheEntry = {
Expand Down
15 changes: 13 additions & 2 deletions src/windows/main/Main.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { SvelteToast } from "@zerodevx/svelte-toast";
import { onDestroy, onMount } from "svelte";
import Titlebar from "../../components/Titlebar.svelte";
import { Splitpanes } from "svelte-splitpanes";
import { Splitpanes, type IPaneSizingEvent } from "svelte-splitpanes";
import Footer from "../../components/Footer.svelte";
import Options from "../../components/core/filters/Options.svelte";
import Games from "../../components/core/games/Games.svelte";
Expand Down Expand Up @@ -56,6 +56,17 @@
LogController.error(`MainWindow: ${message} in ${fileName} at ${lineNumber}:${columnNumber}.`);
}
async function handlePanelResize(event: CustomEvent<IPaneSizingEvent[]>) {
console.log("Resize event:", event);
if (event.detail) {
await SettingsManager.updateSetting("panels", {
"options": event.detail[0].size,
"games": event.detail[1].size,
"grids": event.detail[2].size
})
}
}
onMount(async () => {
window.addEventListener("error", onError);
Expand Down Expand Up @@ -167,7 +178,7 @@
{#if $showUpdateModal}
<UpdateModal />
{/if}
<Splitpanes>
<Splitpanes dblClickSplitter={false} on:resized={handlePanelResize}>
<Options />

<Games />
Expand Down

0 comments on commit 398e5d7

Please sign in to comment.