Add inventory.
All checks were successful
Build Dusk / run-tests (push) Successful in 2m12s
Build Dusk / build-linux (push) Successful in 1m49s
Build Dusk / build-psp (push) Successful in 1m52s

This commit is contained in:
2026-01-06 07:47:16 -06:00
parent 024ace1078
commit af5bf987c8
91 changed files with 1108 additions and 139 deletions

84
src/scene/scene.c Normal file
View File

@@ -0,0 +1,84 @@
// Copyright (c) 2026 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "scene.h"
#include "assert/assert.h"
#include "util/string.h"
const scene_t SCENES[] = {
};
uint_fast8_t SCENE_CURRENT = 0xFF;
errorret_t sceneInit(void) {
// Initialize the scene subsystem here
errorOk();
}
void sceneUpdate(void) {
const scene_t *current = sceneGetCurrent();
if(current && current->update) {
current->update();
}
}
void sceneRender(void) {
const scene_t *current = sceneGetCurrent();
if(current && current->render) {
current->render();
}
}
void sceneDispose(void) {
const scene_t *current = sceneGetCurrent();
if(current && current->dispose) {
current->dispose();
}
}
errorret_t sceneSet(const scene_t *scene) {
sceneDispose();
if(scene) {
SCENE_CURRENT = (uint_fast8_t)(scene - SCENES);
assertTrue(
SCENE_CURRENT < sizeof(SCENES) / sizeof(scene_t),
"Invalid scene index."
);
if(scene->init) {
errorret_t err = scene->init();
if(err.code != ERROR_OK) SCENE_CURRENT = 0xFF;
errorChain(err);
}
} else {
SCENE_CURRENT = 0xFF;
}
errorOk();
}
const scene_t* sceneGetCurrent(void) {
if(SCENE_CURRENT == 0xFF) return NULL;
assertTrue(
SCENE_CURRENT < sizeof(SCENES) / sizeof(scene_t),
"Invalid current scene index."
);
return &SCENES[SCENE_CURRENT];
}
const scene_t* sceneGetByName(const char_t *name) {
for(uint_fast8_t i = 0; i < sizeof(SCENES) / sizeof(scene_t); i++) {
if(stringCompare(SCENES[i].name, name) == 0) {
return &SCENES[i];
}
}
return NULL;
}