def __init__(self, data: Dict[str, Any]): from ba.internal import is_browser_likely_available ba.set_analytics_screen('Friend Promo Code') self._width = 650 self._height = 400 uiscale = ba.app.uiscale super().__init__(root_widget=ba.containerwidget( size=(self._width, self._height), color=(0.45, 0.63, 0.15), transition='in_scale', scale=(1.7 if uiscale is ba.UIScale.SMALL else 1.35 if uiscale is ba.UIScale.MEDIUM else 1.0))) self._data = copy.deepcopy(data) ba.playsound(ba.getsound('cashRegister')) ba.playsound(ba.getsound('swish')) self._cancel_button = ba.buttonwidget(parent=self._root_widget, scale=0.7, position=(50, self._height - 50), size=(60, 60), label='', on_activate_call=self.close, autoselect=True, color=(0.45, 0.63, 0.15), icon=ba.gettexture('crossOut'), iconscale=1.2) ba.containerwidget(edit=self._root_widget, cancel_button=self._cancel_button) ba.textwidget( parent=self._root_widget, position=(self._width * 0.5, self._height * 0.8), size=(0, 0), color=ba.app.ui.infotextcolor, scale=1.0, flatness=1.0, h_align='center', v_align='center', text=ba.Lstr(resource='gatherWindow.shareThisCodeWithFriendsText'), maxwidth=self._width * 0.85) ba.textwidget(parent=self._root_widget, position=(self._width * 0.5, self._height * 0.645), size=(0, 0), color=(1.0, 3.0, 1.0), scale=2.0, h_align='center', v_align='center', text=data['code'], maxwidth=self._width * 0.85) award_str: Optional[Union[str, ba.Lstr]] if self._data['awardTickets'] != 0: award_str = ba.Lstr( resource='gatherWindow.friendPromoCodeAwardText', subs=[('${COUNT}', str(self._data['awardTickets']))]) else: award_str = '' ba.textwidget( parent=self._root_widget, position=(self._width * 0.5, self._height * 0.37), size=(0, 0), color=ba.app.ui.infotextcolor, scale=1.0, flatness=1.0, h_align='center', v_align='center', text=ba.Lstr( value='${A}\n${B}\n${C}\n${D}', subs=[ ('${A}', ba.Lstr( resource='gatherWindow.friendPromoCodeRedeemLongText', subs=[('${COUNT}', str(self._data['tickets'])), ('${MAX_USES}', str(self._data['usesRemaining']))])), ('${B}', ba.Lstr(resource=( 'gatherWindow.friendPromoCodeWhereToEnterText'))), ('${C}', award_str), ('${D}', ba.Lstr(resource='gatherWindow.friendPromoCodeExpireText', subs=[('${EXPIRE_HOURS}', str(self._data['expireHours']))])) ]), maxwidth=self._width * 0.9, max_height=self._height * 0.35) if is_browser_likely_available(): xoffs = 0 ba.buttonwidget(parent=self._root_widget, size=(200, 40), position=(self._width * 0.5 - 100 + xoffs, 39), autoselect=True, label=ba.Lstr(resource='gatherWindow.emailItText'), on_activate_call=ba.WeakCall(self._email))
def __init__(self, account_id: str, profile_id: str = None, position: Tuple[float, float] = (0.0, 0.0), scale: float = None, offset: Tuple[float, float] = (0.0, 0.0)): from ba.internal import is_browser_likely_available, master_server_get self._account_id = account_id self._profile_id = profile_id uiscale = ba.app.uiscale if scale is None: scale = (2.6 if uiscale is ba.UIScale.SMALL else 1.8 if uiscale is ba.UIScale.MEDIUM else 1.4) self._transitioning_out = False self._width = 400 self._height = (300 if uiscale is ba.UIScale.SMALL else 400 if uiscale is ba.UIScale.MEDIUM else 450) self._subcontainer: Optional[ba.Widget] = None bg_color = (0.5, 0.4, 0.6) # Creates our _root_widget. popup.PopupWindow.__init__(self, position=position, size=(self._width, self._height), scale=scale, bg_color=bg_color, offset=offset) self._cancel_button = ba.buttonwidget( parent=self.root_widget, position=(50, self._height - 30), size=(50, 50), scale=0.5, label='', color=bg_color, on_activate_call=self._on_cancel_press, autoselect=True, icon=ba.gettexture('crossOut'), iconscale=1.2) self._title_text = ba.textwidget( parent=self.root_widget, position=(self._width * 0.5, self._height - 20), size=(0, 0), h_align='center', v_align='center', scale=0.6, text=ba.Lstr(resource='playerInfoText'), maxwidth=200, color=(0.7, 0.7, 0.7, 0.7)) self._scrollwidget = ba.scrollwidget(parent=self.root_widget, size=(self._width - 60, self._height - 70), position=(30, 30), capture_arrows=True, simple_culling_v=10) ba.widget(edit=self._scrollwidget, autoselect=True) self._loading_text = ba.textwidget( parent=self._scrollwidget, scale=0.5, text=ba.Lstr(value='${A}...', subs=[('${A}', ba.Lstr(resource='loadingText'))]), size=(self._width - 60, 100), h_align='center', v_align='center') # In cases where the user most likely has a browser/email, lets # offer a 'report this user' button. if (is_browser_likely_available() and _ba.get_account_misc_read_val( 'showAccountExtrasMenu', False)): self._extras_menu_button = ba.buttonwidget( parent=self.root_widget, size=(20, 20), position=(self._width - 60, self._height - 30), autoselect=True, label='...', button_type='square', color=(0.64, 0.52, 0.69), textcolor=(0.57, 0.47, 0.57), on_activate_call=self._on_extras_menu_press) ba.containerwidget(edit=self.root_widget, cancel_button=self._cancel_button) master_server_get('bsAccountInfo', { 'buildNumber': ba.app.build_number, 'accountID': self._account_id, 'profileID': self._profile_id }, callback=ba.WeakCall(self._on_query_response))
def __init__(self, origin_widget: ba.Widget): from ba.internal import is_browser_likely_available logincode = '1412345' address = ( f'{_ba.get_master_server_address(version=2)}?login={logincode}') self._width = 600 self._height = 500 uiscale = ba.app.ui.uiscale super().__init__(root_widget=ba.containerwidget( size=(self._width, self._height), transition='in_scale', scale_origin_stack_offset=origin_widget.get_screen_space_center(), scale=(1.25 if uiscale is ba.UIScale.SMALL else 1.0 if uiscale is ba.UIScale.MEDIUM else 0.85))) ba.textwidget( parent=self._root_widget, position=(self._width * 0.5, self._height - 85), size=(0, 0), text=ba.Lstr( resource='accountSettingsWindow.v2LinkInstructionsText'), color=ba.app.ui.title_color, maxwidth=self._width * 0.9, h_align='center', v_align='center') button_width = 450 if is_browser_likely_available(): ba.buttonwidget(parent=self._root_widget, position=((self._width * 0.5 - button_width * 0.5), self._height - 175), autoselect=True, size=(button_width, 60), label=ba.Lstr(value=address), color=(0.55, 0.5, 0.6), textcolor=(0.75, 0.7, 0.8), on_activate_call=lambda: ba.open_url(address)) qroffs = 0.0 else: ba.textwidget(parent=self._root_widget, position=(self._width * 0.5, self._height - 135), size=(0, 0), text=ba.Lstr(value=address), flatness=1.0, maxwidth=self._width, scale=0.75, h_align='center', v_align='center') qroffs = 20.0 self._cancel_button = ba.buttonwidget( parent=self._root_widget, position=(30, self._height - 55), size=(130, 50), scale=0.8, label=ba.Lstr(resource='cancelText'), # color=(0.6, 0.5, 0.6), on_activate_call=self._done, autoselect=True, textcolor=(0.75, 0.7, 0.8), # icon=ba.gettexture('crossOut'), # iconscale=1.2 ) ba.containerwidget(edit=self._root_widget, cancel_button=self._cancel_button) qr_size = 270 ba.imagewidget(parent=self._root_widget, position=(self._width * 0.5 - qr_size * 0.5, self._height * 0.34 + qroffs - qr_size * 0.5), size=(qr_size, qr_size), texture=_ba.get_qrcode_texture(address))