ErrorReport.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. // Description : Class that collects error reports to present them later.
  9. #ifndef CRYINCLUDE_EDITOR_ERRORREPORT_H
  10. #define CRYINCLUDE_EDITOR_ERRORREPORT_H
  11. #pragma once
  12. // forward declarations.
  13. class CParticleItem;
  14. #include "Include/EditorCoreAPI.h"
  15. #include "Include/IErrorReport.h"
  16. #include "ErrorRecorder.h"
  17. /*! Single error entry in error report.
  18. */
  19. class CErrorRecord
  20. {
  21. public:
  22. enum ESeverity
  23. {
  24. ESEVERITY_ERROR,
  25. ESEVERITY_WARNING,
  26. ESEVERITY_COMMENT
  27. };
  28. enum EFlags
  29. {
  30. FLAG_NOFILE = 0x0001, // Indicate that required file was not found.
  31. FLAG_SCRIPT = 0x0002, // Error with scripts.
  32. FLAG_TEXTURE = 0x0004, // Error with scripts.
  33. FLAG_OBJECTID = 0x0008, // Error with object Ids, Unresolved/Duplicate etc...
  34. FLAG_AI = 0x0010, // Error with AI.
  35. };
  36. //! Severety of this error.
  37. ESeverity severity;
  38. //! Module of error.
  39. EValidatorModule module;
  40. //! Error Text.
  41. QString error;
  42. //! File which is missing or causing problem.
  43. QString file;
  44. //! More detailed description for this error.
  45. QString description;
  46. // Asset dependencies
  47. QString assetScope;
  48. int count;
  49. //! Object that caused this error.
  50. int flags;
  51. CErrorRecord()
  52. {
  53. severity = ESEVERITY_WARNING;
  54. module = VALIDATOR_MODULE_EDITOR;
  55. flags = 0;
  56. count = 0;
  57. }
  58. QString GetErrorText() const;
  59. };
  60. /*! Error report manages collection of errors occured duruing map analyzes or level load.
  61. */
  62. class CErrorReport
  63. : public IErrorReport
  64. {
  65. public:
  66. CErrorReport();
  67. //! If enabled errors are reported immidiatly and not stored.
  68. void SetImmediateMode(bool bEnable);
  69. bool IsImmediateMode() const { return m_bImmediateMode; };
  70. void SetShowErrors(bool bShowErrors = true) { m_bShowErrors = bShowErrors; };
  71. //! Adds new error to report.
  72. void ReportError(CErrorRecord& err);
  73. //! Check if error report have any errors.
  74. bool IsEmpty() const;
  75. //! Get number of contained error records.
  76. int GetErrorCount() const { return static_cast<int>(m_errors.size()); };
  77. //! Get access to indexed error record.
  78. CErrorRecord& GetError(int i);
  79. //! Clear all error records.
  80. void Clear();
  81. //! Display dialog with all errors.
  82. void Display();
  83. //! Assign current filename.
  84. void SetCurrentFile(const QString& file);
  85. private:
  86. //! Array of all error records added to report.
  87. std::vector<CErrorRecord> m_errors;
  88. bool m_bImmediateMode;
  89. bool m_bShowErrors;
  90. CParticleItem* m_pParticle;
  91. QString m_currentFilename;
  92. };
  93. #endif // CRYINCLUDE_EDITOR_ERRORREPORT_H