/******************************************************************************
*	File		-	project.h
*	Author		-	Joey Pollack
*	Date		-	2021/11/09 (y/m/d)
*	Mod Date	-	2021/11/09 (y/m/d)
*	Description	-	Manage data for a game project
******************************************************************************/

#ifndef PROJECT_H_
#define PROJECT_H_

#include <utils/op_res.h>

#include <string>
#include <vector>
#include <filesystem>

namespace lunarium { namespace editor 
{
    class ContentManager;
    class World;

    class Project
    {
    public:
        Project();

        /// location should NOT include the project file
        [[nodiscard]] OpRes GenerateProject(std::string name, std::filesystem::path location);

        /// location should be the full path including the project file
        [[nodiscard]] OpRes LoadProject(std::filesystem::path location);
        void UnloadCurrentProject();
        void SaveProject();

        bool IsLoaded() const;
        const std::string& GetName() const;
        std::filesystem::path GetRootDirectory() const;
        std::filesystem::path GetContentDirectory() const;
        std::filesystem::path GetAssetDirectory() const;

        // Convert an absolute path to a path relative to the project root
        std::filesystem::path MakeRelativeToRoot(std::filesystem::path, bool include_root = false) const;
        std::filesystem::path MakeRelativeToAssets(std::filesystem::path, bool include_root = false) const;

    private:
        bool mIsLoaded;
        std::string mName;
        std::filesystem::path mLocation;

        ContentManager* mpContentManager;
        std::vector<World*> mWorlds;

    private:
        void LoadContent();
        std::filesystem::path MakeRelativeTo(std::filesystem::path p, std::filesystem::path rel_to, bool include_root) const;
    };
}}

#endif  // PROJECT_H_