Esempio n. 1
0
    def _confirm_leave_party(self) -> None:
        # pylint: disable=cyclic-import
        from bastd.ui.confirm import ConfirmWindow

        # Select cancel by default; this occasionally gets called by accident
        # in a fit of button mashing and this will help reduce damage.
        ConfirmWindow(ba.Lstr(resource=self._r + '.leavePartyConfirmText'),
                      self._leave_party,
                      cancel_is_selected=True)
Esempio n. 2
0
 def show_global_profile_info(self) -> None:
     """Show an explanation of global profiles."""
     from bastd.ui.confirm import ConfirmWindow
     txtl = ba.Lstr(resource='editProfileWindow.globalProfileInfoText')
     ConfirmWindow(txtl,
                   cancel_button=False,
                   width=600,
                   height=250,
                   origin_widget=self._account_type_info_button)
Esempio n. 3
0
    def _confirm_end_game(self) -> None:
        # pylint: disable=cyclic-import
        from bastd.ui.confirm import ConfirmWindow
        # FIXME: Currently we crash calling this on client-sessions.

        # Select cancel by default; this occasionally gets called by accident
        # in a fit of button mashing and this will help reduce damage.
        ConfirmWindow(ba.Lstr(resource=self._r + '.exitToMenuText'),
                      self._end_game,
                      cancel_is_selected=True)
Esempio n. 4
0
def show_sign_in_prompt(account_type: str = None) -> None:
    """Bring up a prompt telling the user they must sign in."""
    from bastd.ui.confirm import ConfirmWindow
    from bastd.ui.account import settings
    if account_type == 'Google Play':
        ConfirmWindow(
            ba.Lstr(resource='notSignedInGooglePlayErrorText'),
            lambda: _ba.sign_in_v1('Google Play'),
            ok_text=ba.Lstr(resource='accountSettingsWindow.signInText'),
            width=460,
            height=130)
    else:
        ConfirmWindow(
            ba.Lstr(resource='notSignedInErrorText'),
            lambda: settings.AccountSettingsWindow(modal=True,
                                                   close_once_signed_in=True),
            ok_text=ba.Lstr(resource='accountSettingsWindow.signInText'),
            width=460,
            height=130)
Esempio n. 5
0
    def buy(self, item: str) -> None:
        """Attempt to purchase the provided item."""
        from ba.internal import (get_available_sale_time,
                                 get_store_item_name_translated)
        from bastd.ui import account
        from bastd.ui.confirm import ConfirmWindow
        from bastd.ui import getcurrency

        # Prevent pressing buy within a few seconds of the last press
        # (gives the buttons time to disable themselves and whatnot).
        curtime = ba.time(ba.TimeType.REAL)
        if self._last_buy_time is not None and (curtime -
                                                self._last_buy_time) < 2.0:
            ba.playsound(ba.getsound('error'))
        else:
            if _ba.get_account_state() != 'signed_in':
                account.show_sign_in_prompt()
            else:
                self._last_buy_time = curtime

                # Pro is an actual IAP; the rest are ticket purchases.
                if item == 'pro':
                    ba.playsound(ba.getsound('click01'))

                    # Purchase either pro or pro_sale depending on whether
                    # there is a sale going on.
                    self._do_purchase_check('pro' if get_available_sale_time(
                        'extras') is None else 'pro_sale')
                else:
                    price = _ba.get_account_misc_read_val(
                        'price.' + item, None)
                    our_tickets = _ba.get_account_ticket_count()
                    if price is not None and our_tickets < price:
                        ba.playsound(ba.getsound('error'))
                        getcurrency.show_get_tickets_prompt()
                    else:

                        def do_it() -> None:
                            self._do_purchase_check(item,
                                                    is_ticket_purchase=True)

                        ba.playsound(ba.getsound('swish'))
                        ConfirmWindow(
                            ba.Lstr(resource='store.purchaseConfirmText',
                                    subs=[
                                        ('${ITEM}',
                                         get_store_item_name_translated(item))
                                    ]),
                            width=400,
                            height=120,
                            action=do_it,
                            ok_text=ba.Lstr(resource='store.purchaseText',
                                            fallback_resource='okText'))
