From 63445e107a0da2584475b16539d2499f54153909 Mon Sep 17 00:00:00 2001 From: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> Date: Fri, 30 Jul 2021 17:33:50 -0700 Subject: [PATCH] fxies for AzFramework Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> --- .../Network/AssetProcessorConnection.cpp | 2 +- .../Android/platform_android_files.cmake | 1 - .../AssetProcessorConnection_Default.cpp | 24 ------------------ .../AzFramework/IO/LocalFileIO_WinAPI.cpp | 17 ++++++++----- .../AssetProcessorConnection_WinAPI.cpp | 25 ------------------- .../Platform/Linux/platform_linux_files.cmake | 1 - .../Platform/Mac/platform_mac_files.cmake | 1 - .../AssetSystemComponentHelper_Windows.cpp | 12 ++++++--- .../TargetManagementComponent_Windows.cpp | 9 ++++--- .../Windowing/NativeWindow_Windows.cpp | 17 ++++++++----- .../Windows/platform_windows_files.cmake | 1 - .../Platform/iOS/platform_ios_files.cmake | 1 - 12 files changed, 36 insertions(+), 75 deletions(-) delete mode 100644 Code/Framework/AzFramework/Platform/Common/Default/AzFramework/Network/AssetProcessorConnection_Default.cpp delete mode 100644 Code/Framework/AzFramework/Platform/Common/WinAPI/AzFramework/Network/AssetProcessorConnection_WinAPI.cpp diff --git a/Code/Framework/AzFramework/AzFramework/Network/AssetProcessorConnection.cpp b/Code/Framework/AzFramework/AzFramework/Network/AssetProcessorConnection.cpp index a65a3079a0..ebea29c2d9 100644 --- a/Code/Framework/AzFramework/AzFramework/Network/AssetProcessorConnection.cpp +++ b/Code/Framework/AzFramework/AzFramework/Network/AssetProcessorConnection.cpp @@ -136,7 +136,7 @@ namespace AzFramework AZStd::array buffer; azsnprintf(buffer.data(), buffer.size(), "(%p/%#" PRIxPTR "): %s\n", this, numericThreadId, msg.data()); - Platform::DebugOutput(buffer.data()); + AZ::Debug::Platform::OutputToDebugger("AssetProcessorConnection", buffer.data()); #else // ASSETPROCESORCONNECTION_VERBOSE_LOGGING is not defined (void)format; #endif diff --git a/Code/Framework/AzFramework/Platform/Android/platform_android_files.cmake b/Code/Framework/AzFramework/Platform/Android/platform_android_files.cmake index 35b5a10151..c220bc1154 100644 --- a/Code/Framework/AzFramework/Platform/Android/platform_android_files.cmake +++ b/Code/Framework/AzFramework/Platform/Android/platform_android_files.cmake @@ -14,7 +14,6 @@ set(FILES AzFramework/Application/Application_Android.cpp ../Common/Unimplemented/AzFramework/Asset/AssetSystemComponentHelper_Unimplemented.cpp AzFramework/IO/LocalFileIO_Android.cpp - ../Common/Default/AzFramework/Network/AssetProcessorConnection_Default.cpp ../Common/Unimplemented/AzFramework/StreamingInstall/StreamingInstall_Unimplemented.cpp ../Common/Default/AzFramework/TargetManagement/TargetManagementComponent_Default.cpp AzFramework/Windowing/NativeWindow_Android.cpp diff --git a/Code/Framework/AzFramework/Platform/Common/Default/AzFramework/Network/AssetProcessorConnection_Default.cpp b/Code/Framework/AzFramework/Platform/Common/Default/AzFramework/Network/AssetProcessorConnection_Default.cpp deleted file mode 100644 index 5bc020a1d6..0000000000 --- a/Code/Framework/AzFramework/Platform/Common/Default/AzFramework/Network/AssetProcessorConnection_Default.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include - -namespace AzFramework -{ - namespace AssetSystem - { - namespace Platform - { - void DebugOutput(const char* message) - { - fputs("AssetProcessorConnection:", stdout); - fputs(message, stdout); - } - } - } -} diff --git a/Code/Framework/AzFramework/Platform/Common/WinAPI/AzFramework/IO/LocalFileIO_WinAPI.cpp b/Code/Framework/AzFramework/Platform/Common/WinAPI/AzFramework/IO/LocalFileIO_WinAPI.cpp index 4c7d84b511..58afebfb90 100644 --- a/Code/Framework/AzFramework/Platform/Common/WinAPI/AzFramework/IO/LocalFileIO_WinAPI.cpp +++ b/Code/Framework/AzFramework/Platform/Common/WinAPI/AzFramework/IO/LocalFileIO_WinAPI.cpp @@ -9,6 +9,7 @@ #include #include #include +#include namespace AZ { @@ -33,7 +34,7 @@ namespace AZ char resolvedPath[AZ_MAX_PATH_LEN]; ResolvePath(filePath, resolvedPath, AZ_MAX_PATH_LEN); - AZ::OSString searchPattern; + AZStd::string searchPattern; if ((resolvedPath[0] == 0) || (resolvedPath[1] == 0)) { return ResultCode::Error; // not a valid path. @@ -54,7 +55,9 @@ namespace AZ searchPattern += "\\*.*"; // use our own filtering function! WIN32_FIND_DATA findData; - HANDLE hFind = FindFirstFile(searchPattern.c_str(), &findData); + AZStd::wstring searchPatternW; + AZStd::to_wstring(searchPatternW, searchPattern.c_str()); + HANDLE hFind = FindFirstFileW(searchPatternW.c_str(), &findData); if (hFind != INVALID_HANDLE_VALUE) { @@ -63,15 +66,17 @@ namespace AZ char tempBuffer[AZ_MAX_PATH_LEN]; do { - AZStd::string_view filenameView = findData.cFileName; + AZStd::string fileName; + AZStd::to_string(fileName, findData.cFileName); + AZStd::string_view filenameView = fileName; // Skip over the current directory and parent directory paths to prevent infinite recursion - if (filenameView == "." || filenameView == ".." || !NameMatchesFilter(findData.cFileName, filter)) + if (filenameView == "." || filenameView == ".." || !NameMatchesFilter(fileName.c_str(), filter)) { continue; } - AZ::OSString foundFilePath = CheckForTrailingSlash(resolvedPath); - foundFilePath += findData.cFileName; + AZStd::string foundFilePath = CheckForTrailingSlash(resolvedPath); + foundFilePath += fileName; AZStd::replace(foundFilePath.begin(), foundFilePath.end(), '\\', '/'); // if aliased, de-alias! diff --git a/Code/Framework/AzFramework/Platform/Common/WinAPI/AzFramework/Network/AssetProcessorConnection_WinAPI.cpp b/Code/Framework/AzFramework/Platform/Common/WinAPI/AzFramework/Network/AssetProcessorConnection_WinAPI.cpp deleted file mode 100644 index a02e697df6..0000000000 --- a/Code/Framework/AzFramework/Platform/Common/WinAPI/AzFramework/Network/AssetProcessorConnection_WinAPI.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include -#include - -namespace AzFramework -{ - namespace AssetSystem - { - namespace Platform - { - void DebugOutput(const char* message) - { - OutputDebugString("AssetProcessorConnection:"); - OutputDebugString(message); - } - } - } -} diff --git a/Code/Framework/AzFramework/Platform/Linux/platform_linux_files.cmake b/Code/Framework/AzFramework/Platform/Linux/platform_linux_files.cmake index 60b16938a1..21201d954d 100644 --- a/Code/Framework/AzFramework/Platform/Linux/platform_linux_files.cmake +++ b/Code/Framework/AzFramework/Platform/Linux/platform_linux_files.cmake @@ -17,7 +17,6 @@ set(FILES AzFramework/Process/ProcessCommon.h AzFramework/Process/ProcessCommunicator_Linux.cpp ../Common/UnixLike/AzFramework/IO/LocalFileIO_UnixLike.cpp - ../Common/Default/AzFramework/Network/AssetProcessorConnection_Default.cpp ../Common/Unimplemented/AzFramework/StreamingInstall/StreamingInstall_Unimplemented.cpp ../Common/Default/AzFramework/TargetManagement/TargetManagementComponent_Default.cpp AzFramework/Windowing/NativeWindow_Linux.cpp diff --git a/Code/Framework/AzFramework/Platform/Mac/platform_mac_files.cmake b/Code/Framework/AzFramework/Platform/Mac/platform_mac_files.cmake index c428160892..78f11a65da 100644 --- a/Code/Framework/AzFramework/Platform/Mac/platform_mac_files.cmake +++ b/Code/Framework/AzFramework/Platform/Mac/platform_mac_files.cmake @@ -17,7 +17,6 @@ set(FILES AzFramework/Process/ProcessCommon.h AzFramework/Process/ProcessCommunicator_Mac.cpp ../Common/UnixLike/AzFramework/IO/LocalFileIO_UnixLike.cpp - ../Common/Default/AzFramework/Network/AssetProcessorConnection_Default.cpp ../Common/Unimplemented/AzFramework/StreamingInstall/StreamingInstall_Unimplemented.cpp AzFramework/TargetManagement/TargetManagementComponent_Mac.cpp AzFramework/Windowing/NativeWindow_Mac.mm diff --git a/Code/Framework/AzFramework/Platform/Windows/AzFramework/Asset/AssetSystemComponentHelper_Windows.cpp b/Code/Framework/AzFramework/Platform/Windows/AzFramework/Asset/AssetSystemComponentHelper_Windows.cpp index 4b685b25a3..a3782ae081 100644 --- a/Code/Framework/AzFramework/Platform/Windows/AzFramework/Asset/AssetSystemComponentHelper_Windows.cpp +++ b/Code/Framework/AzFramework/Platform/Windows/AzFramework/Asset/AssetSystemComponentHelper_Windows.cpp @@ -48,10 +48,10 @@ namespace AzFramework::AssetSystem::Platform // Get the first module, because that will be the executable if (EnumProcessModules(processHandle, &moduleHandle, sizeof(moduleHandle), &bytesNeededForAllProcessModules)) { - char processName[4096] = TEXT(""); - if (GetModuleBaseNameA(processHandle, moduleHandle, processName, AZ_ARRAY_SIZE(processName)) > 0) + wchar_t processName[4096] = L""; + if (GetModuleBaseName(processHandle, moduleHandle, processName, AZ_ARRAY_SIZE(processName)) > 0) { - if (azstricmp(processName, "AssetProcessor") == 0) + if (azwcsicmp(processName, L"AssetProcessor") == 0) { AllowSetForegroundWindow(processId); } @@ -126,7 +126,11 @@ namespace AzFramework::AssetSystem::Platform si.wShowWindow = SW_MINIMIZE; PROCESS_INFORMATION pi; - bool createResult = ::CreateProcessA(nullptr, fullLaunchCommand.data(), nullptr, nullptr, FALSE, 0, nullptr, AZ::IO::FixedMaxPathString{ executableDirectory }.c_str(), &si, &pi) != 0; + AZStd::wstring fullLaunchCommandW; + AZStd::to_wstring(fullLaunchCommandW, fullLaunchCommand.c_str()); + AZStd::wstring execututableDirectoryW; + AZStd::to_wstring(execututableDirectoryW, executableDirectory.data()); + bool createResult = ::CreateProcessW(nullptr, fullLaunchCommandW.data(), nullptr, nullptr, FALSE, 0, nullptr, execututableDirectoryW.c_str(), &si, &pi) != 0; if (ap_tether_lifetime && apJob && createResult) { diff --git a/Code/Framework/AzFramework/Platform/Windows/AzFramework/TargetManagement/TargetManagementComponent_Windows.cpp b/Code/Framework/AzFramework/Platform/Windows/AzFramework/TargetManagement/TargetManagementComponent_Windows.cpp index fbfb3778cb..e168968278 100644 --- a/Code/Framework/AzFramework/Platform/Windows/AzFramework/TargetManagement/TargetManagementComponent_Windows.cpp +++ b/Code/Framework/AzFramework/Platform/Windows/AzFramework/TargetManagement/TargetManagementComponent_Windows.cpp @@ -10,6 +10,7 @@ #include #include #include +#include namespace AzFramework { @@ -35,12 +36,12 @@ namespace AzFramework AZStd::string GetNeighborhoodName() { AZStd::string neighborhoodName; - - char localhost[MAX_COMPUTERNAME_LENGTH + 1]; + + wchar_t localhost[MAX_COMPUTERNAME_LENGTH + 1]; DWORD len = AZ_ARRAY_SIZE(localhost); - if (GetComputerName(localhost, &len)) + if (GetComputerNameW(localhost, &len)) { - neighborhoodName = localhost; + AZStd::to_string(neighborhoodName, localhost); } return neighborhoodName; diff --git a/Code/Framework/AzFramework/Platform/Windows/AzFramework/Windowing/NativeWindow_Windows.cpp b/Code/Framework/AzFramework/Platform/Windows/AzFramework/Windowing/NativeWindow_Windows.cpp index 0047929120..22a293891c 100644 --- a/Code/Framework/AzFramework/Platform/Windows/AzFramework/Windowing/NativeWindow_Windows.cpp +++ b/Code/Framework/AzFramework/Platform/Windows/AzFramework/Windowing/NativeWindow_Windows.cpp @@ -11,6 +11,7 @@ #include #include +#include namespace AzFramework { @@ -41,7 +42,7 @@ namespace AzFramework static DWORD ConvertToWin32WindowStyleMask(const WindowStyleMasks& styleMasks); static LRESULT CALLBACK WindowCallback(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); - static const char* s_defaultClassName; + static const wchar_t* s_defaultClassName; void WindowSizeChanged(const uint32_t width, const uint32_t height); @@ -57,7 +58,7 @@ namespace AzFramework GetDpiForWindowType* m_getDpiFunction = nullptr; }; - const char* NativeWindowImpl_Win32::s_defaultClassName = "O3DEWin32Class"; + const wchar_t* NativeWindowImpl_Win32::s_defaultClassName = L"O3DEWin32Class"; NativeWindow::Implementation* NativeWindow::Implementation::Create() { @@ -88,7 +89,7 @@ namespace AzFramework // register window class if it does not exist WNDCLASSEX windowClass; - if (GetClassInfoEx(hInstance, s_defaultClassName, &windowClass) == false) + if (GetClassInfoExW(hInstance, s_defaultClassName, &windowClass) == false) { windowClass.cbSize = sizeof(WNDCLASSEX); windowClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; @@ -127,8 +128,10 @@ namespace AzFramework m_height = geometry.m_height; // create main window - m_win32Handle = CreateWindow( - s_defaultClassName, title.c_str(), + AZStd::wstring titleW; + AZStd::to_wstring(titleW, title); + m_win32Handle = CreateWindowW( + s_defaultClassName, titleW.c_str(), windowStyle, geometry.m_posX, geometry.m_posY, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top, NULL, NULL, hInstance, NULL); @@ -175,7 +178,9 @@ namespace AzFramework void NativeWindowImpl_Win32::SetWindowTitle(const AZStd::string& title) { - SetWindowText(m_win32Handle, title.c_str()); + AZStd::wstring titleW; + AZStd::to_wstring(titleW, title); + SetWindowTextW(m_win32Handle, titleW.c_str()); } DWORD NativeWindowImpl_Win32::ConvertToWin32WindowStyleMask(const WindowStyleMasks& styleMasks) diff --git a/Code/Framework/AzFramework/Platform/Windows/platform_windows_files.cmake b/Code/Framework/AzFramework/Platform/Windows/platform_windows_files.cmake index af43234bd0..b8f5b5f841 100644 --- a/Code/Framework/AzFramework/Platform/Windows/platform_windows_files.cmake +++ b/Code/Framework/AzFramework/Platform/Windows/platform_windows_files.cmake @@ -18,7 +18,6 @@ set(FILES AzFramework/Process/ProcessCommunicator_Win.cpp ../Common/WinAPI/AzFramework/IO/LocalFileIO_WinAPI.cpp AzFramework/IO/LocalFileIO_Windows.cpp - ../Common/WinAPI/AzFramework/Network/AssetProcessorConnection_WinAPI.cpp ../Common/Unimplemented/AzFramework/StreamingInstall/StreamingInstall_Unimplemented.cpp AzFramework/TargetManagement/TargetManagementComponent_Windows.cpp AzFramework/Windowing/NativeWindow_Windows.cpp diff --git a/Code/Framework/AzFramework/Platform/iOS/platform_ios_files.cmake b/Code/Framework/AzFramework/Platform/iOS/platform_ios_files.cmake index f47eb136be..7745f43ec9 100644 --- a/Code/Framework/AzFramework/Platform/iOS/platform_ios_files.cmake +++ b/Code/Framework/AzFramework/Platform/iOS/platform_ios_files.cmake @@ -14,7 +14,6 @@ set(FILES AzFramework/Application/Application_iOS.mm ../Common/Unimplemented/AzFramework/Asset/AssetSystemComponentHelper_Unimplemented.cpp ../Common/UnixLike/AzFramework/IO/LocalFileIO_UnixLike.cpp - ../Common/Default/AzFramework/Network/AssetProcessorConnection_Default.cpp ../Common/Unimplemented/AzFramework/StreamingInstall/StreamingInstall_Unimplemented.cpp ../Common/Default/AzFramework/TargetManagement/TargetManagementComponent_Default.cpp AzFramework/Windowing/NativeWindow_ios.mm