Merge pull request #97 from kingsamurai123/autoformat-description

Add partition function
This commit is contained in:
Rikko 2023-01-18 19:06:05 +05:30 committed by GitHub
commit abcf2b57f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 6 deletions

View file

@ -1,5 +1,10 @@
## Plugin Manager (dd-mm-yyyy) ## Plugin Manager (dd-mm-yyyy)
### 0.2.2 (18-01-2022)
- Auto add new line breaks in long plugin descriptions.
- Fixed an issue where pressing back on the main plugin manager window would play the sound twice.
### 0.2.1 (17-12-2022) ### 0.2.1 (17-12-2022)
- Add Google DNS as a fallback for Jio ISP DNS blocking resolution of raw.githubusercontent.com domain. - Add Google DNS as a fallback for Jio ISP DNS blocking resolution of raw.githubusercontent.com domain.

View file

@ -1,6 +1,12 @@
{ {
"plugin_manager_url": "https://github.com/bombsquad-community/plugin-manager/{content_type}/{tag}/plugin_manager.py", "plugin_manager_url": "https://github.com/bombsquad-community/plugin-manager/{content_type}/{tag}/plugin_manager.py",
"versions": { "versions": {
"0.2.2": {
"api_version": 7,
"commit_sha": "2672a5a",
"released_on": "18-01-2023",
"md5sum": "2ef9761e4a02057cd93db3d280427f12"
},
"0.2.1": { "0.2.1": {
"api_version": 7, "api_version": 7,
"commit_sha": "8ac1032", "commit_sha": "8ac1032",

View file

@ -24,7 +24,7 @@ _env = _ba.env()
_uiscale = ba.app.ui.uiscale _uiscale = ba.app.ui.uiscale
PLUGIN_MANAGER_VERSION = "0.2.1" PLUGIN_MANAGER_VERSION = "0.2.2"
REPOSITORY_URL = "https://github.com/bombsquad-community/plugin-manager" REPOSITORY_URL = "https://github.com/bombsquad-community/plugin-manager"
CURRENT_TAG = "main" CURRENT_TAG = "main"
INDEX_META = "{repository_url}/{content_type}/{tag}/index.json" INDEX_META = "{repository_url}/{content_type}/{tag}/index.json"
@ -788,8 +788,32 @@ class PluginWindow(popup.PopupWindow):
loop = asyncio.get_event_loop() loop = asyncio.get_event_loop()
loop.create_task(self.draw_ui()) loop.create_task(self.draw_ui())
def get_description(self, minimum_character_offset=40):
"""
Splits the loong plugin description into multiple lines.
"""
string = self.plugin.info["description"]
string_length = len(string)
partitioned_string = ""
partitioned_string_length = len(partitioned_string)
while partitioned_string_length != string_length:
next_empty_space = string[partitioned_string_length +
minimum_character_offset:].find(" ")
next_word_end_position = partitioned_string_length + \
minimum_character_offset + max(0, next_empty_space)
partitioned_string += string[partitioned_string_length:next_word_end_position]
if next_empty_space != -1:
# Insert a line break here, there's still more partitioning to do.
partitioned_string += "\n"
partitioned_string_length = len(partitioned_string)
return partitioned_string
async def draw_ui(self): async def draw_ui(self):
# print(ba.app.plugins.active_plugins) # print(ba.app.plugins.active_plugins)
play_sound() play_sound()
b_text_color = (0.75, 0.7, 0.8) b_text_color = (0.75, 0.7, 0.8)
s = 1.1 if _uiscale is ba.UIScale.SMALL else 1.27 if ba.UIScale.MEDIUM else 1.57 s = 1.1 if _uiscale is ba.UIScale.SMALL else 1.27 if ba.UIScale.MEDIUM else 1.57
@ -837,7 +861,7 @@ class PluginWindow(popup.PopupWindow):
ba.textwidget(parent=self._root_widget, ba.textwidget(parent=self._root_widget,
position=(width * 0.49, pos), size=(0, 0), position=(width * 0.49, pos), size=(0, 0),
h_align='center', v_align='center', h_align='center', v_align='center',
text=self.plugin.info["description"], text=self.get_description(),
scale=text_scale * 0.6, color=color, scale=text_scale * 0.6, color=color,
maxwidth=width * 0.95) maxwidth=width * 0.95)
b1_color = None b1_color = None
@ -1420,7 +1444,6 @@ class PluginManagerWindow(ba.Window):
) )
def _back(self) -> None: def _back(self) -> None:
play_sound()
from bastd.ui.settings.allsettings import AllSettingsWindow from bastd.ui.settings.allsettings import AllSettingsWindow
ba.containerwidget(edit=self._root_widget, ba.containerwidget(edit=self._root_widget,
transition=self._transition_out) transition=self._transition_out)

View file

@ -482,7 +482,7 @@
} }
}, },
"pro_unlocker": { "pro_unlocker": {
"description": "Unlocks some pro-only features - custom colors, playlist maker, etc.\n(Please support the game developer if you can!)", "description": "Unlocks some pro-only features - custom colors, playlist maker, etc. (Please support the game developer if you can!)",
"external_url": "", "external_url": "",
"authors": [ "authors": [
{ {
@ -558,7 +558,7 @@
} }
}, },
"bomb_radius_visualizer": { "bomb_radius_visualizer": {
"description": "With this cutting edge technology, you precisely know\nhow close to the bomb you can tread.\nSupports modified blast radius values!", "description": "With this cutting edge technology, you precisely know how close to the bomb you can tread. Supports modified blast radius values!",
"external_url": "", "external_url": "",
"authors": [ "authors": [
{ {
@ -615,7 +615,7 @@
} }
}, },
"autorun": { "autorun": {
"description": "Run without holding any buttons. Made for beginners or players on mobile.\nKeeps your character maneuverable. Start running as usual to override.", "description": "Run without holding any buttons. Made for beginners or players on mobile. Keeps your character maneuverable. Start running as usual to override.",
"external_url": "", "external_url": "",
"authors": [ "authors": [
{ {