Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
urwrstkn8mare committed Jul 27, 2020
1 parent 9f9e274 commit 2e08685
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
15 changes: 9 additions & 6 deletions src/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class LocalClient:
def __init__(self):
self.process = dict.fromkeys(GAME_IDS, None)
self.install_location = dict.fromkeys(list(GAME_REGISTY_PATH.keys()), None)
self._riot_client_services_path = None
self.riot_client_services_path = None
self._vangaurd_uninstall_path = None

def game_running(self, game_id) -> bool:
Expand All @@ -36,7 +36,7 @@ def game_installed(self, game_id):

def launch(self, game_id, *, save_process=True):
p = utils.open_path(
self._riot_client_services_path,
self.riot_client_services_path,
[f"--launch-product={game_id}", "--launch-patchline=live"],
)
if save_process:
Expand All @@ -45,7 +45,7 @@ def launch(self, game_id, *, save_process=True):

def uninstall(self, game_id):
utils.open_path(
self._riot_client_services_path,
self.riot_client_services_path,
[f"--uninstall-product={game_id}", "--uninstall-patchline=live"],
)

Expand All @@ -64,7 +64,10 @@ def get_riot_client_services_path_from_cmd(cmd):
return pth

games = list(GAME_REGISTY_PATH.keys())
self._riot_client_services_path = None
if self.riot_client_services_path is not None and not os.path.isfile(
self.riot_client_services_path
):
self.riot_client_services_path = None
self._vangaurd_uninstall_path = None
for start_path in REGISTRY_START_PATHS:
for software_path in SOFTWARE_PATHS:
Expand All @@ -77,14 +80,14 @@ def get_riot_client_services_path_from_cmd(cmd):
) as key:
if (
game_id != GameID.vanguard
and self._riot_client_services_path is None
and self.riot_client_services_path is None
):
path = get_riot_client_services_path_from_cmd(
winreg.QueryValueEx(key, UNINSTALL_STRING_KEY)[0]
)
if not os.path.isfile(path):
path = None
self._riot_client_services_path = path
self.riot_client_services_path = path
elif game_id == GameID.vanguard:
self._vangaurd_uninstall_path = os.path.abspath(
winreg.QueryValueEx(key, UNINSTALL_STRING_KEY)[0].strip('"')
Expand Down
3 changes: 1 addition & 2 deletions src/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def __init__(self, reader, writer, token):
writer,
token,
)
self.game_time_tracker = None
self.local_client = LocalClient()
self.status = dict.fromkeys(GAME_IDS, LocalGameState.None_)
self._update_task = None
Expand Down Expand Up @@ -101,7 +100,7 @@ async def get_os_compatibility(self, game_id, context):
async def install_game(self, game_id):
log.info("Installing game")
self.local_client.update_installed()
if self.local_client._riot_client_services_path is None:
if self.local_client.riot_client_services_path is None:
utils.open_path(utils.download(DOWNLOAD_URL[game_id]))
else:
self.local_client.launch(game_id, save_process=False)
Expand Down

0 comments on commit 2e08685

Please sign in to comment.