LYN-4946 | Merge Game Mode buttons in the Play Controls toolbar (#5557)

* LYN-4946 Double play buttons - Tranformer style into one.

Signed-off-by: sphrose <82213493+sphrose@users.noreply.github.com>

* compile fix

Signed-off-by: sphrose <82213493+sphrose@users.noreply.github.com>

* Changes as per review.

Signed-off-by: sphrose <82213493+sphrose@users.noreply.github.com>

* Address minor confusion points.

Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com>

* Fix rename operation missing some matches...

Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com>

* Remove extra newline.

Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com>

Co-authored-by: sphrose <82213493+sphrose@users.noreply.github.com>
monroegm-disable-blank-issue-2
Danilo Aimini 4 years ago committed by GitHub
parent 2fa3c134e0
commit a544800536
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -371,10 +371,8 @@ void CCryEditApp::RegisterActionHandlers()
ON_COMMAND(ID_EDIT_FETCH, OnEditFetch) ON_COMMAND(ID_EDIT_FETCH, OnEditFetch)
ON_COMMAND(ID_FILE_EXPORTTOGAMENOSURFACETEXTURE, OnFileExportToGameNoSurfaceTexture) ON_COMMAND(ID_FILE_EXPORTTOGAMENOSURFACETEXTURE, OnFileExportToGameNoSurfaceTexture)
ON_COMMAND(ID_VIEW_SWITCHTOGAME, OnViewSwitchToGame) ON_COMMAND(ID_VIEW_SWITCHTOGAME, OnViewSwitchToGame)
MainWindow::instance()->GetActionManager()->RegisterActionHandler(ID_VIEW_SWITCHTOGAME_FULLSCREEN, [this]() { ON_COMMAND(ID_VIEW_SWITCHTOGAME_VIEWPORT, OnViewSwitchToGame)
ed_previewGameInFullscreen_once = true; ON_COMMAND(ID_VIEW_SWITCHTOGAME_FULLSCREEN, OnViewSwitchToGameFullScreen)
OnViewSwitchToGame();
});
ON_COMMAND(ID_MOVE_OBJECT, OnMoveObject) ON_COMMAND(ID_MOVE_OBJECT, OnMoveObject)
ON_COMMAND(ID_RENAME_OBJ, OnRenameObj) ON_COMMAND(ID_RENAME_OBJ, OnRenameObj)
ON_COMMAND(ID_UNDO, OnUndo) ON_COMMAND(ID_UNDO, OnUndo)
@ -2575,6 +2573,12 @@ void CCryEditApp::OnViewSwitchToGame()
GetIEditor()->SetInGameMode(inGame); GetIEditor()->SetInGameMode(inGame);
} }
void CCryEditApp::OnViewSwitchToGameFullScreen()
{
ed_previewGameInFullscreen_once = true;
OnViewSwitchToGame();
}
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void CCryEditApp::OnExportSelectedObjects() void CCryEditApp::OnExportSelectedObjects()
{ {

@ -212,6 +212,7 @@ public:
void OnEditFetch(); void OnEditFetch();
void OnFileExportToGameNoSurfaceTexture(); void OnFileExportToGameNoSurfaceTexture();
void OnViewSwitchToGame(); void OnViewSwitchToGame();
void OnViewSwitchToGameFullScreen();
void OnViewDeploy(); void OnViewDeploy();
void DeleteSelectedEntities(bool includeDescendants); void DeleteSelectedEntities(bool includeDescendants);
void OnMoveObject(); void OnMoveObject();

@ -939,27 +939,27 @@ void MainWindow::InitActions()
.Connect(&QAction::triggered, this, &MainWindow::OnRefreshAudioSystem); .Connect(&QAction::triggered, this, &MainWindow::OnRefreshAudioSystem);
// Game actions // Game actions
am->AddAction(ID_VIEW_SWITCHTOGAME, tr("Play &Game")) am->AddAction(ID_VIEW_SWITCHTOGAME, tr("Play Game"))
.SetIcon(QIcon(":/stylesheet/img/UI20/toolbar/Play.svg")) .SetIcon(QIcon(":/stylesheet/img/UI20/toolbar/Play.svg"))
.SetToolTip(tr("Play Game"))
.SetStatusTip(tr("Activate the game input mode"))
.SetCheckable(true)
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdatePlayGame);
am->AddAction(ID_VIEW_SWITCHTOGAME_VIEWPORT, tr("Play Game"))
.SetShortcut(tr("Ctrl+G")) .SetShortcut(tr("Ctrl+G"))
.SetToolTip(tr("Play Game (Ctrl+G)")) .SetToolTip(tr("Play Game (Ctrl+G)"))
.SetStatusTip(tr("Activate the game input mode")) .SetStatusTip(tr("Activate the game input mode"))
.SetApplyHoverEffect()
.SetCheckable(true)
.RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdatePlayGame); .RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdatePlayGame);
am->AddAction(ID_VIEW_SWITCHTOGAME_FULLSCREEN, tr("Play &Game (Maximized)")) am->AddAction(ID_VIEW_SWITCHTOGAME_FULLSCREEN, tr("Play Game (Maximized)"))
.SetShortcut(tr("Ctrl+Shift+G")) .SetShortcut(tr("Ctrl+Shift+G"))
.SetStatusTip(tr("Activate the game input mode (maximized)")) .SetStatusTip(tr("Activate the game input mode (maximized)"))
.SetIcon(Style::icon("Play")) .RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdatePlayGame);
.SetApplyHoverEffect()
.SetCheckable(true);
am->AddAction(ID_TOOLBAR_WIDGET_PLAYCONSOLE_LABEL, tr("Play Controls")) am->AddAction(ID_TOOLBAR_WIDGET_PLAYCONSOLE_LABEL, tr("Play Controls"))
.SetText(tr("Play Controls")); .SetText(tr("Play Controls"));
am->AddAction(ID_SWITCH_PHYSICS, tr("Simulate")) am->AddAction(ID_SWITCH_PHYSICS, tr("Simulate"))
.SetIcon(QIcon(":/stylesheet/img/UI20/toolbar/Simulate_Physics.svg")) .SetIcon(QIcon(":/stylesheet/img/UI20/toolbar/Simulate_Physics.svg"))
.SetShortcut(tr("Ctrl+P")) .SetShortcut(tr("Ctrl+P"))
.SetToolTip(tr("Simulate (Ctrl+P)")) .SetToolTip(tr("Simulate (Ctrl+P)"))
.SetCheckable(true)
.SetStatusTip(tr("Enable processing of Physics and AI.")) .SetStatusTip(tr("Enable processing of Physics and AI."))
.SetApplyHoverEffect() .SetApplyHoverEffect()
.SetCheckable(true) .SetCheckable(true)
@ -1266,7 +1266,9 @@ void MainWindow::OnGameModeChanged(bool inGameMode)
// block signals on the switch to game actions before setting the checked state, as // block signals on the switch to game actions before setting the checked state, as
// setting the checked state triggers the action, which will re-enter this function // setting the checked state triggers the action, which will re-enter this function
// and result in an infinite loop // and result in an infinite loop
AZStd::vector<QAction*> actions = { m_actionManager->GetAction(ID_VIEW_SWITCHTOGAME), m_actionManager->GetAction(ID_VIEW_SWITCHTOGAME_FULLSCREEN) }; AZStd::vector<QAction*> actions = { m_actionManager->GetAction(ID_VIEW_SWITCHTOGAME_VIEWPORT),
m_actionManager->GetAction(ID_VIEW_SWITCHTOGAME_FULLSCREEN),
m_actionManager->GetAction(ID_VIEW_SWITCHTOGAME)};
for (auto action : actions) for (auto action : actions)
{ {
action->blockSignals(true); action->blockSignals(true);

@ -104,6 +104,7 @@
#define ID_FILE_EXPORTTOGAMENOSURFACETEXTURE 33473 #define ID_FILE_EXPORTTOGAMENOSURFACETEXTURE 33473
#define ID_VIEW_SWITCHTOGAME 33477 #define ID_VIEW_SWITCHTOGAME 33477
#define ID_VIEW_SWITCHTOGAME_FULLSCREEN 33478 #define ID_VIEW_SWITCHTOGAME_FULLSCREEN 33478
#define ID_VIEW_SWITCHTOGAME_VIEWPORT 33479
#define ID_MOVE_OBJECT 33481 #define ID_MOVE_OBJECT 33481
#define ID_RENAME_OBJ 33483 #define ID_RENAME_OBJ 33483
#define ID_FETCH 33496 #define ID_FETCH 33496

@ -590,6 +590,16 @@ AmazonToolbar ToolbarManager::GetObjectToolbar() const
return t; return t;
} }
QMenu* ToolbarManager::CreatePlayButtonMenu() const
{
QMenu* playButtonMenu = new QMenu("Play Game");
playButtonMenu->addAction(m_actionManager->GetAction(ID_VIEW_SWITCHTOGAME_VIEWPORT));
playButtonMenu->addAction(m_actionManager->GetAction(ID_VIEW_SWITCHTOGAME_FULLSCREEN));
return playButtonMenu;
}
AmazonToolbar ToolbarManager::GetPlayConsoleToolbar() const AmazonToolbar ToolbarManager::GetPlayConsoleToolbar() const
{ {
AmazonToolbar t = AmazonToolbar("PlayConsole", QObject::tr("Play Controls")); AmazonToolbar t = AmazonToolbar("PlayConsole", QObject::tr("Play Controls"));
@ -598,8 +608,17 @@ AmazonToolbar ToolbarManager::GetPlayConsoleToolbar() const
t.AddAction(ID_TOOLBAR_WIDGET_SPACER_RIGHT, ORIGINAL_TOOLBAR_VERSION); t.AddAction(ID_TOOLBAR_WIDGET_SPACER_RIGHT, ORIGINAL_TOOLBAR_VERSION);
t.AddAction(ID_TOOLBAR_SEPARATOR, ORIGINAL_TOOLBAR_VERSION); t.AddAction(ID_TOOLBAR_SEPARATOR, ORIGINAL_TOOLBAR_VERSION);
t.AddAction(ID_TOOLBAR_WIDGET_PLAYCONSOLE_LABEL, ORIGINAL_TOOLBAR_VERSION); t.AddAction(ID_TOOLBAR_WIDGET_PLAYCONSOLE_LABEL, ORIGINAL_TOOLBAR_VERSION);
t.AddAction(ID_VIEW_SWITCHTOGAME, TOOLBARS_WITH_PLAY_GAME);
t.AddAction(ID_VIEW_SWITCHTOGAME_FULLSCREEN, TOOLBARS_WITH_PLAY_GAME); QAction* playAction = m_actionManager->GetAction(ID_VIEW_SWITCHTOGAME);
QToolButton* playButton = new QToolButton(t.Toolbar());
QMenu* menu = CreatePlayButtonMenu();
menu->setParent(t.Toolbar());
playAction->setMenu(menu);
playButton->setDefaultAction(playAction);
t.AddWidget(playButton, ID_VIEW_SWITCHTOGAME, ORIGINAL_TOOLBAR_VERSION);
t.AddAction(ID_TOOLBAR_SEPARATOR, ORIGINAL_TOOLBAR_VERSION); t.AddAction(ID_TOOLBAR_SEPARATOR, ORIGINAL_TOOLBAR_VERSION);
t.AddAction(ID_SWITCH_PHYSICS, TOOLBARS_WITH_PLAY_GAME); t.AddAction(ID_SWITCH_PHYSICS, TOOLBARS_WITH_PLAY_GAME);
return t; return t;
@ -728,7 +747,14 @@ void AmazonToolbar::SetActionsOnInternalToolbar(ActionManager* actionManager)
{ {
if (actionManager->HasAction(actionId)) if (actionManager->HasAction(actionId))
{ {
m_toolbar->addAction(actionManager->GetAction(actionId)); if (actionData.widget != nullptr)
{
m_toolbar->addWidget(actionData.widget);
}
else
{
m_toolbar->addAction(actionManager->GetAction(actionId));
}
} }
} }
} }
@ -1367,7 +1393,12 @@ void AmazonToolbar::InstantiateToolbar(QMainWindow* mainWindow, ToolbarManager*
void AmazonToolbar::AddAction(int actionId, int toolbarVersionAdded) void AmazonToolbar::AddAction(int actionId, int toolbarVersionAdded)
{ {
m_actions.push_back({ actionId, toolbarVersionAdded }); AddWidget(nullptr, actionId, toolbarVersionAdded);
}
void AmazonToolbar::AddWidget(QWidget* widget, int actionId, int toolbarVersionAdded)
{
m_actions.push_back({ actionId, toolbarVersionAdded, widget });
} }
void AmazonToolbar::Clear() void AmazonToolbar::Clear()

@ -87,6 +87,7 @@ public:
const QString& GetTranslatedName() const { return m_translatedName; } const QString& GetTranslatedName() const { return m_translatedName; }
void AddAction(int actionId, int toolbarVersionAdded = 0); void AddAction(int actionId, int toolbarVersionAdded = 0);
void AddWidget(QWidget* widget, int actionId, int toolbarVersionAdded = 0);
QToolBar* Toolbar() const { return m_toolbar; } QToolBar* Toolbar() const { return m_toolbar; }
@ -117,6 +118,7 @@ private:
{ {
int actionId; int actionId;
int toolbarVersionAdded; int toolbarVersionAdded;
QWidget* widget;
bool operator ==(const AmazonToolbar::ActionData& other) const bool operator ==(const AmazonToolbar::ActionData& other) const
{ {
@ -133,7 +135,9 @@ private:
class AmazonToolBarExpanderWatcher; class AmazonToolBarExpanderWatcher;
class ToolbarManager class ToolbarManager
: public QObject
{ {
Q_OBJECT
public: public:
explicit ToolbarManager(ActionManager* actionManager, MainWindow* mainWindow); explicit ToolbarManager(ActionManager* actionManager, MainWindow* mainWindow);
~ToolbarManager(); ~ToolbarManager();
@ -178,6 +182,8 @@ private:
void UpdateAllowedAreas(QToolBar* toolbar); void UpdateAllowedAreas(QToolBar* toolbar);
bool IsDirty(const AmazonToolbar& toolbar) const; bool IsDirty(const AmazonToolbar& toolbar) const;
QMenu* CreatePlayButtonMenu() const;
const AmazonToolbar* FindDefaultToolbar(const QString& toolbarName) const; const AmazonToolbar* FindDefaultToolbar(const QString& toolbarName) const;
AmazonToolbar* FindToolbar(const QString& toolbarName); AmazonToolbar* FindToolbar(const QString& toolbarName);

Loading…
Cancel
Save