Add Platform.Users to handle users per-platform

This commit is contained in:
Wojtek Figat
2021-11-07 20:46:56 +01:00
parent 21e6e8bc7b
commit b3eb17f61e
17 changed files with 203 additions and 94 deletions

View File

@@ -5,6 +5,7 @@
#include "Engine/Platform/MemoryStats.h"
#include "Engine/Platform/MessageBox.h"
#include "Engine/Platform/FileSystem.h"
#include "Engine/Platform/User.h"
#include "Engine/Core/Log.h"
#include "Engine/Core/Types/DateTime.h"
#include "Engine/Core/Types/TimeSpan.h"
@@ -40,6 +41,9 @@ static_assert(sizeof(float) == 4, "Invalid float type size.");
static_assert(sizeof(double) == 8, "Invalid double type size.");
float PlatformBase::CustomDpiScale = 1.0f;
Array<User*, FixedAllocation<8>> PlatformBase::Users;
Delegate<User*> PlatformBase::UserAdded;
Delegate<User*> PlatformBase::UserRemoved;
const Char* ToString(NetworkConnectionType value)
{
@@ -102,6 +106,22 @@ const Char* ToString(ThreadPriority value)
}
}
UserBase::UserBase(const String& name)
: UserBase(SpawnParams(Guid::New(), TypeInitializer), name)
{
}
UserBase::UserBase(const SpawnParams& params, const String& name)
: PersistentScriptingObject(params)
, _name(name)
{
}
String UserBase::GetName() const
{
return _name;
}
bool PlatformBase::Init()
{
#if BUILD_DEBUG
@@ -462,6 +482,11 @@ ScreenOrientationType PlatformBase::GetScreenOrientationType()
return ScreenOrientationType::Unknown;
}
String PlatformBase::GetUserName()
{
return Users.Count() != 0 ? Users[0]->GetName() : String::Empty;
}
bool PlatformBase::GetIsPaused()
{
return false;