🎨 Reorganized game loading from disk
This commit is contained in:
@@ -1,14 +1,13 @@
|
||||
from src import shared
|
||||
from src.game import Game
|
||||
from src.store.managers.file_manager import FileManager
|
||||
from src.store.managers.manager import Manager
|
||||
from src.store.managers.sgdb_manager import SGDBManager
|
||||
from src.store.managers.steam_api_manager import SteamAPIManager
|
||||
|
||||
|
||||
class DisplayManager(Manager):
|
||||
"""Manager in charge of adding a game to the UI"""
|
||||
|
||||
run_after = set((SteamAPIManager, SGDBManager))
|
||||
run_after = set((FileManager,))
|
||||
|
||||
def run(self, game: Game) -> None:
|
||||
# TODO decouple a game from its widget
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from src.game import Game
|
||||
from src.store.managers.format_update_manager import FormatUpdateManager
|
||||
from src.store.managers.manager import Manager
|
||||
from src.store.managers.sgdb_manager import SGDBManager
|
||||
from src.store.managers.steam_api_manager import SteamAPIManager
|
||||
@@ -7,7 +8,7 @@ from src.store.managers.steam_api_manager import SteamAPIManager
|
||||
class FileManager(Manager):
|
||||
"""Manager in charge of saving a game to a file"""
|
||||
|
||||
run_after = set((SteamAPIManager, SGDBManager))
|
||||
run_after = set((SteamAPIManager, SGDBManager, FormatUpdateManager))
|
||||
|
||||
def run(self, game: Game) -> None:
|
||||
# TODO make game.save (disk) not trigger game.update (UI)
|
||||
|
||||
20
src/store/managers/format_update_manager.py
Normal file
20
src/store/managers/format_update_manager.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from src.store.managers.manager import Manager
|
||||
from src.game import Game
|
||||
|
||||
|
||||
class FormatUpdateManager(Manager):
|
||||
"""Class in charge of migrating a game from an older format"""
|
||||
|
||||
def v1_5_to_v2_0(self, game: Game) -> None:
|
||||
"""Convert a game from v1.5 format to v2.0 format"""
|
||||
if game.blacklisted is None:
|
||||
game.blacklisted = False
|
||||
if game.removed is None:
|
||||
game.removed = False
|
||||
game.version = 2.0
|
||||
|
||||
def run(self, game: Game) -> None:
|
||||
if game.version is None:
|
||||
self.v1_5_to_v2_0(game)
|
||||
# TODO make game.save (disk) not trigger game.update (UI)
|
||||
game.save()
|
||||
@@ -103,7 +103,7 @@ class Store:
|
||||
"""
|
||||
|
||||
# Ignore games from a newer spec version
|
||||
if (version := game.get("version")) and version > shared.spec_version:
|
||||
if game.version > shared.spec_version:
|
||||
return None
|
||||
|
||||
# Ignore games that are already there
|
||||
|
||||
Reference in New Issue
Block a user