mirror of
https://github.com/lutris/lutris
synced 2024-10-06 07:50:16 +00:00
Remove get_icon_path and get_banner_path from datapath module
This commit is contained in:
parent
9815b372fa
commit
a59d8bd20c
|
@ -15,7 +15,6 @@ from lutris.gui.widgets.utils import (
|
|||
ICON_SIZE,
|
||||
)
|
||||
from lutris.util.strings import slugify
|
||||
from lutris.util import datapath
|
||||
from lutris.util import resources
|
||||
|
||||
|
||||
|
@ -465,12 +464,12 @@ class GameDialogCommon:
|
|||
image_path = dialog.get_filename()
|
||||
if image_type == "banner":
|
||||
self.game.has_custom_banner = True
|
||||
dest_path = datapath.get_banner_path(self.game.slug)
|
||||
dest_path = resources.get_banner_path(self.game.slug)
|
||||
size = BANNER_SIZE
|
||||
file_format = "jpeg"
|
||||
else:
|
||||
self.game.has_custom_icon = True
|
||||
dest_path = datapath.get_icon_path(self.game.slug)
|
||||
dest_path = resources.get_icon_path(self.game.slug)
|
||||
size = ICON_SIZE
|
||||
file_format = "png"
|
||||
pixbuf = get_pixbuf(image_path, size)
|
||||
|
@ -485,10 +484,10 @@ class GameDialogCommon:
|
|||
def on_custom_image_reset_clicked(self, widget, image_type):
|
||||
if image_type == "banner":
|
||||
self.game.has_custom_banner = False
|
||||
dest_path = datapath.get_banner_path(self.game.slug)
|
||||
dest_path = resources.get_banner_path(self.game.slug)
|
||||
elif image_type == "icon":
|
||||
self.game.has_custom_icon = False
|
||||
dest_path = datapath.get_icon_path(self.game.slug)
|
||||
dest_path = resources.get_icon_path(self.game.slug)
|
||||
else:
|
||||
raise ValueError("Unsupported image type %s", image_type)
|
||||
os.remove(dest_path)
|
||||
|
|
|
@ -806,4 +806,5 @@ class LutrisWindow(Gtk.ApplicationWindow):
|
|||
dialogs.ErrorDialog("Could not connect to your Lutris account, please sign-in again.")
|
||||
|
||||
def show_library_sync_error(self):
|
||||
dialogs.ErrorDialog("Failed to retrieve game library, there might be some problems contacting lutris.net")
|
||||
dialogs.ErrorDialog("Failed to retrieve game library, "
|
||||
"there might be some problems contacting lutris.net")
|
||||
|
|
|
@ -252,7 +252,6 @@ class GameStore(GObject.Object):
|
|||
self.refresh_icon(game.slug)
|
||||
|
||||
def refresh_icon(self, game_slug):
|
||||
logger.debug("Getting icon for %s", game_slug)
|
||||
AsyncCall(self.fetch_icon, None, game_slug)
|
||||
|
||||
def on_icon_loaded(self, _store, game_slug, media_type):
|
||||
|
@ -280,12 +279,12 @@ class GameStore(GObject.Object):
|
|||
for media_type in ("banner", "icon"):
|
||||
url = self.medias[media_type].get(slug)
|
||||
if url:
|
||||
logger.debug("Getting %s for %s: %s", media_type, slug, url)
|
||||
download_media(url, get_icon_path(slug, media_type))
|
||||
self.emit("icon-loaded", slug, media_type)
|
||||
|
||||
def on_media_loaded(self, response):
|
||||
for slug in self.games_to_refresh:
|
||||
logger.debug("Refreshing %s", slug)
|
||||
self.refresh_icon(slug)
|
||||
|
||||
def add_games_by_ids(self, game_ids):
|
||||
|
|
|
@ -7,6 +7,7 @@ from gi.repository import GdkPixbuf, GLib, Gtk, Gio, Gdk
|
|||
from lutris.util.log import logger
|
||||
from lutris.util import datapath
|
||||
from lutris.util import system
|
||||
from lutris.util import resources
|
||||
from lutris import settings
|
||||
|
||||
|
||||
|
@ -102,10 +103,10 @@ def get_overlay(overlay_path, size):
|
|||
def get_pixbuf_for_game(game_slug, icon_type, is_installed=True):
|
||||
if icon_type.startswith("banner"):
|
||||
default_icon_path = os.path.join(datapath.get(), "media/default_banner.png")
|
||||
icon_path = datapath.get_banner_path(game_slug)
|
||||
icon_path = resources.get_banner_path(game_slug)
|
||||
elif icon_type.startswith("icon"):
|
||||
default_icon_path = os.path.join(datapath.get(), "media/default_icon.png")
|
||||
icon_path = datapath.get_icon_path(game_slug)
|
||||
icon_path = resources.get_icon_path(game_slug)
|
||||
else:
|
||||
logger.error("Invalid icon type '%s'", icon_type)
|
||||
return None
|
||||
|
|
|
@ -36,7 +36,11 @@ class residualvm(Runner):
|
|||
"option": "renderer",
|
||||
"label": "Renderer",
|
||||
"type": "choice",
|
||||
"choices": (("OpenGL", "opengl"), ("OpenGL shaders", "opengl_shaders"), ("Software", "software")),
|
||||
"choices": (
|
||||
("OpenGL", "opengl"),
|
||||
("OpenGL shaders", "opengl_shaders"),
|
||||
("Software", "software"),
|
||||
),
|
||||
"default": "OpenGL",
|
||||
},
|
||||
{
|
||||
|
@ -105,7 +109,7 @@ class residualvm(Runner):
|
|||
dir_limit = None
|
||||
if dir_limit is not None:
|
||||
game_dir = game[0:dir_limit]
|
||||
game_name = game[dir_limit + 1:len(game)].strip()
|
||||
game_name = game[dir_limit + 1 : len(game)].strip()
|
||||
game_array.append([game_dir, game_name])
|
||||
# The actual list is below a separator
|
||||
if game.startswith("-----"):
|
||||
|
|
|
@ -4,7 +4,7 @@ import shlex
|
|||
from urllib.parse import urlparse
|
||||
|
||||
from lutris.runners.runner import Runner
|
||||
from lutris.util import datapath, system
|
||||
from lutris.util import datapath, system, resources
|
||||
from lutris import pga, settings
|
||||
|
||||
DEFAULT_ICON = os.path.join(datapath.get(), "media/default_icon.png")
|
||||
|
@ -209,7 +209,7 @@ class web(Runner):
|
|||
|
||||
return {"command": command}
|
||||
|
||||
icon = datapath.get_icon_path(game_data.get("slug"))
|
||||
icon = resources.get_icon_path(game_data.get("slug"))
|
||||
if not system.path_exists(icon):
|
||||
icon = DEFAULT_ICON
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
"""Utility to get the path of Lutris assets"""
|
||||
import os
|
||||
import sys
|
||||
from lutris import settings
|
||||
from lutris.util import system
|
||||
|
||||
|
||||
|
@ -23,11 +23,3 @@ def get():
|
|||
if not system.path_exists(data_path):
|
||||
raise IOError("data_path can't be found at : %s" % data_path)
|
||||
return data_path
|
||||
|
||||
|
||||
def get_banner_path(slug):
|
||||
return os.path.join(settings.BANNER_PATH, "%s.jpg" % slug)
|
||||
|
||||
|
||||
def get_icon_path(slug):
|
||||
return os.path.join(settings.ICON_PATH, "lutris_%s.png" % slug)
|
||||
|
|
|
@ -14,7 +14,7 @@ BANNER = "banner"
|
|||
ICON = "icon"
|
||||
|
||||
|
||||
def get_icon_path(game_slug, icon_type):
|
||||
def get_icon_path(game_slug, icon_type=ICON):
|
||||
"""Return the absolute path for a game_slug icon/banner"""
|
||||
if icon_type == BANNER:
|
||||
return os.path.join(settings.BANNER_PATH, "%s.jpg" % game_slug)
|
||||
|
@ -23,6 +23,10 @@ def get_icon_path(game_slug, icon_type):
|
|||
return None
|
||||
|
||||
|
||||
def get_banner_path(game_slug):
|
||||
return get_icon_path(game_slug, BANNER)
|
||||
|
||||
|
||||
def fetch_icons(lutris_media, callback):
|
||||
"""Download missing icons from lutris.net"""
|
||||
if not lutris_media:
|
||||
|
|
Loading…
Reference in a new issue