Added confirmation window

This commit is contained in:
Loup 2023-02-07 21:55:25 +05:30 committed by GitHub
parent d07794a05d
commit fe4d41177a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,7 +1,7 @@
# ba_meta require api 7
import ba
import _ba
from bastd.ui import popup
from bastd.ui import popup, confirm
import urllib.request
import http.client
@ -813,7 +813,6 @@ class PluginWindow(popup.PopupWindow):
async def draw_ui(self):
# print(ba.app.plugins.active_plugins)
play_sound()
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
@ -961,6 +960,43 @@ class PluginWindow(popup.PopupWindow):
rotate=25,
scale=0.45)
# Below snippet handles the tutorial button in the plugin window
tutorial_url = self.plugin.info["external_url"]
if tutorial_url:
def tutorial_confirm_window():
text="This will take you to \n\""+self.plugin.info["external_url"] + "\""
tutorial_confirm_window = confirm.ConfirmWindow(
text=text,
action=lambda: ba.open_url(self.plugin.info["external_url"]),
)
open_pos_x = (350 if _uiscale is ba.UIScale.SMALL else
410 if _uiscale is ba.UIScale.MEDIUM else 400)
open_pos_y = (100 if _uiscale is ba.UIScale.SMALL else
110 if _uiscale is ba.UIScale.MEDIUM else 120)
open_button = ba.buttonwidget(parent=self._root_widget,
autoselect=True,
position=(open_pos_x, open_pos_y),
size=(40, 40),
button_type="square",
label="",
# color=ba.app.ui.title_color,
color=(0.6, 0.53, 0.63),
on_activate_call=tutorial_confirm_window)
ba.imagewidget(parent=self._root_widget,
position=(open_pos_x, open_pos_y),
size=(40, 40),
color=(0.8, 0.95, 1),
texture=ba.gettexture("frameInset"),
draw_controller=open_button)
ba.textwidget(parent=self._root_widget,
position=(open_pos_x - 3, open_pos_y + 12),
text="Tutorial",
size=(10, 10),
draw_controller=open_button,
color=(1, 1, 1, 1),
rotate=25,
scale=0.45)
if to_draw_button4:
settings_pos_x = (60 if _uiscale is ba.UIScale.SMALL else
60 if _uiscale is ba.UIScale.MEDIUM else 60)