Added playable button feauture that shows only games I could play now

This commit is contained in:
Hoaper
2025-05-19 22:33:32 +05:00
parent 650b02e673
commit 2224b00c57
11 changed files with 53 additions and 12 deletions

View File

@@ -122,5 +122,6 @@
"typescript": "^5.3.3", "typescript": "^5.3.3",
"vite": "^5.0.12", "vite": "^5.0.12",
"vite-plugin-svgr": "^4.2.0" "vite-plugin-svgr": "^4.2.0"
} },
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
} }

View File

@@ -21,7 +21,8 @@
"queued": "{{title}} (In Warteschlange)", "queued": "{{title}} (In Warteschlange)",
"game_has_no_executable": "Spiel hat keine ausführbare Datei gewählt", "game_has_no_executable": "Spiel hat keine ausführbare Datei gewählt",
"sign_in": "Anmelden", "sign_in": "Anmelden",
"favorites": "Favoriten" "favorites": "Favoriten",
"playable_button_title": "Nur Spiele anzeigen, die Sie jetzt spielen können"
}, },
"header": { "header": {
"search": "Spiele suchen", "search": "Spiele suchen",

View File

@@ -27,7 +27,8 @@
"sign_in": "Sign in", "sign_in": "Sign in",
"friends": "Friends", "friends": "Friends",
"need_help": "Need help?", "need_help": "Need help?",
"favorites": "Favorites" "favorites": "Favorites",
"playable_button_title": "Show only games you could play now"
}, },
"header": { "header": {
"search": "Search games", "search": "Search games",

View File

@@ -27,7 +27,8 @@
"sign_in": "Iniciar sesión", "sign_in": "Iniciar sesión",
"friends": "Amigos", "friends": "Amigos",
"need_help": "¿Necesitas ayuda?", "need_help": "¿Necesitas ayuda?",
"favorites": "Favoritos" "favorites": "Favoritos",
"playable_button_title": "Mostrar solo juegos que puedes jugar ahora"
}, },
"header": { "header": {
"search": "Buscar juegos", "search": "Buscar juegos",

View File

@@ -27,7 +27,8 @@
"sign_in": "Se connecter", "sign_in": "Se connecter",
"friends": "Amis", "friends": "Amis",
"need_help": "Besoin d'aide ?", "need_help": "Besoin d'aide ?",
"favorites": "Favoris" "favorites": "Favoris",
"playable_button_title": "Afficher uniquement les jeux que vous pouvez jouer maintenant"
}, },
"header": { "header": {
"search": "Rechercher", "search": "Rechercher",

View File

@@ -15,7 +15,8 @@
"downloading": "{{title}} ({{percentage}} - Download…)", "downloading": "{{title}} ({{percentage}} - Download…)",
"filter": "Filtra libreria", "filter": "Filtra libreria",
"home": "Home", "home": "Home",
"favorites": "Preferiti" "favorites": "Preferiti",
"playable_button_title": "Mostra solo i giochi che puoi giocare ora"
}, },
"header": { "header": {
"search": "Cerca", "search": "Cerca",

View File

@@ -15,7 +15,8 @@
"downloading": "{{title}} ({{percentage}} - Pobieranie…)", "downloading": "{{title}} ({{percentage}} - Pobieranie…)",
"filter": "Filtruj biblioteke", "filter": "Filtruj biblioteke",
"home": "Główna", "home": "Główna",
"favorites": "Ulubione" "favorites": "Ulubione",
"playable_button_title": "Pokaż tylko gry, w które możesz grać teraz"
}, },
"header": { "header": {
"search": "Szukaj", "search": "Szukaj",

View File

@@ -27,7 +27,8 @@
"sign_in": "Войти", "sign_in": "Войти",
"friends": "Друзья", "friends": "Друзья",
"need_help": "Нужна помощь?", "need_help": "Нужна помощь?",
"favorites": "Избранное" "favorites": "Избранное",
"playable_button_title": "Показать только игры, в которые можно играть сейчас"
}, },
"header": { "header": {
"search": "Поиск", "search": "Поиск",

View File

@@ -25,9 +25,10 @@
"game_has_no_executable": "Не було вибрано файл для запуску гри", "game_has_no_executable": "Не було вибрано файл для запуску гри",
"queued": "{{title}} в черзі", "queued": "{{title}} в черзі",
"sign_in": "Увійти", "sign_in": "Увійти",
"favorites": "Улюблені", "favorites": "Избранное",
"friends": "Друзі", "friends": "Друзі",
"need_help": "Потрібна допомога?" "need_help": "Потрібна допомога?",
"playable_button_title": "Показать только игры, в которые можно играть сейчас"
}, },
"header": { "header": {
"search": "Пошук", "search": "Пошук",

View File

@@ -143,3 +143,23 @@
border-radius: 50%; border-radius: 50%;
} }
} }
.sidebar__play-button {
background: none;
border: none;
color: white;
cursor: pointer;
padding: 0;
&:active {
color: gray;
}
&--active {
color: #16b195;
}
svg {
display: block;
}
}

View File

@@ -21,7 +21,7 @@ import { buildGameDetailsPath } from "@renderer/helpers";
import { SidebarProfile } from "./sidebar-profile"; import { SidebarProfile } from "./sidebar-profile";
import { sortBy } from "lodash-es"; import { sortBy } from "lodash-es";
import cn from "classnames"; import cn from "classnames";
import { CommentDiscussionIcon } from "@primer/octicons-react"; import { CommentDiscussionIcon, PlayIcon } from "@primer/octicons-react";
import { SidebarGameItem } from "./sidebar-game-item"; import { SidebarGameItem } from "./sidebar-game-item";
import { setFriendRequestCount } from "@renderer/features/user-details-slice"; import { setFriendRequestCount } from "@renderer/features/user-details-slice";
import { useDispatch } from "react-redux"; import { useDispatch } from "react-redux";
@@ -60,6 +60,12 @@ export function Sidebar() {
const { showWarningToast } = useToast(); const { showWarningToast } = useToast();
const [showPlayableOnly, setShowPlayableOnly] = useState(false);
const handlePlayButtonClick = () => {
setShowPlayableOnly(!showPlayableOnly);
};
useEffect(() => { useEffect(() => {
updateLibrary(); updateLibrary();
}, [lastPacket?.gameId, updateLibrary]); }, [lastPacket?.gameId, updateLibrary]);
@@ -242,7 +248,12 @@ export function Sidebar() {
)} )}
<section className="sidebar__section"> <section className="sidebar__section">
<small className="sidebar__section-title">{t("my_library")}</small> <div style={{ display: "flex", justifyContent: "space-between", alignItems: "center" }}>
<small className="sidebar__section-title">{t("my_library")}</small>
<button type="button" className={`sidebar__play-button ${showPlayableOnly ? 'sidebar__play-button--active' : ''}`} title={t("playable_button_title")} onClick={handlePlayButtonClick}>
<PlayIcon size={16} />
</button>
</div>
<TextField <TextField
ref={filterRef} ref={filterRef}
@@ -254,6 +265,7 @@ export function Sidebar() {
<ul className="sidebar__menu"> <ul className="sidebar__menu">
{filteredLibrary {filteredLibrary
.filter((game) => !game.favorite) .filter((game) => !game.favorite)
.filter((game) => !showPlayableOnly || Boolean(game.executablePath))
.map((game) => ( .map((game) => (
<SidebarGameItem <SidebarGameItem
key={game.id} key={game.id}