An Update

This commit is contained in:
Vishal 2022-09-05 21:59:10 +05:30 committed by GitHub
parent 92b80eae1e
commit 5c286a8078
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 8 deletions

View File

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

View File

@ -20,12 +20,12 @@ class ServerDialogWindow(ba.Window):
self._dialog_id = data['dialogID'] self._dialog_id = data['dialogID']
txt = ba.Lstr(translate=('serverResponses', data['text']), txt = ba.Lstr(translate=('serverResponses', data['text']),
subs=data.get('subs', [])).evaluate() subs=data.get('subs', [])).evaluate()
self.txt = txt.strip() txt = txt.strip()
txt_scale = 1.5 txt_scale = 1.5
txt_height = (_ba.get_string_height(self.txt, suppress_warning=True) * txt_height = (_ba.get_string_height(txt, suppress_warning=True) *
txt_scale) txt_scale)
self._width = 500 self._width = 500
self._height = 130 + min(200, txt_height) self._height = 160 + min(200, txt_height)
uiscale = ba.app.ui.uiscale uiscale = ba.app.ui.uiscale
super().__init__(root_widget=ba.containerwidget( super().__init__(root_widget=ba.containerwidget(
size=(self._width, self._height), size=(self._width, self._height),
@ -43,11 +43,11 @@ class ServerDialogWindow(ba.Window):
scale=txt_scale, scale=txt_scale,
h_align='center', h_align='center',
v_align='center', v_align='center',
text=self.txt, text=txt,
maxwidth=self._width * 0.85, maxwidth=self._width * 0.85,
max_height=(self._height - 110)) max_height=(self._height - 110))
show_cancel = data.get('showCancel', True) show_cancel = data.get('showCancel', True)
show_copy = ba.clipboard_is_supported() self.copy_text = data.get('copyText', None)
self._cancel_button: ba.Widget | None self._cancel_button: ba.Widget | None
self._copy_button: ba.Widget | None self._copy_button: ba.Widget | None
if show_cancel: if show_cancel:
@ -58,7 +58,7 @@ class ServerDialogWindow(ba.Window):
autoselect=True, autoselect=True,
label=ba.Lstr(resource='cancelText'), label=ba.Lstr(resource='cancelText'),
on_activate_call=self._cancel_press) on_activate_call=self._cancel_press)
elif show_copy: elif self.copy_text is not None:
self._cancel_button = None self._cancel_button = None
self._copy_button = ba.buttonwidget( self._copy_button = ba.buttonwidget(
parent=self._root_widget, parent=self._root_widget,
@ -73,7 +73,7 @@ class ServerDialogWindow(ba.Window):
self._ok_button = ba.buttonwidget( self._ok_button = ba.buttonwidget(
parent=self._root_widget, parent=self._root_widget,
position=((self._width - 182) if show_cancel else position=((self._width - 182) if show_cancel else
(self._width - 182) if show_copy else (self._width - 182) if self.copy_text is not None else
(self._width * 0.5 - 80), 30), (self._width * 0.5 - 80), 30),
size=(160, 60), size=(160, 60),
autoselect=True, autoselect=True,
@ -85,7 +85,7 @@ class ServerDialogWindow(ba.Window):
selected_child=self._ok_button) selected_child=self._ok_button)
def _copy_press(self) -> None: def _copy_press(self) -> None:
ba.clipboard_set_text(self.txt) ba.clipboard_set_text(self.copy_text)
ba.screenmessage('Copied To Clipboard', color = (0, 1, 0)) ba.screenmessage('Copied To Clipboard', color = (0, 1, 0))
def _ok_press(self) -> None: def _ok_press(self) -> None: