CmEditorPrefs.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #pragma once
  2. #include "CmEditorPrerequisites.h"
  3. #include "CmModule.h"
  4. #include <QtCore/QString>
  5. #include "3rdParty/pugixml/pugixml.hpp"
  6. namespace CamelotEditor
  7. {
  8. struct WindowLayoutDesc
  9. {
  10. WindowLayoutDesc()
  11. :width(0), height(0), left(0), top(0),
  12. screenIdx(-1), maximized(true), docked(false)
  13. {
  14. }
  15. QString name;
  16. UINT32 width;
  17. UINT32 height;
  18. UINT32 left;
  19. UINT32 top;
  20. UINT32 screenIdx;
  21. bool maximized;
  22. bool docked;
  23. };
  24. class EditorPrefs : public CamelotEngine::Module<EditorPrefs>
  25. {
  26. public:
  27. UINT32 getNumRecentlyUsedProjects() const;
  28. const QString& getRecentlyUsedProjectPath(UINT32 idx) const;
  29. void addRecentlyUsedProjectPath(const QString& path);
  30. void removeRecentlyUsedProjectPath(UINT32 idx);
  31. void setLastUsedProjectDirectory(const QString& value);
  32. const QString& getLastUsedProjectDirectory() const;
  33. void setMainWindowLayout(const WindowLayoutDesc& desc);
  34. const WindowLayoutDesc& getMainWindowLayout() const;
  35. void save(const QString& path, bool overwrite = true) const;
  36. void load(const QString& path);
  37. private:
  38. vector<QString>::type mRecentlyUsedProjects;
  39. QString mLastUsedProjectDirectory;
  40. WindowLayoutDesc mMainWindowLayout;
  41. void saveWindowLayout(pugi::xml_node parentNode, const WindowLayoutDesc& desc) const;
  42. WindowLayoutDesc loadWindowLayout(pugi::xml_node node) const;
  43. void clear();
  44. };
  45. EditorPrefs& gEditorPrefs();
  46. }