def _do_controllers(self) -> None: # pylint: disable=cyclic-import from bastd.ui.settings.controls import ControlsSettingsWindow self._save_state() ba.containerwidget(edit=self._root_widget, transition='out_left') ba.app.main_menu_window = (ControlsSettingsWindow( origin_widget=self._controllers_button).get_root_widget())
def _save(self) -> None: from bastd.ui.settings.controls import ControlsSettingsWindow from ba.internal import (get_input_device_config, should_submit_debug_info, master_server_post) ba.containerwidget(edit=self._root_widget, transition='out_right') ba.playsound(ba.getsound('gunCocking')) # There's a chance the device disappeared; handle that gracefully. if not self._input: return dst = get_input_device_config(self._input, default=False) dst2: Dict[str, Any] = dst[0][dst[1]] dst2.clear() # Store any values that aren't -1. for key, val in list(self._settings.items()): if val != -1: dst2[key] = val # If we're allowed to phone home, send this config so we can generate # more defaults in the future. if should_submit_debug_info(): master_server_post( 'controllerConfig', { 'ua': ba.app.user_agent_string, 'name': self._name, 'b': ba.app.build_number, 'config': dst2, 'v': 2 }) ba.app.config.apply_and_commit() ba.app.ui.set_main_menu_window( ControlsSettingsWindow(transition='in_left').get_root_widget())
def _cancel(self) -> None: from bastd.ui.settings.controls import ControlsSettingsWindow ba.containerwidget(edit=self._root_widget, transition=self._transition_out) if self._is_main_menu: ba.app.ui.set_main_menu_window( ControlsSettingsWindow(transition='in_left').get_root_widget())
def _save(self) -> None: from ba.internal import (master_server_post, get_input_device_config, get_input_map_hash, should_submit_debug_info) ba.containerwidget(edit=self._root_widget, transition=self._transition_out) # If we're a secondary editor we just go away (we were editing our # parent's settings dict). if self._is_secondary: return assert self._settings is not None if self._input: dst = get_input_device_config(self._input, default=True) dst2: Dict[str, Any] = dst[0][dst[1]] dst2.clear() # Store any values that aren't -1. for key, val in list(self._settings.items()): if val != -1: dst2[key] = val # If we're allowed to phone home, send this config so we can # generate more defaults in the future. inputhash = get_input_map_hash(self._input) if should_submit_debug_info(): master_server_post( 'controllerConfig', { 'ua': ba.app.user_agent_string, 'b': ba.app.build_number, 'name': self._name, 'inputMapHash': inputhash, 'config': dst2, 'v': 2 }) ba.app.config.apply_and_commit() ba.playsound(ba.getsound('gunCocking')) else: ba.playsound(ba.getsound('error')) if self._is_main_menu: from bastd.ui.settings.controls import ControlsSettingsWindow ba.app.ui.set_main_menu_window( ControlsSettingsWindow(transition='in_left').get_root_widget())
def _cancel(self) -> None: from bastd.ui.settings.controls import ControlsSettingsWindow ba.containerwidget(edit=self._root_widget, transition='out_right') ba.app.main_menu_window = (ControlsSettingsWindow( transition='in_left').get_root_widget())