You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Add OS.get_version_alias() to return a human-readable Windows/macOS version number
Windows 11's major version number is actually 10.x.x, which can be confusing if you don't know about this quirk. `OS.get_version_alias()` avoids this by displaying the "branding" version number and the build number as a suffix, so that individual updates can still be distinguished from each other. On macOS, `OS.get_version_alias()` returns the version number prepended with the version name (e.g. Sequoia for macOS 15). On other operating systems, this returns the same value as `OS.get_version()`.
This commit is contained in:
@@ -185,6 +185,33 @@ String OS_MacOS::get_version() const {
|
||||
return vformat("%d.%d.%d", (int64_t)ver.majorVersion, (int64_t)ver.minorVersion, (int64_t)ver.patchVersion);
|
||||
}
|
||||
|
||||
String OS_MacOS::get_version_alias() const {
|
||||
NSOperatingSystemVersion ver = [NSProcessInfo processInfo].operatingSystemVersion;
|
||||
String macos_string;
|
||||
if (ver.majorVersion == 15) {
|
||||
macos_string += "Sequoia";
|
||||
} else if (ver.majorVersion == 14) {
|
||||
macos_string += "Sonoma";
|
||||
} else if (ver.majorVersion == 13) {
|
||||
macos_string += "Ventura";
|
||||
} else if (ver.majorVersion == 12) {
|
||||
macos_string += "Monterey";
|
||||
} else if (ver.majorVersion == 11 || (ver.majorVersion == 10 && ver.minorVersion == 16)) {
|
||||
// Big Sur was 10.16 during beta, but it became 11 for the stable version.
|
||||
macos_string += "Big Sur";
|
||||
} else if (ver.majorVersion == 10 && ver.minorVersion == 15) {
|
||||
macos_string += "Catalina";
|
||||
} else if (ver.majorVersion == 10 && ver.minorVersion == 14) {
|
||||
macos_string += "Mojave";
|
||||
} else if (ver.majorVersion == 10 && ver.minorVersion == 13) {
|
||||
macos_string += "High Sierra";
|
||||
} else {
|
||||
macos_string += "Unknown";
|
||||
}
|
||||
// macOS versions older than 10.13 cannot run Godot.
|
||||
return vformat("%s (%s)", macos_string, get_version());
|
||||
}
|
||||
|
||||
void OS_MacOS::alert(const String &p_alert, const String &p_title) {
|
||||
NSAlert *window = [[NSAlert alloc] init];
|
||||
NSString *ns_title = [NSString stringWithUTF8String:p_title.utf8().get_data()];
|
||||
|
||||
Reference in New Issue
Block a user