Add more debug
This commit is contained in:
@@ -120,8 +120,6 @@ void sceneMapRender(scenedata_t *data) {
|
|||||||
cameraPopMatrix();
|
cameraPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void sceneMapRenderEntity(entity_t *entity) {
|
void sceneMapRenderEntity(entity_t *entity) {
|
||||||
assertNotNull(entity, "Entity cannot be NULL");
|
assertNotNull(entity, "Entity cannot be NULL");
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ target_sources(${DUSK_TARGET_NAME}
|
|||||||
PRIVATE
|
PRIVATE
|
||||||
ui.c
|
ui.c
|
||||||
uitext.c
|
uitext.c
|
||||||
uifps.c
|
uidebug.c
|
||||||
uiframe.c
|
uiframe.c
|
||||||
uitextbox.c
|
uitextbox.c
|
||||||
)
|
)
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
#include "assert/assert.h"
|
#include "assert/assert.h"
|
||||||
#include "ui/uifps.h"
|
#include "ui/uidebug.h"
|
||||||
#include "util/memory.h"
|
#include "util/memory.h"
|
||||||
#include "display/tileset/tileset_minogram.h"
|
#include "display/tileset/tileset_minogram.h"
|
||||||
#include "display/screen.h"
|
#include "display/screen.h"
|
||||||
@@ -41,7 +41,7 @@ void uiRender(void) {
|
|||||||
|
|
||||||
// Render UI elements here
|
// Render UI elements here
|
||||||
if(UI.fontTexture.width > 0) {
|
if(UI.fontTexture.width > 0) {
|
||||||
uiFPSRender(UI.fontTileset, &UI.fontTexture);
|
uiDebugRender(UI.fontTileset, &UI.fontTexture);
|
||||||
uiTextboxRender();
|
uiTextboxRender();
|
||||||
}
|
}
|
||||||
cameraPopMatrix();
|
cameraPopMatrix();
|
||||||
|
|||||||
@@ -5,21 +5,24 @@
|
|||||||
* https://opensource.org/licenses/MIT
|
* https://opensource.org/licenses/MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "uifps.h"
|
#include "uidebug.h"
|
||||||
#include "time/time.h"
|
#include "time/time.h"
|
||||||
#include "util/string.h"
|
#include "util/string.h"
|
||||||
#include "ui/uitext.h"
|
#include "ui/uitext.h"
|
||||||
#include "display/screen.h"
|
#include "display/screen.h"
|
||||||
#include "display/spritebatch.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) {
|
void uiDebugRender(const tileset_t *tileset, texture_t *texture) {
|
||||||
if(!UI_FPS_DRAW) return;
|
if(!UI_DEBUG_DRAW) return;
|
||||||
|
|
||||||
char_t buffer[96];
|
char_t buffer[96];
|
||||||
color_t color;
|
color_t color;
|
||||||
|
int32_t w, h, hOffset = 0;
|
||||||
|
|
||||||
|
// FPS Meter
|
||||||
#if TIME_FIXED == 0
|
#if TIME_FIXED == 0
|
||||||
float_t fpsDynamic = TIME.dynamicDelta > 0.0f ? (1.0f / TIME.dynamicDelta) : 0.0f;
|
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;
|
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(
|
snprintf(
|
||||||
buffer,
|
buffer,
|
||||||
sizeof(buffer),
|
sizeof(buffer),
|
||||||
"%.2f/%d",
|
"%.2f/%d/FXD",
|
||||||
TIME.delta * 1000.0f,
|
TIME.delta * 1000.0f,
|
||||||
(int32_t)fps
|
(int32_t)fps
|
||||||
);
|
);
|
||||||
@@ -53,12 +56,40 @@ void uiFPSRender(const tileset_t *tileset, texture_t *texture) {
|
|||||||
COLOR_RED
|
COLOR_RED
|
||||||
);
|
);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int32_t w, h;
|
|
||||||
uiTextMeasure(buffer, tileset, &w, &h);
|
uiTextMeasure(buffer, tileset, &w, &h);
|
||||||
uiTextDraw(
|
uiTextDraw(
|
||||||
SCREEN.width - w, 0,
|
SCREEN.width - w, hOffset,
|
||||||
buffer, color, tileset, texture
|
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();
|
spriteBatchFlush();
|
||||||
}
|
}
|
||||||
@@ -10,9 +10,9 @@
|
|||||||
#include "display/texture.h"
|
#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 tileset The tileset to use for rendering text.
|
||||||
* @param texture The texture associated with the tileset.
|
* @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