Add SystemName and SystemVersion to Platform api
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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<char const*>(ptr));
|
||||
}
|
||||
static bool Is64BitPlatform();
|
||||
static String GetSystemName();
|
||||
static Version GetSystemVersion();
|
||||
static CPUInfo GetCPUInfo();
|
||||
static MemoryStats GetMemoryStats();
|
||||
static ProcessMemoryStats GetProcessMemoryStats();
|
||||
|
||||
@@ -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 <sys/sysctl.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <mach/mach_time.h>
|
||||
#include <mach-o/dyld.h>
|
||||
#include <uuid/uuid.h>
|
||||
#include <os/proc.h>
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include <Foundation/Foundation.h>
|
||||
#include <CoreGraphics/CoreGraphics.h>
|
||||
@@ -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;
|
||||
|
||||
@@ -66,6 +66,8 @@ public:
|
||||
__builtin_prefetch(static_cast<char const*>(ptr));
|
||||
}
|
||||
static bool Is64BitPlatform();
|
||||
static String GetSystemName();
|
||||
static Version GetSystemVersion();
|
||||
static CPUInfo GetCPUInfo();
|
||||
static MemoryStats GetMemoryStats();
|
||||
static ProcessMemoryStats GetProcessMemoryStats();
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <string.h>
|
||||
|
||||
struct Guid;
|
||||
struct Version;
|
||||
struct CPUInfo;
|
||||
struct MemoryStats;
|
||||
struct ProcessMemoryStats;
|
||||
@@ -372,6 +373,16 @@ public:
|
||||
/// <returns>True if running on 64-bit computer, otherwise false.</returns>
|
||||
API_PROPERTY() static bool Is64BitPlatform() = delete;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the operating system.
|
||||
/// </summary>
|
||||
API_PROPERTY() static String GetSystemName() = delete;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the version of the operating system version.
|
||||
/// </summary>
|
||||
API_PROPERTY() static Version GetSystemVersion() = delete;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the CPU information.
|
||||
/// </summary>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
/// <summary>
|
||||
/// Contains information about power supply (battery).
|
||||
/// </summary>
|
||||
API_STRUCT() struct BatteryInfo
|
||||
API_STRUCT(NoDefault) struct BatteryInfo
|
||||
{
|
||||
DECLARE_SCRIPTING_TYPE_MINIMAL(BatteryInfo);
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
/// <summary>
|
||||
/// Contains information about CPU (Central Processing Unit).
|
||||
/// </summary>
|
||||
API_STRUCT() struct CPUInfo
|
||||
API_STRUCT(NoDefault) struct CPUInfo
|
||||
{
|
||||
DECLARE_SCRIPTING_TYPE_MINIMAL(CPUInfo);
|
||||
DECLARE_SCRIPTING_TYPE_MINIMAL(CPUInfo);
|
||||
|
||||
/// <summary>
|
||||
/// The number of physical processor packages.
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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<String, String> configs = LoadConfigFile(TEXT("/etc/os-release"));
|
||||
String str;
|
||||
if (configs.TryGet(TEXT("NAME"), str))
|
||||
return str;
|
||||
return TEXT("Linux");
|
||||
}
|
||||
|
||||
Version LinuxPlatform::GetSystemVersion()
|
||||
{
|
||||
Dictionary<String, String> 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;
|
||||
|
||||
@@ -94,6 +94,8 @@ public:
|
||||
__builtin_prefetch(static_cast<char const*>(ptr));
|
||||
}
|
||||
static bool Is64BitPlatform();
|
||||
static String GetSystemName();
|
||||
static Version GetSystemVersion();
|
||||
static CPUInfo GetCPUInfo();
|
||||
static MemoryStats GetMemoryStats();
|
||||
static ProcessMemoryStats GetProcessMemoryStats();
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -18,7 +18,6 @@ public:
|
||||
static void RunOnMainThread(const Function<void()>& func, bool wait = false);
|
||||
|
||||
public:
|
||||
|
||||
// [ApplePlatform]
|
||||
static bool Init();
|
||||
static void LogInfo();
|
||||
|
||||
Reference in New Issue
Block a user