コード例 #1
0
 def _on_get_more_tickets_press(self) -> None:
     from bastd.ui import account
     from bastd.ui import getcurrency
     if _ba.get_account_state() != 'signed_in':
         account.show_sign_in_prompt()
         return
     getcurrency.GetCurrencyWindow(modal=True).get_root_widget()
コード例 #2
0
ファイル: button.py プロジェクト: zwl1671/ballistica
 def _default_on_activate_call(self) -> None:
     from bastd.ui import account
     from bastd.ui.store import browser
     if _ba.get_account_state() != 'signed_in':
         account.show_sign_in_prompt()
         return
     browser.StoreBrowserWindow(modal=True, origin_widget=self._button)
コード例 #3
0
 def _on_friend_promo_code_press(self) -> None:
     from bastd.ui import appinvite
     from bastd.ui import account
     if _ba.get_v1_account_state() != 'signed_in':
         account.show_sign_in_prompt()
         return
     appinvite.handle_app_invites_press()
コード例 #4
0
ファイル: abouttab.py プロジェクト: imayushsaini/ballistica
 def _invite_to_try_press(self) -> None:
     from bastd.ui.account import show_sign_in_prompt
     from bastd.ui.appinvite import handle_app_invites_press
     if _ba.get_v1_account_state() != 'signed_in':
         show_sign_in_prompt()
         return
     handle_app_invites_press()
コード例 #5
0
    def on_boost_press(self) -> None:
        """Boost was pressed."""
        from bastd.ui import account
        from bastd.ui import getcurrency
        if _ba.get_account_state() != 'signed_in':
            account.show_sign_in_prompt()
            return

        if _ba.get_account_ticket_count() < self._boost_tickets:
            ba.playsound(ba.getsound('error'))
            getcurrency.show_get_tickets_prompt()
            return

        ba.playsound(ba.getsound('laserReverse'))
        _ba.add_transaction(
            {
                'type': 'PARTY_QUEUE_BOOST',
                't': self._boost_tickets,
                'q': self._queue_id
            },
            callback=ba.WeakCall(self.on_update_response))
        # lets not run these immediately (since they may be rapid-fire,
        # just bucket them until the next tick)

        # the transaction handles the local ticket change, but we apply our
        # local boost vis manually here..
        # (our visualization isn't really wired up to be transaction-based)
        our_dude = self._dudes_by_id.get(-1)
        if our_dude is not None:
            our_dude.boost(self._boost_strength, self._smoothing)
コード例 #6
0
    def _on_start_advertizing_press(self) -> None:
        from bastd.ui.account import show_sign_in_prompt
        if _ba.get_account_state() != 'signed_in':
            show_sign_in_prompt()
            return

        name = cast(str, ba.textwidget(query=self._host_name_text))
        if name == '':
            ba.screenmessage(ba.Lstr(resource='internal.invalidNameErrorText'),
                             color=(1, 0, 0))
            ba.playsound(ba.getsound('error'))
            return
        _ba.set_public_party_name(name)
        cfg = ba.app.config
        cfg['Public Party Name'] = name
        cfg.commit()
        ba.playsound(ba.getsound('shieldUp'))
        _ba.set_public_party_enabled(True)

        # In GUI builds we want to authenticate clients only when hosting
        # public parties.
        _ba.set_authenticate_clients(True)

        self._do_status_check()
        ba.buttonwidget(
            edit=self._host_toggle_button,
            label=ba.Lstr(
                resource='gatherWindow.makePartyPrivateText',
                fallback_resource='gatherWindow.stopAdvertisingText'),
            on_activate_call=self._on_stop_advertising_press)
コード例 #7
0
 def _on_google_play_show_invites_press(self) -> None:
     from bastd.ui import account
     if (_ba.get_account_state() != 'signed_in'
             or _ba.get_account_type() != 'Google Play'):
         account.show_sign_in_prompt('Google Play')
     else:
         _ba.show_invites_ui()
