Refactored and simplified lua stuff a lot.
Some checks failed
Build Dusk / run-tests (push) Failing after 1m23s
Build Dusk / build-linux (push) Failing after 1m47s
Build Dusk / build-psp (push) Failing after 1m41s

This commit is contained in:
2026-02-01 21:28:21 -06:00
parent 78e1ae885a
commit 053778a502
53 changed files with 638 additions and 804 deletions

View File

@@ -45,5 +45,5 @@ int moduleMapLoad(lua_State *L) {
void moduleMapSystem(scriptcontext_t *context) {
assertNotNull(context, "Script context cannot be NULL");
scriptContextRegFunc(context, "mapLoad", moduleMapLoad);
lua_register(context->luaState, "mapLoad", moduleMapLoad);
}

View File

@@ -128,8 +128,8 @@ int scriptFuncEntitySetZ(lua_State *L) {
void scriptFuncEntity(scriptcontext_t *context) {
assertNotNull(context, "Script context cannot be NULL");
scriptContextRegFunc(context, "entityAdd", scriptFuncEntityAdd);
scriptContextRegFunc(context, "entitySetX", scriptFuncEntitySetX);
scriptContextRegFunc(context, "entitySetY", scriptFuncEntitySetY);
scriptContextRegFunc(context, "entitySetZ", scriptFuncEntitySetZ);
lua_register(context->luaState, "entityAdd", scriptFuncEntityAdd);
lua_register(context->luaState, "entitySetX", scriptFuncEntitySetX);
lua_register(context->luaState, "entitySetY", scriptFuncEntitySetY);
lua_register(context->luaState, "entitySetZ", scriptFuncEntitySetZ);
}

17
archive/ui/CMakeLists.txt Normal file
View File

@@ -0,0 +1,17 @@
# Copyright (c) 2025 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Sources
target_sources(${DUSK_LIBRARY_TARGET_NAME}
PUBLIC
ui.c
uitext.c
uidebug.c
uiframe.c
uitextbox.c
)
# Subdirs
add_subdirectory(element)

View File

@@ -0,0 +1,9 @@
# Copyright (c) 2025 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Sources
target_sources(${DUSK_LIBRARY_TARGET_NAME}
PUBLIC
)

View File

@@ -0,0 +1,16 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
typedef enum {
UI_ELEMENT_TYPE_NULL,
UI_ELEMENT_TYPE_TEXT,
UI_ELEMENT_TYPE_COUNT,
} uielementtype_t;

67
archive/ui/ui.c Normal file
View File

@@ -0,0 +1,67 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "ui.h"
#include "assert/assert.h"
#include "ui/uidebug.h"
#include "util/memory.h"
#include "display/tileset/tileset_minogram.h"
#include "display/screen.h"
// #include "ui/uitextbox.h"
ui_t UI;
errorret_t uiInit(void) {
memoryZero(&UI, sizeof(ui_t));
cameraInitOrthographic(&UI.camera);
// Initialize UI components here
uiSetFont(&TILESET_MINOGRAM);
errorOk();
}
void uiUpdate(void) {
// Update UI state here
UI.camera.orthographic.left = 0;
UI.camera.orthographic.right = SCREEN.width;
UI.camera.orthographic.top = 0;
UI.camera.orthographic.bottom = SCREEN.height;
// uiTextboxUpdate();
}
void uiRender(void) {
cameraPushMatrix(&UI.camera);
// Render UI elements here
if(UI.fontTexture.width > 0) {
uiDebugRender(UI.fontTileset, &UI.fontTexture);
}
cameraPopMatrix();
}
errorret_t uiSetFont(const tileset_t *fontTileset) {
if(UI.fontTexture.width > 0) {
textureDispose(&UI.fontTexture);
UI.fontTexture.width = -1;
}
assertNotNull(fontTileset, "Font tileset cannot be NULL.");
UI.fontTileset = fontTileset;
errorChain(assetLoad(UI.fontTileset->image, &UI.fontTexture));
errorOk();
}
void uiDispose(void) {
if(UI.fontTexture.width > 0) {
textureDispose(&UI.fontTexture);
UI.fontTexture.width = -1;
}
}

51
archive/ui/ui.h Normal file
View File

@@ -0,0 +1,51 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "asset/asset.h"
#include "display/texture.h"
#include "display/tileset/tileset.h"
#include "display/camera/camera.h"
typedef struct {
camera_t camera;
texture_t fontTexture;
const tileset_t *fontTileset;
} ui_t;
extern ui_t UI;
/**
* Initializes the UI system, loading necessary resources.
*
* @return An errorret_t indicating success or failure.
*/
errorret_t uiInit(void);
/**
* Updates the UI state, handling user interactions and animations.
*/
void uiUpdate(void);
/**
* Renders the UI elements to the screen.
*/
void uiRender(void);
/**
* Sets the font tileset for UI text rendering.
*
* @param fontTileset Pointer to the tileset to use for UI fonts.
*
* @return An errorret_t indicating success or failure.
*/
errorret_t uiSetFont(const tileset_t *fontTileset);
/**
* Cleans up and frees all UI resources.
*/
void uiDispose(void);

98
archive/ui/uidebug.c Normal file
View File

@@ -0,0 +1,98 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "uidebug.h"
#include "time/time.h"
#include "util/string.h"
#include "ui/uitext.h"
#include "display/screen.h"
#include "display/spritebatch.h"
// #include "rpg/entity/entity.h"
bool_t UI_DEBUG_DRAW = true;
void uiDebugRender(const tileset_t *tileset, texture_t *texture) {
if(!UI_DEBUG_DRAW) return;
char_t buffer[128];
color_t color;
int32_t w, h, hOffset = 0;
// FPS Meter
#if TIME_FIXED == 0
float_t fpsDynamic = TIME.dynamicDelta > 0.0f ? (1.0f / TIME.dynamicDelta) : 0.0f;
float_t fpsFixed = TIME.delta > 0.0f ? (1.0f / TIME.delta) : 0.0f;
snprintf(
buffer,
sizeof(buffer),
"%.2f/%.2f/%d/%d",
TIME.dynamicDelta * 1000.0f,
TIME.delta * 1000.0f,
TIME.dynamicUpdate,
(int32_t)fpsDynamic
);
color = (
fpsDynamic >= 50.0f ? COLOR_GREEN :
fpsDynamic >= 30.0f ? COLOR_YELLOW :
COLOR_RED
);
#else
float_t fps = TIME.delta > 0.0f ? (1.0f / TIME.delta) : 0.0f;
snprintf(
buffer,
sizeof(buffer),
"%.2f/%d/FXD",
TIME.delta * 1000.0f,
(int32_t)fps
);
color = (
fps >= 50.0f ? COLOR_GREEN :
fps >= 30.0f ? COLOR_YELLOW :
COLOR_RED
);
#endif
uiTextMeasure(buffer, tileset, &w, &h);
uiTextDraw(
SCREEN.width - w, hOffset,
buffer, color, tileset, texture
);
hOffset += h;
// Player position
// entity_t *player = NULL;
// for(uint8_t i = 0; i < ENTITY_COUNT; i++) {
// if(ENTITIES[i].type != ENTITY_TYPE_PLAYER) continue;
// player = &ENTITIES[i];
// break;
// }
// if(player == NULL) {
// snprintf(buffer, sizeof(buffer), "Player: N/A");
// } else {
// snprintf(
// buffer,
// sizeof(buffer),
// "%d,%d,%d/%d/%d",
// player->position.x,
// player->position.y,
// player->position.z,
// (int32_t)player->direction,
// (int32_t)player->animation
// );
// }
// uiTextMeasure(buffer, tileset, &w, &h);
// uiTextDraw(
// SCREEN.width - w, hOffset,
// buffer, COLOR_GREEN, tileset, texture
// );
// hOffset += h;
spriteBatchFlush();
}

18
archive/ui/uidebug.h Normal file
View File

@@ -0,0 +1,18 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "display/tileset/tileset.h"
#include "display/texture.h"
/**
* Renders the debug information UI element.
*
* @param tileset The tileset to use for rendering text.
* @param texture The texture associated with the tileset.
*/
void uiDebugRender(const tileset_t *tileset, texture_t *texture);

390
archive/ui/uiframe.c Normal file
View File

@@ -0,0 +1,390 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "uiframe.h"
#include "display/spritebatch.h"
#include "assert/assert.h"
#include <math.h>
void uiFrameDraw(
const float_t x,
const float_t y,
const float_t width,
const float_t height,
const tileset_t *tileset,
const uint16_t column,
const uint16_t row,
const bool_t drawInner,
texture_t *texture
) {
assertNotNull(tileset, "Tileset cannot be NULL");
assertNotNull(texture, "Texture cannot be NULL");
if(height <= 0 || width <= 0) return;
// Top-Left
vec4 uv;
tilesetPositionGetUV(
tileset,
column,
row,
uv
);
spriteBatchPush(
texture,
x, y,
x + tileset->tileWidth,
y + tileset->tileHeight,
COLOR_WHITE,
uv[0], uv[1], uv[2], uv[3]
);
// Top-Center
tilesetPositionGetUV(
tileset,
column + 1,
row,
uv
);
spriteBatchPush(
texture,
x + tileset->tileWidth, y,
x + width - tileset->tileWidth, y + tileset->tileHeight,
COLOR_WHITE,
uv[0], uv[1], uv[2], uv[3]
);
// Top-Right
tilesetPositionGetUV(
tileset,
column + 2,
row,
uv
);
spriteBatchPush(
texture,
x + width - tileset->tileWidth, y,
x + width, y + tileset->tileHeight,
COLOR_WHITE,
uv[0], uv[1], uv[2], uv[3]
);
// Middle-Left
tilesetPositionGetUV(
tileset,
column,
row + 1,
uv
);
spriteBatchPush(
texture,
x, y + tileset->tileHeight,
x + tileset->tileWidth, y + height - tileset->tileHeight,
COLOR_WHITE,
uv[0], uv[1], uv[2], uv[3]
);
// Middle-Center
if(drawInner) {
tilesetPositionGetUV(
tileset,
column + 1,
row + 1,
uv
);
spriteBatchPush(
texture,
x + tileset->tileWidth, y + tileset->tileHeight,
x + width - tileset->tileWidth, y + height - tileset->tileHeight,
COLOR_WHITE,
uv[0], uv[1], uv[2], uv[3]
);
}
// Middle-Right
tilesetPositionGetUV(
tileset,
column + 2,
row + 1,
uv
);
spriteBatchPush(
texture,
x + width - tileset->tileWidth, y + tileset->tileHeight,
x + width, y + height - tileset->tileHeight,
COLOR_WHITE,
uv[0], uv[1], uv[2], uv[3]
);
// Bottom-Left
tilesetPositionGetUV(
tileset,
column,
row + 2,
uv
);
spriteBatchPush(
texture,
x, y + height - tileset->tileHeight,
x + tileset->tileWidth, y + height,
COLOR_WHITE,
uv[0], uv[1], uv[2], uv[3]
);
// Bottom-Center
tilesetPositionGetUV(
tileset,
column + 1,
row + 2,
uv
);
spriteBatchPush(
texture,
x + tileset->tileWidth, y + height - tileset->tileHeight,
x + width - tileset->tileWidth, y + height,
COLOR_WHITE,
uv[0], uv[1], uv[2], uv[3]
);
// Bottom-Right
tilesetPositionGetUV(
tileset,
column + 2,
row + 2,
uv
);
spriteBatchPush(
texture,
x + width - tileset->tileWidth, y + height - tileset->tileHeight,
x + width, y + height,
COLOR_WHITE,
uv[0], uv[1], uv[2], uv[3]
);
}
void uiFrameDrawTiled(
const float_t x,
const float_t y,
const float_t width,
const float_t height,
const tileset_t *tileset,
const uint16_t column,
const uint16_t row,
const bool_t drawInner,
texture_t *texture
) {
assertNotNull(tileset, "Tileset cannot be NULL");
assertNotNull(texture, "Texture cannot be NULL");
if(height <= 0 || width <= 0) return;
uint32_t segmentsX, segmentsY;
float_t remainderX, remainderY;
segmentsX = (width - (tileset->tileWidth * 2)) / tileset->tileWidth;
segmentsY = (height - (tileset->tileHeight * 2)) / tileset->tileHeight;
remainderX = fmodf(width - (tileset->tileWidth * 2), tileset->tileWidth);
remainderY = fmodf(height - (tileset->tileHeight * 2), tileset->tileHeight);
// Corners
vec4 uv;
// Top-Left
tilesetPositionGetUV(
tileset,
column,
row,
uv
);
spriteBatchPush(
texture,
x, y,
x + tileset->tileWidth,
y + tileset->tileHeight,
COLOR_WHITE,
uv[0], uv[1], uv[2], uv[3]
);
// Top-Right
tilesetPositionGetUV(
tileset,
column + 2,
row,
uv
);
spriteBatchPush(
texture,
x + width - tileset->tileWidth, y,
x + width, y + tileset->tileHeight,
COLOR_WHITE,
uv[0], uv[1], uv[2], uv[3]
);
// Bottom-Left
tilesetPositionGetUV(
tileset,
column,
row + 2,
uv
);
spriteBatchPush(
texture,
x, y + height - tileset->tileHeight,
x + tileset->tileWidth, y + height,
COLOR_WHITE,
uv[0], uv[1], uv[2], uv[3]
);
// Bottom-Right
tilesetPositionGetUV(
tileset,
column + 2,
row + 2,
uv
);
spriteBatchPush(
texture,
x + width - tileset->tileWidth, y + height - tileset->tileHeight,
x + width, y + height,
COLOR_WHITE,
uv[0], uv[1], uv[2], uv[3]
);
// Top and Bottom Edges (Tiled)
tilesetPositionGetUV(tileset, column + 1, row, uv); // Top edge
float_t edgeX = x + tileset->tileWidth;
for(uint32_t i = 0; i < segmentsX; ++i, edgeX += tileset->tileWidth) {
spriteBatchPush(
texture,
edgeX, y,
edgeX + tileset->tileWidth, y + tileset->tileHeight,
COLOR_WHITE,
uv[0], uv[1], uv[2], uv[3]
);
}
if(remainderX) {
spriteBatchPush(
texture,
edgeX, y,
edgeX + remainderX, y + tileset->tileHeight,
COLOR_WHITE,
uv[0], uv[1], uv[2], uv[3]
);
}
tilesetPositionGetUV(tileset, column + 1, row + 2, uv); // Bottom edge
edgeX = x + tileset->tileWidth;
for(uint32_t i = 0; i < segmentsX; ++i, edgeX += tileset->tileWidth) {
spriteBatchPush(
texture,
edgeX, y + height - tileset->tileHeight,
edgeX + tileset->tileWidth, y + height,
COLOR_WHITE,
uv[0], uv[1], uv[2], uv[3]
);
}
if(remainderX) {
spriteBatchPush(
texture,
edgeX, y + height - tileset->tileHeight,
edgeX + remainderX, y + height,
COLOR_WHITE,
uv[0], uv[1], uv[2], uv[3]
);
}
// Left and Right Edges (Tiled)
tilesetPositionGetUV(tileset, column, row + 1, uv); // Left edge
float_t edgeY = y + tileset->tileHeight;
for(uint32_t i = 0; i < segmentsY; ++i, edgeY += tileset->tileHeight) {
spriteBatchPush(
texture,
x, edgeY,
x + tileset->tileWidth, edgeY + tileset->tileHeight,
COLOR_WHITE,
uv[0], uv[1], uv[2], uv[3]
);
}
if(remainderY) {
spriteBatchPush(
texture,
x, edgeY,
x + tileset->tileWidth, edgeY + remainderY,
COLOR_WHITE,
uv[0], uv[1], uv[2], uv[3]
);
}
tilesetPositionGetUV(tileset, column + 2, row + 1, uv); // Right edge
edgeY = y + tileset->tileHeight;
for(uint32_t i = 0; i < segmentsY; ++i, edgeY += tileset->tileHeight) {
spriteBatchPush(
texture,
x + width - tileset->tileWidth, edgeY,
x + width, edgeY + tileset->tileHeight,
COLOR_WHITE,
uv[0], uv[1], uv[2], uv[3]
);
}
if(remainderY) {
spriteBatchPush(
texture,
x + width - tileset->tileWidth, edgeY,
x + width, edgeY + remainderY,
COLOR_WHITE,
uv[0], uv[1], uv[2], uv[3]
);
}
// Center (Tiled)
if(!drawInner) return;
tilesetPositionGetUV(tileset, column + 1, row + 1, uv); // Center tile
float_t centerY = y + tileset->tileHeight;
for(uint32_t j = 0; j < segmentsY; ++j, centerY += tileset->tileHeight) {
float_t centerX = x + tileset->tileWidth;
for(uint32_t i = 0; i < segmentsX; ++i, centerX += tileset->tileWidth) {
spriteBatchPush(
texture,
centerX, centerY,
centerX + tileset->tileWidth, centerY + tileset->tileHeight,
COLOR_WHITE,
uv[0], uv[1], uv[2], uv[3]
);
}
if(remainderX) {
spriteBatchPush(
texture,
centerX, centerY,
centerX + remainderX, centerY + tileset->tileHeight,
COLOR_WHITE,
uv[0], uv[1], uv[2], uv[3]
);
}
}
if(remainderY) {
float_t centerX = x + tileset->tileWidth;
for(uint32_t i = 0; i < segmentsX; ++i, centerX += tileset->tileWidth) {
spriteBatchPush(
texture,
centerX, centerY,
centerX + tileset->tileWidth, centerY + remainderY,
COLOR_WHITE,
uv[0], uv[1], uv[2], uv[3]
);
}
if(remainderX) {
spriteBatchPush(
texture,
centerX, centerY,
centerX + remainderX, centerY + remainderY,
COLOR_WHITE,
uv[0], uv[1], uv[2], uv[3]
);
}
}
}

61
archive/ui/uiframe.h Normal file
View File

@@ -0,0 +1,61 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "display/tileset/tileset.h"
#include "display/texture.h"
/**
* Draw a UI Frame (using the 9-slice technique).
*
* @param x The x position to draw the frame at.
* @param y The y position to draw the frame at.
* @param width The width of the frame.
* @param height The height of the frame.
* @param tileset The tileset to use for rendering the frame.
* @param column The column in the tileset to use for the frame.
* @param row The row in the tileset to use for the frame.
* @param drawInner Whether to draw the inner area.
* @param texture The texture associated with the tileset.
*/
void uiFrameDraw(
const float_t x,
const float_t y,
const float_t width,
const float_t height,
const tileset_t *tileset,
const uint16_t column,
const uint16_t row,
const bool_t drawInner,
texture_t *texture
);
/**
* Draw a tiled UI Frame (using the 9-slice technique). This will tile the
* center components to allow them to repeat without distortion.
*
* @param x The x position to draw the frame at.
* @param y The y position to draw the frame at.
* @param width The width of the frame.
* @param height The height of the frame.
* @param tileset The tileset to use for rendering the frame.
* @param column The column in the tileset to use for the frame.
* @param row The row in the tileset to use for the frame.
* @param drawInner Whether to draw the inner tiled area.
* @param texture The texture associated with the tileset.
*/
void uiFrameDrawTiled(
const float_t x,
const float_t y,
const float_t width,
const float_t height,
const tileset_t *tileset,
const uint16_t column,
const uint16_t row,
const bool_t drawInner,
texture_t *texture
);

111
archive/ui/uitext.c Normal file
View File

@@ -0,0 +1,111 @@
// /**
// * Copyright (c) 2025 Dominic Masters
// *
// * This software is released under the MIT License.
// * https://opensource.org/licenses/MIT
// */
#include "uitext.h"
#include "assert/assert.h"
#include "util/memory.h"
#include "display/spritebatch.h"
void uiTextDrawChar(
const float_t x,
const float_t y,
const char_t c,
const color_t color,
const tileset_t *tileset,
texture_t *texture
) {
int32_t tileIndex = (int32_t)(c) - UI_TEXT_CHAR_START;
if(tileIndex < 0 || tileIndex >= tileset->tileCount) {
tileIndex = ((int32_t)'@') - UI_TEXT_CHAR_START;
}
assertTrue(
tileIndex >= 0 && tileIndex <= tileset->tileCount,
"Character is out of bounds for font tiles"
);
vec4 uv;
tilesetTileGetUV(tileset, tileIndex, uv);
spriteBatchPush(
texture,
x, y,
x + tileset->tileWidth,
y + tileset->tileHeight,
color,
uv[0], uv[1], uv[2], uv[3]
);
}
void uiTextDraw(
const float_t x,
const float_t y,
const char_t *text,
const color_t color,
const tileset_t *tileset,
texture_t *texture
) {
assertNotNull(text, "Text cannot be NULL");
float_t posX = x;
float_t posY = y;
char_t c;
int32_t i = 0;
while((c = text[i++]) != '\0') {
if(c == '\n') {
posX = x;
posY += tileset->tileHeight;
continue;
}
if(c == ' ') {
posX += tileset->tileWidth;
continue;
}
uiTextDrawChar(posX, posY, c, color, tileset, texture);
posX += tileset->tileWidth;
}
}
void uiTextMeasure(
const char_t *text,
const tileset_t *tileset,
int32_t *outWidth,
int32_t *outHeight
) {
assertNotNull(text, "Text cannot be NULL");
assertNotNull(outWidth, "Output width pointer cannot be NULL");
assertNotNull(outHeight, "Output height pointer cannot be NULL");
int32_t width = 0;
int32_t height = tileset->tileHeight;
int32_t lineWidth = 0;
char_t c;
int32_t i = 0;
while((c = text[i++]) != '\0') {
if(c == '\n') {
if(lineWidth > width) {
width = lineWidth;
}
lineWidth = 0;
height += tileset->tileHeight;
continue;
}
lineWidth += tileset->tileWidth;
}
if(lineWidth > width) {
width = lineWidth;
}
*outWidth = width;
*outHeight = height;
}

66
archive/ui/uitext.h Normal file
View File

@@ -0,0 +1,66 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "asset/asset.h"
#include "display/texture.h"
#include "display/tileset/tileset_minogram.h"
#define UI_TEXT_CHAR_START '!'
/**
* Draws a single character at the specified position.
*
* @param x The x-coordinate to draw the character at.
* @param y The y-coordinate to draw the character at.
* @param c The character to draw.
* @param color The color to draw the character in.
* @param tileset Font tileset to use for rendering.
* @param texture Texture containing the font tileset image.
*/
void uiTextDrawChar(
const float_t x,
const float_t y,
const char_t c,
const color_t color,
const tileset_t *tileset,
texture_t *texture
);
/**
* Draws a string of text at the specified position.
*
* @param x The x-coordinate to draw the text at.
* @param y The y-coordinate to draw the text at.
* @param text The null-terminated string of text to draw.
* @param color The color to draw the text in.
* @param tileset Font tileset to use for rendering.
* @param texture Texture containing the font tileset image.
*/
void uiTextDraw(
const float_t x,
const float_t y,
const char_t *text,
const color_t color,
const tileset_t *tileset,
texture_t *texture
);
/**
* Measures the width and height of the given text string when rendered.
*
* @param text The null-terminated string of text to measure.
* @param tileset Font tileset to use for measurement.
* @param outWidth Pointer to store the measured width in pixels.
* @param outHeight Pointer to store the measured height in pixels.
*/
void uiTextMeasure(
const char_t *text,
const tileset_t *tileset,
int32_t *outWidth,
int32_t *outHeight
);

45
archive/ui/uitextbox.c Normal file
View File

@@ -0,0 +1,45 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "uitextbox.h"
#include "ui/ui.h"
#include "ui/uitext.h"
// #include "rpg/rpgtextbox.h"
#include "display/screen.h"
#include "display/spritebatch.h"
#include "input/input.h"
// void uiTextboxUpdate() {
// if(!rpgTextboxIsVisible()) return;
// if(inputPressed(INPUT_ACTION_ACCEPT)) {
// rpgTextboxHide();
// }
// }
// void uiTextboxRender() {
// if(!rpgTextboxIsVisible()) return;
// const char_t *text = RPG_TEXTBOX.text;
// int32_t textWidth, textHeight;
// uiTextMeasure(text, UI.fontTileset, &textWidth, &textHeight);
// float_t y = 0;
// if(RPG_TEXTBOX.position == RPG_TEXTBOX_POS_BOTTOM) {
// y = SCREEN.height - (float_t)textHeight;
// }
// spriteBatchPush(
// NULL,
// 0.0f, y,
// (float_t)SCREEN.width, (float_t)(y + textHeight),
// COLOR_BLACK,
// 0.0f, 0.0f, 1.0f, 1.0f
// );
// uiTextDraw(0, y, text, COLOR_RED, UI.fontTileset, &UI.fontTexture);
// }

19
archive/ui/uitextbox.h Normal file
View File

@@ -0,0 +1,19 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "dusk.h"
/**
* Updates the RPG textbox state.
*/
void uiTextboxUpdate();
/**
* Draws the RPG textbox if it is visible.
*/
void uiTextboxRender();

View File

@@ -0,0 +1,9 @@
# Copyright (c) 2026 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Sources
target_sources(${DUSK_LIBRARY_TARGET_NAME}
PUBLIC
)

8
archive/ui2/ui2.c Normal file
View File

@@ -0,0 +1,8 @@
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "ui2.h"

10
archive/ui2/ui2.h Normal file
View File

@@ -0,0 +1,10 @@
// Copyright (c) 2026 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "dusk.h"
// Two kinds of UI elements, those that are scripted (with a state, logic, etc)
// and those that are draw only (rectangle, text, etc).