AssetImporterWindow.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. #pragma once
  2. /*
  3. * Copyright (c) Contributors to the Open 3D Engine Project.
  4. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  5. *
  6. * SPDX-License-Identifier: Apache-2.0 OR MIT
  7. *
  8. */
  9. /////////////////////////////////////////////////////////////////////////////
  10. //
  11. // Asset Importer Qt Interface
  12. //
  13. /////////////////////////////////////////////////////////////////////////////
  14. #if !defined(Q_MOC_RUN)
  15. #include <AzCore/Math/Guid.h>
  16. #include <AzCore/PlatformIncl.h>
  17. #include <AzCore/std/smart_ptr/shared_ptr.h>
  18. #include <SceneAPI/SceneUI/CommonWidgets/OverlayWidget.h>
  19. #include <SceneAPI/SceneUI/CommonWidgets/SceneSettingsCard.h>
  20. #include <QFileSystemWatcher>
  21. #include <QMainWindow>
  22. #endif
  23. namespace AzQtComponents
  24. {
  25. class Card;
  26. }
  27. namespace AZStd
  28. {
  29. class thread;
  30. }
  31. namespace Ui
  32. {
  33. class AssetImporterWindow;
  34. }
  35. namespace AZ
  36. {
  37. class Module;
  38. namespace SceneAPI
  39. {
  40. namespace Containers
  41. {
  42. class Scene;
  43. }
  44. namespace DataTypes
  45. {
  46. class IScriptProcessorRule;
  47. }
  48. }
  49. }
  50. class AssetImporterDocument;
  51. class ImporterRootDisplayWidget;
  52. class QCloseEvent;
  53. class QMenu;
  54. class QAction;
  55. class QVBoxLayout;
  56. class QScrollArea;
  57. class AssetImporterWindow
  58. : public QMainWindow
  59. {
  60. Q_OBJECT
  61. public:
  62. AssetImporterWindow();
  63. explicit AssetImporterWindow(QWidget* parent);
  64. ~AssetImporterWindow();
  65. // This implementation is required for unregister/register on "RegisterQtViewPane"
  66. static const GUID& GetClassID()
  67. {
  68. // {c50c09d6-5bfa-4d49-8542-e350656ed1bc}
  69. static const GUID guid = {
  70. 0xc50c09d6, 0x5bfa, 0x4d49, { 0x85, 0x42, 0xe3, 0x50, 0x65, 0x6e, 0xd1, 0xbc }
  71. };
  72. return guid;
  73. }
  74. void OpenFile(const AZStd::string& filePath);
  75. bool CanClose();
  76. public slots:
  77. void OnClearUnsavedChangesRequested();
  78. void OnSceneResetRequested();
  79. void OnAssignScript();
  80. void OnInspect();
  81. void SceneSettingsCardDestroyed();
  82. void SceneSettingsCardProcessingCompleted();
  83. private:
  84. void Init();
  85. void OpenFileInternal(const AZStd::string& filePath);
  86. bool IsAllowedToChangeSourceFile();
  87. bool ShouldSaveBeforeClose();
  88. void HandleAssetLoadingCompleted();
  89. SceneSettingsCard* CreateSceneSettingsCard(
  90. QString fileName,
  91. SceneSettingsCard::Layout layout,
  92. SceneSettingsCard::State state);
  93. /// Reloads the currently loaded scene.
  94. /// warnUser: if true, always warns the user this operation is occuring. If false, only warn if there's a problem.
  95. void ReloadCurrentScene(bool warnUser);
  96. private slots:
  97. void SaveClicked();
  98. void OverlayLayerAdded();
  99. void OverlayLayerRemoved();
  100. void UpdateDefaultSceneDisplay();
  101. void UpdateSceneDisplay(const AZStd::shared_ptr<AZ::SceneAPI::Containers::Scene> scene = {}) const;
  102. void FileChanged(QString path);
  103. private:
  104. static const AZ::Uuid s_browseTag;
  105. static const char* s_documentationWebAddress;
  106. QScopedPointer<Ui::AssetImporterWindow> ui;
  107. QScopedPointer<AssetImporterDocument> m_assetImporterDocument;
  108. QScopedPointer<AZ::SceneAPI::UI::OverlayWidget> m_overlay;
  109. int m_openSceneSettingsCards = 0;
  110. int m_sceneSettingsCardOverlay = AZ::SceneAPI::UI::OverlayWidget::s_invalidOverlayIndex;
  111. // Monitor the scene file, and scene settings file in case they are changed outside the scene settings tool.
  112. QFileSystemWatcher m_qtFileWatcher;
  113. AZ::SerializeContext* m_serializeContext;
  114. AZStd::string m_fullSourcePath;
  115. QScopedPointer<ImporterRootDisplayWidget> m_rootDisplay;
  116. bool m_isClosed;
  117. bool m_isSaving = false;
  118. AZStd::string m_scriptProcessorRuleFilename;
  119. };