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:
Hugo Locurcio 2024-12-13 17:16:14 +01:00
parent 7f5c469292
commit 928982891e
11 changed files with 105 additions and 5 deletions

View file

@ -424,6 +424,10 @@ String OS::get_version() const {
return ::OS::get_singleton()->get_version();
}
String OS::get_version_alias() const {
return ::OS::get_singleton()->get_version_alias();
}
Vector<String> OS::get_video_adapter_driver_info() const {
return ::OS::get_singleton()->get_video_adapter_driver_info();
}
@ -680,6 +684,7 @@ void OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_name"), &OS::get_name);
ClassDB::bind_method(D_METHOD("get_distribution_name"), &OS::get_distribution_name);
ClassDB::bind_method(D_METHOD("get_version"), &OS::get_version);
ClassDB::bind_method(D_METHOD("get_version_alias"), &OS::get_version_alias);
ClassDB::bind_method(D_METHOD("get_cmdline_args"), &OS::get_cmdline_args);
ClassDB::bind_method(D_METHOD("get_cmdline_user_args"), &OS::get_cmdline_user_args);