Polyphase Game Engine
Loading...
Searching...
No Matches
TemplateManager.h
Go to the documentation of this file.
1#pragma once
2
3#if EDITOR
4
5#include "TemplateData.h"
6#include <string>
7#include <vector>
8
15class TemplateManager
16{
17public:
18 static void Create();
19 static void Destroy();
20 static TemplateManager* Get();
21
23 std::string GetTemplatesDirectory();
24
26 std::string GetSettingsPath();
27
29 void LoadTemplates();
30
32 void SaveTemplates();
33
35 bool AddTemplateFromZip(const std::string& zipPath, std::string& outError);
36
38 bool AddTemplateFromGitHub(const std::string& gitHubUrl, std::string& outError);
39
41 bool RemoveTemplate(const std::string& templateId);
42
44 const std::vector<Template>& GetTemplates() const { return mTemplates; }
45
47 const Template* FindTemplate(const std::string& templateId) const;
48
50 bool CreateProjectFromTemplate(const std::string& templateId,
51 const std::string& projectPath,
52 const std::string& projectName,
53 std::string& outError);
54
55private:
56 static TemplateManager* sInstance;
57 TemplateManager();
58 ~TemplateManager();
59
61 void EnsureTemplatesDirectory();
62
64 void ScanTemplatesDirectory();
65
67 bool LoadTemplateMetadata(const std::string& templateDir, Template& outTemplate);
68
70 bool DownloadFile(const std::string& url, const std::string& destPath, std::string& outError);
71
73 bool ExtractZip(const std::string& zipPath, const std::string& destDir, std::string& outError);
74
76 std::string ConvertGitHubUrlToDownloadUrl(const std::string& gitHubUrl);
77
78 std::vector<Template> mTemplates;
79};
80
81#endif