Is it really that time again?
This commit is contained in:
@@ -20,7 +20,6 @@ errorret_t renderInit(void) {
|
||||
// Init SDL
|
||||
uint32_t flags = SDL_INIT_VIDEO;
|
||||
#if INPUT_SUPPORT_GAMEPAD
|
||||
printf("Gamepad support enabled.\n");
|
||||
flags |= SDL_INIT_GAMECONTROLLER;
|
||||
#endif
|
||||
|
||||
|
@@ -23,23 +23,20 @@ renderscenecallback_t RENDER_SCENE_CALLBACKS[SCENE_COUNT] = {
|
||||
};
|
||||
|
||||
void renderSceneInit(void) {
|
||||
for (int i = 0; i < SCENE_COUNT; i++) {
|
||||
if (RENDER_SCENE_CALLBACKS[i].init) {
|
||||
for(int32_t i = 0; i < SCENE_COUNT; i++) {
|
||||
if(!RENDER_SCENE_CALLBACKS[i].init) continue;
|
||||
RENDER_SCENE_CALLBACKS[i].init();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void renderSceneDraw(void) {
|
||||
if(RENDER_SCENE_CALLBACKS[SCENE_CURRENT].draw) {
|
||||
if(!RENDER_SCENE_CALLBACKS[SCENE_CURRENT].draw) return;
|
||||
RENDER_SCENE_CALLBACKS[SCENE_CURRENT].draw();
|
||||
}
|
||||
}
|
||||
|
||||
void renderSceneDispose(void) {
|
||||
for (int i = 0; i < SCENE_COUNT; i++) {
|
||||
if (RENDER_SCENE_CALLBACKS[i].dispose) {
|
||||
for(int32_t i = 0; i < SCENE_COUNT; i++) {
|
||||
if(!RENDER_SCENE_CALLBACKS[i].dispose) continue;
|
||||
RENDER_SCENE_CALLBACKS[i].dispose();
|
||||
}
|
||||
}
|
||||
}
|
8
src/dusksdl2/display/ui/rendertextbox.h
Normal file
8
src/dusksdl2/display/ui/rendertextbox.h
Normal file
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Copyright (c) 2025 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
@@ -12,18 +12,46 @@
|
||||
#include "display/spritebatch/spritebatch.h"
|
||||
#include "display/camera/camera.h"
|
||||
|
||||
renderuicallback_t RENDER_UI_CALLBACKS[] = {
|
||||
{
|
||||
.init = renderTextInit,
|
||||
.dispose = renderTextDispose
|
||||
},
|
||||
|
||||
{
|
||||
.draw = renderConsoleDraw,
|
||||
},
|
||||
|
||||
{
|
||||
.draw = renderFPSDraw,
|
||||
},
|
||||
};
|
||||
|
||||
#define RENDER_UI_CALLBACKS_COUNT ( \
|
||||
sizeof(RENDER_UI_CALLBACKS) / sizeof(RENDER_UI_CALLBACKS[0]) \
|
||||
)
|
||||
|
||||
void renderUIInit(void) {
|
||||
renderTextInit();
|
||||
for (int32_t i = 0; i < RENDER_UI_CALLBACKS_COUNT; i++) {
|
||||
if(!RENDER_UI_CALLBACKS[i].init) continue;
|
||||
RENDER_UI_CALLBACKS[i].init();
|
||||
}
|
||||
}
|
||||
|
||||
void renderUIDraw(void) {
|
||||
cameraUIPush();
|
||||
renderConsoleDraw();
|
||||
renderFPSDraw();
|
||||
spriteBatchFlush();
|
||||
|
||||
for (int32_t i = 0; i < RENDER_UI_CALLBACKS_COUNT; i++) {
|
||||
if(!RENDER_UI_CALLBACKS[i].draw) continue;
|
||||
RENDER_UI_CALLBACKS[i].draw();
|
||||
}
|
||||
|
||||
cameraUIPop();
|
||||
}
|
||||
|
||||
void renderUIDispose(void) {
|
||||
renderTextDispose();
|
||||
for (int32_t i = 0; i < RENDER_UI_CALLBACKS_COUNT; i++) {
|
||||
if(!RENDER_UI_CALLBACKS[i].dispose) continue;
|
||||
RENDER_UI_CALLBACKS[i].dispose();
|
||||
}
|
||||
}
|
@@ -8,6 +8,25 @@
|
||||
#pragma once
|
||||
#include "dusksdl2.h"
|
||||
|
||||
typedef struct {
|
||||
void (*init)(void);
|
||||
void (*draw)(void);
|
||||
void (*dispose)(void);
|
||||
} renderuicallback_t;
|
||||
|
||||
extern renderuicallback_t RENDER_UI_CALLBACKS[];
|
||||
|
||||
/**
|
||||
* Initialize the UI rendering system.
|
||||
*/
|
||||
void renderUIInit(void);
|
||||
|
||||
/**
|
||||
* Draw the UI elements.
|
||||
*/
|
||||
void renderUIDraw(void);
|
||||
|
||||
/**
|
||||
* Dispose of the UI rendering system.
|
||||
*/
|
||||
void renderUIDispose(void);
|
Reference in New Issue
Block a user