This commit is contained in:
2026-07-19 17:31:29 -05:00
parent de0ff2e263
commit ef60ddf6a8
34 changed files with 830 additions and 150 deletions
+1
View File
@@ -14,3 +14,4 @@ add_subdirectory(game)
add_subdirectory(input)
add_subdirectory(item)
add_subdirectory(scene)
add_subdirectory(ui)
+9
View File
@@ -0,0 +1,9 @@
# Copyright (c) 2026 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
target_sources(${DUSK_LIBRARY_TARGET_NAME}
PUBLIC
uitestlabel.c
)
+24
View File
@@ -0,0 +1,24 @@
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
// Game-specific UI elements, appended after the engine's inbuilt elements
// in ui/uielementlist.h.
//
// #include any headers this file's rows need at the top -- they're safe
// to include here even though this file also gets spliced inside
// UI_ELEMENTS[]'s braces, since uielement.c runs a priming pass over this
// same content at file scope first; each such header's own #pragma once
// makes the second (real) inclusion a no-op.
//
// X(init, update, draw, dispose, order) -- pass NULL for any callback
// the element doesn't need. order controls update/draw sequence relative
// to the engine's built-in elements -- see UI_ELEMENT_ORDER_* in
// src/dusk/ui/uielement.h, or use any int32_t value of your own.
#include "ui/uitestlabel.h"
X(uiTestLabelInit, NULL, uiTestLabelDraw, NULL, UI_ELEMENT_ORDER_DEBUG)
+35
View File
@@ -0,0 +1,35 @@
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "uitestlabel.h"
#include "ui/widget/uilabel.h"
#include "display/text/text.h"
#include "display/screen/screen.h"
#include "engine/engine.h"
uilabel_t UI_TEST_LABEL;
errorret_t uiTestLabelInit() {
uiLabelInit(&UI_TEST_LABEL, &FONT_DEFAULT);
uiLabelSetText(&UI_TEST_LABEL, "duskrpg");
errorOk();
}
errorret_t uiTestLabelDraw() {
int32_t versionWidth, versionHeight;
textMeasure(ENGINE.version, &FONT_DEFAULT, &versionWidth, &versionHeight);
errorChain(uiLabelDraw(
&UI_TEST_LABEL,
(float_t)(SCREEN.scanX + SCREEN.scanWidth - UI_TEST_LABEL.width),
(float_t)(
SCREEN.scanY + SCREEN.scanHeight - versionHeight -
UI_TEST_LABEL.height
)
));
errorOk();
}
+24
View File
@@ -0,0 +1,24 @@
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "error/error.h"
/**
* Initializes the test label, a smoke test for the duskrpg-side UI
* element extension point (uielementgame.h).
*
* @return Any error that occurs.
*/
errorret_t uiTestLabelInit();
/**
* Draws the test label above the engine's debug version number.
*
* @return Any error that occurs.
*/
errorret_t uiTestLabelDraw();