pareshi for HDR colors

This commit is contained in:
David Gibson committed 2022-05-07 17:21:28 -05:00
1 parent e03bb48bb3
commit 6c473e7c09
2 files changed
+27

No files matched your search

+24
View File
@@ -1,5 +1,7 @@
#include "parsehi.h"
#include "globalincs/vmallocator.h"
#include "parselo.h"
#include "graphics/color.h"
/**
* @brief Parses an optional table value into a field if the name is found
@@ -34,3 +36,25 @@ bool parse_optional_bool_into(const SCP_string& field_name, bool* value_target)
}
return false;
}
/**
* @brief Parses an optional table color into an object if the color is found
*
* @param field_name The name of the table field
* @param value_target Pointer to the variable to assign any parsed value to
*
* @return True if a value was parsed, false if not
*/
bool parse_optional_color3i_into(const SCP_string& field_name, hdr_color* out_color)
{
if (optional_string(field_name.c_str())) {
int components[3] = {255, 255, 255};
stuff_int_list(components, 3, RAW_INTEGER_TYPE);
if (out_color == nullptr) {
out_color = new hdr_color();
}
out_color->set_rgb(components);
return true;
}
return false;
}
+3
View File
@@ -1,5 +1,6 @@
#pragma once
#include "parse/parselo.h"
#include "graphics/color.h"
//parsehi is intended for higher level, frequently used combinations of parselo functions
//and also for collection of standardized parsing of complex types where appropriate
@@ -7,3 +8,5 @@
extern bool parse_optional_float_into(const SCP_string& field_name, float* value_target);
extern bool parse_optional_bool_into(const SCP_string& field_name, bool* value_target);
extern bool parse_optional_color3i_into(const SCP_string &field_name, hdr_color *out_color);