Fixes and tweaks

This commit is contained in:
Wojciech Figat
2022-01-26 16:55:22 +01:00
parent 05a935660d
commit 18b156ad44
9 changed files with 94 additions and 37 deletions

View File

@@ -294,6 +294,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=mipmaps/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=mipmaps/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Mordor/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Mordor/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=MSAA/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=MSAA/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=multiplayer/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Multisample/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Multisample/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=multisampled/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=multisampled/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=multisampling/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=multisampling/@EntryIndexedValue">True</s:Boolean>

View File

@@ -52,17 +52,15 @@ int32 GameBase::LoadProduct()
// Load build game header file // Load build game header file
{ {
int32 tmp;
Array<byte> data;
FileReadStream* stream = nullptr;
#if 1 #if 1
// Open file // Open file
FileReadStream* stream = nullptr;
stream = FileReadStream::Open(Globals::ProjectFolder / TEXT("Content/head")); stream = FileReadStream::Open(Globals::ProjectFolder / TEXT("Content/head"));
if (stream == nullptr) if (stream == nullptr)
goto LOAD_GAME_HEAD_FAILED; goto LOAD_GAME_HEAD_FAILED;
// Check header // Check header
int32 tmp;
stream->ReadInt32(&tmp); stream->ReadInt32(&tmp);
if (tmp != ('x' + 'D') * 131) if (tmp != ('x' + 'D') * 131)
goto LOAD_GAME_HEAD_FAILED; goto LOAD_GAME_HEAD_FAILED;
@@ -73,6 +71,7 @@ int32 GameBase::LoadProduct()
goto LOAD_GAME_HEAD_FAILED; goto LOAD_GAME_HEAD_FAILED;
// Load game primary data // Load game primary data
Array<byte> data;
stream->ReadArray(&data); stream->ReadArray(&data);
if (data.Count() != 808 + sizeof(Guid)) if (data.Count() != 808 + sizeof(Guid))
goto LOAD_GAME_HEAD_FAILED; goto LOAD_GAME_HEAD_FAILED;

View File

@@ -251,8 +251,8 @@ bool GPUDeviceDX12::Init()
updateFrameEvents(); updateFrameEvents();
#if PLATFORM_GDK #if PLATFORM_GDK
GDKPlatform::OnSuspend.Bind<GPUDeviceDX12, &GPUDeviceDX12::OnSuspend>(this); GDKPlatform::Suspended.Bind<GPUDeviceDX12, &GPUDeviceDX12::OnSuspended>(this);
GDKPlatform::OnResume.Bind<GPUDeviceDX12, &GPUDeviceDX12::OnResume>(this); GDKPlatform::Resumed.Bind<GPUDeviceDX12, &GPUDeviceDX12::OnResumed>(this);
#endif #endif
#else #else
// Get DXGI adapter // Get DXGI adapter
@@ -838,12 +838,12 @@ void GPUDeviceDX12::updateRes2Dispose()
#if PLATFORM_XBOX_SCARLETT || PLATFORM_XBOX_ONE #if PLATFORM_XBOX_SCARLETT || PLATFORM_XBOX_ONE
void GPUDeviceDX12::OnSuspend() void GPUDeviceDX12::OnSuspended()
{ {
_commandQueue->GetCommandQueue()->SuspendX(0); _commandQueue->GetCommandQueue()->SuspendX(0);
} }
void GPUDeviceDX12::OnResume() void GPUDeviceDX12::OnResumed()
{ {
_commandQueue->GetCommandQueue()->ResumeX(); _commandQueue->GetCommandQueue()->ResumeX();

View File

@@ -158,8 +158,8 @@ public:
} }
#if PLATFORM_XBOX_SCARLETT ||PLATFORM_XBOX_ONE #if PLATFORM_XBOX_SCARLETT ||PLATFORM_XBOX_ONE
void OnSuspend(); void OnSuspended();
void OnResume(); void OnResumed();
#endif #endif
private: private:

View File

@@ -406,6 +406,12 @@ bool StringUtils::Parse(const Char* str, float* result)
return false; return false;
} }
bool StringUtils::Parse(const char* str, float* result)
{
*result = (float)atof(str);
return false;
}
String StringUtils::ToString(int32 value) String StringUtils::ToString(int32 value)
{ {
char buf[STRING_UTILS_ITOSTR_BUFFER_SIZE]; char buf[STRING_UTILS_ITOSTR_BUFFER_SIZE];

View File

@@ -21,6 +21,10 @@
#include <XGameRuntime.h> #include <XGameRuntime.h>
#include <appnotify.h> #include <appnotify.h>
#define GDK_LOG(result, method) \
if (FAILED(result)) \
LOG(Error, "GDK method {0} failed with result 0x{1:x}", TEXT(method), (uint32)result)
inline bool operator==(const APP_LOCAL_DEVICE_ID& l, const APP_LOCAL_DEVICE_ID& r) inline bool operator==(const APP_LOCAL_DEVICE_ID& l, const APP_LOCAL_DEVICE_ID& r)
{ {
return Platform::MemoryCompare(&l, &r, sizeof(APP_LOCAL_DEVICE_ID)) == 0; return Platform::MemoryCompare(&l, &r, sizeof(APP_LOCAL_DEVICE_ID)) == 0;
@@ -28,8 +32,8 @@ inline bool operator==(const APP_LOCAL_DEVICE_ID& l, const APP_LOCAL_DEVICE_ID&
const Char* GDKPlatform::ApplicationWindowClass = TEXT("FlaxWindow"); const Char* GDKPlatform::ApplicationWindowClass = TEXT("FlaxWindow");
void* GDKPlatform::Instance = nullptr; void* GDKPlatform::Instance = nullptr;
Delegate<> GDKPlatform::OnSuspend; Delegate<> GDKPlatform::Suspended;
Delegate<> GDKPlatform::OnResume; Delegate<> GDKPlatform::Resumed;
namespace namespace
{ {
@@ -51,7 +55,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
LOG(Info, "Suspending application"); LOG(Info, "Suspending application");
IsSuspended = true; IsSuspended = true;
GDKPlatform::OnSuspend(); GDKPlatform::Suspended();
// Complete deferral // Complete deferral
SetEvent(PlmSuspendComplete); SetEvent(PlmSuspendComplete);
@@ -60,7 +64,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
IsSuspended = false; IsSuspended = false;
LOG(Info, "Resuming application"); LOG(Info, "Resuming application");
GDKPlatform::OnResume(); GDKPlatform::Resumed();
return DefWindowProc(hWnd, msg, wParam, lParam); return DefWindowProc(hWnd, msg, wParam, lParam);
} }
} }
@@ -93,6 +97,7 @@ void CALLBACK UserChangeEventCallback(_In_opt_ void* context, _In_ XUserLocalId
if (user) if (user)
{ {
// Logout // Logout
LOG(Info, "GDK user '{0}' logged out", user->GetName());
OnPlatformUserRemove(user); OnPlatformUserRemove(user);
} }
break; break;
@@ -161,8 +166,9 @@ void OnMainWindowCreated(HWND hWnd)
void CALLBACK AddUserComplete(_In_ XAsyncBlock* ab) void CALLBACK AddUserComplete(_In_ XAsyncBlock* ab)
{ {
XUserHandle userHandle; XUserHandle userHandle;
HRESULT hr = XUserAddResult(ab, &userHandle); HRESULT result = XUserAddResult(ab, &userHandle);
if (SUCCEEDED(hr)) delete ab;
if (SUCCEEDED(result))
{ {
XUserLocalId userLocalId; XUserLocalId userLocalId;
XUserGetLocalId(userHandle, &userLocalId); XUserGetLocalId(userHandle, &userLocalId);
@@ -173,12 +179,24 @@ void CALLBACK AddUserComplete(_In_ XAsyncBlock* ab)
if (Platform::FindUser(localId) == nullptr) if (Platform::FindUser(localId) == nullptr)
{ {
// Login // Login
auto user = New<User>(userHandle, userLocalId, String::Empty); char gamerTag[XUserGamertagComponentModernMaxBytes];
size_t gamerTagSize;
XUserGetGamertag(userHandle, XUserGamertagComponent::Modern, ARRAY_COUNT(gamerTag), gamerTag, &gamerTagSize);
String name;
name.SetUTF8(gamerTag, StringUtils::Length(gamerTag));
LOG(Info, "GDK user '{0}' logged in", name);
auto user = New<User>(userHandle, userLocalId, name);
OnPlatformUserAdd(user); OnPlatformUserAdd(user);
} }
} }
else if (result == E_GAMEUSER_NO_DEFAULT_USER || result == E_GAMEUSER_RESOLVE_USER_ISSUE_REQUIRED || result == 0x8015DC12)
delete ab; {
Platform::SignInWithUI();
}
else
{
GDK_LOG(result, "XUserAddResult");
}
} }
DialogResult MessageBox::Show(Window* parent, const StringView& text, const StringView& caption, MessageBoxButtons buttons, MessageBoxIcon icon) DialogResult MessageBox::Show(Window* parent, const StringView& text, const StringView& caption, MessageBoxButtons buttons, MessageBoxIcon icon)
@@ -312,6 +330,32 @@ bool GDKPlatform::IsRunningOnDevKit()
return deviceType == XSystemDeviceType::XboxOneXDevkit || deviceType == XSystemDeviceType::XboxScarlettDevkit; return deviceType == XSystemDeviceType::XboxOneXDevkit || deviceType == XSystemDeviceType::XboxScarlettDevkit;
} }
void GDKPlatform::SignInSilently()
{
auto asyncBlock = new XAsyncBlock();
asyncBlock->queue = TaskQueue;
asyncBlock->callback = AddUserComplete;
HRESULT result = XUserAddAsync(XUserAddOptions::AddDefaultUserSilently, asyncBlock);
if (FAILED(result))
{
GDK_LOG(result, "XUserAddAsync");
delete asyncBlock;
}
}
void GDKPlatform::SignInWithUI()
{
auto ab = new XAsyncBlock();
ab->queue = TaskQueue;
ab->callback = AddUserComplete;
HRESULT result = XUserAddAsync(XUserAddOptions::AllowGuests, ab);
if (FAILED(result))
{
GDK_LOG(result, "XUserAddAsync");
delete ab;
}
}
User* GDKPlatform::FindUser(const XUserLocalId& id) User* GDKPlatform::FindUser(const XUserLocalId& id)
{ {
User* result = nullptr; User* result = nullptr;
@@ -366,29 +410,27 @@ bool GDKPlatform::Init()
&UserDeviceAssociationChangedCallbackToken &UserDeviceAssociationChangedCallbackToken
); );
// Login the default user
{
auto asyncBlock = new XAsyncBlock();
asyncBlock->queue = TaskQueue;
asyncBlock->callback = AddUserComplete;
HRESULT hr = XUserAddAsync(XUserAddOptions::AddDefaultUserAllowingUI, asyncBlock);
if (FAILED(hr))
delete asyncBlock;
}
GDKInput::Init(); GDKInput::Init();
return false; return false;
} }
void GDKPlatform::BeforeRun() void GDKPlatform::LogInfo()
{ {
Win32Platform::LogInfo();
// Log system info // Log system info
const XSystemAnalyticsInfo analyticsInfo = XSystemGetAnalyticsInfo(); const XSystemAnalyticsInfo analyticsInfo = XSystemGetAnalyticsInfo();
LOG(Info, "{0}, {1}", StringAsUTF16<64>(analyticsInfo.family).Get(), StringAsUTF16<64>(analyticsInfo.form).Get()); 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); LOG(Info, "OS Version {0}.{1}.{2}.{3}", analyticsInfo.osVersion.major, analyticsInfo.osVersion.minor, analyticsInfo.osVersion.build, analyticsInfo.osVersion.revision);
} }
void GDKPlatform::BeforeRun()
{
// Login the default user
SignInSilently();
}
void GDKPlatform::Tick() void GDKPlatform::Tick()
{ {
PROFILE_CPU_NAMED("Application.Tick"); PROFILE_CPU_NAMED("Application.Tick");

View File

@@ -23,8 +23,8 @@ public:
/// </summary> /// </summary>
static void* Instance; static void* Instance;
static Delegate<> OnSuspend; static Delegate<> Suspended;
static Delegate<> OnResume; static Delegate<> Resumed;
public: public:
@@ -44,12 +44,15 @@ public:
static bool IsRunningOnDevKit(); static bool IsRunningOnDevKit();
static void SignInSilently();
static void SignInWithUI();
static User* FindUser(const struct XUserLocalId& id); static User* FindUser(const struct XUserLocalId& id);
public: public:
// [Win32Platform] // [Win32Platform]
static bool Init(); static bool Init();
static void LogInfo();
static void BeforeRun(); static void BeforeRun();
static void Tick(); static void Tick();
static void BeforeExit(); static void BeforeExit();

View File

@@ -15,9 +15,8 @@ class Texture;
/// </summary> /// </summary>
API_CLASS(Namespace="FlaxEditor.Content.Settings") class FLAXENGINE_API GDKPlatformSettings : public SettingsBase API_CLASS(Namespace="FlaxEditor.Content.Settings") class FLAXENGINE_API GDKPlatformSettings : public SettingsBase
{ {
DECLARE_SCRIPTING_TYPE_MINIMAL(GDKPlatformSettings); DECLARE_SCRIPTING_TYPE_MINIMAL(GDKPlatformSettings);
public: public:
/// <summary> /// <summary>
/// Game identity name stored in game package manifest (for store). If empty the product name will be used from Game Settings. /// Game identity name stored in game package manifest (for store). If empty the product name will be used from Game Settings.
/// </summary> /// </summary>
@@ -96,6 +95,12 @@ public:
API_FIELD(Attributes="EditorOrder(320), EditorDisplay(\"Xbox Live\")") API_FIELD(Attributes="EditorOrder(320), EditorDisplay(\"Xbox Live\")")
bool RequiresXboxLive = false; bool RequiresXboxLive = false;
/// <summary>
/// Service Configuration ID (see Xbox Live docs).
/// </summary>
API_FIELD(Attributes="EditorOrder(330), EditorDisplay(\"Xbox Live\")")
StringAnsi SCID;
/// <summary> /// <summary>
/// Specifies if the Game DVR system component is enabled or not. /// Specifies if the Game DVR system component is enabled or not.
/// </summary> /// </summary>
@@ -106,16 +111,15 @@ public:
/// Specifies if broadcasting the title should be blocked or allowed. /// Specifies if broadcasting the title should be blocked or allowed.
/// </summary> /// </summary>
API_FIELD(Attributes="EditorOrder(410), EditorDisplay(\"Media Capture\")") API_FIELD(Attributes="EditorOrder(410), EditorDisplay(\"Media Capture\")")
bool BlockBroadcast = false; bool BlockBroadcast = false;
/// <summary> /// <summary>
/// Specifies if Game DVR of the title should be blocked or allowed. /// Specifies if Game DVR of the title should be blocked or allowed.
/// </summary> /// </summary>
API_FIELD(Attributes="EditorOrder(420), EditorDisplay(\"Media Capture\")") API_FIELD(Attributes="EditorOrder(420), EditorDisplay(\"Media Capture\")")
bool BlockGameDVR = false; bool BlockGameDVR = false;
public: public:
// [SettingsBase] // [SettingsBase]
void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) override void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) override
{ {
@@ -131,6 +135,7 @@ public:
DESERIALIZE(TitleId); DESERIALIZE(TitleId);
DESERIALIZE(StoreId); DESERIALIZE(StoreId);
DESERIALIZE(RequiresXboxLive); DESERIALIZE(RequiresXboxLive);
DESERIALIZE(SCID);
DESERIALIZE(GameDVRSystemComponent); DESERIALIZE(GameDVRSystemComponent);
DESERIALIZE(BlockBroadcast); DESERIALIZE(BlockBroadcast);
DESERIALIZE(BlockGameDVR); DESERIALIZE(BlockGameDVR);

View File

@@ -428,6 +428,7 @@ public:
// @return Result value // @return Result value
// @returns True if cannot convert data, otherwise false // @returns True if cannot convert data, otherwise false
static bool Parse(const Char* str, float* result); static bool Parse(const Char* str, float* result);
static bool Parse(const char* str, float* result);
public: public: