EditorActionsHandler.cpp 117 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725
  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 <Core/EditorActionsHandler.h>
  9. #include <AzFramework/API/ApplicationAPI.h>
  10. #include <AzToolsFramework/ActionManager/Action/ActionManagerInterface.h>
  11. #include <AzToolsFramework/ActionManager/Action/ActionManagerInternalInterface.h>
  12. #include <AzToolsFramework/ActionManager/HotKey/HotKeyManagerInterface.h>
  13. #include <AzToolsFramework/ActionManager/Menu/MenuManagerInterface.h>
  14. #include <AzToolsFramework/ActionManager/Menu/MenuManagerInternalInterface.h>
  15. #include <AzToolsFramework/ActionManager/ToolBar/ToolBarManagerInterface.h>
  16. #include <AzToolsFramework/Editor/ActionManagerIdentifiers/EditorActionUpdaterIdentifiers.h>
  17. #include <AzToolsFramework/Editor/EditorSettingsAPIBus.h>
  18. #include <AzToolsFramework/Editor/ActionManagerIdentifiers/EditorContextIdentifiers.h>
  19. #include <AzToolsFramework/Editor/ActionManagerIdentifiers/EditorMenuIdentifiers.h>
  20. #include <AzToolsFramework/Editor/ActionManagerIdentifiers/EditorToolBarIdentifiers.h>
  21. #include <AzToolsFramework/Entity/EditorEntityContextBus.h>
  22. #include <AzToolsFramework/UI/Outliner/EntityOutlinerRequestBus.h>
  23. #include <AzToolsFramework/Viewport/LocalViewBookmarkLoader.h>
  24. #include <AzToolsFramework/Viewport/ViewportSettings.h>
  25. #include <AzQtComponents/Components/SearchLineEdit.h>
  26. #include <AzQtComponents/Components/Style.h>
  27. #include <AtomLyIntegration/AtomViewportDisplayInfo/AtomViewportInfoDisplayBus.h>
  28. #include <Core/Widgets/PrefabEditVisualModeWidget.h>
  29. #include <Core/Widgets/ViewportSettingsWidgets.h>
  30. #include <CryEdit.h>
  31. #include <EditorCoreAPI.h>
  32. #include <Editor/EditorViewportCamera.h>
  33. #include <Editor/EditorViewportSettings.h>
  34. #include <Editor/Undo/Undo.h>
  35. #include <GameEngine.h>
  36. #include <LmbrCentral/Audio/AudioSystemComponentBus.h>
  37. #include <MainWindow.h>
  38. #include <QtViewPaneManager.h>
  39. #include <ToolBox.h>
  40. #include <ToolsConfigPage.h>
  41. #include <Util/PathUtil.h>
  42. #include <QDesktopServices>
  43. #include <QDir>
  44. #include <QHBoxLayout>
  45. #include <QLabel>
  46. #include <QMainWindow>
  47. #include <QMenu>
  48. #include <QTimer>
  49. #include <QUrl>
  50. #include <QUrlQuery>
  51. #include <QWidget>
  52. static const int maxRecentFiles = 10;
  53. class EditorViewportDisplayInfoHandler
  54. : private AZ::AtomBridge::AtomViewportInfoDisplayNotificationBus::Handler
  55. {
  56. public:
  57. EditorViewportDisplayInfoHandler()
  58. {
  59. m_actionManagerInterface = AZ::Interface<AzToolsFramework::ActionManagerInterface>::Get();
  60. AZ_Assert(
  61. m_actionManagerInterface, "EditorViewportDisplayInfoHandler - could not get ActionManagerInterface on EditorViewportDisplayInfoHandler construction.");
  62. if (m_actionManagerInterface)
  63. {
  64. AZ::AtomBridge::AtomViewportInfoDisplayNotificationBus::Handler::BusConnect();
  65. }
  66. }
  67. ~EditorViewportDisplayInfoHandler()
  68. {
  69. if (m_actionManagerInterface)
  70. {
  71. AZ::AtomBridge::AtomViewportInfoDisplayNotificationBus::Handler::BusDisconnect();
  72. }
  73. }
  74. void OnViewportInfoDisplayStateChanged([[maybe_unused]] AZ::AtomBridge::ViewportInfoDisplayState state) override
  75. {
  76. m_actionManagerInterface->TriggerActionUpdater(EditorIdentifiers::ViewportDisplayInfoStateChangedUpdaterIdentifier);
  77. }
  78. private:
  79. AzToolsFramework::ActionManagerInterface* m_actionManagerInterface = nullptr;
  80. };
  81. bool IsLevelLoaded()
  82. {
  83. auto cryEdit = CCryEditApp::instance();
  84. return !cryEdit->IsExportingLegacyData() && GetIEditor()->IsLevelLoaded();
  85. }
  86. bool AreEntitiesSelected()
  87. {
  88. bool result = false;
  89. AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(
  90. result, &AzToolsFramework::ToolsApplicationRequestBus::Handler::AreAnyEntitiesSelected);
  91. return result;
  92. }
  93. static bool CompareLayoutNames(const QString& name1, const QString& name2)
  94. {
  95. return name1.compare(name2, Qt::CaseInsensitive) < 0;
  96. }
  97. void EditorActionsHandler::Initialize(MainWindow* mainWindow)
  98. {
  99. m_mainWindow = mainWindow;
  100. m_cryEditApp = CCryEditApp::instance();
  101. m_qtViewPaneManager = QtViewPaneManager::instance();
  102. m_levelExtension = EditorUtils::LevelFile::GetDefaultFileExtension();
  103. m_actionManagerInterface = AZ::Interface<AzToolsFramework::ActionManagerInterface>::Get();
  104. AZ_Assert(m_actionManagerInterface, "EditorActionsHandler - could not get ActionManagerInterface on EditorActionsHandler construction.");
  105. m_actionManagerInternalInterface = AZ::Interface<AzToolsFramework::ActionManagerInternalInterface>::Get();
  106. AZ_Assert(
  107. m_actionManagerInternalInterface,
  108. "EditorActionsHandler - could not get ActionManagerInternalInterface on EditorActionsHandler construction.");
  109. m_hotKeyManagerInterface = AZ::Interface<AzToolsFramework::HotKeyManagerInterface>::Get();
  110. AZ_Assert(m_hotKeyManagerInterface, "EditorActionsHandler - could not get HotKeyManagerInterface on EditorActionsHandler construction.");
  111. m_menuManagerInterface = AZ::Interface<AzToolsFramework::MenuManagerInterface>::Get();
  112. AZ_Assert(m_menuManagerInterface, "EditorActionsHandler - could not get MenuManagerInterface on EditorActionsHandler construction.");
  113. m_menuManagerInternalInterface = AZ::Interface<AzToolsFramework::MenuManagerInternalInterface>::Get();
  114. AZ_Assert(
  115. m_menuManagerInternalInterface, "EditorActionsHandler - could not get MenuManagerInternalInterface on EditorActionsHandler construction.");
  116. m_toolBarManagerInterface = AZ::Interface<AzToolsFramework::ToolBarManagerInterface>::Get();
  117. AZ_Assert(m_toolBarManagerInterface, "EditorActionsHandler - could not get ToolBarManagerInterface on EditorActionsHandler construction.");
  118. // Retrieve the bookmark count from the loader.
  119. m_defaultBookmarkCount = AzToolsFramework::LocalViewBookmarkLoader::DefaultViewBookmarkCount;
  120. const int DefaultViewportId = 0;
  121. // Get EditorEntityContextId
  122. AzFramework::EntityContextId editorEntityContextId = AzFramework::EntityContextId::CreateNull();
  123. AzToolsFramework::EditorEntityContextRequestBus::BroadcastResult(
  124. editorEntityContextId, &AzToolsFramework::EditorEntityContextRequests::GetEditorEntityContextId);
  125. AzToolsFramework::ActionManagerRegistrationNotificationBus::Handler::BusConnect();
  126. AzToolsFramework::EditorEventsBus::Handler::BusConnect();
  127. AzToolsFramework::EditorEntityContextNotificationBus::Handler::BusConnect();
  128. AzToolsFramework::ToolsApplicationNotificationBus::Handler::BusConnect();
  129. AzToolsFramework::ViewportInteraction::ViewportSettingsNotificationBus::Handler::BusConnect(DefaultViewportId);
  130. AzToolsFramework::EditorPickModeNotificationBus::Handler::BusConnect(editorEntityContextId);
  131. AzToolsFramework::ContainerEntityNotificationBus::Handler::BusConnect(editorEntityContextId);
  132. m_editorViewportDisplayInfoHandler = new EditorViewportDisplayInfoHandler();
  133. m_initialized = true;
  134. }
  135. EditorActionsHandler::~EditorActionsHandler()
  136. {
  137. if (m_initialized)
  138. {
  139. AzToolsFramework::ContainerEntityNotificationBus::Handler::BusDisconnect();
  140. AzToolsFramework::EditorPickModeNotificationBus::Handler::BusDisconnect();
  141. AzToolsFramework::ViewportInteraction::ViewportSettingsNotificationBus::Handler::BusDisconnect();
  142. AzToolsFramework::ToolsApplicationNotificationBus::Handler::BusDisconnect();
  143. AzToolsFramework::EditorEntityContextNotificationBus::Handler::BusDisconnect();
  144. AzToolsFramework::EditorEventsBus::Handler::BusDisconnect();
  145. AzToolsFramework::ActionManagerRegistrationNotificationBus::Handler::BusDisconnect();
  146. if (m_editorViewportDisplayInfoHandler)
  147. {
  148. delete m_editorViewportDisplayInfoHandler;
  149. }
  150. }
  151. }
  152. void EditorActionsHandler::OnActionContextRegistrationHook()
  153. {
  154. // Main Window
  155. {
  156. AzToolsFramework::ActionContextProperties contextProperties;
  157. contextProperties.m_name = "O3DE Editor";
  158. m_actionManagerInterface->RegisterActionContext(
  159. EditorIdentifiers::MainWindowActionContextIdentifier, contextProperties);
  160. m_hotKeyManagerInterface->AssignWidgetToActionContext(EditorIdentifiers::MainWindowActionContextIdentifier, m_mainWindow);
  161. }
  162. // Editor Asset Browser
  163. {
  164. AzToolsFramework::ActionContextProperties contextProperties;
  165. contextProperties.m_name = "O3DE Editor - Asset Browser";
  166. m_actionManagerInterface->RegisterActionContext(
  167. EditorIdentifiers::EditorAssetBrowserActionContextIdentifier, contextProperties);
  168. }
  169. // Editor Console
  170. {
  171. AzToolsFramework::ActionContextProperties contextProperties;
  172. contextProperties.m_name = "O3DE Editor - Console";
  173. m_actionManagerInterface->RegisterActionContext(
  174. EditorIdentifiers::EditorConsoleActionContextIdentifier, contextProperties);
  175. }
  176. // Editor Entity Property Editor (Entity Inspector)
  177. {
  178. AzToolsFramework::ActionContextProperties contextProperties;
  179. contextProperties.m_name = "O3DE Editor - Entity Inspector";
  180. m_actionManagerInterface->RegisterActionContext(
  181. EditorIdentifiers::EditorEntityPropertyEditorActionContextIdentifier, contextProperties);
  182. }
  183. }
  184. void EditorActionsHandler::OnActionUpdaterRegistrationHook()
  185. {
  186. m_actionManagerInterface->RegisterActionUpdater(EditorIdentifiers::AngleSnappingStateChangedUpdaterIdentifier);
  187. m_actionManagerInterface->RegisterActionUpdater(EditorIdentifiers::ContainerEntityStatesChangedUpdaterIdentifier);
  188. m_actionManagerInterface->RegisterActionUpdater(EditorIdentifiers::DrawHelpersStateChangedUpdaterIdentifier);
  189. m_actionManagerInterface->RegisterActionUpdater(EditorIdentifiers::EntityPickingModeChangedUpdaterIdentifier);
  190. m_actionManagerInterface->RegisterActionUpdater(EditorIdentifiers::EntitySelectionChangedUpdaterIdentifier);
  191. m_actionManagerInterface->RegisterActionUpdater(EditorIdentifiers::GameModeStateChangedUpdaterIdentifier);
  192. m_actionManagerInterface->RegisterActionUpdater(EditorIdentifiers::GridSnappingStateChangedUpdaterIdentifier);
  193. m_actionManagerInterface->RegisterActionUpdater(EditorIdentifiers::IconsStateChangedUpdaterIdentifier);
  194. m_actionManagerInterface->RegisterActionUpdater(EditorIdentifiers::RecentFilesChangedUpdaterIdentifier);
  195. m_actionManagerInterface->RegisterActionUpdater(EditorIdentifiers::UndoRedoUpdaterIdentifier);
  196. m_actionManagerInterface->RegisterActionUpdater(EditorIdentifiers::ViewportDisplayInfoStateChangedUpdaterIdentifier);
  197. // If the Prefab system is not enabled, have a backup to update actions based on level loading.
  198. AzFramework::ApplicationRequests::Bus::BroadcastResult(
  199. m_isPrefabSystemEnabled, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
  200. if (!m_isPrefabSystemEnabled)
  201. {
  202. m_actionManagerInterface->RegisterActionUpdater(EditorIdentifiers::LevelLoadedUpdaterIdentifier);
  203. }
  204. }
  205. void EditorActionsHandler::OnActionRegistrationHook()
  206. {
  207. // --- File Actions
  208. // New Level
  209. {
  210. constexpr AZStd::string_view actionIdentifier = "o3de.action.file.new";
  211. AzToolsFramework::ActionProperties actionProperties;
  212. actionProperties.m_name = "New Level";
  213. actionProperties.m_description = "Create a new level";
  214. actionProperties.m_category = "Level";
  215. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  216. m_actionManagerInterface->RegisterAction(
  217. EditorIdentifiers::MainWindowActionContextIdentifier,
  218. actionIdentifier,
  219. actionProperties,
  220. [cryEdit = m_cryEditApp]
  221. {
  222. cryEdit->OnCreateLevel();
  223. }
  224. );
  225. // This action is only accessible outside of Component Modes
  226. m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, actionIdentifier);
  227. m_hotKeyManagerInterface->SetActionHotKey("o3de.action.file.new", "Ctrl+N");
  228. }
  229. // Open Level
  230. {
  231. constexpr AZStd::string_view actionIdentifier = "o3de.action.file.open";
  232. AzToolsFramework::ActionProperties actionProperties;
  233. actionProperties.m_name = "Open Level...";
  234. actionProperties.m_description = "Open an existing level";
  235. actionProperties.m_category = "Level";
  236. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  237. m_actionManagerInterface->RegisterAction(
  238. EditorIdentifiers::MainWindowActionContextIdentifier,
  239. actionIdentifier,
  240. actionProperties,
  241. [cryEdit = m_cryEditApp]
  242. {
  243. cryEdit->OnOpenLevel();
  244. }
  245. );
  246. // This action is only accessible outside of Component Modes
  247. m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, actionIdentifier);
  248. m_hotKeyManagerInterface->SetActionHotKey("o3de.action.file.open", "Ctrl+O");
  249. }
  250. // Recent Files
  251. {
  252. RecentFileList* recentFiles = m_cryEditApp->GetRecentFileList();
  253. const int recentFilesSize = recentFiles->GetSize();
  254. for (int index = 0; index < maxRecentFiles; ++index)
  255. {
  256. AzToolsFramework::ActionProperties actionProperties;
  257. if (index < recentFilesSize)
  258. {
  259. actionProperties.m_name = AZStd::string::format("%i | %s", index + 1, (*recentFiles)[index].toUtf8().data());
  260. }
  261. else
  262. {
  263. actionProperties.m_name = AZStd::string::format("Recent File #%i", index + 1);
  264. }
  265. actionProperties.m_category = "Level";
  266. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::HideWhenDisabled;
  267. AZStd::string actionIdentifier = AZStd::string::format("o3de.action.file.recent.file%i", index + 1);
  268. m_actionManagerInterface->RegisterAction(
  269. EditorIdentifiers::MainWindowActionContextIdentifier,
  270. actionIdentifier,
  271. actionProperties,
  272. [&, index]
  273. {
  274. OpenLevelByRecentFileEntryIndex(index);
  275. }
  276. );
  277. m_actionManagerInterface->InstallEnabledStateCallback(
  278. actionIdentifier,
  279. [&, index]() -> bool
  280. {
  281. return IsRecentFileActionActive(index);
  282. }
  283. );
  284. m_actionManagerInterface->AddActionToUpdater(EditorIdentifiers::RecentFilesChangedUpdaterIdentifier, actionIdentifier);
  285. // This action is only accessible outside of Component Modes
  286. m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, actionIdentifier);
  287. }
  288. }
  289. // Clear Recent Files
  290. {
  291. constexpr AZStd::string_view actionIdentifier = "o3de.action.file.recent.clearAll";
  292. AzToolsFramework::ActionProperties actionProperties;
  293. actionProperties.m_name = "Clear All";
  294. actionProperties.m_description = "Clear the recent files list.";
  295. actionProperties.m_category = "Level";
  296. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  297. m_actionManagerInterface->RegisterAction(
  298. EditorIdentifiers::MainWindowActionContextIdentifier,
  299. actionIdentifier,
  300. actionProperties,
  301. [&]
  302. {
  303. RecentFileList* mruList = CCryEditApp::instance()->GetRecentFileList();
  304. // remove everything from the mru list
  305. for (int i = mruList->GetSize(); i > 0; i--)
  306. {
  307. mruList->Remove(i - 1);
  308. }
  309. // save the settings immediately to the registry
  310. mruList->WriteList();
  311. // re-update the menus
  312. UpdateRecentFileActions();
  313. }
  314. );
  315. // This action is only accessible outside of Component Modes
  316. m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, actionIdentifier);
  317. }
  318. // Save
  319. {
  320. AzToolsFramework::ActionProperties actionProperties;
  321. actionProperties.m_name = "Save";
  322. actionProperties.m_description = "Save the current level";
  323. actionProperties.m_category = "Level";
  324. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  325. m_actionManagerInterface->RegisterAction(
  326. EditorIdentifiers::MainWindowActionContextIdentifier, "o3de.action.file.save", actionProperties,
  327. [cryEdit = m_cryEditApp]
  328. {
  329. cryEdit->OnFileSave();
  330. }
  331. );
  332. m_actionManagerInterface->InstallEnabledStateCallback("o3de.action.file.save", IsLevelLoaded);
  333. m_actionManagerInterface->AddActionToUpdater(EditorIdentifiers::LevelLoadedUpdaterIdentifier, "o3de.action.file.save");
  334. m_hotKeyManagerInterface->SetActionHotKey("o3de.action.file.save", "Ctrl+S");
  335. }
  336. // Save As...
  337. {
  338. AzToolsFramework::ActionProperties actionProperties;
  339. actionProperties.m_name = "Save As...";
  340. actionProperties.m_description = "Save the current level";
  341. actionProperties.m_category = "Level";
  342. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  343. m_actionManagerInterface->RegisterAction(
  344. EditorIdentifiers::MainWindowActionContextIdentifier, "o3de.action.file.saveAs", actionProperties,
  345. []
  346. {
  347. CCryEditDoc* pDoc = GetIEditor()->GetDocument();
  348. pDoc->OnFileSaveAs();
  349. }
  350. );
  351. m_actionManagerInterface->InstallEnabledStateCallback("o3de.action.file.saveAs", IsLevelLoaded);
  352. m_actionManagerInterface->AddActionToUpdater(EditorIdentifiers::LevelLoadedUpdaterIdentifier, "o3de.action.file.saveAs");
  353. }
  354. // Save Level Statistics
  355. {
  356. constexpr AZStd::string_view actionIdentifier = "o3de.action.file.saveLevelStatistics";
  357. AzToolsFramework::ActionProperties actionProperties;
  358. actionProperties.m_name = "Save Level Statistics";
  359. actionProperties.m_description = "Logs Editor memory usage.";
  360. actionProperties.m_category = "Level";
  361. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  362. m_actionManagerInterface->RegisterAction(
  363. EditorIdentifiers::MainWindowActionContextIdentifier,
  364. actionIdentifier,
  365. actionProperties,
  366. [cryEdit = m_cryEditApp]
  367. {
  368. cryEdit->OnToolsLogMemoryUsage();
  369. }
  370. );
  371. // This action is required by python tests, but is always disabled.
  372. m_actionManagerInterface->InstallEnabledStateCallback(
  373. actionIdentifier,
  374. []() -> bool
  375. {
  376. return false;
  377. }
  378. );
  379. // This action is only accessible outside of Component Modes
  380. m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, actionIdentifier);
  381. }
  382. // Edit Project Settings
  383. {
  384. constexpr AZStd::string_view actionIdentifier = "o3de.action.project.editSettings";
  385. AzToolsFramework::ActionProperties actionProperties;
  386. actionProperties.m_name = "Edit Project Settings...";
  387. actionProperties.m_description = "Open the Project Settings panel.";
  388. actionProperties.m_category = "Project";
  389. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  390. m_actionManagerInterface->RegisterAction(
  391. EditorIdentifiers::MainWindowActionContextIdentifier,
  392. actionIdentifier,
  393. actionProperties,
  394. [cryEdit = m_cryEditApp]
  395. {
  396. cryEdit->OnOpenProjectManagerSettings();
  397. }
  398. );
  399. // This action is only accessible outside of Component Modes
  400. m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, actionIdentifier);
  401. }
  402. // Edit Platform Settings
  403. {
  404. constexpr AZStd::string_view actionIdentifier = "o3de.action.platform.editSettings";
  405. AzToolsFramework::ActionProperties actionProperties;
  406. actionProperties.m_name = "Edit Platform Settings...";
  407. actionProperties.m_description = "Open the Platform Settings panel.";
  408. actionProperties.m_category = "Platform";
  409. m_actionManagerInterface->RegisterAction(
  410. EditorIdentifiers::MainWindowActionContextIdentifier,
  411. actionIdentifier,
  412. actionProperties,
  413. [qtViewPaneManager = m_qtViewPaneManager]
  414. {
  415. qtViewPaneManager->OpenPane(LyViewPane::ProjectSettingsTool);
  416. }
  417. );
  418. }
  419. // New Project
  420. {
  421. constexpr AZStd::string_view actionIdentifier = "o3de.action.project.new";
  422. AzToolsFramework::ActionProperties actionProperties;
  423. actionProperties.m_name = "New Project...";
  424. actionProperties.m_description = "Create a new project in the Project Manager.";
  425. actionProperties.m_category = "Project";
  426. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  427. m_actionManagerInterface->RegisterAction(
  428. EditorIdentifiers::MainWindowActionContextIdentifier,
  429. actionIdentifier,
  430. actionProperties,
  431. [cryEdit = m_cryEditApp]
  432. {
  433. cryEdit->OnOpenProjectManagerNew();
  434. }
  435. );
  436. // This action is only accessible outside of Component Modes
  437. m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, actionIdentifier);
  438. }
  439. // Open Project
  440. {
  441. constexpr AZStd::string_view actionIdentifier = "o3de.action.project.open";
  442. AzToolsFramework::ActionProperties actionProperties;
  443. actionProperties.m_name = "Open Project...";
  444. actionProperties.m_description = "Open a different project in the Project Manager.";
  445. actionProperties.m_category = "Project";
  446. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  447. m_actionManagerInterface->RegisterAction(
  448. EditorIdentifiers::MainWindowActionContextIdentifier,
  449. actionIdentifier,
  450. actionProperties,
  451. [cryEdit = m_cryEditApp]
  452. {
  453. cryEdit->OnOpenProjectManager();
  454. }
  455. );
  456. // This action is only accessible outside of Component Modes
  457. m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, actionIdentifier);
  458. }
  459. // Show Log File
  460. {
  461. constexpr AZStd::string_view actionIdentifier = "o3de.action.file.showLog";
  462. AzToolsFramework::ActionProperties actionProperties;
  463. actionProperties.m_name = "Show Log File";
  464. actionProperties.m_category = "Project";
  465. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  466. m_actionManagerInterface->RegisterAction(
  467. EditorIdentifiers::MainWindowActionContextIdentifier,
  468. actionIdentifier,
  469. actionProperties,
  470. [cryEdit = m_cryEditApp]
  471. {
  472. cryEdit->OnFileEditLogFile();
  473. }
  474. );
  475. // This action is only accessible outside of Component Modes
  476. m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, actionIdentifier);
  477. }
  478. // Editor Exit
  479. {
  480. AzToolsFramework::ActionProperties actionProperties;
  481. actionProperties.m_name = "Exit";
  482. actionProperties.m_description = "Exit the Editor";
  483. actionProperties.m_category = "Editor";
  484. m_actionManagerInterface->RegisterAction(
  485. EditorIdentifiers::MainWindowActionContextIdentifier,
  486. "o3de.action.editor.exit",
  487. actionProperties,
  488. [=]
  489. {
  490. m_mainWindow->window()->close();
  491. }
  492. );
  493. }
  494. // --- Edit Actions
  495. // Undo
  496. {
  497. AzToolsFramework::ActionProperties actionProperties;
  498. actionProperties.m_name = "&Undo";
  499. actionProperties.m_description = "Undo last operation";
  500. actionProperties.m_category = "Edit";
  501. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  502. m_actionManagerInterface->RegisterAction(
  503. EditorIdentifiers::MainWindowActionContextIdentifier,
  504. "o3de.action.edit.undo",
  505. actionProperties,
  506. [cryEdit = m_cryEditApp]
  507. {
  508. cryEdit->OnUndo();
  509. }
  510. );
  511. m_actionManagerInterface->InstallEnabledStateCallback(
  512. "o3de.action.edit.undo",
  513. []() -> bool
  514. {
  515. return GetIEditor()->GetUndoManager()->IsHaveUndo();
  516. }
  517. );
  518. // Trigger update after every undo or redo operation
  519. m_actionManagerInterface->AddActionToUpdater(EditorIdentifiers::UndoRedoUpdaterIdentifier, "o3de.action.edit.undo");
  520. m_hotKeyManagerInterface->SetActionHotKey("o3de.action.edit.undo", "Ctrl+Z");
  521. }
  522. // Redo
  523. {
  524. AzToolsFramework::ActionProperties actionProperties;
  525. actionProperties.m_name = "&Redo";
  526. actionProperties.m_description = "Redo last undo operation";
  527. actionProperties.m_category = "Edit";
  528. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  529. m_actionManagerInterface->RegisterAction(
  530. EditorIdentifiers::MainWindowActionContextIdentifier,
  531. "o3de.action.edit.redo",
  532. actionProperties,
  533. [cryEdit = m_cryEditApp]
  534. {
  535. cryEdit->OnRedo();
  536. }
  537. );
  538. m_actionManagerInterface->InstallEnabledStateCallback(
  539. "o3de.action.edit.redo",
  540. []() -> bool
  541. {
  542. return GetIEditor()->GetUndoManager()->IsHaveRedo();
  543. }
  544. );
  545. // Trigger update after every undo or redo operation
  546. m_actionManagerInterface->AddActionToUpdater(EditorIdentifiers::UndoRedoUpdaterIdentifier, "o3de.action.edit.redo");
  547. m_hotKeyManagerInterface->SetActionHotKey("o3de.action.edit.redo", "Ctrl+Shift+Z");
  548. }
  549. // Angle Snapping
  550. {
  551. constexpr AZStd::string_view actionIdentifier = "o3de.action.edit.snap.toggleAngleSnapping";
  552. AzToolsFramework::ActionProperties actionProperties;
  553. actionProperties.m_name = "Angle snapping";
  554. actionProperties.m_description = "Toggle angle snapping";
  555. actionProperties.m_category = "Edit";
  556. actionProperties.m_iconPath = ":/stylesheet/img/UI20/toolbar/Angle.svg";
  557. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  558. m_actionManagerInterface->RegisterCheckableAction(
  559. EditorIdentifiers::MainWindowActionContextIdentifier,
  560. actionIdentifier,
  561. actionProperties,
  562. []
  563. {
  564. SandboxEditor::SetAngleSnapping(!SandboxEditor::AngleSnappingEnabled());
  565. },
  566. []() -> bool
  567. {
  568. return SandboxEditor::AngleSnappingEnabled();
  569. }
  570. );
  571. // Trigger update when the angle snapping setting changes
  572. m_actionManagerInterface->AddActionToUpdater(EditorIdentifiers::AngleSnappingStateChangedUpdaterIdentifier, actionIdentifier);
  573. // This action is only accessible outside of Component Modes
  574. m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, actionIdentifier);
  575. }
  576. // Grid Snapping
  577. {
  578. constexpr AZStd::string_view actionIdentifier = "o3de.action.edit.snap.toggleGridSnapping";
  579. AzToolsFramework::ActionProperties actionProperties;
  580. actionProperties.m_name = "Grid snapping";
  581. actionProperties.m_description = "Toggle grid snapping";
  582. actionProperties.m_category = "Edit";
  583. actionProperties.m_iconPath = ":/stylesheet/img/UI20/toolbar/Grid.svg";
  584. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  585. m_actionManagerInterface->RegisterCheckableAction(
  586. EditorIdentifiers::MainWindowActionContextIdentifier,
  587. actionIdentifier,
  588. actionProperties,
  589. []
  590. {
  591. SandboxEditor::SetGridSnapping(!SandboxEditor::GridSnappingEnabled());
  592. },
  593. []() -> bool
  594. {
  595. return SandboxEditor::GridSnappingEnabled();
  596. }
  597. );
  598. // Trigger update when the grid snapping setting changes
  599. m_actionManagerInterface->AddActionToUpdater(EditorIdentifiers::GridSnappingStateChangedUpdaterIdentifier, actionIdentifier);
  600. // This action is only accessible outside of Component Modes
  601. m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, actionIdentifier);
  602. }
  603. // Show Grid
  604. {
  605. constexpr AZStd::string_view actionIdentifier = "o3de.action.edit.snap.toggleShowingGrid";
  606. AzToolsFramework::ActionProperties actionProperties;
  607. actionProperties.m_name = "Show Grid";
  608. actionProperties.m_description = "Show Grid for entity snapping.";
  609. actionProperties.m_category = "Edit";
  610. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  611. m_actionManagerInterface->RegisterCheckableAction(
  612. EditorIdentifiers::MainWindowActionContextIdentifier,
  613. actionIdentifier,
  614. actionProperties,
  615. []
  616. {
  617. SandboxEditor::SetShowingGrid(!SandboxEditor::ShowingGrid());
  618. },
  619. []()
  620. {
  621. return SandboxEditor::ShowingGrid();
  622. }
  623. );
  624. // Trigger update when the grid snapping setting changes
  625. m_actionManagerInterface->AddActionToUpdater(EditorIdentifiers::GridShowingChangedUpdaterIdentifier, actionIdentifier);
  626. // This action is only accessible outside of Component Modes
  627. m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, actionIdentifier);
  628. }
  629. // Global Preferences
  630. {
  631. constexpr AZStd::string_view actionIdentifier = "o3de.action.edit.globalPreferences";
  632. AzToolsFramework::ActionProperties actionProperties;
  633. actionProperties.m_name = "Global Preferences...";
  634. actionProperties.m_category = "Editor";
  635. m_actionManagerInterface->RegisterAction(
  636. EditorIdentifiers::MainWindowActionContextIdentifier,
  637. actionIdentifier,
  638. actionProperties,
  639. [cryEdit = m_cryEditApp]
  640. {
  641. cryEdit->OnToolsPreferences();
  642. }
  643. );
  644. // This action is only accessible outside of Component Modes
  645. m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, actionIdentifier);
  646. }
  647. // Editor Settings Manager
  648. {
  649. constexpr AZStd::string_view actionIdentifier = "o3de.action.edit.editorSettingsManager";
  650. AzToolsFramework::ActionProperties actionProperties;
  651. actionProperties.m_name = "Editor Settings Manager";
  652. actionProperties.m_category = "Editor";
  653. m_actionManagerInterface->RegisterAction(
  654. EditorIdentifiers::MainWindowActionContextIdentifier,
  655. actionIdentifier,
  656. actionProperties,
  657. []
  658. {
  659. QtViewPaneManager::instance()->OpenPane(LyViewPane::EditorSettingsManager);
  660. }
  661. );
  662. // This action is only accessible outside of Component Modes
  663. m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, actionIdentifier);
  664. }
  665. // Rename Entity (in the Entity Outliner)
  666. {
  667. const AZStd::string_view actionIdentifier = "o3de.action.entity.rename";
  668. AzToolsFramework::ActionProperties actionProperties;
  669. actionProperties.m_name = "Rename";
  670. actionProperties.m_description = "Rename the current selection.";
  671. actionProperties.m_category = "Entity";
  672. m_actionManagerInterface->RegisterAction(
  673. EditorIdentifiers::MainWindowActionContextIdentifier,
  674. actionIdentifier,
  675. actionProperties,
  676. []()
  677. {
  678. AzToolsFramework::EntityIdList selectedEntities;
  679. AzToolsFramework::ToolsApplicationRequests::Bus::BroadcastResult(
  680. selectedEntities, &AzToolsFramework::ToolsApplicationRequests::Bus::Events::GetSelectedEntities);
  681. // Can only rename one entity at a time
  682. if (selectedEntities.size() == 1)
  683. {
  684. AzToolsFramework::EntityOutlinerRequestBus::Broadcast(
  685. &AzToolsFramework::EntityOutlinerRequests::TriggerRenameEntityUi, selectedEntities.front());
  686. }
  687. }
  688. );
  689. m_actionManagerInterface->InstallEnabledStateCallback(
  690. actionIdentifier,
  691. []() -> bool
  692. {
  693. int selectedEntitiesCount;
  694. AzToolsFramework::ToolsApplicationRequests::Bus::BroadcastResult(
  695. selectedEntitiesCount, &AzToolsFramework::ToolsApplicationRequests::Bus::Events::GetSelectedEntitiesCount);
  696. // Can only rename one entity at a time
  697. return selectedEntitiesCount == 1;
  698. }
  699. );
  700. // Trigger update whenever entity selection changes.
  701. m_actionManagerInterface->AddActionToUpdater(EditorIdentifiers::EntitySelectionChangedUpdaterIdentifier, actionIdentifier);
  702. m_hotKeyManagerInterface->SetActionHotKey(actionIdentifier, "F2");
  703. }
  704. // Find Entity (in the Entity Outliner)
  705. {
  706. const AZStd::string_view actionIdentifier = "o3de.action.entityOutliner.findEntity";
  707. AzToolsFramework::ActionProperties actionProperties;
  708. actionProperties.m_name = "Find in Entity Outliner";
  709. actionProperties.m_description = "Ensure the current entity is visible in the Entity Outliner.";
  710. actionProperties.m_category = "Entity";
  711. m_actionManagerInterface->RegisterAction(
  712. EditorIdentifiers::MainWindowActionContextIdentifier,
  713. actionIdentifier,
  714. actionProperties,
  715. []()
  716. {
  717. AzToolsFramework::EntityIdList selectedEntities;
  718. AzToolsFramework::ToolsApplicationRequests::Bus::BroadcastResult(
  719. selectedEntities, &AzToolsFramework::ToolsApplicationRequests::Bus::Events::GetSelectedEntities);
  720. if (!selectedEntities.empty())
  721. {
  722. AzToolsFramework::EditorEntityContextNotificationBus::Broadcast(
  723. &EditorEntityContextNotification::OnFocusInEntityOutliner, selectedEntities);
  724. }
  725. }
  726. );
  727. m_actionManagerInterface->InstallEnabledStateCallback(
  728. actionIdentifier,
  729. []() -> bool
  730. {
  731. AzToolsFramework::EntityIdList selectedEntities;
  732. AzToolsFramework::ToolsApplicationRequests::Bus::BroadcastResult(
  733. selectedEntities, &AzToolsFramework::ToolsApplicationRequests::Bus::Events::GetSelectedEntities);
  734. return !selectedEntities.empty();
  735. }
  736. );
  737. // Trigger update whenever entity selection changes.
  738. m_actionManagerInterface->AddActionToUpdater(EditorIdentifiers::EntitySelectionChangedUpdaterIdentifier, actionIdentifier);
  739. // Trigger update whenever entity selection changes.
  740. m_actionManagerInterface->AddActionToUpdater(EditorIdentifiers::EntitySelectionChangedUpdaterIdentifier, actionIdentifier);
  741. }
  742. // --- Game Actions
  743. // Play Game
  744. {
  745. constexpr AZStd::string_view actionIdentifier = "o3de.action.game.play";
  746. AzToolsFramework::ActionProperties actionProperties;
  747. actionProperties.m_name = "Play Game";
  748. actionProperties.m_description = "Activate the game input mode.";
  749. actionProperties.m_category = "Game";
  750. actionProperties.m_iconPath = ":/stylesheet/img/UI20/toolbar/Play.svg";
  751. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  752. m_actionManagerInterface->RegisterCheckableAction(
  753. EditorIdentifiers::MainWindowActionContextIdentifier,
  754. actionIdentifier,
  755. actionProperties,
  756. [cryEdit = m_cryEditApp]
  757. {
  758. cryEdit->OnViewSwitchToGame();
  759. },
  760. []
  761. {
  762. return GetIEditor()->IsInGameMode();
  763. }
  764. );
  765. m_actionManagerInterface->InstallEnabledStateCallback(actionIdentifier, IsLevelLoaded);
  766. m_actionManagerInterface->AddActionToUpdater(EditorIdentifiers::LevelLoadedUpdaterIdentifier, actionIdentifier);
  767. m_actionManagerInterface->AddActionToUpdater(EditorIdentifiers::GameModeStateChangedUpdaterIdentifier, actionIdentifier);
  768. // This action is only accessible outside of Component Modes
  769. m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, actionIdentifier);
  770. m_hotKeyManagerInterface->SetActionHotKey(actionIdentifier, "Ctrl+G");
  771. }
  772. // Play Game (Maximized)
  773. {
  774. constexpr AZStd::string_view actionIdentifier = "o3de.action.game.playMaximized";
  775. AzToolsFramework::ActionProperties actionProperties;
  776. actionProperties.m_name = "Play Game (Maximized)";
  777. actionProperties.m_description = "Activate the game input mode (maximized).";
  778. actionProperties.m_category = "Game";
  779. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  780. m_actionManagerInterface->RegisterCheckableAction(
  781. EditorIdentifiers::MainWindowActionContextIdentifier,
  782. actionIdentifier,
  783. actionProperties,
  784. [cryEdit = m_cryEditApp]
  785. {
  786. cryEdit->OnViewSwitchToGameFullScreen();
  787. },
  788. []
  789. {
  790. return GetIEditor()->IsInGameMode();
  791. }
  792. );
  793. m_actionManagerInterface->InstallEnabledStateCallback(actionIdentifier, IsLevelLoaded);
  794. m_actionManagerInterface->AddActionToUpdater(EditorIdentifiers::LevelLoadedUpdaterIdentifier, actionIdentifier);
  795. m_actionManagerInterface->AddActionToUpdater(EditorIdentifiers::GameModeStateChangedUpdaterIdentifier, actionIdentifier);
  796. // This action is only accessible outside of Component Modes
  797. m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, actionIdentifier);
  798. }
  799. // Simulate
  800. {
  801. constexpr AZStd::string_view actionIdentifier = "o3de.action.game.simulate";
  802. AzToolsFramework::ActionProperties actionProperties;
  803. actionProperties.m_name = "Simulate";
  804. actionProperties.m_description = "Enable processing of Physics and AI.";
  805. actionProperties.m_category = "Game";
  806. actionProperties.m_iconPath = ":/stylesheet/img/UI20/toolbar/Simulate_Physics.svg";
  807. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  808. m_actionManagerInterface->RegisterCheckableAction(
  809. EditorIdentifiers::MainWindowActionContextIdentifier,
  810. actionIdentifier,
  811. actionProperties,
  812. [cryEdit = m_cryEditApp]
  813. {
  814. cryEdit->OnSwitchPhysics();
  815. },
  816. [cryEdit = m_cryEditApp]
  817. {
  818. return !cryEdit->IsExportingLegacyData() && GetIEditor()->GetGameEngine()->GetSimulationMode();
  819. }
  820. );
  821. m_actionManagerInterface->InstallEnabledStateCallback(actionIdentifier, IsLevelLoaded);
  822. m_actionManagerInterface->AddActionToUpdater(EditorIdentifiers::LevelLoadedUpdaterIdentifier, actionIdentifier);
  823. m_actionManagerInterface->AddActionToUpdater(EditorIdentifiers::GameModeStateChangedUpdaterIdentifier, actionIdentifier);
  824. // This action is only accessible outside of Component Modes
  825. m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, actionIdentifier);
  826. }
  827. // Move Player and Camera Separately
  828. {
  829. constexpr AZStd::string_view actionIdentifier = "o3de.action.game.movePlayerAndCameraSeparately";
  830. AzToolsFramework::ActionProperties actionProperties;
  831. actionProperties.m_name = "Move Player and Camera Separately";
  832. actionProperties.m_description = "Move Player and Camera Separately.";
  833. actionProperties.m_category = "Game";
  834. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  835. m_actionManagerInterface->RegisterCheckableAction(
  836. EditorIdentifiers::MainWindowActionContextIdentifier,
  837. actionIdentifier,
  838. actionProperties,
  839. []
  840. {
  841. GetIEditor()->GetGameEngine()->SyncPlayerPosition(!GetIEditor()->GetGameEngine()->IsSyncPlayerPosition());
  842. },
  843. []
  844. {
  845. return !GetIEditor()->GetGameEngine()->IsSyncPlayerPosition();
  846. }
  847. );
  848. // This action is only accessible outside of Component Modes
  849. m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, actionIdentifier);
  850. }
  851. // Stop All Sounds
  852. {
  853. constexpr AZStd::string_view actionIdentifier = "o3de.action.game.audio.stopAllSounds";
  854. AzToolsFramework::ActionProperties actionProperties;
  855. actionProperties.m_name = "Stop All Sounds";
  856. actionProperties.m_description = "Stop All Sounds.";
  857. actionProperties.m_category = "Game";
  858. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  859. m_actionManagerInterface->RegisterAction(
  860. EditorIdentifiers::MainWindowActionContextIdentifier,
  861. actionIdentifier,
  862. actionProperties,
  863. []
  864. {
  865. LmbrCentral::AudioSystemComponentRequestBus::Broadcast(
  866. &LmbrCentral::AudioSystemComponentRequestBus::Events::GlobalStopAllSounds);
  867. }
  868. );
  869. // This action is only accessible outside of Component Modes
  870. m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, actionIdentifier);
  871. }
  872. // Refresh Audio System
  873. {
  874. constexpr AZStd::string_view actionIdentifier = "o3de.action.game.audio.refresh";
  875. AzToolsFramework::ActionProperties actionProperties;
  876. actionProperties.m_name = "Refresh";
  877. actionProperties.m_description = "Refresh Audio System.";
  878. actionProperties.m_category = "Game";
  879. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  880. m_actionManagerInterface->RegisterAction(
  881. EditorIdentifiers::MainWindowActionContextIdentifier,
  882. actionIdentifier,
  883. actionProperties,
  884. []
  885. {
  886. AZStd::string levelName;
  887. AzToolsFramework::EditorRequestBus::BroadcastResult(levelName, &AzToolsFramework::EditorRequestBus::Events::GetLevelName);
  888. AZStd::to_lower(levelName.begin(), levelName.end());
  889. if (levelName == "untitled")
  890. {
  891. levelName.clear();
  892. }
  893. LmbrCentral::AudioSystemComponentRequestBus::Broadcast(
  894. &LmbrCentral::AudioSystemComponentRequestBus::Events::GlobalRefreshAudio, AZStd::string_view{ levelName });
  895. }
  896. );
  897. // This action is only accessible outside of Component Modes
  898. m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, actionIdentifier);
  899. }
  900. // Error Report
  901. {
  902. constexpr AZStd::string_view actionIdentifier = "o3de.action.game.debugging.errorDialog";
  903. AzToolsFramework::ActionProperties actionProperties;
  904. actionProperties.m_name = "Error Report";
  905. actionProperties.m_description = "Open the Error Report dialog.";
  906. actionProperties.m_category = "Debugging";
  907. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  908. m_actionManagerInterface->RegisterAction(
  909. EditorIdentifiers::MainWindowActionContextIdentifier,
  910. actionIdentifier,
  911. actionProperties,
  912. [qtViewPaneManager = m_qtViewPaneManager]
  913. {
  914. qtViewPaneManager->OpenPane(LyViewPane::ErrorReport);
  915. }
  916. );
  917. // This action is only accessible outside of Component Modes
  918. m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, actionIdentifier);
  919. }
  920. // Configure Toolbox Macros
  921. {
  922. constexpr AZStd::string_view actionIdentifier = "o3de.action.game.debugging.toolboxMacros";
  923. AzToolsFramework::ActionProperties actionProperties;
  924. actionProperties.m_name = "Configure Toolbox Macros...";
  925. actionProperties.m_description = "Open the Toolbox Macros dialog.";
  926. actionProperties.m_category = "Debugging";
  927. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  928. m_actionManagerInterface->RegisterAction(
  929. EditorIdentifiers::MainWindowActionContextIdentifier,
  930. actionIdentifier,
  931. actionProperties,
  932. [&]
  933. {
  934. ToolsConfigDialog dlg;
  935. if (dlg.exec() == QDialog::Accepted)
  936. {
  937. RefreshToolboxMacroActions();
  938. }
  939. }
  940. );
  941. // This action is only accessible outside of Component Modes
  942. m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, actionIdentifier);
  943. }
  944. // -- Tools Actions
  945. // Lua Editor
  946. {
  947. constexpr AZStd::string_view actionIdentifier = "o3de.action.tools.luaEditor";
  948. AzToolsFramework::ActionProperties actionProperties;
  949. actionProperties.m_name = "Lua Editor";
  950. actionProperties.m_category = "Tools";
  951. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  952. m_actionManagerInterface->RegisterAction(
  953. EditorIdentifiers::MainWindowActionContextIdentifier,
  954. actionIdentifier,
  955. actionProperties,
  956. []
  957. {
  958. AzToolsFramework::EditorRequestBus::Broadcast(&AzToolsFramework::EditorRequests::LaunchLuaEditor, nullptr);
  959. }
  960. );
  961. // This action is only accessible outside of Component Modes
  962. m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, actionIdentifier);
  963. }
  964. // --- View Actions
  965. // Component Entity Layout
  966. {
  967. constexpr AZStd::string_view actionIdentifier = "o3de.action.layout.componentEntityLayout";
  968. AzToolsFramework::ActionProperties actionProperties;
  969. actionProperties.m_name = "Component Entity Layout (Default)";
  970. actionProperties.m_category = "Layout";
  971. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  972. m_actionManagerInterface->RegisterAction(
  973. EditorIdentifiers::MainWindowActionContextIdentifier,
  974. actionIdentifier,
  975. actionProperties,
  976. [this]
  977. {
  978. m_mainWindow->m_viewPaneManager->RestoreDefaultLayout();
  979. }
  980. );
  981. // This action is only accessible outside of Component Modes
  982. m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, actionIdentifier);
  983. }
  984. // Save Layout...
  985. {
  986. constexpr AZStd::string_view actionIdentifier = "o3de.action.layout.save";
  987. AzToolsFramework::ActionProperties actionProperties;
  988. actionProperties.m_name = "Save Layout...";
  989. actionProperties.m_description = "Save the current layout.";
  990. actionProperties.m_category = "Layout";
  991. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  992. m_actionManagerInterface->RegisterAction(
  993. EditorIdentifiers::MainWindowActionContextIdentifier,
  994. actionIdentifier,
  995. actionProperties,
  996. [this]
  997. {
  998. m_mainWindow->SaveLayout();
  999. }
  1000. );
  1001. // This action is only accessible outside of Component Modes
  1002. m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, actionIdentifier);
  1003. }
  1004. // Restore Default Layout
  1005. {
  1006. constexpr AZStd::string_view actionIdentifier = "o3de.action.layout.restoreDefault";
  1007. AzToolsFramework::ActionProperties actionProperties;
  1008. actionProperties.m_name = "Restore Default Layout";
  1009. actionProperties.m_description = "Restored the default layout for the Editor.";
  1010. actionProperties.m_category = "Layout";
  1011. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  1012. m_actionManagerInterface->RegisterAction(
  1013. EditorIdentifiers::MainWindowActionContextIdentifier,
  1014. actionIdentifier,
  1015. actionProperties,
  1016. [this]
  1017. {
  1018. m_mainWindow->m_viewPaneManager->RestoreDefaultLayout(true);
  1019. }
  1020. );
  1021. // This action is only accessible outside of Component Modes
  1022. m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, actionIdentifier);
  1023. }
  1024. // Go to Position...
  1025. {
  1026. constexpr AZStd::string_view actionIdentifier = "o3de.action.view.goToPosition";
  1027. AzToolsFramework::ActionProperties actionProperties;
  1028. actionProperties.m_name = "Go to Position...";
  1029. actionProperties.m_description = "Move the editor camera to the position and rotation provided.";
  1030. actionProperties.m_category = "View";
  1031. actionProperties.m_iconPath = ":/Menu/camera.svg";
  1032. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  1033. m_actionManagerInterface->RegisterAction(
  1034. EditorIdentifiers::MainWindowActionContextIdentifier,
  1035. actionIdentifier,
  1036. actionProperties,
  1037. [cryEdit = m_cryEditApp]
  1038. {
  1039. cryEdit->OnDisplayGotoPosition();
  1040. }
  1041. );
  1042. m_actionManagerInterface->InstallEnabledStateCallback(actionIdentifier, IsLevelLoaded);
  1043. m_actionManagerInterface->AddActionToUpdater(EditorIdentifiers::LevelLoadedUpdaterIdentifier, actionIdentifier);
  1044. }
  1045. // Center on Selection
  1046. {
  1047. constexpr AZStd::string_view actionIdentifier = "o3de.action.view.centerOnSelection";
  1048. AzToolsFramework::ActionProperties actionProperties;
  1049. actionProperties.m_name = "Find Selected Entities in Viewport";
  1050. actionProperties.m_description = "Center the viewport to show selected entities.";
  1051. actionProperties.m_category = "View";
  1052. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  1053. m_actionManagerInterface->RegisterAction(
  1054. EditorIdentifiers::MainWindowActionContextIdentifier,
  1055. actionIdentifier,
  1056. actionProperties,
  1057. []
  1058. {
  1059. AzToolsFramework::EditorRequestBus::Broadcast(&AzToolsFramework::EditorRequestBus::Events::GoToSelectedEntitiesInViewports);
  1060. }
  1061. );
  1062. m_actionManagerInterface->InstallEnabledStateCallback(actionIdentifier, AreEntitiesSelected);
  1063. m_actionManagerInterface->AddActionToUpdater(EditorIdentifiers::EntitySelectionChangedUpdaterIdentifier, actionIdentifier);
  1064. m_hotKeyManagerInterface->SetActionHotKey(actionIdentifier, "Z");
  1065. }
  1066. // View Bookmarks
  1067. InitializeViewBookmarkActions();
  1068. // Show Icons
  1069. {
  1070. constexpr AZStd::string_view actionIdentifier = "o3de.action.view.toggleIcons";
  1071. AzToolsFramework::ActionProperties actionProperties;
  1072. actionProperties.m_name = "Show Icons";
  1073. actionProperties.m_description = "Show/Hide Icons.";
  1074. actionProperties.m_category = "View";
  1075. m_actionManagerInterface->RegisterCheckableAction(
  1076. EditorIdentifiers::MainWindowActionContextIdentifier,
  1077. actionIdentifier,
  1078. actionProperties,
  1079. []
  1080. {
  1081. AzToolsFramework::SetIconsVisible(!AzToolsFramework::IconsVisible());
  1082. AzToolsFramework::EditorSettingsAPIBus::Broadcast(
  1083. &AzToolsFramework::EditorSettingsAPIBus::Events::SaveSettingsRegistryFile);
  1084. },
  1085. []
  1086. {
  1087. return AzToolsFramework::IconsVisible();
  1088. });
  1089. m_actionManagerInterface->AddActionToUpdater(EditorIdentifiers::IconsStateChangedUpdaterIdentifier, actionIdentifier);
  1090. m_hotKeyManagerInterface->SetActionHotKey(actionIdentifier, "Ctrl+Space");
  1091. }
  1092. // Show Helpers
  1093. {
  1094. constexpr AZStd::string_view actionIdentifier = "o3de.action.view.showHelpers";
  1095. AzToolsFramework::ActionProperties actionProperties;
  1096. actionProperties.m_name = "Show Helpers for all entities";
  1097. actionProperties.m_description = "Show Helpers.";
  1098. actionProperties.m_category = "View";
  1099. actionProperties.m_iconPath = ":/Menu/helpers.svg";
  1100. m_actionManagerInterface->RegisterCheckableAction(
  1101. EditorIdentifiers::MainWindowActionContextIdentifier,
  1102. actionIdentifier,
  1103. actionProperties,
  1104. [this]
  1105. {
  1106. AzToolsFramework::SetHelpersVisible(true);
  1107. AzToolsFramework::SetOnlyShowHelpersForSelectedEntities(false);
  1108. m_actionManagerInterface->TriggerActionUpdater(EditorIdentifiers::DrawHelpersStateChangedUpdaterIdentifier);
  1109. AzToolsFramework::EditorSettingsAPIBus::Broadcast(
  1110. &AzToolsFramework::EditorSettingsAPIBus::Events::SaveSettingsRegistryFile);
  1111. },
  1112. []
  1113. {
  1114. return AzToolsFramework::HelpersVisible();
  1115. }
  1116. );
  1117. m_actionManagerInterface->AddActionToUpdater(EditorIdentifiers::DrawHelpersStateChangedUpdaterIdentifier, actionIdentifier);
  1118. m_hotKeyManagerInterface->SetActionHotKey(actionIdentifier, "Shift+Space");
  1119. }
  1120. // Only Show Helpers for Selected Entities
  1121. {
  1122. constexpr AZStd::string_view actionIdentifier = "o3de.action.view.showSelectedEntityHelpers";
  1123. AzToolsFramework::ActionProperties actionProperties;
  1124. actionProperties.m_name = "Show Helpers for selected entities";
  1125. actionProperties.m_description = "If enabled, shows Helpers for selected entities only.";
  1126. actionProperties.m_category = "View";
  1127. m_actionManagerInterface->RegisterCheckableAction(
  1128. EditorIdentifiers::MainWindowActionContextIdentifier,
  1129. actionIdentifier,
  1130. actionProperties,
  1131. [this]
  1132. {
  1133. AzToolsFramework::SetOnlyShowHelpersForSelectedEntities(true);
  1134. AzToolsFramework::SetHelpersVisible(false);
  1135. m_actionManagerInterface->TriggerActionUpdater(EditorIdentifiers::DrawHelpersStateChangedUpdaterIdentifier);
  1136. AzToolsFramework::EditorSettingsAPIBus::Broadcast(
  1137. &AzToolsFramework::EditorSettingsAPIBus::Events::SaveSettingsRegistryFile);
  1138. },
  1139. []
  1140. {
  1141. return AzToolsFramework::OnlyShowHelpersForSelectedEntities();
  1142. });
  1143. m_actionManagerInterface->AddActionToUpdater(EditorIdentifiers::DrawHelpersStateChangedUpdaterIdentifier, actionIdentifier);
  1144. }
  1145. // Hide Helpers
  1146. {
  1147. constexpr AZStd::string_view actionIdentifier = "o3de.action.view.hideHelpers";
  1148. AzToolsFramework::ActionProperties actionProperties;
  1149. actionProperties.m_name = "Hide Helpers";
  1150. actionProperties.m_description = "Hide all helpers";
  1151. actionProperties.m_category = "View";
  1152. m_actionManagerInterface->RegisterCheckableAction(
  1153. EditorIdentifiers::MainWindowActionContextIdentifier,
  1154. actionIdentifier,
  1155. actionProperties,
  1156. [this]
  1157. {
  1158. AzToolsFramework::SetOnlyShowHelpersForSelectedEntities(false);
  1159. AzToolsFramework::SetHelpersVisible(false);
  1160. m_actionManagerInterface->TriggerActionUpdater(EditorIdentifiers::DrawHelpersStateChangedUpdaterIdentifier);
  1161. AzToolsFramework::EditorSettingsAPIBus::Broadcast(
  1162. &AzToolsFramework::EditorSettingsAPIBus::Events::SaveSettingsRegistryFile);
  1163. },
  1164. []
  1165. {
  1166. return !AzToolsFramework::HelpersVisible() && !AzToolsFramework::OnlyShowHelpersForSelectedEntities();
  1167. });
  1168. m_actionManagerInterface->AddActionToUpdater(EditorIdentifiers::DrawHelpersStateChangedUpdaterIdentifier, actionIdentifier);
  1169. }
  1170. // Refresh Style
  1171. {
  1172. constexpr AZStd::string_view actionIdentifier = "o3de.action.view.refreshEditorStyle";
  1173. AzToolsFramework::ActionProperties actionProperties;
  1174. actionProperties.m_name = "Refresh Style";
  1175. actionProperties.m_description = "Refreshes the editor stylesheet.";
  1176. actionProperties.m_category = "View";
  1177. m_actionManagerInterface->RegisterAction(
  1178. EditorIdentifiers::MainWindowActionContextIdentifier,
  1179. actionIdentifier,
  1180. actionProperties,
  1181. []
  1182. {
  1183. GetIEditor()->Notify(eNotify_OnStyleChanged);
  1184. }
  1185. );
  1186. }
  1187. // --- Help Actions
  1188. // Tutorials
  1189. {
  1190. AzToolsFramework::ActionProperties actionProperties;
  1191. actionProperties.m_name = "Tutorials";
  1192. actionProperties.m_category = "Help";
  1193. m_actionManagerInterface->RegisterAction(
  1194. EditorIdentifiers::MainWindowActionContextIdentifier, "o3de.action.help.tutorials", actionProperties,
  1195. [cryEdit = m_cryEditApp]
  1196. {
  1197. cryEdit->OnDocumentationTutorials();
  1198. }
  1199. );
  1200. }
  1201. // Open 3D Engine Documentation
  1202. {
  1203. AzToolsFramework::ActionProperties actionProperties;
  1204. actionProperties.m_name = "Open 3D Engine Documentation";
  1205. actionProperties.m_category = "Help";
  1206. m_actionManagerInterface->RegisterAction(
  1207. EditorIdentifiers::MainWindowActionContextIdentifier, "o3de.action.help.documentation.o3de", actionProperties,
  1208. [cryEdit = m_cryEditApp]
  1209. {
  1210. cryEdit->OnDocumentationO3DE();
  1211. }
  1212. );
  1213. }
  1214. // GameLift Documentation
  1215. {
  1216. AzToolsFramework::ActionProperties actionProperties;
  1217. actionProperties.m_name = "GameLift Documentation";
  1218. actionProperties.m_category = "Help";
  1219. m_actionManagerInterface->RegisterAction(
  1220. EditorIdentifiers::MainWindowActionContextIdentifier, "o3de.action.help.documentation.gamelift", actionProperties,
  1221. [cryEdit = m_cryEditApp]
  1222. {
  1223. cryEdit->OnDocumentationGamelift();
  1224. }
  1225. );
  1226. }
  1227. // Release Notes
  1228. {
  1229. AzToolsFramework::ActionProperties actionProperties;
  1230. actionProperties.m_name = "Release Notes";
  1231. actionProperties.m_category = "Help";
  1232. m_actionManagerInterface->RegisterAction(
  1233. EditorIdentifiers::MainWindowActionContextIdentifier, "o3de.action.help.documentation.releasenotes", actionProperties,
  1234. [cryEdit = m_cryEditApp]
  1235. {
  1236. cryEdit->OnDocumentationReleaseNotes();
  1237. }
  1238. );
  1239. }
  1240. // GameDev Blog
  1241. {
  1242. AzToolsFramework::ActionProperties actionProperties;
  1243. actionProperties.m_name = "GameDev Blog";
  1244. actionProperties.m_category = "Help";
  1245. m_actionManagerInterface->RegisterAction(
  1246. EditorIdentifiers::MainWindowActionContextIdentifier, "o3de.action.help.resources.gamedevblog", actionProperties,
  1247. [cryEdit = m_cryEditApp]
  1248. {
  1249. cryEdit->OnDocumentationGameDevBlog();
  1250. }
  1251. );
  1252. }
  1253. // Forums
  1254. {
  1255. AzToolsFramework::ActionProperties actionProperties;
  1256. actionProperties.m_name = "Forums";
  1257. actionProperties.m_category = "Help";
  1258. m_actionManagerInterface->RegisterAction(
  1259. EditorIdentifiers::MainWindowActionContextIdentifier, "o3de.action.help.resources.forums", actionProperties,
  1260. [cryEdit = m_cryEditApp]
  1261. {
  1262. cryEdit->OnDocumentationForums();
  1263. }
  1264. );
  1265. }
  1266. // AWS Support
  1267. {
  1268. AzToolsFramework::ActionProperties actionProperties;
  1269. actionProperties.m_name = "AWS Support";
  1270. actionProperties.m_category = "Help";
  1271. m_actionManagerInterface->RegisterAction(
  1272. EditorIdentifiers::MainWindowActionContextIdentifier, "o3de.action.help.resources.awssupport", actionProperties,
  1273. [cryEdit = m_cryEditApp]
  1274. {
  1275. cryEdit->OnDocumentationAWSSupport();
  1276. }
  1277. );
  1278. }
  1279. // About O3DE
  1280. {
  1281. AzToolsFramework::ActionProperties actionProperties;
  1282. actionProperties.m_name = "&About O3DE";
  1283. actionProperties.m_category = "Help";
  1284. m_actionManagerInterface->RegisterAction(
  1285. EditorIdentifiers::MainWindowActionContextIdentifier, "o3de.action.help.abouto3de", actionProperties,
  1286. [cryEdit = m_cryEditApp]
  1287. {
  1288. cryEdit->OnAppAbout();
  1289. }
  1290. );
  1291. }
  1292. // Welcome
  1293. {
  1294. constexpr AZStd::string_view actionIdentifier = "o3de.action.help.welcome";
  1295. AzToolsFramework::ActionProperties actionProperties;
  1296. actionProperties.m_name = "&Welcome";
  1297. actionProperties.m_category = "Help";
  1298. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  1299. m_actionManagerInterface->RegisterAction(
  1300. EditorIdentifiers::MainWindowActionContextIdentifier,
  1301. actionIdentifier,
  1302. actionProperties,
  1303. [cryEdit = m_cryEditApp]
  1304. {
  1305. cryEdit->OnAppShowWelcomeScreen();
  1306. }
  1307. );
  1308. // This action is only accessible outside of Component Modes
  1309. m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, actionIdentifier);
  1310. }
  1311. }
  1312. void EditorActionsHandler::OnWidgetActionRegistrationHook()
  1313. {
  1314. // Help - Search Documentation Widget
  1315. {
  1316. AzToolsFramework::WidgetActionProperties widgetActionProperties;
  1317. widgetActionProperties.m_name = "Search Documentation";
  1318. widgetActionProperties.m_category = "Help";
  1319. auto outcome = m_actionManagerInterface->RegisterWidgetAction(
  1320. "o3de.widgetAction.help.searchDocumentation",
  1321. widgetActionProperties,
  1322. [&]
  1323. {
  1324. return CreateDocsSearchWidget();
  1325. }
  1326. );
  1327. }
  1328. // Expander
  1329. {
  1330. AzToolsFramework::WidgetActionProperties widgetActionProperties;
  1331. widgetActionProperties.m_name = "Expander";
  1332. widgetActionProperties.m_category = "Widgets";
  1333. m_actionManagerInterface->RegisterWidgetAction(
  1334. "o3de.widgetAction.expander",
  1335. widgetActionProperties,
  1336. [&]
  1337. {
  1338. return CreateExpander();
  1339. }
  1340. );
  1341. }
  1342. // Play Controls - Label
  1343. {
  1344. AzToolsFramework::WidgetActionProperties widgetActionProperties;
  1345. widgetActionProperties.m_name = "Play Controls Label";
  1346. widgetActionProperties.m_category = "Game";
  1347. m_actionManagerInterface->RegisterWidgetAction(
  1348. "o3de.widgetAction.game.playControlsLabel",
  1349. widgetActionProperties,
  1350. [&]
  1351. {
  1352. return CreatePlayControlsLabel();
  1353. }
  1354. );
  1355. }
  1356. // Prefab Edit Visual Mode Selection Widget
  1357. {
  1358. AzToolsFramework::WidgetActionProperties widgetActionProperties;
  1359. widgetActionProperties.m_name = "Prefab Edit Visual Mode Selection";
  1360. widgetActionProperties.m_category = "Prefabs";
  1361. auto outcome = m_actionManagerInterface->RegisterWidgetAction(
  1362. "o3de.widgetAction.prefab.editVisualMode",
  1363. widgetActionProperties,
  1364. []() -> QWidget*
  1365. {
  1366. return new PrefabEditVisualModeWidget();
  1367. }
  1368. );
  1369. }
  1370. // Viewport - Field of View Property Widget
  1371. {
  1372. AzToolsFramework::WidgetActionProperties widgetActionProperties;
  1373. widgetActionProperties.m_name = "Viewport Field of View";
  1374. widgetActionProperties.m_category = "Viewport";
  1375. auto outcome = m_actionManagerInterface->RegisterWidgetAction(
  1376. "o3de.widgetAction.viewport.fieldOfView",
  1377. widgetActionProperties,
  1378. []() -> QWidget*
  1379. {
  1380. return new ViewportFieldOfViewPropertyWidget();
  1381. }
  1382. );
  1383. }
  1384. // Viewport - Camera Speed Scale Property Widget
  1385. {
  1386. AzToolsFramework::WidgetActionProperties widgetActionProperties;
  1387. widgetActionProperties.m_name = "Viewport Camera Speed Scale";
  1388. widgetActionProperties.m_category = "Viewport";
  1389. auto outcome = m_actionManagerInterface->RegisterWidgetAction(
  1390. "o3de.widgetAction.viewport.cameraSpeedScale",
  1391. widgetActionProperties,
  1392. []() -> QWidget*
  1393. {
  1394. return new ViewportCameraSpeedScalePropertyWidget();
  1395. }
  1396. );
  1397. }
  1398. // Viewport - Grid Size Property Widget
  1399. {
  1400. AzToolsFramework::WidgetActionProperties widgetActionProperties;
  1401. widgetActionProperties.m_name = "Viewport Grid Snapping Size";
  1402. widgetActionProperties.m_category = "Viewport";
  1403. auto outcome = m_actionManagerInterface->RegisterWidgetAction(
  1404. "o3de.widgetAction.viewport.gridSnappingSize",
  1405. widgetActionProperties,
  1406. []() -> QWidget*
  1407. {
  1408. return new ViewportGridSnappingSizePropertyWidget();
  1409. }
  1410. );
  1411. }
  1412. // Viewport - Angle Size Property Widget
  1413. {
  1414. AzToolsFramework::WidgetActionProperties widgetActionProperties;
  1415. widgetActionProperties.m_name = "Viewport Angle Snapping Size";
  1416. widgetActionProperties.m_category = "Viewport";
  1417. auto outcome = m_actionManagerInterface->RegisterWidgetAction(
  1418. "o3de.widgetAction.viewport.angleSnappingSize",
  1419. widgetActionProperties,
  1420. []() -> QWidget*
  1421. {
  1422. return new ViewportAngleSnappingSizePropertyWidget();
  1423. }
  1424. );
  1425. }
  1426. }
  1427. void EditorActionsHandler::OnMenuBarRegistrationHook()
  1428. {
  1429. // Register MenuBar
  1430. m_menuManagerInterface->RegisterMenuBar(EditorIdentifiers::EditorMainWindowMenuBarIdentifier, m_mainWindow);
  1431. }
  1432. void EditorActionsHandler::OnMenuRegistrationHook()
  1433. {
  1434. // Initialize Menus
  1435. {
  1436. AzToolsFramework::MenuProperties menuProperties;
  1437. menuProperties.m_name = "&File";
  1438. m_menuManagerInterface->RegisterMenu(EditorIdentifiers::FileMenuIdentifier, menuProperties);
  1439. }
  1440. {
  1441. AzToolsFramework::MenuProperties menuProperties;
  1442. menuProperties.m_name = "Open Recent";
  1443. m_menuManagerInterface->RegisterMenu(EditorIdentifiers::RecentFilesMenuIdentifier, menuProperties);
  1444. // Legacy - the menu should update when the files list is changed.
  1445. QMenu* menu = m_menuManagerInternalInterface->GetMenu(EditorIdentifiers::FileMenuIdentifier);
  1446. QObject::connect(
  1447. menu,
  1448. &QMenu::aboutToShow,
  1449. m_mainWindow,
  1450. [&]
  1451. {
  1452. UpdateRecentFileActions();
  1453. }
  1454. );
  1455. }
  1456. {
  1457. AzToolsFramework::MenuProperties menuProperties;
  1458. menuProperties.m_name = "&Edit";
  1459. m_menuManagerInterface->RegisterMenu(EditorIdentifiers::EditMenuIdentifier, menuProperties);
  1460. }
  1461. {
  1462. AzToolsFramework::MenuProperties menuProperties;
  1463. menuProperties.m_name = "Modify";
  1464. m_menuManagerInterface->RegisterMenu(EditorIdentifiers::EditModifyMenuIdentifier, menuProperties);
  1465. }
  1466. {
  1467. AzToolsFramework::MenuProperties menuProperties;
  1468. menuProperties.m_name = "Snap";
  1469. m_menuManagerInterface->RegisterMenu(EditorIdentifiers::EditModifySnapMenuIdentifier, menuProperties);
  1470. }
  1471. {
  1472. AzToolsFramework::MenuProperties menuProperties;
  1473. menuProperties.m_name = "Transform Mode";
  1474. m_menuManagerInterface->RegisterMenu(EditorIdentifiers::EditModifyModesMenuIdentifier, menuProperties);
  1475. }
  1476. {
  1477. AzToolsFramework::MenuProperties menuProperties;
  1478. menuProperties.m_name = "Editor Settings";
  1479. m_menuManagerInterface->RegisterMenu(EditorIdentifiers::EditSettingsMenuIdentifier, menuProperties);
  1480. }
  1481. {
  1482. AzToolsFramework::MenuProperties menuProperties;
  1483. menuProperties.m_name = "&Game";
  1484. m_menuManagerInterface->RegisterMenu(EditorIdentifiers::GameMenuIdentifier, menuProperties);
  1485. }
  1486. {
  1487. AzToolsFramework::MenuProperties menuProperties;
  1488. menuProperties.m_name = "Play Game";
  1489. m_menuManagerInterface->RegisterMenu(EditorIdentifiers::PlayGameMenuIdentifier, menuProperties);
  1490. }
  1491. {
  1492. AzToolsFramework::MenuProperties menuProperties;
  1493. menuProperties.m_name = "Audio";
  1494. m_menuManagerInterface->RegisterMenu(EditorIdentifiers::GameAudioMenuIdentifier, menuProperties);
  1495. }
  1496. {
  1497. AzToolsFramework::MenuProperties menuProperties;
  1498. menuProperties.m_name = "Debugging";
  1499. m_menuManagerInterface->RegisterMenu(EditorIdentifiers::GameDebuggingMenuIdentifier, menuProperties);
  1500. }
  1501. {
  1502. AzToolsFramework::MenuProperties menuProperties;
  1503. menuProperties.m_name = "ToolBox Macros";
  1504. m_menuManagerInterface->RegisterMenu(EditorIdentifiers::ToolBoxMacrosMenuIdentifier, menuProperties);
  1505. }
  1506. {
  1507. AzToolsFramework::MenuProperties menuProperties;
  1508. menuProperties.m_name = "&Tools";
  1509. m_menuManagerInterface->RegisterMenu(EditorIdentifiers::ToolsMenuIdentifier, menuProperties);
  1510. }
  1511. {
  1512. AzToolsFramework::MenuProperties menuProperties;
  1513. menuProperties.m_name = "&View";
  1514. m_menuManagerInterface->RegisterMenu(EditorIdentifiers::ViewMenuIdentifier, menuProperties);
  1515. }
  1516. {
  1517. AzToolsFramework::MenuProperties menuProperties;
  1518. menuProperties.m_name = "Layouts";
  1519. m_menuManagerInterface->RegisterMenu(EditorIdentifiers::LayoutsMenuIdentifier, menuProperties);
  1520. }
  1521. {
  1522. AzToolsFramework::MenuProperties menuProperties;
  1523. menuProperties.m_name = "Viewport";
  1524. m_menuManagerInterface->RegisterMenu(EditorIdentifiers::ViewportMenuIdentifier, menuProperties);
  1525. }
  1526. {
  1527. AzToolsFramework::MenuProperties menuProperties;
  1528. menuProperties.m_name = "Go to Location";
  1529. m_menuManagerInterface->RegisterMenu(EditorIdentifiers::GoToLocationMenuIdentifier, menuProperties);
  1530. }
  1531. {
  1532. AzToolsFramework::MenuProperties menuProperties;
  1533. menuProperties.m_name = "Save Location";
  1534. m_menuManagerInterface->RegisterMenu(EditorIdentifiers::SaveLocationMenuIdentifier, menuProperties);
  1535. }
  1536. {
  1537. AzToolsFramework::MenuProperties menuProperties;
  1538. menuProperties.m_name = "&Help";
  1539. m_menuManagerInterface->RegisterMenu(EditorIdentifiers::HelpMenuIdentifier, menuProperties);
  1540. }
  1541. {
  1542. AzToolsFramework::MenuProperties menuProperties;
  1543. menuProperties.m_name = "Documentation";
  1544. m_menuManagerInterface->RegisterMenu(EditorIdentifiers::HelpDocumentationMenuIdentifier, menuProperties);
  1545. }
  1546. {
  1547. AzToolsFramework::MenuProperties menuProperties;
  1548. menuProperties.m_name = "GameDev Resources";
  1549. m_menuManagerInterface->RegisterMenu(EditorIdentifiers::HelpGameDevResourcesMenuIdentifier, menuProperties);
  1550. }
  1551. // Editor Menus
  1552. {
  1553. AzToolsFramework::MenuProperties menuProperties;
  1554. menuProperties.m_name = "Entity Outliner Context Menu";
  1555. m_menuManagerInterface->RegisterMenu(EditorIdentifiers::EntityOutlinerContextMenuIdentifier, menuProperties);
  1556. }
  1557. {
  1558. AzToolsFramework::MenuProperties menuProperties;
  1559. menuProperties.m_name = "Viewport Context Menu";
  1560. m_menuManagerInterface->RegisterMenu(EditorIdentifiers::ViewportContextMenuIdentifier, menuProperties);
  1561. }
  1562. {
  1563. AzToolsFramework::MenuProperties menuProperties;
  1564. menuProperties.m_name = "Create";
  1565. m_menuManagerInterface->RegisterMenu(EditorIdentifiers::EntityCreationMenuIdentifier, menuProperties);
  1566. }
  1567. }
  1568. void EditorActionsHandler::OnMenuBindingHook()
  1569. {
  1570. // Add Menus to MenuBar
  1571. // We space the sortkeys by 100 to allow external systems to add menus in-between.
  1572. m_menuManagerInterface->AddMenuToMenuBar(EditorIdentifiers::EditorMainWindowMenuBarIdentifier, EditorIdentifiers::FileMenuIdentifier, 100);
  1573. m_menuManagerInterface->AddMenuToMenuBar(EditorIdentifiers::EditorMainWindowMenuBarIdentifier, EditorIdentifiers::EditMenuIdentifier, 200);
  1574. m_menuManagerInterface->AddMenuToMenuBar(EditorIdentifiers::EditorMainWindowMenuBarIdentifier, EditorIdentifiers::GameMenuIdentifier, 300);
  1575. m_menuManagerInterface->AddMenuToMenuBar(EditorIdentifiers::EditorMainWindowMenuBarIdentifier, EditorIdentifiers::ToolsMenuIdentifier, 400);
  1576. m_menuManagerInterface->AddMenuToMenuBar(EditorIdentifiers::EditorMainWindowMenuBarIdentifier, EditorIdentifiers::ViewMenuIdentifier, 500);
  1577. m_menuManagerInterface->AddMenuToMenuBar(EditorIdentifiers::EditorMainWindowMenuBarIdentifier, EditorIdentifiers::HelpMenuIdentifier, 600);
  1578. // Add actions to each menu
  1579. // File
  1580. {
  1581. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::FileMenuIdentifier, "o3de.action.file.new", 100);
  1582. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::FileMenuIdentifier, "o3de.action.file.open", 200);
  1583. m_menuManagerInterface->AddSubMenuToMenu(EditorIdentifiers::FileMenuIdentifier, EditorIdentifiers::RecentFilesMenuIdentifier, 300);
  1584. {
  1585. for (int index = 0; index < maxRecentFiles; ++index)
  1586. {
  1587. AZStd::string actionIdentifier = AZStd::string::format("o3de.action.file.recent.file%i", index + 1);
  1588. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::RecentFilesMenuIdentifier, actionIdentifier, 100);
  1589. }
  1590. m_menuManagerInterface->AddSeparatorToMenu(EditorIdentifiers::RecentFilesMenuIdentifier, 200);
  1591. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::RecentFilesMenuIdentifier, "o3de.action.file.recent.clearAll", 300);
  1592. }
  1593. m_menuManagerInterface->AddSeparatorToMenu(EditorIdentifiers::FileMenuIdentifier, 400);
  1594. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::FileMenuIdentifier, "o3de.action.file.save", 500);
  1595. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::FileMenuIdentifier, "o3de.action.file.saveAs", 600);
  1596. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::FileMenuIdentifier, "o3de.action.file.saveLevelStatistics", 700);
  1597. m_menuManagerInterface->AddSeparatorToMenu(EditorIdentifiers::FileMenuIdentifier, 800);
  1598. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::FileMenuIdentifier, "o3de.action.project.editSettings", 900);
  1599. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::FileMenuIdentifier, "o3de.action.platform.editSettings", 1000);
  1600. m_menuManagerInterface->AddSeparatorToMenu(EditorIdentifiers::FileMenuIdentifier, 1100);
  1601. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::FileMenuIdentifier, "o3de.action.project.new", 1200);
  1602. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::FileMenuIdentifier, "o3de.action.project.open", 1300);
  1603. m_menuManagerInterface->AddSeparatorToMenu(EditorIdentifiers::FileMenuIdentifier, 1400);
  1604. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::FileMenuIdentifier, "o3de.action.file.showLog", 1500);
  1605. m_menuManagerInterface->AddSeparatorToMenu(EditorIdentifiers::FileMenuIdentifier, 1600);
  1606. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::FileMenuIdentifier, "o3de.action.editor.exit", 1700);
  1607. }
  1608. // Edit
  1609. {
  1610. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::EditMenuIdentifier, "o3de.action.edit.undo", 100);
  1611. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::EditMenuIdentifier, "o3de.action.edit.redo", 200);
  1612. m_menuManagerInterface->AddSubMenuToMenu(EditorIdentifiers::EditMenuIdentifier, EditorIdentifiers::EditModifyMenuIdentifier, 1800);
  1613. {
  1614. m_menuManagerInterface->AddSubMenuToMenu(EditorIdentifiers::EditModifyMenuIdentifier, EditorIdentifiers::EditModifySnapMenuIdentifier, 100);
  1615. {
  1616. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::EditModifySnapMenuIdentifier, "o3de.action.edit.snap.toggleGridSnapping", 100);
  1617. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::EditModifySnapMenuIdentifier, "o3de.action.edit.snap.toggleAngleSnapping", 200);
  1618. }
  1619. m_menuManagerInterface->AddSubMenuToMenu(EditorIdentifiers::EditModifyMenuIdentifier, EditorIdentifiers::EditModifyModesMenuIdentifier, 200);
  1620. }
  1621. m_menuManagerInterface->AddSeparatorToMenu(EditorIdentifiers::EditMenuIdentifier, 1900);
  1622. m_menuManagerInterface->AddSubMenuToMenu(EditorIdentifiers::EditMenuIdentifier, EditorIdentifiers::EditSettingsMenuIdentifier, 2000);
  1623. {
  1624. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::EditSettingsMenuIdentifier, "o3de.action.edit.globalPreferences", 100);
  1625. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::EditSettingsMenuIdentifier, "o3de.action.edit.editorSettingsManager", 200);
  1626. }
  1627. }
  1628. // Game
  1629. {
  1630. m_menuManagerInterface->AddSubMenuToMenu(EditorIdentifiers::GameMenuIdentifier, EditorIdentifiers::PlayGameMenuIdentifier, 100);
  1631. {
  1632. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::PlayGameMenuIdentifier, "o3de.action.game.play", 100);
  1633. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::PlayGameMenuIdentifier, "o3de.action.game.playMaximized", 200);
  1634. }
  1635. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::GameMenuIdentifier, "o3de.action.game.simulate", 200);
  1636. m_menuManagerInterface->AddSeparatorToMenu(EditorIdentifiers::GameMenuIdentifier, 300);
  1637. m_menuManagerInterface->AddSeparatorToMenu(EditorIdentifiers::GameMenuIdentifier, 600);
  1638. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::GameMenuIdentifier, "o3de.action.game.movePlayerAndCameraSeparately", 700);
  1639. m_menuManagerInterface->AddSeparatorToMenu(EditorIdentifiers::GameMenuIdentifier, 800);
  1640. m_menuManagerInterface->AddSubMenuToMenu(EditorIdentifiers::GameMenuIdentifier, EditorIdentifiers::GameAudioMenuIdentifier, 900);
  1641. {
  1642. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::GameAudioMenuIdentifier, "o3de.action.game.audio.stopAllSounds", 100);
  1643. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::GameAudioMenuIdentifier, "o3de.action.game.audio.refresh", 200);
  1644. }
  1645. m_menuManagerInterface->AddSeparatorToMenu(EditorIdentifiers::GameMenuIdentifier, 1000);
  1646. m_menuManagerInterface->AddSubMenuToMenu(EditorIdentifiers::GameMenuIdentifier, EditorIdentifiers::GameDebuggingMenuIdentifier, 1100);
  1647. {
  1648. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::GameDebuggingMenuIdentifier, "o3de.action.game.debugging.errorDialog", 100);
  1649. m_menuManagerInterface->AddSeparatorToMenu(EditorIdentifiers::GameDebuggingMenuIdentifier, 200);
  1650. m_menuManagerInterface->AddSubMenuToMenu(EditorIdentifiers::GameDebuggingMenuIdentifier, EditorIdentifiers::ToolBoxMacrosMenuIdentifier, 300);
  1651. {
  1652. // Some of the contents of the ToolBox Macros menu are initialized in RefreshToolboxMacrosActions.
  1653. m_menuManagerInterface->AddSeparatorToMenu(EditorIdentifiers::ToolBoxMacrosMenuIdentifier, 200);
  1654. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::ToolBoxMacrosMenuIdentifier, "o3de.action.game.debugging.toolboxMacros", 300);
  1655. }
  1656. }
  1657. }
  1658. // Tools
  1659. {
  1660. m_menuManagerInterface->AddActionToMenu(
  1661. EditorIdentifiers::ToolsMenuIdentifier,
  1662. "o3de.action.tools.luaEditor",
  1663. m_actionManagerInterface->GenerateActionAlphabeticalSortKey("o3de.action.tools.luaEditor")
  1664. );
  1665. }
  1666. // View
  1667. {
  1668. m_menuManagerInterface->AddSubMenuToMenu(EditorIdentifiers::ViewMenuIdentifier, EditorIdentifiers::LayoutsMenuIdentifier, 100);
  1669. {
  1670. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::LayoutsMenuIdentifier, "o3de.action.layout.componentEntityLayout", 100);
  1671. m_menuManagerInterface->AddSeparatorToMenu(EditorIdentifiers::LayoutsMenuIdentifier, 200);
  1672. // Some of the contents of the Layouts menu are initialized in RefreshLayoutActions.
  1673. m_menuManagerInterface->AddSeparatorToMenu(EditorIdentifiers::LayoutsMenuIdentifier, 400);
  1674. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::LayoutsMenuIdentifier, "o3de.action.layout.save", 500);
  1675. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::LayoutsMenuIdentifier, "o3de.action.layout.restoreDefault", 600);
  1676. }
  1677. m_menuManagerInterface->AddSubMenuToMenu(EditorIdentifiers::ViewMenuIdentifier, EditorIdentifiers::ViewportMenuIdentifier, 200);
  1678. {
  1679. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::ViewportMenuIdentifier, "o3de.action.view.goToPosition", 100);
  1680. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::ViewportMenuIdentifier, "o3de.action.view.centerOnSelection", 200);
  1681. m_menuManagerInterface->AddSubMenuToMenu(EditorIdentifiers::ViewportMenuIdentifier, EditorIdentifiers::GoToLocationMenuIdentifier, 300);
  1682. {
  1683. for (int index = 0; index < m_defaultBookmarkCount; ++index)
  1684. {
  1685. const AZStd::string actionIdentifier = AZStd::string::format("o3de.action.view.bookmark[%i].goTo", index);
  1686. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::GoToLocationMenuIdentifier, actionIdentifier, 0);
  1687. }
  1688. }
  1689. m_menuManagerInterface->AddSubMenuToMenu(EditorIdentifiers::ViewportMenuIdentifier, EditorIdentifiers::SaveLocationMenuIdentifier, 400);
  1690. {
  1691. for (int index = 0; index < m_defaultBookmarkCount; ++index)
  1692. {
  1693. const AZStd::string actionIdentifier = AZStd::string::format("o3de.action.view.bookmark[%i].save", index);
  1694. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::SaveLocationMenuIdentifier, actionIdentifier, 0);
  1695. }
  1696. }
  1697. m_menuManagerInterface->AddSeparatorToMenu(EditorIdentifiers::ViewportMenuIdentifier, 500);
  1698. m_menuManagerInterface->AddSubMenuToMenu(
  1699. EditorIdentifiers::ViewportMenuIdentifier, EditorIdentifiers::ViewportHelpersMenuIdentifier, 600);
  1700. }
  1701. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::ViewMenuIdentifier, "o3de.action.view.refreshEditorStyle", 300);
  1702. }
  1703. // Help
  1704. {
  1705. m_menuManagerInterface->AddWidgetToMenu(EditorIdentifiers::HelpMenuIdentifier, "o3de.widgetAction.help.searchDocumentation", 100);
  1706. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::HelpMenuIdentifier, "o3de.action.help.tutorials", 200);
  1707. m_menuManagerInterface->AddSubMenuToMenu(EditorIdentifiers::HelpMenuIdentifier, EditorIdentifiers::HelpDocumentationMenuIdentifier, 300);
  1708. {
  1709. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::HelpDocumentationMenuIdentifier, "o3de.action.help.documentation.o3de", 100);
  1710. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::HelpDocumentationMenuIdentifier, "o3de.action.help.documentation.gamelift", 200);
  1711. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::HelpDocumentationMenuIdentifier, "o3de.action.help.documentation.releasenotes", 300);
  1712. }
  1713. m_menuManagerInterface->AddSubMenuToMenu(EditorIdentifiers::HelpMenuIdentifier, EditorIdentifiers::HelpGameDevResourcesMenuIdentifier, 400);
  1714. {
  1715. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::HelpGameDevResourcesMenuIdentifier, "o3de.action.help.resources.gamedevblog", 100);
  1716. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::HelpGameDevResourcesMenuIdentifier, "o3de.action.help.resources.forums", 200);
  1717. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::HelpGameDevResourcesMenuIdentifier, "o3de.action.help.resources.awssupport", 300);
  1718. }
  1719. m_menuManagerInterface->AddSeparatorToMenu(EditorIdentifiers::HelpMenuIdentifier, 500);
  1720. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::HelpMenuIdentifier, "o3de.action.help.abouto3de", 600);
  1721. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::HelpMenuIdentifier, "o3de.action.help.welcome", 700);
  1722. }
  1723. // Entity Outliner Context Menu
  1724. m_menuManagerInterface->AddSubMenuToMenu(
  1725. EditorIdentifiers::EntityOutlinerContextMenuIdentifier, EditorIdentifiers::EntityCreationMenuIdentifier, 200);
  1726. m_menuManagerInterface->AddSeparatorToMenu(EditorIdentifiers::EntityOutlinerContextMenuIdentifier, 10000);
  1727. m_menuManagerInterface->AddSeparatorToMenu(EditorIdentifiers::EntityOutlinerContextMenuIdentifier, 20000);
  1728. m_menuManagerInterface->AddSeparatorToMenu(EditorIdentifiers::EntityOutlinerContextMenuIdentifier, 30000);
  1729. m_menuManagerInterface->AddSeparatorToMenu(EditorIdentifiers::EntityOutlinerContextMenuIdentifier, 40000);
  1730. m_menuManagerInterface->AddSeparatorToMenu(EditorIdentifiers::EntityOutlinerContextMenuIdentifier, 50000);
  1731. m_menuManagerInterface->AddSeparatorToMenu(EditorIdentifiers::EntityOutlinerContextMenuIdentifier, 60000);
  1732. m_menuManagerInterface->AddSeparatorToMenu(EditorIdentifiers::EntityOutlinerContextMenuIdentifier, 70000);
  1733. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::EntityOutlinerContextMenuIdentifier, "o3de.action.entity.rename", 70100);
  1734. m_menuManagerInterface->AddSeparatorToMenu(EditorIdentifiers::EntityOutlinerContextMenuIdentifier, 80000);
  1735. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::EntityOutlinerContextMenuIdentifier, "o3de.action.view.centerOnSelection", 80100);
  1736. // Viewport Context Menu
  1737. m_menuManagerInterface->AddSubMenuToMenu(
  1738. EditorIdentifiers::ViewportContextMenuIdentifier, EditorIdentifiers::EntityCreationMenuIdentifier, 200);
  1739. m_menuManagerInterface->AddSeparatorToMenu(EditorIdentifiers::ViewportContextMenuIdentifier, 10000);
  1740. m_menuManagerInterface->AddSeparatorToMenu(EditorIdentifiers::ViewportContextMenuIdentifier, 20000);
  1741. m_menuManagerInterface->AddSeparatorToMenu(EditorIdentifiers::ViewportContextMenuIdentifier, 30000);
  1742. m_menuManagerInterface->AddSeparatorToMenu(EditorIdentifiers::ViewportContextMenuIdentifier, 40000);
  1743. m_menuManagerInterface->AddSeparatorToMenu(EditorIdentifiers::ViewportContextMenuIdentifier, 50000);
  1744. m_menuManagerInterface->AddSeparatorToMenu(EditorIdentifiers::ViewportContextMenuIdentifier, 60000);
  1745. m_menuManagerInterface->AddSeparatorToMenu(EditorIdentifiers::ViewportContextMenuIdentifier, 70000);
  1746. m_menuManagerInterface->AddSeparatorToMenu(EditorIdentifiers::ViewportContextMenuIdentifier, 80000);
  1747. m_menuManagerInterface->AddActionToMenu(
  1748. EditorIdentifiers::ViewportContextMenuIdentifier, "o3de.action.entityOutliner.findEntity", 80100);
  1749. }
  1750. void EditorActionsHandler::OnToolBarAreaRegistrationHook()
  1751. {
  1752. m_toolBarManagerInterface->RegisterToolBarArea(
  1753. EditorIdentifiers::MainWindowTopToolBarAreaIdentifier, m_mainWindow, Qt::ToolBarArea::TopToolBarArea);
  1754. }
  1755. void EditorActionsHandler::OnToolBarRegistrationHook()
  1756. {
  1757. // Initialize ToolBars
  1758. {
  1759. AzToolsFramework::ToolBarProperties toolBarProperties;
  1760. toolBarProperties.m_name = "Tools";
  1761. m_toolBarManagerInterface->RegisterToolBar(EditorIdentifiers::ToolsToolBarIdentifier, toolBarProperties);
  1762. }
  1763. {
  1764. AzToolsFramework::ToolBarProperties toolBarProperties;
  1765. toolBarProperties.m_name = "Play Controls";
  1766. m_toolBarManagerInterface->RegisterToolBar(EditorIdentifiers::PlayControlsToolBarIdentifier, toolBarProperties);
  1767. }
  1768. }
  1769. void EditorActionsHandler::OnToolBarBindingHook()
  1770. {
  1771. // Add ToolBars to ToolBar Areas
  1772. // We space the sortkeys by 100 to allow external systems to add toolbars in-between.
  1773. m_toolBarManagerInterface->AddToolBarToToolBarArea(
  1774. EditorIdentifiers::MainWindowTopToolBarAreaIdentifier, EditorIdentifiers::ToolsToolBarIdentifier, 100);
  1775. m_toolBarManagerInterface->AddToolBarToToolBarArea(
  1776. EditorIdentifiers::MainWindowTopToolBarAreaIdentifier, EditorIdentifiers::PlayControlsToolBarIdentifier, 200);
  1777. // Add actions to each toolbar
  1778. // Play Controls
  1779. {
  1780. m_toolBarManagerInterface->AddWidgetToToolBar(EditorIdentifiers::PlayControlsToolBarIdentifier, "o3de.widgetAction.expander", 100);
  1781. m_toolBarManagerInterface->AddSeparatorToToolBar(EditorIdentifiers::PlayControlsToolBarIdentifier, 200);
  1782. m_toolBarManagerInterface->AddWidgetToToolBar(EditorIdentifiers::PlayControlsToolBarIdentifier, "o3de.widgetAction.game.playControlsLabel", 300);
  1783. m_toolBarManagerInterface->AddActionWithSubMenuToToolBar(
  1784. EditorIdentifiers::PlayControlsToolBarIdentifier, "o3de.action.game.play", EditorIdentifiers::PlayGameMenuIdentifier, 400);
  1785. m_toolBarManagerInterface->AddSeparatorToToolBar(EditorIdentifiers::PlayControlsToolBarIdentifier, 500);
  1786. m_toolBarManagerInterface->AddActionToToolBar(EditorIdentifiers::PlayControlsToolBarIdentifier, "o3de.action.game.simulate", 600);
  1787. }
  1788. }
  1789. void EditorActionsHandler::OnPostActionManagerRegistrationHook()
  1790. {
  1791. // Ensure the layouts menu is refreshed when the layouts list changes.
  1792. QObject::connect(
  1793. m_mainWindow->m_viewPaneManager, &QtViewPaneManager::savedLayoutsChanged, m_mainWindow,
  1794. [&]
  1795. {
  1796. RefreshLayoutActions();
  1797. }
  1798. );
  1799. RefreshLayoutActions();
  1800. // Ensure the tools menu and toolbar are refreshed when the viewpanes change.
  1801. QObject::connect(
  1802. m_qtViewPaneManager, &QtViewPaneManager::registeredPanesChanged, m_mainWindow,
  1803. [&]
  1804. {
  1805. RefreshToolActions();
  1806. }
  1807. );
  1808. RefreshToolActions();
  1809. // Initialize the Toolbox Macro actions
  1810. RefreshToolboxMacroActions();
  1811. }
  1812. QWidget* EditorActionsHandler::CreateExpander()
  1813. {
  1814. QWidget* expander = new QWidget(m_mainWindow);
  1815. expander->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
  1816. expander->setVisible(true);
  1817. return expander;
  1818. }
  1819. QWidget* EditorActionsHandler::CreatePlayControlsLabel()
  1820. {
  1821. QLabel* label = new QLabel(m_mainWindow);
  1822. label->setText("Play Controls");
  1823. return label;
  1824. }
  1825. QWidget* EditorActionsHandler::CreateDocsSearchWidget()
  1826. {
  1827. QWidget* containerWidget = new QWidget(m_mainWindow);
  1828. auto lineEdit = new AzQtComponents::SearchLineEdit(m_mainWindow);
  1829. QHBoxLayout* layout = new QHBoxLayout;
  1830. layout->setContentsMargins(0, 0, 0, 0);
  1831. layout->addWidget(lineEdit);
  1832. containerWidget->setLayout(layout);
  1833. containerWidget->setContentsMargins(2, 0, 2, 0);
  1834. lineEdit->setPlaceholderText(QObject::tr("Search documentation..."));
  1835. auto searchAction = [lineEdit]
  1836. {
  1837. auto text = lineEdit->text();
  1838. if (text.isEmpty())
  1839. {
  1840. QDesktopServices::openUrl(QUrl("https://www.o3de.org/docs/"));
  1841. }
  1842. else
  1843. {
  1844. QUrl docSearchUrl("https://www.o3de.org/search/");
  1845. QUrlQuery docSearchQuery;
  1846. docSearchQuery.addQueryItem("query", text);
  1847. docSearchUrl.setQuery(docSearchQuery);
  1848. QDesktopServices::openUrl(docSearchUrl);
  1849. }
  1850. lineEdit->clear();
  1851. };
  1852. QObject::connect(lineEdit, &QLineEdit::returnPressed, m_mainWindow, searchAction);
  1853. QMenu* helpMenu = m_menuManagerInternalInterface->GetMenu(EditorIdentifiers::HelpMenuIdentifier);
  1854. QObject::connect(helpMenu, &QMenu::aboutToHide, lineEdit, &QLineEdit::clear);
  1855. QObject::connect(helpMenu, &QMenu::aboutToShow, lineEdit, &QLineEdit::clearFocus);
  1856. return containerWidget;
  1857. }
  1858. void EditorActionsHandler::OnViewPaneOpened(const char* viewPaneName)
  1859. {
  1860. AZStd::string toolActionIdentifier = AZStd::string::format("o3de.action.tool.%s", viewPaneName);
  1861. m_actionManagerInterface->UpdateAction(toolActionIdentifier);
  1862. }
  1863. void EditorActionsHandler::OnViewPaneClosed(const char* viewPaneName)
  1864. {
  1865. AZStd::string toolActionIdentifier = AZStd::string::format("o3de.action.tool.%s", viewPaneName);
  1866. m_actionManagerInterface->UpdateAction(toolActionIdentifier);
  1867. }
  1868. void EditorActionsHandler::OnStartPlayInEditor()
  1869. {
  1870. m_actionManagerInterface->TriggerActionUpdater(EditorIdentifiers::GameModeStateChangedUpdaterIdentifier);
  1871. }
  1872. void EditorActionsHandler::OnStopPlayInEditor()
  1873. {
  1874. // Wait one frame for the game mode to actually be shut off.
  1875. QTimer::singleShot(
  1876. 0,
  1877. nullptr,
  1878. [actionManagerInterface = m_actionManagerInterface]
  1879. {
  1880. actionManagerInterface->TriggerActionUpdater(EditorIdentifiers::GameModeStateChangedUpdaterIdentifier);
  1881. }
  1882. );
  1883. }
  1884. void EditorActionsHandler::OnEntityStreamLoadSuccess()
  1885. {
  1886. if (!m_isPrefabSystemEnabled)
  1887. {
  1888. m_actionManagerInterface->TriggerActionUpdater(EditorIdentifiers::LevelLoadedUpdaterIdentifier);
  1889. }
  1890. }
  1891. void EditorActionsHandler::AfterEntitySelectionChanged(
  1892. [[maybe_unused]] const AzToolsFramework::EntityIdList& newlySelectedEntities,
  1893. [[maybe_unused]] const AzToolsFramework::EntityIdList& newlyDeselectedEntities)
  1894. {
  1895. m_actionManagerInterface->TriggerActionUpdater(EditorIdentifiers::EntitySelectionChangedUpdaterIdentifier);
  1896. }
  1897. void EditorActionsHandler::AfterUndoRedo()
  1898. {
  1899. // Wait one frame for the undo stack to actually be updated.
  1900. QTimer::singleShot(
  1901. 0,
  1902. nullptr,
  1903. [actionManagerInterface = m_actionManagerInterface]
  1904. {
  1905. actionManagerInterface->TriggerActionUpdater(EditorIdentifiers::UndoRedoUpdaterIdentifier);
  1906. }
  1907. );
  1908. }
  1909. void EditorActionsHandler::OnEndUndo([[maybe_unused]] const char* label, [[maybe_unused]] bool changed)
  1910. {
  1911. // Wait one frame for the undo stack to actually be updated.
  1912. QTimer::singleShot(
  1913. 0,
  1914. nullptr,
  1915. [actionManagerInterface = m_actionManagerInterface]
  1916. {
  1917. actionManagerInterface->TriggerActionUpdater(EditorIdentifiers::UndoRedoUpdaterIdentifier);
  1918. }
  1919. );
  1920. }
  1921. void EditorActionsHandler::OnAngleSnappingChanged([[maybe_unused]] bool enabled)
  1922. {
  1923. m_actionManagerInterface->TriggerActionUpdater(EditorIdentifiers::AngleSnappingStateChangedUpdaterIdentifier);
  1924. }
  1925. void EditorActionsHandler::OnDrawHelpersChanged([[maybe_unused]] bool enabled)
  1926. {
  1927. m_actionManagerInterface->TriggerActionUpdater(EditorIdentifiers::DrawHelpersStateChangedUpdaterIdentifier);
  1928. }
  1929. void EditorActionsHandler::OnGridShowingChanged([[maybe_unused]] bool showing)
  1930. {
  1931. m_actionManagerInterface->TriggerActionUpdater(EditorIdentifiers::GridShowingChangedUpdaterIdentifier);
  1932. }
  1933. void EditorActionsHandler::OnGridSnappingChanged([[maybe_unused]] bool enabled)
  1934. {
  1935. m_actionManagerInterface->TriggerActionUpdater(EditorIdentifiers::GridSnappingStateChangedUpdaterIdentifier);
  1936. }
  1937. void EditorActionsHandler::OnIconsVisibilityChanged([[maybe_unused]] bool enabled)
  1938. {
  1939. m_actionManagerInterface->TriggerActionUpdater(EditorIdentifiers::IconsStateChangedUpdaterIdentifier);
  1940. }
  1941. void EditorActionsHandler::OnEntityPickModeStarted()
  1942. {
  1943. m_actionManagerInterface->TriggerActionUpdater(EditorIdentifiers::EntityPickingModeChangedUpdaterIdentifier);
  1944. }
  1945. void EditorActionsHandler::OnEntityPickModeStopped()
  1946. {
  1947. m_actionManagerInterface->TriggerActionUpdater(EditorIdentifiers::EntityPickingModeChangedUpdaterIdentifier);
  1948. }
  1949. void EditorActionsHandler::OnContainerEntityStatusChanged([[maybe_unused]] AZ::EntityId entityId, [[maybe_unused]] bool open)
  1950. {
  1951. m_actionManagerInterface->TriggerActionUpdater(EditorIdentifiers::ContainerEntityStatesChangedUpdaterIdentifier);
  1952. }
  1953. bool EditorActionsHandler::IsRecentFileActionActive(int index)
  1954. {
  1955. return (index < m_recentFileActionsCount);
  1956. }
  1957. bool EditorActionsHandler::IsRecentFileEntryValid(const QString& entry, const QString& gameFolderPath)
  1958. {
  1959. if (entry.isEmpty())
  1960. {
  1961. return false;
  1962. }
  1963. QFileInfo info(entry);
  1964. if (!info.exists())
  1965. {
  1966. return false;
  1967. }
  1968. if (!entry.endsWith(m_levelExtension))
  1969. {
  1970. return false;
  1971. }
  1972. const QDir gameDir(gameFolderPath);
  1973. QDir dir(entry); // actually pointing at file, first cdUp() gets us the parent dir
  1974. while (dir.cdUp())
  1975. {
  1976. if (dir == gameDir)
  1977. {
  1978. return true;
  1979. }
  1980. }
  1981. return false;
  1982. }
  1983. void EditorActionsHandler::OpenLevelByRecentFileEntryIndex(int index)
  1984. {
  1985. // Out of bounds, do nothing
  1986. if (index >= m_recentFileActionsCount)
  1987. {
  1988. return;
  1989. }
  1990. RecentFileList* recentFiles = m_cryEditApp->GetRecentFileList();
  1991. const int recentFilesSize = recentFiles->GetSize();
  1992. QString sCurDir = QString(Path::GetEditingGameDataFolder().c_str()) + QDir::separator();
  1993. QFileInfo gameDir(sCurDir); // Pass it through QFileInfo so it comes out normalized
  1994. const QString gameDirPath = gameDir.absolutePath();
  1995. // Index is the index of the action in the menu, but in generating that list we skipped invalid files from other projects.
  1996. // As such, we need to actually go through the list again to find the correct index for the recentFiles array.
  1997. int counter = 0;
  1998. int fileIndex = 0;
  1999. for (; fileIndex < recentFilesSize; ++fileIndex)
  2000. {
  2001. if (!IsRecentFileEntryValid((*recentFiles)[fileIndex], gameDirPath))
  2002. {
  2003. continue;
  2004. }
  2005. if (counter == index)
  2006. {
  2007. break;
  2008. }
  2009. ++counter;
  2010. }
  2011. m_cryEditApp->OpenDocumentFile((*recentFiles)[fileIndex].toUtf8().data(), true, COpenSameLevelOptions::ReopenLevelIfSame);
  2012. }
  2013. void EditorActionsHandler::UpdateRecentFileActions()
  2014. {
  2015. RecentFileList* recentFiles = m_cryEditApp->GetRecentFileList();
  2016. const int recentFilesSize = recentFiles->GetSize();
  2017. QString sCurDir = QString(Path::GetEditingGameDataFolder().c_str()) + QDir::separator();
  2018. QFileInfo gameDir(sCurDir); // Pass it through QFileInfo so it comes out normalized
  2019. const QString gameDirPath = gameDir.absolutePath();
  2020. m_recentFileActionsCount = 0;
  2021. int index = 0;
  2022. // Update all names
  2023. for (int counter = 0; counter < maxRecentFiles; ++counter)
  2024. {
  2025. // Loop through all Recent Files Menu entries, even the hidden ones.
  2026. AZStd::string actionIdentifier = AZStd::string::format("o3de.action.file.recent.file%i", counter + 1);
  2027. // Check if the recent file at index is valid. If not, increment index until you find one, or the list ends.
  2028. while (index < recentFilesSize)
  2029. {
  2030. if (IsRecentFileEntryValid((*recentFiles)[index], gameDirPath))
  2031. {
  2032. break;
  2033. }
  2034. ++index;
  2035. }
  2036. if (index < recentFilesSize)
  2037. {
  2038. // If the index is valid, use it to populate the action's name and then increment for the next menu item.
  2039. QString displayName;
  2040. recentFiles->GetDisplayName(displayName, index, sCurDir);
  2041. m_actionManagerInterface->SetActionName(
  2042. actionIdentifier, AZStd::string::format("%i | %s", counter + 1, displayName.toUtf8().data()));
  2043. ++m_recentFileActionsCount;
  2044. ++index;
  2045. }
  2046. else
  2047. {
  2048. // If the index is invalid, give the default name for consistency.
  2049. // The menu item will not show as it will be disabled by its enabled state callback.
  2050. m_actionManagerInterface->SetActionName(actionIdentifier, AZStd::string::format("Recent File #%i", counter + 1));
  2051. }
  2052. }
  2053. // Trigger the updater
  2054. m_actionManagerInterface->TriggerActionUpdater(EditorIdentifiers::RecentFilesChangedUpdaterIdentifier);
  2055. }
  2056. void EditorActionsHandler::RefreshLayoutActions()
  2057. {
  2058. m_menuManagerInterface->RemoveSubMenusFromMenu(EditorIdentifiers::LayoutsMenuIdentifier, m_layoutMenuIdentifiers);
  2059. m_layoutMenuIdentifiers.clear();
  2060. // Place all sub-menus in the same sort index in the menu.
  2061. // This will display them in order of addition (alphabetical) and ensure no external tool can add items in-between
  2062. const int sortKey = 300;
  2063. QStringList layoutNames = m_mainWindow->m_viewPaneManager->LayoutNames();
  2064. std::sort(layoutNames.begin(), layoutNames.end(), CompareLayoutNames);
  2065. for (const auto& layoutName : layoutNames)
  2066. {
  2067. AZStd::string layoutMenuIdentifier = AZStd::string::format("o3de.menu.layout[%s]", layoutName.toUtf8().data());
  2068. // Create the menu and related actions for the layout if they do not already exist.
  2069. if (!m_menuManagerInterface->IsMenuRegistered(layoutMenuIdentifier))
  2070. {
  2071. AzToolsFramework::MenuProperties menuProperties;
  2072. menuProperties.m_name = layoutName.toUtf8().data();
  2073. m_menuManagerInterface->RegisterMenu(layoutMenuIdentifier, menuProperties);
  2074. {
  2075. AZStd::string actionIdentifier = AZStd::string::format("o3de.action.layout[%s].load", layoutName.toUtf8().data());
  2076. AzToolsFramework::ActionProperties actionProperties;
  2077. actionProperties.m_name = "Load";
  2078. actionProperties.m_description = AZStd::string::format("Load the \"%s\" layout.", layoutName.toUtf8().data());
  2079. actionProperties.m_category = "Layout";
  2080. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  2081. m_actionManagerInterface->RegisterAction(
  2082. EditorIdentifiers::MainWindowActionContextIdentifier,
  2083. actionIdentifier,
  2084. actionProperties,
  2085. [layout = layoutName, this]
  2086. {
  2087. m_mainWindow->ViewLoadPaneLayout(layout);
  2088. }
  2089. );
  2090. // This action is only accessible outside of Component Modes
  2091. m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, actionIdentifier);
  2092. m_menuManagerInterface->AddActionToMenu(layoutMenuIdentifier, actionIdentifier, 0);
  2093. }
  2094. {
  2095. AZStd::string actionIdentifier = AZStd::string::format("o3de.action.layout[%s].save", layoutName.toUtf8().data());
  2096. AzToolsFramework::ActionProperties actionProperties;
  2097. actionProperties.m_name = "Save";
  2098. actionProperties.m_description = AZStd::string::format("Save the \"%s\" layout.", layoutName.toUtf8().data());
  2099. actionProperties.m_category = "Layout";
  2100. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  2101. m_actionManagerInterface->RegisterAction(
  2102. EditorIdentifiers::MainWindowActionContextIdentifier,
  2103. actionIdentifier,
  2104. actionProperties,
  2105. [layout = layoutName, this]
  2106. {
  2107. m_mainWindow->ViewSavePaneLayout(layout);
  2108. }
  2109. );
  2110. // This action is only accessible outside of Component Modes
  2111. m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, actionIdentifier);
  2112. m_menuManagerInterface->AddActionToMenu(layoutMenuIdentifier, actionIdentifier, 100);
  2113. }
  2114. {
  2115. AZStd::string actionIdentifier = AZStd::string::format("o3de.action.layout[%s].rename", layoutName.toUtf8().data());
  2116. AzToolsFramework::ActionProperties actionProperties;
  2117. actionProperties.m_name = "Rename...";
  2118. actionProperties.m_description = AZStd::string::format("Rename the \"%s\" layout.", layoutName.toUtf8().data());
  2119. actionProperties.m_category = "Layout";
  2120. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  2121. m_actionManagerInterface->RegisterAction(
  2122. EditorIdentifiers::MainWindowActionContextIdentifier,
  2123. actionIdentifier,
  2124. actionProperties,
  2125. [layout = layoutName, this]
  2126. {
  2127. m_mainWindow->ViewRenamePaneLayout(layout);
  2128. }
  2129. );
  2130. // This action is only accessible outside of Component Modes
  2131. m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, actionIdentifier);
  2132. m_menuManagerInterface->AddActionToMenu(layoutMenuIdentifier, actionIdentifier, 200);
  2133. }
  2134. {
  2135. AZStd::string actionIdentifier = AZStd::string::format("o3de.action.layout[%s].delete", layoutName.toUtf8().data());
  2136. AzToolsFramework::ActionProperties actionProperties;
  2137. actionProperties.m_name = "Delete";
  2138. actionProperties.m_description = AZStd::string::format("Delete the \"%s\" layout.", layoutName.toUtf8().data());
  2139. actionProperties.m_category = "Layout";
  2140. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  2141. m_actionManagerInterface->RegisterAction(
  2142. EditorIdentifiers::MainWindowActionContextIdentifier,
  2143. actionIdentifier,
  2144. actionProperties,
  2145. [layout = layoutName, this]
  2146. {
  2147. m_mainWindow->ViewDeletePaneLayout(layout);
  2148. }
  2149. );
  2150. // This action is only accessible outside of Component Modes
  2151. m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, actionIdentifier);
  2152. m_menuManagerInterface->AddActionToMenu(layoutMenuIdentifier, actionIdentifier, 300);
  2153. }
  2154. }
  2155. m_layoutMenuIdentifiers.push_back(layoutMenuIdentifier);
  2156. m_menuManagerInterface->AddSubMenuToMenu(EditorIdentifiers::LayoutsMenuIdentifier, layoutMenuIdentifier, sortKey);
  2157. }
  2158. }
  2159. void EditorActionsHandler::RefreshToolboxMacroActions()
  2160. {
  2161. // If the toolbox macros are being displayed in the menu already, remove them.
  2162. m_menuManagerInterface->RemoveActionsFromMenu(EditorIdentifiers::ToolBoxMacrosMenuIdentifier, m_toolboxMacroActionIdentifiers);
  2163. m_toolboxMacroActionIdentifiers.clear();
  2164. // Place all actions in the same sort index in the menu .
  2165. // This will display them in order of addition (alphabetical).
  2166. const int sortKey = 0;
  2167. auto tools = GetIEditor()->GetToolBoxManager();
  2168. const int macroCount = tools->GetMacroCount(true);
  2169. for (int macroIndex = 0; macroIndex < macroCount; ++macroIndex)
  2170. {
  2171. auto macro = tools->GetMacro(macroIndex, true);
  2172. const int toolbarId = macro->GetToolbarId();
  2173. if (toolbarId == -1 || toolbarId == ID_TOOLS_TOOL1)
  2174. {
  2175. AZStd::string toolboxMacroActionIdentifier = AZStd::string::format("o3de.action.toolboxMacro[%s]", macro->GetTitle().toStdString().c_str());
  2176. // Create the action if it does not already exist.
  2177. if (!m_actionManagerInterface->IsActionRegistered(toolboxMacroActionIdentifier))
  2178. {
  2179. AzToolsFramework::ActionProperties actionProperties;
  2180. actionProperties.m_name = macro->GetTitle().toStdString().c_str();
  2181. actionProperties.m_category = "Toolbox Macro";
  2182. actionProperties.m_iconPath = macro->GetIconPath().toStdString().c_str();
  2183. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  2184. m_actionManagerInterface->RegisterAction(
  2185. EditorIdentifiers::MainWindowActionContextIdentifier,
  2186. toolboxMacroActionIdentifier,
  2187. actionProperties,
  2188. [macro]
  2189. {
  2190. macro->Execute();
  2191. }
  2192. );
  2193. // This action is only accessible outside of Component Modes
  2194. m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, toolboxMacroActionIdentifier);
  2195. }
  2196. m_menuManagerInterface->AddActionToMenu(EditorIdentifiers::ToolBoxMacrosMenuIdentifier, toolboxMacroActionIdentifier, sortKey);
  2197. m_toolboxMacroActionIdentifiers.push_back(AZStd::move(toolboxMacroActionIdentifier));
  2198. }
  2199. }
  2200. }
  2201. void EditorActionsHandler::RefreshToolActions()
  2202. {
  2203. // If the tools are being displayed in the menu or toolbar already, remove them.
  2204. m_menuManagerInterface->RemoveActionsFromMenu(EditorIdentifiers::ToolsMenuIdentifier, m_toolActionIdentifiers);
  2205. m_toolBarManagerInterface->RemoveActionsFromToolBar(EditorIdentifiers::ToolsToolBarIdentifier, m_toolActionIdentifiers);
  2206. m_toolActionIdentifiers.clear();
  2207. AZStd::vector<AZStd::pair<AZStd::string, int>> toolsMenuItems;
  2208. AZStd::vector<AZStd::pair<AZStd::string, int>> toolsToolBarItems;
  2209. // Get the tools list and refresh the menu.
  2210. const QtViewPanes& viewpanes = m_qtViewPaneManager->GetRegisteredPanes();
  2211. for (const auto& viewpane : viewpanes)
  2212. {
  2213. if (viewpane.IsViewportPane())
  2214. {
  2215. continue;
  2216. }
  2217. AZStd::string toolActionIdentifier = AZStd::string::format("o3de.action.tool.%s", viewpane.m_name.toUtf8().data());
  2218. // Create the action if it does not already exist.
  2219. if (!m_actionManagerInterface->IsActionRegistered(toolActionIdentifier))
  2220. {
  2221. AzToolsFramework::ActionProperties actionProperties;
  2222. actionProperties.m_name = viewpane.m_options.optionalMenuText.length() > 0 ? viewpane.m_options.optionalMenuText.toUtf8().data()
  2223. : viewpane.m_name.toUtf8().data();
  2224. actionProperties.m_category = "Tool";
  2225. actionProperties.m_iconPath = viewpane.m_options.toolbarIcon;
  2226. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  2227. actionProperties.m_toolBarVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  2228. m_actionManagerInterface->RegisterCheckableAction(
  2229. EditorIdentifiers::MainWindowActionContextIdentifier,
  2230. toolActionIdentifier,
  2231. actionProperties,
  2232. [viewpaneManager = m_qtViewPaneManager, viewpaneName = viewpane.m_name]
  2233. {
  2234. viewpaneManager->TogglePane(viewpaneName);
  2235. },
  2236. [viewpaneManager = m_qtViewPaneManager, viewpaneName = viewpane.m_name]() -> bool
  2237. {
  2238. return viewpaneManager->IsEnumeratedInstanceVisible(viewpaneName);
  2239. }
  2240. );
  2241. // This action is only accessible outside of Component Modes
  2242. m_actionManagerInterface->AssignModeToAction(AzToolsFramework::DefaultActionContextModeIdentifier, toolActionIdentifier);
  2243. }
  2244. m_toolActionIdentifiers.push_back(toolActionIdentifier);
  2245. // Set the sortKey as the ASCII of the first character in the toolName.
  2246. // This will allow Tool actions to always be sorted alphabetically even if they are
  2247. // plugged in by Gems, as long as they use this same logic.
  2248. int sortKey = m_actionManagerInterface->GenerateActionAlphabeticalSortKey(toolActionIdentifier);
  2249. if (viewpane.m_options.showInMenu)
  2250. {
  2251. toolsMenuItems.push_back({ toolActionIdentifier, sortKey });
  2252. }
  2253. if (viewpane.m_options.showOnToolsToolbar)
  2254. {
  2255. toolsToolBarItems.push_back({ toolActionIdentifier, sortKey });
  2256. }
  2257. }
  2258. m_menuManagerInterface->AddActionsToMenu(EditorIdentifiers::ToolsMenuIdentifier, toolsMenuItems);
  2259. m_toolBarManagerInterface->AddActionsToToolBar(EditorIdentifiers::ToolsToolBarIdentifier, toolsToolBarItems);
  2260. }
  2261. void EditorActionsHandler::InitializeViewBookmarkActions()
  2262. {
  2263. // --- Go to Location
  2264. for (int index = 0; index < m_defaultBookmarkCount; ++index)
  2265. {
  2266. const AZStd::string actionIdentifier = AZStd::string::format("o3de.action.view.bookmark[%i].goTo", index);
  2267. AzToolsFramework::ActionProperties actionProperties;
  2268. actionProperties.m_name = AZStd::string::format("Go to Location %i", index+1);
  2269. actionProperties.m_description = AZStd::string::format("Go to Location %i.", index+1);
  2270. actionProperties.m_category = "View Bookmark";
  2271. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  2272. auto outcome = m_actionManagerInterface->RegisterAction(
  2273. EditorIdentifiers::MainWindowActionContextIdentifier,
  2274. actionIdentifier,
  2275. actionProperties,
  2276. [index]
  2277. {
  2278. AzToolsFramework::ViewBookmarkInterface* viewBookmarkInterface = AZ::Interface<AzToolsFramework::ViewBookmarkInterface>::Get();
  2279. if (!viewBookmarkInterface)
  2280. {
  2281. AZ_Warning("Main Window", false, "Couldn't find View Bookmark Loader");
  2282. return false;
  2283. }
  2284. const AZStd::optional<AzToolsFramework::ViewBookmark> bookmark = viewBookmarkInterface->LoadBookmarkAtIndex(index);
  2285. if (!bookmark.has_value())
  2286. {
  2287. return false;
  2288. }
  2289. // Check the bookmark we want to load is not exactly 0.
  2290. if (bookmark.value().IsZero())
  2291. {
  2292. QString tagConsoleText = QObject::tr("View Bookmark %1 has not been set yet").arg(index + 1);
  2293. AZ_Warning("Main Window", false, tagConsoleText.toUtf8().data());
  2294. return false;
  2295. }
  2296. SandboxEditor::HandleDefaultViewportCameraTransitionFromSetting(
  2297. bookmark->m_position, AZ::DegToRad(bookmark->m_rotation.GetX()), AZ::DegToRad(bookmark->m_rotation.GetZ()));
  2298. QString tagConsoleText = QObject::tr("View Bookmark %1 loaded position: x=%2, y=%3, z=%4")
  2299. .arg(index + 1)
  2300. .arg(bookmark->m_position.GetX(), 0, 'f', 2)
  2301. .arg(bookmark->m_position.GetY(), 0, 'f', 2)
  2302. .arg(bookmark->m_position.GetZ(), 0, 'f', 2);
  2303. AZ_Printf("MainWindow", tagConsoleText.toUtf8().data());
  2304. return true;
  2305. }
  2306. );
  2307. m_actionManagerInterface->InstallEnabledStateCallback(actionIdentifier, IsLevelLoaded);
  2308. m_actionManagerInterface->AddActionToUpdater(EditorIdentifiers::LevelLoadedUpdaterIdentifier, actionIdentifier);
  2309. m_hotKeyManagerInterface->SetActionHotKey(actionIdentifier, AZStd::string::format("Shift+F%i", index+1));
  2310. }
  2311. // --- Save Location
  2312. for (int index = 0; index < m_defaultBookmarkCount; ++index)
  2313. {
  2314. const AZStd::string actionIdentifier = AZStd::string::format("o3de.action.view.bookmark[%i].save", index);
  2315. AzToolsFramework::ActionProperties actionProperties;
  2316. actionProperties.m_name = AZStd::string::format("Save Location %i", index+1);
  2317. actionProperties.m_description = AZStd::string::format("Save Location %i.", index+1);
  2318. actionProperties.m_category = "View Bookmark";
  2319. actionProperties.m_menuVisibility = AzToolsFramework::ActionVisibility::AlwaysShow;
  2320. m_actionManagerInterface->RegisterAction(
  2321. EditorIdentifiers::MainWindowActionContextIdentifier,
  2322. actionIdentifier,
  2323. actionProperties,
  2324. [index]
  2325. {
  2326. if (auto viewBookmark = AzToolsFramework::StoreViewBookmarkFromActiveCameraAtIndex(index); viewBookmark.has_value())
  2327. {
  2328. const QString tagConsoleText = QObject::tr("View Bookmark %1 set to the position: x=%2, y=%3, z=%4")
  2329. .arg(index + 1)
  2330. .arg(viewBookmark->m_position.GetX(), 0, 'f', 2)
  2331. .arg(viewBookmark->m_position.GetY(), 0, 'f', 2)
  2332. .arg(viewBookmark->m_position.GetZ(), 0, 'f', 2);
  2333. AZ_Printf("MainWindow", tagConsoleText.toUtf8().data());
  2334. }
  2335. }
  2336. );
  2337. m_actionManagerInterface->InstallEnabledStateCallback(actionIdentifier, IsLevelLoaded);
  2338. m_actionManagerInterface->AddActionToUpdater(EditorIdentifiers::LevelLoadedUpdaterIdentifier, actionIdentifier);
  2339. m_hotKeyManagerInterface->SetActionHotKey(actionIdentifier, AZStd::string::format("Ctrl+F%i", index+1));
  2340. }
  2341. }