コード例 #8
0
ファイル: button.py プロジェクト: snow-1711/ballistica
 def _default_on_activate_call(self) -> None:
     # pylint: disable=cyclic-import
     from bastd.ui.account import show_sign_in_prompt
     from bastd.ui.store.browser import StoreBrowserWindow
     if _ba.get_account_state() != 'signed_in':
         show_sign_in_prompt()
         return
     StoreBrowserWindow(modal=True, origin_widget=self._button)
コード例 #9
0
    def upgrade_profile(self) -> None:
        """Attempt to ugrade the profile to global."""
        from bastd.ui import account
        from bastd.ui.profile import upgrade as pupgrade
        if _ba.get_account_state() != 'signed_in':
            account.show_sign_in_prompt()
            return

        pupgrade.ProfileUpgradeWindow(self)
コード例 #10
0
 def _on_get_more_games_press(self) -> None:
     from bastd.ui.account import show_sign_in_prompt
     from bastd.ui.store.browser import StoreBrowserWindow
     if _ba.get_account_state() != 'signed_in':
         show_sign_in_prompt()
         return
     StoreBrowserWindow(modal=True,
                        show_tab=StoreBrowserWindow.TabID.MINIGAMES,
                        on_close_call=self._on_store_close,
                        origin_widget=self._get_more_games_button)
コード例 #11
0
ファイル: iconpicker.py プロジェクト: TheSZR/SaulSquad
 def _on_store_press(self) -> None:
     from bastd.ui.account import show_sign_in_prompt
     from bastd.ui.store.browser import StoreBrowserWindow
     if _ba.get_account_state() != 'signed_in':
         show_sign_in_prompt()
         return
     self._transition_out()
     StoreBrowserWindow(modal=True,
                        show_tab=StoreBrowserWindow.TabID.ICONS,
                        origin_widget=self._get_more_icons_button)
コード例 #12
0
 def _on_store_press(self) -> None:
     from bastd.ui import account
     from bastd.ui.store import browser
     if _ba.get_account_state() != 'signed_in':
         account.show_sign_in_prompt()
         return
     self._transition_out()
     browser.StoreBrowserWindow(modal=True,
                                show_tab='icons',
                                origin_widget=self._get_more_icons_button)
コード例 #13
0
 def _on_get_more_games_press(self) -> None:
     from bastd.ui import account
     from bastd.ui.store import browser
     if _ba.get_account_state() != 'signed_in':
         account.show_sign_in_prompt()
         return
     browser.StoreBrowserWindow(modal=True,
                                show_tab='minigames',
                                on_close_call=self._on_store_close,
                                origin_widget=self._get_more_games_button)
コード例 #14
0
 def _on_store_press(self) -> None:
     from bastd.ui import account
     from bastd.ui.store.browser import StoreBrowserWindow
     if _ba.get_v1_account_state() != 'signed_in':
         account.show_sign_in_prompt()
         return
     StoreBrowserWindow(modal=True,
                        show_tab=StoreBrowserWindow.TabID.MAPS,
                        on_close_call=self._on_store_close,
                        origin_widget=self._get_more_maps_button)
コード例 #15
0
ファイル: mainmenu.py プロジェクト: ShifengHuGit/ballistica
 def _on_store_pressed(self) -> None:
     # pylint: disable=cyclic-import
     from bastd.ui.store import browser
     from bastd.ui import account
     if _ba.get_account_state() != 'signed_in':
         account.show_sign_in_prompt()
         return
     self._save_state()
     ba.containerwidget(edit=self._root_widget, transition='out_left')
     ba.app.main_menu_window = (browser.StoreBrowserWindow(
         origin_widget=self._store_button).get_root_widget())
コード例 #16
0
ファイル: play.py プロジェクト: SahandAslani/ballistica
 def _coop(self) -> None:
     # pylint: disable=cyclic-import
     from bastd.ui.account import show_sign_in_prompt
     from bastd.ui.coop.browser import CoopBrowserWindow
     if _ba.get_account_state() != 'signed_in':
         show_sign_in_prompt()
         return
     self._save_state()
     ba.containerwidget(edit=self._root_widget, transition='out_left')
     ba.app.main_menu_window = (CoopBrowserWindow(
         origin_widget=self._coop_button).get_root_widget())
