Launcher_Windows.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <Launcher.h>
  9. #include <AzCore/Math/Vector2.h>
  10. #include <AzCore/Memory/SystemAllocator.h>
  11. #if O3DE_HEADLESS_SERVER
  12. int main(int argc, char* argv[])
  13. {
  14. int argCount = argc;
  15. char** argValues = argv;
  16. #else
  17. int APIENTRY WinMain([[maybe_unused]] HINSTANCE hInstance, [[maybe_unused]] HINSTANCE hPrevInstance, [[maybe_unused]] LPSTR lpCmdLine, [[maybe_unused]] int nCmdShow)
  18. {
  19. int argCount = __argc;
  20. char** argValues = __argv;
  21. #endif // O3DE_HEADLESS_SERVER
  22. const AZ::Debug::Trace tracer;
  23. InitRootDir();
  24. using namespace O3DELauncher;
  25. PlatformMainInfo mainInfo;
  26. mainInfo.m_instance = GetModuleHandle(nullptr);
  27. mainInfo.CopyCommandLine(argCount, argValues);
  28. ReturnCode status = Run(mainInfo);
  29. #if !O3DE_HEADLESS_SERVER
  30. #if !defined(_RELEASE)
  31. bool noPrompt = (strstr(mainInfo.m_commandLine, "-noprompt") != nullptr);
  32. #else
  33. bool noPrompt = false;
  34. #endif // !defined(_RELEASE)
  35. if (!noPrompt && status != ReturnCode::Success)
  36. {
  37. MessageBoxA(0, GetReturnCodeString(status), "Error", MB_OK | MB_DEFAULT_DESKTOP_ONLY | MB_ICONERROR);
  38. }
  39. #endif // !O3DE_HEADLESS_SERVER
  40. return static_cast<int>(status);
  41. }
  42. void CVar_OnViewportPosition(const AZ::Vector2& value)
  43. {
  44. if (HWND windowHandle = GetActiveWindow())
  45. {
  46. SetWindowPos(windowHandle, nullptr,
  47. static_cast<int>(value.GetX()),
  48. static_cast<int>(value.GetY()),
  49. 0, 0, SWP_NOOWNERZORDER | SWP_NOSIZE);
  50. }
  51. }