3
0

Launcher_Windows.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. int APIENTRY WinMain([[maybe_unused]] HINSTANCE hInstance, [[maybe_unused]] HINSTANCE hPrevInstance, [[maybe_unused]] LPSTR lpCmdLine, [[maybe_unused]] int nCmdShow)
  12. {
  13. const AZ::Debug::Trace tracer;
  14. InitRootDir();
  15. using namespace O3DELauncher;
  16. PlatformMainInfo mainInfo;
  17. mainInfo.m_instance = GetModuleHandle(0);
  18. mainInfo.CopyCommandLine(__argc, __argv);
  19. ReturnCode status = Run(mainInfo);
  20. #if !defined(_RELEASE)
  21. bool noPrompt = (strstr(mainInfo.m_commandLine, "-noprompt") != nullptr);
  22. #else
  23. bool noPrompt = false;
  24. #endif // !defined(_RELEASE)
  25. if (!noPrompt && status != ReturnCode::Success)
  26. {
  27. MessageBoxA(0, GetReturnCodeString(status), "Error", MB_OK | MB_DEFAULT_DESKTOP_ONLY | MB_ICONERROR);
  28. }
  29. return static_cast<int>(status);
  30. }
  31. void CVar_OnViewportPosition(const AZ::Vector2& value)
  32. {
  33. if (HWND windowHandle = GetActiveWindow())
  34. {
  35. SetWindowPos(windowHandle, nullptr,
  36. static_cast<int>(value.GetX()),
  37. static_cast<int>(value.GetY()),
  38. 0, 0, SWP_NOOWNERZORDER | SWP_NOSIZE);
  39. }
  40. }