-
Notifications
You must be signed in to change notification settings - Fork 3
/
Duplicator.h
58 lines (49 loc) · 2.13 KB
/
Duplicator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#pragma once
#include "CKUtils.h"
#include <functional>
#include <map>
struct KEnvironment;
struct EditorInterface;
struct CKObject;
struct CKHook;
struct CKGroup;
struct CKSceneNode;
namespace std::filesystem { class path; };
namespace KFab {
void saveKFab(KEnvironment& kfab, CKObject* mainObj, const std::filesystem::path& path);
CKObject* loadKFab(KEnvironment& kfab, const std::filesystem::path& path);
KEnvironment makeSimilarKEnv(const KEnvironment& kenv);
}
// Hook duplication that clones hooks and related objects by looking through every reference member of the hook.
// Works with some (hopefully most) types of hooks, though some others might need special treatment.
struct HookMemberDuplicator : MemberListener {
public:
HookMemberDuplicator(KEnvironment& kenv, EditorInterface* ui) : kenv(kenv), ui(ui) {}
void doClone(CKHook* hook);
void doExport(CKHook* hook, const std::filesystem::path& path);
void doImport(const std::filesystem::path& path, CKGroup* parent);
private:
KEnvironment& kenv;
KEnvironment* srcEnv; KEnvironment* destEnv;
EditorInterface* ui;
std::map<CKObject*, CKObject*> cloneMap;
std::function<CKObject* (CKObject*, int)> cloneFunction;
MemberFlags currentFlags = MemberFlags::MF_NONE;
template <typename T> T* cloneWrap(T* obj, int sector = -1) {
return (T*)cloneFunction(obj, sector);
}
CKSceneNode* cloneNode(CKSceneNode* original, bool recursive);
static CKGroup* findGroup(CKHook* hook, CKGroup* root);
virtual void reflect(uint8_t& ref, const char* name);
virtual void reflect(uint16_t& ref, const char* name);
virtual void reflect(uint32_t& ref, const char* name);
virtual void reflect(float& ref, const char* name);
virtual void reflectAnyRef(kanyobjref& ref, int clfid, const char* name);
virtual void reflect(Vector3& ref, const char* name);
virtual void reflect(EventNode& ref, const char* name, CKObject* user);
virtual void reflect(MarkerIndex& ref, const char* name);
virtual void reflect(std::string& ref, const char* name);
virtual void setNextFlags(MemberFlags flags) override;
CKHook* doCommon(CKHook* hook);
CKHook* doTransfer(CKHook* hook, KEnvironment* srcEnv, KEnvironment* destEnv);
};