First pass story flags
This commit is contained in:
@@ -23,11 +23,13 @@
|
||||
#include "scene/scene.h"
|
||||
#include "ui/rpg/uiemoji.h"
|
||||
#include "rpg/story/storyflag.h"
|
||||
#include "rpg/story/story.h"
|
||||
|
||||
errorret_t rpgInit(void) {
|
||||
memoryZero(ENTITIES, sizeof(ENTITIES));
|
||||
memoryZero(MAP_AREAS, sizeof(MAP_AREAS));
|
||||
|
||||
errorChain(storyInit());
|
||||
errorChain(itemInit());
|
||||
backpackInit();
|
||||
partyInit();
|
||||
|
||||
@@ -1,19 +1,11 @@
|
||||
# Copyright (c) 2026 Dominic Masters
|
||||
#
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
# Sources
|
||||
target_sources(${DUSK_LIBRARY_TARGET_NAME}
|
||||
PUBLIC
|
||||
story.c
|
||||
storyflag.c
|
||||
)
|
||||
|
||||
# Story Flag Definitions
|
||||
dusk_run_python(
|
||||
dusk_story_defs
|
||||
tools.story
|
||||
--csv ${CMAKE_CURRENT_SOURCE_DIR}/storyflag.csv
|
||||
--output ${DUSK_GENERATED_HEADERS_DIR}/rpg/story/storyflagvalue.h
|
||||
)
|
||||
add_dependencies(${DUSK_LIBRARY_TARGET_NAME} dusk_story_defs)
|
||||
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Copyright (c) 2026 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "story.h"
|
||||
#include "asset/asset.h"
|
||||
#include "asset/loader/assetloader.h"
|
||||
|
||||
errorret_t storyInit(void) {
|
||||
assetentry_t *entry = assetLock(
|
||||
"story/storyflag.jsonc", ASSET_LOADER_TYPE_JSON, NULL
|
||||
);
|
||||
errorret_t ret = assetRequireLoaded(entry);
|
||||
if(errorIsNotOk(ret)) {
|
||||
assetUnlockEntry(entry);
|
||||
errorChain(ret);
|
||||
}
|
||||
|
||||
// TODO: Parse entry->data.json into a storyflagid_t registry, the same
|
||||
// way item.c's itemInit() builds ITEM.defs from items/items.jsonc.
|
||||
|
||||
assetUnlockEntry(entry);
|
||||
errorOk();
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Copyright (c) 2026 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "error/error.h"
|
||||
|
||||
|
||||
/**
|
||||
* Initializes the story subsystem, loading assets/story/storyflag.jsonc.
|
||||
*
|
||||
* @return Any error that occurs.
|
||||
*/
|
||||
errorret_t storyInit(void);
|
||||
@@ -9,15 +9,15 @@
|
||||
#include "assert/assert.h"
|
||||
#include "console/console.h"
|
||||
|
||||
storyflagvalue_t storyFlagGet(const storyflag_t flag) {
|
||||
assertTrue(flag > STORY_FLAG_NULL && flag < STORY_FLAG_COUNT, "Bad Flag");
|
||||
bool_t storyFlagGet(const storyflag_t flag) {
|
||||
assertTrue(flag < STORY_FLAG_COUNT_MAX, "Bad Flag");
|
||||
consolePrint("Story flag get without save implementation");
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
void storyFlagSet(const storyflag_t flag, const storyflagvalue_t value) {
|
||||
assertTrue(flag > STORY_FLAG_NULL && flag < STORY_FLAG_COUNT, "Bad Flag");
|
||||
|
||||
void storyFlagSet(const storyflag_t flag, const bool_t value) {
|
||||
assertTrue(flag < STORY_FLAG_COUNT_MAX, "Bad Flag");
|
||||
|
||||
// TODO: Dirty savefile
|
||||
consolePrint("Story flag set without save implementation");
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
id,description,initial
|
||||
test,"Test flag for debugging purposes",1
|
||||
|
@@ -6,7 +6,18 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "rpg/story/storyflagvalue.h"
|
||||
#include "dusk.h"
|
||||
|
||||
#define STORY_FLAG_BASE_TYPE uint32_t
|
||||
#define STORY_FLAG_BASE_BITS (sizeof(STORY_FLAG_BASE_TYPE) * 8)
|
||||
#define STORY_FLAG_COUNT_MAX 1024
|
||||
#define STORY_FLAG_BASE_COUNT \
|
||||
((STORY_FLAG_COUNT_MAX + STORY_FLAG_BASE_BITS - 1) / STORY_FLAG_BASE_BITS)
|
||||
|
||||
typedef STORY_FLAG_BASE_TYPE storyflag_t;
|
||||
typedef STORY_FLAG_BASE_TYPE storyflaglist_t[STORY_FLAG_BASE_COUNT];
|
||||
typedef uint16_t storyflagid_t;
|
||||
|
||||
|
||||
/**
|
||||
* Gets the value of a story flag. Reads directly from the active save
|
||||
@@ -15,7 +26,7 @@
|
||||
* @param flag The story flag to get.
|
||||
* @return The value of the story flag.
|
||||
*/
|
||||
storyflagvalue_t storyFlagGet(const storyflag_t flag);
|
||||
bool_t storyFlagGet(const storyflag_t flag);
|
||||
|
||||
/**
|
||||
* Sets the value of a story flag. Will dirty the savefile.
|
||||
@@ -23,4 +34,4 @@ storyflagvalue_t storyFlagGet(const storyflag_t flag);
|
||||
* @param flag The story flag to set.
|
||||
* @param value The value to set the story flag to.
|
||||
*/
|
||||
void storyFlagSet(const storyflag_t flag, const storyflagvalue_t value);
|
||||
void storyFlagSet(const storyflag_t flag, const bool_t value);
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2026 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "dusk.h"
|
||||
|
||||
typedef uint8_t storyflagvalue_t;
|
||||
Reference in New Issue
Block a user