Esempio n. 6
0
def show_get_tickets_prompt() -> None:
    """Show a 'not enough tickets' prompt with an option to purchase more.

    Note that the purchase option may not always be available
    depending on the build of the game.
    """
    from bastd.ui.confirm import ConfirmWindow
    if ba.app.allow_ticket_purchases:
        ConfirmWindow(
            ba.Lstr(translate=('serverResponses',
                               'You don\'t have enough tickets for this!')),
            lambda: GetCurrencyWindow(modal=True),
            ok_text=ba.Lstr(resource='getTicketsWindow.titleText'),
            width=460,
            height=130)
    else:
        ConfirmWindow(
            ba.Lstr(translate=('serverResponses',
                               'You don\'t have enough tickets for this!')),
            cancel_button=False,
            width=460,
            height=130)
Esempio n. 7
0
 def show_account_profile_info(self) -> None:
     """Show an explanation of account profiles."""
     from bastd.ui.confirm import ConfirmWindow
     icons_str = ' '.join([
         ba.charstr(n) for n in [
             ba.SpecialChar.GOOGLE_PLAY_GAMES_LOGO,
             ba.SpecialChar.GAME_CENTER_LOGO,
             ba.SpecialChar.GAME_CIRCLE_LOGO, ba.SpecialChar.OUYA_LOGO,
             ba.SpecialChar.LOCAL_ACCOUNT, ba.SpecialChar.ALIBABA_LOGO,
             ba.SpecialChar.OCULUS_LOGO, ba.SpecialChar.NVIDIA_LOGO
         ]
     ])
     txtl = ba.Lstr(resource='editProfileWindow.accountProfileInfoText',
                    subs=[('${ICONS}', icons_str)])
     ConfirmWindow(txtl,
                   cancel_button=False,
                   width=500,
                   height=300,
                   origin_widget=self._account_type_info_button)
Esempio n. 8
0
    def _delete_playlist(self) -> None:
        # pylint: disable=cyclic-import
        from bastd.ui.purchase import PurchaseWindow
        from bastd.ui.confirm import ConfirmWindow
        if not ba.app.accounts.have_pro_options():
            PurchaseWindow(items=['pro'])
            return

        if self._selected_playlist_name is None:
            return
        if self._selected_playlist_name == '__default__':
            ba.playsound(ba.getsound('error'))
            ba.screenmessage(
                ba.Lstr(resource=self._r + '.cantDeleteDefaultText'))
        else:
            ConfirmWindow(
                ba.Lstr(resource=self._r + '.deleteConfirmText',
                        subs=[('${LIST}', self._selected_playlist_name)]),
                self._do_delete_playlist, 450, 150)
Esempio n. 9
0
 def _on_google_play_invite_press(self) -> None:
     from bastd.ui.confirm import ConfirmWindow
     from bastd.ui.account import show_sign_in_prompt
     if (_ba.get_account_state() != 'signed_in'
             or _ba.get_account_type() != 'Google Play'):
         show_sign_in_prompt('Google Play')
     else:
         # If there's google play people connected to us, inform the user
         # that they will get disconnected. Otherwise just go ahead.
         google_player_count = (_ba.get_google_play_party_client_count())
         if google_player_count > 0:
             ConfirmWindow(
                 ba.Lstr(resource='gatherWindow.'
                         'googlePlayReInviteText',
                         subs=[('${COUNT}', str(google_player_count))]),
                 lambda: ba.timer(
                     0.2, _ba.invite_players, timetype=ba.TimeType.REAL),
                 width=500,
                 height=150,
                 ok_text=ba.Lstr(resource='gatherWindow.'
                                 'googlePlayInviteText'))
         else:
             ba.timer(0.1, _ba.invite_players, timetype=ba.TimeType.REAL)
Esempio n. 10
0
 def _on_uninstall(self):
     from bastd.ui.confirm import ConfirmWindow
     ConfirmWindow(text=f'Uninstall {self.pkginfo.to_string()}?',
                   action=ba.WeakCall(self._uninstall))
Esempio n. 11
0
File: menu.py Progetto: BombDash/bap
 def _on_file_selected(path):
     if path is None:
         return
     ConfirmWindow(action=ba.Call(_do_install, path),
                   text=f'Install {os.path.basename(path)}?')
Esempio n. 12
0
 def _on_upgrade(self):
     from bastd.ui.confirm import ConfirmWindow
     ConfirmWindow(text=f'Upgrade {self.pkginfo.to_string()}?',
                   action=ba.WeakCall(self._install, upgrade=True))