diff --git a/dzgui/const/enum.py b/dzgui/const/enum.py index 147bfad..50b1755 100644 --- a/dzgui/const/enum.py +++ b/dzgui/const/enum.py @@ -9,6 +9,13 @@ class Port(Enum): CUSTOM = 2 +class ServerTab(Enum): + BROWSER = 1 + SAVED = 2 + RECENT = 3 + LAN = 4 + + class Popup(Enum): WAIT = 1 NOTIFY = 2 @@ -59,20 +66,47 @@ class EnumWithAttrs(Enum): def __init__(self, d: dict): self.dict = d + class Preferences(EnumWithAttrs): - STEAM = {"key": "steam_api",} - BM = {"key": "bm_api",} - CLIENT = {"key": "client",} - WINDOW = {"key": "fullscreen",} - DIST = {"key": "use_miles",} - NAME = {"key": "name",} - INSTALL = {"key": "auto_install",} - DEBUG = {"key": "debug",} - DEFAULT = {"key": "default_steam_path",} - FAV_LBL = {"key": "fav_label",} - FAV_SRV = {"key": "fav_server",} - IP_LIST = {"key": "ip_list",} - BRANCH = {"key": "branch",} + STEAM = { + "key": "steam_api", + } + BM = { + "key": "bm_api", + } + CLIENT = { + "key": "client", + } + WINDOW = { + "key": "fullscreen", + } + DIST = { + "key": "use_miles", + } + NAME = { + "key": "name", + } + INSTALL = { + "key": "auto_install", + } + DEBUG = { + "key": "debug", + } + DEFAULT = { + "key": "default_steam_path", + } + FAV_LBL = { + "key": "fav_label", + } + FAV_SRV = { + "key": "fav_server", + } + IP_LIST = { + "key": "ip_list", + } + BRANCH = { + "key": "branch", + } class NotebookPage(EnumWithAttrs): @@ -93,173 +127,53 @@ class RowType(EnumWithAttrs): for member in cls: if string == member.dict["label"]: return member - return RowType.DYNAMIC - # specialized behavior - # TODO: deprecated - DYNAMIC = { - "label": None, - "tooltip": None, - } - RESOLVE_IP = { - "label": "Resolve IP", - "tooltip": None, - "wait_msg": "Resolving remote IP", - } - HIGHLIGHT = { - "label": "Highlight stale", - "tooltip": None, - "wait_msg": "Looking for stale mods", - } - - # pages - SERVER_BROWSER = { - "label": "Server browser", - "tooltip": "Used to browse the global server list", - "type": "server", - } - SAVED_SERVERS = { - "label": "My saved servers", - "tooltip": "Browse your saved servers. Unreachable servers will be excluded", - "type": "server", - } - RECENT_SERVERS = { - "label": "Recent servers", - "tooltip": "Shows the last 10 servers you connected to (includes attempts)", - "type": "server", - } - SCAN_LAN = { - "label": "Scan LAN servers", - "tooltip": "Search for servers on your local network", - "type": "server", - } - LIST_MODS = { - "label": "Mods", - "tooltip": "Browse a list of locally-installed mods", - "quad_label": "Mods", - "type": "mods", - } + # TODO: add to strings + # SERVER_BROWSER = { + # "label": "Server browser", + # "tooltip": "Used to browse the global server list", + # "type": "server", + # } + # SAVED_SERVERS = { + # "label": "My saved servers", + # "tooltip": "Browse your saved servers. Unreachable servers will be excluded", + # "type": "server", + # } + # RECENT_SERVERS = { + # "label": "Recent servers", + # "tooltip": "Shows the last 10 servers you connected to (includes attempts)", + # "type": "server", + # } + # SCAN_LAN = { + # "label": "Scan LAN servers", + # "tooltip": "Search for servers on your local network", + # "type": "server", + # } + # LIST_MODS = { + # "label": "Mods", + # "tooltip": "Browse a list of locally-installed mods", + # "quad_label": "Mods", + # "type": "mods", + # } CHANGELOG = { "label": "View changelog", "tooltip": "Opens the DZGUI changelog", } - OPTIONS = {"label": "Options", "tooltip": None} - KEYBINDINGS = {"label": "Keybindings", "tooltip": None} SHOW_LOG = { "label": "Show debug log", "tooltip": "Read the DZGUI log generated since startup", "quad_label": "Debug log", } - - # interactive dialogs - CONN_BY_IP = { - "label": "Connect by IP", - "tooltip": "Connect to a server by IP", - "prompt": "Enter IP in IP:Queryport format (e.g. 192.168.1.1:27016)", - "link_label": None, - "type": Command.INTERACTIVE, - } - CONN_BY_ID = { - "label": "Connect by ID", - "tooltip": "Connect to a server by Battlemetrics ID", - "prompt": "Enter server ID", - "link_label": "Open Battlemetrics", - "type": Command.INTERACTIVE, - } SEPARATOR = { - "label" : "SEPARATOR", + "label": "SEPARATOR", "tooltip": "", } - ADD_BY_IP = { - "label": "Add server by IP", - "tooltip": "Add a server by IP", - "prompt": "Enter IP in IP:Queryport format (e.g. 192.168.1.1:27016)", - "link_label": None, - "type": Command.INTERACTIVE, - } - ADD_BY_ID = { - "label": "Add server by ID", - "tooltip": "Add a server by Battlemetrics ID", - "prompt": "Enter server ID", - "link_label": "Open Battlemetrics", - "type": Command.INTERACTIVE, - } - CHNG_FAV = { - "label": "Change favorite server", - "tooltip": "Update your quick-connect server", - "prompt": "Enter IP in IP:Queryport format (e.g. 192.168.1.1:27016)", - "link_label": None, - "alt": None, - "default": "unset", - "val": "fav_label", - "type": Command.INTERACTIVE, - } - CHNG_PLAYER = { - "label": "Change player name", - "tooltip": "Update your in-game name (required by some servers)", - "prompt": "Enter new nickname", - "link_label": None, - "alt": None, - "default": None, - "val": "name", - "type": Command.INTERACTIVE, - } - CHNG_STEAM_API = { - "label": "Change Steam API key", - "tooltip": "Can be used if you revoked an old API key", - "prompt": "Enter new API key", - "link_label": "Open Steam API page", - "type": Command.INTERACTIVE, - } - CHNG_BM_API = { - "label": "Change Battlemetrics API key", - "tooltip": "Can be used if you revoked an old API key", - "link_label": "Open Battlemetrics API page", - "prompt": "Enter new API key", - "type": Command.INTERACTIVE, - } - - # oneshot commands - QUICK_CONNECT = { - "label": "Quick-connect to favorite server", - "tooltip": "Connect to your favorite server", - "wait_msg": "Working", - "default": "unset", - "alt": None, - "val": "fav_label", - "type": Command.ONESHOT, - } - FORCE_UPDATE = { - "label": "Force update local mods", - "tooltip": "Synchronize local mods with remote versions (experimental)", - "wait_msg": "Updating mods", - "type": Command.ONESHOT, - } DUMP_LOG = { "label": "Output system info to log file", "tooltip": "Dump diagnostic data for troubleshooting", "wait_msg": "Generating log", "type": Command.ONESHOT, } - HANDSHAKE = { - "label": "Handshake", - "tooltip": None, - "wait_msg": "Waiting for DayZ", - "type": Command.ONESHOT, - } - HANDSHAKE_EXP = { - "label": "Handshake_EXP", - "tooltip": None, - "wait_msg": "Waiting for DayZ", - "type": Command.ONESHOT, - } - DELETE_SELECTED = { - "label": "Delete selected mods", - "tooltip": None, - "wait_msg": "Deleting mods", - "type": Command.ONESHOT, - } - # help pages DOCS = { "label": "Documentation/help files (GitHub) ⧉", @@ -315,12 +229,9 @@ class ContextMenuGroup(Enum): """ Groupings of context menu items """ - MOD = ( - ContextMenu.OPEN_WORKSHOP, ContextMenu.DELETE_MOD - ) - LOG = ( - ContextMenu.COPY_LOG_CLIPBOARD, - ) + + MOD = (ContextMenu.OPEN_WORKSHOP, ContextMenu.DELETE_MOD) + LOG = (ContextMenu.COPY_LOG_CLIPBOARD,) SERVER_BROWSER = ( ContextMenu.CONNECT, ContextMenu.ADD_SERVER, @@ -366,6 +277,7 @@ class ContextMenuGroup(Enum): ContextMenu.REFRESH_PLAYERS, ) + class ModButton(EnumWithAttrs): SELECT_ALL = { "label": strings.mod_panel.select_all, @@ -373,7 +285,7 @@ class ModButton(EnumWithAttrs): } UNSELECT_ALL = { "label": strings.mod_panel.unselect_all, - "tooltip": strings.mod_panel.unselect_all_tooltip + "tooltip": strings.mod_panel.unselect_all_tooltip, } HIGHLIGHT_STALE = { "label": strings.mod_panel.highlight_stale, @@ -388,8 +300,8 @@ class ModButton(EnumWithAttrs): "tooltip": strings.mod_panel.delete_selected_tooltip, } SELECT_STALE = { - "label": strings.mod_panel.select_stale, - "tooltip": strings.mod_panel.select_stale_tooltip, + "label": strings.mod_panel.select_stale, + "tooltip": strings.mod_panel.select_stale_tooltip, } @@ -407,8 +319,8 @@ class ButtonType(EnumWithAttrs): OPTIONS = { "label": strings.buttons.options_label, "tooltip": strings.buttons.options_tooltip, - "opens": NotebookPage.OPTIONS - } + "opens": NotebookPage.OPTIONS, + } HELP = { "label": strings.buttons.help_label, "tooltip": strings.buttons.help_tooltip, @@ -434,9 +346,3 @@ HELP_MENU_ROWS = ( RowType.SEPARATOR, RowType.THANKS, ) - -class ServerTab(Enum): - BROWSER = 1 - SAVED = 2 - RECENT = 3 - LAN = 4 diff --git a/dzgui/controllers/mc.py b/dzgui/controllers/mc.py index 4f8a8cc..7acdf4c 100644 --- a/dzgui/controllers/mc.py +++ b/dzgui/controllers/mc.py @@ -518,6 +518,7 @@ class Controller: except Exception as e: dialog = ExceptionDialog(self, str(e)) dialog.run() + return self.open_page(NotebookPage.LOG) def select_colorized(self) -> None: diff --git a/dzgui/util/open_links.py b/dzgui/util/open_links.py index 7d0f92e..60db2a6 100644 --- a/dzgui/util/open_links.py +++ b/dzgui/util/open_links.py @@ -12,10 +12,6 @@ links = { RowType.BUGS: endpoints.GITHUB_ISSUES, RowType.FORUM: endpoints.FORUM, RowType.SPONSOR: endpoints.SPONSORS, - RowType.CHNG_STEAM_API: endpoints.STEAM_API_SETUP, - RowType.CHNG_BM_API: endpoints.BM_API_SETUP, - RowType.CONN_BY_ID: endpoints.BM_BROWSE, - RowType.ADD_BY_ID: endpoints.BM_BROWSE, } diff --git a/dzgui/views/trees/tree_menu.py b/dzgui/views/trees/tree_menu.py index 953d300..de0b132 100644 --- a/dzgui/views/trees/tree_menu.py +++ b/dzgui/views/trees/tree_menu.py @@ -51,11 +51,6 @@ class MenuTreeView(TreeView): match row_type: case RowType.THANKS: self.controller.open_page(NotebookPage.THANKS) - case RowType.SERVER_BROWSER: - # TODO: add threading - # TODO: handle recent, saved, lan, etc. - # self.controller.open_page(NotebookPage.SERVERS) - return case RowType.SHOW_LOG: self.controller.populate_log() case RowType.CHANGELOG: