From 5ec1659865eafe11ccbd8ca206b990548e149521 Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Thu, 10 Aug 2023 22:40:02 -0700 Subject: [PATCH] Button test --- src/dawn/state/StateProperty.hpp | 2 +- src/dawnshared/display/Color.hpp | 13 +++++++++++- src/dawntools/CMakeLists.txt | 1 - .../util/generator/SceneItemGenerator.cpp | 12 +++++++++++ src/dawntools/util/parser/CMakeLists.txt | 1 - src/dawntools/util/parser/SceneItemParser.cpp | 20 ++++++++++++++++++- src/dawntools/util/parser/SceneItemParser.hpp | 3 +++ 7 files changed, 47 insertions(+), 5 deletions(-) diff --git a/src/dawn/state/StateProperty.hpp b/src/dawn/state/StateProperty.hpp index 10627531..c7cdc69b 100644 --- a/src/dawn/state/StateProperty.hpp +++ b/src/dawn/state/StateProperty.hpp @@ -16,7 +16,7 @@ namespace Dawn { * * @param val Value that is to be used for this property. */ - void setInternal(V val) { + void setInternal(const V val) { if(val == this->_realValue) return;// TODO: can I omit this? kinda bad tbh. // Run the teardowns diff --git a/src/dawnshared/display/Color.hpp b/src/dawnshared/display/Color.hpp index 31613be5..3eeca8fa 100644 --- a/src/dawnshared/display/Color.hpp +++ b/src/dawnshared/display/Color.hpp @@ -22,9 +22,16 @@ namespace Dawn { */ static struct Color fromString(std::string str); - float_t r, g, b, a; + const struct Color& operator = (const struct Color &val) { + this->r = val.r; + this->g = val.g; + this->b = val.b; + this->a = val.a; + return *this; + } + struct Color operator * (const float_t &x) { return { r * x, @@ -52,6 +59,10 @@ namespace Dawn { }; } + const bool_t operator == (const struct Color &other) { + return r == other.r && g == other.g && b == other.b && a == other.a; + } + operator struct ColorU8() const { return { (uint8_t)(r * 255), diff --git a/src/dawntools/CMakeLists.txt b/src/dawntools/CMakeLists.txt index 60242593..106d19e3 100644 --- a/src/dawntools/CMakeLists.txt +++ b/src/dawntools/CMakeLists.txt @@ -23,7 +23,6 @@ include(util/generator/CMakeLists.txt) # Tools add_subdirectory(prefabtool) -add_subdirectory(propertytool) add_subdirectory(scenetool) add_subdirectory(texturetool) add_subdirectory(truetypetool) diff --git a/src/dawntools/util/generator/SceneItemGenerator.cpp b/src/dawntools/util/generator/SceneItemGenerator.cpp index 489388f5..3f7154f6 100644 --- a/src/dawntools/util/generator/SceneItemGenerator.cpp +++ b/src/dawntools/util/generator/SceneItemGenerator.cpp @@ -135,6 +135,18 @@ void SceneItemGenerator::generate( line(initBody, name + "->transform.setLocalPosition(" + item->position + ");", ""); } + if(item->alignment.size() > 0) { + line(initBody, name + "->uiItem->alignment = " + item->alignment + ";", ""); + } + + if(item->menuX.size() > 0) { + line(initBody, name + "->menuItem->menuX = " + item->menuX + ";", ""); + } + + if(item->menuY.size() > 0) { + line(initBody, name + "->menuItem->menuY = " + item->menuY + ";", ""); + } + if(item->scale.size() > 0) { line(initBody, name + "->transform.setLocalScale(" + item->scale + ");", ""); } diff --git a/src/dawntools/util/parser/CMakeLists.txt b/src/dawntools/util/parser/CMakeLists.txt index 24956fc5..584fb9a9 100644 --- a/src/dawntools/util/parser/CMakeLists.txt +++ b/src/dawntools/util/parser/CMakeLists.txt @@ -14,7 +14,6 @@ set( ${D}/SceneCodeParser.cpp ${D}/SceneItemComponentParser.cpp ${D}/SceneItemComponentRegistry.cpp - ${D}/ScenePropertyParser.cpp CACHE INTERNAL ${DAWN_CACHE_TARGET} diff --git a/src/dawntools/util/parser/SceneItemParser.cpp b/src/dawntools/util/parser/SceneItemParser.cpp index 9e971350..b995d20d 100644 --- a/src/dawntools/util/parser/SceneItemParser.cpp +++ b/src/dawntools/util/parser/SceneItemParser.cpp @@ -17,7 +17,10 @@ std::map SceneItemParser::getOptionalAttributes() { { "position", "" }, { "lookAt", "" }, { "scale", "" }, - { "prefab", "" } + { "prefab", "" }, + { "alignment", "" }, + { "menuX", "" }, + { "menuY", "" } }; } @@ -34,6 +37,21 @@ int32_t SceneItemParser::onParse( if(error->size() > 0) return 1; } + if(values["alignment"].size() > 0) { + out->alignment = vec4Parser(values["alignment"], error); + if(error->size() > 0) return 1; + } + + if(values["menuX"].size() > 0) { + out->menuX = intParser(values["menuX"], error); + if(error->size() > 0) return 1; + } + + if(values["menuY"].size() > 0) { + out->menuY = intParser(values["menuY"], error); + if(error->size() > 0) return 1; + } + if(values["scale"].size() > 0) { out->scale = vec3Parser(values["scale"], error); if(error->size() > 0) return 1; diff --git a/src/dawntools/util/parser/SceneItemParser.hpp b/src/dawntools/util/parser/SceneItemParser.hpp index 00678bf3..c6da961f 100644 --- a/src/dawntools/util/parser/SceneItemParser.hpp +++ b/src/dawntools/util/parser/SceneItemParser.hpp @@ -24,10 +24,13 @@ namespace Dawn { struct SceneItemComponentRegistry *registry; std::string ref; std::string position; + std::string alignment; std::string lookAtPosition; std::string lookAtTarget; std::string scale; std::string prefab; + std::string menuX; + std::string menuY; std::vector components; std::vector children; std::vector assets;