Exemplo n.º 1
0
    def _new_profile(self) -> None:
        # pylint: disable=cyclic-import
        from ba.internal import have_pro_options
        from bastd.ui.profile import edit as pedit
        from bastd.ui import purchase

        # Limit to a handful profiles if they don't have pro-options.
        max_non_pro_profiles = _ba.get_account_misc_read_val('mnpp', 5)
        assert self._profiles is not None
        if (not have_pro_options()
                and len(self._profiles) >= max_non_pro_profiles):
            purchase.PurchaseWindow(items=['pro'],
                                    header_text=ba.Lstr(
                                        resource='unlockThisProfilesText',
                                        subs=[('${NUM}',
                                               str(max_non_pro_profiles))]))
            return

        # Clamp at 100 profiles (otherwise the server will and that's less
        # elegant looking).
        if len(self._profiles) > 100:
            ba.screenmessage(
                ba.Lstr(translate=('serverResponses',
                                   'Max number of profiles reached.')),
                color=(1, 0, 0))
            ba.playsound(ba.getsound('error'))
            return

        self._save_state()
        ba.containerwidget(edit=self._root_widget, transition='out_left')
        ba.app.main_menu_window = (pedit.EditProfileWindow(
            existing_profile=None,
            in_main_menu=self._in_main_menu).get_root_widget())
Exemplo n.º 2
0
 def _edit_profile(self) -> None:
     # pylint: disable=cyclic-import
     from bastd.ui.profile import edit as pedit
     if self._selected_profile is None:
         ba.playsound(ba.getsound('error'))
         ba.screenmessage(ba.Lstr(resource='nothingIsSelectedErrorText'),
                          color=(1, 0, 0))
         return
     self._save_state()
     ba.containerwidget(edit=self._root_widget, transition='out_left')
     ba.app.main_menu_window = (pedit.EditProfileWindow(
         self._selected_profile,
         in_main_menu=self._in_main_menu).get_root_widget())