Basic animated cover support

This commit is contained in:
kramo
2023-04-10 23:24:48 +02:00
parent c1715aa328
commit 62aff0e7cc
6 changed files with 79 additions and 4 deletions

View File

@@ -25,6 +25,7 @@ from shutil import rmtree
from gi.repository import Adw, GdkPixbuf, Gio, GLib, Gtk
from .display_animation import display_animation
from .game import game
from .get_games import get_games
from .save_game import save_game
@@ -99,6 +100,7 @@ class CartridgesWindow(Adw.ApplicationWindow):
self.active_game_id = None
self.loading = None
self.scaled_pixbuf = None
self.current_anim = None
self.overview.set_measure_overlay(self.overview_box, True)
self.overview.set_clip_overlay(self.overview_box, False)
@@ -286,6 +288,18 @@ class CartridgesWindow(Adw.ApplicationWindow):
pixbuf = current_game.pixbuf
self.overview_cover.set_pixbuf(pixbuf)
new_id = game_id if self.current_anim != game_id else f"{game_id}_new"
self.current_anim = new_id
if current_game.animation_path.is_file():
display_animation(
self.overview_cover.set_pixbuf,
current_game.animation_path,
parent_widget=self,
game_id=new_id,
)
self.scaled_pixbuf = pixbuf.scale_simple(2, 3, GdkPixbuf.InterpType.BILINEAR)
self.overview_blurred_cover.set_pixbuf(self.scaled_pixbuf)
self.set_overview_opacity()