-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added start menu tiles updating system
- Loading branch information
1 parent
90ce315
commit f8d80e5
Showing
11 changed files
with
176 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
<script lang="ts"> | ||
import { showUpdateTilesModal } from "../../stores/Modals"; | ||
import { appLibraryCache, manualSteamGames, originalAppLibraryCache, steamGames } from "../../stores/AppState"; | ||
import { AppController } from "../../lib/controllers/AppController"; | ||
import { ToastController } from "../../lib/controllers/ToastController"; | ||
import { LogController } from "../../lib/controllers/LogController"; | ||
import { onMount } from "svelte"; | ||
import Button from "../interactables/Button.svelte"; | ||
import Spacer from "../layout/Spacer.svelte"; | ||
import ModalBody from "./modal-utils/ModalBody.svelte"; | ||
import GameFilter from "./modal-utils/game-filter/GameFilter.svelte"; | ||
let appsWithTilesIds: string[]; | ||
let appsWithTiles: Record<string, string>; | ||
let filteredSteamGames: GameStruct[] = []; | ||
let selectedGameIds: string[] = []; | ||
/** | ||
* The function to run when the modal closes. | ||
*/ | ||
function onClose(): void { | ||
$showUpdateTilesModal = false; | ||
} | ||
/** | ||
* Updates the tile for the chosen games | ||
*/ | ||
async function updateGameTiles(): Promise<void> { | ||
const appIconEntries = selectedGameIds.map((appid) => [ appid, $appLibraryCache[appid].Icon ]); | ||
const appIconsMap = Object.fromEntries(appIconEntries); | ||
const appTilePathEntries = selectedGameIds.map((appid) => [ appid, appsWithTiles[appid] ]); | ||
const appTilePathsMap = Object.fromEntries(appTilePathEntries); | ||
const failedIds = await AppController.updateAppTiles(appIconsMap, appTilePathsMap); | ||
if (failedIds.length > 0) { | ||
LogController.error(`Failed to update ${failedIds.length} tiles. Ids that failed: ${JSON.stringify(failedIds)}.`); | ||
ToastController.showWarningToast(`Failed to update ${failedIds.length} tiles!`) | ||
} else { | ||
LogController.log(`Updated ${selectedGameIds.length} tiles.`); | ||
ToastController.showSuccessToast(`Updated ${selectedGameIds.length} tiles`); | ||
onClose(); | ||
} | ||
} | ||
onMount(() => { | ||
AppController.getAppTiles().then((appTiles) => { | ||
appsWithTilesIds = Object.keys(appTiles); | ||
appsWithTiles = appTiles; | ||
const tilesFilter = (game: GameStruct) => { | ||
return appsWithTilesIds.includes(game.appid.toString()); | ||
} | ||
// TODO: potentially diff the images to determine if this has been applied before. | ||
const gameIconChangedFilter = (game: GameStruct) => { | ||
return $appLibraryCache[game.appid].Icon !== $originalAppLibraryCache[game.appid].Icon; | ||
} | ||
filteredSteamGames = [ ...$steamGames, ...$manualSteamGames ].filter(gameIconChangedFilter).filter(tilesFilter); | ||
}); | ||
}); | ||
</script> | ||
|
||
<ModalBody title={"Update Start Menu Tiles"} onClose={onClose}> | ||
<div class="content"> | ||
<Spacer orientation="VERTICAL" /> | ||
<div class="description"> | ||
Here you can batch update the game icons shown in your Operating System's start menu to match your custom icons shown in steam. | ||
<br/> | ||
<br/> | ||
Games that show up below are the result of the following filters: | ||
<br/> | ||
<ul> | ||
<li>You already have a Start Menu shortcut for this game.</li> | ||
<li>You have changed the icon for this game.</li> | ||
</ul> | ||
</div> | ||
<Spacer orientation="VERTICAL" /> | ||
<Spacer orientation="VERTICAL" /> | ||
<div class="view"> | ||
<GameFilter steamGames={filteredSteamGames} bind:selectedGameIds={selectedGameIds} showPlatforms={false} showFilters={false} noGamesMessage={"No games with tiles/new icons were found."}/> | ||
</div> | ||
<div class="buttons"> | ||
<Button label="Update" onClick={updateGameTiles} width="47.5%" disabled={selectedGameIds.length === 0} /> | ||
<Button label="Cancel" onClick={onClose} width="47.5%" /> | ||
</div> | ||
</div> | ||
</ModalBody> | ||
|
||
<style> | ||
.content { | ||
width: 600px; | ||
height: calc(100% - 60px); | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: flex-start; | ||
align-items: center; | ||
} | ||
.description { | ||
width: calc(100% - 14px); | ||
font-size: 14px; | ||
} | ||
.description ul { | ||
margin: 0px; | ||
padding-left: 20px; | ||
font-size: 13px; | ||
} | ||
.description li { | ||
margin-top: 4px; | ||
} | ||
.view { | ||
width: 100%; | ||
} | ||
.buttons { | ||
margin-top: 14px; | ||
margin-bottom: 7px; | ||
width: 100%; | ||
display: flex; | ||
justify-content: space-around; | ||
justify-self: flex-end; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.