Program Listing for File haloscript.h¶
↰ Return to documentation for file (blam\components\haloscript\haloscript.h
)
#pragma once
#include <string>
#include <map>
#include <vector>
#define GVARS_FILE "./gvars.xml"
#ifndef BLAM
#define BLAM
#endif
#ifndef HSC
#define HSC
#endif
namespace Blam
{
class command_object
{
public:
std::string name;
std::string description;
std::string action;
};
BLAM command_object CreateCommandFromFile(std::string filename);
BLAM std::string get_csc_cmd_name(std::string filename);
BLAM std::string csc_var_process(std::string const& s);
BLAM std::string csc_var_process(std::string const& s, char read_until);
}
namespace BlamScript
{
namespace Globals
{
enum GvarUpdateResult
{
InvalidType,
UnknownGlobal,
Ok,
InvalidArgs,
OutOfBounds,
GlobalIsProtected
};
enum GvarType
{
Boolean,
Real,
Short,
Long,
Object,
String,
Int,
Float
};
struct ScriptGlobal
{
GvarType type;
std::string name = "";
std::string info = "";
std::string value_raw = "";
bool read_only = false;
// Additional value storage types, these are used in place of value_raw based on type. //
bool boolean_value = false;
short short_value = 0;
long long_value = 0;
int int_value = 0;
float float_value = 0.0f;
};
HSC std::map<std::string, ScriptGlobal>* GetGlobalsList();
HSC bool LoadGlobalsFromFile();
HSC std::string GetGvarTypeLabel(GvarType type);
HSC bool GlobalExists(std::string id);
HSC void RegisterGvar(ScriptGlobal var);
HSC void RegisterGvar(std::string name, std::string value_raw, GvarType type);
HSC void RegisterGvar(std::string name, std::string value_raw, GvarType type, std::string info);
HSC ScriptGlobal* GetGlobal(std::string name);
HSC GvarUpdateResult UpdateGlobalWrap(std::string name, std::string new_value);
HSC GvarUpdateResult UpdateGlobal(std::string name, std::string new_value);
HSC GvarUpdateResult UpdateGlobal(std::string name, bool new_value);
HSC GvarUpdateResult UpdateGlobal(std::string name, int new_value);
HSC GvarUpdateResult UpdateGlobal(std::string name, short new_value);
HSC GvarUpdateResult UpdateGlobal(std::string name, long new_value);
HSC GvarUpdateResult UpdateGlobal(std::string name, float new_value);
HSC bool* GetGlobalAsBoolean(std::string name);
HSC std::string* GetGlobalAsString(std::string name);
HSC short* GetGlobalAsShort(std::string name);
HSC long* GetGlobalAsLong(std::string name);
HSC int* GetGlobalAsInteger(std::string name);
HSC float* GetGlobalAsFloat(std::string name);
}
// old garbage below this line, cool new shit above this line
// Everything here is used for parsing BlamScript/HaloScript files (.hsc) //
//Classes
class script_action {
public:
std::string type;
std::vector<std::string> arguments;
};
class cmd_script_object {
public:
std::string name;
std::string description;
std::vector<script_action> actions;
};
class script_gvar {
public:
std::string name;
std::vector<std::string> arguments;
};
class script_object {
public:
std::vector<script_gvar> global_vars;
std::vector<script_action> actions;
};
//Functions
HSC cmd_script_object parse_cmd_script(std::string filename); //Reads a script as a command
HSC std::string get_cmd_name(std::string filename); //Gets ONLY the command name from a HSC file
HSC std::vector<std::string> getCommandsCSC();
HSC std::vector<cmd_script_object> getCommandsHSC();
HSC std::vector<std::string> get_csc_data();
HSC std::vector<cmd_script_object> get_hsc_data();
HSC void InitCSC();
HSC void InitHSC();
}