fixed EpicGames

This commit is contained in:
Christian Moser 2025-03-13 17:56:08 +01:00
parent db8a01d43d
commit f257d4c78e
Failed to extract signature
3 changed files with 69 additions and 21 deletions

View File

@ -1192,11 +1192,11 @@ class EpicWindowsData(EpicPlatformData):
def __init__(self,
savegame_root:str,
savegame_dir:str,
variables:dict[str:str],
file_match:list[GameFileMatcher],
ignore_match:list[GameFileMatcher],
installdir:str|None):
GameData.__init__(self,
variables:dict[str:str]|None=None,
file_match:list[GameFileMatcher]|None=None,
ignore_match:list[GameFileMatcher]|None=None,
installdir:str|None=None):
EpicPlatformData.__init__(self,
savegame_type=SavegameType.EPIC_WINDOWS,
savegame_root=savegame_root,
savegame_dir=savegame_dir,
@ -1295,8 +1295,8 @@ class Game(GObject):
savegame_root=data['savegame_root'],
savegame_dir=data['savegame_dir'],
variables=dict(((v['name'],v['value']) for v in data['variables'])) if ('variables' in data and config['variables']) else None,
file_match=file_match,
ignore_match=ignore_match,
file_match=file_match if 'file_match' in data else None,
ignore_match=ignore_match if 'ignore_match' in data else None,
installdir=data['installdir'] if ('installdir' in data and data['installdir']) else None,
librarydir=data['librarydir'] if ('librarydir' in data and data['librarydir']) else None
)
@ -1340,10 +1340,9 @@ class Game(GObject):
savegame_root=data['savegame_root'],
savegame_dir=data['savegame_dir'],
variables=dict(((v['name'],v['value']) for v in data['variables'])) if ('variables' in data and config['variables']) else None,
file_match=file_match,
ignore_match=ignore_match,
installdir=data['installdir'] if ('installdir' in data and data['installdir']) else None,
librarydir=data['librarydir'] if ('librarydir' in data and data['librarydir']) else None
file_match=file_match if 'file_match' in data else None ,
ignore_match=ignore_match if 'ignore_match' in data else None,
installdir=data['installdir'] if ('installdir' in data and data['installdir']) else None
)
if not "epic" in conf:

View File

@ -22,10 +22,50 @@ from gi.repository.GObject import GObject,Property,Signal,SignalFlags
from ..i18n import gettext as _,gettext_noop as N_
from ..game import GameManager,Game,EpicGameData,EpicWindowsData
from ..epic import Epic,EpicGameInfo,EpicIgnoredApp
from ._gamedialog import GameSearchDialog
from ..utility import PLATFORM_WINDOWS
from ._gamedialog import GameDialog
class EpicLookupGamesDialog(GameSearchDialog):
def __init__(self,parent:Gtk.Window|None=None,info:EpicGameInfo|None=None):
GameSearchDialog.__init__(self,parent,info.name if info else None)
self.__gameinfo = info
@Property
def gameinfo(self)->EpicGameInfo|None:
return self.__gameinfo
@gameinfo.setter
def gameinfo(self,info:EpicGameInfo|None):
if info:
self.search_name = info.name
else:
self.search_name = None
self.__gameinfo = info
def do_prepare_game(self,game:Game):
game = super().do_prepare_game(game)
if self.gameinfo:
if game.epic:
game.epic.catalog_item_id = self.gameinfo.catalog_item_id
else:
game.epic = EpicGameData(self.gameinfo.catalog_item_id)
if PLATFORM_WINDOWS:
if not game.epic.windows:
game.epic.windows = EpicWindowsData("","",installdir=self.gameinfo.installdir)
else:
game.epic.windows.installdir = self.gameinfo.installdir
else:
if not game.epic:
game.epic = EpicGameData()
if PLATFORM_WINDOWS and not game.epic.windows:
game.epic.windows = EpicWindowsData("","")
return game
### EpicNewGamesDialog ########################################################
class EpicNewAppsDialogSorter(Gtk.Sorter):
def do_compare(self,item1:EpicGameInfo,item2:EpicGameInfo):
name1 = item1.name.lower()
@ -152,7 +192,6 @@ class EpicNewAppsDialog(Gtk.Dialog):
child.lookup_button._signal_clicked_connector = child.lookup_button.connect('clicked',
self._on_listview_lookup_button_clicked,
data)
child.lookup_button.set_sensitive(False)
if hasattr(child.online_button,'_signal_clicked_connector'):
child.online_button.disconnect(child.online_button._signal_clicked_connector)
@ -215,10 +254,9 @@ class EpicNewAppsDialog(Gtk.Dialog):
dialog.connect('response',self._on_ignore_dialog_response,info)
dialog.present()
def _on_listview_lookup_button_clicked(self,button:Gtk.Button,info:EpicGameInfo):
pass
dialog = EpicLookupGamesDialog(parent=self,info=info)
dialog.present()
def _on_listview_online_button_clicked(self,button:Gtk.Button,info:EpicGameInfo):
pass
@ -226,4 +264,11 @@ class EpicNewAppsDialog(Gtk.Dialog):
def do_response(self,response):
self.hide()
self.destroy()
def refresh(self):
epic = Epic()
self.__liststore.remove_all()
for gameinfo in epic.find_new_apps():
self.__liststore.append(gameinfo)

View File

@ -759,7 +759,7 @@ class GameDialog(Gtk.Dialog):
page.catalogitemid_entry = Gtk.Entry()
page.catalogitemid_entry.set_hexpand(True)
grid.attach(label,0,0,1,1)
grid.attach(page.appname_entry,1,0,1,1)
grid.attach(page.catalogitemid_entry,1,0,1,1)
page.append(grid)
page.notebook = Gtk.Notebook()
@ -1071,6 +1071,7 @@ class GameDialog(Gtk.Dialog):
def get_epic_data(widget):
conf = get_game_data(widget)
conf.update({'installdir':widget.installdir_entry.get_text()})
return conf
if not self.get_is_valid():
return
@ -1569,6 +1570,7 @@ class GameSearchDialog(Gtk.Dialog):
if parent:
self.set_transient_for(parent)
self.set_default_size(640,500)
self.search_name = search_name
self.__actionbar = Gtk.ActionBar()
@ -1605,7 +1607,9 @@ class GameSearchDialog(Gtk.Dialog):
factory.connect('bind',self._on_listview_bind)
self.__listview = Gtk.ListView(model=selection,factory=factory)
self.__listview.set_vexpand(True)
scrolled.set_child(self.__listview)
scrolled.set_vexpand(True)
self.get_content_area().append(scrolled)
@ -1728,16 +1732,16 @@ class GameSearchDialog(Gtk.Dialog):
parent.refresh()
try:
game = self.do_prepare_game()
game = self.do_prepare_game(game)
except Exception as ex:
dialog = Gtk.MessageDialog(
message=_("Unable to edit game <i>{}</i>!".format(GLib.markup_escape_text(game.name))),
text=_("Unable to edit game <i>{}</i>!".format(GLib.markup_escape_text(game.name))),
use_markup=True,
secondary_message=str(ex),
secondary_text=str(ex),
secondary_use_markup=False,
transient_for=self.get_transient_for(),
parent=self.get_transient_for(),
buttons=Gtk.Buttons.OK
buttons=Gtk.ButtonsType.OK
)
dialog.connect('response',lambda dialog,response: dialog.destroy())
dialog.present()