mirror of
https://github.com/aclist/dztui.git
synced 2026-10-28 05:32:44 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f839001097 | ||
|
|
ab2b651b6c | ||
|
|
e5934848c7 | ||
|
|
cab10efc96 | ||
|
|
0a4efba905 | ||
|
|
1e4e09e52c | ||
|
|
910c068109 | ||
|
|
1dd773a9bf | ||
|
|
f4d065d766 | ||
|
|
1fe66076c6 | ||
|
|
668ec1d7a0 | ||
|
|
412f0d3193 | ||
|
|
894a9b106d | ||
|
|
1b0a9c9a69 | ||
|
|
c4818d2097 | ||
|
|
69135150c7 | ||
|
|
4d8949427b | ||
|
|
0139f6bfba | ||
|
|
8d77d46eda | ||
|
|
179f92234a | ||
|
|
650a5ecd7b | ||
|
|
8cebb362e9 | ||
|
|
bfd1d3e0f9 | ||
|
|
e8b18d83a5 | ||
|
|
d305f47bb9 | ||
|
|
43f6c17c4b | ||
|
|
38bfef3836 | ||
|
|
c818945a28 | ||
|
|
5cb4f69500 | ||
|
|
cee9052dea | ||
|
|
b3b98aa407 | ||
|
|
b8230cbf43 | ||
|
|
4b16edbbee | ||
|
|
966d935032 | ||
|
|
8b8c6268ab | ||
|
|
513c445b24 | ||
|
|
55f82c2e91 | ||
|
|
ad589ba850 | ||
|
|
85f6fa053d | ||
|
|
f7a42e2cdb | ||
|
|
e1cb682e74 | ||
|
|
a8b7ea5008 | ||
|
|
6a6b4c8027 | ||
|
|
c2ef7449e5 | ||
|
|
96fb484b38 | ||
|
|
1e6ff9c4f7 | ||
|
|
4313075b61 | ||
|
|
88270382f1 | ||
|
|
ad85bb7343 | ||
|
|
77df66979a | ||
|
|
d4825390f7 | ||
|
|
d5a857fe3a | ||
|
|
241df72bf3 | ||
|
|
4f51d962e7 | ||
|
|
98b550cec6 | ||
|
|
20c850a977 | ||
|
|
5a8d85ac92 | ||
|
|
450d54d7fd | ||
|
|
65fb07c8da | ||
|
|
8123893a90 | ||
|
|
3c9b5c9ed3 | ||
|
|
f9be6dfae4 | ||
|
|
586f7e6c66 | ||
|
|
49eb3caf0a | ||
|
|
56da5717fa | ||
|
|
9983e91526 | ||
|
|
820deb2955 | ||
|
|
0137bf4610 | ||
|
|
687b1a915e | ||
|
|
401c8625ad | ||
|
|
8503d7e698 | ||
|
|
b35b6148bc | ||
|
|
45fd180dcb | ||
|
|
486da7749a | ||
|
|
606df3423c | ||
|
|
ab439144ea | ||
|
|
db14c5252c | ||
|
|
7d8b3b402f | ||
|
|
4506a0cfda | ||
|
|
978edc5f5f | ||
|
|
2466887014 | ||
|
|
6050a370f8 | ||
|
|
d4a99f8229 | ||
|
|
46fba4eef1 | ||
|
|
bc1118a29f | ||
|
|
775f582ea6 | ||
|
|
2dadd70be3 | ||
|
|
3473f03350 | ||
|
|
e081d0ad16 | ||
|
|
e6026e84f9 | ||
|
|
b17b8c24ff | ||
|
|
20dab38fff | ||
|
|
1ddc4a5ff1 | ||
|
|
d605447fca | ||
|
|
94fe3f9dff | ||
|
|
a966993999 | ||
|
|
8ee3b36816 | ||
|
|
3af53775cd | ||
|
|
e2d6a462db | ||
|
|
4b9687a84d | ||
|
|
0c0f280d15 | ||
|
|
831bd9145d | ||
|
|
0070fe4061 | ||
|
|
9d1443cf65 | ||
|
|
c4cc9f04c4 | ||
|
|
bcd59162b1 | ||
|
|
2f0bac75ac | ||
|
|
9191f43c8e | ||
|
|
2419fedd19 | ||
|
|
83a7996189 | ||
|
|
9d3aa8d9f5 | ||
|
|
0de0dd4a03 |
No files matched your search
@@ -40,6 +40,7 @@
|
|||||||
- Preboot progress dialog
|
- Preboot progress dialog
|
||||||
- Choose to jump into splash screen instead of server
|
- Choose to jump into splash screen instead of server
|
||||||
- Collapsible connection panel
|
- Collapsible connection panel
|
||||||
|
- Play offline (load mods directly)
|
||||||
|
|
||||||
## Changed
|
## Changed
|
||||||
- Conform to PEP 440 versioning for beta versions
|
- Conform to PEP 440 versioning for beta versions
|
||||||
@@ -56,6 +57,7 @@
|
|||||||
- Disable overlay scrollbars on server tables
|
- Disable overlay scrollbars on server tables
|
||||||
- Reduce size of geolocation DB on disk (~100MB)
|
- Reduce size of geolocation DB on disk (~100MB)
|
||||||
- Enable LAN page Empty/Full filters on first run of app
|
- Enable LAN page Empty/Full filters on first run of app
|
||||||
|
- Propagate subscribed mods to Steam client
|
||||||
|
|
||||||
## Dropped
|
## Dropped
|
||||||
- Debug mode
|
- Debug mode
|
||||||
|
|||||||
@@ -0,0 +1,96 @@
|
|||||||
|
import re
|
||||||
|
from collections.abc import Iterator
|
||||||
|
from typing import Any
|
||||||
|
from warnings import deprecated
|
||||||
|
|
||||||
|
|
||||||
|
@deprecated("Use dzgui.api.steam.unsubscribe()")
|
||||||
|
class WorkshopACF:
|
||||||
|
def __init__(self, file: str) -> None:
|
||||||
|
super().__init__()
|
||||||
|
|
||||||
|
self.dict: dict[str, Any]
|
||||||
|
self.load(file)
|
||||||
|
|
||||||
|
def as_dict(self) -> dict[str, Any]:
|
||||||
|
return self.dict
|
||||||
|
|
||||||
|
def load(self, file: str) -> None:
|
||||||
|
delimiter = r"\t\t"
|
||||||
|
lines = []
|
||||||
|
with open(file, "r", encoding="utf-8") as f:
|
||||||
|
for line in f:
|
||||||
|
line = line.strip()
|
||||||
|
if not line:
|
||||||
|
continue
|
||||||
|
els = re.split(delimiter, line, maxsplit=1)
|
||||||
|
lines.append(els)
|
||||||
|
self.dict = self.parse(iter(lines))
|
||||||
|
|
||||||
|
def parse(self, lines: Iterator[list[str]]) -> dict[str, str]:
|
||||||
|
acf: dict[str, Any] = {}
|
||||||
|
try:
|
||||||
|
while True:
|
||||||
|
line = next(lines)
|
||||||
|
if len(line) == 1:
|
||||||
|
key = line[0]
|
||||||
|
if key == "{":
|
||||||
|
continue
|
||||||
|
return acf
|
||||||
|
elif key == "}":
|
||||||
|
return acf
|
||||||
|
else:
|
||||||
|
key = self.dequote(key)
|
||||||
|
acf[key] = self.parse(lines)
|
||||||
|
elif len(line) == 2:
|
||||||
|
k, v = line
|
||||||
|
k = self.dequote(k)
|
||||||
|
v = self.dequote(v)
|
||||||
|
try:
|
||||||
|
n = list(acf.keys())[-1]
|
||||||
|
acf[n][k] = v
|
||||||
|
except Exception:
|
||||||
|
acf[k] = v
|
||||||
|
except StopIteration:
|
||||||
|
return acf
|
||||||
|
|
||||||
|
def unpack(self, d: dict, lines: list[Any] = []) -> str:
|
||||||
|
t1 = "AppWorkshop"
|
||||||
|
t2 = ("WorkshopItemsInstalled", "WorkshopItemDetails")
|
||||||
|
for k, v in d.items():
|
||||||
|
if type(v) is dict:
|
||||||
|
if k in t1:
|
||||||
|
self.indent = 0
|
||||||
|
elif k in t2:
|
||||||
|
self.indent = 1
|
||||||
|
else:
|
||||||
|
self.indent = 2
|
||||||
|
pref = "\t" * self.indent
|
||||||
|
lines.append(pref + self.enquote(k))
|
||||||
|
lines.append(pref + "{")
|
||||||
|
self.unpack(v, lines)
|
||||||
|
lines.append(pref + "}")
|
||||||
|
else:
|
||||||
|
pref = "\t" * (self.indent + 1)
|
||||||
|
lines.append(pref + self.enquote(k) + "\t\t" + self.enquote(v))
|
||||||
|
s = ""
|
||||||
|
for line in lines:
|
||||||
|
s += line + "\n"
|
||||||
|
return s
|
||||||
|
|
||||||
|
def to_file(self, file: str) -> None:
|
||||||
|
s = self.unpack(self.dict)
|
||||||
|
with open(file, "w") as f:
|
||||||
|
f.write(s)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def enquote(cls, s: str) -> str:
|
||||||
|
return f'"{s}"'
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def dequote(cls, s: str) -> str:
|
||||||
|
return s.rstrip('"').lstrip('"')
|
||||||
|
|
||||||
|
def delete(self, modid: int) -> None:
|
||||||
|
del self.dict["AppWorkshop"]["WorkshopItemsInstalled"][modid]
|
||||||
|
del self.dict["AppWorkshop"]["WorkshopItemDetails"][modid]
|
||||||
+46
-39
@@ -1,6 +1,6 @@
|
|||||||
import hashlib
|
import hashlib
|
||||||
import logging
|
import logging
|
||||||
import shlex
|
import re
|
||||||
|
|
||||||
from concurrent.futures import wait
|
from concurrent.futures import wait
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
@@ -12,6 +12,7 @@ from dzgui.api.servers import get_rules, fqip_to_record
|
|||||||
from dzgui.const.constants import (
|
from dzgui.const.constants import (
|
||||||
APP_NAME,
|
APP_NAME,
|
||||||
APPID_DAYZ,
|
APPID_DAYZ,
|
||||||
|
DAYZ_COMMUNITY_ROOT,
|
||||||
LIBRARYFOLDERS_PATH,
|
LIBRARYFOLDERS_PATH,
|
||||||
WORKSHOP_PATH,
|
WORKSHOP_PATH,
|
||||||
)
|
)
|
||||||
@@ -48,36 +49,32 @@ def get_local_mods(workshop_path: Path) -> list[Path]:
|
|||||||
mods = [file for file in workshop_path.iterdir() if file.is_dir()]
|
mods = [file for file in workshop_path.iterdir() if file.is_dir()]
|
||||||
return mods
|
return mods
|
||||||
|
|
||||||
|
def is_mission(path: Path) -> bool:
|
||||||
|
# TODO: parse integrity of other files
|
||||||
|
parent = path.parent.name
|
||||||
|
if parent != DAYZ_COMMUNITY_ROOT:
|
||||||
|
return False
|
||||||
|
file = path / "init.c"
|
||||||
|
return file.exists()
|
||||||
|
|
||||||
def parse_meta(file: Path) -> ModMeta | None:
|
def tokenize(mod: Path) -> dict[str, Any] | None:
|
||||||
mod = file / "meta.cpp"
|
file = mod.joinpath("meta.cpp")
|
||||||
if mod.exists() is False:
|
delimiter=r"\s*=\s*"
|
||||||
|
modmeta = {}
|
||||||
|
try:
|
||||||
|
with open(file, "r", encoding="utf-8") as f:
|
||||||
|
for line in f:
|
||||||
|
line = line.strip().rstrip(";")
|
||||||
|
if not line:
|
||||||
|
continue
|
||||||
|
els = re.split(delimiter, line, maxsplit=1)
|
||||||
|
if len(els) == 2:
|
||||||
|
key, value = els
|
||||||
|
modmeta[key.strip()] = value.strip('"')
|
||||||
|
return modmeta
|
||||||
|
except Exception as e:
|
||||||
|
logger.critical(e)
|
||||||
return None
|
return None
|
||||||
with open(file / "meta.cpp", "r") as f:
|
|
||||||
st = f.read()
|
|
||||||
lex = shlex.shlex(st)
|
|
||||||
lex.whitespace += "=;"
|
|
||||||
v = []
|
|
||||||
while True:
|
|
||||||
tok = lex.get_token()
|
|
||||||
if not tok:
|
|
||||||
break
|
|
||||||
if tok == "protocol" or tok == "publishedid":
|
|
||||||
ntok = lex.get_token()
|
|
||||||
elif tok == "timestamp":
|
|
||||||
# NOTE: some malformed .NET tick conversions result in numbers < 0
|
|
||||||
ntok = lex.get_token()
|
|
||||||
if ntok == "-":
|
|
||||||
ntok += str(lex.get_token())
|
|
||||||
elif tok == "name":
|
|
||||||
ntok = lex.get_token()
|
|
||||||
if ntok is not None:
|
|
||||||
ntok = ntok.split('"')[1]
|
|
||||||
if ntok is not None:
|
|
||||||
v.append(ntok)
|
|
||||||
meta = ModMeta(*v)
|
|
||||||
return meta
|
|
||||||
|
|
||||||
|
|
||||||
def get_mod_size(path: Path) -> float:
|
def get_mod_size(path: Path) -> float:
|
||||||
s = 0
|
s = 0
|
||||||
@@ -87,33 +84,43 @@ def get_mod_size(path: Path) -> float:
|
|||||||
return size
|
return size
|
||||||
|
|
||||||
|
|
||||||
def get_delimited_mods(steam_path: Path) -> list[Any]:
|
def get_custom_mods(path: Path) -> list[Any]:
|
||||||
workshop_path = get_local_mod_path(steam_path)
|
# TODO: rename this function for clarity ("get local vs. get custom")
|
||||||
mods = get_local_mods(workshop_path)
|
mods = get_local_mods(path)
|
||||||
|
# TODO: error handling
|
||||||
|
return parse_mods(mods, use_custom=True)
|
||||||
|
|
||||||
|
|
||||||
|
def parse_mods(mods: list[Path], use_custom: bool = False) -> list[Any]:
|
||||||
clean = []
|
clean = []
|
||||||
for mod in mods:
|
for mod in mods:
|
||||||
mod_dir = mod.name
|
mod_dir = mod.name
|
||||||
symlink = _hash(mod_dir)
|
symlink = _hash(mod_dir, use_custom)
|
||||||
# FIXME: malformed .cpp files could break this
|
meta = tokenize(mod)
|
||||||
# mention that mods may be downloading
|
|
||||||
meta = parse_meta(mod)
|
|
||||||
if meta is None:
|
if meta is None:
|
||||||
continue
|
continue
|
||||||
size = get_mod_size(mod)
|
size = get_mod_size(mod)
|
||||||
# NOTE: final col is cell renderer highlight toggle
|
# NOTE: final col is cell renderer highlight toggle
|
||||||
clean.append([meta.name, symlink, mod_dir, size, False])
|
clean.append([meta["name"], symlink, mod_dir, size, False])
|
||||||
clean.sort(key=lambda row: str(row[0]).casefold())
|
clean.sort(key=lambda row: str(row[0]).casefold())
|
||||||
return clean
|
return clean
|
||||||
|
|
||||||
|
|
||||||
|
def get_delimited_mods(steam_path: Path) -> list[Any]:
|
||||||
|
workshop_path = get_local_mod_path(steam_path)
|
||||||
|
mods = get_local_mods(workshop_path)
|
||||||
|
return parse_mods(mods)
|
||||||
|
|
||||||
|
|
||||||
def get_missing_mods(local: list, remote: list) -> list:
|
def get_missing_mods(local: list, remote: list) -> list:
|
||||||
return [mod for mod in remote if mod not in local]
|
return [mod for mod in remote if mod not in local]
|
||||||
|
|
||||||
|
|
||||||
def _hash(uid: str) -> str:
|
def _hash(uid: str, use_custom: bool = False) -> str:
|
||||||
md5 = hashlib.md5()
|
md5 = hashlib.md5()
|
||||||
md5.update(uid.encode("ascii"))
|
md5.update(uid.encode("ascii"))
|
||||||
return "@" + md5.hexdigest()[:8]
|
prefix = "@C" if use_custom else "@"
|
||||||
|
return prefix + md5.hexdigest()[:8]
|
||||||
|
|
||||||
|
|
||||||
def remove_stale_signatures(config: Path, versions: Path) -> None:
|
def remove_stale_signatures(config: Path, versions: Path) -> None:
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ from typing import Any, Optional, TYPE_CHECKING, Union
|
|||||||
from dzgui.api.bm import map_id_to_record
|
from dzgui.api.bm import map_id_to_record
|
||||||
from dzgui.const.constants import APP_NAME, REQUEST_TIMEOUT
|
from dzgui.const.constants import APP_NAME, REQUEST_TIMEOUT
|
||||||
from dzgui.const.endpoints import STEAM_SERVERS
|
from dzgui.const.endpoints import STEAM_SERVERS
|
||||||
|
from dzgui.util.format import format_exception
|
||||||
from dzgui.util import strings
|
from dzgui.util import strings
|
||||||
|
|
||||||
import a2s
|
import a2s
|
||||||
@@ -272,8 +273,9 @@ def source_info_to_dict(ip: str, qport: int, info: "SourceInfo") -> dict[str, An
|
|||||||
res["ping"] = ping
|
res["ping"] = ping
|
||||||
return res
|
return res
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# TODO: generalized function
|
msg = format_exception(e)
|
||||||
logger.critical(f"{type(e).__name__}: {e} ({ip}:{qport})")
|
msg += f" ({ip}:{qport})"
|
||||||
|
logger.critical(msg)
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+64
-22
@@ -3,20 +3,25 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import requests
|
import requests
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from typing import Union
|
||||||
|
from warnings import deprecated
|
||||||
|
|
||||||
from shlex import shlex
|
from shlex import shlex
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from dzgui.init.prereqs import has_steam_client
|
from dzgui.init.prereqs import has_steam_client
|
||||||
|
from dzgui.api.mods import _hash
|
||||||
from dzgui.const.constants import (
|
from dzgui.const.constants import (
|
||||||
|
APPID_DAYZ,
|
||||||
APP_NAME,
|
APP_NAME,
|
||||||
DEBIAN_STEAM_PATH,
|
DEBIAN_STEAM_PATH,
|
||||||
DEFAULT_STEAM_PATH,
|
DEFAULT_STEAM_PATH,
|
||||||
FLATPAK_STEAM_PATH,
|
FLATPAK_STEAM_PATH,
|
||||||
UBUNTU_STEAM_PATH,
|
UBUNTU_STEAM_PATH,
|
||||||
|
REQUEST_TIMEOUT,
|
||||||
VDF_PATH,
|
VDF_PATH,
|
||||||
)
|
)
|
||||||
from dzgui.const.endpoints import STEAM_PUBLISHED_FILES
|
from dzgui.const.endpoints import SUB_ENDPOINT, STEAM_PUBLISHED_FILES, UNSUB_ENDPOINT
|
||||||
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
|
||||||
|
|
||||||
@@ -53,8 +58,6 @@ def get_steam_paths() -> list[tuple[Path, str]]:
|
|||||||
|
|
||||||
|
|
||||||
def concat_mods(mods: list[str]) -> str:
|
def concat_mods(mods: list[str]) -> str:
|
||||||
from dzgui.util.symlink import _hash
|
|
||||||
|
|
||||||
hashes = []
|
hashes = []
|
||||||
for mod in mods:
|
for mod in mods:
|
||||||
md5sum = _hash(mod)
|
md5sum = _hash(mod)
|
||||||
@@ -68,31 +71,21 @@ def get_local_signatures(version_file: Path) -> dict[str, int]:
|
|||||||
for line in lines:
|
for line in lines:
|
||||||
data = line.split(",")
|
data = line.split(",")
|
||||||
_id = data[0]
|
_id = data[0]
|
||||||
_hash = int(data[1])
|
mod_hash = int(data[1])
|
||||||
hashes[_id] = _hash
|
hashes[_id] = mod_hash
|
||||||
return hashes
|
return hashes
|
||||||
|
|
||||||
|
|
||||||
def enqueue_mod(mod: str, appid: int) -> None:
|
|
||||||
args = [
|
|
||||||
"steam",
|
|
||||||
f"steam://url/CommunityFilePage/{mod}+workshop_download_item",
|
|
||||||
str(appid),
|
|
||||||
mod,
|
|
||||||
]
|
|
||||||
subprocess.Popen(["/usr/bin/env", "bash", *args])
|
|
||||||
|
|
||||||
|
|
||||||
def get_needs_update(
|
def get_needs_update(
|
||||||
version_file: Path, remote_hashes: list[tuple[str, str, int, int]]
|
version_file: Path, remote_hashes: list[tuple[str, str, int, int]]
|
||||||
) -> list[tuple[str, str, int, int]]:
|
) -> list[tuple[str, str, int, int]]:
|
||||||
local_hashes = get_local_signatures(version_file)
|
local_stamps = get_local_signatures(version_file)
|
||||||
needs_update: list[tuple[str, str, int, int]] = []
|
needs_update: list[tuple[str, str, int, int]] = []
|
||||||
for title, _id, _hash, size in remote_hashes:
|
for title, _id, stamp, size in remote_hashes:
|
||||||
if _id not in local_hashes:
|
if _id not in local_stamps:
|
||||||
needs_update.append((title, _id, _hash, size))
|
needs_update.append((title, _id, stamp, size))
|
||||||
elif _hash != local_hashes[_id]:
|
elif stamp != local_stamps[_id]:
|
||||||
needs_update.append((title, _id, _hash, size))
|
needs_update.append((title, _id, stamp, size))
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
return needs_update
|
return needs_update
|
||||||
@@ -146,7 +139,7 @@ def connect(client: str, addr: str, appid: int, name: str, mods: list[str]) -> i
|
|||||||
return proc.returncode
|
return proc.returncode
|
||||||
|
|
||||||
|
|
||||||
def load_to_menu(client: str, addr: str, appid: int, name: str, mods: list[str]) -> int:
|
def load_to_menu(client: str, appid: int, name: str, mods: list[str]) -> int:
|
||||||
"""Loads to the menu screen with the selected mods; used for AFK/pre-joining"""
|
"""Loads to the menu screen with the selected mods; used for AFK/pre-joining"""
|
||||||
concat = concat_mods(mods)
|
concat = concat_mods(mods)
|
||||||
client_args = concat_bash_args(client)
|
client_args = concat_bash_args(client)
|
||||||
@@ -163,6 +156,26 @@ def load_to_menu(client: str, addr: str, appid: int, name: str, mods: list[str])
|
|||||||
return proc.returncode
|
return proc.returncode
|
||||||
|
|
||||||
|
|
||||||
|
def launch_offline(
|
||||||
|
client: str, appid: int, name: str, mods: list[str], mission: str
|
||||||
|
) -> int:
|
||||||
|
"""Launch offline with specific mods/missions"""
|
||||||
|
symlinks = ";".join(mods)
|
||||||
|
client_args = concat_bash_args(client)
|
||||||
|
params = [
|
||||||
|
"-applaunch",
|
||||||
|
str(appid),
|
||||||
|
"-nolauncher",
|
||||||
|
"-nosplash",
|
||||||
|
"-skipintro",
|
||||||
|
f"-name={name}",
|
||||||
|
f"-mod={symlinks}",
|
||||||
|
f"-mission={mission}",
|
||||||
|
]
|
||||||
|
proc = subprocess.run([*client_args, *params])
|
||||||
|
return proc.returncode
|
||||||
|
|
||||||
|
|
||||||
def find_user_id(path: Path) -> str | None:
|
def find_user_id(path: Path) -> str | None:
|
||||||
resolved_path = path / "config" / "loginusers.vdf"
|
resolved_path = path / "config" / "loginusers.vdf"
|
||||||
try:
|
try:
|
||||||
@@ -217,6 +230,29 @@ def vdf2json(path: Path) -> str:
|
|||||||
jbuf += "\n"
|
jbuf += "\n"
|
||||||
|
|
||||||
|
|
||||||
|
def update_workshop(key: str, mod: int, endpoint: str) -> None:
|
||||||
|
payload: dict[str, Union[int, str]] = {
|
||||||
|
"publishedfileid": mod,
|
||||||
|
"appid": APPID_DAYZ,
|
||||||
|
"key": key,
|
||||||
|
"list_type": 1,
|
||||||
|
"notify_client": 1,
|
||||||
|
}
|
||||||
|
try:
|
||||||
|
res = requests.post(endpoint, params=payload, timeout=REQUEST_TIMEOUT)
|
||||||
|
res.raise_for_status()
|
||||||
|
except Exception as e:
|
||||||
|
logger.critical(e)
|
||||||
|
|
||||||
|
|
||||||
|
def subscribe(key: str, mod: int) -> None:
|
||||||
|
update_workshop(key, mod, SUB_ENDPOINT)
|
||||||
|
|
||||||
|
|
||||||
|
def unsubscribe(key: str, mod: int) -> None:
|
||||||
|
update_workshop(key, mod, UNSUB_ENDPOINT)
|
||||||
|
|
||||||
|
|
||||||
def gen_shortcut() -> None:
|
def gen_shortcut() -> None:
|
||||||
# TODO:
|
# TODO:
|
||||||
"""
|
"""
|
||||||
@@ -229,3 +265,9 @@ def gen_shortcut() -> None:
|
|||||||
# or get right-most 32 bits
|
# or get right-most 32 bits
|
||||||
# STEAMID_64 & 0xFFFFFFFF
|
# STEAMID_64 & 0xFFFFFFFF
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@deprecated("Use subscribe()")
|
||||||
|
def enqueue_mod(client: str, mod: str, appid: int) -> None:
|
||||||
|
client_args = concat_bash_args(client)
|
||||||
|
subprocess.Popen([*client_args, "+workshop_download_item", str(appid), mod])
|
||||||
@@ -4,6 +4,7 @@ UDP_PORT = 27016
|
|||||||
VM_FILE = "/proc/sys/vm/max_map_count"
|
VM_FILE = "/proc/sys/vm/max_map_count"
|
||||||
MIN_COUNT = 1048576
|
MIN_COUNT = 1048576
|
||||||
|
|
||||||
|
RATE_LIMIT_THRESHOLD = 3
|
||||||
REQUEST_TIMEOUT = 10
|
REQUEST_TIMEOUT = 10
|
||||||
|
|
||||||
APPNAME_DAYZ = "DayZ"
|
APPNAME_DAYZ = "DayZ"
|
||||||
@@ -32,9 +33,12 @@ HEX_GREEN = "#32CD32"
|
|||||||
HEX_RED = "#FF0000"
|
HEX_RED = "#FF0000"
|
||||||
HEX_ORANGE = "#FFAC1C"
|
HEX_ORANGE = "#FFAC1C"
|
||||||
|
|
||||||
|
# FIXME: normalize icon names
|
||||||
CARET_DOWN = "go-down-symbolic"
|
CARET_DOWN = "go-down-symbolic"
|
||||||
CARET_UP = "go-up-symbolic"
|
CARET_UP = "go-up-symbolic"
|
||||||
CLIPBOARD = "edit-copy-symbolic"
|
CLIPBOARD = "edit-copy-symbolic"
|
||||||
|
FOLDER = "folder-symbolic"
|
||||||
|
EDIT_DELETE = "edit-delete-symbolic"
|
||||||
ERROR = "dialog-error-symbolic"
|
ERROR = "dialog-error-symbolic"
|
||||||
HELP_BUBBLE = "help-about-symbolic"
|
HELP_BUBBLE = "help-about-symbolic"
|
||||||
INPUT_KEYBOARD = "input-keyboard-symbolic"
|
INPUT_KEYBOARD = "input-keyboard-symbolic"
|
||||||
@@ -80,3 +84,5 @@ LOG_FILTERS = ("CRITICAL", "WARNING", "INFO", "DEBUG")
|
|||||||
TMP_PATH = "/tmp"
|
TMP_PATH = "/tmp"
|
||||||
TMP_TARBALL = "/tmp/dzgui.tar.gz"
|
TMP_TARBALL = "/tmp/dzgui.tar.gz"
|
||||||
TMP_EXE = "/tmp/dzgui/dzgui"
|
TMP_EXE = "/tmp/dzgui/dzgui"
|
||||||
|
|
||||||
|
DAYZ_COMMUNITY_ROOT = "Missions"
|
||||||
@@ -1,6 +1,11 @@
|
|||||||
# internal
|
# internal
|
||||||
STEAM_PUBLISHED_FILES = "https://api.steampowered.com/ISteamRemoteStorage/GetPublishedFileDetails/v1/?format=json"
|
STEAM_PUBLISHED_FILES = (
|
||||||
STEAM_SERVERS = "https://api.steampowered.com/IGameServersService/GetServerList/v1/?"
|
"https://api.steampowered.com/ISteamRemoteStorage/GetPublishedFileDetails/v1"
|
||||||
|
)
|
||||||
|
STEAM_SERVERS = "https://api.steampowered.com/IGameServersService/GetServerList/v1"
|
||||||
|
SUB_ENDPOINT = "https://api.steampowered.com/IPublishedFileService/Subscribe/v1"
|
||||||
|
UNSUB_ENDPOINT = "https://api.steampowered.com/IPublishedFileService/Unsubscribe/v1"
|
||||||
|
|
||||||
BM_SERVERS = "https://api.battlemetrics.com/servers?"
|
BM_SERVERS = "https://api.battlemetrics.com/servers?"
|
||||||
GITHUB = "https://github.com/aclist"
|
GITHUB = "https://github.com/aclist"
|
||||||
GITHUB_RELEASES = "https://api.github.com/repos/aclist/dztui/releases/latest"
|
GITHUB_RELEASES = "https://api.github.com/repos/aclist/dztui/releases/latest"
|
||||||
|
|||||||
+7
-5
@@ -103,6 +103,7 @@ class Preferences(EnumWithAttrs):
|
|||||||
|
|
||||||
|
|
||||||
class NotebookPage(EnumWithAttrs):
|
class NotebookPage(EnumWithAttrs):
|
||||||
|
OFFLINE = {"crumbs": strings.crumbs.offline, "statusbar": True}
|
||||||
CHANGELOG = {"crumbs": strings.crumbs.changelog, "statusbar": True}
|
CHANGELOG = {"crumbs": strings.crumbs.changelog, "statusbar": True}
|
||||||
DEVELOPERS = {"crumbs": strings.crumbs.developers, "statusbar": False}
|
DEVELOPERS = {"crumbs": strings.crumbs.developers, "statusbar": False}
|
||||||
HELP = {"crumbs": strings.crumbs._help, "statusbar": True}
|
HELP = {"crumbs": strings.crumbs._help, "statusbar": True}
|
||||||
@@ -167,7 +168,7 @@ class ContextMenu(EnumWithAttrs):
|
|||||||
COPY_LOG_CLIPBOARD = {"label": strings.copy_log}
|
COPY_LOG_CLIPBOARD = {"label": strings.copy_log}
|
||||||
COPY_SERVER_IP = {"label": strings.copy_ip}
|
COPY_SERVER_IP = {"label": strings.copy_ip}
|
||||||
COPY_SERVER_NAME = {"label": strings.copy_name}
|
COPY_SERVER_NAME = {"label": strings.copy_name}
|
||||||
DELETE_MOD = {"label": strings.delete_mod}
|
UNSUB_MOD = {"label": strings.unsub_mod}
|
||||||
OPEN_WORKSHOP = {"label": strings.open_workshop}
|
OPEN_WORKSHOP = {"label": strings.open_workshop}
|
||||||
REFRESH_PLAYERS = {"label": strings.refresh_players}
|
REFRESH_PLAYERS = {"label": strings.refresh_players}
|
||||||
REMOVE_HISTORY = {"label": strings.remove_history}
|
REMOVE_HISTORY = {"label": strings.remove_history}
|
||||||
@@ -183,7 +184,8 @@ class ContextMenuGroup(Enum):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
SERVER_MOD = (ContextMenu.OPEN_WORKSHOP,)
|
SERVER_MOD = (ContextMenu.OPEN_WORKSHOP,)
|
||||||
MOD = (ContextMenu.OPEN_WORKSHOP, ContextMenu.DELETE_MOD)
|
MOD = (ContextMenu.OPEN_WORKSHOP, ContextMenu.UNSUB_MOD)
|
||||||
|
MOD_OFFLINE = (None,)
|
||||||
LOG = (ContextMenu.COPY_LOG_CLIPBOARD,)
|
LOG = (ContextMenu.COPY_LOG_CLIPBOARD,)
|
||||||
SERVER_BROWSER = (
|
SERVER_BROWSER = (
|
||||||
ContextMenu.CONNECT,
|
ContextMenu.CONNECT,
|
||||||
@@ -248,9 +250,9 @@ class ModButton(EnumWithAttrs):
|
|||||||
"label": strings.mod_panel.unhighlight_stale,
|
"label": strings.mod_panel.unhighlight_stale,
|
||||||
"tooltip": strings.mod_panel.unhighlight_stale_tooltip,
|
"tooltip": strings.mod_panel.unhighlight_stale_tooltip,
|
||||||
}
|
}
|
||||||
DELETE_SELECTED = {
|
UNSUB_SELECTED = {
|
||||||
"label": strings.mod_panel.delete_selected,
|
"label": strings.mod_panel.unsub_selected,
|
||||||
"tooltip": strings.mod_panel.delete_selected_tooltip,
|
"tooltip": strings.mod_panel.unsub_selected_tooltip,
|
||||||
}
|
}
|
||||||
SELECT_STALE = {
|
SELECT_STALE = {
|
||||||
"label": strings.mod_panel.select_stale,
|
"label": strings.mod_panel.select_stale,
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ from gi.repository import Gdk, GObject # noqa E402
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from dzgui.const.enum import NotebookPage, ServerTab
|
from dzgui.const.enum import NotebookPage, ServerTab
|
||||||
|
from dzgui.model.model_factory import FastInsertListStore
|
||||||
|
from dzgui.views.pages.offline import FolderHBox
|
||||||
|
|
||||||
|
|
||||||
# TODO: if servers fail to load, may leave dangling widgets waiting for a signal
|
# TODO: if servers fail to load, may leave dangling widgets waiting for a signal
|
||||||
@@ -154,3 +156,19 @@ class Emitter(GObject.GObject):
|
|||||||
@GObject.Signal(flags=GObject.SignalFlags.RUN_LAST, arg_types=())
|
@GObject.Signal(flags=GObject.SignalFlags.RUN_LAST, arg_types=())
|
||||||
def lan_page_initialized(self) -> None:
|
def lan_page_initialized(self) -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@GObject.Signal(flags=GObject.SignalFlags.RUN_LAST, arg_types=(object, str))
|
||||||
|
def custom_mods_loaded(self, store: "FastInsertListStore", folder: str) -> None:
|
||||||
|
pass
|
||||||
|
|
||||||
|
@GObject.Signal(flags=GObject.SignalFlags.RUN_LAST, arg_types=(object,))
|
||||||
|
def custom_mods_unloaded(self, widget: "FolderHBox") -> None:
|
||||||
|
pass
|
||||||
|
|
||||||
|
@GObject.Signal(flags=GObject.SignalFlags.RUN_LAST, arg_types=(str, bool))
|
||||||
|
def custom_mission_loaded(self, folder: str, is_valid: bool) -> None:
|
||||||
|
pass
|
||||||
|
|
||||||
|
@GObject.Signal(flags=GObject.SignalFlags.RUN_LAST, arg_types=())
|
||||||
|
def invalid_custom_mods(self) -> None:
|
||||||
|
pass
|
||||||
+31
-13
@@ -20,7 +20,6 @@ from dzgui.controllers.emitter import Emitter
|
|||||||
from dzgui.managers.config import ConfigManager
|
from dzgui.managers.config import ConfigManager
|
||||||
from dzgui.managers.connection import ConnectionManager
|
from dzgui.managers.connection import ConnectionManager
|
||||||
from dzgui.managers.contextmenu import ContextMenuManager
|
from dzgui.managers.contextmenu import ContextMenuManager
|
||||||
from dzgui.managers.mods import ModManager
|
|
||||||
from dzgui.managers.notes import NoteManager
|
from dzgui.managers.notes import NoteManager
|
||||||
from dzgui.model.servers import ServerModelManager
|
from dzgui.model.servers import ServerModelManager
|
||||||
from dzgui.util.diag import write_diagnostic
|
from dzgui.util.diag import write_diagnostic
|
||||||
@@ -47,12 +46,13 @@ if TYPE_CHECKING:
|
|||||||
from dzgui.views.components.filter_panel import FilterPanel
|
from dzgui.views.components.filter_panel import FilterPanel
|
||||||
from dzgui.views.components.right_panel import RightPanel
|
from dzgui.views.components.right_panel import RightPanel
|
||||||
from dzgui.views.components.statusbar import Statusbar
|
from dzgui.views.components.statusbar import Statusbar
|
||||||
|
from dzgui.views.pages.offline import OfflineLoader
|
||||||
from dzgui.views.pages.options import Options
|
from dzgui.views.pages.options import Options
|
||||||
from dzgui.views.pages.preconnect import PreConnectionAssistant
|
from dzgui.views.pages.preconnect import PreConnectionAssistant
|
||||||
from dzgui.views.pages.servers import ServerNotebook
|
from dzgui.views.pages.servers import ServerNotebook
|
||||||
from dzgui.views.trees.tree_log import LogTreeView
|
from dzgui.views.trees.tree_log import LogTreeView
|
||||||
from dzgui.views.trees.tree_menu import MenuTreeView
|
from dzgui.views.trees.tree_menu import MenuTreeView
|
||||||
from dzgui.views.trees.tree_mods import ModTreeView
|
from dzgui.views.trees.tree_mods import ModTreeView, OfflineModTreeView
|
||||||
from dzgui.views.trees.tree_servers import ServerTreeView
|
from dzgui.views.trees.tree_servers import ServerTreeView
|
||||||
|
|
||||||
|
|
||||||
@@ -72,6 +72,7 @@ class AppNavigation:
|
|||||||
filters: "FilterPanel"
|
filters: "FilterPanel"
|
||||||
preconnect: "PreConnectionAssistant"
|
preconnect: "PreConnectionAssistant"
|
||||||
options: "Options"
|
options: "Options"
|
||||||
|
offline_loader: "OfflineLoader"
|
||||||
|
|
||||||
|
|
||||||
class Controller(GObject.GObject):
|
class Controller(GObject.GObject):
|
||||||
@@ -218,19 +219,29 @@ class Controller(GObject.GObject):
|
|||||||
open_user_workshop(uid, client)
|
open_user_workshop(uid, client)
|
||||||
|
|
||||||
def load_mods(self) -> None:
|
def load_mods(self) -> None:
|
||||||
self.mod_man = ModManager(self)
|
self.mediator.modtreeview.load_mods()
|
||||||
|
|
||||||
def uncolorize_mods(self) -> None:
|
def uncolorize_mods(self) -> None:
|
||||||
self.mod_man.uncolorize_mods()
|
mod_man = self.mediator.modtreeview.get_mod_man()
|
||||||
|
mod_man.uncolorize_mods()
|
||||||
|
|
||||||
def highlight_stale(self) -> None:
|
def highlight_stale(self) -> None:
|
||||||
self.mod_man.highlight_stale()
|
mod_man = self.mediator.modtreeview.get_mod_man()
|
||||||
|
mod_man.highlight_stale()
|
||||||
|
|
||||||
def toggle_mod_selection(self, state: bool) -> None:
|
def toggle_mod_selection(self, state: bool) -> None:
|
||||||
self.mod_man.toggle_mod_selection(state)
|
mod_man = self.mediator.modtreeview.get_mod_man()
|
||||||
|
mod_man.toggle_mod_selection(state)
|
||||||
|
|
||||||
def delete_mods(self) -> None:
|
def unsub_mods(
|
||||||
self.mod_man.delete_mods()
|
self, treeview: Union["ModTreeView", "OfflineModTreeView", None] = None
|
||||||
|
) -> None:
|
||||||
|
if treeview is None:
|
||||||
|
view = self.mediator.modtreeview
|
||||||
|
else:
|
||||||
|
view = treeview
|
||||||
|
mod_man = view.get_mod_man()
|
||||||
|
mod_man.unsub_mods()
|
||||||
|
|
||||||
def get_mod_store(self) -> Gtk.TreeModel | None:
|
def get_mod_store(self) -> Gtk.TreeModel | None:
|
||||||
return self.mediator.modtreeview.get_model()
|
return self.mediator.modtreeview.get_model()
|
||||||
@@ -257,7 +268,8 @@ class Controller(GObject.GObject):
|
|||||||
dialog.run()
|
dialog.run()
|
||||||
|
|
||||||
def select_colorized(self) -> None:
|
def select_colorized(self) -> None:
|
||||||
self.mod_man.select_colorized()
|
mod_man = self.mediator.modtreeview.get_mod_man()
|
||||||
|
mod_man.select_colorized()
|
||||||
|
|
||||||
def get_all_tree_filters(self) -> dict[str, dict[str, bool]]:
|
def get_all_tree_filters(self) -> dict[str, dict[str, bool]]:
|
||||||
servers = self.get_servers()
|
servers = self.get_servers()
|
||||||
@@ -511,11 +523,11 @@ class Controller(GObject.GObject):
|
|||||||
ind = self.config_man.get_start_tab()
|
ind = self.config_man.get_start_tab()
|
||||||
self.get_servers().notebook.set_current_page(ind)
|
self.get_servers().notebook.set_current_page(ind)
|
||||||
|
|
||||||
def update_and_load_to_menu(self, raise_window: bool) -> None:
|
def update_and_load_to_menu(self) -> None:
|
||||||
self.connection_man.update_and_connect(raise_window, menu_only=True)
|
self.connection_man.update_and_connect(menu_only=True)
|
||||||
|
|
||||||
def update_and_connect(self, raise_window: bool) -> None:
|
def update_and_connect(self) -> None:
|
||||||
self.connection_man.update_and_connect(raise_window)
|
self.connection_man.update_and_connect()
|
||||||
|
|
||||||
def update_status(self) -> None:
|
def update_status(self) -> None:
|
||||||
self.mediator.preconnect.mark_finished()
|
self.mediator.preconnect.mark_finished()
|
||||||
@@ -533,3 +545,9 @@ class Controller(GObject.GObject):
|
|||||||
self.clear_cancel_event()
|
self.clear_cancel_event()
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def open_offline(self) -> None:
|
||||||
|
self.open_page(NotebookPage.OFFLINE)
|
||||||
|
mod_man = self.mediator.modtreeview.get_mod_man()
|
||||||
|
store = mod_man.store
|
||||||
|
self.mediator.offline_loader.populate(store)
|
||||||
@@ -40,6 +40,7 @@
|
|||||||
- Preboot progress dialog
|
- Preboot progress dialog
|
||||||
- Choose to jump into splash screen instead of server
|
- Choose to jump into splash screen instead of server
|
||||||
- Collapsible connection panel
|
- Collapsible connection panel
|
||||||
|
- Play offline (load mods directly)
|
||||||
|
|
||||||
## Changed
|
## Changed
|
||||||
- Conform to PEP 440 versioning for beta versions
|
- Conform to PEP 440 versioning for beta versions
|
||||||
@@ -56,6 +57,7 @@
|
|||||||
- Disable overlay scrollbars on server tables
|
- Disable overlay scrollbars on server tables
|
||||||
- Reduce size of geolocation DB on disk (~100MB)
|
- Reduce size of geolocation DB on disk (~100MB)
|
||||||
- Enable LAN page Empty/Full filters on first run of app
|
- Enable LAN page Empty/Full filters on first run of app
|
||||||
|
- Propagate subscribed mods to Steam client
|
||||||
|
|
||||||
## Dropped
|
## Dropped
|
||||||
- Debug mode
|
- Debug mode
|
||||||
|
|||||||
+1
-4
@@ -1,12 +1,10 @@
|
|||||||
import logging
|
import logging
|
||||||
import sys
|
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from dzgui.config.query import lookup
|
from dzgui.config.query import lookup
|
||||||
from dzgui.const.constants import APPID_DAYZ, APP_NAME, LIBRARYFOLDERS_PATH
|
from dzgui.const.constants import APPID_DAYZ, APP_NAME, LIBRARYFOLDERS_PATH
|
||||||
from dzgui.const.enum import Preferences
|
from dzgui.const.enum import Preferences
|
||||||
from dzgui.views.dialogs.early_alert import EarlyAlertDialog
|
|
||||||
|
|
||||||
import dzgui.api.pefile as PeFile
|
import dzgui.api.pefile as PeFile
|
||||||
|
|
||||||
@@ -19,5 +17,4 @@ def is_dayz_installed(config: Path) -> None:
|
|||||||
PeFile.get_app_path(Path(path) / LIBRARYFOLDERS_PATH, APPID_DAYZ)
|
PeFile.get_app_path(Path(path) / LIBRARYFOLDERS_PATH, APPID_DAYZ)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.critical(e)
|
logger.critical(e)
|
||||||
EarlyAlertDialog(str(e))
|
raise e
|
||||||
sys.exit(1)
|
|
||||||
@@ -11,7 +11,6 @@ from dzgui.const.enum import Preferences
|
|||||||
from dzgui.config.query import lookup
|
from dzgui.config.query import lookup
|
||||||
from dzgui.config.userprefs import UserPrefs
|
from dzgui.config.userprefs import UserPrefs
|
||||||
from dzgui.config.xdg import get_xdg_paths, parse_filepaths
|
from dzgui.config.xdg import get_xdg_paths, parse_filepaths
|
||||||
from dzgui.init.dayz import is_dayz_installed
|
|
||||||
from dzgui.init.flock import lock_acquire
|
from dzgui.init.flock import lock_acquire
|
||||||
from dzgui.init.migrate import (
|
from dzgui.init.migrate import (
|
||||||
has_new_config,
|
has_new_config,
|
||||||
@@ -124,18 +123,9 @@ def main() -> None:
|
|||||||
if has_steam_client() is False:
|
if has_steam_client() is False:
|
||||||
EarlyAlertDialog(init.requires_steam)
|
EarlyAlertDialog(init.requires_steam)
|
||||||
|
|
||||||
is_dayz_installed(XDG.config)
|
|
||||||
|
|
||||||
bootwin = BootWindow(XDG, version)
|
bootwin = BootWindow(XDG, version)
|
||||||
local_coords, latest_release = bootwin.get_results()
|
local_coords, latest_release = bootwin.get_results()
|
||||||
|
|
||||||
# rebuild_symlinks(XDG.config)
|
|
||||||
# remove_stale_signatures(XDG.config, XDG.version)
|
|
||||||
|
|
||||||
## TODO: handle IP DB failure and use coords fallback
|
|
||||||
# local_coords = get_local_coords(XDG.ips)
|
|
||||||
# latest_release = check_updates(version)
|
|
||||||
|
|
||||||
use_miles = lookup(XDG.config, Preferences.DIST)
|
use_miles = lookup(XDG.config, Preferences.DIST)
|
||||||
prefs = UserPrefs(
|
prefs = UserPrefs(
|
||||||
is_steam_deck=_is_steam_deck,
|
is_steam_deck=_is_steam_deck,
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ import dzgui.api.servers as Servers
|
|||||||
|
|
||||||
from dzgui.api.steam import (
|
from dzgui.api.steam import (
|
||||||
connect,
|
connect,
|
||||||
enqueue_mod,
|
|
||||||
get_remote_signatures,
|
get_remote_signatures,
|
||||||
get_needs_update,
|
get_needs_update,
|
||||||
load_to_menu,
|
load_to_menu,
|
||||||
|
subscribe,
|
||||||
)
|
)
|
||||||
|
|
||||||
from dzgui.api.mods import (
|
from dzgui.api.mods import (
|
||||||
@@ -30,6 +30,7 @@ from dzgui.const.constants import (
|
|||||||
APPID_DAYZ_EXP,
|
APPID_DAYZ_EXP,
|
||||||
APPNAME_DAYZ,
|
APPNAME_DAYZ,
|
||||||
APPNAME_DAYZ_EXP_HUMAN,
|
APPNAME_DAYZ_EXP_HUMAN,
|
||||||
|
RATE_LIMIT_THRESHOLD,
|
||||||
)
|
)
|
||||||
from dzgui.const.enum import NotebookPage, Preferences
|
from dzgui.const.enum import NotebookPage, Preferences
|
||||||
from dzgui.init.proc import is_dayz_running, is_steam_running
|
from dzgui.init.proc import is_dayz_running, is_steam_running
|
||||||
@@ -88,6 +89,7 @@ class ConnectionManager:
|
|||||||
self.record: Record
|
self.record: Record
|
||||||
self.workshop: Path
|
self.workshop: Path
|
||||||
|
|
||||||
|
self.client: str
|
||||||
self.remote_mod_ids: list[str] = []
|
self.remote_mod_ids: list[str] = []
|
||||||
self.missing_mods: list[tuple[str, str, int, int]] = []
|
self.missing_mods: list[tuple[str, str, int, int]] = []
|
||||||
|
|
||||||
@@ -171,6 +173,7 @@ class ConnectionManager:
|
|||||||
client = self.controller.query_config(Preferences.CLIENT)
|
client = self.controller.query_config(Preferences.CLIENT)
|
||||||
running = is_steam_running(client)
|
running = is_steam_running(client)
|
||||||
steam_proc = SteamProcess(client_name, running)
|
steam_proc = SteamProcess(client_name, running)
|
||||||
|
self.client = client
|
||||||
|
|
||||||
game_mode = prefs.is_game_mode
|
game_mode = prefs.is_game_mode
|
||||||
|
|
||||||
@@ -238,8 +241,7 @@ class ConnectionManager:
|
|||||||
def query_modlist_and_present(self, record: Servers.Record) -> None:
|
def query_modlist_and_present(self, record: Servers.Record) -> None:
|
||||||
try:
|
try:
|
||||||
mods = self._query_modlist(record)
|
mods = self._query_modlist(record)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
print(f"{type(e).__name__}: {e}")
|
|
||||||
self.thread_man.set_cleanup_func(
|
self.thread_man.set_cleanup_func(
|
||||||
StoredFunc(self._server_timeout), destroy_first=True
|
StoredFunc(self._server_timeout), destroy_first=True
|
||||||
)
|
)
|
||||||
@@ -264,11 +266,10 @@ class ConnectionManager:
|
|||||||
def _connect_steam(self, menu_only: bool) -> None:
|
def _connect_steam(self, menu_only: bool) -> None:
|
||||||
addr = f"{self.record.ip}:{self.record.gameport}"
|
addr = f"{self.record.ip}:{self.record.gameport}"
|
||||||
playername = self.controller.query_config(Preferences.NAME)
|
playername = self.controller.query_config(Preferences.NAME)
|
||||||
client = self.controller.query_config(Preferences.CLIENT)
|
|
||||||
if menu_only:
|
if menu_only:
|
||||||
rc = load_to_menu(client, addr, self.appid, playername, self.remote_mod_ids)
|
rc = load_to_menu(self.client, self.appid, playername, self.remote_mod_ids)
|
||||||
else:
|
else:
|
||||||
rc = connect(client, addr, self.appid, playername, self.remote_mod_ids)
|
rc = connect(self.client, addr, self.appid, playername, self.remote_mod_ids)
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
# TODO: log/pop the error
|
# TODO: log/pop the error
|
||||||
func = StoredFunc(self.controller.update_status)
|
func = StoredFunc(self.controller.update_status)
|
||||||
@@ -278,6 +279,7 @@ class ConnectionManager:
|
|||||||
self.thread_man.show_cancel(False)
|
self.thread_man.show_cancel(False)
|
||||||
self.thread_man.update_dialog(waiting_for_launch)
|
self.thread_man.update_dialog(waiting_for_launch)
|
||||||
while True:
|
while True:
|
||||||
|
# FIXME: cancel should not be visible here per setting above
|
||||||
if self.controller.is_cancel_pending():
|
if self.controller.is_cancel_pending():
|
||||||
# TODO: some facility to also close spawned steam process
|
# TODO: some facility to also close spawned steam process
|
||||||
return
|
return
|
||||||
@@ -292,19 +294,16 @@ class ConnectionManager:
|
|||||||
self.controller.add_to_history(self.history, self.record)
|
self.controller.add_to_history(self.history, self.record)
|
||||||
self.controller.open_page(NotebookPage.SERVERS)
|
self.controller.open_page(NotebookPage.SERVERS)
|
||||||
|
|
||||||
def _update_mods(self, raise_window: bool, menu_only: bool = False) -> None:
|
def _update_mods(self, menu_only: bool = False) -> None:
|
||||||
# NOTE: fast enqueue all mods in auto mode
|
|
||||||
prefs = self.controller.get_prefs()
|
prefs = self.controller.get_prefs()
|
||||||
|
config_man = self.controller.get_config_man()
|
||||||
|
key = config_man.lookup(Preferences.STEAM)
|
||||||
|
|
||||||
for title, mod, stamp, size in self.missing_mods:
|
for title, mod, stamp, size in self.missing_mods:
|
||||||
if self.controller.is_cancel_pending():
|
if self.controller.is_cancel_pending():
|
||||||
return
|
return
|
||||||
enqueue_mod(mod, self.appid)
|
subscribe(key, int(mod))
|
||||||
time.sleep(3)
|
time.sleep(RATE_LIMIT_THRESHOLD)
|
||||||
|
|
||||||
if raise_window is True:
|
|
||||||
logger.info("Bringing window to foreground")
|
|
||||||
GLib.idle_add(self.controller.present_window)
|
|
||||||
|
|
||||||
for title, mod, stamp, size in self.missing_mods:
|
for title, mod, stamp, size in self.missing_mods:
|
||||||
mod_path = self.workshop / mod
|
mod_path = self.workshop / mod
|
||||||
@@ -328,8 +327,8 @@ class ConnectionManager:
|
|||||||
self._connect_steam(menu_only)
|
self._connect_steam(menu_only)
|
||||||
|
|
||||||
@call_on_thread(waiting_for_mods, show_cancel=True)
|
@call_on_thread(waiting_for_mods, show_cancel=True)
|
||||||
def update_and_connect(self, raise_window: bool, menu_only: bool = False) -> None:
|
def update_and_connect(self, menu_only: bool = False) -> None:
|
||||||
if len(self.missing_mods) > 0:
|
if len(self.missing_mods) > 0:
|
||||||
self._update_mods(raise_window, menu_only)
|
self._update_mods(menu_only)
|
||||||
else:
|
else:
|
||||||
self._connect_steam(menu_only)
|
self._connect_steam(menu_only)
|
||||||
@@ -8,7 +8,7 @@ from dzgui.util.clip import copy_clipboard
|
|||||||
from dzgui.util.open_links import open_workshop_page
|
from dzgui.util.open_links import open_workshop_page
|
||||||
|
|
||||||
from dzgui.views.dialogs.note import NoteDialog
|
from dzgui.views.dialogs.note import NoteDialog
|
||||||
from dzgui.views.trees.tree_mods import ModTreeView
|
from dzgui.views.trees.tree_mods import ModTreeView, OfflineModTreeView
|
||||||
from dzgui.views.trees.tree_log import LogTreeView
|
from dzgui.views.trees.tree_log import LogTreeView
|
||||||
from dzgui.views.trees.tree_servers import ServerTreeView
|
from dzgui.views.trees.tree_servers import ServerTreeView
|
||||||
from dzgui.views.trees.tree_server_mods import ServerModTreeView
|
from dzgui.views.trees.tree_server_mods import ServerModTreeView
|
||||||
@@ -27,7 +27,13 @@ if TYPE_CHECKING:
|
|||||||
class ContextMenuManager:
|
class ContextMenuManager:
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
treeview: LogTreeView | ModTreeView | ServerTreeView | ServerModTreeView,
|
treeview: (
|
||||||
|
LogTreeView
|
||||||
|
| ModTreeView
|
||||||
|
| ServerTreeView
|
||||||
|
| ServerModTreeView
|
||||||
|
| OfflineModTreeView
|
||||||
|
),
|
||||||
controller: "Controller",
|
controller: "Controller",
|
||||||
) -> None:
|
) -> None:
|
||||||
self.controller = controller
|
self.controller = controller
|
||||||
@@ -72,10 +78,10 @@ class ContextMenuManager:
|
|||||||
case ContextMenu.SHOW_MODS:
|
case ContextMenu.SHOW_MODS:
|
||||||
self.controller.get_modlist(record)
|
self.controller.get_modlist(record)
|
||||||
|
|
||||||
if isinstance(self.treeview, ModTreeView):
|
if isinstance(self.treeview, (ModTreeView, OfflineModTreeView)):
|
||||||
match action:
|
match action:
|
||||||
case ContextMenu.DELETE_MOD:
|
case ContextMenu.UNSUB_MOD:
|
||||||
self.controller.delete_mods()
|
self.controller.unsub_mods(self.treeview)
|
||||||
case ContextMenu.OPEN_WORKSHOP:
|
case ContextMenu.OPEN_WORKSHOP:
|
||||||
self.open_mod_page()
|
self.open_mod_page()
|
||||||
|
|
||||||
|
|||||||
@@ -89,8 +89,9 @@ class FilterManager:
|
|||||||
continue
|
continue
|
||||||
self.append_map([m])
|
self.append_map([m])
|
||||||
|
|
||||||
|
# TODO: currently unused
|
||||||
def get_unique_maps(self) -> list[str]:
|
def get_unique_maps(self) -> list[str]:
|
||||||
return [row[0] for row in self.map_store if row != "All maps"]
|
return [row[0] for row in self.map_store if row[0] != "All maps"]
|
||||||
|
|
||||||
def get_all_filters(self) -> tuple:
|
def get_all_filters(self) -> tuple:
|
||||||
map_name = self.get_active_map_name()
|
map_name = self.get_active_map_name()
|
||||||
|
|||||||
+43
-26
@@ -1,17 +1,22 @@
|
|||||||
import logging
|
import logging
|
||||||
import shutil
|
import time
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
from dzgui.api.steam import unsubscribe
|
||||||
from dzgui.api.mods import (
|
from dzgui.api.mods import (
|
||||||
get_delimited_mods,
|
get_delimited_mods,
|
||||||
get_local_mod_path,
|
|
||||||
find_stale_mods,
|
find_stale_mods,
|
||||||
_hash,
|
_hash,
|
||||||
remove_stale_signatures,
|
remove_stale_signatures,
|
||||||
)
|
)
|
||||||
from dzgui.const.constants import APP_NAME, APPID_DAYZ, APPID_DAYZ_EXP
|
from dzgui.const.constants import (
|
||||||
|
APP_NAME,
|
||||||
|
APPID_DAYZ,
|
||||||
|
APPID_DAYZ_EXP,
|
||||||
|
RATE_LIMIT_THRESHOLD,
|
||||||
|
)
|
||||||
from dzgui.const.enum import Preferences
|
from dzgui.const.enum import Preferences
|
||||||
from dzgui.managers.threading import call_on_thread, StoredFunc, ThreadingManager
|
from dzgui.managers.threading import call_on_thread, StoredFunc, ThreadingManager
|
||||||
from dzgui.model.model_factory import FastInsertListStore, ModelFactory
|
from dzgui.model.model_factory import FastInsertListStore, ModelFactory
|
||||||
@@ -40,20 +45,20 @@ class ModManager:
|
|||||||
this manager is instantiated each time the Mods page is opened
|
this manager is instantiated each time the Mods page is opened
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, controller: "Controller") -> None:
|
def __init__(self, tree: Gtk.TreeView, controller: "Controller") -> None:
|
||||||
|
self.treeview = tree
|
||||||
self.controller = controller
|
self.controller = controller
|
||||||
|
|
||||||
self.emitter = controller.get_emitter()
|
self.emitter = controller.get_emitter()
|
||||||
self.prefs = controller.get_prefs()
|
self.prefs = controller.get_prefs()
|
||||||
self.path = controller.query_config(Preferences.DEFAULT)
|
self.path = controller.query_config(Preferences.DEFAULT)
|
||||||
self.treeview = self.controller.get_modtreeview()
|
|
||||||
|
|
||||||
self.store: FastInsertListStore
|
self.store: FastInsertListStore | None = None
|
||||||
|
|
||||||
self.thread_man = ThreadingManager(controller)
|
self.thread_man = ThreadingManager(controller)
|
||||||
self._get_mods()
|
|
||||||
|
|
||||||
@call_on_thread(dialogs.fetching_mods)
|
@call_on_thread(dialogs.fetching_mods)
|
||||||
def _get_mods(self) -> None:
|
def load_mods(self) -> None:
|
||||||
mods = get_delimited_mods(self.path)
|
mods = get_delimited_mods(self.path)
|
||||||
if len(mods) < 1:
|
if len(mods) < 1:
|
||||||
msg = self.format_mod_statusbar()
|
msg = self.format_mod_statusbar()
|
||||||
@@ -61,18 +66,23 @@ class ModManager:
|
|||||||
self.thread_man.set_cleanup_func(func)
|
self.thread_man.set_cleanup_func(func)
|
||||||
return
|
return
|
||||||
|
|
||||||
func = StoredFunc(self._on_mods_loaded, mods)
|
|
||||||
self.thread_man.set_cleanup_func(func)
|
|
||||||
|
|
||||||
def _on_mods_loaded(self, mods: list[list[Any]]) -> None:
|
|
||||||
self.store = ModelFactory().make_mod_store()
|
self.store = ModelFactory().make_mod_store()
|
||||||
self.store.extend(mods)
|
self.store.extend(mods)
|
||||||
|
func = StoredFunc(self._on_mods_loaded)
|
||||||
|
self.thread_man.set_cleanup_func(func)
|
||||||
|
|
||||||
|
def set_store(self, store: "FastInsertListStore") -> None:
|
||||||
|
self.store = store
|
||||||
|
|
||||||
|
def _on_mods_loaded(self) -> None:
|
||||||
self.treeview.set_model(self.store)
|
self.treeview.set_model(self.store)
|
||||||
|
if self.store is None:
|
||||||
|
return
|
||||||
msg = self.format_mod_statusbar()
|
msg = self.format_mod_statusbar()
|
||||||
total_mods = len(self.store)
|
total_mods = len(self.store)
|
||||||
self.emitter.emit("mods_updated", msg, total_mods)
|
self.emitter.emit("mods_updated", msg, total_mods)
|
||||||
|
|
||||||
def delete_mods(self) -> None:
|
def unsub_mods(self) -> None:
|
||||||
sel = self.treeview.get_selection()
|
sel = self.treeview.get_selection()
|
||||||
model, pathlist = sel.get_selected_rows()
|
model, pathlist = sel.get_selected_rows()
|
||||||
# NOTE: reverse when multiple selection
|
# NOTE: reverse when multiple selection
|
||||||
@@ -83,7 +93,7 @@ class ModManager:
|
|||||||
continue
|
continue
|
||||||
mod, _iter = res
|
mod, _iter = res
|
||||||
mods.append((mod, _iter))
|
mods.append((mod, _iter))
|
||||||
self.delete_mods_on_system(mods)
|
self.unsub_all_mods(mods)
|
||||||
|
|
||||||
def get_mod_from_tree_path(
|
def get_mod_from_tree_path(
|
||||||
self, tree_path: Gtk.TreePath
|
self, tree_path: Gtk.TreePath
|
||||||
@@ -96,24 +106,28 @@ class ModManager:
|
|||||||
return mod, tree_iter
|
return mod, tree_iter
|
||||||
|
|
||||||
@call_on_thread(dialogs.deleting_mods)
|
@call_on_thread(dialogs.deleting_mods)
|
||||||
def delete_mods_on_system(self, mods: list[tuple[str, Gtk.TreeIter]]) -> None:
|
def unsub_all_mods(self, mods: list[tuple[str, Gtk.TreeIter]]) -> None:
|
||||||
for mod, _iter in mods:
|
for mod, _iter in mods:
|
||||||
self.delete_single_mod(mod)
|
self.unsub_atomic_mod(mod)
|
||||||
|
|
||||||
iters = [_iter for mod, _iter in mods]
|
iters = [_iter for mod, _iter in mods]
|
||||||
func = StoredFunc(self._on_mods_deleted, iters)
|
func = StoredFunc(self._on_mods_unsubbed, iters)
|
||||||
self.thread_man.set_cleanup_func(func)
|
self.thread_man.set_cleanup_func(func)
|
||||||
|
|
||||||
def delete_single_mod(self, mod: str) -> None:
|
def unsub_atomic_mod(self, mod: str) -> None:
|
||||||
|
config_man = self.controller.get_config_man()
|
||||||
|
key = config_man.lookup(Preferences.STEAM)
|
||||||
|
unsubscribe(key, int(mod))
|
||||||
|
|
||||||
steam_path = Path(self.path)
|
steam_path = Path(self.path)
|
||||||
mods_path = get_local_mod_path(steam_path)
|
|
||||||
app_path = PeFile.get_nested_app_path(steam_path, APPID_DAYZ)
|
app_path = PeFile.get_nested_app_path(steam_path, APPID_DAYZ)
|
||||||
|
|
||||||
md5 = _hash(mod)
|
try:
|
||||||
symlink = app_path / md5
|
md5 = _hash(mod)
|
||||||
symlink.unlink()
|
symlink = app_path / md5
|
||||||
shutil.rmtree(mods_path / mod)
|
symlink.unlink()
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(e)
|
||||||
# NOTE: second pass to unlink DAYZ_EXP mods
|
# NOTE: second pass to unlink DAYZ_EXP mods
|
||||||
# TODO: test this with working APPID_DAYZ_EXP installation
|
# TODO: test this with working APPID_DAYZ_EXP installation
|
||||||
try:
|
try:
|
||||||
@@ -122,8 +136,11 @@ class ModManager:
|
|||||||
symlink.unlink()
|
symlink.unlink()
|
||||||
except PeFile.AppNotInstalledError:
|
except PeFile.AppNotInstalledError:
|
||||||
pass
|
pass
|
||||||
|
time.sleep(RATE_LIMIT_THRESHOLD)
|
||||||
|
|
||||||
def _on_mods_deleted(self, iters: list[Gtk.TreeIter]) -> None:
|
def _on_mods_unsubbed(self, iters: list[Gtk.TreeIter]) -> None:
|
||||||
|
if self.store is None:
|
||||||
|
return
|
||||||
for _iter in iters:
|
for _iter in iters:
|
||||||
self.store.remove(_iter)
|
self.store.remove(_iter)
|
||||||
remove_stale_signatures(self.prefs.paths.config, self.prefs.paths.version)
|
remove_stale_signatures(self.prefs.paths.config, self.prefs.paths.version)
|
||||||
|
|||||||
@@ -0,0 +1,134 @@
|
|||||||
|
import logging
|
||||||
|
import time
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import Callable, TYPE_CHECKING, Union
|
||||||
|
|
||||||
|
import dzgui.api.pefile as PeFile
|
||||||
|
from dzgui.api.mods import is_mission, get_custom_mods
|
||||||
|
from dzgui.api.steam import launch_offline
|
||||||
|
from dzgui.const.constants import APP_NAME, APPID_DAYZ_EXP
|
||||||
|
from dzgui.const.enum import Preferences
|
||||||
|
from dzgui.init.proc import is_dayz_running
|
||||||
|
from dzgui.managers.threading import call_on_thread, StoredFunc, ThreadingManager
|
||||||
|
from dzgui.model.model_factory import ModelFactory
|
||||||
|
from dzgui.strings import dialogs
|
||||||
|
from dzgui.util.symlink import create_custom_symlinks, rebuild_symlinks, symlink_mission
|
||||||
|
from dzgui.views.dialogs.filepicker import FolderPicker
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from dzgui.controllers.mc import Controller
|
||||||
|
from dzgui.model.model_factory import FastInsertListStore
|
||||||
|
|
||||||
|
logger = logging.getLogger(APP_NAME)
|
||||||
|
|
||||||
|
|
||||||
|
class OfflineManager:
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
controller: "Controller",
|
||||||
|
) -> None:
|
||||||
|
super().__init__()
|
||||||
|
|
||||||
|
self.controller = controller
|
||||||
|
self.emitter = controller.get_emitter()
|
||||||
|
self.thread_man = ThreadingManager(controller)
|
||||||
|
|
||||||
|
self.appid: int
|
||||||
|
self.local_mods: list[str] | None
|
||||||
|
self.custom_mods: list[str] | None
|
||||||
|
|
||||||
|
# TODO: more robust test
|
||||||
|
def is_custom_folder_valid(self, folder: str) -> bool:
|
||||||
|
return Path(folder).exists()
|
||||||
|
|
||||||
|
# TODO: set properties as members of offline manager on demand and check them here
|
||||||
|
# rather than passing strings again
|
||||||
|
def is_mission_valid(self, folder: str) -> bool:
|
||||||
|
return is_mission(Path(folder))
|
||||||
|
|
||||||
|
def get_mission(self) -> None:
|
||||||
|
folder = self.open_folderpicker(dialogs.mission_dialog)
|
||||||
|
if folder is None:
|
||||||
|
return
|
||||||
|
is_valid = is_mission(folder)
|
||||||
|
self.emitter.emit("custom_mission_loaded", str(folder), is_valid)
|
||||||
|
|
||||||
|
def find_custom_mods(self, callback: Callable) -> None:
|
||||||
|
folder = self.open_folderpicker(dialogs.custom_mod_dialog)
|
||||||
|
window = self.controller.get_window()
|
||||||
|
window.set_sensitive(False)
|
||||||
|
if folder is None:
|
||||||
|
window.set_sensitive(True)
|
||||||
|
return
|
||||||
|
# NOTE: starts spinner in calling UI
|
||||||
|
callback()
|
||||||
|
self.parse_custom_mods(folder)
|
||||||
|
|
||||||
|
@call_on_thread(dialogs.parsing_mods, show_dialog=False)
|
||||||
|
def parse_custom_mods(self, folder: str) -> None:
|
||||||
|
mods = get_custom_mods(Path(folder))
|
||||||
|
store = ModelFactory().make_mod_store()
|
||||||
|
store.extend(mods)
|
||||||
|
func = StoredFunc(self.post_mod_loading, store, folder)
|
||||||
|
self.thread_man.set_cleanup_func(func)
|
||||||
|
|
||||||
|
def post_mod_loading(self, store: "FastInsertListStore", folder: str) -> None:
|
||||||
|
window = self.controller.get_window()
|
||||||
|
window.set_sensitive(True)
|
||||||
|
self.emitter.emit("custom_mods_loaded", store, folder)
|
||||||
|
|
||||||
|
@call_on_thread(dialogs.waiting_for_launch)
|
||||||
|
def launch(
|
||||||
|
self,
|
||||||
|
appid: int,
|
||||||
|
mission: str,
|
||||||
|
local_mods: list[str],
|
||||||
|
custom_folder: str,
|
||||||
|
custom_mods: list[str],
|
||||||
|
) -> None:
|
||||||
|
|
||||||
|
# NOTE: local_mods and custom_mods are lists of symlinks
|
||||||
|
client = self.controller.query_config(Preferences.CLIENT)
|
||||||
|
name = self.controller.query_config(Preferences.NAME)
|
||||||
|
steam_path = self.controller.query_config(Preferences.DEFAULT)
|
||||||
|
|
||||||
|
combined_mods: list[str] = []
|
||||||
|
|
||||||
|
if len(local_mods) > 0:
|
||||||
|
combined_mods.extend(local_mods)
|
||||||
|
config = self.controller.get_prefs().paths.config
|
||||||
|
rebuild_symlinks(config)
|
||||||
|
|
||||||
|
if len(custom_mods) > 0:
|
||||||
|
new_symlinks = create_custom_symlinks(
|
||||||
|
Path(steam_path), Path(custom_folder), custom_mods
|
||||||
|
)
|
||||||
|
combined_mods.extend(new_symlinks)
|
||||||
|
|
||||||
|
relative_link = ""
|
||||||
|
if len(mission) > 0:
|
||||||
|
relative_link = symlink_mission(Path(steam_path), mission)
|
||||||
|
|
||||||
|
launch_offline(client, appid, name, combined_mods, relative_link)
|
||||||
|
while True:
|
||||||
|
if is_dayz_running():
|
||||||
|
break
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
def open_folderpicker(self, title: str) -> Union["Path", None]:
|
||||||
|
picker = FolderPicker(self.controller.get_window(), title)
|
||||||
|
folder = picker.pick_folder()
|
||||||
|
picker.destroy()
|
||||||
|
return folder
|
||||||
|
|
||||||
|
def has_dayz_exp(self) -> bool:
|
||||||
|
try:
|
||||||
|
default_steam_path = self.controller.query_config(Preferences.DEFAULT)
|
||||||
|
steam_path = Path(default_steam_path)
|
||||||
|
dayz_exp = PeFile.get_pretty_version(steam_path, APPID_DAYZ_EXP)
|
||||||
|
if dayz_exp is None:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(e)
|
||||||
|
return False
|
||||||
@@ -53,7 +53,7 @@ class UpdateManager:
|
|||||||
func = StoredFunc(self._on_update_failure, msg)
|
func = StoredFunc(self._on_update_failure, msg)
|
||||||
self.thread_man.set_cleanup_func(func, destroy_first=True)
|
self.thread_man.set_cleanup_func(func, destroy_first=True)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
func = StoredFunc(self._on_update_failure, e)
|
func = StoredFunc(self._on_update_failure, str(e))
|
||||||
self.thread_man.set_cleanup_func(func, destroy_first=True)
|
self.thread_man.set_cleanup_func(func, destroy_first=True)
|
||||||
logger.warning(e)
|
logger.warning(e)
|
||||||
|
|
||||||
|
|||||||
@@ -165,3 +165,6 @@ class ModelFactory:
|
|||||||
|
|
||||||
def make_server_store(self) -> FastInsertListStore:
|
def make_server_store(self) -> FastInsertListStore:
|
||||||
return self.new_model_from_class(ServerCols)
|
return self.new_model_from_class(ServerCols)
|
||||||
|
|
||||||
|
# def convert_model_to_list(self, model: "FastInsertListStore") -> list:
|
||||||
|
# return [[el for el in row] for row in model]
|
||||||
@@ -374,7 +374,7 @@ class ServerModelManager:
|
|||||||
proxy = self._get_proxy_man().get_proxy_model()
|
proxy = self._get_proxy_man().get_proxy_model()
|
||||||
self.tv.set_model(proxy)
|
self.tv.set_model(proxy)
|
||||||
|
|
||||||
if self.controller.get_active_treeview().get_enum == ServerTab.SAVED:
|
if self.controller.get_active_treeview().get_enum() == ServerTab.SAVED:
|
||||||
self.emitter.emit("servers_loaded", self.enum)
|
self.emitter.emit("servers_loaded", self.enum)
|
||||||
|
|
||||||
filter_man = self.tv.get_filter_man()
|
filter_man = self.tv.get_filter_man()
|
||||||
|
|||||||
@@ -7,7 +7,15 @@ update_success = "Updated successfully. Please exit and relaunch."
|
|||||||
|
|
||||||
load_error_lan = "Failed to find any servers on your network.\nCheck the server query port or your firewall settings."
|
load_error_lan = "Failed to find any servers on your network.\nCheck the server query port or your firewall settings."
|
||||||
fetching_mods = "Fetching mod metadata"
|
fetching_mods = "Fetching mod metadata"
|
||||||
deleting_mods = "Deleting mods"
|
deleting_mods = "Unsubscribing mods"
|
||||||
scanning_mods = "Scanning mods"
|
scanning_mods = "Scanning mods"
|
||||||
|
parsing_mods = "Parsing mods"
|
||||||
|
|
||||||
checking_api = "Checking API key"
|
checking_api = "Checking API key"
|
||||||
|
|
||||||
|
running = "Running"
|
||||||
|
failed = "FAILED"
|
||||||
|
ok = "OK"
|
||||||
|
|
||||||
|
mission_dialog = "Set a mission folder location"
|
||||||
|
custom_mod_dialog = "Set location to a custom mods folder"
|
||||||
@@ -3,3 +3,4 @@ api_validation_error = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
api_popover = "API key validation failed."
|
api_popover = "API key validation failed."
|
||||||
|
dayz_not_found = "Could not find a valid DayZ installation."
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
selectable_tree = "Ctrl-click to select multiple; Shift-click to select a range."
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
heading = "Play offline"
|
||||||
|
|
||||||
|
mission_button = "Select mission folder"
|
||||||
|
mission_frame = "Mission"
|
||||||
|
|
||||||
|
version = "DayZ Version"
|
||||||
|
|
||||||
|
custom_frame = "Custom mods"
|
||||||
|
custom_button = "Set custom mod folder"
|
||||||
|
|
||||||
|
local_frame = "Installed mods"
|
||||||
|
|
||||||
|
no_local_mods = "No local mods found"
|
||||||
|
no_mods = "No valid mods found"
|
||||||
|
no_mission = "Not a valid mission"
|
||||||
|
folder_changed = "Folder missing or changed on disk"
|
||||||
|
|
||||||
|
custom_eventbox = "Set the root folder. Mods must be in atomic folders and have a meta.cpp file at a minimum."
|
||||||
|
mission_eventbox = "Select a single mission folder containing an init.c file."
|
||||||
|
|
||||||
|
folder_prefix = "<b>Current folder: </b>"
|
||||||
|
unset_button = "Unset folder"
|
||||||
@@ -3,3 +3,4 @@ signatures = "Updating mod signatures"
|
|||||||
geo = "Checking geolocation records"
|
geo = "Checking geolocation records"
|
||||||
coords = "Checking local coordinates"
|
coords = "Checking local coordinates"
|
||||||
updates = "Checking for updates"
|
updates = "Checking for updates"
|
||||||
|
dayz = "Looking for DayZ"
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from dzgui.util.localize import number
|
from dzgui.util.localize import number
|
||||||
|
from dzgui.strings.generic import selectable_tree
|
||||||
from dzgui.util.strings import no_mods, no_servers, workshop
|
from dzgui.util.strings import no_mods, no_servers, workshop
|
||||||
|
|
||||||
import gi
|
import gi
|
||||||
@@ -46,8 +47,7 @@ def format_mods(size: int, mods: int) -> str:
|
|||||||
return no_mods
|
return no_mods
|
||||||
l_size = number(size)
|
l_size = number(size)
|
||||||
plural = pluralize("mods", mods)
|
plural = pluralize("mods", mods)
|
||||||
# TODO: strings
|
suffix = selectable_tree
|
||||||
suffix = "Ctrl-click to select multiple; Shift-click to select a range."
|
|
||||||
return f"Found {mods:n} {plural} taking up {l_size} MiB. {suffix}"
|
return f"Found {mods:n} {plural} taking up {l_size} MiB. {suffix}"
|
||||||
|
|
||||||
|
|
||||||
@@ -83,3 +83,7 @@ def format_player_count(model: Gtk.TreeModel | None, control: list) -> str:
|
|||||||
|
|
||||||
def embolden(text: str) -> str:
|
def embolden(text: str) -> str:
|
||||||
return f"<b>{text}</b>"
|
return f"<b>{text}</b>"
|
||||||
|
|
||||||
|
|
||||||
|
def format_exception(e: Exception) -> str:
|
||||||
|
return f"{type(e).__name__}: {e}"
|
||||||
+10
-7
@@ -52,7 +52,7 @@ show_mods = "Show server-side mods"
|
|||||||
show_details = "Show server details"
|
show_details = "Show server details"
|
||||||
refresh_players = "Refresh player count"
|
refresh_players = "Refresh player count"
|
||||||
open_workshop = "Open in Steam Workshop"
|
open_workshop = "Open in Steam Workshop"
|
||||||
delete_mod = "Delete mod"
|
unsub_mod = "Unsubscribe mod"
|
||||||
copy_name = "Copy name to clipboard"
|
copy_name = "Copy name to clipboard"
|
||||||
copy_ip = "Copy IP to clipboard"
|
copy_ip = "Copy IP to clipboard"
|
||||||
copy_log = "Copy record(s) to clipboard"
|
copy_log = "Copy record(s) to clipboard"
|
||||||
@@ -64,7 +64,7 @@ connect = "Connect"
|
|||||||
|
|
||||||
# Columns
|
# Columns
|
||||||
server_mod_cols = ["Mod", "ID", "Installed"]
|
server_mod_cols = ["Mod", "ID", "Installed"]
|
||||||
mod_cols = ["Mod", "Symlink", "Dir", "Size (MiB)", "Color"]
|
mod_cols = ["Mod", "Symlink", "ID", "Size (MiB)", "Color"]
|
||||||
log_cols = ["Timestamp", "Flag", "Traceback", "Message"]
|
log_cols = ["Timestamp", "Flag", "Traceback", "Message"]
|
||||||
browser_cols = [
|
browser_cols = [
|
||||||
"Name",
|
"Name",
|
||||||
@@ -181,7 +181,7 @@ filter_lowpop = "Low pop"
|
|||||||
filter_nonascii = "Non-ASCII"
|
filter_nonascii = "Non-ASCII"
|
||||||
filter_duplicate = "Duplicate"
|
filter_duplicate = "Duplicate"
|
||||||
filter_official = "Official"
|
filter_official = "Official"
|
||||||
filter_unofficial = "Unoffic."
|
filter_unofficial = "Unofficial"
|
||||||
filter_modded = "Modded"
|
filter_modded = "Modded"
|
||||||
|
|
||||||
# maps
|
# maps
|
||||||
@@ -215,8 +215,8 @@ class ModPanelStrings:
|
|||||||
unhighlight_stale_tooltip: str
|
unhighlight_stale_tooltip: str
|
||||||
highlight_stale: str
|
highlight_stale: str
|
||||||
highlight_stale_tooltip: str
|
highlight_stale_tooltip: str
|
||||||
delete_selected: str
|
unsub_selected: str
|
||||||
delete_selected_tooltip: str
|
unsub_selected_tooltip: str
|
||||||
unselect_all: str
|
unselect_all: str
|
||||||
unselect_all_tooltip: str
|
unselect_all_tooltip: str
|
||||||
select_all: str
|
select_all: str
|
||||||
@@ -273,6 +273,7 @@ class Crumbs:
|
|||||||
thanks: str
|
thanks: str
|
||||||
developers: str
|
developers: str
|
||||||
default: str
|
default: str
|
||||||
|
offline: str
|
||||||
|
|
||||||
|
|
||||||
@dataclass(slots=True, frozen=True)
|
@dataclass(slots=True, frozen=True)
|
||||||
@@ -336,8 +337,8 @@ mod_panel = ModPanelStrings(
|
|||||||
"Shows locally-installed mods which are not used by any server "
|
"Shows locally-installed mods which are not used by any server "
|
||||||
"in your Saved Servers"
|
"in your Saved Servers"
|
||||||
),
|
),
|
||||||
delete_selected="Delete selected",
|
unsub_selected="Unsubscribe selected",
|
||||||
delete_selected_tooltip="Deletes selected mods from the system",
|
unsub_selected_tooltip="Unsubscribes from selected mods",
|
||||||
unselect_all="Unselect all",
|
unselect_all="Unselect all",
|
||||||
unselect_all_tooltip="Bulk unselects all mods",
|
unselect_all_tooltip="Bulk unselects all mods",
|
||||||
select_all="Select all",
|
select_all="Select all",
|
||||||
@@ -366,6 +367,7 @@ thanks = Thanks(
|
|||||||
"Johnofwrong",
|
"Johnofwrong",
|
||||||
"MatheusLasserr",
|
"MatheusLasserr",
|
||||||
"nolan-perez",
|
"nolan-perez",
|
||||||
|
"OnniSaarni",
|
||||||
"scandalouss",
|
"scandalouss",
|
||||||
"SnackSBR",
|
"SnackSBR",
|
||||||
"StevelDusa",
|
"StevelDusa",
|
||||||
@@ -462,6 +464,7 @@ crumbs = Crumbs(
|
|||||||
thanks="Help > Special thanks",
|
thanks="Help > Special thanks",
|
||||||
developers="Options > Developers",
|
developers="Options > Developers",
|
||||||
default="Servers > ",
|
default="Servers > ",
|
||||||
|
offline="Mods > Play offline",
|
||||||
)
|
)
|
||||||
|
|
||||||
no_mods = "No local mods found."
|
no_mods = "No local mods found."
|
||||||
|
|||||||
+44
-4
@@ -2,7 +2,7 @@ import logging
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from dzgui.api.mods import get_local_mod_path, get_local_mod_ids, _hash
|
from dzgui.api.mods import get_local_mod_path, get_local_mod_ids, _hash
|
||||||
from dzgui.const.constants import APPID_DAYZ, APPID_DAYZ_EXP, APP_NAME
|
from dzgui.const.constants import APPID_DAYZ, APPID_DAYZ_EXP, APP_NAME, DAYZ_COMMUNITY_ROOT
|
||||||
from dzgui.const.enum import Preferences
|
from dzgui.const.enum import Preferences
|
||||||
from dzgui.config.query import lookup
|
from dzgui.config.query import lookup
|
||||||
|
|
||||||
@@ -11,14 +11,23 @@ import dzgui.api.pefile as PeFile
|
|||||||
logger = logging.getLogger(APP_NAME)
|
logger = logging.getLogger(APP_NAME)
|
||||||
|
|
||||||
|
|
||||||
|
def expunge_link(file: Path) -> None:
|
||||||
|
if not file.is_symlink():
|
||||||
|
return
|
||||||
|
# NOTE: unlink stale symlinks
|
||||||
|
if file.exists() is False:
|
||||||
|
file.unlink()
|
||||||
|
if str(file.stem)[:2] == "@C":
|
||||||
|
file.unlink()
|
||||||
|
|
||||||
def rebuild_symlinks(config: Path) -> None:
|
def rebuild_symlinks(config: Path) -> None:
|
||||||
|
# TODO: pass direct path as argument
|
||||||
path = lookup(config, Preferences.DEFAULT)
|
path = lookup(config, Preferences.DEFAULT)
|
||||||
steam_path = Path(path)
|
steam_path = Path(path)
|
||||||
dayz_path = PeFile.get_nested_app_path(steam_path, APPID_DAYZ)
|
dayz_path = PeFile.get_nested_app_path(steam_path, APPID_DAYZ)
|
||||||
# NOTE: unlink stale symlinks
|
|
||||||
for file in dayz_path.iterdir():
|
for file in dayz_path.iterdir():
|
||||||
if file.is_symlink() and file.exists() is False:
|
expunge_link(file)
|
||||||
file.unlink()
|
|
||||||
workshop = get_local_mod_path(steam_path)
|
workshop = get_local_mod_path(steam_path)
|
||||||
# NOTE: create symlinks for missing mods
|
# NOTE: create symlinks for missing mods
|
||||||
for mod_id in get_local_mod_ids(steam_path):
|
for mod_id in get_local_mod_ids(steam_path):
|
||||||
@@ -30,6 +39,37 @@ def rebuild_symlinks(config: Path) -> None:
|
|||||||
clone_symlinks(steam_path)
|
clone_symlinks(steam_path)
|
||||||
|
|
||||||
|
|
||||||
|
def create_custom_symlinks(
|
||||||
|
steam_path: Path, custom_dir: Path, uids: list[str]
|
||||||
|
) -> list[str]:
|
||||||
|
dayz_path = PeFile.get_nested_app_path(steam_path, APPID_DAYZ)
|
||||||
|
links = []
|
||||||
|
for uid in uids:
|
||||||
|
md5sum = _hash(uid, use_custom=True)
|
||||||
|
source = dayz_path.joinpath(md5sum)
|
||||||
|
target = custom_dir.joinpath(uid)
|
||||||
|
links.append(md5sum)
|
||||||
|
if source.exists() is False:
|
||||||
|
source.symlink_to(target)
|
||||||
|
clone_symlinks(steam_path)
|
||||||
|
return links
|
||||||
|
|
||||||
|
|
||||||
|
def symlink_mission(steam_path: Path, target: str) -> str:
|
||||||
|
dayz_path = PeFile.get_nested_app_path(steam_path, APPID_DAYZ)
|
||||||
|
for file in dayz_path.iterdir():
|
||||||
|
expunge_link(file)
|
||||||
|
path = Path(target)
|
||||||
|
stem = path.name
|
||||||
|
parent = path.parent
|
||||||
|
source = dayz_path.joinpath(DAYZ_COMMUNITY_ROOT)
|
||||||
|
try:
|
||||||
|
source.symlink_to(parent)
|
||||||
|
except Exception:
|
||||||
|
return ""
|
||||||
|
return f"{DAYZ_COMMUNITY_ROOT}/{stem}"
|
||||||
|
|
||||||
|
|
||||||
def clone_symlinks(steam_path: Path) -> None:
|
def clone_symlinks(steam_path: Path) -> None:
|
||||||
"""
|
"""
|
||||||
Shares symlinks between builds. Used after any symlink operation
|
Shares symlinks between builds. Used after any symlink operation
|
||||||
|
|||||||
+5
-1
@@ -23,6 +23,8 @@ from dzgui.views.pages.help import Help
|
|||||||
from dzgui.views.pages.keys import Keybindings
|
from dzgui.views.pages.keys import Keybindings
|
||||||
from dzgui.views.pages.log import Log
|
from dzgui.views.pages.log import Log
|
||||||
from dzgui.views.pages.mods import Mods
|
from dzgui.views.pages.mods import Mods
|
||||||
|
|
||||||
|
from dzgui.views.pages.offline import OfflineLoader
|
||||||
from dzgui.views.pages.options import Options
|
from dzgui.views.pages.options import Options
|
||||||
from dzgui.views.pages.preconnect import PreConnectionAssistant
|
from dzgui.views.pages.preconnect import PreConnectionAssistant
|
||||||
from dzgui.views.pages.servers import ServerNotebook
|
from dzgui.views.pages.servers import ServerNotebook
|
||||||
@@ -68,7 +70,6 @@ class OuterWindow(Gtk.Window):
|
|||||||
MainController.set_start_tab()
|
MainController.set_start_tab()
|
||||||
self.grid.hide_widgets_on_init()
|
self.grid.hide_widgets_on_init()
|
||||||
|
|
||||||
# TODO: POC, trigger page change here
|
|
||||||
MainController.loaded = True
|
MainController.loaded = True
|
||||||
MainController.populate_model(MainController.get_active_treeview())
|
MainController.populate_model(MainController.get_active_treeview())
|
||||||
|
|
||||||
@@ -110,8 +111,11 @@ class Notebook(ScrollableMixin, Gtk.Notebook): # type: ignore
|
|||||||
|
|
||||||
self.connection = PreConnectionAssistant(MainController)
|
self.connection = PreConnectionAssistant(MainController)
|
||||||
|
|
||||||
|
self.offline = OfflineLoader(MainController)
|
||||||
|
|
||||||
self.pages = {
|
self.pages = {
|
||||||
self.help: NotebookPage.HELP,
|
self.help: NotebookPage.HELP,
|
||||||
|
self.offline: NotebookPage.OFFLINE,
|
||||||
self.clog: NotebookPage.CHANGELOG,
|
self.clog: NotebookPage.CHANGELOG,
|
||||||
self.keys: NotebookPage.KEYS,
|
self.keys: NotebookPage.KEYS,
|
||||||
self.settings: NotebookPage.OPTIONS,
|
self.settings: NotebookPage.OPTIONS,
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
from typing import Sequence
|
||||||
|
|
||||||
|
import gi
|
||||||
|
|
||||||
|
gi.require_version("Gtk", "3.0")
|
||||||
|
from gi.repository import Gtk # noqa
|
||||||
|
|
||||||
|
|
||||||
|
class GenericBox(Gtk.Box):
|
||||||
|
def __init__(self, orientation: Gtk.Orientation, spacing: int = 0) -> None:
|
||||||
|
super().__init__(orientation=orientation, spacing=spacing)
|
||||||
|
|
||||||
|
def extend(self, els: Sequence[Gtk.Widget]) -> None:
|
||||||
|
for el in els:
|
||||||
|
self.add(el)
|
||||||
|
|
||||||
|
|
||||||
|
class HBox(GenericBox):
|
||||||
|
def __init__(self, spacing: int = 0) -> None:
|
||||||
|
super().__init__(orientation=Gtk.Orientation.HORIZONTAL, spacing=spacing)
|
||||||
|
|
||||||
|
|
||||||
|
class VBox(GenericBox):
|
||||||
|
def __init__(self, spacing: int = 0) -> None:
|
||||||
|
super().__init__(orientation=Gtk.Orientation.VERTICAL, spacing=spacing)
|
||||||
@@ -31,40 +31,61 @@ if TYPE_CHECKING:
|
|||||||
|
|
||||||
|
|
||||||
class Icon(Gtk.Image):
|
class Icon(Gtk.Image):
|
||||||
def __init__(self, name: str, l_margin: int = 0) -> None:
|
def __init__(self, name: str, margin_start: int = 0, margin_end: int = 0) -> None:
|
||||||
super().__init__(
|
super().__init__(
|
||||||
icon_name=name,
|
icon_name=name,
|
||||||
icon_size=Gtk.IconSize.BUTTON,
|
icon_size=Gtk.IconSize.BUTTON,
|
||||||
margin_start=l_margin,
|
margin_start=margin_start,
|
||||||
|
margin_end=margin_end,
|
||||||
ypad=2,
|
ypad=2,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class LargeIcon(Gtk.Image):
|
class LargeIcon(Gtk.Image):
|
||||||
def __init__(self, name: str, l_margin: int = 5) -> None:
|
def __init__(self, name: str, margin_start: int = 5, margin_end: int = 0) -> None:
|
||||||
super().__init__(
|
super().__init__(
|
||||||
icon_name=name, icon_size=Gtk.IconSize.LARGE_TOOLBAR, margin_start=l_margin
|
icon_name=name,
|
||||||
|
icon_size=Gtk.IconSize.LARGE_TOOLBAR,
|
||||||
|
margin_start=margin_start,
|
||||||
|
margin_end=margin_end,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class IconButton(Gtk.Button):
|
class IconButton(Gtk.Button):
|
||||||
def __init__(self, icon: str, margin: int = 0) -> None:
|
def __init__(
|
||||||
|
self,
|
||||||
|
icon: str,
|
||||||
|
position: Gtk.PositionType = Gtk.PositionType.RIGHT,
|
||||||
|
margin_start: int = 0,
|
||||||
|
margin_end: int = 0,
|
||||||
|
) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.icon = Icon(icon, l_margin=margin)
|
self.icon = Icon(icon, margin_start=margin_start, margin_end=margin_end)
|
||||||
self.set_image(self.icon)
|
self.set_image(self.icon)
|
||||||
self.set_image_position(Gtk.PositionType.RIGHT)
|
self.set_image_position(position)
|
||||||
|
# self.set_image_position(Gtk.PositionType.RIGHT)
|
||||||
self.set_focus_on_click(False)
|
self.set_focus_on_click(False)
|
||||||
|
|
||||||
|
|
||||||
class IconTextButton(IconButton):
|
class IconTextButton(IconButton):
|
||||||
def __init__(self, icon: str, label: str) -> None:
|
def __init__(
|
||||||
super().__init__(icon, margin=5)
|
self, icon: str, label: str, position: Gtk.PositionType = Gtk.PositionType.RIGHT
|
||||||
|
) -> None:
|
||||||
|
match position:
|
||||||
|
case Gtk.PositionType.RIGHT:
|
||||||
|
super().__init__(icon, position, margin_start=5)
|
||||||
|
case Gtk.PositionType.LEFT:
|
||||||
|
super().__init__(icon, position, margin_end=5)
|
||||||
|
case _:
|
||||||
|
raise ValueError("Unsupported position type")
|
||||||
self.set_label(label)
|
self.set_label(label)
|
||||||
|
|
||||||
|
|
||||||
class LargeIconTextButton(IconButton):
|
class LargeIconTextButton(IconButton):
|
||||||
def __init__(self, icon: str, label: str) -> None:
|
def __init__(
|
||||||
super().__init__(icon)
|
self, icon: str, label: str, position: Gtk.PositionType = Gtk.PositionType.RIGHT
|
||||||
|
) -> None:
|
||||||
|
super().__init__(icon, position)
|
||||||
self.set_label(label)
|
self.set_label(label)
|
||||||
self.set_image(LargeIcon(icon))
|
self.set_image(LargeIcon(icon))
|
||||||
|
|
||||||
@@ -187,6 +208,8 @@ class SteamWorkshopButton(SteamTextButton):
|
|||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
super().__init__(label=buttons.workshop)
|
super().__init__(label=buttons.workshop)
|
||||||
self.set_tooltip_text(buttons.workshop_tooltip)
|
self.set_tooltip_text(buttons.workshop_tooltip)
|
||||||
|
self.set_margin_top(10)
|
||||||
|
self.set_margin_bottom(10)
|
||||||
|
|
||||||
|
|
||||||
class AddButton(IconTextButton):
|
class AddButton(IconTextButton):
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
from dzgui.strings import preconnect
|
||||||
|
import gi
|
||||||
|
|
||||||
|
gi.require_version("Gtk", "3.0")
|
||||||
|
from gi.repository import Gdk, Gtk # noqa E402
|
||||||
|
|
||||||
|
|
||||||
|
class ConnectBox(Gtk.Box):
|
||||||
|
def __init__(self) -> None:
|
||||||
|
super().__init__(orientation=Gtk.Orientation.HORIZONTAL, spacing=5)
|
||||||
|
|
||||||
|
self.back = Gtk.Button(
|
||||||
|
label=preconnect.back, halign=Gtk.Align.END, hexpand=True
|
||||||
|
)
|
||||||
|
|
||||||
|
# TODO: dynamically update this
|
||||||
|
self.ok = Gtk.Button(label="Launch", halign=Gtk.Align.END)
|
||||||
|
|
||||||
|
for button in self.back, self.ok:
|
||||||
|
self.add(button)
|
||||||
|
|
||||||
|
def get_back_button(self) -> Gtk.Button:
|
||||||
|
return self.back
|
||||||
|
|
||||||
|
def get_ok_button(self) -> Gtk.Button:
|
||||||
|
return self.ok
|
||||||
|
|
||||||
|
|
||||||
|
class PreconnectBox(Gtk.Box):
|
||||||
|
def __init__(self) -> None:
|
||||||
|
super().__init__(
|
||||||
|
orientation=Gtk.Orientation.VERTICAL,
|
||||||
|
valign=Gtk.Align.END,
|
||||||
|
vexpand=True,
|
||||||
|
spacing=5,
|
||||||
|
)
|
||||||
|
|
||||||
|
self.button_hbox = ConnectBox()
|
||||||
|
self.ok = self.button_hbox.get_ok_button()
|
||||||
|
self.ok.set_label(preconnect.update_mods)
|
||||||
|
|
||||||
|
self.connect_last = Gtk.Button(
|
||||||
|
label=preconnect.connect_last,
|
||||||
|
halign=Gtk.Align.END,
|
||||||
|
tooltip_text=preconnect.connect_last_tooltip,
|
||||||
|
)
|
||||||
|
self.button_hbox.add(self.connect_last)
|
||||||
|
|
||||||
|
self.raise_window = Gtk.CheckButton(
|
||||||
|
# TODO: strings
|
||||||
|
label="Foreground DZGUI while downloading",
|
||||||
|
halign=Gtk.Align.END,
|
||||||
|
hexpand=True,
|
||||||
|
valign=Gtk.Align.END,
|
||||||
|
visible=False,
|
||||||
|
has_tooltip=True,
|
||||||
|
sensitive=False,
|
||||||
|
tooltip_text="Foreground the DZGUI window after mod downloads are queued",
|
||||||
|
active=True,
|
||||||
|
)
|
||||||
|
self.add(self.button_hbox)
|
||||||
|
self.add(self.raise_window)
|
||||||
|
|
||||||
|
def get_back_button(self) -> Gtk.Button:
|
||||||
|
return self.button_hbox.get_back_button()
|
||||||
|
|
||||||
|
def get_ok_button(self) -> Gtk.Button:
|
||||||
|
return self.ok
|
||||||
@@ -20,7 +20,8 @@ gi.require_version("Gtk", "3.0")
|
|||||||
from gi.repository import Gtk, Gdk # noqa E402
|
from gi.repository import Gtk, Gdk # noqa E402
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from dzgui.controllers.mc import Controller, Emitter
|
from dzgui.controllers.mc import Controller
|
||||||
|
from dzgui.controllers.emitter import Emitter
|
||||||
|
|
||||||
COLS = 1
|
COLS = 1
|
||||||
ROWS = 1
|
ROWS = 1
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ from dzgui.const.constants import (
|
|||||||
)
|
)
|
||||||
from dzgui.const.enum import FilterMode
|
from dzgui.const.enum import FilterMode
|
||||||
from dzgui.model.servers import ServerModelManager
|
from dzgui.model.servers import ServerModelManager
|
||||||
|
from dzgui.util.format import format_exception
|
||||||
from dzgui.util.strings import all_maps
|
from dzgui.util.strings import all_maps
|
||||||
from dzgui.views.components.maps_combo import MapsCombo
|
from dzgui.views.components.maps_combo import MapsCombo
|
||||||
from dzgui.views.components.labels import BoldLabel
|
from dzgui.views.components.labels import BoldLabel
|
||||||
@@ -333,6 +334,10 @@ class FilterPanel(Gtk.Box):
|
|||||||
self.emitter.emit("map_selection_changed", name)
|
self.emitter.emit("map_selection_changed", name)
|
||||||
|
|
||||||
def set_filters(self, filters: dict[str, bool]) -> None:
|
def set_filters(self, filters: dict[str, bool]) -> None:
|
||||||
for check in self.button_grid.checks:
|
try:
|
||||||
label = check.get_label()
|
for check in self.button_grid.checks:
|
||||||
check.set_active(filters[label])
|
label = check.get_label()
|
||||||
|
check.set_active(filters[label])
|
||||||
|
except Exception as e:
|
||||||
|
msg = format_exception(e)
|
||||||
|
logger.warning(msg)
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
from typing import Self
|
||||||
from dzgui.util import css
|
from dzgui.util import css
|
||||||
|
|
||||||
import gi
|
import gi
|
||||||
@@ -6,16 +7,23 @@ gi.require_version("Gtk", "3.0")
|
|||||||
from gi.repository import Gtk # noqa
|
from gi.repository import Gtk # noqa
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: subclass Gtk.Frame directly
|
||||||
class HeadingFrame(Gtk.Box):
|
class HeadingFrame(Gtk.Box):
|
||||||
def __init__(self, widget: Gtk.Widget, heading: str) -> None:
|
def __init__(self, heading: str = "") -> None:
|
||||||
super().__init__(orientation=Gtk.Orientation.VERTICAL)
|
super().__init__(orientation=Gtk.Orientation.VERTICAL)
|
||||||
|
|
||||||
label = Gtk.Label(label=heading)
|
self.label = Gtk.Label(label=heading)
|
||||||
label.set_halign(Gtk.Align.START)
|
self.label.set_halign(Gtk.Align.START)
|
||||||
css.add_class(label, "settings-subheading")
|
css.add_class(self.label, "settings-subheading")
|
||||||
|
|
||||||
frame = Gtk.Frame(hexpand=True)
|
self.frame = Gtk.Frame(hexpand=True)
|
||||||
frame.add(widget)
|
self.frame.set_label_widget(self.label)
|
||||||
frame.set_label_widget(label)
|
|
||||||
|
|
||||||
self.add(frame)
|
self.add(self.frame)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def new_with_widget_and_label(cls, widget: Gtk.Widget, label: str) -> Self:
|
||||||
|
n = cls()
|
||||||
|
n.frame.add(widget)
|
||||||
|
n.label.set_label(label)
|
||||||
|
return n
|
||||||
@@ -11,7 +11,8 @@ gi.require_version("Gtk", "3.0")
|
|||||||
from gi.repository import Gtk # noqa E402
|
from gi.repository import Gtk # noqa E402
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from dzgui.controllers.mc import Controller, Emitter
|
from dzgui.controllers.mc import Controller
|
||||||
|
from dzgui.controllers.emitter import Emitter
|
||||||
|
|
||||||
|
|
||||||
class EnumeratedModButton(Gtk.Button):
|
class EnumeratedModButton(Gtk.Button):
|
||||||
@@ -48,7 +49,7 @@ class ModSelectionPanel(Gtk.Box):
|
|||||||
buttons = (
|
buttons = (
|
||||||
ModButton.SELECT_ALL,
|
ModButton.SELECT_ALL,
|
||||||
ModButton.UNSELECT_ALL,
|
ModButton.UNSELECT_ALL,
|
||||||
ModButton.DELETE_SELECTED,
|
ModButton.UNSUB_SELECTED,
|
||||||
)
|
)
|
||||||
for button in buttons:
|
for button in buttons:
|
||||||
b = EnumeratedModButton(button)
|
b = EnumeratedModButton(button)
|
||||||
@@ -100,8 +101,8 @@ class ModSelectionPanel(Gtk.Box):
|
|||||||
self.controller.toggle_mod_selection(True)
|
self.controller.toggle_mod_selection(True)
|
||||||
case ModButton.UNSELECT_ALL:
|
case ModButton.UNSELECT_ALL:
|
||||||
self.controller.toggle_mod_selection(False)
|
self.controller.toggle_mod_selection(False)
|
||||||
case ModButton.DELETE_SELECTED:
|
case ModButton.UNSUB_SELECTED:
|
||||||
self.controller.delete_mods()
|
self.controller.unsub_mods()
|
||||||
case ModButton.HIGHLIGHT_STALE:
|
case ModButton.HIGHLIGHT_STALE:
|
||||||
self.controller.highlight_stale()
|
self.controller.highlight_stale()
|
||||||
case ModButton.UNHIGHLIGHT_STALE:
|
case ModButton.UNHIGHLIGHT_STALE:
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
from typing import Self, Union, TYPE_CHECKING
|
from typing import Self, Union, TYPE_CHECKING
|
||||||
from warnings import deprecated
|
|
||||||
|
|
||||||
from dzgui.const.enum import NotebookPage, ServerTab
|
from dzgui.const.enum import NotebookPage, ServerTab
|
||||||
from dzgui.util.strings import esc_to_return, question_to_return
|
from dzgui.util.strings import esc_to_return, question_to_return
|
||||||
@@ -8,7 +7,7 @@ from dzgui.views.components.buttons import LoggerAlertsButton
|
|||||||
import gi
|
import gi
|
||||||
|
|
||||||
gi.require_version("Gtk", "3.0")
|
gi.require_version("Gtk", "3.0")
|
||||||
from gi.repository import Gtk, GObject # noqa E402
|
from gi.repository import Gtk # noqa E402
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from dzgui.const.enum import ServerTab
|
from dzgui.const.enum import ServerTab
|
||||||
@@ -26,6 +25,8 @@ class Statusbar(Gtk.Grid):
|
|||||||
self.controller.register_widget("statusbar", self)
|
self.controller.register_widget("statusbar", self)
|
||||||
self.emitter = controller.get_emitter()
|
self.emitter = controller.get_emitter()
|
||||||
|
|
||||||
|
self.prior_enum: NotebookPage
|
||||||
|
self.prior_status: str
|
||||||
self.playercount = ""
|
self.playercount = ""
|
||||||
self.statusbar = Gtk.Statusbar()
|
self.statusbar = Gtk.Statusbar()
|
||||||
|
|
||||||
@@ -34,14 +35,6 @@ class Statusbar(Gtk.Grid):
|
|||||||
self.attach(self.statusbar, 0, 0, 3, 1)
|
self.attach(self.statusbar, 0, 0, 3, 1)
|
||||||
self.attach_next_to(self.spinner, self.statusbar, Gtk.PositionType.RIGHT, 3, 1)
|
self.attach_next_to(self.spinner, self.statusbar, Gtk.PositionType.RIGHT, 3, 1)
|
||||||
|
|
||||||
# TODO: pack version event box in right panel into hbox with update button
|
|
||||||
# TODO: spawns a modal or just jumps right to install page
|
|
||||||
# from dzgui.views.components.buttons import IconTextButton
|
|
||||||
# b = IconTextButton("dialog-information-symbolic", label="Updates available")
|
|
||||||
# b.set_halign(Gtk.Align.END)
|
|
||||||
# b.set_hexpand(True)
|
|
||||||
# self.attach_next_to(b, self.spinner, Gtk.PositionType.RIGHT, 3, 1)
|
|
||||||
|
|
||||||
self.players = ""
|
self.players = ""
|
||||||
|
|
||||||
controller.get_menu().connect("generic_treesel_changed", self._help_row_changed)
|
controller.get_menu().connect("generic_treesel_changed", self._help_row_changed)
|
||||||
@@ -78,7 +71,9 @@ class Statusbar(Gtk.Grid):
|
|||||||
NotebookPage.CHANGELOG,
|
NotebookPage.CHANGELOG,
|
||||||
NotebookPage.LOG,
|
NotebookPage.LOG,
|
||||||
NotebookPage.CONNECTION,
|
NotebookPage.CONNECTION,
|
||||||
|
NotebookPage.OFFLINE,
|
||||||
):
|
):
|
||||||
|
self.prior_enum = enum
|
||||||
self.set_by_context(enum, esc_to_return)
|
self.set_by_context(enum, esc_to_return)
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -88,16 +83,11 @@ class Statusbar(Gtk.Grid):
|
|||||||
case NotebookPage.KEYS:
|
case NotebookPage.KEYS:
|
||||||
bar = question_to_return
|
bar = question_to_return
|
||||||
case _:
|
case _:
|
||||||
return
|
bar = self.prior_status
|
||||||
|
|
||||||
|
self.prior_enum = enum
|
||||||
self.set_by_context(enum, bar)
|
self.set_by_context(enum, bar)
|
||||||
|
|
||||||
# TODO: unused
|
|
||||||
def _on_notebook_page_returned(
|
|
||||||
self, statusbar: Self, prior_context: NotebookPage
|
|
||||||
) -> None:
|
|
||||||
self.pop(prior_context)
|
|
||||||
|
|
||||||
def _on_server_row_changed(self, statusbar: Self) -> None:
|
def _on_server_row_changed(self, statusbar: Self) -> None:
|
||||||
self.spinner.start()
|
self.spinner.start()
|
||||||
|
|
||||||
@@ -111,8 +101,13 @@ class Statusbar(Gtk.Grid):
|
|||||||
context: Union["ServerTab", NotebookPage],
|
context: Union["ServerTab", NotebookPage],
|
||||||
) -> None:
|
) -> None:
|
||||||
self.spinner.stop()
|
self.spinner.stop()
|
||||||
|
|
||||||
|
if type(context) is NotebookPage:
|
||||||
|
self.prior_enum = context
|
||||||
|
self.prior_status = ""
|
||||||
# FIXME: CalcDist is being called when table is not loaded
|
# FIXME: CalcDist is being called when table is not loaded
|
||||||
if dist is None:
|
if dist is None:
|
||||||
|
self.set_by_context(context, "")
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
pretty = self.append_distance(dist)
|
pretty = self.append_distance(dist)
|
||||||
@@ -132,15 +127,11 @@ class Statusbar(Gtk.Grid):
|
|||||||
cid = self.statusbar.get_context_id(str(context))
|
cid = self.statusbar.get_context_id(str(context))
|
||||||
self.statusbar.pop(cid)
|
self.statusbar.pop(cid)
|
||||||
|
|
||||||
@deprecated("currently unused")
|
|
||||||
# def get_text(self) -> str:
|
|
||||||
# area = self.statusbar.get_message_area()
|
|
||||||
# label = area.get_children()[0]
|
|
||||||
# return str(label.get_text())
|
|
||||||
|
|
||||||
def set_by_context(
|
def set_by_context(
|
||||||
self, context: Union[NotebookPage, "ServerTab"], string: str
|
self, context: Union[NotebookPage, "ServerTab"], string: str
|
||||||
) -> None:
|
) -> None:
|
||||||
|
if context != NotebookPage.KEYS:
|
||||||
|
self.prior_status = string
|
||||||
meta = self.statusbar.get_context_id(str(context))
|
meta = self.statusbar.get_context_id(str(context))
|
||||||
self.statusbar.push(meta, string)
|
self.statusbar.push(meta, string)
|
||||||
self.set_cache(string)
|
self.set_cache(string)
|
||||||
|
|||||||
+19
-10
@@ -1,19 +1,20 @@
|
|||||||
import sys
|
import sys
|
||||||
from typing import Literal, TYPE_CHECKING
|
from typing import Any, Literal, Self, TYPE_CHECKING
|
||||||
|
|
||||||
# import time
|
# import time
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Any, Self
|
|
||||||
|
|
||||||
# TODO: import dialog titles
|
# TODO: import dialog titles
|
||||||
from dzgui.api.mods import remove_stale_signatures as remove_stale
|
from dzgui.api.mods import remove_stale_signatures as remove_stale
|
||||||
from dzgui.config.ipdb import get_ipdb
|
from dzgui.config.ipdb import get_ipdb
|
||||||
from dzgui.const.constants import HEX_GREEN, HEX_RED
|
from dzgui.const.constants import HEX_GREEN, HEX_RED
|
||||||
from dzgui.init.coords import get_local_coords
|
from dzgui.init.coords import get_local_coords
|
||||||
|
from dzgui.init.dayz import is_dayz_installed
|
||||||
from dzgui.init.update import check_updates
|
from dzgui.init.update import check_updates
|
||||||
from dzgui.const.constants import EXPAND, FILL
|
from dzgui.const.constants import EXPAND, FILL
|
||||||
from dzgui.managers.threading import call_on_thread, StoredFunc, ThreadingManager
|
from dzgui.managers.threading import call_on_thread, StoredFunc, ThreadingManager
|
||||||
from dzgui.strings import preboot
|
from dzgui.strings import preboot, dialogs
|
||||||
|
from dzgui.util.format import format_exception
|
||||||
from dzgui.util.strings import dialog_header
|
from dzgui.util.strings import dialog_header
|
||||||
from dzgui.util.symlink import rebuild_symlinks
|
from dzgui.util.symlink import rebuild_symlinks
|
||||||
from dzgui.views.components.buttons import ClipboardButton
|
from dzgui.views.components.buttons import ClipboardButton
|
||||||
@@ -57,6 +58,9 @@ class BootDialog(Gtk.Dialog):
|
|||||||
self.view = Gtk.TreeView(enable_search=False, headers_visible=False)
|
self.view = Gtk.TreeView(enable_search=False, headers_visible=False)
|
||||||
self.view.set_model(self.store)
|
self.view.set_model(self.store)
|
||||||
|
|
||||||
|
# TODO: capture sigint in early dialogs
|
||||||
|
self.connect("key-press-event", self._on_keypress)
|
||||||
|
|
||||||
for i, column_title in enumerate(["Task", "State"]):
|
for i, column_title in enumerate(["Task", "State"]):
|
||||||
renderer = Gtk.CellRendererText()
|
renderer = Gtk.CellRendererText()
|
||||||
column = Gtk.TreeViewColumn(column_title, renderer, text=i)
|
column = Gtk.TreeViewColumn(column_title, renderer, text=i)
|
||||||
@@ -118,6 +122,7 @@ class BootDialog(Gtk.Dialog):
|
|||||||
self.error_box.hide()
|
self.error_box.hide()
|
||||||
|
|
||||||
steps = [
|
steps = [
|
||||||
|
(StoredFunc(is_dayz_installed, self.xdg.config), preboot.dayz, False),
|
||||||
(StoredFunc(rebuild_symlinks, self.xdg.config), preboot.symlinks, False),
|
(StoredFunc(rebuild_symlinks, self.xdg.config), preboot.symlinks, False),
|
||||||
(
|
(
|
||||||
StoredFunc(remove_stale, self.xdg.config, self.xdg.version),
|
StoredFunc(remove_stale, self.xdg.config, self.xdg.version),
|
||||||
@@ -125,6 +130,7 @@ class BootDialog(Gtk.Dialog):
|
|||||||
False,
|
False,
|
||||||
),
|
),
|
||||||
(StoredFunc(get_ipdb, self.xdg.ips), preboot.geo, False),
|
(StoredFunc(get_ipdb, self.xdg.ips), preboot.geo, False),
|
||||||
|
# TODO: handle IP DB failure and use coords fallback
|
||||||
(StoredFunc(get_local_coords, self.xdg.ips), preboot.coords, True),
|
(StoredFunc(get_local_coords, self.xdg.ips), preboot.coords, True),
|
||||||
(StoredFunc(check_updates, self.version), preboot.updates, True),
|
(StoredFunc(check_updates, self.version), preboot.updates, True),
|
||||||
]
|
]
|
||||||
@@ -134,6 +140,10 @@ class BootDialog(Gtk.Dialog):
|
|||||||
|
|
||||||
GLib.timeout_add(100, self.pulse_spinner)
|
GLib.timeout_add(100, self.pulse_spinner)
|
||||||
|
|
||||||
|
def _on_keypress(self, widget: Self, event: Gdk.EventKey) -> None:
|
||||||
|
if event.keyval == Gdk.KEY_Escape:
|
||||||
|
self.exit_button.emit("clicked")
|
||||||
|
|
||||||
def pulse_spinner(self) -> Literal[True]:
|
def pulse_spinner(self) -> Literal[True]:
|
||||||
for row in self.store:
|
for row in self.store:
|
||||||
if row[2]:
|
if row[2]:
|
||||||
@@ -175,16 +185,15 @@ class BootDialog(Gtk.Dialog):
|
|||||||
self.thread_man.set_cleanup_func(callback)
|
self.thread_man.set_cleanup_func(callback)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.failed = True
|
self.failed = True
|
||||||
# TODO: generic exception wrapper
|
self.exception = format_exception(e)
|
||||||
self.exception = f"{type(e).__name__}: {e}"
|
|
||||||
callback = StoredFunc(self.update_status, Success.FAIL)
|
callback = StoredFunc(self.update_status, Success.FAIL)
|
||||||
self.thread_man.set_cleanup_func(callback)
|
self.thread_man.set_cleanup_func(callback)
|
||||||
|
|
||||||
def update_task(self, task: str) -> None:
|
def update_task(self, task: str) -> None:
|
||||||
self.store.append((task, "Running", True, 0))
|
self.store.append((task, dialogs.running, True, 0))
|
||||||
|
|
||||||
def update_status(self, state: Success) -> None:
|
def update_status(self, state: Success) -> None:
|
||||||
d = {Success.OK: "OK", Success.FAIL: "FAILED"}
|
d = {Success.OK: dialogs.ok, Success.FAIL: dialogs.failed}
|
||||||
msg = d[state]
|
msg = d[state]
|
||||||
self.store[len(self.store) - 1][1] = msg
|
self.store[len(self.store) - 1][1] = msg
|
||||||
self.iter_step()
|
self.iter_step()
|
||||||
@@ -197,7 +206,7 @@ class BootDialog(Gtk.Dialog):
|
|||||||
it: Gtk.TreeIter,
|
it: Gtk.TreeIter,
|
||||||
data: Any,
|
data: Any,
|
||||||
) -> None:
|
) -> None:
|
||||||
if model[it][1] == "Running":
|
if model[it][1] == dialogs.running:
|
||||||
cell.set_property("visible", True)
|
cell.set_property("visible", True)
|
||||||
else:
|
else:
|
||||||
cell.set_property("visible", False)
|
cell.set_property("visible", False)
|
||||||
@@ -214,9 +223,9 @@ class BootDialog(Gtk.Dialog):
|
|||||||
state = model[it][1]
|
state = model[it][1]
|
||||||
if column.get_sort_column_id() != 1:
|
if column.get_sort_column_id() != 1:
|
||||||
return
|
return
|
||||||
if state == "OK":
|
if state == dialogs.ok:
|
||||||
cell.set_property(prop, HEX_GREEN)
|
cell.set_property(prop, HEX_GREEN)
|
||||||
elif state == "FAILED":
|
elif state == dialogs.failed:
|
||||||
cell.set_property(prop, HEX_RED)
|
cell.set_property(prop, HEX_RED)
|
||||||
else:
|
else:
|
||||||
cell.set_property(prop, None)
|
cell.set_property(prop, None)
|
||||||
|
|||||||
@@ -33,3 +33,36 @@ class FilePicker(Gtk.FileChooserDialog):
|
|||||||
self.destroy()
|
self.destroy()
|
||||||
return Path(file)
|
return Path(file)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
class FolderPicker(Gtk.FileChooserDialog):
|
||||||
|
def __init__(self, parent: Gtk.Window, title: str) -> None:
|
||||||
|
super().__init__(
|
||||||
|
title=title,
|
||||||
|
action=Gtk.FileChooserAction.SELECT_FOLDER,
|
||||||
|
parent=parent,
|
||||||
|
resizable=True,
|
||||||
|
)
|
||||||
|
self.add_buttons("_Cancel", Gtk.ResponseType.CANCEL)
|
||||||
|
self.add_buttons("_OK", Gtk.ResponseType.OK)
|
||||||
|
self.set_default_response(Gtk.ResponseType.OK)
|
||||||
|
|
||||||
|
def pick_folder(self) -> Path | None:
|
||||||
|
res = self.run()
|
||||||
|
if res in (Gtk.ResponseType.CANCEL, Gtk.ResponseType.DELETE_EVENT):
|
||||||
|
self.destroy()
|
||||||
|
return None
|
||||||
|
if res == Gtk.ResponseType.OK:
|
||||||
|
folder = self.get_current_folder()
|
||||||
|
if folder is None:
|
||||||
|
try:
|
||||||
|
uri = self.get_uri()
|
||||||
|
if uri is None:
|
||||||
|
return None
|
||||||
|
return Path.from_uri(uri)
|
||||||
|
except Exception:
|
||||||
|
# FIXME: edge cases
|
||||||
|
return Path("/")
|
||||||
|
self.destroy()
|
||||||
|
return Path(folder)
|
||||||
|
return None
|
||||||
@@ -44,6 +44,8 @@ class ContextMixin(TreeView):
|
|||||||
self.context_menu.connect("key-press-event", self._on_key)
|
self.context_menu.connect("key-press-event", self._on_key)
|
||||||
|
|
||||||
for row in group.value:
|
for row in group.value:
|
||||||
|
if row is None:
|
||||||
|
return False
|
||||||
item = self._process_dynamic_row(row)
|
item = self._process_dynamic_row(row)
|
||||||
self.context_menu.append(item)
|
self.context_menu.append(item)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,10 @@
|
|||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from typing import Self, TYPE_CHECKING
|
from typing import Self, TYPE_CHECKING
|
||||||
|
from dzgui.api.steam import find_user_id
|
||||||
|
from dzgui.const.enum import NotebookPage, Preferences
|
||||||
|
from dzgui.views.components.box import HBox
|
||||||
|
from dzgui.views.components.buttons import SteamWorkshopButton
|
||||||
from dzgui.views.components.scrollable import NoOverlayScrolledWindow
|
from dzgui.views.components.scrollable import NoOverlayScrolledWindow
|
||||||
from dzgui.views.trees.tree_mods import ModTreeView
|
from dzgui.views.trees.tree_mods import ModTreeView
|
||||||
|
|
||||||
@@ -11,26 +17,64 @@ if TYPE_CHECKING:
|
|||||||
from dzgui.controllers.mc import Controller
|
from dzgui.controllers.mc import Controller
|
||||||
|
|
||||||
|
|
||||||
|
class Mods(Gtk.Box):
|
||||||
class Mods(NoOverlayScrolledWindow):
|
|
||||||
def __init__(self, controller: "Controller") -> None:
|
def __init__(self, controller: "Controller") -> None:
|
||||||
super().__init__()
|
super().__init__(orientation=Gtk.Orientation.VERTICAL)
|
||||||
|
|
||||||
self.controller = controller
|
self.box = NoOverlayScrolledWindow()
|
||||||
self.emitter = controller.get_emitter()
|
|
||||||
self.tree = ModTreeView(controller)
|
self.tree = ModTreeView(controller)
|
||||||
|
self.tree.set_vexpand(True)
|
||||||
|
self.box.add(self.tree)
|
||||||
|
|
||||||
self.add(self.tree)
|
self.statusbar_cache = ""
|
||||||
|
self.controller = controller
|
||||||
self.controller.register_widget("modtreeview", self.tree)
|
self.controller.register_widget("modtreeview", self.tree)
|
||||||
|
self.emitter = controller.get_emitter()
|
||||||
|
|
||||||
|
# TODO: move
|
||||||
|
default_steam_path = self.controller.query_config(Preferences.DEFAULT)
|
||||||
|
steam_path = Path(default_steam_path)
|
||||||
|
uid = find_user_id(steam_path)
|
||||||
|
|
||||||
|
pretty_uid = "" if uid is None else uid
|
||||||
|
hbox = HBox(spacing=10)
|
||||||
|
workshop_button = SteamWorkshopButton()
|
||||||
|
workshop_button.connect(
|
||||||
|
"clicked", lambda _: self.controller.open_user_workshop(pretty_uid)
|
||||||
|
)
|
||||||
|
self.offline_button = Gtk.Button(
|
||||||
|
label="Play offline",
|
||||||
|
halign=Gtk.Align.START,
|
||||||
|
margin_top=10,
|
||||||
|
margin_bottom=10,
|
||||||
|
)
|
||||||
|
self.offline_button.connect("clicked", self._on_offline_clicked)
|
||||||
|
|
||||||
|
hbox.add(workshop_button)
|
||||||
|
hbox.add(self.offline_button)
|
||||||
|
|
||||||
|
self.add(hbox)
|
||||||
|
self.add(self.box)
|
||||||
|
|
||||||
self.connect("map", self._on_map)
|
self.connect("map", self._on_map)
|
||||||
self.connect("unmap", self._on_unmap)
|
self.connect("unmap", self._on_unmap)
|
||||||
|
|
||||||
|
def _on_offline_clicked(self, button: Gtk.Button) -> None:
|
||||||
|
self.statusbar_cache = self.controller.get_statusbar().get_cache()
|
||||||
|
self.controller.open_offline()
|
||||||
|
|
||||||
def _on_unmap(self, widget: Self) -> None:
|
def _on_unmap(self, widget: Self) -> None:
|
||||||
self.emitter.emit("mod_page_toggled", False)
|
self.emitter.emit("mod_page_toggled", False)
|
||||||
|
|
||||||
def _on_map(self, widget: Self) -> None:
|
def _on_map(self, widget: Self) -> None:
|
||||||
self.emitter.emit("mod_page_toggled", True)
|
self.emitter.emit("mod_page_toggled", True)
|
||||||
|
# TODO: delegation
|
||||||
|
# NOTE: handles going back from offline mods page
|
||||||
|
# more generic cache restoration method
|
||||||
|
if len(self.statusbar_cache) > 0:
|
||||||
|
self.controller.get_statusbar().set_by_context(
|
||||||
|
NotebookPage.MODS, self.statusbar_cache
|
||||||
|
)
|
||||||
|
|
||||||
def grab_content_area(self) -> None:
|
def grab_content_area(self) -> None:
|
||||||
self.tree.grab_focus()
|
self.tree.grab_focus()
|
||||||
@@ -0,0 +1,513 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
from enum import Enum
|
||||||
|
from typing import Self, TYPE_CHECKING, Union
|
||||||
|
|
||||||
|
from dzgui.util import css
|
||||||
|
from dzgui.const.constants import (
|
||||||
|
APPID_DAYZ,
|
||||||
|
APPID_DAYZ_EXP,
|
||||||
|
APPNAME_DAYZ,
|
||||||
|
APPNAME_DAYZ_EXP_HUMAN,
|
||||||
|
EDIT_DELETE,
|
||||||
|
ERROR,
|
||||||
|
FOLDER,
|
||||||
|
WARNING,
|
||||||
|
)
|
||||||
|
from dzgui.const.enum import ContextMenuGroup, NotebookPage
|
||||||
|
from dzgui.managers.offline import OfflineManager
|
||||||
|
from dzgui.strings import generic, offline
|
||||||
|
from dzgui.views.components.box import HBox, VBox
|
||||||
|
from dzgui.views.components.buttons import Icon, IconTextButton
|
||||||
|
from dzgui.views.components.eventbox import InfoEventBox
|
||||||
|
from dzgui.views.components.frame import HeadingFrame
|
||||||
|
from dzgui.views.components.scrollable import NoOverlayScrolledWindow
|
||||||
|
from dzgui.views.trees.tree_mods import OfflineModTreeView
|
||||||
|
|
||||||
|
|
||||||
|
import gi
|
||||||
|
|
||||||
|
gi.require_version("Gtk", "3.0")
|
||||||
|
from gi.repository import Gtk, Gdk, GObject # noqa
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from dzgui.controllers.mc import Controller
|
||||||
|
from dzgui.controllers.emitter import Emitter
|
||||||
|
from dzgui.model.model_factory import FastInsertListStore
|
||||||
|
|
||||||
|
|
||||||
|
class FolderError(Enum):
|
||||||
|
NO_VALID_MODS = 1
|
||||||
|
NO_VALID_MISSION = 2
|
||||||
|
FOLDER_CHANGED = 3
|
||||||
|
|
||||||
|
|
||||||
|
class PageHeading(Gtk.Label):
|
||||||
|
def __init__(self, label: str) -> None:
|
||||||
|
super().__init__(label=label, halign=Gtk.Align.CENTER)
|
||||||
|
|
||||||
|
css.add_class(self, "page-heading")
|
||||||
|
|
||||||
|
|
||||||
|
class ErrorPopover(Gtk.Popover):
|
||||||
|
def __init__(self) -> None:
|
||||||
|
super().__init__(position=Gtk.PositionType.RIGHT)
|
||||||
|
|
||||||
|
self.hbox = HBox()
|
||||||
|
self.label = Gtk.Label(label="", margin_start=10, margin_end=10)
|
||||||
|
error_icon = Icon(ERROR, margin_start=10)
|
||||||
|
self.hbox.extend([error_icon, self.label])
|
||||||
|
self.add(self.hbox)
|
||||||
|
self.show_all()
|
||||||
|
self.popdown()
|
||||||
|
|
||||||
|
def set_label(self, error: FolderError, msg: str) -> None:
|
||||||
|
match error:
|
||||||
|
case FolderError.NO_VALID_MODS:
|
||||||
|
prefix = offline.no_mods
|
||||||
|
case FolderError.NO_VALID_MISSION:
|
||||||
|
prefix = offline.no_mission
|
||||||
|
case FolderError.FOLDER_CHANGED:
|
||||||
|
prefix = offline.folder_changed
|
||||||
|
self.label.set_label(prefix)
|
||||||
|
return
|
||||||
|
self.label.set_label(f"{prefix}: '{msg}'")
|
||||||
|
|
||||||
|
|
||||||
|
class FolderHBox(HBox):
|
||||||
|
def __init__(self, controller: "Controller", btn_label: str, eb_text: str) -> None:
|
||||||
|
super().__init__(spacing=10)
|
||||||
|
|
||||||
|
self.set_margin_start(5)
|
||||||
|
self.set_margin_end(10)
|
||||||
|
self.set_margin_bottom(5)
|
||||||
|
|
||||||
|
self.folder = ""
|
||||||
|
self.controller = controller
|
||||||
|
self.emitter = controller.get_emitter()
|
||||||
|
|
||||||
|
self.eb = InfoEventBox(eb_text, controller)
|
||||||
|
self.button = IconTextButton(FOLDER, btn_label, Gtk.PositionType.LEFT)
|
||||||
|
self.button.set_halign(Gtk.Align.START)
|
||||||
|
self.button.set_image_position(Gtk.PositionType.LEFT)
|
||||||
|
|
||||||
|
self.set_can_focus(True)
|
||||||
|
|
||||||
|
self.scrolled_label = Gtk.ScrolledWindow(
|
||||||
|
propagate_natural_width=True, halign=Gtk.Align.START
|
||||||
|
)
|
||||||
|
self.label = Gtk.Label()
|
||||||
|
self.scrolled_label.add(self.label)
|
||||||
|
|
||||||
|
self.unset_button = IconTextButton(EDIT_DELETE, offline.unset_button)
|
||||||
|
self.unset_button.connect("clicked", self._on_unset_clicked)
|
||||||
|
|
||||||
|
self.spinner = Gtk.Spinner()
|
||||||
|
self.extend(
|
||||||
|
[self.eb, self.button, self.spinner, self.scrolled_label, self.unset_button]
|
||||||
|
)
|
||||||
|
|
||||||
|
self.pop = ErrorPopover()
|
||||||
|
self.pop.set_relative_to(self.button)
|
||||||
|
self.pop.connect("unmap", lambda _: self.grab_focus())
|
||||||
|
|
||||||
|
self.sidepop = ErrorPopover()
|
||||||
|
self.sidepop.set_position(Gtk.PositionType.BOTTOM)
|
||||||
|
self.sidepop.set_relative_to(self.scrolled_label)
|
||||||
|
self.sidepop.connect("unmap", lambda _: self.grab_focus())
|
||||||
|
|
||||||
|
self.connect("map", self._on_map)
|
||||||
|
self.connect("unmap", self._on_unmap)
|
||||||
|
|
||||||
|
def start_spinner(self) -> None:
|
||||||
|
self.spinner.show()
|
||||||
|
self.spinner.start()
|
||||||
|
|
||||||
|
def stop_spinner(self) -> None:
|
||||||
|
self.spinner.hide()
|
||||||
|
self.spinner.stop()
|
||||||
|
|
||||||
|
def _on_unmap(self, widget: Self) -> None:
|
||||||
|
self.unset_button.hide()
|
||||||
|
self.label.set_label("")
|
||||||
|
self.scrolled_label.hide()
|
||||||
|
|
||||||
|
def _on_map(self, widget: Self) -> None:
|
||||||
|
self.spinner.hide()
|
||||||
|
self.scrolled_label.show()
|
||||||
|
self.unset_button.hide()
|
||||||
|
|
||||||
|
def _on_unset_clicked(self, button: Gtk.Button) -> None:
|
||||||
|
self.folder = ""
|
||||||
|
self.label.set_label("")
|
||||||
|
self.unset_button.hide()
|
||||||
|
# FIXME: rename signal
|
||||||
|
self.emitter.emit("custom_mods_unloaded", self)
|
||||||
|
|
||||||
|
def get_button(self) -> Gtk.Button:
|
||||||
|
return self.button
|
||||||
|
|
||||||
|
def hide_label(self) -> None:
|
||||||
|
self.label.hide()
|
||||||
|
|
||||||
|
def get_folder(self) -> str:
|
||||||
|
return self.folder
|
||||||
|
|
||||||
|
def set_folder(self, folder: str) -> None:
|
||||||
|
prefix = offline.folder_prefix
|
||||||
|
self.folder = folder
|
||||||
|
self.label.set_markup(prefix + folder)
|
||||||
|
self.label.show()
|
||||||
|
self.unset_button.show()
|
||||||
|
|
||||||
|
def present_error(self, error: FolderError, msg: str) -> None:
|
||||||
|
if error == FolderError.FOLDER_CHANGED:
|
||||||
|
self.sidepop.set_label(error, msg)
|
||||||
|
self.sidepop.popup()
|
||||||
|
return
|
||||||
|
self.folder = ""
|
||||||
|
self.label.set_text("")
|
||||||
|
self.unset_button.hide()
|
||||||
|
self.pop.set_label(error, msg)
|
||||||
|
self.pop.popup()
|
||||||
|
|
||||||
|
|
||||||
|
class ModFrame(HeadingFrame):
|
||||||
|
def __init__(
|
||||||
|
self, parent: OfflineLoader, controller: "Controller", label: str
|
||||||
|
) -> None:
|
||||||
|
super().__init__(heading=label)
|
||||||
|
|
||||||
|
self.parent = parent
|
||||||
|
self.vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||||
|
|
||||||
|
self.tree = OfflineModTreeView(controller)
|
||||||
|
self.tree.set_model(None)
|
||||||
|
self.tree.set_valign(Gtk.Align.FILL)
|
||||||
|
|
||||||
|
self.scrolled = NoOverlayScrolledWindow()
|
||||||
|
self.scrolled.set_margin_end(5)
|
||||||
|
self.scrolled.set_vexpand(True)
|
||||||
|
self.scrolled.add(self.tree)
|
||||||
|
|
||||||
|
self.status = Gtk.Label(
|
||||||
|
halign=Gtk.Align.START, margin_start=5, margin_top=3, margin_bottom=3
|
||||||
|
)
|
||||||
|
|
||||||
|
self.tree_vbox = VBox()
|
||||||
|
self.tree_vbox.extend([self.scrolled, self.status])
|
||||||
|
|
||||||
|
self.no_mods = HBox(spacing=10)
|
||||||
|
no_mods_icon = Icon(WARNING, margin_start=10)
|
||||||
|
no_mods_label = Gtk.Label(label=offline.no_local_mods, halign=Gtk.Align.START)
|
||||||
|
self.no_mods.extend([no_mods_icon, no_mods_label])
|
||||||
|
|
||||||
|
self.vbox.pack_end(self.no_mods, expand=True, fill=True, padding=3)
|
||||||
|
self.vbox.pack_end(self.tree_vbox, expand=True, fill=True, padding=3)
|
||||||
|
self.frame.add(self.vbox)
|
||||||
|
|
||||||
|
sel = self.tree.get_selection()
|
||||||
|
sel.connect("changed", self._on_selection_changed)
|
||||||
|
|
||||||
|
self.connect("map", self._on_map)
|
||||||
|
self.connect("unmap", self._on_unmap)
|
||||||
|
|
||||||
|
def start_empty(self) -> None:
|
||||||
|
self.tree_vbox.hide()
|
||||||
|
self.no_mods.show()
|
||||||
|
|
||||||
|
def _on_map(self, widget: Self) -> None:
|
||||||
|
self.no_mods.hide()
|
||||||
|
self.tree.set_model(None)
|
||||||
|
self.tree_vbox.hide()
|
||||||
|
|
||||||
|
def _on_unmap(self, widget: Self) -> None:
|
||||||
|
self.tree.set_model(None)
|
||||||
|
self.tree_vbox.hide()
|
||||||
|
self.no_mods.hide()
|
||||||
|
|
||||||
|
def start(self, store: "FastInsertListStore") -> None:
|
||||||
|
# TODO: this manipulates mod man store out of band
|
||||||
|
self.tree.set_model(store)
|
||||||
|
self.tree.mod_man.set_store(store)
|
||||||
|
self.show_tree()
|
||||||
|
|
||||||
|
def get_mods(self) -> list[str]:
|
||||||
|
model, treeiters = self.tree.get_selection().get_selected_rows()
|
||||||
|
if model is None:
|
||||||
|
return []
|
||||||
|
if type(self) is CustomModFrame:
|
||||||
|
# NOTE: custom mod dirs to be hashed
|
||||||
|
return [model[_iter][2] for _iter in treeiters]
|
||||||
|
else:
|
||||||
|
# NOTE: pre-existing, canonical symlinks to published mods
|
||||||
|
return [model[_iter][1] for _iter in treeiters]
|
||||||
|
|
||||||
|
def show_tree(self) -> None:
|
||||||
|
self.tree_vbox.show()
|
||||||
|
|
||||||
|
def collapse_tree(self) -> None:
|
||||||
|
self.tree_vbox.hide()
|
||||||
|
|
||||||
|
def get_tree(self) -> OfflineModTreeView:
|
||||||
|
return self.tree
|
||||||
|
|
||||||
|
def pack(self, widget: Gtk.Widget) -> None:
|
||||||
|
self.vbox.pack_start(widget, expand=False, fill=False, padding=5)
|
||||||
|
|
||||||
|
def set_model(self, model: Union["FastInsertListStore", None]) -> None:
|
||||||
|
self.tree.set_model(model)
|
||||||
|
self.tree.mod_man.store = model
|
||||||
|
self.set_cursor()
|
||||||
|
|
||||||
|
def _on_selection_changed(self, sel: Gtk.TreeSelection) -> None:
|
||||||
|
model, rows = sel.get_selected_rows()
|
||||||
|
if len(rows) == 0:
|
||||||
|
status = generic.selectable_tree
|
||||||
|
else:
|
||||||
|
status = f"Mods selected: {len(rows)}"
|
||||||
|
self.status.set_label(status)
|
||||||
|
# TODO: cleaner delegation
|
||||||
|
# simply send int value or use emitter
|
||||||
|
self.parent.check_button()
|
||||||
|
|
||||||
|
def set_cursor(self) -> None:
|
||||||
|
path = Gtk.TreePath.new_from_indices([0])
|
||||||
|
self.tree.set_cursor(path)
|
||||||
|
self.tree.get_selection().unselect_all()
|
||||||
|
|
||||||
|
|
||||||
|
class CustomModFrame(ModFrame):
|
||||||
|
def __init__(
|
||||||
|
self, parent: OfflineLoader, controller: "Controller", heading: str
|
||||||
|
) -> None:
|
||||||
|
super().__init__(parent, controller, heading)
|
||||||
|
|
||||||
|
self.tree.set_menu(ContextMenuGroup.MOD_OFFLINE)
|
||||||
|
self.parent = parent
|
||||||
|
|
||||||
|
self.controller = controller
|
||||||
|
self.emitter = controller.get_emitter()
|
||||||
|
|
||||||
|
self.custom_hbox = FolderHBox(
|
||||||
|
controller, offline.custom_button, offline.custom_eventbox
|
||||||
|
)
|
||||||
|
self.custom_hbox.get_button().connect("clicked", self._on_custom_button_clicked)
|
||||||
|
|
||||||
|
self.pack(self.custom_hbox)
|
||||||
|
|
||||||
|
self.emitter.connect("custom_mods_loaded", self._on_custom_mods_loaded)
|
||||||
|
self.emitter.connect("custom_mods_unloaded", self._on_custom_mods_unloaded)
|
||||||
|
|
||||||
|
self.connect("map", self._on_map)
|
||||||
|
|
||||||
|
def _on_map(self, widget: Self) -> None:
|
||||||
|
self.hide_tree()
|
||||||
|
|
||||||
|
def _on_custom_mods_unloaded(self, emitter: "Emitter", widget: FolderHBox) -> None:
|
||||||
|
# TODO: kludgy workaround for generic button emitting global signal
|
||||||
|
if widget == self.custom_hbox:
|
||||||
|
self.hide_tree()
|
||||||
|
|
||||||
|
def hide_tree(self) -> None:
|
||||||
|
self.custom_hbox.hide_label()
|
||||||
|
self.tree.set_model(None)
|
||||||
|
self.tree_vbox.hide()
|
||||||
|
self.no_mods.hide()
|
||||||
|
|
||||||
|
def present_folder_changed(self, folder: str) -> None:
|
||||||
|
self.custom_hbox.present_error(FolderError.FOLDER_CHANGED, folder)
|
||||||
|
|
||||||
|
def present_error(self, folder: str) -> None:
|
||||||
|
self.hide_tree()
|
||||||
|
self.custom_hbox.present_error(FolderError.NO_VALID_MODS, folder)
|
||||||
|
|
||||||
|
def present_tree(self, store: "FastInsertListStore", folder: str) -> None:
|
||||||
|
self.custom_hbox.set_folder(folder)
|
||||||
|
self.tree.set_model(store)
|
||||||
|
self.tree_vbox.show()
|
||||||
|
|
||||||
|
def _on_custom_mods_loaded(
|
||||||
|
self,
|
||||||
|
emitter: "Emitter",
|
||||||
|
store: "FastInsertListStore",
|
||||||
|
folder: str,
|
||||||
|
) -> None:
|
||||||
|
self.custom_hbox.stop_spinner()
|
||||||
|
if len(store) == 0:
|
||||||
|
self.present_error(folder)
|
||||||
|
else:
|
||||||
|
self.present_tree(store, folder)
|
||||||
|
|
||||||
|
def _on_custom_button_clicked(self, button: Gtk.Button) -> None:
|
||||||
|
callback = self.custom_hbox.start_spinner
|
||||||
|
# TODO: cleaner delegation
|
||||||
|
self.parent.offline_man.find_custom_mods(callback)
|
||||||
|
|
||||||
|
def get_folder(self) -> str:
|
||||||
|
return self.custom_hbox.get_folder()
|
||||||
|
|
||||||
|
|
||||||
|
class MissionFrame(HeadingFrame):
|
||||||
|
def __init__(self, parent: OfflineLoader, controller: "Controller") -> None:
|
||||||
|
super().__init__(heading=offline.mission_frame)
|
||||||
|
|
||||||
|
self.parent = parent
|
||||||
|
self.controller = controller
|
||||||
|
self.emitter = controller.get_emitter()
|
||||||
|
|
||||||
|
self.mission_hbox = FolderHBox(
|
||||||
|
controller, offline.mission_button, offline.mission_eventbox
|
||||||
|
)
|
||||||
|
self.mission_button = self.mission_hbox.get_button()
|
||||||
|
self.mission_button.connect("clicked", self._on_mission_button_clicked)
|
||||||
|
|
||||||
|
self.frame.add(self.mission_hbox)
|
||||||
|
|
||||||
|
self.emitter.connect("custom_mission_loaded", self._on_mission_loaded)
|
||||||
|
|
||||||
|
def _on_mission_loaded(
|
||||||
|
self, emitter: "Emitter", folder: str, is_valid: bool
|
||||||
|
) -> None:
|
||||||
|
if is_valid:
|
||||||
|
self.mission_hbox.set_folder(folder)
|
||||||
|
else:
|
||||||
|
self.mission_hbox.present_error(FolderError.NO_VALID_MISSION, folder)
|
||||||
|
self.parent.check_button()
|
||||||
|
|
||||||
|
def _on_mission_button_clicked(self, button: Gtk.Button) -> None:
|
||||||
|
self.parent.offline_man.get_mission()
|
||||||
|
|
||||||
|
def get_mission(self) -> str:
|
||||||
|
return self.mission_hbox.get_folder()
|
||||||
|
|
||||||
|
def present_folder_changed(self, folder: str) -> None:
|
||||||
|
self.mission_hbox.present_error(FolderError.FOLDER_CHANGED, folder)
|
||||||
|
|
||||||
|
|
||||||
|
class RadioFrame(HeadingFrame):
|
||||||
|
def __init__(self, parent: OfflineLoader, controller: "Controller") -> None:
|
||||||
|
super().__init__(heading=offline.version)
|
||||||
|
|
||||||
|
self.controller = controller
|
||||||
|
|
||||||
|
self.id_map = {APPNAME_DAYZ: APPID_DAYZ, APPNAME_DAYZ_EXP_HUMAN: APPID_DAYZ_EXP}
|
||||||
|
self.appid = APPID_DAYZ
|
||||||
|
|
||||||
|
self.dayz = Gtk.RadioButton.new_with_label(None, APPNAME_DAYZ)
|
||||||
|
self.dayz_exp = Gtk.RadioButton.new_with_label_from_widget(
|
||||||
|
self.dayz, APPNAME_DAYZ_EXP_HUMAN
|
||||||
|
)
|
||||||
|
|
||||||
|
self.radio_box = HBox()
|
||||||
|
self.radio_box.extend([self.dayz, self.dayz_exp])
|
||||||
|
self.radio_box.set_margin_start(10)
|
||||||
|
self.radio_box.set_margin_bottom(5)
|
||||||
|
|
||||||
|
self.frame.add(self.radio_box)
|
||||||
|
|
||||||
|
# TODO: cleaner delegation
|
||||||
|
has_dayz_exp = parent.offline_man.has_dayz_exp()
|
||||||
|
self.dayz.connect("toggled", self._on_radio_toggled)
|
||||||
|
if has_dayz_exp is False:
|
||||||
|
self.dayz_exp.set_sensitive(False)
|
||||||
|
|
||||||
|
def _on_radio_toggled(self, radio: Gtk.RadioButton) -> None:
|
||||||
|
for el in self.dayz, self.dayz_exp:
|
||||||
|
if el.get_active():
|
||||||
|
label = el.get_label()
|
||||||
|
self.appid = self.id_map[label]
|
||||||
|
|
||||||
|
def get_appid(self) -> int:
|
||||||
|
return self.appid
|
||||||
|
|
||||||
|
|
||||||
|
class OfflineLoader(Gtk.Box):
|
||||||
|
def __init__(self, controller: "Controller"):
|
||||||
|
super().__init__(
|
||||||
|
orientation=Gtk.Orientation.VERTICAL,
|
||||||
|
margin_start=10,
|
||||||
|
margin_end=10,
|
||||||
|
)
|
||||||
|
|
||||||
|
self.controller = controller
|
||||||
|
self.controller.register_widget("offline_loader", self)
|
||||||
|
self.emitter = controller.get_emitter()
|
||||||
|
self.offline_man = OfflineManager(controller)
|
||||||
|
|
||||||
|
self.add(PageHeading(offline.heading))
|
||||||
|
|
||||||
|
self.local_frame = ModFrame(self, controller, offline.local_frame)
|
||||||
|
self.custom_frame = CustomModFrame(self, controller, offline.custom_frame)
|
||||||
|
|
||||||
|
self.custom_tree = OfflineModTreeView(controller)
|
||||||
|
self.mission_frame = MissionFrame(self, controller)
|
||||||
|
self.radio_frame = RadioFrame(self, controller)
|
||||||
|
|
||||||
|
self.scrollable = Gtk.ScrolledWindow(
|
||||||
|
vexpand=True, propagate_natural_height=True
|
||||||
|
)
|
||||||
|
|
||||||
|
self.content_box = VBox(spacing=5)
|
||||||
|
self.content_box.extend(
|
||||||
|
[
|
||||||
|
self.local_frame,
|
||||||
|
self.custom_frame,
|
||||||
|
self.mission_frame,
|
||||||
|
self.radio_frame,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
# TODO: share ConnectBox class with preconnect dialog?
|
||||||
|
self.button_box = HBox(spacing=5)
|
||||||
|
self.button_box.set_halign(Gtk.Align.END)
|
||||||
|
self.button_box.set_margin_top(15)
|
||||||
|
self.back = Gtk.Button(label="Back")
|
||||||
|
self.ok = Gtk.Button(label="Launch", sensitive=False)
|
||||||
|
self.back.connect("clicked", self._on_back_clicked)
|
||||||
|
self.ok.connect("clicked", self._on_ok_clicked)
|
||||||
|
self.connect("key-press-event", self._on_keypress)
|
||||||
|
self.emitter.connect("custom_mods_unloaded", lambda _, __: self.check_button())
|
||||||
|
|
||||||
|
self.button_box.extend([self.back, self.ok])
|
||||||
|
|
||||||
|
self.scrollable.add(self.content_box)
|
||||||
|
self.add(self.scrollable)
|
||||||
|
self.add(self.button_box)
|
||||||
|
|
||||||
|
def check_button(self) -> None:
|
||||||
|
local_mods = self.local_frame.get_mods()
|
||||||
|
custom_mods = self.custom_frame.get_mods()
|
||||||
|
mission = self.mission_frame.get_mission()
|
||||||
|
if len(local_mods) == 0 and len(custom_mods) == 0 and len(mission) == 0:
|
||||||
|
self.ok.set_sensitive(False)
|
||||||
|
else:
|
||||||
|
self.ok.set_sensitive(True)
|
||||||
|
|
||||||
|
def _on_keypress(self, widget: Self, event: Gdk.EventKey) -> None:
|
||||||
|
if event.keyval == Gdk.KEY_Escape:
|
||||||
|
self.back.emit("clicked")
|
||||||
|
|
||||||
|
def populate(self, store: Union["FastInsertListStore", None]) -> None:
|
||||||
|
if store is None:
|
||||||
|
self.local_frame.start_empty()
|
||||||
|
return
|
||||||
|
self.local_frame.start(store)
|
||||||
|
|
||||||
|
def _on_back_clicked(self, button: Gtk.Button) -> None:
|
||||||
|
self.controller.open_page(NotebookPage.MODS)
|
||||||
|
|
||||||
|
def _on_ok_clicked(self, button: Gtk.Button) -> None:
|
||||||
|
appid = self.radio_frame.get_appid()
|
||||||
|
mission = self.mission_frame.get_mission()
|
||||||
|
local_mods = self.local_frame.get_mods()
|
||||||
|
custom_folder = self.custom_frame.get_folder()
|
||||||
|
custom_mods = self.custom_frame.get_mods()
|
||||||
|
|
||||||
|
if custom_folder and not self.offline_man.is_custom_folder_valid(custom_folder):
|
||||||
|
self.custom_frame.present_folder_changed(mission)
|
||||||
|
return
|
||||||
|
|
||||||
|
if mission and not self.offline_man.is_mission_valid(mission):
|
||||||
|
self.mission_frame.present_folder_changed(mission)
|
||||||
|
return
|
||||||
|
self.offline_man.launch(appid, mission, local_mods, custom_folder, custom_mods)
|
||||||
@@ -2,7 +2,7 @@ from pathlib import Path
|
|||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from dzgui.api import pefile as PeFile
|
from dzgui.api import pefile as PeFile
|
||||||
from dzgui.api.steam import find_user_id
|
|
||||||
from dzgui.config import query
|
from dzgui.config import query
|
||||||
from dzgui.const.constants import (
|
from dzgui.const.constants import (
|
||||||
APPID_DAYZ,
|
APPID_DAYZ,
|
||||||
@@ -19,9 +19,8 @@ from dzgui.const.endpoints import STEAM_API_SETUP, BM_API_SETUP
|
|||||||
from dzgui.const.enum import Preferences, ServerTab
|
from dzgui.const.enum import Preferences, ServerTab
|
||||||
from dzgui.strings import errors, options
|
from dzgui.strings import errors, options
|
||||||
from dzgui.util import strings, css, open_links
|
from dzgui.util import strings, css, open_links
|
||||||
from dzgui.views.components.buttons import SteamWorkshopButton
|
|
||||||
from dzgui.views.components.labels import LeftLabel
|
from dzgui.views.components.labels import LeftLabel
|
||||||
from dzgui.views.components.eventbox import InfoEventBox
|
|
||||||
from dzgui.views.components.buttons import WebButton
|
from dzgui.views.components.buttons import WebButton
|
||||||
from dzgui.views.components.frame import HeadingFrame
|
from dzgui.views.components.frame import HeadingFrame
|
||||||
from dzgui.views.components.misc import ClientCombo
|
from dzgui.views.components.misc import ClientCombo
|
||||||
@@ -134,16 +133,6 @@ class Options(Gtk.Box):
|
|||||||
[LeftLabel(strings.options.name), self.player_box],
|
[LeftLabel(strings.options.name), self.player_box],
|
||||||
]
|
]
|
||||||
|
|
||||||
eb = InfoEventBox(options.workshop_eventbox, controller)
|
|
||||||
|
|
||||||
workshop_button = SteamWorkshopButton()
|
|
||||||
workshop_button.connect(
|
|
||||||
"clicked", lambda _: self.controller.open_user_workshop(self.uid)
|
|
||||||
)
|
|
||||||
mod_rows = [
|
|
||||||
[LeftLabel(options.workshop_label), workshop_button, eb],
|
|
||||||
]
|
|
||||||
|
|
||||||
self.dayz_version_label = Gtk.Label(label=strings.null)
|
self.dayz_version_label = Gtk.Label(label=strings.null)
|
||||||
self.dayz_exp_version_label = Gtk.Label(label=strings.null)
|
self.dayz_exp_version_label = Gtk.Label(label=strings.null)
|
||||||
|
|
||||||
@@ -169,7 +158,6 @@ class Options(Gtk.Box):
|
|||||||
api_box.add(api_links_box)
|
api_box.add(api_links_box)
|
||||||
|
|
||||||
prefs_grid = self._make_grid(pref_rows)
|
prefs_grid = self._make_grid(pref_rows)
|
||||||
mods_grid = self._make_grid(mod_rows)
|
|
||||||
version_grid = self._make_grid(version_rows)
|
version_grid = self._make_grid(version_rows)
|
||||||
|
|
||||||
col = 1
|
col = 1
|
||||||
@@ -187,12 +175,13 @@ class Options(Gtk.Box):
|
|||||||
if prefs.is_debug:
|
if prefs.is_debug:
|
||||||
grid.attach(developers, 1, 0, self.DEFAULT_WIDTH, self.DEFAULT_HEIGHT)
|
grid.attach(developers, 1, 0, self.DEFAULT_WIDTH, self.DEFAULT_HEIGHT)
|
||||||
|
|
||||||
for frame in [
|
for pair in [
|
||||||
HeadingFrame(api_box, strings.options.api_keys),
|
(api_box, strings.options.api_keys),
|
||||||
HeadingFrame(prefs_grid, strings.options.prefs),
|
(prefs_grid, strings.options.prefs),
|
||||||
HeadingFrame(mods_grid, strings.options.mods),
|
(version_grid, strings.options.version),
|
||||||
HeadingFrame(version_grid, strings.options.version),
|
|
||||||
]:
|
]:
|
||||||
|
|
||||||
|
frame = HeadingFrame.new_with_widget_and_label(*pair)
|
||||||
grid.attach(frame, col, row, self.DEFAULT_WIDTH, self.DEFAULT_HEIGHT)
|
grid.attach(frame, col, row, self.DEFAULT_WIDTH, self.DEFAULT_HEIGHT)
|
||||||
row += 1
|
row += 1
|
||||||
|
|
||||||
@@ -414,9 +403,6 @@ class Options(Gtk.Box):
|
|||||||
bm = self.controller.query_config(Preferences.BM)
|
bm = self.controller.query_config(Preferences.BM)
|
||||||
|
|
||||||
steam_path = Path(default_steam_path)
|
steam_path = Path(default_steam_path)
|
||||||
# NOTE: this is a best effort guess at the most recent user
|
|
||||||
uid = find_user_id(steam_path)
|
|
||||||
self.uid = "" if uid is None else uid
|
|
||||||
|
|
||||||
self.old_steam = steam
|
self.old_steam = steam
|
||||||
self.old_bm = bm
|
self.old_bm = bm
|
||||||
|
|||||||
@@ -112,18 +112,6 @@ class PreConnectionAssistant(Gtk.Box):
|
|||||||
tooltip_text=preconnect.connect_last_tooltip,
|
tooltip_text=preconnect.connect_last_tooltip,
|
||||||
)
|
)
|
||||||
|
|
||||||
# TODO: abstract
|
|
||||||
self.raise_window = Gtk.CheckButton(
|
|
||||||
label="Foreground DZGUI while downloading",
|
|
||||||
halign=Gtk.Align.END,
|
|
||||||
hexpand=True,
|
|
||||||
valign=Gtk.Align.END,
|
|
||||||
visible=False,
|
|
||||||
has_tooltip=True,
|
|
||||||
sensitive=False,
|
|
||||||
tooltip_text="Foreground the DZGUI window after mod downloads are queued",
|
|
||||||
active=True,
|
|
||||||
)
|
|
||||||
self.button_box = Gtk.Box(
|
self.button_box = Gtk.Box(
|
||||||
orientation=Gtk.Orientation.VERTICAL,
|
orientation=Gtk.Orientation.VERTICAL,
|
||||||
valign=Gtk.Align.END,
|
valign=Gtk.Align.END,
|
||||||
@@ -133,8 +121,7 @@ class PreConnectionAssistant(Gtk.Box):
|
|||||||
box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5)
|
box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5)
|
||||||
for button in self.back, self.ok, self.connect_last:
|
for button in self.back, self.ok, self.connect_last:
|
||||||
box.add(button)
|
box.add(button)
|
||||||
for el in self.raise_window, box:
|
self.button_box.add(box)
|
||||||
self.button_box.add(el)
|
|
||||||
|
|
||||||
self.back.connect("clicked", self._on_back_clicked)
|
self.back.connect("clicked", self._on_back_clicked)
|
||||||
self.ok.connect("clicked", self._on_ok_clicked)
|
self.ok.connect("clicked", self._on_ok_clicked)
|
||||||
@@ -154,7 +141,7 @@ class PreConnectionAssistant(Gtk.Box):
|
|||||||
self.progress_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=15)
|
self.progress_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=15)
|
||||||
self.progress_box.add(self.mod_count)
|
self.progress_box.add(self.mod_count)
|
||||||
|
|
||||||
self.scrolled = Gtk.ScrolledWindow()
|
self.scrolled = Gtk.ScrolledWindow(margin_end=10)
|
||||||
self.scrolled.add(self.tree)
|
self.scrolled.add(self.tree)
|
||||||
self.scrolled.set_size_request(600, 400)
|
self.scrolled.set_size_request(600, 400)
|
||||||
|
|
||||||
@@ -166,7 +153,9 @@ class PreConnectionAssistant(Gtk.Box):
|
|||||||
self.mods_placeholder = Placeholder("This server has no mods.")
|
self.mods_placeholder = Placeholder("This server has no mods.")
|
||||||
self.tree_box.add(self.mods_placeholder)
|
self.tree_box.add(self.mods_placeholder)
|
||||||
|
|
||||||
self.tree_frame = HeadingFrame(self.tree_box, preconnect.mods)
|
self.tree_frame = HeadingFrame.new_with_widget_and_label(
|
||||||
|
self.tree_box, preconnect.mods
|
||||||
|
)
|
||||||
|
|
||||||
# TODO: abstract into components
|
# TODO: abstract into components
|
||||||
self.warning_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
self.warning_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||||
@@ -175,7 +164,9 @@ class PreConnectionAssistant(Gtk.Box):
|
|||||||
self.warning_placeholder = Placeholder("No warnings.")
|
self.warning_placeholder = Placeholder("No warnings.")
|
||||||
self.warning_box.add(self.warning_tree)
|
self.warning_box.add(self.warning_tree)
|
||||||
self.warning_box.add(self.warning_placeholder)
|
self.warning_box.add(self.warning_placeholder)
|
||||||
self.warning_frame = HeadingFrame(self.warning_box, preconnect.warnings)
|
self.warning_frame = HeadingFrame.new_with_widget_and_label(
|
||||||
|
self.warning_box, preconnect.warnings
|
||||||
|
)
|
||||||
|
|
||||||
self.error_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
self.error_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||||
self.error_tree = MaskedTree(ERROR)
|
self.error_tree = MaskedTree(ERROR)
|
||||||
@@ -183,7 +174,9 @@ class PreConnectionAssistant(Gtk.Box):
|
|||||||
self.error_placeholder = Placeholder("No errors.")
|
self.error_placeholder = Placeholder("No errors.")
|
||||||
self.error_box.add(self.error_tree)
|
self.error_box.add(self.error_tree)
|
||||||
self.error_box.add(self.error_placeholder)
|
self.error_box.add(self.error_placeholder)
|
||||||
self.error_frame = HeadingFrame(self.error_box, preconnect.errors)
|
self.error_frame = HeadingFrame.new_with_widget_and_label(
|
||||||
|
self.error_box, preconnect.errors
|
||||||
|
)
|
||||||
|
|
||||||
self.box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10)
|
self.box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10)
|
||||||
self.box.add(self.title)
|
self.box.add(self.title)
|
||||||
@@ -211,8 +204,6 @@ class PreConnectionAssistant(Gtk.Box):
|
|||||||
for child in widgets:
|
for child in widgets:
|
||||||
child.set_visible(True)
|
child.set_visible(True)
|
||||||
|
|
||||||
self.raise_window.set_visible(False)
|
|
||||||
self.raise_window.set_sensitive(False)
|
|
||||||
self.ok.set_sensitive(True)
|
self.ok.set_sensitive(True)
|
||||||
self.ok.set_label(preconnect.update_mods)
|
self.ok.set_label(preconnect.update_mods)
|
||||||
|
|
||||||
@@ -224,10 +215,10 @@ class PreConnectionAssistant(Gtk.Box):
|
|||||||
self.ok.emit("clicked")
|
self.ok.emit("clicked")
|
||||||
|
|
||||||
def _on_connect_last_clicked(self, button: Gtk.Button) -> None:
|
def _on_connect_last_clicked(self, button: Gtk.Button) -> None:
|
||||||
self.controller.update_and_load_to_menu(self.raise_window.get_active())
|
self.controller.update_and_load_to_menu()
|
||||||
|
|
||||||
def _on_ok_clicked(self, button: Gtk.Button) -> None:
|
def _on_ok_clicked(self, button: Gtk.Button) -> None:
|
||||||
self.controller.update_and_connect(self.raise_window.get_active())
|
self.controller.update_and_connect()
|
||||||
|
|
||||||
def _on_back_clicked(self, button: Gtk.Button) -> None:
|
def _on_back_clicked(self, button: Gtk.Button) -> None:
|
||||||
self.controller.open_page(NotebookPage.SERVERS)
|
self.controller.open_page(NotebookPage.SERVERS)
|
||||||
@@ -311,10 +302,6 @@ class PreConnectionAssistant(Gtk.Box):
|
|||||||
|
|
||||||
if prereqs.required_space == 0:
|
if prereqs.required_space == 0:
|
||||||
self.ok.set_label(preconnect.connect)
|
self.ok.set_label(preconnect.connect)
|
||||||
self.raise_window.set_visible(False)
|
|
||||||
else:
|
|
||||||
self.raise_window.set_visible(True)
|
|
||||||
self.raise_window.set_sensitive(True)
|
|
||||||
|
|
||||||
pretty = number(prereqs.required_space)
|
pretty = number(prereqs.required_space)
|
||||||
suffix = f" Need to download {pretty} MiB of mod updates."
|
suffix = f" Need to download {pretty} MiB of mod updates."
|
||||||
@@ -327,10 +314,7 @@ class PreConnectionAssistant(Gtk.Box):
|
|||||||
self.connect_last.hide()
|
self.connect_last.hide()
|
||||||
|
|
||||||
self._process_warnings(prereqs)
|
self._process_warnings(prereqs)
|
||||||
if self.tree.is_visible():
|
self.tree.grab_focus()
|
||||||
self.tree.grab_focus()
|
|
||||||
else:
|
|
||||||
self.grab_focus()
|
|
||||||
|
|
||||||
def mark_finished(self) -> None:
|
def mark_finished(self) -> None:
|
||||||
self.mod_count.set_label(preconnect.all_updated)
|
self.mod_count.set_label(preconnect.all_updated)
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ logger = logging.getLogger(APP_NAME)
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from dzgui.controllers.mc import Controller
|
from dzgui.controllers.mc import Controller
|
||||||
from dzgui.controllers.mc import Emitter
|
from dzgui.controllers.emitter import Emitter
|
||||||
|
|
||||||
|
|
||||||
class ScrollableTree(Gtk.ScrolledWindow):
|
class ScrollableTree(Gtk.ScrolledWindow):
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from typing import Any, Optional, TYPE_CHECKING
|
|||||||
from warnings import deprecated
|
from warnings import deprecated
|
||||||
|
|
||||||
from dzgui.const.constants import APP_NAME, SEPARATOR
|
from dzgui.const.constants import APP_NAME, SEPARATOR
|
||||||
from dzgui.util.keys import is_navkey
|
from dzgui.util.keys import is_ctrl_mask, is_navkey
|
||||||
from dzgui.views.mixins.cursor_mixin import CursorMixin
|
from dzgui.views.mixins.cursor_mixin import CursorMixin
|
||||||
|
|
||||||
import gi
|
import gi
|
||||||
@@ -85,10 +85,17 @@ class TreeView(CursorMixin, Gtk.TreeView): # type: ignore
|
|||||||
model, rows = sel.get_selected_rows()
|
model, rows = sel.get_selected_rows()
|
||||||
return [model[row] for row in rows]
|
return [model[row] for row in rows]
|
||||||
|
|
||||||
def _on_keypress(self, treeview: Gtk.TreeView, event: Gdk.EventKey) -> None:
|
def _on_keypress(self, treeview: Gtk.TreeView, event: Gdk.EventKey) -> bool:
|
||||||
|
from dzgui.views.trees.tree_servers import ServerTreeView
|
||||||
|
|
||||||
|
# NOTE: suppress popup search and delegate binding to server view (cf. request_keyword_focus)
|
||||||
|
if not isinstance(treeview, ServerTreeView):
|
||||||
|
if is_ctrl_mask(event) and event.keyval == Gdk.KEY_f:
|
||||||
|
return True
|
||||||
|
|
||||||
if is_navkey(event.keyval):
|
if is_navkey(event.keyval):
|
||||||
if self.get_model() is None:
|
if self.get_model() is None:
|
||||||
return
|
return True
|
||||||
if self.sel_blocked is False:
|
if self.sel_blocked is False:
|
||||||
self.sel_blocked = True
|
self.sel_blocked = True
|
||||||
self.controller.suppress_signal(
|
self.controller.suppress_signal(
|
||||||
@@ -98,7 +105,7 @@ class TreeView(CursorMixin, Gtk.TreeView): # type: ignore
|
|||||||
True,
|
True,
|
||||||
)
|
)
|
||||||
self._vim_nav(event)
|
self._vim_nav(event)
|
||||||
return
|
return False
|
||||||
|
|
||||||
def _on_key_release(self, treeview: Gtk.TreeView, event: Gdk.EventKey) -> None:
|
def _on_key_release(self, treeview: Gtk.TreeView, event: Gdk.EventKey) -> None:
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ from typing import Any, TYPE_CHECKING
|
|||||||
|
|
||||||
from dzgui.const.constants import APP_NAME, HEX_RED
|
from dzgui.const.constants import APP_NAME, HEX_RED
|
||||||
from dzgui.const.enum import ContextMenuGroup
|
from dzgui.const.enum import ContextMenuGroup
|
||||||
|
from dzgui.managers.mods import ModManager
|
||||||
from dzgui.util import strings, localize
|
from dzgui.util import strings, localize
|
||||||
from dzgui.views.mixins.context_mixin import ContextMixin
|
from dzgui.views.mixins.context_mixin import ContextMixin
|
||||||
from dzgui.views.mixins.mods_mixin import ModsMixin
|
from dzgui.views.mixins.mods_mixin import ModsMixin
|
||||||
@@ -22,16 +23,19 @@ logger = logging.getLogger(APP_NAME)
|
|||||||
|
|
||||||
|
|
||||||
class ModTreeView(ModsMixin, ContextMixin, TreeView): # type: ignore
|
class ModTreeView(ModsMixin, ContextMixin, TreeView): # type: ignore
|
||||||
def __init__(self, controller: "Controller") -> None:
|
def __init__(
|
||||||
super().__init__(controller, menu=ContextMenuGroup.MOD)
|
self, controller: "Controller", menu: ContextMenuGroup = ContextMenuGroup.MOD
|
||||||
|
) -> None:
|
||||||
|
super().__init__(controller, menu=menu)
|
||||||
|
|
||||||
self.controller = controller
|
self.controller = controller
|
||||||
|
self.mod_man = ModManager(self, controller)
|
||||||
|
|
||||||
emitter = self.controller.get_emitter()
|
emitter = self.controller.get_emitter()
|
||||||
emitter.connect("mods_updated", self._on_mods_updated)
|
emitter.connect("mods_updated", self._on_mods_updated)
|
||||||
emitter.connect("mods_highlighted", self._on_mods_highlighted)
|
emitter.connect("mods_highlighted", self._on_mods_highlighted)
|
||||||
|
|
||||||
self.set_fixed_height_mode(True)
|
self.set_fixed_height_mode(True)
|
||||||
self.set_headers_visible(True)
|
|
||||||
|
|
||||||
self.set_model(None)
|
self.set_model(None)
|
||||||
|
|
||||||
for i, column_title in enumerate(strings.mod_cols):
|
for i, column_title in enumerate(strings.mod_cols):
|
||||||
@@ -58,12 +62,40 @@ class ModTreeView(ModsMixin, ContextMixin, TreeView): # type: ignore
|
|||||||
self.connect("button-press-event", self.present_menu)
|
self.connect("button-press-event", self.present_menu)
|
||||||
self.connect("key-press-event", self.present_menu)
|
self.connect("key-press-event", self.present_menu)
|
||||||
|
|
||||||
|
self.connect("button-press-event", self.on_row_click)
|
||||||
|
|
||||||
|
def on_row_click(self, widget: Gtk.TreeView, event: Gdk.EventButton) -> bool:
|
||||||
|
if event.state is Gdk.ModifierType.CONTROL_MASK and event.button == 1:
|
||||||
|
path_info = widget.get_path_at_pos(int(event.x), int(event.y))
|
||||||
|
if path_info is None:
|
||||||
|
return False
|
||||||
|
path, column, cellx, celly = path_info
|
||||||
|
model = self.get_model()
|
||||||
|
if model is None:
|
||||||
|
return False
|
||||||
|
if path is None:
|
||||||
|
return False
|
||||||
|
_iter = model.get_iter(path)
|
||||||
|
if self.get_selection().iter_is_selected(_iter):
|
||||||
|
self.get_selection().unselect_iter(_iter)
|
||||||
|
else:
|
||||||
|
self.get_selection().select_iter(_iter)
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def get_mod_man(self) -> ModManager:
|
||||||
|
return self.mod_man
|
||||||
|
|
||||||
|
def load_mods(self) -> None:
|
||||||
|
self.mod_man.load_mods()
|
||||||
|
|
||||||
def _on_mods_highlighted(self, emitter: "Emitter") -> None:
|
def _on_mods_highlighted(self, emitter: "Emitter") -> None:
|
||||||
self.get_selection().unselect_all()
|
self.get_selection().unselect_all()
|
||||||
|
|
||||||
def _on_mods_updated(self, emitter: "Emitter", msg: str, mods: int) -> None:
|
def _on_mods_updated(self, emitter: "Emitter", msg: str, mods: int) -> None:
|
||||||
if mods < 1:
|
if mods < 1:
|
||||||
return
|
return
|
||||||
|
self.set_headers_visible(True)
|
||||||
path = Gtk.TreePath.new_from_indices([0])
|
path = Gtk.TreePath.new_from_indices([0])
|
||||||
self.set_cursor(path)
|
self.set_cursor(path)
|
||||||
|
|
||||||
@@ -106,3 +138,13 @@ class ModTreeView(ModsMixin, ContextMixin, TreeView): # type: ignore
|
|||||||
val = model[it][3]
|
val = model[it][3]
|
||||||
formatted = localize.number(val)
|
formatted = localize.number(val)
|
||||||
cell.set_property("text", formatted)
|
cell.set_property("text", formatted)
|
||||||
|
# NOTE: reapply color property after float conversion
|
||||||
|
self._format_color(column, cell, model, it, data)
|
||||||
|
|
||||||
|
def set_menu(self, context: ContextMenuGroup) -> None:
|
||||||
|
self.menu = context
|
||||||
|
|
||||||
|
|
||||||
|
class OfflineModTreeView(ModTreeView):
|
||||||
|
def __init__(self, controller: "Controller") -> None:
|
||||||
|
super().__init__(controller)
|
||||||
+1
-1
@@ -4,7 +4,7 @@ description = "DayZ server browser and mod manager for Linux"
|
|||||||
authors = [
|
authors = [
|
||||||
{name = "aclist"}
|
{name = "aclist"}
|
||||||
]
|
]
|
||||||
version = "7.0.0b10"
|
version = "7.0.0b13"
|
||||||
license = "GPL-3.0-or-later"
|
license = "GPL-3.0-or-later"
|
||||||
license-files = ["LICENSE"]
|
license-files = ["LICENSE"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|||||||
Vendored
+5
@@ -0,0 +1,5 @@
|
|||||||
|
protocol = 1;
|
||||||
|
publishedid = 1234567890;
|
||||||
|
name = "ModName";
|
||||||
|
timestamp = 638278452000000000;
|
||||||
|
hash = "a1b2c3d4e5f6g7h8i9j0";
|
||||||
Vendored
+5
@@ -0,0 +1,5 @@
|
|||||||
|
protocol = 1
|
||||||
|
publishedid = 1234567890
|
||||||
|
name = "ModName"
|
||||||
|
timestamp = 638278452000000000
|
||||||
|
hash = "a1b2c3d4e5f6g7h8i9j0"
|
||||||
Vendored
+5
@@ -0,0 +1,5 @@
|
|||||||
|
protocol=1
|
||||||
|
publishedid=1234567890
|
||||||
|
name="ModName"
|
||||||
|
timestamp=638278452000000000
|
||||||
|
hash="a1b2c3d4e5f6g7h8i9j0"
|
||||||
Vendored
+5
@@ -0,0 +1,5 @@
|
|||||||
|
protocol=1
|
||||||
|
publishedid=1234567890
|
||||||
|
name=ModName
|
||||||
|
timestamp=638278452000000000
|
||||||
|
hash=a1b2c3d4e5f6g7h8i9j0
|
||||||
Vendored
+5
@@ -0,0 +1,5 @@
|
|||||||
|
protocol=1;
|
||||||
|
publishedid=1234567890;
|
||||||
|
name=ModName;
|
||||||
|
timestamp=638278452000000000;
|
||||||
|
hash=a1b2c3d4e5f6g7h8i9j0;
|
||||||
Vendored
+5
@@ -0,0 +1,5 @@
|
|||||||
|
protocol=1
|
||||||
|
publishedid=1234567890;
|
||||||
|
name="ModName";
|
||||||
|
timestamp=638278452000000000;
|
||||||
|
hash= a1b2c3d4e5f6g7h8i9j0;
|
||||||
Vendored
+3
@@ -0,0 +1,3 @@
|
|||||||
|
from dzgui.api.mods import tokenize
|
||||||
|
|
||||||
|
print(tokenize("meta4.cpp"))
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import pytest
|
||||||
|
from dzgui.api.mods import tokenize
|
||||||
|
from tests.fixtures import fixture_path
|
||||||
|
|
||||||
|
@pytest.mark.mods
|
||||||
|
@pytest.mark.parametrize("fixture", [
|
||||||
|
fixture_path("cpp/meta1.cpp"),
|
||||||
|
fixture_path("cpp/meta2.cpp"),
|
||||||
|
fixture_path("cpp/meta3.cpp"),
|
||||||
|
fixture_path("cpp/meta4.cpp"),
|
||||||
|
fixture_path("cpp/meta5.cpp"),
|
||||||
|
fixture_path("cpp/meta6.cpp"),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
def test_modmeta(fixture: str) -> None:
|
||||||
|
meta = tokenize(fixture)
|
||||||
|
assert meta["name"] == "ModName"
|
||||||
Reference in new issue
Block a user