Add more debug
This commit is contained in:
@@ -120,8 +120,6 @@ void sceneMapRender(scenedata_t *data) {
|
||||
cameraPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void sceneMapRenderEntity(entity_t *entity) {
|
||||
assertNotNull(entity, "Entity cannot be NULL");
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ target_sources(${DUSK_TARGET_NAME}
|
||||
PRIVATE
|
||||
ui.c
|
||||
uitext.c
|
||||
uifps.c
|
||||
uidebug.c
|
||||
uiframe.c
|
||||
uitextbox.c
|
||||
)
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "ui.h"
|
||||
#include "assert/assert.h"
|
||||
#include "ui/uifps.h"
|
||||
#include "ui/uidebug.h"
|
||||
#include "util/memory.h"
|
||||
#include "display/tileset/tileset_minogram.h"
|
||||
#include "display/screen.h"
|
||||
@@ -41,7 +41,7 @@ void uiRender(void) {
|
||||
|
||||
// Render UI elements here
|
||||
if(UI.fontTexture.width > 0) {
|
||||
uiFPSRender(UI.fontTileset, &UI.fontTexture);
|
||||
uiDebugRender(UI.fontTileset, &UI.fontTexture);
|
||||
uiTextboxRender();
|
||||
}
|
||||
cameraPopMatrix();
|
||||
|
||||
@@ -5,21 +5,24 @@
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "uifps.h"
|
||||
#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_FPS_DRAW = true;
|
||||
bool_t UI_DEBUG_DRAW = true;
|
||||
|
||||
void uiFPSRender(const tileset_t *tileset, texture_t *texture) {
|
||||
if(!UI_FPS_DRAW) return;
|
||||
void uiDebugRender(const tileset_t *tileset, texture_t *texture) {
|
||||
if(!UI_DEBUG_DRAW) return;
|
||||
|
||||
char_t buffer[96];
|
||||
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;
|
||||
@@ -42,7 +45,7 @@ void uiFPSRender(const tileset_t *tileset, texture_t *texture) {
|
||||
snprintf(
|
||||
buffer,
|
||||
sizeof(buffer),
|
||||
"%.2f/%d",
|
||||
"%.2f/%d/FXD",
|
||||
TIME.delta * 1000.0f,
|
||||
(int32_t)fps
|
||||
);
|
||||
@@ -54,11 +57,39 @@ void uiFPSRender(const tileset_t *tileset, texture_t *texture) {
|
||||
);
|
||||
#endif
|
||||
|
||||
int32_t w, h;
|
||||
uiTextMeasure(buffer, tileset, &w, &h);
|
||||
uiTextDraw(
|
||||
SCREEN.width - w, 0,
|
||||
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),
|
||||
"Player: (%d, %d) Dir:%d Anim:%d",
|
||||
player->position.x,
|
||||
player->position.y,
|
||||
(int32_t)player->direction,
|
||||
(int32_t)player->animation
|
||||
);
|
||||
}
|
||||
uiTextMeasure(buffer, tileset, &w, &h);
|
||||
uiTextDraw(
|
||||
SCREEN.width - w, hOffset,
|
||||
buffer, COLOR_WHITE, tileset, texture
|
||||
);
|
||||
hOffset += h;
|
||||
|
||||
spriteBatchFlush();
|
||||
}
|
||||
@@ -10,9 +10,9 @@
|
||||
#include "display/texture.h"
|
||||
|
||||
/**
|
||||
* Renders the FPS counter UI.
|
||||
* Renders the debug information UI element.
|
||||
*
|
||||
* @param tileset The tileset to use for rendering text.
|
||||
* @param texture The texture associated with the tileset.
|
||||
*/
|
||||
void uiFPSRender(const tileset_t *tileset, texture_t *texture);
|
||||
void uiDebugRender(const tileset_t *tileset, texture_t *texture);
|
||||
Reference in New Issue
Block a user