Address some PR feedback

- Use AZ::IConsole instead of deprecated Cry IConsole.
- Create fullscreen preview widget on the same screen where the main window is found, instead of on the 'primary' screen
- Remove "ed_previewGameInFullscreen", which had the effect of always doing a full screen preview. If this functionality is desired, it should be re-added as a registry key instead of a cvar
This commit is contained in:
Yuriy Toporovskyy
2021-06-14 16:19:18 -04:00
parent 5becf25a79
commit 84492dee48
3 changed files with 15 additions and 25 deletions
+4 -2
View File
@@ -53,6 +53,7 @@ AZ_POP_DISABLE_WARNING
#include <AzCore/std/smart_ptr/make_shared.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/Utils/Utils.h>
#include <AzCore/Console/IConsole.h>
// AzFramework
#include <AzFramework/Components/CameraBus.h>
@@ -356,6 +357,8 @@ CCryEditDoc* CCryDocManager::OpenDocumentFile(LPCTSTR lpszFileName, BOOL bAddToM
for (int i = idStart; i <= idEnd; ++i) \
ON_COMMAND(i, method);
AZ_CVAR_EXTERNED(bool, ed_previewGameInFullscreen_once);
void CCryEditApp::RegisterActionHandlers()
{
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
@@ -377,8 +380,7 @@ void CCryEditApp::RegisterActionHandlers()
ON_COMMAND(ID_FILE_EXPORTTOGAMENOSURFACETEXTURE, OnFileExportToGameNoSurfaceTexture)
ON_COMMAND(ID_VIEW_SWITCHTOGAME, OnViewSwitchToGame)
MainWindow::instance()->GetActionManager()->RegisterActionHandler(ID_VIEW_SWITCHTOGAME_FULLSCREEN, [this]() {
auto fs = gEnv->pConsole->GetCVar("ed_previewGameInFullscreen_once");
fs->Set(1);
ed_previewGameInFullscreen_once = true;
OnViewSwitchToGame();
});
ON_COMMAND(ID_MOVE_OBJECT, OnMoveObject)
+8 -17
View File
@@ -29,6 +29,7 @@
#include <AzCore/Component/EntityId.h>
#include <AzCore/Interface/Interface.h>
#include <AzCore/Math/VectorConversions.h>
#include <AzCore/Interface/Interface.h>
#include <AzCore/Console/IConsole.h>
// AzFramework
@@ -3059,6 +3060,8 @@ float EditorViewportSettings::AngleStep() const
return SandboxEditor::AngleSnappingSize();
}
AZ_CVAR_EXTERNED(bool, ed_previewGameInFullscreen_once);
bool EditorViewportWidget::ShouldPreviewFullscreen() const
{
CLayoutWnd* layout = GetIEditor()->GetViewManager()->GetLayout();
@@ -3089,23 +3092,10 @@ bool EditorViewportWidget::ShouldPreviewFullscreen() const
}
}
// Check 'ed_previewGameInFullscreen_once' and 'ed_previewGameInFullscreen' cvars
if (gEnv->pConsole)
// Check 'ed_previewGameInFullscreen_once'
if (ed_previewGameInFullscreen_once)
{
if (auto v = gEnv->pConsole->GetCVar("ed_previewGameInFullscreen_once"))
{
if (v->GetIVal() != 0)
{
v->Set(0);
return true;
}
}
{
auto v = gEnv->pConsole->GetCVar("ed_previewGameInFullscreen");
return v && v->GetIVal() != 0; // if it doesn't exist, assume its value is 0
}
ed_previewGameInFullscreen_once = true;
return true;
}
else
@@ -3119,7 +3109,8 @@ void EditorViewportWidget::StartFullscreenPreview()
AZ_Assert(!m_inFullscreenPreview, "EditorViewportWidget::StartFullscreenPreview called when already in full screen preview");
m_inFullscreenPreview = true;
const QScreen* screen = QGuiApplication::primaryScreen();
// Pick the screen on which the main window lies to use as the screen for the full screen preview
const QScreen* screen = MainWindow::instance()->screen();
const QRect screenGeometry = screen->geometry();
// Unparent this and show it, which turns it into a free floating window
+3 -6
View File
@@ -26,6 +26,7 @@
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/StringFunc/StringFunc.h>
#include <AzCore/Utils/Utils.h>
#include <AzCore/Console/IConsole.h>
// AzFramework
#include <AzFramework/API/ApplicationAPI.h>
@@ -926,6 +927,8 @@ void SEditorSettings::Load()
}
//////////////////////////////////////////////////////////////////////////
AZ_CVAR(bool, ed_previewGameInFullscreen_once, false, nullptr, AZ::ConsoleFunctorFlags::IsInvisible, "Preview the game (Ctrl+G, \"Play Game\", etc.) in fullscreen once");
void SEditorSettings::PostInitApply()
{
if (!gEnv || !gEnv->pConsole)
@@ -947,12 +950,6 @@ void SEditorSettings::PostInitApply()
REGISTER_CVAR2_CB("ed_keepEditorActive", &keepEditorActive, 0, VF_NULL, "Keep the editor active, even if no focus is set", KeepEditorActiveChanged);
REGISTER_CVAR2("g_TemporaryLevelName", &g_TemporaryLevelName, "temp_level", VF_NULL, "Temporary level named used for experimental levels.");
REGISTER_INT("ed_previewGameInFullscreen", 0, VF_DEV_ONLY, "Preview the game (Ctrl+G, \"Play Game\", etc.) in fullscreen. 0 = no, 1 = yes");
gEnv->pConsole->GetCVar("ed_previewGameInFullscreen")->SetLimits(0, 1);
REGISTER_INT("ed_previewGameInFullscreen_once", 0, VF_DEV_ONLY | VF_INVISIBLE, "Preview the game (Ctrl+G, \"Play Game\", etc.) in fullscreen once. 0 = no, 1 = yes");
gEnv->pConsole->GetCVar("ed_previewGameInFullscreen_once")->SetLimits(0, 1);
CCryEditApp::instance()->KeepEditorActive(keepEditorActive > 0);
}