Model.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. #pragma once
  9. #include <AzFramework/Asset/AssetCatalogBus.h>
  10. #include <Editor/View/Windows/Tools/UpgradeTool/ModelTraits.h>
  11. #include <Editor/View/Windows/Tools/UpgradeTool/Modifier.h>
  12. #include <Editor/View/Windows/Tools/UpgradeTool/Scanner.h>
  13. #include <Editor/View/Windows/Tools/UpgradeTool/VersionExplorerLog.h>
  14. #include <ScriptCanvas/Core/Core.h>
  15. struct ICVar;
  16. namespace ScriptCanvasEditor
  17. {
  18. namespace VersionExplorer
  19. {
  20. //! Scoped utility to set and restore the "ed_KeepEditorActive" CVar in order to allow
  21. //! the upgrade tool to work even if the editor is not in the foreground
  22. class EditorKeepAlive
  23. {
  24. public:
  25. EditorKeepAlive();
  26. ~EditorKeepAlive();
  27. private:
  28. int m_keepEditorActive;
  29. ICVar* m_edKeepEditorActive;
  30. };
  31. //! Handles model change requests, state queries; sends state change notifications
  32. class Model
  33. : public ModelRequestsBus::Handler
  34. {
  35. public:
  36. AZ_CLASS_ALLOCATOR(Model, AZ::SystemAllocator);
  37. Model();
  38. ~Model();
  39. const ModificationResults* GetResults() override;
  40. void Modify(const ModifyConfiguration& modification) override;
  41. void Scan(const ScanConfiguration& config) override;
  42. private:
  43. enum class State
  44. {
  45. Idle,
  46. Scanning,
  47. ModifyAll,
  48. ModifySingle
  49. };
  50. State m_state = State::Idle;
  51. Log m_log;
  52. // these two are managed by the same class because the modifier will only operate on the results of the scanner
  53. AZStd::unique_ptr<Modifier> m_modifier;
  54. AZStd::unique_ptr<Scanner> m_scanner;
  55. AZStd::unique_ptr<ScriptCanvas::Grammar::SettingsCache> m_settingsCache;
  56. AZStd::unique_ptr<EditorKeepAlive> m_keepEditorAlive;
  57. ModificationResults m_modResults;
  58. void CacheSettings();
  59. void Idle();
  60. bool IsReadyToModify() const;
  61. bool IsWorking() const;
  62. void OnModificationComplete();
  63. void OnScanComplete();
  64. void RestoreSettings();
  65. };
  66. } // namespace VersionExplorer
  67. } // namespace ScriptCanvasEditor