From 1381d9d00a6854d0ff2155f32ef773cfc0687a19 Mon Sep 17 00:00:00 2001 From: Takiro Date: Sun, 26 Dec 2021 17:17:59 +0100 Subject: [PATCH] Added default file path for Linux, also fixed some weirdness --- main.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/main.py b/main.py index e4cb47e..39eea85 100644 --- a/main.py +++ b/main.py @@ -16,8 +16,14 @@ def __init__(self, *args, **kwargs): self._savegame = None self._connect_signals() self._current_save_file_path = "" - # TODO: Check where the savegame is on Linux - self._search_path = path.abspath(path.expandvars("%appdata%/../LocalLow/Nolla_Games_Noita/save00/")) + platform_ = platform.system() + if platform_ == "Windows": + self._search_path = path.abspath(path.expandvars("%appdata%/../LocalLow/Nolla_Games_Noita/save00/")) + elif platform_ == "Linux": + self._search_path = path.expanduser("~/.local/share/Steam/steamapps/compatdata/881100/pfx/drive_c/users/" + "steamuser/AppData/LocalLow/Nolla_Games_Noita/save00/") + else: + self._search_path = path.expanduser("~") def _connect_signals(self): self.action_quick_load.triggered.connect(self._quick_load_savegame) @@ -147,12 +153,7 @@ def _change_label_on_off(source, state): source.setText("on" if state else "off") def _open_file(self): - search_path = path.expanduser("~") - if platform.system() == "Windows": - if path.exists(self._search_path): - search_path = self._search_path - - file_path = QFileDialog.getOpenFileName(self, "Open savegame", search_path, "XML(*.xml)") + file_path = QFileDialog.getOpenFileName(self, "Open savegame", path.join(self._search_path, 'player.xml'), "XML(*.xml)") if file_path[0]: self._load_savegame(file_path[0]) @@ -161,7 +162,7 @@ def _quick_load_savegame(self): file_path = path.join(self._search_path, 'player.xml') self._load_savegame(file_path) except FileNotFoundError: - pass + self._open_file() def _load_savegame(self, file_path):