From 4d3d9bf0bb09f9ecb2af5fe46ee7ecfe5205bbbc Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Sun, 15 Dec 2024 09:08:35 +0900 Subject: [PATCH 1/2] feat: open workshop subscriptions --- CHANGELOG.md | 4 ++++ dzgui.sh | 4 ++-- helpers/funcs | 21 ++++++++++++++++++ helpers/ui.py | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 88 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8caec7d..71c19b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## [5.6.0-beta.18] 2024-12-14 +### Added +- Open Steam workshop subscriptions + ## [5.6.0-beta.17] 2024-12-14 ### Added - Additional logging diff --git a/dzgui.sh b/dzgui.sh index 86c478e..ff58bfe 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -578,10 +578,10 @@ fetch_helpers_by_sum(){ [[ -f "$config_file" ]] && source "$config_file" declare -A sums sums=( - ["ui.py"]="be3da1e542d14105f4358dd38901e25a" + ["ui.py"]="24d0525e71c0725a1487926fae7330e4" ["query_v2.py"]="55d339ba02512ac69de288eb3be41067" ["vdf2json.py"]="2f49f6f5d3af919bebaab2e9c220f397" - ["funcs"]="37897aa36bc2fb6286cee02c8bb07258" + ["funcs"]="4c1480fcfae15c4bc1c02a337d1de488" ["lan"]="c62e84ddd1457b71a85ad21da662b9af" ) local author="aclist" diff --git a/helpers/funcs b/helpers/funcs index 22c6d44..1bf3d1a 100755 --- a/helpers/funcs +++ b/helpers/funcs @@ -104,6 +104,7 @@ declare -A funcs=( ["Connect by IP"]="validate_and_connect" ["Connect by ID"]="validate_and_connect" ["Connect from table"]="connect_from_table" +["find_id"]="find_id" ["toggle"]="toggle" ["Open link"]="open_link" ["filter"]="dump_servers" @@ -121,6 +122,7 @@ declare -A funcs=( ["is_in_favs"]="is_in_favs" ["show_log"]="show_log" ["Output system info to log file"]="generate_log" +["open_user_workshop"]="open_user_workshop" ["open_workshop_page"]="open_workshop_page" ["Add to my servers"]="update_favs_from_table" ["Remove from my servers"]="update_favs_from_table" @@ -332,6 +334,19 @@ is_in_favs(){ done return 1 } +find_id(){ + local file="$default_steam_path/config/loginusers.vdf" + [[ ! -f $file ]] && return 1 + local res=$(python3 $HOME/.local/share/dzgui/helpers/vdf2json.py \ + -i "$file" | jq -r '.users + |to_entries[] + |select(.value.MostRecent=="1") + |.key' + ) + [[ -z $res ]] && return 1 + printf "%s" "$res" + return 0 +} list_mods(){ local symlink local sep @@ -1051,6 +1066,12 @@ update_config_val(){ show_log(){ < "$debug_log" sed 's/Keyword␞/Keyword/' } +open_user_workshop(){ + shift + local id="$1" + url="https://steamcommunity.com/profiles/$id/myworkshopfiles/?appid=$aid&browsefilter=mysubscriptions" + $steam_cmd steam://openurl/$url & +} open_workshop_page(){ shift local id="$1" diff --git a/helpers/ui.py b/helpers/ui.py index b5f01c0..d741ee0 100644 --- a/helpers/ui.py +++ b/helpers/ui.py @@ -215,6 +215,7 @@ class RowType(EnumWithAttrs): "label": "Toggle mod install mode", "tooltip": "Switch between manual and auto mod installation", "default": "manual", + "link_label": "Open Steam Workshop", "alt": "auto", "val": "auto_install" } @@ -756,6 +757,29 @@ def process_tree_option(input, treeview): case RowType.TGL_BRANCH: wait_msg = "Updating DZGUI branch" call_on_thread(False, "toggle", wait_msg, cmd_string) + case RowType.TGL_INSTALL: + if query_config(None, "auto_install")[0] == "1": + proc = call_out(transient_parent, "toggle", cmd_string) + grid.update_right_statusbar() + tooltip = format_metadata(command.dict["label"]) + transient_parent.grid.update_statusbar(tooltip) + return + # manual -> auto mode + proc = call_out(transient_parent, "find_id", "") + if proc.returncode == 1: + link=None + uid=None + else: + link=command.dict["link_label"] + uid=proc.stdout + manual_sub_msg = """\ + When switching from MANUAL to AUTO mod install mode, + DZGUI will manage mod installation and deletion for you. + To prevent conflicts with Steam Workshop subscriptions and old mods from being downloaded + when Steam updates, you should unsubscribe from any existing Workshop mods you manually subscribed to. + Open your Profile > Workshop Items and select 'Unsubscribe from all' + on the right-hand side, then click OK below to enable AUTO mod install mode.""" + LinkDialog(transient_parent, textwrap.dedent(manual_sub_msg), Popup.NOTIFY, link, command, uid) case _: proc = call_out(transient_parent, "toggle", cmd_string) grid.update_right_statusbar() @@ -2205,6 +2229,43 @@ class ModDialog(GenericDialog): subprocess.Popen(['/usr/bin/env', 'bash', funcs, "open_workshop_page", mod_id]) +class LinkDialog(GenericDialog): + def __init__(self, parent, text, mode, link, command, uid=None): + super().__init__(parent, text, mode) + + self.dialog = GenericDialog(parent, text, mode) + self.dialogBox = self.dialog.get_content_area() + self.dialog.set_default_response(Gtk.ResponseType.OK) + self.dialog.set_size_request(500, 0) + + if link is not None: + button = Gtk.Button(label=link) + button.set_margin_start(60) + button.set_margin_end(60) + button.connect("clicked", self._on_button_clicked, uid) + self.dialogBox.pack_end(button, False, False, 0) + + self.dialog.show_all() + self.dialog.connect("response", self._on_dialog_response, parent, command) + + def _on_button_clicked(self, button, uid): + label = button.get_label() + subprocess.Popen(['/usr/bin/env', 'bash', funcs, "open_user_workshop", uid]) + + def _on_dialog_response(self, dialog, resp, parent, command): + match resp: + case Gtk.ResponseType.DELETE_EVENT: + return + case Gtk.ResponseType.OK: + self.dialog.destroy() + proc = call_out(parent, "toggle", command.dict["label"]) + parent.grid.update_right_statusbar() + tooltip = format_metadata(command.dict["label"]) + parent.grid.update_statusbar(tooltip) + + + + class EntryDialog(GenericDialog): def __init__(self, parent, text, mode, link): super().__init__(parent, text, mode) From 34b3d3bc8cec5b20e66273f17c5ba11ff68afa9e Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Mon, 16 Dec 2024 14:49:55 +0900 Subject: [PATCH 2/2] chore: drop unused var --- dzgui.sh | 2 +- helpers/ui.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/dzgui.sh b/dzgui.sh index ff58bfe..a7aabc6 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -578,7 +578,7 @@ fetch_helpers_by_sum(){ [[ -f "$config_file" ]] && source "$config_file" declare -A sums sums=( - ["ui.py"]="24d0525e71c0725a1487926fae7330e4" + ["ui.py"]="0e3845ef150ee9863f9160c62dbb24f9" ["query_v2.py"]="55d339ba02512ac69de288eb3be41067" ["vdf2json.py"]="2f49f6f5d3af919bebaab2e9c220f397" ["funcs"]="4c1480fcfae15c4bc1c02a337d1de488" diff --git a/helpers/ui.py b/helpers/ui.py index d741ee0..793d552 100644 --- a/helpers/ui.py +++ b/helpers/ui.py @@ -2249,7 +2249,6 @@ class LinkDialog(GenericDialog): self.dialog.connect("response", self._on_dialog_response, parent, command) def _on_button_clicked(self, button, uid): - label = button.get_label() subprocess.Popen(['/usr/bin/env', 'bash', funcs, "open_user_workshop", uid]) def _on_dialog_response(self, dialog, resp, parent, command):