summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editor/editor.cpp13
-rw-r--r--src/font.cpp8
-rw-r--r--src/font.hpp2
-rw-r--r--src/serialization-font.cpp56
-rw-r--r--src/serialization-static-ui.cpp54
-rw-r--r--src/serialization.hpp4
-rw-r--r--src/static-ui.cpp9
-rw-r--r--src/static-ui.hpp6
-rw-r--r--tests/pke-test-serialization.cpp62
9 files changed, 178 insertions, 36 deletions
diff --git a/editor/editor.cpp b/editor/editor.cpp
index 9257f6a..c8b69df 100644
--- a/editor/editor.cpp
+++ b/editor/editor.cpp
@@ -1264,7 +1264,7 @@ void RecordImGuiUITree() {
}
void RecordImGuiUIEdit() {
const ImGuiInputTextFlags text_flags = ImGuiInputTextFlags_AllowTabInput;
- bool changed;
+ bool changed, changed_sub;
if (!ImGui::Begin("pke_ui_edit")) {
ImGui::End();
return;
@@ -1275,6 +1275,7 @@ void RecordImGuiUIEdit() {
}
changed = false;
+ changed_sub = false;
ImGui::Text("Position Type:");
ImGui::BeginDisabled(PK_HAS_FLAG(selected_ui_box->flags, PKE_UI_BOX_FLAG_POSITION_TYPE_FLEX));
@@ -1318,6 +1319,10 @@ void RecordImGuiUIEdit() {
changed = ImGui::InputScalarN("flex_weight", ImGuiDataType_Float, &selected_ui_box->flex_weight, 1, nullptr, nullptr, nullptr, 0) || changed;
changed = ImGui::InputScalarN("flex_direction", ImGuiDataType_U8, &selected_ui_box->flex_direction, 1, nullptr, nullptr, nullptr, 0) || changed;
changed = ImGui::InputScalarN("layer", ImGuiDataType_U8, &selected_ui_box->layer, 1, nullptr, nullptr, nullptr, 0) || changed;
+ if (PK_HAS_FLAG(selected_ui_box->flags, PKE_UI_BOX_FLAG_VISIBILITY_INVISIBLE) == false) {
+ changed = ImGui::ColorEdit4("color_border", &selected_ui_box->color_border[0]) || changed;
+ changed = ImGui::ColorEdit4("color_background", &selected_ui_box->color_background[0]) || changed;
+ }
if (selected_ui_box->type == PKE_UI_BOX_TYPE_TEXT) {
assert(selected_ui_box->type_data != NULL);
@@ -1343,6 +1348,12 @@ void RecordImGuiUIEdit() {
}
ImGui::SameLine();
ImGui::Text("(%.4zu/%4i)", len, buffer_len);
+ changed_sub = ImGui::ColorEdit4("color_foreground(txt)", &fr.settings.color_foreground[0]) || changed_sub;
+ changed_sub = ImGui::ColorEdit4("color_background(txt)", &fr.settings.color_background[0]) || changed_sub;
+ if (changed_sub) {
+ FontType_UpdateStringRender(fr.fr_handle, &fr.settings);
+ }
+ changed |= changed_sub;
}
if (changed) {
diff --git a/src/font.cpp b/src/font.cpp
index 9a0692c..737e86d 100644
--- a/src/font.cpp
+++ b/src/font.cpp
@@ -42,8 +42,8 @@ struct FontTypeData {
struct FontInstanceBufferItem {
glm::mat4 pos_scale;
- glm::vec4 fg_color;
- glm::vec4 bg_color;
+ glm::vec4 color_foreground;
+ glm::vec4 color_background;
glm::vec2 sprite_region_min;
glm::vec2 sprite_region_max;
glm::vec2 bounding_region_min;
@@ -218,8 +218,8 @@ void FontType_Inner_CalcTransforms(const FontType *ft, FontRender *fr, FontInsta
buf_item = &ptr_dst[i];
buf_item->pos_scale = glm::translate(glm::mat4(1), translate);
buf_item->pos_scale = glm::scale(buf_item->pos_scale, scale);
- buf_item->fg_color = glm::vec4(0.4, 0.9, 0.5, 0.8);
- buf_item->bg_color = glm::vec4(0.0, 0.0, 0.0, 0.0);
+ buf_item->color_foreground = fr->settings.color_foreground;
+ buf_item->color_background = fr->settings.color_background;
buf_item->sprite_region_min = fgc->sprite_region_min;
buf_item->sprite_region_max = fgc->sprite_region_max;
diff --git a/src/font.hpp b/src/font.hpp
index 567062e..9d766df 100644
--- a/src/font.hpp
+++ b/src/font.hpp
@@ -50,6 +50,8 @@ struct FontGlyphChar {
FONT_GLYPH_CHAR_FLAG flags;
};
struct FontRenderSettings {
+ glm::vec4 color_foreground = glm::vec4(0.4, 0.9, 0.5, 0.8);
+ glm::vec4 color_background = glm::vec4(0.0, 0.0, 0.0, 0.0);
float char_scale;
float line_height_scale;
float char_spacing_scale;
diff --git a/src/serialization-font.cpp b/src/serialization-font.cpp
index 4ccc55e..f31016e 100644
--- a/src/serialization-font.cpp
+++ b/src/serialization-font.cpp
@@ -31,7 +31,7 @@ pk_handle pke_serialize_font_render(srlztn_serialize_helper *h, FontRender *fr)
h->handle_head.itemIndex++;
pk_arr_append_t(&kvec.child_handles, font_render_settings_handle);
- compt_a<128==sizeof(FontRender)>();
+ compt_a<160==sizeof(FontRender)>();
{
kve.key = SRLZTN_UI_FONT_RENDER_UUID;
s = pk_new<char>(37, h->bkt);
@@ -80,7 +80,7 @@ void pke_deserialize_font_render(srlztn_deserialize_helper *h, pke_kve_container
uint32_t i;
char *s;
- compt_a<128==sizeof(FontRender)>();
+ compt_a<160==sizeof(FontRender)>();
for (i = 0; i < kvec->arr.next; ++i) {
kve = &kvec->arr[i];
if (strcmp(kve->key, SRLZTN_UI_FONT_RENDER_UUID) == 0) {
@@ -127,7 +127,7 @@ pk_handle pke_serialize_font_render_settings(srlztn_serialize_helper *h, FontRen
kvec.child_handles.bkt = h->bkt;
h->handle_head.itemIndex++;
- compt_a<32==sizeof(FontRenderSettings)>();
+ compt_a<64==sizeof(FontRenderSettings)>();
{
kve.key = SRLZTN_UI_FONT_RENDER_SETTINGS_CHAR_SCALE;
len = snprintf(NULL, 0, "%f", frs->char_scale);
@@ -181,6 +181,24 @@ pk_handle pke_serialize_font_render_settings(srlztn_serialize_helper *h, FontRen
kve.end = SRLZTN_KVE_END;
pk_arr_append_t(&kvec.arr, kve);
}
+ {
+ kve.key = SRLZTN_UI_FONT_RENDER_SETTINGS_COLOR_FOREGROUND;
+ len = snprintf(NULL, 0, "%f%s%f%s%f%s%f", frs->color_foreground[0], SRLZTN_NUM_SEPARATOR, frs->color_foreground[1], SRLZTN_NUM_SEPARATOR, frs->color_foreground[2], SRLZTN_NUM_SEPARATOR, frs->color_foreground[3]);
+ s = pk_new<char>(len+1, h->bkt);
+ sprintf(s, "%f%s%f%s%f%s%f", frs->color_foreground[0], SRLZTN_NUM_SEPARATOR, frs->color_foreground[1], SRLZTN_NUM_SEPARATOR, frs->color_foreground[2], SRLZTN_NUM_SEPARATOR, frs->color_foreground[3]);
+ kve.val = s;
+ kve.end = SRLZTN_KVE_END;
+ pk_arr_append_t(&kvec.arr, kve);
+ }
+ {
+ kve.key = SRLZTN_UI_FONT_RENDER_SETTINGS_COLOR_BACKGROUND;
+ len = snprintf(NULL, 0, "%f%s%f%s%f%s%f", frs->color_background[0], SRLZTN_NUM_SEPARATOR, frs->color_background[1], SRLZTN_NUM_SEPARATOR, frs->color_background[2], SRLZTN_NUM_SEPARATOR, frs->color_background[3]);
+ s = pk_new<char>(len+1, h->bkt);
+ sprintf(s, "%f%s%f%s%f%s%f", frs->color_background[0], SRLZTN_NUM_SEPARATOR, frs->color_background[1], SRLZTN_NUM_SEPARATOR, frs->color_background[2], SRLZTN_NUM_SEPARATOR, frs->color_background[3]);
+ kve.val = s;
+ kve.end = SRLZTN_KVE_END;
+ pk_arr_append_t(&kvec.arr, kve);
+ }
pk_arr_append_t(&h->kvp_containers, kvec);
kvec.arr.data = nullptr;
@@ -195,7 +213,7 @@ void pke_deserialize_font_render_settings(srlztn_deserialize_helper *h, pke_kve_
const char *starting_char;
PK_STN_RES stn_res;
char *str_end;
- compt_a<32==sizeof(FontRenderSettings)>();
+ compt_a<64==sizeof(FontRenderSettings)>();
for (i = 0; i < kvec->arr.next; ++i) {
if (strncmp(kvec->arr[i].key, SRLZTN_UI_FONT_RENDER_SETTINGS_CHAR_SCALE, strlen(SRLZTN_UI_FONT_RENDER_SETTINGS_CHAR_SCALE)) == 0) {
stn_res = pk_stn(&frs->char_scale, kvec->arr[i].val, &str_end);
@@ -256,5 +274,35 @@ void pke_deserialize_font_render_settings(srlztn_deserialize_helper *h, pke_kve_
frs->surface_area_type_flags = FONT_RENDER_SURFACE_AREA_TYPE_FLAG(flags);
continue;
}
+ if (strstr(SRLZTN_UI_FONT_RENDER_SETTINGS_COLOR_FOREGROUND, kvec->arr[i].key)) {
+ starting_char = kvec->arr[i].val;
+ index = 0;
+ do {
+ assert(index < 4);
+ stn_res = pk_stn(&frs->color_foreground[index], starting_char, &str_end);
+ if (stn_res != PK_STN_RES_SUCCESS) break;
+ starting_char = str_end + 1;
+ ++index;
+ } while (*str_end != '\0');
+ if (stn_res != PK_STN_RES_SUCCESS) {
+ fprintf(stderr, "[pke_deserialize_ui_box] Failed to parse value for: '%s', err: %i\n", SRLZTN_UI_FONT_RENDER_SETTINGS_COLOR_FOREGROUND, stn_res);
+ }
+ continue;
+ }
+ if (strstr(SRLZTN_UI_FONT_RENDER_SETTINGS_COLOR_BACKGROUND, kvec->arr[i].key)) {
+ starting_char = kvec->arr[i].val;
+ index = 0;
+ do {
+ assert(index < 4);
+ stn_res = pk_stn(&frs->color_background[index], starting_char, &str_end);
+ if (stn_res != PK_STN_RES_SUCCESS) break;
+ starting_char = str_end + 1;
+ ++index;
+ } while (*str_end != '\0');
+ if (stn_res != PK_STN_RES_SUCCESS) {
+ fprintf(stderr, "[pke_deserialize_ui_box] Failed to parse value for: '%s', err: %i\n", SRLZTN_UI_FONT_RENDER_SETTINGS_COLOR_BACKGROUND, stn_res);
+ }
+ continue;
+ }
}
}
diff --git a/src/serialization-static-ui.cpp b/src/serialization-static-ui.cpp
index e68f2ed..49dceaa 100644
--- a/src/serialization-static-ui.cpp
+++ b/src/serialization-static-ui.cpp
@@ -75,7 +75,7 @@ pk_handle pke_serialize_ui_box(srlztn_serialize_helper *h, pke_ui_box *box) {
kvec.children.bkt = h->bkt;
h->handle_head.itemIndex++;
- compt_a<160==sizeof(pke_ui_box)>();
+ compt_a<192==sizeof(pke_ui_box)>();
if (box->uuid != pk_uuid_zed && box->uuid != pk_uuid_max) {
kve.key = SRLZTN_UI_BOX_UUID;
s = pk_new<char>(37, h->bkt);
@@ -160,6 +160,26 @@ pk_handle pke_serialize_ui_box(srlztn_serialize_helper *h, pke_ui_box *box) {
kve.end = SRLZTN_KVE_END;
pk_arr_append_t(&kvec.arr, kve);
}
+ if (PK_HAS_FLAG(box->flags, PKE_UI_BOX_FLAG_VISIBILITY_INVISIBLE) == false)
+ {
+ kve.key = SRLZTN_UI_BOX_COLOR_BORDER;
+ len = snprintf(NULL, 0, "%f%s%f%s%f%s%f", box->color_border[0], SRLZTN_NUM_SEPARATOR, box->color_border[1], SRLZTN_NUM_SEPARATOR, box->color_border[2], SRLZTN_NUM_SEPARATOR, box->color_border[3]);
+ s = pk_new<char>(len+1, h->bkt);
+ sprintf(s, "%f%s%f%s%f%s%f", box->color_border[0], SRLZTN_NUM_SEPARATOR, box->color_border[1], SRLZTN_NUM_SEPARATOR, box->color_border[2], SRLZTN_NUM_SEPARATOR, box->color_border[3]);
+ kve.val = s;
+ kve.end = SRLZTN_KVE_END;
+ pk_arr_append_t(&kvec.arr, kve);
+ }
+ if (PK_HAS_FLAG(box->flags, PKE_UI_BOX_FLAG_VISIBILITY_INVISIBLE) == false)
+ {
+ kve.key = SRLZTN_UI_BOX_COLOR_BACKGROUND;
+ len = snprintf(NULL, 0, "%f%s%f%s%f%s%f", box->color_background[0], SRLZTN_NUM_SEPARATOR, box->color_background[1], SRLZTN_NUM_SEPARATOR, box->color_background[2], SRLZTN_NUM_SEPARATOR, box->color_background[3]);
+ s = pk_new<char>(len+1, h->bkt);
+ sprintf(s, "%f%s%f%s%f%s%f", box->color_background[0], SRLZTN_NUM_SEPARATOR, box->color_background[1], SRLZTN_NUM_SEPARATOR, box->color_background[2], SRLZTN_NUM_SEPARATOR, box->color_background[3]);
+ kve.val = s;
+ kve.end = SRLZTN_KVE_END;
+ pk_arr_append_t(&kvec.arr, kve);
+ }
pk_arr_append_t(&h->kvp_containers, kvec);
pke_kve_container *kvec_ptr = &h->kvp_containers[h->kvp_containers.next-1];
@@ -196,7 +216,7 @@ void pke_deserialize_ui_box(srlztn_deserialize_helper *h, pke_kve_container *kve
pke_ui_box *parent_box = nullptr;
bx.type_data = nullptr;
- compt_a<160==sizeof(pke_ui_box)>();
+ compt_a<192==sizeof(pke_ui_box)>();
for (i = 0; i < kvec->arr.next; ++i) {
kve = &kvec->arr[i];
if (strstr(SRLZTN_UI_BOX_UUID, kve->key)) {
@@ -312,6 +332,36 @@ void pke_deserialize_ui_box(srlztn_deserialize_helper *h, pke_kve_container *kve
}
continue;
}
+ if (strstr(SRLZTN_UI_BOX_COLOR_BORDER, kve->key)) {
+ starting_char = kve->val;
+ index = 0;
+ do {
+ assert(index < 4);
+ res = pk_stn(&bx.color_border[index], starting_char, &stn_end);
+ if (res != PK_STN_RES_SUCCESS) break;
+ starting_char = stn_end + 1;
+ ++index;
+ } while (*stn_end != '\0');
+ if (res != PK_STN_RES_SUCCESS) {
+ fprintf(stderr, "[pke_deserialize_ui_box] Failed to parse value for: '%s', err: %i\n", SRLZTN_UI_BOX_COLOR_BORDER, res);
+ }
+ continue;
+ }
+ if (strstr(SRLZTN_UI_BOX_COLOR_BACKGROUND, kve->key)) {
+ starting_char = kve->val;
+ index = 0;
+ do {
+ assert(index < 4);
+ res = pk_stn(&bx.color_background[index], starting_char, &stn_end);
+ if (res != PK_STN_RES_SUCCESS) break;
+ starting_char = stn_end + 1;
+ ++index;
+ } while (*stn_end != '\0');
+ if (res != PK_STN_RES_SUCCESS) {
+ fprintf(stderr, "[pke_deserialize_ui_box] Failed to parse value for: '%s', err: %i\n", SRLZTN_UI_BOX_COLOR_BACKGROUND, res);
+ }
+ continue;
+ }
}
// deserialize data
diff --git a/src/serialization.hpp b/src/serialization.hpp
index fe7d427..9e592e0 100644
--- a/src/serialization.hpp
+++ b/src/serialization.hpp
@@ -58,11 +58,15 @@ iccsc SRLZTN_UI_BOX_FLEX_WEIGHT = "FlexWeight:";
iccsc SRLZTN_UI_BOX_FLEX_DIRECTION = "FlexDirection:";
iccsc SRLZTN_UI_BOX_LAYER = "Layer:";
iccsc SRLZTN_UI_BOX_TYPE = "Type:";
+iccsc SRLZTN_UI_BOX_COLOR_BORDER = "ColorBorder:";
+iccsc SRLZTN_UI_BOX_COLOR_BACKGROUND = "ColorBackground:";
iccsc SRLZTN_UI_BOX_DATA_TEXT_FONT_RENDER_UUID = "FontRenderUUID:";
iccsc SRLZTN_UI_FONT_RENDER_UUID = "UUID:";
iccsc SRLZTN_UI_FONT_RENDER_FONT_TYPE_TITLE = "FontTypeTitle:";
iccsc SRLZTN_UI_FONT_RENDER_TEXT_BEGIN = "TextBegin::";
+iccsc SRLZTN_UI_FONT_RENDER_SETTINGS_COLOR_FOREGROUND = "ColorForeground:";
+iccsc SRLZTN_UI_FONT_RENDER_SETTINGS_COLOR_BACKGROUND = "ColorBackground:";
iccsc SRLZTN_UI_FONT_RENDER_SETTINGS_CHAR_SCALE = "CharScale:";
iccsc SRLZTN_UI_FONT_RENDER_SETTINGS_LINE_HEIGHT_SCALE = "LineHeightScale:";
iccsc SRLZTN_UI_FONT_RENDER_SETTINGS_CHAR_SPACING_SCALE = "CharSpacingScale:";
diff --git a/src/static-ui.cpp b/src/static-ui.cpp
index 81e0511..68fd551 100644
--- a/src/static-ui.cpp
+++ b/src/static-ui.cpp
@@ -19,8 +19,8 @@ TypeSafeInt_B(PKE_UI_BOX_FLAG);
struct pke_ui_box_instance_buffer_item {
glm::mat4 pos_scale;
- glm::vec4 border_color;
- glm::vec4 background_color;
+ glm::vec4 color_border;
+ glm::vec4 color_background;
glm::vec2 px_scale;
float depth;
float padding[1];
@@ -242,8 +242,8 @@ void pke_ui_calc_px(pk_arr_t<pke_ui_box_instance_buffer_item> &buffer, pke_ui_fl
pke_ui_box_instance_buffer_item tmp{};
tmp.pos_scale = glm::translate(glm::mat4(1), translate);
tmp.pos_scale = glm::scale(tmp.pos_scale, scale);
- tmp.border_color = glm::vec4(1.0, 0.0, 0.0, 1.0);
- tmp.background_color = glm::vec4(0.2, 0.3, 0.2, 0.5);
+ tmp.color_border = box->color_border;
+ tmp.color_background = box->color_background;
tmp.px_scale.x = (2.0 / (float)Extent.width);
tmp.px_scale.y = (2.0 / (float)Extent.height);
tmp.depth = (float)box->layer;
@@ -471,6 +471,7 @@ void pke_ui_internal_new_typed_box(pke_ui_box *box, const PKE_UI_BOX_TYPE type)
case PKE_UI_BOX_TYPE_INPUT_TEXT:
break;
default:
+ assert(true == false && "unknown pke_ui_box::type");
break;
}
}
diff --git a/src/static-ui.hpp b/src/static-ui.hpp
index 6d5c61c..fa1ecf7 100644
--- a/src/static-ui.hpp
+++ b/src/static-ui.hpp
@@ -23,12 +23,12 @@ TypeSafeInt_H(PKE_UI_BOX_FLAG, uint64_t, 0xFFFFFFFFFFFFFFFF);
// layouts
const PKE_UI_BOX_TYPE PKE_UI_BOX_TYPE_STANDARD
- = PKE_UI_BOX_TYPE(000);
+ = PKE_UI_BOX_TYPE(0);
// TODO columns, rows, tabs, etc
// special (content)
const PKE_UI_BOX_TYPE PKE_UI_BOX_TYPE_TEXT
- = PKE_UI_BOX_TYPE(050);
+ = PKE_UI_BOX_TYPE(50);
// TODO image, render target, etc
// inputs
@@ -74,6 +74,8 @@ struct pke_ui_box : public Entity_Base {
PKE_UI_BOX_TYPE type;
uint8_t flex_direction;
uint8_t layer;
+ glm::vec4 color_border = glm::vec4(1.0, 0.0, 0.0, 1.0);
+ glm::vec4 color_background = glm::vec4(0.2, 0.3, 0.2, 0.5);
union pke_ui_box_type_data *type_data;
struct pke_ui_box_internals {
// the exact px to translate (shader)
diff --git a/tests/pke-test-serialization.cpp b/tests/pke-test-serialization.cpp
index c24faca..7a9ec41 100644
--- a/tests/pke-test-serialization.cpp
+++ b/tests/pke-test-serialization.cpp
@@ -400,6 +400,8 @@ CharSpacingScale:1.000000
SurfaceAreaSize:250;250
SurfaceAreaPos:0;0
SurfaceAreaFlags:0x03
+ColorForeground:0.400000;0.900000;0.500000;0.800000
+ColorBackground:0.000000;0.000000;0.000000;0.000000
FontRender:00000000!00000001
ChildId:00000000!00000000
@@ -418,7 +420,7 @@ UUID:02020202-0202-0202-0202-020202020202
Flags:0x84
PosTopLeft:0.100000;0.100000
MaxSize:0.800000;0.800000
-Type:0x28
+Type:0x32
Layer:0x00
:PKFE:)VOGON";
@@ -459,7 +461,7 @@ int pke_test_serialization_003() {
PKE_TEST_ASSERT(h->kvp_containers.next == 4, err_index);
// FontRenderSettings
PKE_TEST_ASSERT(h->kvp_containers[0].child_handles.next == 0, err_index);
- PKE_TEST_ASSERT(h->kvp_containers[0].arr.next == 6, err_index);
+ PKE_TEST_ASSERT(h->kvp_containers[0].arr.next == 8, err_index);
// FontRender
PKE_TEST_ASSERT(h->kvp_containers[1].child_handles.next == 1, err_index);
PKE_TEST_ASSERT(h->kvp_containers[1].arr.next == 3, err_index);
@@ -473,7 +475,7 @@ int pke_test_serialization_003() {
// 12
for (k = 0; k < h->kvp_containers.next; ++k) {
for (i = 0; i < h->kvp_containers[k].arr.next; ++i) {
- // 12 + (3 * (6 + 3 + 1 + 6))
+ // 12 + (3 * (8 + 3 + 1 + 6))
kve = &h->kvp_containers[k].arr[i];
PKE_TEST_ASSERT(kve->key != nullptr, err_index);
PKE_TEST_ASSERT(kve->val != nullptr, err_index);
@@ -481,7 +483,7 @@ int pke_test_serialization_003() {
}
}
- // 60
+ // 66
PKE_TEST_ASSERT(strstr(test_003_str, s.c_str()) != nullptr, err_index);
pke_serialize_teardown(h);
@@ -512,7 +514,7 @@ int pke_test_deserialization_103() {
PKE_TEST_ASSERT(h->kvp_containers.next == 4, err_index);
// FontRenderSettings
PKE_TEST_ASSERT(h->kvp_containers[0].child_handles.next == 0, err_index);
- PKE_TEST_ASSERT(h->kvp_containers[0].arr.next == 6, err_index);
+ PKE_TEST_ASSERT(h->kvp_containers[0].arr.next == 8, err_index);
// FontRender
PKE_TEST_ASSERT(h->kvp_containers[1].child_handles.next == 1, err_index);
PKE_TEST_ASSERT(h->kvp_containers[1].arr.next == 3, err_index);
@@ -526,7 +528,7 @@ int pke_test_deserialization_103() {
// 12
for (k = 0; k < h->kvp_containers.next; ++k) {
for (i = 0; i < h->kvp_containers[k].arr.next; ++i) {
- // 12 + (3 * (6 + 3 + 1 + 6))
+ // 12 + (3 * (8 + 3 + 1 + 6))
kve = &h->kvp_containers[k].arr[i];
PKE_TEST_ASSERT(kve->key != nullptr, err_index);
PKE_TEST_ASSERT(kve->val != nullptr, err_index);
@@ -538,22 +540,26 @@ int pke_test_deserialization_103() {
FontTypeIndex fti = FontTypeIndex{0};
FontType *fonts = FontType_GetFonts(fti);
- // 60
+ // 66
PKE_TEST_ASSERT(fti > FontTypeIndex{0}, err_index);
PKE_TEST_ASSERT(fonts != nullptr, err_index);
PKE_TEST_ASSERT(fonts->h_render > FontRenderIndex{0}, err_index);
PKE_TEST_ASSERT(fonts->n_render > FontRenderIndex{0}, err_index);
FontRender *fr = &fonts[0].renders[0];
- // 64
+ // 70
PKE_TEST_ASSERT(fr->settings.char_scale == 1.f, err_index);
PKE_TEST_ASSERT(fr->settings.line_height_scale == 1.f, err_index);
PKE_TEST_ASSERT(fr->settings.char_spacing_scale == 1.f, err_index);
PKE_TEST_ASSERT(fr->settings.surface_area_size == glm::ivec2(250,250), err_index);
PKE_TEST_ASSERT(fr->settings.surface_area_pos == glm::ivec2(0,0), err_index);
PKE_TEST_ASSERT(fr->settings.surface_area_type_flags == FONT_RENDER_SURFACE_AREA_TYPE_FLAGS_FLUID, err_index);
+ // auto equal_4 = glm::epsilonEqual(fr->settings.color_foreground, glm::vec4(0.4, 0.9, 0.5, 0.8), epsilon_4);
+ // PKE_TEST_ASSERT(equal_4 == bool_4, err_index);
+ PKE_TEST_ASSERT(fr->settings.color_foreground == glm::vec4(0.4, 0.9, 0.5, 0.8), err_index);
+ PKE_TEST_ASSERT(fr->settings.color_background == glm::vec4(0.0, 0.0, 0.0, 0.0), err_index);
- // 70
+ // 78
PKE_TEST_ASSERT(fr->uuid == uuid_n[1], err_index);
PKE_TEST_ASSERT(fr->text.val != nullptr, err_index);
PKE_TEST_ASSERT(fr->text.val[0] == 'a', err_index);
@@ -562,6 +568,16 @@ int pke_test_deserialization_103() {
PKE_TEST_ASSERT(fr->text.val[3] == 'f', err_index);
PKE_TEST_ASSERT(fr->text.val[4] == '\0', err_index);
+ // 85
+ pke_ui_box_count_T count;
+ pke_ui_box **boxes = pke_ui_get_root_boxes(&count);
+ pke_ui_box *box = boxes[0];
+ PKE_TEST_ASSERT(count == 1, err_index)
+ PKE_TEST_ASSERT(box->internal.h_children == 0, err_index)
+ PKE_TEST_ASSERT(box->type == PKE_UI_BOX_TYPE_TEXT, err_index)
+ PKE_TEST_ASSERT(PK_HAS_FLAG(box->flags, PKE_UI_BOX_FLAG_POSITION_TYPE_DYNAMIC), err_index)
+ PKE_TEST_ASSERT(PK_HAS_FLAG(box->flags, PKE_UI_BOX_FLAG_VISIBILITY_INVISIBLE), err_index)
+
pke_deserialize_teardown(h);
} catch (const std::exception &ex) {
@@ -583,6 +599,8 @@ PosTopLeft:1.000000;1.000000
MaxSize:1278.000000;718.000000
Type:0x00
Layer:0x00
+ColorBorder:1.000000;0.000000;0.000000;1.000000
+ColorBackground:0.200000;0.300000;0.200000;0.500000
UIBox:00000000!00000001
UUID:01010101-0101-0101-0101-010101010101
@@ -592,6 +610,8 @@ PosTopLeft:0.100000;0.100000
MaxSize:0.800000;0.800000
Type:0x00
Layer:0x00
+ColorBorder:1.000000;0.000000;0.000000;1.000000
+ColorBackground:0.200000;0.300000;0.200000;0.500000
:PKFE:)VOGON";
int pke_test_serialization_004() {
@@ -627,15 +647,15 @@ int pke_test_serialization_004() {
PKE_TEST_ASSERT(h->kvp_containers.next == 2, err_index);
// ui box
PKE_TEST_ASSERT(h->kvp_containers[0].child_handles.next == 1, err_index);
- PKE_TEST_ASSERT(h->kvp_containers[0].arr.next == 6, err_index);
+ PKE_TEST_ASSERT(h->kvp_containers[0].arr.next == 8, err_index);
// ui box
PKE_TEST_ASSERT(h->kvp_containers[1].child_handles.next == 0, err_index);
- PKE_TEST_ASSERT(h->kvp_containers[1].arr.next == 7, err_index);
+ PKE_TEST_ASSERT(h->kvp_containers[1].arr.next == 9, err_index);
// 8
for (k = 0; k < h->kvp_containers.next; ++k) {
for (i = 0; i < h->kvp_containers[k].arr.next; ++i) {
- // 8 + (3 * (7 + 6))
+ // 8 + (3 * (9 + 8))
kve = &h->kvp_containers[k].arr[i];
PKE_TEST_ASSERT(kve->key != nullptr, err_index);
PKE_TEST_ASSERT(kve->val != nullptr, err_index);
@@ -643,7 +663,7 @@ int pke_test_serialization_004() {
}
}
- // 47
+ // 59
PKE_TEST_ASSERT(strstr(test_004_str, s.c_str()) != nullptr, err_index);
pke_serialize_teardown(h);
@@ -673,15 +693,15 @@ int pke_test_deserialization_104() {
PKE_TEST_ASSERT(h->kvp_containers.next == 2, err_index);
// ui box
PKE_TEST_ASSERT(h->kvp_containers[0].child_handles.next == 1, err_index);
- PKE_TEST_ASSERT(h->kvp_containers[0].arr.next == 6, err_index);
+ PKE_TEST_ASSERT(h->kvp_containers[0].arr.next == 8, err_index);
// ui box
PKE_TEST_ASSERT(h->kvp_containers[1].child_handles.next == 0, err_index);
- PKE_TEST_ASSERT(h->kvp_containers[1].arr.next == 7, err_index);
+ PKE_TEST_ASSERT(h->kvp_containers[1].arr.next == 9, err_index);
// 8
for (k = 0; k < h->kvp_containers.next; ++k) {
for (i = 0; i < h->kvp_containers[k].arr.next; ++i) {
- // 8 + (3 * (7 + 6))
+ // 8 + (3 * (9 + 8))
kve = &h->kvp_containers[k].arr[i];
PKE_TEST_ASSERT(kve->key != nullptr, err_index);
PKE_TEST_ASSERT(kve->val != nullptr, err_index);
@@ -693,12 +713,12 @@ int pke_test_deserialization_104() {
pke_ui_box_count_T box_count;
pke_ui_box **root_boxes = pke_ui_get_root_boxes(&box_count);
- // 47
+ // 59
PKE_TEST_ASSERT(root_boxes != nullptr, err_index);
PKE_TEST_ASSERT(box_count == 1, err_index);
PKE_TEST_ASSERT(root_boxes[0] != nullptr, err_index);
- // 50
+ // 62
PKE_TEST_ASSERT(root_boxes[0]->uuid == uuid_n[2], err_index);
PKE_TEST_ASSERT(PK_HAS_FLAG(root_boxes[0]->flags, PKE_UI_BOX_FLAG_POSITION_TYPE_STATIC), err_index);
PKE_TEST_ASSERT(root_boxes[0]->pos_top_left == glm::vec2(1.f,1.f), err_index);
@@ -709,9 +729,11 @@ int pke_test_deserialization_104() {
PKE_TEST_ASSERT(root_boxes[0]->internal.h_children == 1, err_index);
PKE_TEST_ASSERT(root_boxes[0]->internal.children != nullptr, err_index);
PKE_TEST_ASSERT(root_boxes[0]->internal.children[0] != nullptr, err_index);
+ PKE_TEST_ASSERT(root_boxes[0]->color_border == glm::vec4(1.0,0.0,0.0,1.0), err_index);
+ PKE_TEST_ASSERT(root_boxes[0]->color_background == glm::vec4(0.2,0.3,0.2,0.5), err_index);
pke_ui_box *box_c = root_boxes[0]->internal.children[0];
- // 60
+ // 74
PKE_TEST_ASSERT(box_c->uuid == uuid_n[1], err_index);
PKE_TEST_ASSERT(PK_HAS_FLAG(box_c->flags, PKE_UI_BOX_FLAG_POSITION_TYPE_DYNAMIC), err_index);
PKE_TEST_ASSERT(box_c->pos_top_left == glm::vec2(0.1,0.1), err_index);
@@ -721,6 +743,8 @@ int pke_test_deserialization_104() {
PKE_TEST_ASSERT(box_c->internal.parent == root_boxes[0], err_index);
PKE_TEST_ASSERT(box_c->internal.h_children == 0, err_index);
PKE_TEST_ASSERT(box_c->internal.children == nullptr, err_index);
+ PKE_TEST_ASSERT(box_c->color_border == glm::vec4(1.0,0.0,0.0,1.0), err_index);
+ PKE_TEST_ASSERT(box_c->color_background == glm::vec4(0.2,0.3,0.2,0.5), err_index);
pke_deserialize_teardown(h);