mirror of
https://github.com/aclist/dztui.git
synced 2026-08-30 03:37:00 +02:00
Compare commits
8 Commits
d8239f1c34
...
bbaec35a5f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bbaec35a5f | ||
|
|
c46477f0a7 | ||
|
|
f47446a2e1 | ||
|
|
cdb311cb1f | ||
|
|
11cdcb62b2 | ||
|
|
1913f69e7b | ||
|
|
8c2cea0fdc | ||
|
|
8c29b9b35a |
@ -12,6 +12,7 @@ from typing import Any
|
|||||||
from dzgui.api.steam import find_user_id_32
|
from dzgui.api.steam import find_user_id_32
|
||||||
from dzgui.const.constants import APP_NAME, APP_NAME_LOWER, IMAGES_PATH
|
from dzgui.const.constants import APP_NAME, APP_NAME_LOWER, IMAGES_PATH
|
||||||
from dzgui.util.dirs import copy_dzgui_to_xdg_data
|
from dzgui.util.dirs import copy_dzgui_to_xdg_data
|
||||||
|
from dzgui.util.strings import unknown
|
||||||
|
|
||||||
logger = logging.getLogger(APP_NAME)
|
logger = logging.getLogger(APP_NAME)
|
||||||
|
|
||||||
@ -46,6 +47,13 @@ class Shortcuts:
|
|||||||
wrapped_exe = f'"{exe}"'
|
wrapped_exe = f'"{exe}"'
|
||||||
return appname + wrapped_exe
|
return appname + wrapped_exe
|
||||||
|
|
||||||
|
def find_appname_by_unsigned_id(self, appid: int) -> str:
|
||||||
|
# NOTE: bitmask signed int back to 32-bit CRC
|
||||||
|
for key in self.shortcuts["shortcuts"].keys():
|
||||||
|
if self.shortcuts["shortcuts"][key]["appid"] & 0xFFFFFFFF == appid:
|
||||||
|
return str(self.shortcuts["shortcuts"][key]["appname"])
|
||||||
|
return unknown
|
||||||
|
|
||||||
def get_shortcuts(self) -> Any:
|
def get_shortcuts(self) -> Any:
|
||||||
return self.shortcuts
|
return self.shortcuts
|
||||||
|
|
||||||
|
|||||||
@ -32,23 +32,25 @@ from dzgui.const.endpoints import (
|
|||||||
)
|
)
|
||||||
from dzgui.strings import wizard
|
from dzgui.strings import wizard
|
||||||
from dzgui.util.bash import concat_bash_args
|
from dzgui.util.bash import concat_bash_args
|
||||||
from dzgui.util.strings import unknown
|
|
||||||
|
|
||||||
logger = logging.getLogger(APP_NAME)
|
logger = logging.getLogger(APP_NAME)
|
||||||
|
|
||||||
|
|
||||||
class AppNotInstalledError(Exception):
|
class AppNotInstalledError(Exception):
|
||||||
"""App not present in user's libraryfolders"""
|
"""App not present in user's libraryfolders"""
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class AppMovedError(Exception):
|
class AppMovedError(Exception):
|
||||||
"""VDF points to a nonexistent location on disk"""
|
"""VDF points to a nonexistent location on disk"""
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class VDFLoadError(Exception):
|
class VDFLoadError(Exception):
|
||||||
"""Malformed VDF or JSON conversion"""
|
"""Malformed VDF or JSON conversion"""
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@ -322,9 +324,12 @@ def get_running_app() -> int | None:
|
|||||||
|
|
||||||
|
|
||||||
def get_app_allows_downloads(path: Path, appid: int) -> bool:
|
def get_app_allows_downloads(path: Path, appid: int) -> bool:
|
||||||
root_path = get_app_path(path, appid)
|
try:
|
||||||
acf = root_path.joinpath(f"steamapps/appmanifest_{appid}.acf")
|
root_path = get_app_path(path, appid)
|
||||||
flag = ACF(acf).get_allows_downloads()
|
acf = root_path.joinpath(f"steamapps/appmanifest_{appid}.acf")
|
||||||
|
flag = ACF(acf).get_allows_downloads()
|
||||||
|
except AppNotInstalledError:
|
||||||
|
flag = 0
|
||||||
match flag:
|
match flag:
|
||||||
# NOTE: adheres to global client setting
|
# NOTE: adheres to global client setting
|
||||||
case 0:
|
case 0:
|
||||||
@ -403,13 +408,13 @@ def get_app_path(folders_path: Path, appid: int) -> Path:
|
|||||||
return Path(app_path)
|
return Path(app_path)
|
||||||
|
|
||||||
|
|
||||||
def get_app_name(appid: int) -> str:
|
def get_app_name(appid: int) -> str | None:
|
||||||
payload = {"appids": [appid]}
|
payload = {"appids": [appid]}
|
||||||
res = requests.get(APP_DETAILS, params=payload)
|
res = requests.get(APP_DETAILS, params=payload)
|
||||||
if res.status_code != 200:
|
if res.status_code != 200:
|
||||||
return unknown
|
return None
|
||||||
try:
|
try:
|
||||||
return str(res.json()[str(appid)]["data"]["name"])
|
return str(res.json()[str(appid)]["data"]["name"])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.debug(e)
|
logger.debug(e)
|
||||||
return unknown
|
return None
|
||||||
|
|||||||
@ -9,6 +9,7 @@ from typing import TYPE_CHECKING
|
|||||||
|
|
||||||
import dzgui.api.pefile as PeFile
|
import dzgui.api.pefile as PeFile
|
||||||
import dzgui.api.servers as Servers
|
import dzgui.api.servers as Servers
|
||||||
|
from dzgui.api.shortcuts import Shortcuts
|
||||||
|
|
||||||
from dzgui.api.steam import (
|
from dzgui.api.steam import (
|
||||||
connect,
|
connect,
|
||||||
@ -175,6 +176,12 @@ class ConnectionManager:
|
|||||||
if running_app is not None:
|
if running_app is not None:
|
||||||
allows_dl = get_app_allows_downloads(steam_path, running_app)
|
allows_dl = get_app_allows_downloads(steam_path, running_app)
|
||||||
running_app_name = get_app_name(running_app)
|
running_app_name = get_app_name(running_app)
|
||||||
|
# NOTE: for out-of-range appid, assume NSG.
|
||||||
|
# dzgui.api.steam.get_app_name() will return None
|
||||||
|
if running_app_name is None:
|
||||||
|
s = Shortcuts(steam_path)
|
||||||
|
# NOTE: returns "Unknown" if unparseable
|
||||||
|
running_app_name = s.find_appname_by_unsigned_id(running_app)
|
||||||
allows_downloads = (allows_dl, running_app_name)
|
allows_downloads = (allows_dl, running_app_name)
|
||||||
else:
|
else:
|
||||||
allows_downloads = (True, "")
|
allows_downloads = (True, "")
|
||||||
|
|||||||
@ -273,7 +273,7 @@ class PreConnectionAssistant(Gtk.Box):
|
|||||||
)
|
)
|
||||||
|
|
||||||
allows_dl, running_app = prereqs.allows_downloads
|
allows_dl, running_app = prereqs.allows_downloads
|
||||||
if allows_dl is False:
|
if len(prereqs.mods) > 0 and allows_dl is False:
|
||||||
msg = (
|
msg = (
|
||||||
f"The game '{running_app}' is currently running in Steam, but background downloads are not enabled.\n"
|
f"The game '{running_app}' is currently running in Steam, but background downloads are not enabled.\n"
|
||||||
"Either stop the game first, or update your global Steam settings or the game's local settings.\n"
|
"Either stop the game first, or update your global Steam settings or the game's local settings.\n"
|
||||||
|
|||||||
@ -4,7 +4,7 @@ description = "DayZ server browser and mod manager for Linux"
|
|||||||
authors = [
|
authors = [
|
||||||
{name = "aclist"}
|
{name = "aclist"}
|
||||||
]
|
]
|
||||||
version = "7.0.0b16"
|
version = "7.0.0b17"
|
||||||
license = "GPL-3.0-or-later"
|
license = "GPL-3.0-or-later"
|
||||||
license-files = ["LICENSE"]
|
license-files = ["LICENSE"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|||||||
@ -12,7 +12,7 @@ from dzgui.api.steam import (
|
|||||||
|
|
||||||
from dzgui.config.query import get_config
|
from dzgui.config.query import get_config
|
||||||
from dzgui.config.xdg import get_xdg_paths, parse_filepaths
|
from dzgui.config.xdg import get_xdg_paths, parse_filepaths
|
||||||
from dzgui.const.constants import APPID_DAYZ, LIBRARYFOLDERS_PATH
|
from dzgui.const.constants import APPID_DAYZ
|
||||||
|
|
||||||
from tests.fixtures import fixture_path
|
from tests.fixtures import fixture_path
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user