Skip to content

Commit

Permalink
feat: improve SaveGame compatibility by properly parsing EventManagers
Browse files Browse the repository at this point in the history
  • Loading branch information
lmichaelis committed Nov 2, 2024
1 parent 3a3b206 commit 3007b61
Show file tree
Hide file tree
Showing 7 changed files with 641 additions and 28 deletions.
78 changes: 75 additions & 3 deletions include/zenkit-capi/CutsceneLibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,26 @@
#pragma once
#include "Archive.h"
#include "Library.h"
#include "Object.h"
#include "Stream.h"
#include "Vfs.h"
#include "vobs/Misc.h"

#ifdef __cplusplus
#include <zenkit/CutsceneLibrary.hh>
using ZkCutsceneLibrary = zenkit::CutsceneLibrary;
using ZkCutsceneBlock = zenkit::CutsceneBlock;
using ZkCutsceneMessage = zenkit::CutsceneMessage;
using ZkCutsceneLibrary = ZkSharedHandle<zenkit::CutsceneLibrary>;
using ZkCutsceneBlock = ZkSharedHandle<zenkit::CutsceneBlock>;
using ZkCutsceneMessage = ZkSharedHandle<zenkit::ConversationMessageEvent>;
using ZkCutscene = ZkSharedHandle<zenkit::Cutscene>;
using ZkCutsceneProps = ZkSharedHandle<zenkit::CutsceneProps>;
using ZkCutsceneContext = ZkSharedHandle<zenkit::CutsceneContext>;
#else
typedef struct ZkInternal_CutsceneLibrary ZkCutsceneLibrary;
typedef struct ZkInternal_CutsceneBlock ZkCutsceneBlock;
typedef struct ZkInternal_CutsceneMessage ZkCutsceneMessage;
typedef struct ZkInternal_Cutscene ZkCutscene;
typedef struct ZkInternal_CutsceneProps ZkCutsceneProps;
typedef struct ZkInternal_CutsceneContext ZkCutsceneContext;
#endif

