From 13ca7b04ef27178d3444d05da569fba544afafa1 Mon Sep 17 00:00:00 2001 From: Vishal Date: Mon, 3 Oct 2022 20:20:33 +0530 Subject: [PATCH 1/7] Update to Version 0.1.7 --- CHANGELOG.md | 6 +++++ index.json | 1 + plugin_manager.py | 60 ++++++++++++++++++++++++++++++++++++----------- 3 files changed, 53 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 779927a..ed4f1f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ ## Plugin Manager (dd-mm-yyyy) +### 0.1.7 (03-10-2022) + +- Added New Option in settings for Notifying new plugins. +- Added a Discord Button to join Bombsquad's Official Discord server. + + ### 0.1.6 (15-09-2022) - Distinguish the settings button with a cyan color (previously was green) in plugin manager window. diff --git a/index.json b/index.json index 363be82..376c192 100644 --- a/index.json +++ b/index.json @@ -1,6 +1,7 @@ { "plugin_manager_url": "http://github.com/bombsquad-community/plugin-manager/{content_type}/{tag}/plugin_manager.py", "versions": { + "0.1.7": null, "0.1.6": { "api_version": 7, "commit_sha": "2a7ad8e", diff --git a/plugin_manager.py b/plugin_manager.py index 399482c..f1697f1 100644 --- a/plugin_manager.py +++ b/plugin_manager.py @@ -20,7 +20,7 @@ _env = _ba.env() _uiscale = ba.app.ui.uiscale -PLUGIN_MANAGER_VERSION = "0.1.6" +PLUGIN_MANAGER_VERSION = "0.1.7" REPOSITORY_URL = "http://github.com/bombsquad-community/plugin-manager" CURRENT_TAG = "main" # XXX: Using https with `ba.open_url` seems to trigger a pop-up dialog box on @@ -36,6 +36,7 @@ REGEXP = { "plugin_entry_points": re.compile(b"(ba_meta export plugin\n+class )(.*)\\("), "minigames": re.compile(b"(ba_meta export game\n+class )(.*)\\("), } +DISCORD_URL = "https://ballistica.net/discord" _CACHE = {} @@ -124,7 +125,6 @@ class StartupTasks: plugin_manager_config = ba.app.config.setdefault("Community Plugin Manager", {}) plugin_manager_config.setdefault("Custom Sources", []) installed_plugins = plugin_manager_config.setdefault("Installed Plugins", {}) - for plugin_name in tuple(installed_plugins.keys()): plugin = PluginLocal(plugin_name) if not plugin.is_installed: @@ -135,6 +135,7 @@ class StartupTasks: "Auto Update Plugin Manager": True, "Auto Update Plugins": True, "Auto Enable Plugins After Installation": True, + "Notify New Plugins": True } settings = plugin_manager_config.setdefault("Settings", {}) @@ -174,12 +175,34 @@ class StartupTasks: plugins_to_update.append(plugin.update()) await asyncio.gather(*plugins_to_update) + async def notify_new_plugins(self): + if not ba.app.config["Community Plugin Manager"]["Settings"]["Notify New Plugins"]: + return + + await self.plugin_manager.setup_index() + try: + num_of_plugins = ba.app.config["Community Plugin Manager"]["Existing Number of Plugins"] + except Exception: + ba.app.config["Community Plugin Manager"]["Existing Number of Plugins"] = len(await self.plugin_manager.categories["All"].get_plugins()) + num_of_plugins = ba.app.config["Community Plugin Manager"]["Existing Number of Plugins"] + ba.app.config.commit() + return + + new_num_of_plugins = len(await self.plugin_manager.categories["All"].get_plugins()) + + if num_of_plugins < new_num_of_plugins: + ba.screenmessage("We got new Plugins for you to try!") + ba.app.config["Community Plugin Manager"]["Existing Number of Plugins"] = new_num_of_plugins + ba.app.config.commit() + + async def execute(self): self.setup_config() try: await asyncio.gather( self.update_plugin_manager(), self.update_plugins(), + self.notify_new_plugins(), ) except urllib.error.URLError: pass @@ -1678,7 +1701,7 @@ class PluginManagerSettingsWindow(popup.PopupWindow): scale=text_scale * 0.8) pos -= 34 * text_scale - pos = height - 220 + pos = height - 200 ba.textwidget(parent=self._root_widget, position=(width * 0.49, pos-5), size=(0, 0), @@ -1689,17 +1712,16 @@ class PluginManagerSettingsWindow(popup.PopupWindow): color=color, maxwidth=width * 0.95) - pos -= 45 - ba.textwidget(parent=self._root_widget, - position=(width * 0.22, pos-5), - size=(0, 0), - h_align='center', - v_align='center', - text=f'API Version: {ba.app.api_version}', - scale=text_scale * 0.7, - color=(0.4, 0.8, 1), - maxwidth=width * 0.95) - pos -= 25 + pos -= 75 + ba.buttonwidget(parent=self._root_widget, + position=((width * 0.20) - button_size[0] / 2, pos), + size=button_size, + on_activate_call=lambda: ba.open_url(DISCORD_URL), + textcolor=b_text_color, + button_type='square', + text_scale=1, + label='Discord') + ba.buttonwidget(parent=self._root_widget, position=((width * 0.49) - button_size[0] / 2, pos), size=button_size, @@ -1756,6 +1778,16 @@ class PluginManagerSettingsWindow(popup.PopupWindow): scale=text_scale * 0.8, color=text_color, maxwidth=width * 0.9) + pos -= 25 + ba.textwidget(parent=self._root_widget, + position=(width * 0.49, pos), + size=(0, 0), + h_align='center', + v_align='center', + text=f'API Version: {ba.app.api_version}', + scale=text_scale * 0.7, + color=(0.4, 0.8, 1), + maxwidth=width * 0.95) pos = height * 0.1 From 09991f7e796d04f7423522f7096b797d19ff7918 Mon Sep 17 00:00:00 2001 From: vishal332008 Date: Mon, 3 Oct 2022 17:02:09 +0000 Subject: [PATCH 2/7] [ci] auto-format --- plugin_manager.py | 1 - 1 file changed, 1 deletion(-) diff --git a/plugin_manager.py b/plugin_manager.py index f1697f1..eef9e53 100644 --- a/plugin_manager.py +++ b/plugin_manager.py @@ -195,7 +195,6 @@ class StartupTasks: ba.app.config["Community Plugin Manager"]["Existing Number of Plugins"] = new_num_of_plugins ba.app.config.commit() - async def execute(self): self.setup_config() try: From 8b12e00db6083536fee2d8068a1c9d72c0c5b49b Mon Sep 17 00:00:00 2001 From: vishal332008 Date: Mon, 3 Oct 2022 17:02:10 +0000 Subject: [PATCH 3/7] [ci] apply-version-metadata --- index.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/index.json b/index.json index 376c192..bd993c4 100644 --- a/index.json +++ b/index.json @@ -1,7 +1,12 @@ { "plugin_manager_url": "http://github.com/bombsquad-community/plugin-manager/{content_type}/{tag}/plugin_manager.py", "versions": { - "0.1.7": null, + "0.1.7": { + "api_version": 7, + "commit_sha": "09991f7", + "released_on": "03-10-2022", + "md5sum": "283fdf4b1b16102d77b8b67615780d5d" + }, "0.1.6": { "api_version": 7, "commit_sha": "2a7ad8e", From 6f9fc4baaa1d63f114cce35a6376f9d21096b1a5 Mon Sep 17 00:00:00 2001 From: Rikko Date: Mon, 3 Oct 2022 22:35:47 +0530 Subject: [PATCH 4/7] Plugin index: Avoid making multiple network requests in parallel --- index.json | 9 ++------- plugin_manager.py | 12 ++++++++++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/index.json b/index.json index bd993c4..bb9d90d 100644 --- a/index.json +++ b/index.json @@ -1,12 +1,7 @@ { "plugin_manager_url": "http://github.com/bombsquad-community/plugin-manager/{content_type}/{tag}/plugin_manager.py", "versions": { - "0.1.7": { - "api_version": 7, - "commit_sha": "09991f7", - "released_on": "03-10-2022", - "md5sum": "283fdf4b1b16102d77b8b67615780d5d" - }, + "0.1.7": null, "0.1.6": { "api_version": 7, "commit_sha": "2a7ad8e", @@ -32,4 +27,4 @@ "http://github.com/bombsquad-community/plugin-manager/{content_type}/{tag}/plugins/maps.json" ], "external_source_url": "http://github.com/{repository}/{content_type}/{tag}/category.json" -} \ No newline at end of file +} diff --git a/plugin_manager.py b/plugin_manager.py index eef9e53..618b139 100644 --- a/plugin_manager.py +++ b/plugin_manager.py @@ -920,6 +920,7 @@ class PluginManager: self._index = _CACHE.get("index", {}) self.categories = {} self.module_path = sys.modules[__name__].__file__ + self._index_setup_in_progress = False async def get_index(self): if not self._index: @@ -932,13 +933,20 @@ class PluginManager: headers=self.request_headers, ) response = await async_send_network_request(request) - self._index = json.loads(response.read()) - self.set_index_global_cache(self._index) + index = json.loads(response.read()) + self.set_index_global_cache(index) + self._index = index return self._index async def setup_index(self): + while self._index_setup_in_progress: + # Avoid making multiple network calls to the same resource in parallel. + # Rather wait for the previous network call to complete. + await asyncio.sleep(0.1) + self._index_setup_in_progress = not bool(self._index) index = await self.get_index() await self.setup_plugin_categories(index) + self._index_setup_in_progress = False async def setup_plugin_categories(self, plugin_index): # A hack to have the "All" category show at the top. From 3c2bde366de295e6fd503fa2efcd07196947216a Mon Sep 17 00:00:00 2001 From: rikkolovescats Date: Mon, 3 Oct 2022 17:06:37 +0000 Subject: [PATCH 5/7] [ci] apply-version-metadata --- index.json | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/index.json b/index.json index bb9d90d..1a360cf 100644 --- a/index.json +++ b/index.json @@ -1,7 +1,12 @@ { "plugin_manager_url": "http://github.com/bombsquad-community/plugin-manager/{content_type}/{tag}/plugin_manager.py", "versions": { - "0.1.7": null, + "0.1.7": { + "api_version": 7, + "commit_sha": "6f9fc4b", + "released_on": "03-10-2022", + "md5sum": "550215c42afa9b38bbc5e67bd0fc740f" + }, "0.1.6": { "api_version": 7, "commit_sha": "2a7ad8e", @@ -27,4 +32,4 @@ "http://github.com/bombsquad-community/plugin-manager/{content_type}/{tag}/plugins/maps.json" ], "external_source_url": "http://github.com/{repository}/{content_type}/{tag}/category.json" -} +} \ No newline at end of file From 2fe966ccae50ec41d32329438113769dba3820e4 Mon Sep 17 00:00:00 2001 From: Rikko Date: Tue, 4 Oct 2022 06:50:42 +0530 Subject: [PATCH 6/7] https -> http https://github.com/bombsquad-community/plugin-manager/pull/48#discussion_r986313257 --- index.json | 9 ++------- plugin_manager.py | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/index.json b/index.json index 1a360cf..bb9d90d 100644 --- a/index.json +++ b/index.json @@ -1,12 +1,7 @@ { "plugin_manager_url": "http://github.com/bombsquad-community/plugin-manager/{content_type}/{tag}/plugin_manager.py", "versions": { - "0.1.7": { - "api_version": 7, - "commit_sha": "6f9fc4b", - "released_on": "03-10-2022", - "md5sum": "550215c42afa9b38bbc5e67bd0fc740f" - }, + "0.1.7": null, "0.1.6": { "api_version": 7, "commit_sha": "2a7ad8e", @@ -32,4 +27,4 @@ "http://github.com/bombsquad-community/plugin-manager/{content_type}/{tag}/plugins/maps.json" ], "external_source_url": "http://github.com/{repository}/{content_type}/{tag}/category.json" -} \ No newline at end of file +} diff --git a/plugin_manager.py b/plugin_manager.py index 618b139..e1db5b8 100644 --- a/plugin_manager.py +++ b/plugin_manager.py @@ -36,7 +36,7 @@ REGEXP = { "plugin_entry_points": re.compile(b"(ba_meta export plugin\n+class )(.*)\\("), "minigames": re.compile(b"(ba_meta export game\n+class )(.*)\\("), } -DISCORD_URL = "https://ballistica.net/discord" +DISCORD_URL = "http://ballistica.net/discord" _CACHE = {} From b1daa236ce0b8a4dc91fb888c1bc20cc12f84bb5 Mon Sep 17 00:00:00 2001 From: rikkolovescats Date: Tue, 4 Oct 2022 01:22:43 +0000 Subject: [PATCH 7/7] [ci] apply-version-metadata --- index.json | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/index.json b/index.json index bb9d90d..e4e02ca 100644 --- a/index.json +++ b/index.json @@ -1,7 +1,12 @@ { "plugin_manager_url": "http://github.com/bombsquad-community/plugin-manager/{content_type}/{tag}/plugin_manager.py", "versions": { - "0.1.7": null, + "0.1.7": { + "api_version": 7, + "commit_sha": "2fe966c", + "released_on": "04-10-2022", + "md5sum": "78d7a6b3a62f8920d0da0acab20b419a" + }, "0.1.6": { "api_version": 7, "commit_sha": "2a7ad8e", @@ -27,4 +32,4 @@ "http://github.com/bombsquad-community/plugin-manager/{content_type}/{tag}/plugins/maps.json" ], "external_source_url": "http://github.com/{repository}/{content_type}/{tag}/category.json" -} +} \ No newline at end of file