Work resumed
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@ -85,4 +85,6 @@ assets/borrowed
|
||||
/vita
|
||||
/tools
|
||||
|
||||
._*
|
||||
._*
|
||||
|
||||
*~
|
@ -12,6 +12,7 @@ target_sources(${DAWN_TARGET_NAME}
|
||||
UIImage.cpp
|
||||
UIEmpty.cpp
|
||||
UIBorder.cpp
|
||||
UIMesh.cpp
|
||||
)
|
||||
|
||||
add_subdirectory(menu)
|
||||
|
@ -41,27 +41,61 @@ void UIComponent::updateAlignment() {
|
||||
parentInnerWidth = dimensional->getContentWidth();
|
||||
parentInnerHeight = dimensional->getContentHeight();
|
||||
|
||||
UIComponent::calculateDimensions(
|
||||
this->alignX,
|
||||
this->alignUnitLeft,
|
||||
this->alignUnitRight,
|
||||
&translate.x,
|
||||
&this->width,
|
||||
parentInnerWidth,
|
||||
this->getContentWidth(),
|
||||
glm::vec2(align[0], align[2])
|
||||
);
|
||||
UIComponent::calculateDimensions(
|
||||
this->alignY,
|
||||
this->alignUnitTop,
|
||||
this->alignUnitBottom,
|
||||
&translate.y,
|
||||
&this->height,
|
||||
parentInnerHeight,
|
||||
this->getContentHeight(),
|
||||
glm::vec2(align[1], align[3])
|
||||
// Should we be doing width first, or height first?
|
||||
bool_t heightFirst = (
|
||||
this->alignUnitLeft == UI_COMPONENT_ALIGN_UNIT_RATIO ||
|
||||
this->alignUnitRight == UI_COMPONENT_ALIGN_UNIT_RATIO
|
||||
);
|
||||
|
||||
if(heightFirst) {
|
||||
UIComponent::calculateDimensions(
|
||||
this->alignY,
|
||||
this->alignUnitTop,
|
||||
this->alignUnitBottom,
|
||||
&translate.y,
|
||||
&this->height,
|
||||
parentInnerHeight,
|
||||
this->getContentHeight(),
|
||||
this->width,
|
||||
glm::vec2(align[1], align[3])
|
||||
);
|
||||
UIComponent::calculateDimensions(
|
||||
this->alignX,
|
||||
this->alignUnitLeft,
|
||||
this->alignUnitRight,
|
||||
&translate.x,
|
||||
&this->width,
|
||||
parentInnerWidth,
|
||||
this->getContentWidth(),
|
||||
this->height,
|
||||
glm::vec2(align[0], align[2])
|
||||
);
|
||||
} else {
|
||||
UIComponent::calculateDimensions(
|
||||
this->alignY,
|
||||
this->alignUnitTop,
|
||||
this->alignUnitBottom,
|
||||
&translate.y,
|
||||
&this->height,
|
||||
parentInnerHeight,
|
||||
this->getContentHeight(),
|
||||
this->width,
|
||||
glm::vec2(align[1], align[3])
|
||||
);
|
||||
UIComponent::calculateDimensions(
|
||||
this->alignX,
|
||||
this->alignUnitLeft,
|
||||
this->alignUnitRight,
|
||||
&translate.x,
|
||||
&this->width,
|
||||
parentInnerWidth,
|
||||
this->getContentWidth(),
|
||||
this->height,
|
||||
glm::vec2(align[0], align[2])
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
translate.x += dimensional->getChildOffsetX();
|
||||
translate.y += dimensional->getChildOffsetY();
|
||||
|
||||
@ -73,10 +107,14 @@ void UIComponent::updateAlignment() {
|
||||
float_t UIComponent::calculateAlignmentValue(
|
||||
float_t alignmentValue,
|
||||
float_t parentSize,
|
||||
float_t ratioSize,
|
||||
enum UIComponentAlignUnit unit
|
||||
) {
|
||||
if(unit == UI_COMPONENT_ALIGN_UNIT_SCALE) return alignmentValue;
|
||||
return (alignmentValue / 100.0f) * parentSize;
|
||||
if(unit == UI_COMPONENT_ALIGN_UNIT_PERCENT) return (alignmentValue / 100.0f) * parentSize;
|
||||
if(unit == UI_COMPONENT_ALIGN_UNIT_RATIO) return (alignmentValue / 100.0f) * ratioSize;
|
||||
assertUnreachable("UIComponent::calculateAlignmentValue: Unknown alignment unit");
|
||||
return -1;
|
||||
}
|
||||
|
||||
void UIComponent::calculateDimensions(
|
||||
@ -87,6 +125,7 @@ void UIComponent::calculateDimensions(
|
||||
float_t *size,
|
||||
float_t outerSize,
|
||||
float_t innerSize,
|
||||
float_t ratioSize,
|
||||
glm::vec2 alignment
|
||||
) {
|
||||
assertNotNull(position, "UIComponent::calculateDimensions: Position cannot be null");
|
||||
@ -99,11 +138,13 @@ void UIComponent::calculateDimensions(
|
||||
*position = UIComponent::calculateAlignmentValue(
|
||||
alignment[0],
|
||||
outerSize,
|
||||
ratioSize,
|
||||
unitStart
|
||||
);
|
||||
*size = outerSize - (*position + UIComponent::calculateAlignmentValue(
|
||||
alignment[1],
|
||||
outerSize,
|
||||
ratioSize,
|
||||
unitEnd
|
||||
));
|
||||
break;
|
||||
@ -115,28 +156,29 @@ void UIComponent::calculateDimensions(
|
||||
*position = UIComponent::calculateAlignmentValue(
|
||||
alignment[0],
|
||||
outerSize,
|
||||
ratioSize,
|
||||
unitStart
|
||||
);
|
||||
*size = UIComponent::calculateAlignmentValue(
|
||||
alignment[1],
|
||||
outerSize,
|
||||
ratioSize,
|
||||
unitEnd
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
case UI_COMPONENT_ALIGN_MIDDLE: {
|
||||
*size = mathMax<float_t>(
|
||||
innerSize,
|
||||
UIComponent::calculateAlignmentValue(
|
||||
alignment[1],
|
||||
outerSize,
|
||||
unitEnd
|
||||
)
|
||||
*size = UIComponent::calculateAlignmentValue(
|
||||
alignment[1],
|
||||
outerSize,
|
||||
ratioSize,
|
||||
unitEnd
|
||||
);
|
||||
*position = (outerSize / 2.0f) - (*size / 2.0f) + UIComponent::calculateAlignmentValue(
|
||||
*position = (outerSize / 2.0f) - ((*size) / 2.0f) + UIComponent::calculateAlignmentValue(
|
||||
alignment[0],
|
||||
outerSize,
|
||||
ratioSize,
|
||||
unitStart
|
||||
);
|
||||
break;
|
||||
@ -146,11 +188,13 @@ void UIComponent::calculateDimensions(
|
||||
*size = UIComponent::calculateAlignmentValue(
|
||||
alignment[0],
|
||||
outerSize,
|
||||
ratioSize,
|
||||
unitStart
|
||||
);
|
||||
*position = outerSize - *size - UIComponent::calculateAlignmentValue(
|
||||
alignment[1],
|
||||
outerSize,
|
||||
ratioSize,
|
||||
unitEnd
|
||||
);
|
||||
break;
|
||||
|
@ -21,7 +21,8 @@ namespace Dawn {
|
||||
|
||||
enum UIComponentAlignUnit {
|
||||
UI_COMPONENT_ALIGN_UNIT_SCALE,
|
||||
UI_COMPONENT_ALIGN_UNIT_PERCENT
|
||||
UI_COMPONENT_ALIGN_UNIT_PERCENT,
|
||||
UI_COMPONENT_ALIGN_UNIT_RATIO
|
||||
};
|
||||
|
||||
class UIComponent : public SceneItemComponent, public UIComponentDimensional {
|
||||
@ -53,12 +54,14 @@ namespace Dawn {
|
||||
*
|
||||
* @param alignmentValue Alignment value.
|
||||
* @param parentSize Parent size.
|
||||
* @param ratioSize The dimension that the ratio is based on.
|
||||
* @param unit Alignment unit.
|
||||
* @return The calculated alignment value.
|
||||
*/
|
||||
static float_t calculateAlignmentValue(
|
||||
float_t alignmentValue,
|
||||
float_t parentSize,
|
||||
float_t ratioSize,
|
||||
enum UIComponentAlignUnit unit
|
||||
);
|
||||
|
||||
@ -72,6 +75,7 @@ namespace Dawn {
|
||||
* @param size Output size floating point.
|
||||
* @param outerSize Outer size (of the parent).
|
||||
* @param innerSize Inner size (of this element's content).
|
||||
* @param ratioSize The size that the opposite dimension is.
|
||||
* @param alignment Alignment settings.
|
||||
*/
|
||||
static void calculateDimensions(
|
||||
@ -82,6 +86,7 @@ namespace Dawn {
|
||||
float_t *size,
|
||||
float_t outerSize,
|
||||
float_t innerSize,
|
||||
float_t ratioSize,
|
||||
glm::vec2 alignment
|
||||
);
|
||||
|
||||
|
@ -10,7 +10,8 @@ using namespace Dawn;
|
||||
|
||||
UIImage::UIImage(SceneItem *item) :
|
||||
texture(nullptr),
|
||||
UIComponentRenderable(item)
|
||||
UIComponentRenderable(item),
|
||||
uvs(glm::vec4(0, 1, 1, 0))
|
||||
{
|
||||
|
||||
}
|
||||
@ -42,7 +43,6 @@ std::vector<struct ShaderPassItem> UIImage::getUIRenderPasses() {
|
||||
item.w = this->transform->getWorldPosition().z;
|
||||
item.renderFlags = RENDER_MANAGER_RENDER_FLAG_BLEND;
|
||||
item.mesh = &mesh;
|
||||
|
||||
return { item };
|
||||
}
|
||||
|
||||
@ -51,13 +51,22 @@ void UIImage::onStart() {
|
||||
|
||||
useEvent([&]{
|
||||
QuadMesh::bufferPositions(&mesh,
|
||||
glm::vec2(0, 0), glm::vec2(width, height), 0
|
||||
glm::vec2(0, 0),
|
||||
glm::vec2(width, height), 0
|
||||
);
|
||||
}, this->eventAlignmentUpdated);
|
||||
|
||||
QuadMesh::initQuadMesh(&mesh,
|
||||
glm::vec2(0, 0), glm::vec2(0, 1),
|
||||
glm::vec2(width, height), glm::vec2(1, 0),
|
||||
useEffect([&]{
|
||||
QuadMesh::bufferCoordinates(&mesh,
|
||||
glm::vec2(this->uvs._realValue[0], this->uvs._realValue[1]),
|
||||
glm::vec2(this->uvs._realValue[2], this->uvs._realValue[3]),
|
||||
0
|
||||
);
|
||||
}, this->uvs);
|
||||
|
||||
QuadMesh::initQuadMesh(&mesh,
|
||||
glm::vec2(0, 0), glm::vec2(this->uvs._realValue[0], this->uvs._realValue[1]),
|
||||
glm::vec2(width, height), glm::vec2(this->uvs._realValue[2], this->uvs._realValue[3]),
|
||||
0.0f
|
||||
);
|
||||
}
|
@ -17,6 +17,8 @@ namespace Dawn {
|
||||
struct Color color = COLOR_WHITE;
|
||||
// @optional
|
||||
StateProperty<Texture*> texture;
|
||||
// @optional
|
||||
StateProperty<glm::vec4> uvs;
|
||||
|
||||
UIImage(SceneItem *item);
|
||||
|
||||
|
56
src/dawn/scene/components/ui/UIMesh.cpp
Normal file
56
src/dawn/scene/components/ui/UIMesh.cpp
Normal file
@ -0,0 +1,56 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "UIMesh.hpp"
|
||||
#include "game/DawnGame.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
UIMesh::UIMesh(SceneItem *i) :
|
||||
texture(nullptr),
|
||||
UIComponentRenderable(i)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
float_t UIMesh::getContentWidth() {
|
||||
if(this->texture != nullptr) return this->texture->getWidth();
|
||||
return this->width;
|
||||
}
|
||||
|
||||
float_t UIMesh::getContentHeight() {
|
||||
if(this->texture != nullptr) return this->texture->getHeight();
|
||||
return this->height;
|
||||
}
|
||||
|
||||
std::vector<struct ShaderPassItem> UIMesh::getUIRenderPasses() {
|
||||
struct ShaderPassItem item;
|
||||
auto shader = getGame()->renderManager.uiShader;
|
||||
item.shader = shader;
|
||||
item.colorValues[shader->paramColor] = this->color;
|
||||
item.parameterBuffers[shader->bufferUiCanvas] = &getCanvas()->shaderBuffer;
|
||||
item.matrixValues[shader->paramModel] = this->transform->getWorldTransform();
|
||||
if(this->texture == nullptr) {
|
||||
item.boolValues[shader->paramHasTexture] = false;
|
||||
} else {
|
||||
item.boolValues[shader->paramHasTexture] = true;
|
||||
item.textureSlots[0] = this->texture;
|
||||
item.textureValues[shader->paramTexture] = 0;
|
||||
}
|
||||
item.w = this->transform->getWorldPosition().z;
|
||||
item.renderFlags = RENDER_MANAGER_RENDER_FLAG_BLEND;
|
||||
item.mesh = &mesh;
|
||||
return { item };
|
||||
}
|
||||
|
||||
void UIMesh::onStart() {
|
||||
useEffect([&]{
|
||||
|
||||
}, this->positions)();
|
||||
|
||||
useEffect([&]{
|
||||
|
||||
}, this->uvs)();
|
||||
}
|
31
src/dawn/scene/components/ui/UIMesh.hpp
Normal file
31
src/dawn/scene/components/ui/UIMesh.hpp
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "UIComponentRenderable.hpp"
|
||||
#include "display/mesh/QuadMesh.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class UIMesh : public UIComponentRenderable {
|
||||
private:
|
||||
Mesh mesh;
|
||||
|
||||
public:
|
||||
// @optional
|
||||
StateProperty<std::vector<glm::vec2>> positions;
|
||||
// @optional
|
||||
StateProperty<std::vector<glm::vec2>> uvs;
|
||||
// @optional
|
||||
struct Color color = COLOR_WHITE;
|
||||
// @optional
|
||||
StateProperty<Texture*> texture;
|
||||
|
||||
UIMesh(SceneItem *item);
|
||||
float_t getContentWidth() override;
|
||||
float_t getContentHeight() override;
|
||||
std::vector<struct ShaderPassItem> getUIRenderPasses() override;
|
||||
void onStart() override;
|
||||
};
|
||||
}
|
@ -32,6 +32,9 @@ struct Color Color::fromString(std::string str) {
|
||||
|
||||
} else if(stringIncludes(lower, "blue")) {
|
||||
return COLOR_BLUE;
|
||||
|
||||
} else if(stringIncludes(lower, "transparent")) {
|
||||
return COLOR_TRANSPARENT;
|
||||
}
|
||||
|
||||
// Hex code?
|
||||
|
@ -86,5 +86,5 @@ namespace Dawn {
|
||||
#define COLOR_CORNFLOWER_BLUE COLOR_DEF(0.4f, 0.6f, 0.9f, 1.0f)
|
||||
#define COLOR_WHITE_TRANSPARENT COLOR_DEF(1.0f, 1.0f, 1.0f, 0.0f)
|
||||
#define COLOR_BLACK_TRANSPARENT COLOR_DEF(0.0f, 0.0f, 0.0f, 0.0f)
|
||||
#define COLOR_TRANSPARENT COLOR_BLACK_TRANSPARENT
|
||||
#define COLOR_TRANSPARENT COLOR_WHITE_TRANSPARENT
|
||||
}
|
@ -110,7 +110,7 @@ namespace Dawn {
|
||||
// Split string by comma into two strings that we pass into float
|
||||
auto split = stringSplit(v, ",");
|
||||
if(split.size() != 4) {
|
||||
*error = "Invalid vec4 value: " + v;
|
||||
*error = "Invalid vec4 value: " + v + " (incorrect split len " + std::to_string(split.size()) + ")";
|
||||
return std::string("");
|
||||
}
|
||||
return std::string(
|
||||
@ -125,6 +125,28 @@ namespace Dawn {
|
||||
|
||||
static inline std::string colorParser(std::string v, std::string *error) {
|
||||
return "Color::fromString(" + stringParser(v, error) + ")";
|
||||
};
|
||||
|
||||
static inline std::string uiComponentAlignParser(std::string v, std::string *error) {
|
||||
v = stringToLowercase(v);
|
||||
if(v.find("left") != std::string::npos) return "UI_COMPONENT_ALIGN_START";
|
||||
if(v.find("center") != std::string::npos) return "UI_COMPONENT_ALIGN_MIDDLE";
|
||||
if(v.find("right") != std::string::npos) return "UI_COMPONENT_ALIGN_END";
|
||||
if(v.find("top") != std::string::npos) return "UI_COMPONENT_ALIGN_START";
|
||||
if(v.find("bottom") != std::string::npos) return "UI_COMPONENT_ALIGN_END";
|
||||
if(v.find("stretch") != std::string::npos) return "UI_COMPONENT_ALIGN_STRETCH";
|
||||
if(v.find("start") != std::string::npos) return "UI_COMPONENT_ALIGN_START";
|
||||
if(v.find("middle") != std::string::npos) return "UI_COMPONENT_ALIGN_MIDDLE";
|
||||
if(v.find("end") != std::string::npos) return "UI_COMPONENT_ALIGN_END";
|
||||
*error = "Invalid UIComponentAlign value: " + v;
|
||||
}
|
||||
|
||||
static inline std::string uiComponentAlignUnitParser(std::string v, std::string *error) {
|
||||
v = stringToLowercase(v);
|
||||
if(v.find("scale") != std::string::npos) return "UI_COMPONENT_ALIGN_UNIT_SCALE";
|
||||
if(v.find("percent") != std::string::npos) return "UI_COMPONENT_ALIGN_UNIT_PERCENT";
|
||||
if(v.find("ratio") != std::string::npos) return "UI_COMPONENT_ALIGN_UNIT_RATIO";
|
||||
*error = "Invalid UIComponentAlignUnit value: " + v;
|
||||
}
|
||||
|
||||
static inline std::function<std::string(std::string, std::string*)> parserFromTypeName(std::string type) {
|
||||
@ -149,7 +171,14 @@ namespace Dawn {
|
||||
} else if(type == "flag_t") {
|
||||
parser = rawParser;
|
||||
} else if(type.starts_with("enum")) {
|
||||
parser = rawParser;
|
||||
// Handle Enum Cases
|
||||
if(type.ends_with("UIComponentAlign")) {
|
||||
parser = uiComponentAlignParser;
|
||||
} else if(type.ends_with("UIComponentAlignUnit")) {
|
||||
parser = uiComponentAlignUnitParser;
|
||||
} else {
|
||||
parser = rawParser;
|
||||
}
|
||||
} else if(type.find("*") == (type.size() - 1)) {
|
||||
type = type.substr(0, type.size() - 1);
|
||||
parser = rawParser;
|
||||
|
@ -1,155 +0,0 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "util/string.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
static inline std::string rawParser(std::string v, std::string *error) {
|
||||
return v;
|
||||
};
|
||||
|
||||
static inline std::string stringParser(std::string v, std::string *error) {
|
||||
return "\"" + v + "\"";
|
||||
};
|
||||
|
||||
static inline std::string floatParser(std::string v, std::string *error) {
|
||||
v = stringTrim(v);
|
||||
|
||||
// Make sure number contains decimal
|
||||
if(v.find(".") == std::string::npos) {
|
||||
v += ".0";
|
||||
}
|
||||
// Make sure number contains a number before the decimal
|
||||
if(v.find(".") == 0) {
|
||||
v = "0" + v;
|
||||
}
|
||||
// Make sure ends with f
|
||||
if(v.find("f") == std::string::npos) {
|
||||
v += "f";
|
||||
}
|
||||
return v;
|
||||
};
|
||||
|
||||
static inline std::string intParser(std::string v, std::string *error) {
|
||||
v = stringTrim(v);
|
||||
return v;
|
||||
}
|
||||
|
||||
static inline std::string boolParser(std::string v, std::string *error) {
|
||||
v = stringTrim(v);
|
||||
if(v == "true") return "true";
|
||||
if(v == "false") return "false";
|
||||
*error = "Invalid bool value: " + v;
|
||||
return std::string("");
|
||||
}
|
||||
|
||||
static inline std::string vec2Parser(std::string v, std::string *error) {
|
||||
// Split string by comma into two strings that we pass into float
|
||||
auto split = stringSplit(v, ",");
|
||||
if(split.size() != 2) {
|
||||
*error = "Invalid vec2 value: " + v;
|
||||
return std::string("");
|
||||
}
|
||||
return std::string(
|
||||
"glm::vec2(" +
|
||||
floatParser(split[0], error) + ", " +
|
||||
floatParser(split[1], error) +
|
||||
")"
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
static inline std::string vec3Parser(std::string v, std::string *error) {
|
||||
// Split string by comma into two strings that we pass into float
|
||||
auto split = stringSplit(v, ",");
|
||||
if(split.size() != 3) {
|
||||
*error = "Invalid vec3 value: " + v;
|
||||
return std::string("");
|
||||
}
|
||||
return std::string(
|
||||
"glm::vec3(" +
|
||||
floatParser(split[0], error) + ", " +
|
||||
floatParser(split[1], error) + ", " +
|
||||
floatParser(split[2], error) +
|
||||
")"
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
static inline std::string vec6Parser(std::string v, std::string *error) {
|
||||
// Split string by comma into two strings that we pass into float
|
||||
auto split = stringSplit(v, ",");
|
||||
if(split.size() != 6) {
|
||||
*error = "Invalid vec6 value: " + v;
|
||||
return std::string("");
|
||||
}
|
||||
return std::string(
|
||||
"glm::vec3(" +
|
||||
floatParser(split[0], error) + ", " +
|
||||
floatParser(split[1], error) + ", " +
|
||||
floatParser(split[2], error) + ", " +
|
||||
floatParser(split[3], error) + ", " +
|
||||
floatParser(split[4], error) + ", " +
|
||||
floatParser(split[5], error) +
|
||||
")"
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
static inline std::string vec4Parser(std::string v, std::string *error) {
|
||||
// Split string by comma into two strings that we pass into float
|
||||
auto split = stringSplit(v, ",");
|
||||
if(split.size() != 4) {
|
||||
*error = "Invalid vec4 value: " + v;
|
||||
return std::string("");
|
||||
}
|
||||
return std::string(
|
||||
"glm::vec4(" +
|
||||
floatParser(split[0], error) + ", " +
|
||||
floatParser(split[1], error) + ", " +
|
||||
floatParser(split[2], error) + ", " +
|
||||
floatParser(split[3], error) +
|
||||
")"
|
||||
);
|
||||
};
|
||||
|
||||
static inline std::string colorParser(std::string v, std::string *error) {
|
||||
return rawParser(v, error);
|
||||
}
|
||||
|
||||
static inline std::function<std::string(std::string, std::string*)> parserFromTypeName(std::string type) {
|
||||
std::function<std::string(std::string, std::string*)> parser = rawParser;
|
||||
|
||||
if(type.find("string") != std::string::npos) {
|
||||
parser = stringParser;
|
||||
} else if(type.find("float") != std::string::npos) {
|
||||
parser = floatParser;
|
||||
} else if(type.find("Color") != std::string::npos) {
|
||||
parser = colorParser;
|
||||
} else if(type.find("vec2") != std::string::npos) {
|
||||
parser = vec2Parser;
|
||||
} else if(type.find("vec3") != std::string::npos) {
|
||||
parser = vec3Parser;
|
||||
} else if(type.find("vec4") != std::string::npos) {
|
||||
parser = vec4Parser;
|
||||
} else if(type == "int32_t" || type == "int") {
|
||||
parser = intParser;
|
||||
} else if(type == "bool_t") {
|
||||
parser = boolParser;
|
||||
} else if(type == "flag_t") {
|
||||
parser = rawParser;
|
||||
} else if(type.starts_with("enum")) {
|
||||
parser = rawParser;
|
||||
} else if(type.find("*") == (type.size() - 1)) {
|
||||
type = type.substr(0, type.size() - 1);
|
||||
parser = rawParser;
|
||||
} else {
|
||||
throw std::string("Invalid parser type");
|
||||
}
|
||||
|
||||
return parser;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user