Clarify has_settings_ui and show_settings_ui

This commit is contained in:
Rikko 2022-12-05 22:47:33 +05:30 committed by GitHub
parent eb163cf860
commit c872c320c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -28,7 +28,7 @@ There are two different ways the plugin manager can be installed:
1. Download [plugin_manager.py](https://raw.githubusercontent.com/bombsquad-community/plugin-manager/main/plugin_manager.py) 1. Download [plugin_manager.py](https://raw.githubusercontent.com/bombsquad-community/plugin-manager/main/plugin_manager.py)
to your mods directory (check it out by going into your game's Settings -> Advanced -> Show Mods Folder). This is the to your mods directory (check it out by going into your game's Settings -> Advanced -> Show Mods Folder). This is the
recommended way (see below). recommended way (read next method to know why).
2. Another way is to add 2. Another way is to add
[plugin_manager.py](https://raw.githubusercontent.com/bombsquad-community/plugin-manager/main/plugin_manager.py) [plugin_manager.py](https://raw.githubusercontent.com/bombsquad-community/plugin-manager/main/plugin_manager.py)
@ -57,7 +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 - 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). 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. 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` class has methods `has_settings_ui` and `show_settings_ui`. - Plugin manager will also show and execute the settings icon if your `ba.Plugin` class has methods `has_settings_ui` and `show_settings_ui`; check out the [colorscheme](https://github.com/bombsquad-community/plugin-manager/blob/eb163cf86014b2a057c4a048dcfa3d5b540b7fe1/plugins/utilities/colorscheme.py#L448-L452) plugin for an example.
#### Example: #### Example:
@ -70,6 +70,12 @@ import ba
class Main(ba.Plugin): class Main(ba.Plugin):
def on_app_running(self): def on_app_running(self):
ba.screenmessage("Hi! I am a sample plugin!") ba.screenmessage("Hi! I am a sample plugin!")
def has_settings_ui(self):
return True
def show_settings_ui(self, source_widget):
ba.screenmessage("You tapped my settings!")
``` ```
You'll have to fork this repository and add your `sample_plugin.py` plugin file into the appropriate directory, which for You'll have to fork this repository and add your `sample_plugin.py` plugin file into the appropriate directory, which for
@ -130,6 +136,12 @@ index ebb7dcc..da2b312 100644
class Main(ba.Plugin): class Main(ba.Plugin):
def on_app_running(self): def on_app_running(self):
ba.screenmessage("Hi! I am a sample plugin!") ba.screenmessage("Hi! I am a sample plugin!")
def has_settings_ui(self):
return True
def show_settings_ui(self, source_widget):
- ba.screenmessage("You tapped my settings!")
+ ba.screenmessage("Hey! This is my new screenmessage!") + ba.screenmessage("Hey! This is my new screenmessage!")
``` ```