def _on_customize_press(self) -> None: # pylint: disable=cyclic-import from bastd.ui.playlist import customizebrowser as cb self._save_state() ba.containerwidget(edit=self._root_widget, transition='out_left') ba.app.main_menu_window = (cb.PlaylistCustomizeBrowserWindow( origin_widget=self._customize_button, sessiontype=self._sessiontype).get_root_widget())
def _save_press(self) -> None: from bastd.ui.playlist import customizebrowser as cb new_name = cast(str, ba.textwidget(query=self._text_field)) if (new_name != self._editcontroller.get_existing_playlist_name() and new_name in ba.app.config[self._editcontroller.get_config_name() + ' Playlists']): ba.screenmessage( ba.Lstr(resource=self._r + '.cantSaveAlreadyExistsText')) ba.playsound(ba.getsound('error')) return if not new_name: ba.playsound(ba.getsound('error')) return if not self._editcontroller.get_playlist(): ba.screenmessage( ba.Lstr(resource=self._r + '.cantSaveEmptyListText')) ba.playsound(ba.getsound('error')) return # We couldn't actually replace the default list anyway, but disallow # using its exact name to avoid confusion. if new_name == self._editcontroller.get_default_list_name().evaluate(): ba.screenmessage( ba.Lstr(resource=self._r + '.cantOverwriteDefaultText')) ba.playsound(ba.getsound('error')) return # If we had an old one, delete it. if self._editcontroller.get_existing_playlist_name() is not None: _ba.add_transaction({ 'type': 'REMOVE_PLAYLIST', 'playlistType': self._editcontroller.get_config_name(), 'playlistName': self._editcontroller.get_existing_playlist_name() }) _ba.add_transaction({ 'type': 'ADD_PLAYLIST', 'playlistType': self._editcontroller.get_config_name(), 'playlistName': new_name, 'playlist': self._editcontroller.get_playlist() }) _ba.run_transactions() ba.containerwidget(edit=self._root_widget, transition='out_right') ba.playsound(ba.getsound('gunCocking')) ba.app.main_menu_window = (cb.PlaylistCustomizeBrowserWindow( transition='in_left', sessiontype=self._editcontroller.get_session_type(), select_playlist=new_name).get_root_widget())
def _cancel(self) -> None: from bastd.ui.playlist import customizebrowser as cb ba.playsound(ba.getsound('powerdown01')) ba.containerwidget(edit=self._root_widget, transition='out_right') ba.app.main_menu_window = (cb.PlaylistCustomizeBrowserWindow( transition='in_left', sessiontype=self._editcontroller.get_session_type(), select_playlist=self._editcontroller.get_existing_playlist_name()). get_root_widget())