Elaztek Developer Hub
Blamite Game Engine - Guerilla (Library)  00449.01.12.26.0555.blamite
The tag editor for the Blamite Game Engine.
projects.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include <blam/api/v1/types/project_info.h>
5 
6 #ifdef GUERILLA_LIB_EXPORTS
7 #define GUERILLA_LIB_API __declspec(dllexport)
8 #else
9 #define GUERILLA_LIB_API __declspec(dllimport)
10 #endif
11 
12 class BlamProject;
13 
14 // The file extension for any Blamite project file.
15 #define PROJECT_FILE_EXTENSION ".blam"
16 
17 // The suffix used for user-specific project configuration settings.
18 #define PROJECT_FILE_USER_SUFFIX ".user"
19 
20 // The name of the directory used to store Blamite projects. This folder will always be placed with the engine user data folder.
21 #define BLAM_PROJECTS_DIR "Projects"
22 
31 #define PROJECT_SECTION(name, fields) struct name##_data fields; name##_data name = name##_data();
32 
41 #define PROJECT_FILE_FORMAT_VERSION 1
42 
53 {
54 private:
58  void ClearChildren();
59 
70  std::vector<BlamTagTreeNode*> GetTagsWithinNode(BlamTagTreeNode* node);
71 
72 public:
73  bool is_folder = false;
74  bool path_exists = false;
75 
76  BlamProject* project = nullptr;
77  BlamTagTreeNode* parent = nullptr;
78  std::vector<BlamTagTreeNode*> children;
79 
80  std::string hierarchy_path = "";
81  std::string disk_path = "";
82  std::string display_name = "";
83  std::string class_name_short = "";
84 
93  BlamTagTreeNode(BlamProject* _project, std::string file_path, bool ignore_folder_name_in_hierarchy, BlamTagTreeNode* parent = nullptr);
94 
98  ~BlamTagTreeNode();
99 
103  void Refresh();
104 
113  std::vector<BlamTagTreeNode*> GetBulkNodeList();
114 };
115 
117 {
118 private:
119  bool loaded = false;
120  BlamProject* project = nullptr;
121 
122 public:
124 
125  PROJECT_SECTION(cpp_script_info,
126  {
127  std::string vcxproj_path = "";
128  std::string engine_dependencies_path = "";
129  std::string msbuild_path = "msbuild.exe";
130  });
131 
132  bool Load(std::string file_path);
133  bool IsLoaded();
134 
135  bool Save();
136 };
137 
146 {
147 private:
148  bool load_result = false;
149 
150  void ValidateProjectFolders();
151  bool PopulateProjectInfo(rapidxml::xml_node<>* root_node);
152 
153 public:
154  std::string file_path = "";
155  int format_version = 0;
156  std::string project_name = "unnamed";
157  std::string project_root = "";
158 
159  PROJECT_SECTION(game_info,
160  {
161  std::string title = "core";
162  std::string codename = "core";
163  std::string publisher = "Elaztek Studios";
164  std::string developer = "Elaztek Studios";
165  std::string affiliates = "";
166  std::string copyright = "Copyright (c) Elaztek Studios 2013-2023";
167  std::string website = "https://elaztek.com/";
168  std::string version = "";
169  std::string icon = "";
170  });
171 
172  PROJECT_SECTION(cpp_script_info,
173  {
174  bool uses_cpp_script = false;
175  std::string vcxproj_path = "";
176  std::string engine_dependencies_path = "";
177  std::string msbuild_path = "msbuild.exe";
178  std::string msbuild_extra_args = "";
179  std::string pre_build_commands = "";
180  std::string post_build_commands = "";
181  });
182 
183  /*PROJECT_SECTION(network_settings,
184  {
185  std::string update_info_url = "";
186  std::string mods_info_url = "";
187  std::string invision_api_url = "";
188  });*/
189 
190  PROJECT_SECTION(engine_settings,
191  {
192  std::string user_data_folder = "/";
193 
194  std::string default_cache = "mainmenu";
195  std::string campaign_info = "";
196  std::string startup_movie = "";
197 
198  std::string content_root = "";
199  std::string tags_dir = "tags";
200  std::string movies_dir = "bink";
201  std::string data_dir = "data";
202  std::string cache_dir = "maps";
203  std::string plugins_dir = "plugins";
204  std::string fonts_dir = "maps/fonts";
205 
206  bool allow_user_tag_overrides = false;
207  bool allow_release_debug_tools = false;
208  bool allow_release_console = false;
209  });
210 
211  BlamProjectUserConfig* project_info_user = nullptr;
212  BlamTagTreeNode* hierarchy_root = nullptr;
213 
219  BlamProject(std::string file_path);
220  BlamProject();
221  ~BlamProject();
222 
223  bool LoadFromDisk(std::string file_path);
224  bool Save();
225  bool IsLoaded();
226 
230  bool BuildTagHierarchy();
231 
232  std::string GetContentRoot();
233  std::string GetTagsRoot();
234  std::string GetMoviesRoot();
235  std::string GetDataRoot();
236  std::string GetCacheRoot();
237  std::string GetPluginsRoot();
238  std::string GetFontsRoot();
239 
240  std::string GetVcxprojPath();
241  std::string GetMSBuildPath();
242  std::string GetEngineDependenciesPath();
243 
244  BlamProjectInfo GetProjectInfoForEngine();
245 
246  std::string GetTagFilePathFromTagPath(std::string tag_path);
247  BlamTagTreeNode* GetHierarchyNodeFromTagPath(std::string tag_path);
248 
249  /*std::string GetVcxprojPath()
250  {
251  if ((cpp_script_info.vcxproj_path.length() >= 2 && cpp_script_info.vcxproj_path[1] == ':') || cpp_script_info.vcxproj_path.starts_with("\\\\"))
252  {
253  return cpp_script_info.vcxproj_path;
254  }
255 
256  return project_root + "/" + cpp_script_info.vcxproj_path;
257  }*/
258 };
259 
264 {
267 
275  GUERILLA_LIB_API BlamProject* LoadProject(std::string file_path);
276 
277  GUERILLA_LIB_API BlamProject* CreateProject(std::string name);
278 
284 
289 
295  GUERILLA_LIB_API std::vector<BlamProject*> GetLoadedProjects();
296 
297  GUERILLA_LIB_API std::string GetProjectsRoot();
298 }
BlamProject::GetCacheRoot
std::string GetCacheRoot()
Definition: BlamProject.cpp:247
BlamProject::GetContentRoot
std::string GetContentRoot()
Definition: BlamProject.cpp:199
BlamProject::LoadFromDisk
bool LoadFromDisk(std::string file_path)
Definition: BlamProject.cpp:27
BlamDatarefValueHintType::C
@ C
C Code.
BlamTagTreeNode::disk_path
std::string disk_path
The path of this node on disk, relative or absolute, ex: ./tags/levels/multi/forge_halo
Definition: projects.h:81
BlamProject::project_info_user
BlamProjectUserConfig * project_info_user
Definition: projects.h:211
BlamTagTreeNode::children
std::vector< BlamTagTreeNode * > children
Any child nodes within this node, will only apply for Folder nodes.
Definition: projects.h:78
Guerilla::Projects::LoadProject
GUERILLA_LIB_API BlamProject * LoadProject(std::string file_path)
Loads a project file from disk and prepares it for use.
Definition: projects.cpp:23
BlamProject::GetMSBuildPath
std::string GetMSBuildPath()
Definition: BlamProject.cpp:293
BlamProject::GetTagsRoot
std::string GetTagsRoot()
Definition: BlamProject.cpp:211
BlamProject
Class representing a Blamite Project.
Definition: projects.h:145
BlamProject::Save
bool Save()
Definition: BlamProject.cpp:85
tags.h
BlamProject::format_version
int format_version
Definition: projects.h:155
BlamTagTreeNode::BlamTagTreeNode
BlamTagTreeNode(BlamProject *_project, std::string file_path, bool ignore_folder_name_in_hierarchy, BlamTagTreeNode *parent=nullptr)
Constructs a new tag tree node.
Definition: BlamTagTreeNode.cpp:8
Guerilla::Projects::CreateProject
GUERILLA_LIB_API BlamProject * CreateProject(std::string name)
Definition: projects.cpp:98
Guerilla::Projects::GetLoadedProjects
GUERILLA_LIB_API std::vector< BlamProject * > GetLoadedProjects()
Retrieves the list of loaded projects.
Definition: projects.cpp:93
active_project
BlamProject * active_project
Definition: projects.cpp:11
render_model_report_type::comment
@ comment
BlamProject::GetEngineDependenciesPath
std::string GetEngineDependenciesPath()
Definition: BlamProject.cpp:303
BlamProject::GetDataRoot
std::string GetDataRoot()
Definition: BlamProject.cpp:235
BlamTagTreeNode::class_name_short
std::string class_name_short
The plugin/tag class this tag uses. Will be nullptr if the node is a directory or if the tag has no p...
Definition: projects.h:83
BlamTagTreeNode::path_exists
bool path_exists
Whether or not the path associated with this node exists.
Definition: projects.h:74
BlamProject::GetPluginsRoot
std::string GetPluginsRoot()
Definition: BlamProject.cpp:259
BlamTagTreeNode::Refresh
void Refresh()
Refreshes the node for any changes to its children on disk.
Definition: BlamTagTreeNode.cpp:84
GUERILLA_LIB_API
#define GUERILLA_LIB_API
Definition: projects.h:9
Guerilla::Projects
Namespace containing functions for working with project files.
Definition: projects.h:263
Guerilla::Projects::SetCurrentProject
GUERILLA_LIB_API void SetCurrentProject(BlamProject *project)
Definition: projects.cpp:18
BlamTagTreeNode::display_name
std::string display_name
The display name of this node, ex: forge_halo
Definition: projects.h:82
BlamProjectUserConfig::Load
bool Load(std::string file_path)
Definition: BlamProjectUserConfig.cpp:13
BlamProject::GetTagFilePathFromTagPath
std::string GetTagFilePathFromTagPath(std::string tag_path)
Definition: BlamProject.cpp:471
BlamProjectUserConfig::PROJECT_SECTION
PROJECT_SECTION(cpp_script_info, { std::string vcxproj_path="";std::string engine_dependencies_path="";std::string msbuild_path="msbuild.exe";})
BlamProject::hierarchy_root
BlamTagTreeNode * hierarchy_root
The root node for the project's tag hierarchy.
Definition: projects.h:212
plugins
std::vector< BlamPlugin * > plugins
The list of loaded plugins.
Definition: plugins.cpp:9
BlamTagTreeNode::~BlamTagTreeNode
~BlamTagTreeNode()
Destroys a tag tree node.
Definition: BlamTagTreeNode.cpp:79
BlamProject::GetFontsRoot
std::string GetFontsRoot()
Definition: BlamProject.cpp:271
Guerilla::Tags::GetPluginList
GUERILLA_LIB_API std::vector< BlamPlugin * > GetPluginList()
Retrieves the list of loaded plugins.
Definition: plugins.cpp:132
BlamProject::BlamProject
BlamProject()
Definition: BlamProject.cpp:16
BlamProject::GetMoviesRoot
std::string GetMoviesRoot()
Definition: BlamProject.cpp:223
Guerilla::Projects::GetProjectsRoot
GUERILLA_LIB_API std::string GetProjectsRoot()
Definition: projects.cpp:118
PROJECT_FILE_FORMAT_VERSION
#define PROJECT_FILE_FORMAT_VERSION
The current project file format version.
Definition: projects.h:41
BlamTagTreeNode::is_folder
bool is_folder
Indicates whether the node represents a file. If this is false, then the node represents a file.
Definition: projects.h:73
BlamProject::BuildTagHierarchy
bool BuildTagHierarchy()
Builds the tag hierarchy for the project.
Definition: BlamProject.cpp:178
BlamProject::IsLoaded
bool IsLoaded()
Definition: BlamProject.cpp:173
Guerilla::Projects::UnloadProjects
GUERILLA_LIB_API void UnloadProjects()
Releases all project data loaded into memory.
Definition: projects.cpp:83
BlamProjectUserConfig::IsLoaded
bool IsLoaded()
Definition: BlamProjectUserConfig.cpp:57
BlamTagTreeNode::project
BlamProject * project
The project this node belongs to.
Definition: projects.h:76
BlamProject::project_root
std::string project_root
The root folder for the project.
Definition: projects.h:157
BlamProject::GetHierarchyNodeFromTagPath
BlamTagTreeNode * GetHierarchyNodeFromTagPath(std::string tag_path)
Definition: BlamProject.cpp:483
loaded_projects
std::vector< BlamProject * > loaded_projects
Definition: projects.cpp:10
BlamProject::project_name
std::string project_name
The name of the project.
Definition: projects.h:156
BlamTagTreeNode::parent
BlamTagTreeNode * parent
The parent node of this node. If this item is the root node, then this will be nullptr.
Definition: projects.h:77
BlamProject::GetProjectInfoForEngine
BlamProjectInfo GetProjectInfoForEngine()
Definition: BlamProject.cpp:439
BlamTagTreeNode::hierarchy_path
std::string hierarchy_path
The path of this node within the hierarchy, ex: /levels/multi/forge_halo
Definition: projects.h:80
projects.h
BlamProject::file_path
std::string file_path
Definition: projects.h:154
PROJECT_FILE_USER_SUFFIX
#define PROJECT_FILE_USER_SUFFIX
Definition: projects.h:18
PROJECT_FILE_EXTENSION
#define PROJECT_FILE_EXTENSION
Definition: projects.h:15
BlamProjectUserConfig::Save
bool Save()
Definition: BlamProjectUserConfig.cpp:62
config.h
PROJECT_SECTION
#define PROJECT_SECTION(name, fields)
Macro used to aid in the creation of BlamProjectInfo sections.
Definition: projects.h:31
BlamTagTreeNode
Class representing a tag tree node.
Definition: projects.h:52
BlamProject::GetVcxprojPath
std::string GetVcxprojPath()
Definition: BlamProject.cpp:283
BLAM_PROJECTS_DIR
#define BLAM_PROJECTS_DIR
Definition: projects.h:21
Guerilla::Projects::LoadProjects
GUERILLA_LIB_API void LoadProjects()
Attempts to load all available project folders.
Definition: projects.cpp:40
BlamProject::~BlamProject
~BlamProject()
Definition: BlamProject.cpp:21
BlamProjectUserConfig::BlamProjectUserConfig
BlamProjectUserConfig(BlamProject *_project)
Definition: BlamProjectUserConfig.cpp:8
BlamProjectUserConfig
Definition: projects.h:116
Guerilla::Projects::GetCurrentProject
GUERILLA_LIB_API BlamProject * GetCurrentProject()
Definition: projects.cpp:13
BlamTagTreeNode::GetBulkNodeList
std::vector< BlamTagTreeNode * > GetBulkNodeList()
Retrieves a bulk list of all tag nodes within this node.
Definition: BlamTagTreeNode.cpp:146