typedef ZkBool (*ZkCutsceneBlockEnumerator)(void* ctx, ZkCutsceneBlock const* block);
Expand All @@ -35,7 +43,71 @@ ZKC_API void ZkCutsceneLibrary_enumerateBlocks(ZkCutsceneLibrary const* slf, ZkC

ZKC_API ZkString ZkCutsceneBlock_getName(ZkCutsceneBlock const* slf);
ZKC_API ZkCutsceneMessage const* ZkCutsceneBlock_getMessage(ZkCutsceneBlock const* slf);
ZKC_API void ZkCutsceneBlock_setMessage(ZkCutsceneBlock const* slf, ZkCutsceneMessage* msg);
ZKC_API void ZkCutsceneBlock_release(ZkCutsceneBlock const* slf);

ZKC_API uint32_t ZkCutsceneMessage_getType(ZkCutsceneMessage const* slf);
ZKC_API ZkString ZkCutsceneMessage_getText(ZkCutsceneMessage const* slf);
ZKC_API ZkString ZkCutsceneMessage_getName(ZkCutsceneMessage const* slf);
ZKC_API ZkBool ZkCutsceneMessage_getIsHighPriority(ZkCutsceneMessage const* slf);
ZKC_API ZkBool ZkCutsceneMessage_getIsUsed(ZkCutsceneMessage const* slf);
ZKC_API ZkBool ZkCutsceneMessage_getIsDeleted(ZkCutsceneMessage const* slf);

ZKC_API void ZkCutsceneMessage_setType(ZkCutsceneMessage* slf, uint32_t value);
ZKC_API void ZkCutsceneMessage_setText(ZkCutsceneMessage* slf, ZkString value);
ZKC_API void ZkCutsceneMessage_setName(ZkCutsceneMessage* slf, ZkString value);
ZKC_API void ZkCutsceneMessage_setIsHighPriority(ZkCutsceneMessage* slf, ZkBool value);
ZKC_API void ZkCutsceneMessage_setIsUsed(ZkCutsceneMessage* slf, ZkBool value);
ZKC_API void ZkCutsceneMessage_setIsDeleted(ZkCutsceneMessage* slf, ZkBool value);

ZKC_API void ZkCutsceneMessage_release(ZkCutsceneMessage const* slf);

ZKC_API ZkCutsceneProps* ZkCutsceneProps_new(void);
ZKC_API void ZkCutsceneProps_release(ZkCutsceneProps* slf);

ZKC_API ZkString ZkCutsceneProps_getName(ZkCutsceneProps const* slf);
ZKC_API ZkBool ZkCutsceneProps_getIsGlobal(ZkCutsceneProps const* slf);
ZKC_API ZkBool ZkCutsceneProps_getIsLoop(ZkCutsceneProps const* slf);
ZKC_API ZkBool ZkCutsceneProps_getHasToBeTriggered(ZkCutsceneProps const* slf);
ZKC_API float ZkCutsceneProps_getDistance(ZkCutsceneProps const* slf);
ZKC_API float ZkCutsceneProps_getRange(ZkCutsceneProps const* slf);
ZKC_API int32_t ZkCutsceneProps_getLockedBlockCount(ZkCutsceneProps const* slf);
ZKC_API uint32_t ZkCutsceneProps_getRunBehaviour(ZkCutsceneProps const* slf);
ZKC_API int ZkCutsceneProps_getRunBehaviourValue(ZkCutsceneProps const* slf);
ZKC_API ZkString ZkCutsceneProps_getStageName(ZkCutsceneProps const* slf);
ZKC_API ZkString ZkCutsceneProps_getScriptFunctionOnStop(ZkCutsceneProps const* slf);

ZKC_API void ZkCutsceneProps_setName(ZkCutsceneProps* slf, ZkString value);
ZKC_API void ZkCutsceneProps_setIsGlobal(ZkCutsceneProps* slf, ZkBool value);
ZKC_API void ZkCutsceneProps_setIsLoop(ZkCutsceneProps* slf, ZkBool value);
ZKC_API void ZkCutsceneProps_setHasToBeTriggered(ZkCutsceneProps* slf, ZkBool value);
ZKC_API void ZkCutsceneProps_setDistance(ZkCutsceneProps* slf, float value);
ZKC_API void ZkCutsceneProps_setRange(ZkCutsceneProps* slf, float value);
ZKC_API void ZkCutsceneProps_setLockedBlockCount(ZkCutsceneProps* slf, int32_t value);
ZKC_API void ZkCutsceneProps_setRunBehaviour(ZkCutsceneProps* slf, uint32_t value);
ZKC_API void ZkCutsceneProps_setRunBehaviourValue(ZkCutsceneProps* slf, int value);
ZKC_API void ZkCutsceneProps_setStageName(ZkCutsceneProps* slf, ZkString value);
ZKC_API void ZkCutsceneProps_setScriptFunctionOnStop(ZkCutsceneProps* slf, ZkString value);

ZKC_API ZkCutsceneContext* ZkCutsceneContext_new(void);
ZKC_API void ZkCutsceneContext_release(ZkCutsceneContext* slf);

ZKC_API ZkCutsceneProps* ZkCutsceneContext_getProps(ZkCutsceneContext const* slf);
ZKC_API int32_t ZkCutsceneContext_getRoleCount(ZkCutsceneContext const* slf);
ZKC_API int32_t ZkCutsceneContext_getRoleVobCount(ZkCutsceneContext const* slf);
ZKC_API ZkNpc* ZkCutsceneContext_getNpc(ZkCutsceneContext const* slf);
ZKC_API ZkNpc* ZkCutsceneContext_getMainRole(ZkCutsceneContext const* slf);
ZKC_API ZkBool ZkCutsceneContext_getIsCutscene(ZkCutsceneContext const* slf);
ZKC_API int ZkCutsceneContext_getReference(ZkCutsceneContext const* slf);
ZKC_API int ZkCutsceneContext_getActualBlock(ZkCutsceneContext const* slf);
ZKC_API ZkBool ZkCutsceneContext_getWasTriggered(ZkCutsceneContext const* slf);

ZKC_API void ZkCutsceneContext_setProps(ZkCutsceneContext const* slf, ZkCutsceneProps* value);
ZKC_API void ZkCutsceneContext_setRoleCount(ZkCutsceneContext const* slf, int32_t value);
ZKC_API void ZkCutsceneContext_setRoleVobCount(ZkCutsceneContext const* slf, int32_t value);
ZKC_API void ZkCutsceneContext_setNpc(ZkCutsceneContext const* slf, ZkNpc* value);
ZKC_API void ZkCutsceneContext_setMainRole(ZkCutsceneContext const* slf, ZkNpc* value);
ZKC_API void ZkCutsceneContext_setIsCutscene(ZkCutsceneContext const* slf, ZkBool value);
ZKC_API void ZkCutsceneContext_setReference(ZkCutsceneContext const* slf, int value);
ZKC_API void ZkCutsceneContext_setActualBlock(ZkCutsceneContext const* slf, int value);
ZKC_API void ZkCutsceneContext_setWasTriggered(ZkCutsceneContext const* slf, ZkBool value);
3 changes: 2 additions & 1 deletion include/zenkit-capi/World.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright © 2023. GothicKit Contributors
// SPDX-License-Identifier: MIT
#pragma once
#include "CutsceneLibrary.h"
#include "Library.h"
#include "Mesh.h"
#include "Object.h"
Expand Down Expand Up @@ -75,9 +76,9 @@ ZKC_API void ZkCutscenePlayer_del(ZkCutscenePlayer* slf);
ZKC_API int32_t ZkCutscenePlayer_getLastProcessDay(ZkCutscenePlayer const* slf);
ZKC_API int32_t ZkCutscenePlayer_getLastProcessHour(ZkCutscenePlayer const* slf);
ZKC_API int32_t ZkCutscenePlayer_getPlayListCount(ZkCutscenePlayer const* slf);
ZKC_API ZkCutsceneContext* ZkCutscenePlayer_getPlayListItem(ZkCutscenePlayer const* slf, uint32_t index);
ZKC_API void ZkCutscenePlayer_setLastProcessDay(ZkCutscenePlayer* slf, int32_t val);
ZKC_API void ZkCutscenePlayer_setLastProcessHour(ZkCutscenePlayer* slf, int32_t val);
ZKC_API void ZkCutscenePlayer_setPlayListCount(ZkCutscenePlayer* slf, int32_t val);

ZKC_API ZkSkyController* ZkSkyContoller_new(void);
ZKC_API void ZkSkyContoller_del(ZkSkyController* slf);
Expand Down
6 changes: 6 additions & 0 deletions include/zenkit-capi/vobs/VirtualObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#ifdef __cplusplus
#include <zenkit/vobs/VirtualObject.hh>
#include <zenkit/CutsceneLibrary.hh>

using ZkVirtualObject = ZkSharedHandle<zenkit::VirtualObject>;
using ZkVisual = ZkSharedHandle<zenkit::Visual>;
using ZkVisualDecal = ZkSharedHandle<zenkit::VisualDecal>;
Expand All @@ -20,6 +22,7 @@ using ZkAiMove = ZkSharedHandle<zenkit::AiMove>;
using ZkEventManager = ZkSharedHandle<zenkit::EventManager>;

using ZkNpc = ZkSharedHandle<zenkit::VNpc>;
using ZkCutsceneContextFwd = ZkSharedHandle<zenkit::CutsceneContext>;
#else
typedef struct ZkInternal_VirtualObject ZkVirtualObject;
typedef struct ZkInternal_Visual ZkVisual;
Expand All @@ -29,6 +32,7 @@ typedef struct ZkInternal_AiHuman ZkAiHuman;
typedef struct ZkInternal_AiMove ZkAiMove;
typedef struct ZkInternal_EventManager ZkEventManager;
typedef struct ZkInternal_Npc ZkNpc;
typedef struct ZkInternal_CutsceneContext ZkCutsceneContextFwd;
#endif

typedef ZkBool (*ZkVirtualObjectEnumerator)(void* ctx, ZkVirtualObject const* vob);
Expand Down Expand Up @@ -244,3 +248,5 @@ ZKC_API ZkBool ZkEventManager_getCleared(ZkEventManager const* slf);
ZKC_API void ZkEventManager_setCleared(ZkEventManager* slf, ZkBool cleared);
ZKC_API ZkBool ZkEventManager_getActive(ZkEventManager const* slf);
ZKC_API void ZkEventManager_setActive(ZkEventManager* slf, ZkBool active);
ZKC_API ZkCutsceneContextFwd* ZkEventManager_getCutscene(ZkEventManager const* slf);
ZKC_API void ZkEventManager_setCutscene(ZkEventManager* slf, ZkCutsceneContextFwd* cutscene);
Loading

0 comments on commit 3007b61

Please sign in to comment.