#pragma once #include "Utils/Sigslot.hpp" #include "cplt_fwd.hpp" #include #include #include class GlobalStates { public: static void Init(); static void Init(std::filesystem::path userDataDir); static void Shutdown(); static GlobalStates& GetInstance(); static const std::filesystem::path& GetUserDataPath(); struct RecentProject { std::filesystem::path path; std::string cachedUtf8String; }; public: Signal<> OnModified; private: std::vector mRecentProjects; mutable bool mDirty = false; public: const std::vector& GetRecentProjects() const; void ClearRecentProjects(); void AddRecentProject(const Project& project); /// Move or add the project to end of the recent projects list. /// If the project is not in the list of recently used projects, it will be appended, otherwise /// it will be moved to the end. void MoveProjectToTop(const Project& project); void RemoveRecentProject(int idx); // TODO async autosaving to prevent data loss on crash void WriteToDisk() const; bool IsDirty() const; private: void MarkDirty(); };