Added r_ViewportPos cvar for set the position of a viewport of a game/server launchers

This commit is contained in:
AMZN-Olex
2021-06-15 13:46:53 -04:00
parent a47b30c708
commit 2f5cffe679
6 changed files with 24 additions and 0 deletions
+5
View File
@@ -46,6 +46,8 @@ extern "C" void CreateStaticModules(AZStd::vector<AZ::Module*>& modulesOut);
# define REMOTE_ASSET_PROCESSOR
#endif
void CVar_OnViewportPosition(const AZ::Vector2& value);
namespace
{
void OnViewportResize(const AZ::Vector2& value);
@@ -60,6 +62,9 @@ namespace
AzFramework::WindowSize newSize = AzFramework::WindowSize(aznumeric_cast<int32_t>(value.GetX()), aznumeric_cast<int32_t>(value.GetY()));
AzFramework::WindowRequestBus::Broadcast(&AzFramework::WindowRequestBus::Events::ResizeClientArea, newSize);
}
AZ_CVAR(AZ::Vector2, r_viewportPos, AZ::Vector2::CreateZero(), CVar_OnViewportPosition, AZ::ConsoleFunctorFlags::DontReplicate,
"The default position for the launcher viewport, 0 0 means top left corner of your main desktop");
void ExecuteConsoleCommandFile(AzFramework::Application& application)
{
@@ -433,3 +433,5 @@ void android_main(android_app* appState)
MAIN_EXIT_FAILURE(appState, GetReturnCodeString(status));
}
}
void CVar_OnViewportPosition([[maybe_unused]] const AZ::Vector2& value) {}
@@ -113,3 +113,5 @@ int main(int argc, char** argv)
return static_cast<int>(status);
}
void CVar_OnViewportPosition([[maybe_unused]] const AZ::Vector2& value) {}
@@ -63,3 +63,5 @@ int main(int argc, char* argv[])
}
#endif // AZ_TESTS_ENABLED
void CVar_OnViewportPosition([[maybe_unused]] const AZ::Vector2& value) {}
@@ -69,3 +69,14 @@ int APIENTRY WinMain([[maybe_unused]] HINSTANCE hInstance, [[maybe_unused]] HINS
return static_cast<int>(status);
}
void CVar_OnViewportPosition(const AZ::Vector2& value)
{
if (HWND windowHandle = GetActiveWindow())
{
SetWindowPos(windowHandle, nullptr,
value.GetX(),
value.GetY(),
0, 0, SWP_NOOWNERZORDER | SWP_NOSIZE);
}
}
@@ -23,3 +23,5 @@ int main(int argc, char* argv[])
[pool release];
return 0;
}
void CVar_OnViewportPosition([[maybe_unused]] const AZ::Vector2& value) {}