# Released under the MIT License. See LICENSE for details.#"""Provides AppMode functionality."""from__future__importannotationsfromtypingimportTYPE_CHECKINGifTYPE_CHECKING:frombacommon.appimportAppExperiencefrombabase._appintentimportAppIntentclassAppMode:"""A high level mode for the app. Category: **App Classes** """
[docs]@classmethoddefget_app_experience(cls)->AppExperience:"""Return the overall experience provided by this mode."""raiseNotImplementedError('AppMode subclasses must override this.')
[docs]@classmethoddefcan_handle_intent(cls,intent:AppIntent)->bool:"""Return whether this mode can handle the provided intent. For this to return True, the AppMode must claim to support the provided intent (via its _supports_intent() method) AND the AppExperience associated with the AppMode must be supported by the current app and runtime environment. """# TODO: check AppExperience.returncls._supports_intent(intent)
@classmethoddef_supports_intent(cls,intent:AppIntent)->bool:"""Return whether our mode can handle the provided intent. AppModes should override this to define what they can handle. Note that AppExperience does not have to be considered here; that is handled automatically by the can_handle_intent() call."""raiseNotImplementedError('AppMode subclasses must override this.')
[docs]defhandle_intent(self,intent:AppIntent)->None:"""Handle an intent."""raiseNotImplementedError('AppMode subclasses must override this.')
[docs]defon_activate(self)->None:"""Called when the mode is being activated."""
[docs]defon_deactivate(self)->None:"""Called when the mode is being deactivated."""
[docs]defon_app_active_changed(self)->None:"""Called when ba*.app.active changes while this mode is active. The app-mode may want to take action such as pausing a running game in such cases. """