Skip to content

Commit

Permalink
fix: added message for games without existing icons
Browse files Browse the repository at this point in the history
  • Loading branch information
Tormak9970 committed Feb 26, 2025
1 parent 11ad80e commit 30e9ad0
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 83 deletions.
3 changes: 1 addition & 2 deletions src-tauri/src/handle_changes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ fn adjust_path(app_handle: &AppHandle, appid: &str, path: &str, grid_type: &str)
/// Filters the grid paths based on which have change.
fn filter_paths(app_handle: &AppHandle, steam_path: String, steam_active_user_id: String, current_paths: &GridImageCache, original_paths: &GridImageCache, shortcut_icons: &Map<String, Value>) -> Vec<ChangedPath> {
let grids_dir = PathBuf::from(steam::get_grids_directory(app_handle.to_owned(), steam_path.to_owned(), steam_active_user_id));
let lib_cache_dir = PathBuf::from(steam::get_library_cache_directory(app_handle.to_owned(), steam_path.to_owned()));
let mut res:Vec<ChangedPath> = Vec::new();

for (appid, grids_map) in current_paths.into_iter() {
Expand All @@ -71,7 +70,7 @@ fn filter_paths(app_handle: &AppHandle, steam_path: String, steam_active_user_id
if source_path != "REMOVE" {
let adjusted_path = adjust_path(app_handle, appid.as_str(), source_path_owned.as_str(), grid_type.as_str()).replace("\\", "/");
if grid_type == "Icon" && !is_appid_shortcut(&appid, shortcut_icons) {
target_path = String::from(lib_cache_dir.join(adjusted_path).to_str().unwrap()).replace("\\", "/");
target_path = String::from(grid_path).replace("\\", "/");
} else {
target_path = String::from(grids_dir.join(adjusted_path).to_str().unwrap()).replace("\\", "/");
}
Expand Down
6 changes: 5 additions & 1 deletion src/components/core/games/GameEntry.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import type { Unsubscriber } from "svelte/store";
import { convertFileSrc } from "@tauri-apps/api/core";
import type { GameStruct, GridTypes, LibraryCacheEntry } from "@types";
import { GridTypes, type GameStruct, type LibraryCacheEntry } from "@types";
import { Platforms, appLibraryCache, currentPlatform, customGameNames, gridType, hiddenGameIds, originalAppLibraryCache, renderGamesInList, selectedGameAppId, unfilteredLibraryCache } from "../../../stores/AppState";
import { currentGridsAppid, showCurrentGridsModal } from "../../../stores/Modals";
import GridEntry from "./grid-view/GridEntry.svelte";
Expand All @@ -28,6 +28,8 @@
false;
$: canDiscard = gridChanged;
$: disabled = $gridType === GridTypes.ICON && iconPath === "";
/**
* Selects this game.
*/
Expand Down Expand Up @@ -127,6 +129,7 @@
selectGame={selectGame}
toggleHidden={toggleHidden}
showAllGrids={showAllGrids}
disabled={disabled}
/>
{:else}
<GridEntry
Expand All @@ -142,5 +145,6 @@
selectGame={selectGame}
toggleHidden={toggleHidden}
showAllGrids={showAllGrids}
disabled={disabled}
/>
{/if}
107 changes: 66 additions & 41 deletions src/components/core/games/grid-view/GridEntry.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,66 +13,91 @@
export let hasCustomName: boolean;
export let hasCustomArt: boolean;
export let canDiscard: boolean;
export let disabled: boolean;
export let selectGame: () => void;
export let toggleHidden: (isHidden: boolean) => void;
export let showAllGrids: (appId: number) => void;
</script>

<!-- svelte-ignore a11y-click-events-have-key-events -->
<div class="game" class:selected={$selectedGameAppId === game.appid.toString()} on:click={selectGame}>
<div class="button-container">
<div
class="image-control"
on:click|stopPropagation={() => showAllGrids(game.appid)}
use:AppController.tippy={{ content: "Grids", placement: "right", onShow: AppController.onTippyShow }}
>
<AllGrids />
</div>
<div
class="image-control"
on:click|stopPropagation={() => toggleHidden(!isHidden)}
use:AppController.tippy={{ content: isHidden ? "Unhide" : "Hide", placement: "right", onShow: AppController.onTippyShow }}
>
{#if isHidden}
<Show />
{:else}
<Hide />
{/if}
</div>
{#if hasCustomName}
<div
class="image-control"
on:click|stopPropagation={() => { AppController.clearCustomNameForGame(game.appid.toString()); }}
use:AppController.tippy={{ content: "Clear Name", placement: "right", onShow: AppController.onTippyShow }}
>
<Tag height="1em" />
</div>
{/if}
{#if hasCustomArt}
<!-- svelte-ignore a11y-no-static-element-interactions -->
<div class="container">
{#if disabled}
<div class="disabled-tooltip" use:AppController.tippy={{ content: "Icons can't be applied to games without them right now", placement: "top", onShow: AppController.onTippyShow }}></div>
{/if}
<div class="game" class:disabled class:selected={$selectedGameAppId === game.appid.toString()} on:click={selectGame}>
<div class="button-container">
<div
class="image-control"
on:click|stopPropagation={() => { AppController.clearCustomArtForGame(game.appid.toString()); }}
use:AppController.tippy={{ content: "Clear Art", placement: "right", onShow: AppController.onTippyShow }}
on:click|stopPropagation={() => showAllGrids(game.appid)}
use:AppController.tippy={{ content: "Grids", placement: "right", onShow: AppController.onTippyShow }}
>
<Ban />
<AllGrids />
</div>
{/if}
{#if canDiscard}
<div
class="image-control"
on:click|stopPropagation={() => { AppController.discardChangesForGame(game.appid.toString()); }}
use:AppController.tippy={{ content: "Discard Changes", placement: "right", onShow: AppController.onTippyShow }}
on:click|stopPropagation={() => toggleHidden(!isHidden)}
use:AppController.tippy={{ content: isHidden ? "Unhide" : "Hide", placement: "right", onShow: AppController.onTippyShow }}
>
<Recycle />
{#if isHidden}
<Show />
{:else}
<Hide />
{/if}
</div>
{/if}
{#if hasCustomName}
<div
class="image-control"
on:click|stopPropagation={() => { AppController.clearCustomNameForGame(game.appid.toString()); }}
use:AppController.tippy={{ content: "Clear Name", placement: "right", onShow: AppController.onTippyShow }}
>
<Tag height="1em" />
</div>
{/if}
{#if hasCustomArt}
<div
class="image-control"
on:click|stopPropagation={() => { AppController.clearCustomArtForGame(game.appid.toString()); }}
use:AppController.tippy={{ content: "Clear Art", placement: "right", onShow: AppController.onTippyShow }}
>
<Ban />
</div>
{/if}
{#if canDiscard}
<div
class="image-control"
on:click|stopPropagation={() => { AppController.discardChangesForGame(game.appid.toString()); }}
use:AppController.tippy={{ content: "Discard Changes", placement: "right", onShow: AppController.onTippyShow }}
>
<Recycle />
</div>
{/if}
</div>
<GridImage imagePath={imagePath} altText="{game.name}'s {$gridType} image" showImage={showImage} missingMessage="Missing {$gridType}" />
<div class="name" use:AppController.tippy={{ content: game.name, placement: "right", onShow: AppController.onTippyShow }}>{game.name}</div>
</div>
<GridImage imagePath={imagePath} altText="{game.name}'s {$gridType} image" showImage={showImage} missingMessage="Missing {$gridType}" />
<div class="name" use:AppController.tippy={{ content: game.name, placement: "right", onShow: AppController.onTippyShow }}>{game.name}</div>
</div>

<style>
.container {
position: relative;
}
.disabled-tooltip {
width: 100%;
height: 100%;
border-radius: 4px;
overflow: hidden;
position: absolute;
z-index: 1;
backdrop-filter: brightness(0.8);
}
.game {
background-color: var(--foreground);
padding: 10px;
Expand Down
112 changes: 73 additions & 39 deletions src/components/core/games/list-view/ListEntry.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
export let hasCustomName: boolean;
export let hasCustomArt: boolean;
export let canDiscard: boolean;
export let disabled: boolean;
export let selectGame: () => void;
export let toggleHidden: (isHidden: boolean) => void;
Expand All @@ -22,49 +23,79 @@

<!-- svelte-ignore a11y-click-events-have-key-events -->
<!-- svelte-ignore a11y-no-static-element-interactions -->
<div class="list-entry" class:selected={$selectedGameAppId === game.appid.toString()} on:click={selectGame}>
<div class="entry-info">
<div class="icon-container">
{#if showIcon}
<Lazy height="{SMALL_GRID_DIMENSIONS.heights.Icon}px" fadeOption={IMAGE_FADE_OPTIONS}>
<img src="{iconPath}" alt="{game.name}'s icon image" style="max-width: {SMALL_GRID_DIMENSIONS.widths.Icon}px; max-height: {SMALL_GRID_DIMENSIONS.heights.Icon}px; width: auto; height: auto;" draggable="false" />
</Lazy>
{:else}
<div style="text-align: center;">No icon image for game</div>
{/if}
</div>
<div class="name" use:AppController.tippy={{ content: game.name, placement: "right", onShow: AppController.onTippyShow }}>{game.name}</div>
</div>
<div class="status">
<div class="image-control" on:click|stopPropagation={() => showAllGrids(game.appid)} use:AppController.tippy={{ content: "View Grids", placement: "right", onShow: AppController.onTippyShow }}>
<AllGrids />
</div>
<div class="image-control" on:click|stopPropagation={() => toggleHidden(!isHidden)} use:AppController.tippy={{ content: isHidden ? "Unhide" : "Hide", placement: "right", onShow: AppController.onTippyShow }}>
{#if isHidden}
<Show />
{:else}
<Hide />
{/if}
</div>
{#if hasCustomName}
<div class="image-control" on:click|stopPropagation={() => { AppController.clearCustomNameForGame(game.appid.toString()); }} use:AppController.tippy={{ content: "Clear Custom Name", placement: "right", onShow: AppController.onTippyShow }}>
<Tag />
<div class="container">
{#if disabled}
<div class="disabled-tooltip" use:AppController.tippy={{ content: "Icons can't be applied to games without them right now", placement: "top", onShow: AppController.onTippyShow }}></div>
{/if}
<div class="list-entry" class:disabled class:selected={$selectedGameAppId === game.appid.toString()} on:click={selectGame}>
<div class="entry-info">
<div class="icon-container">
{#if showIcon}
<Lazy height="{SMALL_GRID_DIMENSIONS.heights.Icon}px" fadeOption={IMAGE_FADE_OPTIONS}>
<img src="{iconPath}" alt="{game.name}'s icon image" style="max-width: {SMALL_GRID_DIMENSIONS.widths.Icon}px; max-height: {SMALL_GRID_DIMENSIONS.heights.Icon}px; width: auto; height: auto;" draggable="false" />
</Lazy>
{:else}
<div style="text-align: center;">No icon image for game</div>
{/if}
</div>
{/if}
{#if hasCustomArt}
<div class="image-control" on:click|stopPropagation={() => { AppController.clearCustomArtForGame(game.appid.toString()); }} use:AppController.tippy={{ content: "Clear Art", placement: "right", onShow: AppController.onTippyShow }}>
<Ban />
<div class="name" use:AppController.tippy={{ content: game.name, placement: "right", onShow: AppController.onTippyShow }}>{game.name}</div>
</div>
<div class="status">
<div class="image-control" on:click|stopPropagation={() => showAllGrids(game.appid)} use:AppController.tippy={{ content: "View Grids", placement: "right", onShow: AppController.onTippyShow }}>
<AllGrids />
</div>
{/if}
{#if canDiscard}
<div class="image-control" on:click|stopPropagation={() => { AppController.discardChangesForGame(game.appid.toString()); }} use:AppController.tippy={{ content: "Discard Changes", placement: "right", onShow: AppController.onTippyShow }}>
<Recycle />
<div class="image-control" on:click|stopPropagation={() => toggleHidden(!isHidden)} use:AppController.tippy={{ content: isHidden ? "Unhide" : "Hide", placement: "right", onShow: AppController.onTippyShow }}>
{#if isHidden}
<Show />
{:else}
<Hide />
{/if}
</div>
{/if}
{#if hasCustomName}
<div class="image-control" on:click|stopPropagation={() => { AppController.clearCustomNameForGame(game.appid.toString()); }} use:AppController.tippy={{ content: "Clear Custom Name", placement: "right", onShow: AppController.onTippyShow }}>
<Tag />
</div>
{/if}
{#if hasCustomArt}
<div class="image-control" on:click|stopPropagation={() => { AppController.clearCustomArtForGame(game.appid.toString()); }} use:AppController.tippy={{ content: "Clear Art", placement: "right", onShow: AppController.onTippyShow }}>
<Ban />
</div>
{/if}
{#if canDiscard}
<div class="image-control" on:click|stopPropagation={() => { AppController.discardChangesForGame(game.appid.toString()); }} use:AppController.tippy={{ content: "Discard Changes", placement: "right", onShow: AppController.onTippyShow }}>
<Recycle />
</div>
{/if}
</div>
</div>
</div>

<style>
.container {
width: 100%;
border-radius: 4px;
margin-bottom: 7px;
margin-right: 7px;
position: relative;
}
.disabled-tooltip {
width: 100%;
height: 100%;
border-radius: 4px;
overflow: hidden;
position: absolute;
z-index: 1;
backdrop-filter: brightness(0.8);
}
.list-entry {
background-color: var(--foreground);
padding: 6px 10px;
Expand All @@ -85,12 +116,15 @@
transition: background-color 0.2s ease-in-out;
margin-bottom: 7px;
margin-right: 7px;
width: calc(100% - 20px);
width: 100%;
z-index: 0;
}
.list-entry:hover { background-color: var(--foreground-hover); }
.disabled {
pointer-events: none;
}
.selected { background-color: var(--foreground-light); }
.selected:hover { background-color: var(--foreground-light-hover); }
Expand Down

0 comments on commit 30e9ad0

Please sign in to comment.