Blamite Game Engine - blam!  00263.10.17.20.0001.blamite
The core library for the Blamite Game Engine.
tagclass.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 #include <vector>
5 #include <Windows.h>
6 
10 #include "components/3rdparty/imgui/imgui.h"
11 #include "fields.h"
12 
13 #ifndef BLAM
14 #define BLAM
15 #endif
16 
17 namespace Blam::Content::Tags
18 {
30  class TagClass
31  {
32  public:
33  std::string class_name_long;
34  std::string class_name_short;
35 
36  std::vector<TagField*> fields;
37 
38  int tag_size;
39 
40  void* tag_address;
41 
48  {
49  for (int i = 0; i < fields.size(); i++)
50  {
51  fields.at(i)->ShowImPropertyControl();
52  }
53  }
54 
60  void SetMemoryLocation(void* address)
61  {
62  tag_address = address;
63 
64  void* next_address = address;
65 
66  for (int i = 0; i < fields.size(); i++)
67  {
68  fields[i]->SetMemoryLocation(next_address);
69 
70  next_address = (char*)next_address + fields[i]->read_length;
71  }
72  }
73 
78  {
79  std::string plugin_xml_content = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
80 
81  int field_offset = 0;
82 
83  plugin_xml_content += "<plugin game=\"blamite\" longName=\"" + class_name_long + "\" engineVersion=\"" + Blam::EngineDefs::GetVersion() + "\" baseSize=\"" + std::to_string(tag_size) + "\">";
84 
85  plugin_xml_content += "<!-- Automatically generated plugin -->";
86 
87  plugin_xml_content += "<revisions>";
88 
89  plugin_xml_content += "<revision author=\"Blamite Game Engine\" version=\"1\">Generated plugin at runtime through usage of -autogenplugins flag</revision>";
90  plugin_xml_content += "</revisions>";
91 
92  for (int i = 0; i < fields.size(); i++)
93  {
94  plugin_xml_content += fields.at(i)->GetFieldXMLString(field_offset);
95  field_offset += fields.at(i)->read_length;
96  }
97 
98  plugin_xml_content += "</plugin>";
99 
100  Blam::Utils::IO::CreateNewFile(Blam::Config::GetConfig()->GetString("plugins_dir") + "./" + class_name_short + ".xml", plugin_xml_content);
101  }
102  };
103 
107  BLAM void LoadDefaultClasses();
108 
116  BLAM TagClass* GetTagClass(std::string id);
117 
123  BLAM std::vector<TagClass*>* GetRegisteredTagClasses();
124 
130  BLAM void RegisterTagClass(TagClass* data);
131 
137  BLAM void GenerateAllPlugins(bool require_switch);
138 }
139 
143 namespace BlamTagClass
144 {
151 }
Blam::Content::Tags
Namespace containing things related to tag data.
Definition: bitmap.h:9
Blam::Content::Tags::RegisterTagClass
BLAM void RegisterTagClass(TagClass *data)
Registers a new tag class within the engine.
Definition: tagclass.cpp:67
Blam::Content::Tags::LoadDefaultClasses
BLAM void LoadDefaultClasses()
Loads all built-in tag classes available to the engine.
Definition: tagclass.cpp:106
Blam::Content::Tags::TagClass::class_name_long
std::string class_name_long
The longer class name. Typically shown alongside short name for user-friendliness.
Definition: tagclass.h:33
Blam::Config::GetConfig
BLAM ConfigFile * GetConfig(std::string filename)
Retrieves the specified configuration file.
Definition: config.cpp:227
Blam::Content::Tags::TagClass::class_name_short
std::string class_name_short
The short, 4-character name of the tag class.
Definition: tagclass.h:34
Blam::Content::Tags::TagClass::tag_size
int tag_size
The size of the tag's data. Used on loading/writing tag files.
Definition: tagclass.h:38
Blam::Content::Tags::TagClass::ShowImPropertyEditor
void ShowImPropertyEditor()
Shows a series of ImGUI controls used to modify tag data with a simple UI.
Definition: tagclass.h:47
Blam::EngineDefs::GetVersion
const BLAM char * GetVersion()
Retrieves the version of the engine in the following format:
Definition: engine_definitions.cpp:108
Blam::Content::Tags::TagClass::GeneratePluginFile
void GeneratePluginFile()
Generates a plugin file from the given tag.
Definition: tagclass.h:77
BlamTagClass
Legacy namespace for tag class data.
Definition: tagclass.h:143
Blam::Content::Tags::GenerateAllPlugins
BLAM void GenerateAllPlugins(bool require_switch)
Instructs the engine to generate Assembly/Guerilla plugins at startup.
Definition: tagclass.cpp:77
Blam::Content::Tags::TagClass::tag_address
void * tag_address
The memory address of a tag. Used when a tag class is used in the context of a tag.
Definition: tagclass.h:40
engine_definitions.h
fields.h
BlamTagClass::scenario_structure_bsp
BLAM void scenario_structure_bsp()
Legacy function made before I had any idea what I was doing.
Definition: tagclass.cpp:19
Blam::Content::Tags::GetTagClass
BLAM TagClass * GetTagClass(std::string id)
Retrieves a tag class that matches the given string.
Definition: tagclass.cpp:54
Blam::Content::Tags::TagClass
Class representing a tag class.
Definition: tagclass.h:30
BLAM
#define BLAM
Definition: discord_rpc.h:8
io.h
config.h
Blam::Content::Tags::TagClass::SetMemoryLocation
void SetMemoryLocation(void *address)
Sets the address and size of the tag that this class should be applied to.
Definition: tagclass.h:60
Blam::Content::Tags::GetRegisteredTagClasses
BLAM std::vector< TagClass * > * GetRegisteredTagClasses()
Retrieves the list of all registered tag classes.
Definition: tagclass.cpp:72
Blam::Utils::IO::CreateNewFile
BLAM int CreateNewFile(std::string filename, std::string file_contents)
Creates a file with the specified contents.
Definition: io.cpp:28
Blam::Content::Tags::TagClass::fields
std::vector< TagField * > fields
A series of tag fields that store the layout of the tag.
Definition: tagclass.h:36