# UiProfile —— desktop / mobile presentation selection. # # The profile only selects presentation and input surfaces. It must never # change the M2 protocol or gameplay rules. Desktop developers can force the # mobile HUD with `--mobile-ui` (or the project setting below) without needing # an Android build. extends RefCounted enum Mode { AUTO, DESKTOP, MOBILE } const SETTING := "mt/ui/profile" const MOBILE_ARG := "--mobile-ui" const DESKTOP_ARG := "--desktop-ui" static func parse(value: String) -> int: match value.strip_edges().to_lower(): "mobile": return Mode.MOBILE "desktop": return Mode.DESKTOP _: return Mode.AUTO static func resolve(value: String = "") -> int: var requested := value if requested == "": requested = String(ProjectSettings.get_setting(SETTING, "auto")) var parsed := parse(requested) if parsed != Mode.AUTO: return parsed for arg in OS.get_cmdline_args(): if arg == MOBILE_ARG: return Mode.MOBILE if arg == DESKTOP_ARG: return Mode.DESKTOP return Mode.MOBILE if OS.has_feature("mobile") else Mode.DESKTOP static func is_mobile(value: String = "") -> bool: return resolve(value) == Mode.MOBILE static func name(mode: int) -> String: match mode: Mode.MOBILE: return "mobile" Mode.DESKTOP: return "desktop" _: return "auto"