Is it really that time again?
This commit is contained in:
@@ -20,7 +20,6 @@ errorret_t renderInit(void) {
|
|||||||
// Init SDL
|
// Init SDL
|
||||||
uint32_t flags = SDL_INIT_VIDEO;
|
uint32_t flags = SDL_INIT_VIDEO;
|
||||||
#if INPUT_SUPPORT_GAMEPAD
|
#if INPUT_SUPPORT_GAMEPAD
|
||||||
printf("Gamepad support enabled.\n");
|
|
||||||
flags |= SDL_INIT_GAMECONTROLLER;
|
flags |= SDL_INIT_GAMECONTROLLER;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -23,23 +23,20 @@ renderscenecallback_t RENDER_SCENE_CALLBACKS[SCENE_COUNT] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void renderSceneInit(void) {
|
void renderSceneInit(void) {
|
||||||
for (int i = 0; i < SCENE_COUNT; i++) {
|
for(int32_t i = 0; i < SCENE_COUNT; i++) {
|
||||||
if (RENDER_SCENE_CALLBACKS[i].init) {
|
if(!RENDER_SCENE_CALLBACKS[i].init) continue;
|
||||||
RENDER_SCENE_CALLBACKS[i].init();
|
RENDER_SCENE_CALLBACKS[i].init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void renderSceneDraw(void) {
|
void renderSceneDraw(void) {
|
||||||
if(RENDER_SCENE_CALLBACKS[SCENE_CURRENT].draw) {
|
if(!RENDER_SCENE_CALLBACKS[SCENE_CURRENT].draw) return;
|
||||||
RENDER_SCENE_CALLBACKS[SCENE_CURRENT].draw();
|
RENDER_SCENE_CALLBACKS[SCENE_CURRENT].draw();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void renderSceneDispose(void) {
|
void renderSceneDispose(void) {
|
||||||
for (int i = 0; i < SCENE_COUNT; i++) {
|
for(int32_t i = 0; i < SCENE_COUNT; i++) {
|
||||||
if (RENDER_SCENE_CALLBACKS[i].dispose) {
|
if(!RENDER_SCENE_CALLBACKS[i].dispose) continue;
|
||||||
RENDER_SCENE_CALLBACKS[i].dispose();
|
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/spritebatch/spritebatch.h"
|
||||||
#include "display/camera/camera.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) {
|
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) {
|
void renderUIDraw(void) {
|
||||||
cameraUIPush();
|
cameraUIPush();
|
||||||
renderConsoleDraw();
|
|
||||||
renderFPSDraw();
|
for (int32_t i = 0; i < RENDER_UI_CALLBACKS_COUNT; i++) {
|
||||||
spriteBatchFlush();
|
if(!RENDER_UI_CALLBACKS[i].draw) continue;
|
||||||
|
RENDER_UI_CALLBACKS[i].draw();
|
||||||
|
}
|
||||||
|
|
||||||
cameraUIPop();
|
cameraUIPop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void renderUIDispose(void) {
|
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
|
#pragma once
|
||||||
#include "dusksdl2.h"
|
#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);
|
void renderUIInit(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draw the UI elements.
|
||||||
|
*/
|
||||||
void renderUIDraw(void);
|
void renderUIDraw(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dispose of the UI rendering system.
|
||||||
|
*/
|
||||||
void renderUIDispose(void);
|
void renderUIDispose(void);
|
Reference in New Issue
Block a user