diff --git a/Code/Editor/Controls/ConsoleSCB.cpp b/Code/Editor/Controls/ConsoleSCB.cpp index 9f1921395c..1bc00fdc3f 100644 --- a/Code/Editor/Controls/ConsoleSCB.cpp +++ b/Code/Editor/Controls/ConsoleSCB.cpp @@ -338,6 +338,8 @@ CConsoleSCB::CConsoleSCB(QWidget* parent) connect(findPreviousAction, &QAction::triggered, this, &CConsoleSCB::findPrevious); ui->findPrevButton->addAction(findPreviousAction); + GetIEditor()->RegisterNotifyListener(this); + connect(ui->button, &QPushButton::clicked, this, &CConsoleSCB::showVariableEditor); connect(ui->findButton, &QPushButton::clicked, this, &CConsoleSCB::toggleConsoleSearch); connect(ui->textEdit, &ConsoleTextEdit::searchBarRequested, this, [this] @@ -376,6 +378,8 @@ CConsoleSCB::~CConsoleSCB() { AzToolsFramework::EditorPreferencesNotificationBus::Handler::BusDisconnect(); + GetIEditor()->UnregisterNotifyListener(this); + s_consoleSCB = nullptr; CLogFile::AttachEditBox(nullptr); } @@ -1352,4 +1356,19 @@ CConsoleSCB* CConsoleSCB::GetCreatedInstance() return s_consoleSCB; } +void CConsoleSCB::OnEditorNotifyEvent(EEditorNotifyEvent event) +{ + switch (event) + { + case eNotify_OnBeginGameMode: + if (gSettings.clearConsoleOnGameModeStart) + { + ui->textEdit->clear(); + } + break; + default: + break; + } +} + #include diff --git a/Code/Editor/Controls/ConsoleSCB.h b/Code/Editor/Controls/ConsoleSCB.h index 98bf4b391d..f51786e2a5 100644 --- a/Code/Editor/Controls/ConsoleSCB.h +++ b/Code/Editor/Controls/ConsoleSCB.h @@ -159,6 +159,7 @@ private: class CConsoleSCB : public QWidget , private AzToolsFramework::EditorPreferencesNotificationBus::Handler + , public IEditorNotifyListener { Q_OBJECT public: @@ -187,6 +188,8 @@ private Q_SLOTS: void findNext(); private: + void OnEditorNotifyEvent(EEditorNotifyEvent event) override; + QScopedPointer ui; int m_richEditTextLength; diff --git a/Code/Editor/EditorPreferencesPageGeneral.cpp b/Code/Editor/EditorPreferencesPageGeneral.cpp index 70ac0fd46f..79ecfbdfc7 100644 --- a/Code/Editor/EditorPreferencesPageGeneral.cpp +++ b/Code/Editor/EditorPreferencesPageGeneral.cpp @@ -32,6 +32,7 @@ void CEditorPreferencesPage_General::Reflect(AZ::SerializeContext& serialize) ->Field("PreviewPanel", &GeneralSettings::m_previewPanel) ->Field("ApplyConfigSpec", &GeneralSettings::m_applyConfigSpec) ->Field("EnableSourceControl", &GeneralSettings::m_enableSourceControl) + ->Field("ClearConsole", &GeneralSettings::m_clearConsoleOnGameModeStart) ->Field("ConsoleBackgroundColorTheme", &GeneralSettings::m_consoleBackgroundColorTheme) ->Field("AutoloadLastLevel", &GeneralSettings::m_autoLoadLastLevel) ->Field("ShowTimeInConsole", &GeneralSettings::m_bShowTimeInConsole) @@ -77,6 +78,8 @@ void CEditorPreferencesPage_General::Reflect(AZ::SerializeContext& serialize) ->DataElement(AZ::Edit::UIHandlers::CheckBox, &GeneralSettings::m_previewPanel, "Show Geometry Preview Panel", "Show Geometry Preview Panel") ->DataElement(AZ::Edit::UIHandlers::CheckBox, &GeneralSettings::m_applyConfigSpec, "Hide objects by config spec", "Hide objects by config spec") ->DataElement(AZ::Edit::UIHandlers::CheckBox, &GeneralSettings::m_enableSourceControl, "Enable Source Control", "Enable Source Control") + ->DataElement( + AZ::Edit::UIHandlers::CheckBox, &GeneralSettings::m_clearConsoleOnGameModeStart, "Clear Console at game startup", "Clear Console when game mode starts") ->DataElement(AZ::Edit::UIHandlers::ComboBox, &GeneralSettings::m_consoleBackgroundColorTheme, "Console Background", "Console Background") ->EnumAttribute(AzToolsFramework::ConsoleColorTheme::Light, "Light") ->EnumAttribute(AzToolsFramework::ConsoleColorTheme::Dark, "Dark") @@ -142,6 +145,7 @@ void CEditorPreferencesPage_General::OnApply() gSettings.bPreviewGeometryWindow = m_generalSettings.m_previewPanel; gSettings.bApplyConfigSpecInEditor = m_generalSettings.m_applyConfigSpec; gSettings.enableSourceControl = m_generalSettings.m_enableSourceControl; + gSettings.clearConsoleOnGameModeStart = m_generalSettings.m_clearConsoleOnGameModeStart; gSettings.consoleBackgroundColorTheme = m_generalSettings.m_consoleBackgroundColorTheme; gSettings.bShowTimeInConsole = m_generalSettings.m_bShowTimeInConsole; gSettings.bShowDashboardAtStartup = m_messaging.m_showDashboard; @@ -176,6 +180,7 @@ void CEditorPreferencesPage_General::InitializeSettings() m_generalSettings.m_previewPanel = gSettings.bPreviewGeometryWindow; m_generalSettings.m_applyConfigSpec = gSettings.bApplyConfigSpecInEditor; m_generalSettings.m_enableSourceControl = gSettings.enableSourceControl; + m_generalSettings.m_clearConsoleOnGameModeStart = gSettings.clearConsoleOnGameModeStart; m_generalSettings.m_consoleBackgroundColorTheme = gSettings.consoleBackgroundColorTheme; m_generalSettings.m_bShowTimeInConsole = gSettings.bShowTimeInConsole; m_generalSettings.m_autoLoadLastLevel = gSettings.bAutoloadLastLevelAtStartup; diff --git a/Code/Editor/EditorPreferencesPageGeneral.h b/Code/Editor/EditorPreferencesPageGeneral.h index f22cfdd424..9a3a0f21e8 100644 --- a/Code/Editor/EditorPreferencesPageGeneral.h +++ b/Code/Editor/EditorPreferencesPageGeneral.h @@ -46,6 +46,7 @@ private: bool m_previewPanel; bool m_applyConfigSpec; bool m_enableSourceControl; + bool m_clearConsoleOnGameModeStart; AzToolsFramework::ConsoleColorTheme m_consoleBackgroundColorTheme; bool m_autoLoadLastLevel; bool m_bShowTimeInConsole; diff --git a/Code/Editor/GameEngine.cpp b/Code/Editor/GameEngine.cpp index dff6476ff9..173c13c235 100644 --- a/Code/Editor/GameEngine.cpp +++ b/Code/Editor/GameEngine.cpp @@ -566,7 +566,7 @@ void CGameEngine::SwitchToInGame() streamer->QueueRequest(flush); wait.acquire(); } - + GetIEditor()->Notify(eNotify_OnBeginGameMode); m_pISystem->GetIMovieSystem()->EnablePhysicsEvents(true); diff --git a/Code/Editor/Settings.cpp b/Code/Editor/Settings.cpp index 8f86c74b25..ad9996adcd 100644 --- a/Code/Editor/Settings.cpp +++ b/Code/Editor/Settings.cpp @@ -189,6 +189,7 @@ SEditorSettings::SEditorSettings() consoleBackgroundColorTheme = AzToolsFramework::ConsoleColorTheme::Dark; bShowTimeInConsole = false; + clearConsoleOnGameModeStart = false; enableSceneInspector = false; @@ -527,6 +528,8 @@ void SEditorSettings::Save() SaveValue("Settings", "ConsoleBackgroundColorThemeV2", (int)consoleBackgroundColorTheme); + SaveValue("Settings", "ClearConsoleOnGameModeStart", clearConsoleOnGameModeStart); + SaveValue("Settings", "ShowTimeInConsole", bShowTimeInConsole); SaveValue("Settings", "EnableSceneInspector", enableSceneInspector); @@ -745,6 +748,8 @@ void SEditorSettings::Load() consoleBackgroundColorTheme = AzToolsFramework::ConsoleColorTheme::Dark; } + LoadValue("Settings", "ClearConsoleOnGameModeStart", clearConsoleOnGameModeStart); + LoadValue("Settings", "ShowTimeInConsole", bShowTimeInConsole); LoadValue("Settings", "EnableSceneInspector", enableSceneInspector); diff --git a/Code/Editor/Settings.h b/Code/Editor/Settings.h index 979820e5e6..39a4093915 100644 --- a/Code/Editor/Settings.h +++ b/Code/Editor/Settings.h @@ -380,6 +380,7 @@ AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING //! Source Control Enabling. bool enableSourceControl; + bool clearConsoleOnGameModeStart; //! Text editor. QString textEditorForScript;