Elaztek Developer Hub
Blamite Game Engine - Guerilla (Library)  00461.10.28.26.0311.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  bool use_custom_tagdef_export_dir = false;
183  std::string tagdef_export_dir = "";
184  });
185 
186  /*PROJECT_SECTION(network_settings,
187  {
188  std::string update_info_url = "";
189  std::string mods_info_url = "";
190  std::string invision_api_url = "";
191  });*/
192 
193  PROJECT_SECTION(engine_settings,
194  {
195  std::string user_data_folder = "/";
196 
197  std::string default_cache = "mainmenu";
198  std::string campaign_info = "";
199  std::string startup_movie = "";
200 
201  std::string content_root = "";
202  std::string tags_dir = "tags";
203  std::string movies_dir = "bink";
204  std::string data_dir = "data";
205  std::string cache_dir = "maps";
206  std::string plugins_dir = "plugins";
207  std::string fonts_dir = "maps/fonts";
208 
209  bool allow_user_tag_overrides = false;
210  bool allow_release_debug_tools = false;
211  bool allow_release_console = false;
212  });
213 
214  BlamProjectUserConfig* project_info_user = nullptr;
215  BlamTagTreeNode* hierarchy_root = nullptr;
216 
222  BlamProject(std::string file_path);
223  BlamProject();
224  ~BlamProject();
225 
226  bool LoadFromDisk(std::string file_path);
227  bool Save();
228  bool IsLoaded();
229 
233  bool BuildTagHierarchy();
234 
235  std::string GetContentRoot();
236  std::string GetTagsRoot();
237  std::string GetMoviesRoot();
238  std::string GetDataRoot();
239  std::string GetCacheRoot();
240  std::string GetPluginsRoot();
241  std::string GetFontsRoot();
242 
243  std::string GetVcxprojPath();
244  std::string GetMSBuildPath();
245  std::string GetEngineDependenciesPath();
246  std::string GetExportedTagdefsRoot();
247 
248  BlamProjectInfo GetProjectInfoForEngine();
249 
250  std::string GetTagFilePathFromTagPath(std::string tag_path);
251  BlamTagTreeNode* GetHierarchyNodeFromTagPath(std::string tag_path);
252 
253  /*std::string GetVcxprojPath()
254  {
255  if ((cpp_script_info.vcxproj_path.length() >= 2 && cpp_script_info.vcxproj_path[1] == ':') || cpp_script_info.vcxproj_path.starts_with("\\\\"))
256  {
257  return cpp_script_info.vcxproj_path;
258  }
259 
260  return project_root + "/" + cpp_script_info.vcxproj_path;
261  }*/
262 };
263 
268 {
271 
279  GUERILLA_LIB_API BlamProject* LoadProject(std::string file_path);
280 
281  GUERILLA_LIB_API BlamProject* CreateProject(std::string name);
282 
288 
293 
299  GUERILLA_LIB_API std::vector<BlamProject*> GetLoadedProjects();
300 
301  GUERILLA_LIB_API std::string GetProjectsRoot();
302 }
BlamProject::GetCacheRoot
std::string GetCacheRoot()
Definition: BlamProject.cpp:258
BlamProject::GetContentRoot
std::string GetContentRoot()
Definition: BlamProject.cpp:210
BlamProject::LoadFromDisk
bool LoadFromDisk(std::string file_path)
Definition: BlamProject.cpp:29
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:214
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:25
BlamProject::GetMSBuildPath
std::string GetMSBuildPath()
Definition: BlamProject.cpp:304
BlamProject::GetTagsRoot
std::string GetTagsRoot()
Definition: BlamProject.cpp:222
BlamProject
Class representing a Blamite Project.
Definition: projects.h:145
BlamProject::Save
bool Save()
Definition: BlamProject.cpp:87
tags.h
BlamProject::format_version
int format_version
Definition: projects.h:155
BlamProject::GetExportedTagdefsRoot
std::string GetExportedTagdefsRoot()
Definition: BlamProject.cpp:324
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:120
Guerilla::Projects::GetLoadedProjects
GUERILLA_LIB_API std::vector< BlamProject * > GetLoadedProjects()
Retrieves the list of loaded projects.
Definition: projects.cpp:115
active_project
BlamProject * active_project
Definition: projects.cpp:12
render_model_report_type::comment
@ comment
BlamProject::GetEngineDependenciesPath
std::string GetEngineDependenciesPath()
Definition: BlamProject.cpp:314
BlamProject::GetDataRoot
std::string GetDataRoot()
Definition: BlamProject.cpp:246
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:270
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:267
Guerilla::Projects::SetCurrentProject
GUERILLA_LIB_API void SetCurrentProject(BlamProject *project)
Definition: projects.cpp:19
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:511
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:215
plugins
std::vector< BlamPlugin * > plugins
The list of loaded plugins.
Definition: plugins.cpp:10
BlamTagTreeNode::~BlamTagTreeNode
~BlamTagTreeNode()
Destroys a tag tree node.
Definition: BlamTagTreeNode.cpp:79
BlamProject::GetFontsRoot
std::string GetFontsRoot()
Definition: BlamProject.cpp:282
Guerilla::Tags::GetPluginList
GUERILLA_LIB_API std::vector< BlamPlugin * > GetPluginList()
Retrieves the list of loaded plugins.
Definition: plugins.cpp:150
BlamProject::BlamProject
BlamProject()
Definition: BlamProject.cpp:18
BlamProject::GetMoviesRoot
std::string GetMoviesRoot()
Definition: BlamProject.cpp:234
Guerilla::Projects::GetProjectsRoot
GUERILLA_LIB_API std::string GetProjectsRoot()
Definition: projects.cpp:140
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:182
BlamProject::IsLoaded
bool IsLoaded()
Definition: BlamProject.cpp:177
Guerilla::Projects::UnloadProjects
GUERILLA_LIB_API void UnloadProjects()
Releases all project data loaded into memory.
Definition: projects.cpp:105
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:523
loaded_projects
std::vector< BlamProject * > loaded_projects
Definition: projects.cpp:11
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:471
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:294
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:42
BlamProject::~BlamProject
~BlamProject()
Definition: BlamProject.cpp:23
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:14
BlamTagTreeNode::GetBulkNodeList
std::vector< BlamTagTreeNode * > GetBulkNodeList()
Retrieves a bulk list of all tag nodes within this node.
Definition: BlamTagTreeNode.cpp:146