コード例 #17
0
ファイル: browser.py プロジェクト: SahandAslani/ballistica
    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'))
コード例 #18
0
    def _on_promo_code_press(self) -> None:
        from bastd.ui import promocode
        from bastd.ui import account

        # We have to be logged in for promo-codes to work.
        if _ba.get_account_state() != 'signed_in':
            account.show_sign_in_prompt()
            return
        self._save_state()
        ba.containerwidget(edit=self._root_widget, transition='out_left')
        ba.app.main_menu_window = (promocode.PromoCodeWindow(
            origin_widget=self._promo_code_button).get_root_widget())
コード例 #19
0
 def _generate_press(self) -> None:
     from bastd.ui import account
     if _ba.get_account_state() != 'signed_in':
         account.show_sign_in_prompt()
         return
     ba.screenmessage(
         ba.Lstr(resource='gatherWindow.requestingAPromoCodeText'),
         color=(0, 1, 0))
     _ba.add_transaction({
         'type': 'ACCOUNT_LINK_CODE_REQUEST',
         'expire_time': time.time() + 5
     })
     _ba.run_transactions()
コード例 #20
0
ファイル: browser.py プロジェクト: SahandAslani/ballistica
 def _on_get_more_tickets_press(self) -> None:
     # pylint: disable=cyclic-import
     from bastd.ui import account
     from bastd.ui import getcurrency
     if _ba.get_account_state() != 'signed_in':
         account.show_sign_in_prompt()
         return
     self._save_state()
     ba.containerwidget(edit=self._root_widget, transition='out_left')
     window = getcurrency.GetCurrencyWindow(
         from_modal_store=self._modal,
         store_back_location=self._back_location).get_root_widget()
     if not self._modal:
         ba.app.main_menu_window = window
コード例 #21
0
 def _custom_colors_names_press(self) -> None:
     from bastd.ui.account import show_sign_in_prompt
     from bastd.ui.teamnamescolors import TeamNamesColorsWindow
     from bastd.ui.purchase import PurchaseWindow
     if not ba.app.accounts.have_pro():
         if _ba.get_account_state() != 'signed_in':
             show_sign_in_prompt()
         else:
             PurchaseWindow(items=['pro'])
         self._transition_out()
         return
     assert self._custom_colors_names_button
     TeamNamesColorsWindow(scale_origin=self._custom_colors_names_button.
                           get_screen_space_center())
コード例 #22
0
 def _custom_colors_names_press(self) -> None:
     from ba.internal import have_pro
     from bastd.ui import account as accountui
     from bastd.ui import teamnamescolors
     from bastd.ui import purchase
     if not have_pro():
         if _ba.get_account_state() != 'signed_in':
             accountui.show_sign_in_prompt()
         else:
             purchase.PurchaseWindow(items=['pro'])
         self._transition_out()
         return
     assert self._custom_colors_names_button
     teamnamescolors.TeamNamesColorsWindow(
         scale_origin=self._custom_colors_names_button.
         get_screen_space_center())
コード例 #23
0
ファイル: getcurrency.py プロジェクト: zwl1671/ballistica
 def _purchase(self, item: str) -> None:
     from bastd.ui import account
     from bastd.ui import appinvite
     from ba.internal import serverget
     if item == 'app_invite':
         if _ba.get_account_state() != 'signed_in':
             account.show_sign_in_prompt()
             return
         appinvite.handle_app_invites_press()
         return
     # here we ping the server to ask if it's valid for us to
     # purchase this.. (better to fail now than after we've paid locally)
     app = ba.app
     serverget('bsAccountPurchaseCheck', {
         'item': item,
         'platform': app.platform,
         'subplatform': app.subplatform,
         'version': app.version,
         'buildNumber': app.build_number
     },
               callback=ba.WeakCall(self._purchase_check_result, item))
コード例 #24
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)
コード例 #25
0
ファイル: browser.py プロジェクト: SahandAslani/ballistica
 def _restore_purchases(self) -> None:
     from bastd.ui import account
     if _ba.get_account_state() != 'signed_in':
         account.show_sign_in_prompt()
     else:
         _ba.restore_purchases()