Merge pull request #503 from vishal332008/master

PB-ID Copy Button
This commit is contained in:
Eric Froemling 2022-09-05 11:40:20 -05:00 committed by GitHub
commit eb9ce9fb3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 3 deletions

View File

@ -35,3 +35,7 @@
### Easy10781
- Added feature
### Vishal332008
- Bug Fixer
- Modder

View File

@ -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={

View File

@ -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: