mirror of
https://github.com/lutris/lutris
synced 2024-11-02 11:48:38 +00:00
Add a 'missing' column for the game store; use this to display a badge in teh grid view.
The initialization of this thing is not very efficient though.
This commit is contained in:
parent
89b191af70
commit
668cd25220
5 changed files with 36 additions and 5 deletions
|
@ -15,7 +15,8 @@
|
|||
COL_INSTALLED_AT_TEXT,
|
||||
COL_PLAYTIME,
|
||||
COL_PLAYTIME_TEXT,
|
||||
) = list(range(15))
|
||||
COL_MISSING
|
||||
) = list(range(16))
|
||||
|
||||
COLUMN_NAMES = {
|
||||
COL_NAME: "name",
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
from gi.repository import Gtk
|
||||
|
||||
from lutris import settings
|
||||
from lutris.gui.views import COL_INSTALLED, COL_MEDIA_PATH, COL_NAME, COL_PLATFORM
|
||||
from lutris.gui.views import COL_INSTALLED, COL_MEDIA_PATH, COL_NAME, COL_PLATFORM, COL_MISSING
|
||||
from lutris.gui.views.base import GameView
|
||||
from lutris.gui.widgets.cellrenderers import GridViewCellRendererImage, GridViewCellRendererText
|
||||
from lutris.util.log import logger
|
||||
|
@ -75,8 +75,10 @@ class GameGridView(Gtk.IconView, GameView):
|
|||
self.add_attribute(self.image_renderer, "media_path", COL_MEDIA_PATH)
|
||||
if self.show_badges:
|
||||
self.add_attribute(self.image_renderer, "platform", COL_PLATFORM)
|
||||
self.add_attribute(self.image_renderer, "is_missing", COL_MISSING)
|
||||
else:
|
||||
self.image_renderer.platform = None
|
||||
self.image_renderer.is_missing = False
|
||||
self.add_attribute(self.image_renderer, "is_installed", COL_INSTALLED)
|
||||
|
||||
def select(self):
|
||||
|
|
|
@ -12,7 +12,8 @@ from lutris.util.strings import gtk_safe
|
|||
|
||||
from . import (
|
||||
COL_ID, COL_INSTALLED, COL_INSTALLED_AT, COL_INSTALLED_AT_TEXT, COL_LASTPLAYED, COL_LASTPLAYED_TEXT, COL_MEDIA_PATH,
|
||||
COL_NAME, COL_PLATFORM, COL_PLAYTIME, COL_PLAYTIME_TEXT, COL_RUNNER, COL_RUNNER_HUMAN_NAME, COL_SLUG, COL_YEAR
|
||||
COL_NAME, COL_PLATFORM, COL_PLAYTIME, COL_PLAYTIME_TEXT, COL_RUNNER, COL_RUNNER_HUMAN_NAME, COL_SLUG, COL_YEAR,
|
||||
COL_MISSING
|
||||
)
|
||||
|
||||
|
||||
|
@ -82,6 +83,7 @@ class GameStore(GObject.Object):
|
|||
str,
|
||||
float,
|
||||
str,
|
||||
bool
|
||||
)
|
||||
|
||||
@property
|
||||
|
@ -144,6 +146,7 @@ class GameStore(GObject.Object):
|
|||
row[COL_INSTALLED_AT_TEXT] = store_item.installed_at_text
|
||||
row[COL_PLAYTIME] = store_item.playtime
|
||||
row[COL_PLAYTIME_TEXT] = store_item.playtime_text
|
||||
row[COL_MISSING] = store_item.missing
|
||||
return True
|
||||
|
||||
def add_game(self, db_game):
|
||||
|
@ -166,6 +169,7 @@ class GameStore(GObject.Object):
|
|||
game.installed_at_text,
|
||||
game.playtime,
|
||||
game.playtime_text,
|
||||
game.missing
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
"""Game representation for views"""
|
||||
import os
|
||||
import time
|
||||
|
||||
from lutris.database import games
|
||||
from lutris.database.games import get_service_games
|
||||
from lutris.runners import get_runner_human_name
|
||||
from lutris.scanners.lutris import get_path_cache
|
||||
from lutris.services import SERVICES
|
||||
from lutris.util.log import logger
|
||||
from lutris.util.strings import get_formatted_playtime, gtk_safe
|
||||
|
@ -55,7 +57,7 @@ class StoreItem:
|
|||
@property
|
||||
def id(self): # pylint: disable=invalid-name
|
||||
"""Game internal ID"""
|
||||
# Return an unique identifier for the game.
|
||||
# Return a unique identifier for the game.
|
||||
# Since service games are not related to lutris, use the appid
|
||||
if "service_id" not in self._game_data:
|
||||
if "appid" in self._game_data:
|
||||
|
@ -116,6 +118,17 @@ class StoreItem:
|
|||
return False
|
||||
return self._game_data.get("installed")
|
||||
|
||||
@property
|
||||
def missing(self):
|
||||
"""Game is installed, but its directory is not found."""
|
||||
if self.installed:
|
||||
cache = get_path_cache()
|
||||
id = self.id
|
||||
path = cache.get(str(id))
|
||||
if path and not os.path.exists(path):
|
||||
return True
|
||||
return False
|
||||
|
||||
def get_media_path(self):
|
||||
"""Returns the path to the image file for this item"""
|
||||
if self._game_data.get("icon"):
|
||||
|
|
|
@ -95,6 +95,7 @@ class GridViewCellRendererImage(Gtk.CellRenderer):
|
|||
self._media_path = None
|
||||
self._platform = None
|
||||
self._is_installed = True
|
||||
self._is_missing = False
|
||||
self.cached_surfaces_new = {}
|
||||
self.cached_surfaces_old = {}
|
||||
self.cached_surfaces_loaded = 0
|
||||
|
@ -156,6 +157,15 @@ class GridViewCellRendererImage(Gtk.CellRenderer):
|
|||
def is_installed(self, value):
|
||||
self._is_installed = value
|
||||
|
||||
@GObject.Property(type=bool, default=False)
|
||||
def is_missing(self):
|
||||
"""This flag indicates if the game is missing; if so a badge is shown."""
|
||||
return self._is_missing
|
||||
|
||||
@is_missing.setter
|
||||
def is_missing(self, value):
|
||||
self._is_missing = value
|
||||
|
||||
def do_get_preferred_width(self, widget):
|
||||
return self.media_width, self.media_width
|
||||
|
||||
|
@ -175,7 +185,6 @@ class GridViewCellRendererImage(Gtk.CellRenderer):
|
|||
path = get_default_icon_path((media_width, media_height))
|
||||
surface = self.get_cached_surface_by_path(widget, path,
|
||||
preserve_aspect_ratio=False)
|
||||
|
||||
if surface:
|
||||
x, y = self.get_media_position(surface, cell_area)
|
||||
self.select_badge_metrics(surface)
|
||||
|
@ -183,6 +192,8 @@ class GridViewCellRendererImage(Gtk.CellRenderer):
|
|||
if alpha >= 1:
|
||||
self.render_media(cr, widget, surface, x, y)
|
||||
self.render_platforms(cr, widget, surface, x, cell_area)
|
||||
if self.is_missing:
|
||||
self.render_text_badge(cr, widget, "Missing", x, cell_area.y + cell_area.height)
|
||||
else:
|
||||
cr.push_group()
|
||||
self.render_media(cr, widget, surface, x, y)
|
||||
|
|
Loading…
Reference in a new issue