From 6218b08e993cc2bf2f9779cb8fea5dcd402d76eb Mon Sep 17 00:00:00 2001 From: Steve Lhomme Date: Thu, 18 Jan 2024 01:33:23 -0800 Subject: [PATCH 1/2] add a define for Windows Games builds The proper way would be to use WINAPI_PARTITION() but I did it in the same format as before. --- Source/ZenLib/Conf.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Source/ZenLib/Conf.h b/Source/ZenLib/Conf.h index 18264cfe..14d4d5a9 100644 --- a/Source/ZenLib/Conf.h +++ b/Source/ZenLib/Conf.h @@ -63,6 +63,11 @@ #define WINDOWS_UWP #endif #endif + #if defined(WINAPI_FAMILY) && (WINAPI_FAMILY==WINAPI_FAMILY_GAMES) + #ifndef WINDOWS_GAMES + #define WINDOWS_GAMES + #endif + #endif #endif //--------------------------------------------------------------------------- From b770ce91da3b497a00325fe9c272534ce6275604 Mon Sep 17 00:00:00 2001 From: Steve Lhomme Date: Thu, 18 Jan 2024 02:05:32 -0800 Subject: [PATCH 2/2] don't call Windows API not available when building for Games --- Source/ZenLib/FileName.cpp | 14 +++++++++----- Source/ZenLib/OS_Utils.cpp | 4 ++-- Source/ZenLib/Ztring.cpp | 4 +++- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Source/ZenLib/FileName.cpp b/Source/ZenLib/FileName.cpp index d26784ca..2f48d6ac 100644 --- a/Source/ZenLib/FileName.cpp +++ b/Source/ZenLib/FileName.cpp @@ -190,11 +190,15 @@ Ztring FileName::TempFileName_Create(const Ztring &Prefix) if (!GetTempPath(MAX_PATH, Path)) return Ztring(); //Problem while getting a temp path - Char FileName[MAX_PATH+1]; - if (!GetTempFileName(Path, Prefix.c_str(), 0, FileName)) - return Ztring(); //Problem while getting a file name - - return Ztring(FileName); + #ifndef WINDOWS_GAMES + Char FileName[MAX_PATH+1]; + if (!GetTempFileName(Path, Prefix.c_str(), 0, FileName)) + return Ztring(); //Problem while getting a file name + + return Ztring(FileName); + #else // #ifdef WINDOWS_GAMES + return __T("D:\\xxx.txt"); + #endif // #ifdef WINDOWS_GAMES #else return __T("C:\\xxx.txt"); #endif diff --git a/Source/ZenLib/OS_Utils.cpp b/Source/ZenLib/OS_Utils.cpp index ac92b4d3..841a2eb6 100644 --- a/Source/ZenLib/OS_Utils.cpp +++ b/Source/ZenLib/OS_Utils.cpp @@ -234,7 +234,7 @@ void Shell_Execute(const Ztring &ToExecute) { #ifdef ZENLIB_USEWX #else //ZENLIB_USEWX - #if defined(WINDOWS) && !defined(WINDOWS_UWP) + #if defined(WINDOWS) && !defined(WINDOWS_UWP) && !defined(WINDOWS_GAMES) ShellExecute(NULL, __T("open"), ToExecute.c_str(), NULL, NULL, 0); #else //Not supported @@ -252,7 +252,7 @@ void Shell_Execute(const Ztring &ToExecute) Ztring Directory_Select_Caption; -#if defined(WINDOWS) && !defined(WINDOWS_UWP) +#if defined(WINDOWS) && !defined(WINDOWS_UWP) && !defined(WINDOWS_GAMES) #ifdef UNICODE char InitDirA[MAX_PATH]; wchar_t InitDir [MAX_PATH]; diff --git a/Source/ZenLib/Ztring.cpp b/Source/ZenLib/Ztring.cpp index 31525b5e..027a29cc 100644 --- a/Source/ZenLib/Ztring.cpp +++ b/Source/ZenLib/Ztring.cpp @@ -32,7 +32,9 @@ #ifdef WINDOWS #undef __TEXT #include - #include + #ifndef WINDOWS_GAMES + #include + #endif #endif #endif //ZENLIB_USEWX #ifdef __MINGW32__