scene crap
This commit is contained in:
@@ -12,10 +12,14 @@
|
||||
#include "display/framebuffer.h"
|
||||
#include "util/string.h"
|
||||
|
||||
#include "scene/scene/scenetest.h"
|
||||
|
||||
scenemanager_t SCENE_MANAGER;
|
||||
|
||||
errorret_t sceneManagerInit(void) {
|
||||
memoryZero(&SCENE_MANAGER, sizeof(scenemanager_t));
|
||||
|
||||
// sceneManagerRegisterScene(&SCENE_TEST);
|
||||
|
||||
errorOk();
|
||||
}
|
||||
@@ -47,13 +51,16 @@ void sceneManagerRegisterScene(scene_t *scene) {
|
||||
|
||||
void sceneManagerSetScene(scene_t *scene) {
|
||||
if(SCENE_MANAGER.current) {
|
||||
if(SCENE_MANAGER.current->sleep) SCENE_MANAGER.current->sleep();
|
||||
|
||||
// TODO: Should dispose?
|
||||
SCENE_MANAGER.current->flags &= ~(
|
||||
SCENE_FLAG_INITIALIZED | SCENE_FLAG_ACTIVE
|
||||
assertTrue(
|
||||
SCENE_MANAGER.current->flags & SCENE_FLAG_INITIALIZED,
|
||||
"Current scene not initialized"
|
||||
);
|
||||
if(SCENE_MANAGER.current->dispose) SCENE_MANAGER.current->dispose();
|
||||
|
||||
SCENE_MANAGER.current->flags &= ~SCENE_FLAG_INITIALIZED;
|
||||
if(SCENE_MANAGER.current->dispose) {
|
||||
SCENE_MANAGER.current->dispose(SCENE_MANAGER.current->data);
|
||||
}
|
||||
}
|
||||
|
||||
SCENE_MANAGER.current = scene;
|
||||
@@ -63,34 +70,25 @@ void sceneManagerSetScene(scene_t *scene) {
|
||||
scene->flags & SCENE_FLAG_INITIALIZED,
|
||||
"Scene not initialized"
|
||||
);
|
||||
|
||||
if(scene->active) scene->active();
|
||||
scene->flags |= SCENE_FLAG_ACTIVE;
|
||||
}
|
||||
}
|
||||
|
||||
void sceneManagerUpdate(void) {
|
||||
if(!SCENE_MANAGER.current) return;
|
||||
|
||||
assertTrue(
|
||||
SCENE_MANAGER.current->flags & SCENE_FLAG_ACTIVE,
|
||||
"Current scene not active"
|
||||
);
|
||||
assertTrue(
|
||||
SCENE_MANAGER.current->flags & SCENE_FLAG_INITIALIZED,
|
||||
"Current scene not initialized"
|
||||
);
|
||||
|
||||
if(SCENE_MANAGER.current->update) SCENE_MANAGER.current->update();
|
||||
if(SCENE_MANAGER.current->update) {
|
||||
SCENE_MANAGER.current->update(SCENE_MANAGER.current->data);
|
||||
}
|
||||
}
|
||||
|
||||
void sceneManagerRender(void) {
|
||||
if(!SCENE_MANAGER.current) return;
|
||||
|
||||
assertTrue(
|
||||
SCENE_MANAGER.current->flags & SCENE_FLAG_ACTIVE,
|
||||
"Current scene not active"
|
||||
);
|
||||
assertTrue(
|
||||
SCENE_MANAGER.current->flags & SCENE_FLAG_INITIALIZED,
|
||||
"Current scene not initialized"
|
||||
@@ -101,14 +99,16 @@ void sceneManagerRender(void) {
|
||||
SCENE_MANAGER.current->background
|
||||
);
|
||||
|
||||
if(SCENE_MANAGER.current->render) SCENE_MANAGER.current->render();
|
||||
if(SCENE_MANAGER.current->render) {
|
||||
SCENE_MANAGER.current->render(SCENE_MANAGER.current->data);
|
||||
}
|
||||
}
|
||||
|
||||
void sceneManagerDispose(void) {
|
||||
for(uint8_t i = 0; i < SCENE_MANAGER.sceneCount; i++) {
|
||||
scene_t *scene = SCENE_MANAGER.scenes[i];
|
||||
if(scene->flags & SCENE_FLAG_INITIALIZED) {
|
||||
scene->dispose();
|
||||
scene->dispose(scene->data);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user