1bd73d69fe
- keyframeGetValue now returns the last keyframe's value for times at or beyond it, fixes a missing util/math.h include, and asserts keyframes are sorted by time; adds test/animation/test_keyframe.c - Adds mainmenu scene/UI and a battle HUD UI frame - Adds save autosave-related fields and battle scene tweaks - Adds headless test coverage for cutscenes, entities, and map areas
94 lines
2.4 KiB
C
94 lines
2.4 KiB
C
/**
|
|
* Copyright (c) 2026 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#include "scene/scene.h"
|
|
#include "assert/assert.h"
|
|
#include "util/memory.h"
|
|
#include "error/error.h"
|
|
#include "save/save.h"
|
|
#include "ui/frame/initial/uiinitialnocard.h"
|
|
#include "ui/frame/initial/uiinitialcreatesave.h"
|
|
|
|
static void sceneInitialCheckSave(void);
|
|
|
|
static void sceneInitialCreateSaveWriteComplete(errorret_t result, void *user) {
|
|
if(errorIsNotOk(result)) errorCatch(errorPrint(result));
|
|
sceneSet(SCENE_TYPE_MAIN_MENU);
|
|
}
|
|
|
|
static void sceneInitialCreateSaveResult(const bool_t create, void *user) {
|
|
if(!create) {
|
|
sceneSet(SCENE_TYPE_MAIN_MENU);
|
|
return;
|
|
}
|
|
|
|
saveWriteSlot(SAVE_ACTIVE_SLOT, sceneInitialCreateSaveWriteComplete, NULL);
|
|
}
|
|
|
|
static void sceneInitialNoCardResult(const bool_t retry, void *user) {
|
|
if(retry) {
|
|
sceneInitialCheckSave();
|
|
return;
|
|
}
|
|
|
|
// The player explicitly acknowledged there's no save device and chose
|
|
// to proceed anyway - stick with that for the rest of the session (see
|
|
// saveMarkTemporary()'s doc comment for why this can't be un-set later).
|
|
saveMarkTemporary();
|
|
sceneSet(SCENE_TYPE_MAIN_MENU);
|
|
}
|
|
|
|
static void sceneInitialLoadComplete(errorret_t result, void *user) {
|
|
if(errorIsNotOk(result) || !saveIsAvailable()) {
|
|
errorCatch(result);
|
|
uiInitialNoCardOpen(sceneInitialNoCardResult, NULL);
|
|
return;
|
|
}
|
|
|
|
if(saveSlotExists(SAVE_ACTIVE_SLOT)) {
|
|
sceneSet(SCENE_TYPE_MAIN_MENU);
|
|
return;
|
|
}
|
|
|
|
uiInitialCreateSaveOpen(sceneInitialCreateSaveResult, NULL);
|
|
}
|
|
|
|
static void sceneInitialCheckSave(void) {
|
|
if(!saveIsAvailable()) {
|
|
uiInitialNoCardOpen(sceneInitialNoCardResult, NULL);
|
|
return;
|
|
}
|
|
|
|
if(saveIsBusy()) return;
|
|
|
|
saveLoadSlot(SAVE_ACTIVE_SLOT, sceneInitialLoadComplete, NULL);
|
|
}
|
|
|
|
errorret_t sceneInitialInit(scenedata_t *sceneData) {
|
|
assertNotNull(sceneData, "Scene data cannot be null");
|
|
memoryZero(&sceneData->initial, sizeof(sceneinitial_t));
|
|
|
|
sceneInitialCheckSave();
|
|
|
|
errorOk();
|
|
}
|
|
|
|
errorret_t sceneInitialUpdate(scenedata_t *sceneData) {
|
|
assertNotNull(sceneData, "Scene data cannot be null");
|
|
errorOk();
|
|
}
|
|
|
|
errorret_t sceneInitialRender(scenedata_t *sceneData) {
|
|
assertNotNull(sceneData, "Scene data cannot be null");
|
|
errorOk();
|
|
}
|
|
|
|
errorret_t sceneInitialDispose(scenedata_t *sceneData) {
|
|
assertNotNull(sceneData, "Scene data cannot be null");
|
|
errorOk();
|
|
}
|