diff --git a/Source/Engine/Platform/Android/AndroidPlatform.cpp b/Source/Engine/Platform/Android/AndroidPlatform.cpp index 466e72e0c..5447fc215 100644 --- a/Source/Engine/Platform/Android/AndroidPlatform.cpp +++ b/Source/Engine/Platform/Android/AndroidPlatform.cpp @@ -8,6 +8,7 @@ #include "Engine/Core/Log.h" #include "Engine/Core/Types/Guid.h" #include "Engine/Core/Types/String.h" +#include "Engine/Core/Types/Version.h" #include "Engine/Core/Collections/HashFunctions.h" #include "Engine/Core/Collections/Array.h" #include "Engine/Core/Math/Math.h" @@ -681,11 +682,6 @@ String AndroidPlatform::GetDeviceBuildNumber() return DeviceBuildNumber; } -String AndroidPlatform::GetSystemVersion() -{ - return SystemVersion; -} - void AndroidPlatform::PreInit(android_app* app) { App = app; @@ -889,8 +885,8 @@ void AndroidPlatform::LogInfo() { UnixPlatform::LogInfo(); - LOG(Info, "App Package Name: {0}", AppPackageName); - LOG(Info, "System Version: {0}", SystemVersion); + LOG(Info, "App Package: {0}", AppPackageName); + LOG(Info, "Android {0}", SystemVersion); LOG(Info, "Device: {0} {1}, {2}", DeviceManufacturer, DeviceModel, DeviceBuildNumber); } @@ -945,6 +941,18 @@ void AndroidPlatform::Log(const StringView& msg) #endif +String AndroidPlatform::GetSystemName() +{ + return String::Format(TEXT("Android {}"), SystemVersion); +} + +Version AndroidPlatform::GetSystemVersion() +{ + Version version(0, 0); + Version::Parse(SystemVersion, &version); + return version; +} + int32 AndroidPlatform::GetDpi() { return AConfiguration_getScreenWidthDp(App->config); diff --git a/Source/Engine/Platform/Android/AndroidPlatform.h b/Source/Engine/Platform/Android/AndroidPlatform.h index c300a0f2a..0ec21784d 100644 --- a/Source/Engine/Platform/Android/AndroidPlatform.h +++ b/Source/Engine/Platform/Android/AndroidPlatform.h @@ -21,7 +21,6 @@ public: static String GetDeviceManufacturer(); static String GetDeviceModel(); static String GetDeviceBuildNumber(); - static String GetSystemVersion(); static void PreInit(android_app* app); public: @@ -80,6 +79,8 @@ public: __builtin_prefetch(static_cast(ptr)); } static bool Is64BitPlatform(); + static String GetSystemName(); + static Version GetSystemVersion(); static CPUInfo GetCPUInfo(); static MemoryStats GetMemoryStats(); static ProcessMemoryStats GetProcessMemoryStats(); diff --git a/Source/Engine/Platform/Apple/ApplePlatform.cpp b/Source/Engine/Platform/Apple/ApplePlatform.cpp index 6d9b19296..9b3d2f099 100644 --- a/Source/Engine/Platform/Apple/ApplePlatform.cpp +++ b/Source/Engine/Platform/Apple/ApplePlatform.cpp @@ -7,6 +7,7 @@ #include "Engine/Core/Log.h" #include "Engine/Core/Types/Guid.h" #include "Engine/Core/Types/String.h" +#include "Engine/Core/Types/Version.h" #include "Engine/Core/Collections/HashFunctions.h" #include "Engine/Core/Collections/Array.h" #include "Engine/Core/Collections/Dictionary.h" @@ -32,9 +33,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -129,6 +132,19 @@ bool ApplePlatform::Is64BitPlatform() return PLATFORM_64BITS; } +String ApplePlatform::GetSystemName() +{ + struct utsname systemInfo; + uname(&systemInfo); + return String(systemInfo.machine); +} + +Version ApplePlatform::GetSystemVersion() +{ + NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion]; + return Version(version.major, version.majorVersion, version.minorVersion, version.patchVersion); +} + CPUInfo ApplePlatform::GetCPUInfo() { return Cpu; diff --git a/Source/Engine/Platform/Apple/ApplePlatform.h b/Source/Engine/Platform/Apple/ApplePlatform.h index 6f16c07e8..0324e18f1 100644 --- a/Source/Engine/Platform/Apple/ApplePlatform.h +++ b/Source/Engine/Platform/Apple/ApplePlatform.h @@ -66,6 +66,8 @@ public: __builtin_prefetch(static_cast(ptr)); } static bool Is64BitPlatform(); + static String GetSystemName(); + static Version GetSystemVersion(); static CPUInfo GetCPUInfo(); static MemoryStats GetMemoryStats(); static ProcessMemoryStats GetProcessMemoryStats(); diff --git a/Source/Engine/Platform/Base/PlatformBase.h b/Source/Engine/Platform/Base/PlatformBase.h index f6f56c4b7..56da92e50 100644 --- a/Source/Engine/Platform/Base/PlatformBase.h +++ b/Source/Engine/Platform/Base/PlatformBase.h @@ -7,6 +7,7 @@ #include struct Guid; +struct Version; struct CPUInfo; struct MemoryStats; struct ProcessMemoryStats; @@ -372,6 +373,16 @@ public: /// True if running on 64-bit computer, otherwise false. API_PROPERTY() static bool Is64BitPlatform() = delete; + /// + /// Gets the name of the operating system. + /// + API_PROPERTY() static String GetSystemName() = delete; + + /// + /// Gets the version of the operating system version. + /// + API_PROPERTY() static Version GetSystemVersion() = delete; + /// /// Gets the CPU information. /// diff --git a/Source/Engine/Platform/BatteryInfo.h b/Source/Engine/Platform/BatteryInfo.h index c7f70ee27..ef0ebaa35 100644 --- a/Source/Engine/Platform/BatteryInfo.h +++ b/Source/Engine/Platform/BatteryInfo.h @@ -7,7 +7,7 @@ /// /// Contains information about power supply (battery). /// -API_STRUCT() struct BatteryInfo +API_STRUCT(NoDefault) struct BatteryInfo { DECLARE_SCRIPTING_TYPE_MINIMAL(BatteryInfo); diff --git a/Source/Engine/Platform/CPUInfo.h b/Source/Engine/Platform/CPUInfo.h index e5b1fcd2d..24b11a0db 100644 --- a/Source/Engine/Platform/CPUInfo.h +++ b/Source/Engine/Platform/CPUInfo.h @@ -7,9 +7,9 @@ /// /// Contains information about CPU (Central Processing Unit). /// -API_STRUCT() struct CPUInfo +API_STRUCT(NoDefault) struct CPUInfo { -DECLARE_SCRIPTING_TYPE_MINIMAL(CPUInfo); + DECLARE_SCRIPTING_TYPE_MINIMAL(CPUInfo); /// /// The number of physical processor packages. diff --git a/Source/Engine/Platform/GDK/GDKPlatform.cpp b/Source/Engine/Platform/GDK/GDKPlatform.cpp index fe58c8c98..14fa665b8 100644 --- a/Source/Engine/Platform/GDK/GDKPlatform.cpp +++ b/Source/Engine/Platform/GDK/GDKPlatform.cpp @@ -10,6 +10,7 @@ #include "Engine/Platform/Base/PlatformUtils.h" #include "Engine/Profiler/ProfilerCPU.h" #include "Engine/Core/Log.h" +#include "Engine/Core/Types/Version.h" #include "Engine/Core/Collections/Array.h" #include "Engine/Core/Collections/Dictionary.h" #include "Engine/Platform/MessageBox.h" @@ -41,6 +42,7 @@ namespace HANDLE PlmSignalResume = nullptr; PAPPSTATE_REGISTRATION Plm = {}; String UserLocale, ComputerName; + XSystemAnalyticsInfo SystemAnalyticsInfo; XTaskQueueHandle TaskQueue = nullptr; XTaskQueueRegistrationToken UserChangeEventCallbackToken; XTaskQueueRegistrationToken UserDeviceAssociationChangedCallbackToken; @@ -377,6 +379,8 @@ bool GDKPlatform::Init() DWORD tmp; Char buffer[256]; + SystemAnalyticsInfo = XSystemGetAnalyticsInfo(); + // Get user locale string if (GetUserDefaultLocaleName(buffer, LOCALE_NAME_MAX_LENGTH)) { @@ -419,7 +423,7 @@ void GDKPlatform::LogInfo() Win32Platform::LogInfo(); // Log system info - const XSystemAnalyticsInfo analyticsInfo = XSystemGetAnalyticsInfo(); + const XSystemAnalyticsInfo& analyticsInfo = SystemAnalyticsInfo; LOG(Info, "{0}, {1}", StringAsUTF16<64>(analyticsInfo.family).Get(), StringAsUTF16<64>(analyticsInfo.form).Get()); LOG(Info, "OS Version {0}.{1}.{2}.{3}", analyticsInfo.osVersion.major, analyticsInfo.osVersion.minor, analyticsInfo.osVersion.build, analyticsInfo.osVersion.revision); } @@ -504,6 +508,17 @@ bool GDKPlatform::IsDebuggerPresent() #endif +String GDKPlatform::GetSystemName() +{ + return String(SystemAnalyticsInfo.form); +} + +Version GDKPlatform::GetSystemVersion() +{ + XVersion version = SystemAnalyticsInfo.hostingOsVersion; + return Version(version.major, version.minor, version.build, version.revision); +} + BatteryInfo GDKPlatform::GetBatteryInfo() { BatteryInfo info; diff --git a/Source/Engine/Platform/GDK/GDKPlatform.h b/Source/Engine/Platform/GDK/GDKPlatform.h index 98297cf33..eb8c9ec8e 100644 --- a/Source/Engine/Platform/GDK/GDKPlatform.h +++ b/Source/Engine/Platform/GDK/GDKPlatform.h @@ -61,6 +61,8 @@ public: static void Log(const StringView& msg); static bool IsDebuggerPresent(); #endif + static String GetSystemName(); + static Version GetSystemVersion(); static BatteryInfo GetBatteryInfo(); static int32 GetDpi(); static String GetUserLocaleName(); diff --git a/Source/Engine/Platform/Linux/LinuxPlatform.cpp b/Source/Engine/Platform/Linux/LinuxPlatform.cpp index 354560c34..cfc78a0e4 100644 --- a/Source/Engine/Platform/Linux/LinuxPlatform.cpp +++ b/Source/Engine/Platform/Linux/LinuxPlatform.cpp @@ -8,6 +8,7 @@ #include "Engine/Core/Log.h" #include "Engine/Core/Types/Guid.h" #include "Engine/Core/Types/String.h" +#include "Engine/Core/Types/Version.h" #include "Engine/Core/Collections/HashFunctions.h" #include "Engine/Core/Collections/Array.h" #include "Engine/Core/Collections/Dictionary.h" @@ -19,6 +20,7 @@ #include "Engine/Platform/MemoryStats.h" #include "Engine/Platform/StringUtils.h" #include "Engine/Platform/MessageBox.h" +#include "Engine/Platform/File.h" #include "Engine/Platform/WindowsManager.h" #include "Engine/Platform/CreateProcessSettings.h" #include "Engine/Platform/Clipboard.h" @@ -2646,6 +2648,25 @@ void LinuxPlatform::Exit() } } +String LinuxPlatform::GetSystemName() +{ + Dictionary configs = LoadConfigFile(TEXT("/etc/os-release")); + String str; + if (configs.TryGet(TEXT("NAME"), str)) + return str; + return TEXT("Linux"); +} + +Version LinuxPlatform::GetSystemVersion() +{ + Dictionary configs = LoadConfigFile(TEXT("/etc/os-release")); + String str; + Version version; + if (configs.TryGet(TEXT("VERSION_ID"), str) && !Version::Parse(str, &version)) + return version; + return Version(0, 0); +} + int32 LinuxPlatform::GetDpi() { return SystemDpi; diff --git a/Source/Engine/Platform/Linux/LinuxPlatform.h b/Source/Engine/Platform/Linux/LinuxPlatform.h index 864e27812..faf41febc 100644 --- a/Source/Engine/Platform/Linux/LinuxPlatform.h +++ b/Source/Engine/Platform/Linux/LinuxPlatform.h @@ -94,6 +94,8 @@ public: __builtin_prefetch(static_cast(ptr)); } static bool Is64BitPlatform(); + static String GetSystemName(); + static Version GetSystemVersion(); static CPUInfo GetCPUInfo(); static MemoryStats GetMemoryStats(); static ProcessMemoryStats GetProcessMemoryStats(); diff --git a/Source/Engine/Platform/Mac/MacPlatform.h b/Source/Engine/Platform/Mac/MacPlatform.h index c47d1b118..8e4efb887 100644 --- a/Source/Engine/Platform/Mac/MacPlatform.h +++ b/Source/Engine/Platform/Mac/MacPlatform.h @@ -12,21 +12,20 @@ class FLAXENGINE_API MacPlatform : public ApplePlatform { public: - // [ApplePlatform] static bool Init(); static void LogInfo(); static void BeforeRun(); static void Tick(); static int32 GetDpi(); - static Guid GetUniqueDeviceId(); + static Guid GetUniqueDeviceId(); static String GetComputerName(); static Float2 GetMousePosition(); static void SetMousePosition(const Float2& pos); static Rectangle GetMonitorBounds(const Float2& screenPos); static Float2 GetDesktopSize(); static Rectangle GetVirtualDesktopBounds(); - static String GetMainDirectory(); + static String GetMainDirectory(); static Window* CreateWindow(const CreateWindowSettings& settings); static int32 CreateProcess(CreateProcessSettings& settings); }; diff --git a/Source/Engine/Platform/Windows/WindowsPlatform.cpp b/Source/Engine/Platform/Windows/WindowsPlatform.cpp index 41ea7a340..20e17e800 100644 --- a/Source/Engine/Platform/Windows/WindowsPlatform.cpp +++ b/Source/Engine/Platform/Windows/WindowsPlatform.cpp @@ -11,8 +11,8 @@ #include "Engine/Platform/MemoryStats.h" #include "Engine/Platform/BatteryInfo.h" #include "Engine/Platform/Base/PlatformUtils.h" -#include "Engine/Engine/Globals.h" #include "Engine/Core/Log.h" +#include "Engine/Core/Types/Version.h" #include "Engine/Core/Collections/Dictionary.h" #include "Engine/Core/Collections/Array.h" #include "Engine/Platform/MessageBox.h" @@ -793,6 +793,16 @@ void WindowsPlatform::SetHighDpiAwarenessEnabled(bool enable) ::FreeLibrary(shCoreDll); } +String WindowsPlatform::GetSystemName() +{ + return WindowsName; +} + +Version WindowsPlatform::GetSystemVersion() +{ + return Version(VersionMajor, VersionMinor, VersionBuild); +} + BatteryInfo WindowsPlatform::GetBatteryInfo() { BatteryInfo info; diff --git a/Source/Engine/Platform/Windows/WindowsPlatform.h b/Source/Engine/Platform/Windows/WindowsPlatform.h index 046b79d58..c01b6cdaa 100644 --- a/Source/Engine/Platform/Windows/WindowsPlatform.h +++ b/Source/Engine/Platform/Windows/WindowsPlatform.h @@ -67,6 +67,8 @@ public: static bool IsDebuggerPresent(); #endif static void SetHighDpiAwarenessEnabled(bool enable); + static String GetSystemName(); + static Version GetSystemVersion(); static BatteryInfo GetBatteryInfo(); static int32 GetDpi(); static String GetUserLocaleName(); diff --git a/Source/Engine/Platform/iOS/iOSPlatform.h b/Source/Engine/Platform/iOS/iOSPlatform.h index 87d08e2a6..f6dffea61 100644 --- a/Source/Engine/Platform/iOS/iOSPlatform.h +++ b/Source/Engine/Platform/iOS/iOSPlatform.h @@ -18,7 +18,6 @@ public: static void RunOnMainThread(const Function& func, bool wait = false); public: - // [ApplePlatform] static bool Init(); static void LogInfo();