Merge pull request #86 from Freaku17/main

Replace `on_plugin_manager_prompt` to default plugin setting ui
This commit is contained in:
Rikko 2022-12-05 22:23:08 +05:30 committed by GitHub
commit eb163cf860
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 48 additions and 24 deletions

View file

@ -1,5 +1,13 @@
## Plugin Manager (dd-mm-yyyy)
### 0.2.0 (05-12-2022)
- Removed `on_plugin_manager_prompt` and replaced it with the in-game's plugin settings ui
### 0.1.10 (05-12-2022)
- Added Discord and Github textures on buttons
### 0.1.9 (03-12-2022)
- Search now filters on author names and plugin description.

View file

@ -57,10 +57,7 @@ There are two different ways the plugin manager can be installed:
- New plugins are accepted through a [pull request](../../compare). Add your plugin in the minigames, utilities, or
the category directory you feel is the most relevant to the type of plugin you're submitting, [here](plugins).
Then add an entry to the category's JSON metadata file.
- Plugin manager will also show and execute the settings icon if your `ba.Plugin` export class has a method named
`on_plugin_manager_prompt`; check out the
[colorscheme](https://github.com/bombsquad-community/plugin-manager/blob/f24f0ca5ded427f6041795021f1af2e6a08b6ce9/plugins/utilities/colorscheme.py#L419-L420)
plugin as an example and its behaviour when the settings icon is tapped via the plugin manager in-game.
- Plugin manager will also show and execute the settings icon if your `ba.Plugin` class has methods `has_settings_ui` and `show_settings_ui`.
#### Example:
@ -73,9 +70,6 @@ import ba
class Main(ba.Plugin):
def on_app_running(self):
ba.screenmessage("Hi! I am a sample plugin!")
def on_plugin_manager_prompt(self):
ba.screenmessage("You tapped my settings from the Plugin Manager Window!")
```
You'll have to fork this repository and add your `sample_plugin.py` plugin file into the appropriate directory, which for
@ -137,9 +131,6 @@ index ebb7dcc..da2b312 100644
def on_app_running(self):
ba.screenmessage("Hi! I am a sample plugin!")
+ ba.screenmessage("Hey! This is my new screenmessage!")
def on_plugin_manager_prompt(self):
ba.screenmessage("You tapped my settings from the Plugin Manager Window!")
```
To name this new version as `1.1.0`, add `"1.1.0": null,` just above the previous plugin version in `utilities.json`:

View file

@ -1,6 +1,12 @@
{
"plugin_manager_url": "https://github.com/bombsquad-community/plugin-manager/{content_type}/{tag}/plugin_manager.py",
"versions": {
"0.2.0": {
"api_version": 7,
"commit_sha": "bd9dc14",
"released_on": "05-12-2022",
"md5sum": "3633c9c58037cbad7d2942858270c4ae"
},
"0.1.10": {
"api_version": 7,
"commit_sha": "e122d0f",

View file

@ -20,7 +20,7 @@ _env = _ba.env()
_uiscale = ba.app.ui.uiscale
PLUGIN_MANAGER_VERSION = "0.1.10"
PLUGIN_MANAGER_VERSION = "0.2.0"
REPOSITORY_URL = "https://github.com/bombsquad-community/plugin-manager"
CURRENT_TAG = "main"
INDEX_META = "{repository_url}/{content_type}/{tag}/index.json"
@ -364,13 +364,12 @@ class PluginLocal:
def has_settings(self):
for plugin_entry_point, plugin_class in ba.app.plugins.active_plugins.items():
if plugin_entry_point.startswith(self._entry_point_initials):
return hasattr(plugin_class, "on_plugin_manager_prompt")
return False
return plugin_class.has_settings_ui()
def launch_settings(self):
def launch_settings(self, source_widget):
for plugin_entry_point, plugin_class in ba.app.plugins.active_plugins.items():
if plugin_entry_point.startswith(self._entry_point_initials):
return plugin_class.on_plugin_manager_prompt()
return plugin_class.show_settings_ui(source_widget)
async def get_content(self):
if self._content is None:
@ -851,8 +850,10 @@ class PluginWindow(popup.PopupWindow):
size=(40, 40),
button_type="square",
label="",
color=(0, 0.75, 0.75),
on_activate_call=self.settings)
color=(0, 0.75, 0.75),)
ba.buttonwidget(
edit=settings_button,
on_activate_call=ba.Call(self.settings, settings_button),)
ba.imagewidget(parent=self._root_widget,
position=(settings_pos_x, settings_pos_y),
size=(40, 40),
@ -883,8 +884,8 @@ class PluginWindow(popup.PopupWindow):
return wrapper
def settings(self):
self.local_plugin.launch_settings()
def settings(self, source_widget):
self.local_plugin.launch_settings(source_widget)
@button
def disable(self) -> None:

View file

@ -14,6 +14,12 @@
}
],
"versions": {
"1.2.1": {
"api_version": 7,
"commit_sha": "7753b87",
"released_on": "05-12-2022",
"md5sum": "7ab5c7ebd43ebd929866fccb82cd5a45"
},
"1.2.0": {
"api_version": 7,
"commit_sha": "f07d2f8",
@ -145,6 +151,12 @@
}
],
"versions": {
"1.2.2": {
"api_version": 7,
"commit_sha": "7753b87",
"released_on": "05-12-2022",
"md5sum": "c6e5366b446e265c623e34010d5c40c7"
},
"1.2.1": {
"api_version": 7,
"commit_sha": "2fda676",
@ -181,6 +193,12 @@
}
],
"versions": {
"1.2.3": {
"api_version": 7,
"commit_sha": "7753b87",
"released_on": "05-12-2022",
"md5sum": "659794e1fa1e87cf9768899519994eac"
},
"1.2.2": {
"api_version": 7,
"commit_sha": "a6d1a43",

View file

@ -445,5 +445,8 @@ class Main(ba.Plugin):
def on_app_running(self):
load_plugin()
def on_plugin_manager_prompt(self):
def has_settings_ui(self):
return True
def show_settings_ui(self, source_widget):
launch_colorscheme_selection_window()

View file

@ -287,7 +287,7 @@ class moodlight(ba.Plugin):
def on_app_running(self):
_ba.show_progress_bar()
def on_plugin_manager_prompt(self):
def show_settings_ui(self, source_widget):
SettingWindow()
def has_settings_ui(self):

View file

@ -262,6 +262,3 @@ class Loup(ba.Plugin):
def show_settings_ui(self, button):
SettingWindow()
def on_plugin_manager_prompt(self):
SettingWindow()