diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index ae0de83b..79ecd547 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -35,3 +35,7 @@ ### Easy10781 - Added feature + +### Vishal332008 +- Bug Fixer +- Modder \ No newline at end of file diff --git a/assets/src/ba_data/python/bastd/actor/popuptext.py b/assets/src/ba_data/python/bastd/actor/popuptext.py index d078e7ea..ab270dd7 100644 --- a/assets/src/ba_data/python/bastd/actor/popuptext.py +++ b/assets/src/ba_data/python/bastd/actor/popuptext.py @@ -36,9 +36,9 @@ class PopupText(ba.Actor): if len(color) == 3: color = (color[0], color[1], color[2], 1.0) pos = (position[0] + offset[0] + random_offset * - (0.5 - random.random()), position[1] + offset[0] + + (0.5 - random.random()), position[1] + offset[1] + random_offset * (0.5 - random.random()), position[2] + - offset[0] + random_offset * (0.5 - random.random())) + offset[2] + random_offset * (0.5 - random.random())) self.node = ba.newnode('text', attrs={ diff --git a/assets/src/ba_data/python/bastd/ui/serverdialog.py b/assets/src/ba_data/python/bastd/ui/serverdialog.py index 40c64436..02c0503b 100644 --- a/assets/src/ba_data/python/bastd/ui/serverdialog.py +++ b/assets/src/ba_data/python/bastd/ui/serverdialog.py @@ -26,7 +26,7 @@ class ServerDialogWindow(ba.Window): txt_height = (_ba.get_string_height(txt, suppress_warning=True) * txt_scale) self._width = 500 - self._height = 130 + min(200, txt_height) + self._height = 160 + min(200, txt_height) uiscale = ba.app.ui.uiscale super().__init__(root_widget=ba.containerwidget( size=(self._width, self._height), @@ -48,7 +48,9 @@ class ServerDialogWindow(ba.Window): maxwidth=self._width * 0.85, max_height=(self._height - 110)) show_cancel = data.get('showCancel', True) + self.copy_text = data.get('copyText', None) self._cancel_button: ba.Widget | None + self._copy_button: ba.Widget | None if show_cancel: self._cancel_button = ba.buttonwidget( parent=self._root_widget, @@ -57,11 +59,22 @@ class ServerDialogWindow(ba.Window): autoselect=True, label=ba.Lstr(resource='cancelText'), on_activate_call=self._cancel_press) + elif self.copy_text is not None: + self._cancel_button = None + self._copy_button = ba.buttonwidget( + parent=self._root_widget, + position=(30, 30), + size=(160, 60), + autoselect=True, + label=ba.Lstr(resource='copyText'), + on_activate_call=self._copy_press) else: self._cancel_button = None + self._copy_button = None self._ok_button = ba.buttonwidget( parent=self._root_widget, position=((self._width - 182) if show_cancel else + (self._width - 182) if self.copy_text is not None else (self._width * 0.5 - 80), 30), size=(160, 60), autoselect=True, @@ -72,6 +85,10 @@ class ServerDialogWindow(ba.Window): start_button=self._ok_button, selected_child=self._ok_button) + def _copy_press(self) -> None: + ba.clipboard_set_text(self.copy_text) + ba.screenmessage('Copied To Clipboard', color = (0, 1, 0)) + def _ok_press(self) -> None: if ba.time(ba.TimeType.REAL, ba.TimeFormat.MILLISECONDS) - self._starttime < 1000: