Skip to content

Commit

Permalink
Some nice dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
Dummerle committed Jan 6, 2021
1 parent 7b481da commit 50bbea2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
12 changes: 8 additions & 4 deletions Rare/Tabs/GamesInstalled/GameSettingsDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,16 @@ def get_settings(self):
return self.action

def uninstall(self):
dia = AcceptDialog(f"Do you really want to delete {self.game.title}")
if dia.get_accept():
msg = QMessageBox()
msg.setIcon(QMessageBox.Warning)
msg.setText(f"Do you really want to delete {self.game.title}")
msg.setWindowTitle("Uninstall Game")
msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel)
ret = msg.exec_()

if ret == QMessageBox.Ok:
self.action = "uninstall"
self.close()



def exit_settings(self):
self.close()
15 changes: 10 additions & 5 deletions Rare/Tabs/GamesInstalled/InstalledList.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,26 +53,29 @@ def remove_game(self, app_name: str):

def import_games_prepare(self):
# Automatically import from windows
imported = 0
if os.name == "nt":
available_drives = ['%s:' % d for d in string.ascii_uppercase if os.path.exists('%s:' % d)]
for drive in available_drives:
path = f"{drive}/Program Files/Epic Games/"
if os.path.exists(path):
self.auto_import_games(path)
imported += self.auto_import_games(path)

else:
possible_wineprefixes = [os.path.expanduser("~/.wine/"), os.path.expanduser("~/Games/epic-games-store/")]
for wine_prefix in possible_wineprefixes:
self.auto_import_games(f"{wine_prefix}drive_c/Program Files/Epic Games/")
imported += self.auto_import_games(f"{wine_prefix}drive_c/Program Files/Epic Games/")

QMessageBox.information(self, "Imported Games", f"Successfully imported {imported} Games")
logger.info("Restarting app to import games")

def auto_import_games(self, game_path):
imported = 0
if not os.path.exists(game_path):
return
return 0
if os.listdir(game_path) == 0:
logger.info(f"No Games found in {game_path}")
return
return 0
for path in os.listdir(game_path):
json_path = game_path + path + "/.egstore"
print(json_path)
Expand All @@ -83,4 +86,6 @@ def auto_import_games(self, game_path):
for file in os.listdir(json_path):
if file.endswith(".mancpn"):
app_name = json.load(open(os.path.join(json_path, file)))["AppName"]
legendaryUtils.import_game(self.core, app_name, game_path + path)
if legendaryUtils.import_game(self.core, app_name, game_path + path):
imported +=1
return imported

0 comments on commit 50bbea2

Please sign in to comment.