add environment exporter(semi-finished)

This commit is contained in:
yyc12345 2020-04-19 00:08:33 +08:00
parent 06df7ded3c
commit 896a821fe5
9 changed files with 335 additions and 143 deletions

View File

@ -93,6 +93,7 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="database.h" />
<ClInclude Include="env_export.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="script_export.h" />
<ClInclude Include="vt_menu.h" />
@ -100,6 +101,7 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="database.cpp" />
<ClCompile Include="env_export.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="script_export.cpp" />
<ClCompile Include="vt_menu.cpp" />

View File

@ -30,6 +30,9 @@
<ClInclude Include="script_export.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="env_export.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
@ -44,6 +47,9 @@
<ClCompile Include="script_export.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="env_export.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="SuperScriptMaterializer.def">

View File

@ -2,7 +2,7 @@
#pragma region helper
void dbDataStructHelper::init(CKParameterManager* paramManager) {
void dbScriptDataStructHelper::init(CKParameterManager* paramManager) {
_dbCKBehavior = new dbCKBehavior();
_dbCKScript = new dbCKScript();
_db_pTarget = new db_pTarget();
@ -19,7 +19,7 @@ void dbDataStructHelper::init(CKParameterManager* paramManager) {
_parameterManager = paramManager;
}
void dbDataStructHelper::dispose() {
void dbScriptDataStructHelper::dispose() {
delete _dbCKBehavior;
delete _dbCKScript;
delete _db_pTarget;
@ -36,6 +36,14 @@ void dbDataStructHelper::dispose() {
_parameterManager = NULL;
}
void dbEnvDataStructHelper::init() {
_db_envOp = new db_envOp;
}
void dbEnvDataStructHelper::dispose() {
delete _db_envOp;
}
#pragma endregion
@ -51,68 +59,8 @@ void database::open(const char* file) {
result = sqlite3_open(file, &db);
if (result != SQLITE_OK) goto fail;
result = sqlite3_exec(db, "PRAGMA synchronous = OFF;", NULL, NULL, &errmsg);
if (result != SQLITE_OK) goto fail;
if (!init()) goto fail;
//init table
result = sqlite3_exec(db,
"CREATE TABLE script([thisobj] INTEGER, [name] TEXT, [index] INTEGER, [behavior] INTEGER);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) goto fail;
result = sqlite3_exec(db,
"CREATE TABLE behavior([thisobj] INTEGER, [name] TEXT, [type] INTEGER, [proto_name] TEXT, [proto_guid] TEXT, [flags] INTEGER, [priority] INTEGER, [version] INTEGER, [pin_count] TEXT, [parent] INTEGER);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) goto fail;
result = sqlite3_exec(db,
"CREATE TABLE pTarget([thisobj] INTEGER, [name] TEXT, [type] TEXT, [type_guid] TEXT, [belong_to] INTEGER, [direct_source] INTEGER, [shard_source] INTEGER);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) goto fail;
result = sqlite3_exec(db,
"CREATE TABLE pIn([thisobj] INTEGER, [index] INTEGER, [name] TEXT, [type] TEXT, [type_guid] TEXT, [belong_to] INTEGER, [direct_source] INTEGER, [shard_source] INTEGER);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) goto fail;
result = sqlite3_exec(db,
"CREATE TABLE pOut([thisobj] INTEGER, [index] INTEGER, [name] TEXT, [type] TEXT, [type_guid] TEXT, [belong_to] INTEGER);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) goto fail;
result = sqlite3_exec(db,
"CREATE TABLE bIn([thisobj] INTEGER, [index] INTEGER, [name] TEXT, [belong_to] INTEGER);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) goto fail;
result = sqlite3_exec(db,
"CREATE TABLE bOut([thisobj] INTEGER, [index] INTEGER, [name] TEXT, [belong_to] INTEGER);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) goto fail;
result = sqlite3_exec(db,
"CREATE TABLE bLink([input] INTEGER, [output] INTEGER, [delay] INTEGER, [input_obj] INTEGER, [input_type] INTEGER, [input_index] INETEGR, [output_obj] INTEGER, [output_type] INTEGER, [output_index] INETEGR, [belong_to] INTEGER);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) goto fail;
result = sqlite3_exec(db,
"CREATE TABLE pLocal([thisobj] INTEGER, [name] TEXT, [type] TEXT, [type_guid] TEXT, [is_setting] INTEGER, [belong_to] INTEGER);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) goto fail;
result = sqlite3_exec(db,
"CREATE TABLE pLocalData([field] TEXT, [data] TEXT, [belong_to] INTEGER);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) goto fail;
result = sqlite3_exec(db,
"CREATE TABLE pLink([input] INTEGER, [output] INTEGER, [input_obj] INTEGER, [input_type] INTEGER, [input_is_bb] INTEGER, [input_index] INETEGR, [output_obj] INTEGER, [output_type] INTEGER, [output_is_bb] INTEGER, [output_index] INETEGR, [belong_to] INTEGER);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) goto fail;
result = sqlite3_exec(db,
"CREATE TABLE pOper([thisobj] INTEGER, [op] TEXT, [op_guid] TEXT, [belong_to] INTEGER);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) goto fail;
result = sqlite3_exec(db,
"CREATE TABLE eLink([export_obj] INTEGER, [internal_obj] INTEGER, [is_in] INTEGER, [index] INTEGER, [belong_to] INTEGER);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) goto fail;
//start job
sqlite3_exec(db, "begin;", NULL, NULL, &errmsg);
//return
return;
fail:
db = NULL;
@ -121,6 +69,88 @@ fail:
void database::close() {
if (db == NULL) return;
finalJob();
//release res
sqlite3_close(db);
db = NULL;
free(errmsg);
free(commandStr);
}
BOOL scriptDatabase::init() {
int result;
result = sqlite3_exec(db, "PRAGMA synchronous = OFF;", NULL, NULL, &errmsg);
if (result != SQLITE_OK) return FALSE;
//init table
result = sqlite3_exec(db, "begin;", NULL, NULL, &errmsg);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE script([thisobj] INTEGER, [name] TEXT, [index] INTEGER, [behavior] INTEGER);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE behavior([thisobj] INTEGER, [name] TEXT, [type] INTEGER, [proto_name] TEXT, [proto_guid] TEXT, [flags] INTEGER, [priority] INTEGER, [version] INTEGER, [pin_count] TEXT, [parent] INTEGER);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE pTarget([thisobj] INTEGER, [name] TEXT, [type] TEXT, [type_guid] TEXT, [belong_to] INTEGER, [direct_source] INTEGER, [shard_source] INTEGER);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE pIn([thisobj] INTEGER, [index] INTEGER, [name] TEXT, [type] TEXT, [type_guid] TEXT, [belong_to] INTEGER, [direct_source] INTEGER, [shard_source] INTEGER);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE pOut([thisobj] INTEGER, [index] INTEGER, [name] TEXT, [type] TEXT, [type_guid] TEXT, [belong_to] INTEGER);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE bIn([thisobj] INTEGER, [index] INTEGER, [name] TEXT, [belong_to] INTEGER);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE bOut([thisobj] INTEGER, [index] INTEGER, [name] TEXT, [belong_to] INTEGER);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE bLink([input] INTEGER, [output] INTEGER, [delay] INTEGER, [input_obj] INTEGER, [input_type] INTEGER, [input_index] INETEGR, [output_obj] INTEGER, [output_type] INTEGER, [output_index] INETEGR, [belong_to] INTEGER);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE pLocal([thisobj] INTEGER, [name] TEXT, [type] TEXT, [type_guid] TEXT, [is_setting] INTEGER, [belong_to] INTEGER);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE pLocalData([field] TEXT, [data] TEXT, [belong_to] INTEGER);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE pLink([input] INTEGER, [output] INTEGER, [input_obj] INTEGER, [input_type] INTEGER, [input_is_bb] INTEGER, [input_index] INETEGR, [output_obj] INTEGER, [output_type] INTEGER, [output_is_bb] INTEGER, [output_index] INETEGR, [belong_to] INTEGER);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE pOper([thisobj] INTEGER, [op] TEXT, [op_guid] TEXT, [belong_to] INTEGER);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE eLink([export_obj] INTEGER, [internal_obj] INTEGER, [is_in] INTEGER, [index] INTEGER, [belong_to] INTEGER);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db, "commit;", NULL, NULL, &errmsg);
if (result != SQLITE_OK) return FALSE;
//start job
sqlite3_exec(db, "begin;", NULL, NULL, &errmsg);
return TRUE;
}
BOOL scriptDatabase::finalJob() {
//stop job
sqlite3_exec(db, "commit;", NULL, NULL, &errmsg);
@ -132,19 +162,44 @@ void database::close() {
sqlite3_exec(db, "CREATE INDEX [quick_where4] ON pOut (thisobj)", NULL, NULL, &errmsg);
sqlite3_exec(db, "commit;", NULL, NULL, &errmsg);*/
//release res
sqlite3_close(db);
db = NULL;
return TRUE;
}
free(errmsg);
free(commandStr);
BOOL envDatabase::init() {
int result;
result = sqlite3_exec(db, "PRAGMA synchronous = OFF;", NULL, NULL, &errmsg);
if (result != SQLITE_OK) return FALSE;
//init table
result = sqlite3_exec(db, "begin;", NULL, NULL, &errmsg);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db,
"CREATE TABLE op([funcptr] INTEGER, [in1_guid_1] INTEGER, [in1_guid_2] INTEGER, [in2_guid_1] INTEGER, [in2_guid_2] INTEGER, [out_guid_1] INTEGER, [out_guid_2] INTEGER, [op_guid_1] INTEGER, [op_guid_2] INTEGER, [op_name] TEXT, [op_code] INTEGER);",
NULL, NULL, &errmsg);
if (result != SQLITE_OK) return FALSE;
result = sqlite3_exec(db, "commit;", NULL, NULL, &errmsg);
if (result != SQLITE_OK) return FALSE;
//start job
sqlite3_exec(db, "begin;", NULL, NULL, &errmsg);
return TRUE;
}
BOOL envDatabase::finalJob() {
//stop job
sqlite3_exec(db, "commit;", NULL, NULL, &errmsg);
return TRUE;
}
#pragma endregion
#pragma region write func
void database::write_CKBehavior(dbCKBehavior* data) {
void scriptDatabase::write_CKBehavior(dbCKBehavior* data) {
if (db == NULL) return;
sprintf(commandStr, "INSERT INTO behavior VALUES (%d, '%s', %d, '%s', '%d, %d', %d, %d, %d, '%s', %d);",
@ -163,7 +218,7 @@ void database::write_CKBehavior(dbCKBehavior* data) {
sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
}
void database::write_CKScript(dbCKScript* data) {
void scriptDatabase::write_CKScript(dbCKScript* data) {
if (db == NULL) return;
sprintf(commandStr, "INSERT INTO script VALUES (%d, '%s', %d, %d);",
@ -175,7 +230,7 @@ void database::write_CKScript(dbCKScript* data) {
sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
}
void database::write_pTarget(db_pTarget* data) {
void scriptDatabase::write_pTarget(db_pTarget* data) {
if (db == NULL) return;
sprintf(commandStr, "INSERT INTO pTarget VALUES (%d, '%s', '%s', '%d, %d', %d, %d, %d);",
@ -191,7 +246,7 @@ void database::write_pTarget(db_pTarget* data) {
sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
}
void database::write_pIn(db_pIn* data) {
void scriptDatabase::write_pIn(db_pIn* data) {
if (db == NULL) return;
sprintf(commandStr, "INSERT INTO pIn VALUES (%d, %d, '%s', '%s', '%d, %d', %d, %d, %d);",
@ -208,7 +263,7 @@ void database::write_pIn(db_pIn* data) {
sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
}
void database::write_pOut(db_pOut* data) {
void scriptDatabase::write_pOut(db_pOut* data) {
if (db == NULL) return;
sprintf(commandStr, "INSERT INTO pOut VALUES (%d, %d, '%s', '%s', '%d, %d', %d);",
@ -223,7 +278,7 @@ void database::write_pOut(db_pOut* data) {
sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
}
void database::write_bIn(db_bIn* data) {
void scriptDatabase::write_bIn(db_bIn* data) {
if (db == NULL) return;
sprintf(commandStr, "INSERT INTO bIn VALUES (%d, %d, '%s', %d);",
@ -235,7 +290,7 @@ void database::write_bIn(db_bIn* data) {
sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
}
void database::write_bOut(db_bOut* data) {
void scriptDatabase::write_bOut(db_bOut* data) {
if (db == NULL) return;
sprintf(commandStr, "INSERT INTO bOut VALUES (%d, %d, '%s', %d);",
@ -247,7 +302,7 @@ void database::write_bOut(db_bOut* data) {
sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
}
void database::write_bLink(db_bLink* data) {
void scriptDatabase::write_bLink(db_bLink* data) {
if (db == NULL) return;
sprintf(commandStr, "INSERT INTO bLink VALUES (%d, %d, %d, %d, %d, %d, %d, %d, %d, %d);",
@ -265,7 +320,7 @@ void database::write_bLink(db_bLink* data) {
sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
}
void database::write_pLocal(db_pLocal* data) {
void scriptDatabase::write_pLocal(db_pLocal* data) {
if (db == NULL) return;
sprintf(commandStr, "INSERT INTO pLocal VALUES (%d, '%s', '%s', '%d, %d', %d, %d);",
@ -280,7 +335,7 @@ void database::write_pLocal(db_pLocal* data) {
sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
}
void database::write_pLink(db_pLink* data) {
void scriptDatabase::write_pLink(db_pLink* data) {
if (db == NULL) return;
sprintf(commandStr, "INSERT INTO pLink VALUES (%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d);",
@ -299,7 +354,7 @@ void database::write_pLink(db_pLink* data) {
sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
}
void database::write_pLocalData(db_pLocalData* data) {
void scriptDatabase::write_pLocalData(db_pLocalData* data) {
if (db == NULL) return;
sprintf(commandStr, "INSERT INTO pLocalData VALUES ('%s', '%s', %d);",
@ -310,7 +365,7 @@ void database::write_pLocalData(db_pLocalData* data) {
sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
}
void database::write_pOper(db_pOper* data) {
void scriptDatabase::write_pOper(db_pOper* data) {
if (db == NULL) return;
sprintf(commandStr, "INSERT INTO pOper VALUES (%d, '%s', '%d, %d', %d);",
@ -323,7 +378,7 @@ void database::write_pOper(db_pOper* data) {
sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
}
void database::write_eLink(db_eLink* data) {
void scriptDatabase::write_eLink(db_eLink* data) {
if (db == NULL) return;
sprintf(commandStr, "INSERT INTO eLink VALUES (%d, %d, %d, %d, %d);",
@ -336,4 +391,24 @@ void database::write_eLink(db_eLink* data) {
sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
}
void envDatabase::write_envOp(db_envOp* data) {
if (db == NULL) return;
sprintf(commandStr, "INSERT INTO op VALUES (%d, %d, %d, %d, %d, %d, %d, %d, %d, '%s', %d);",
data->funcPtr,
data->in1_guid[0],
data->in1_guid[1],
data->in2_guid[0],
data->in2_guid[1],
data->out_guid[0],
data->out_guid[1],
data->op_guid[0],
data->op_guid[1],
data->op_name,
data->op_code);
sqlite3_exec(db, commandStr, NULL, NULL, &errmsg);
}
#pragma endregion

View File

@ -139,9 +139,21 @@ typedef struct {
EXPAND_CK_ID belong_to;
}db_eLink;
typedef struct {
CK_PARAMETEROPERATION funcPtr;
CKDWORD in1_guid[2];
CKDWORD in2_guid[2];
CKDWORD out_guid[2];
CKDWORD op_guid[2];
char op_name[1024];
CKOperationType op_code;
}db_envOp;
#pragma endregion
class dbDataStructHelper {
class dbScriptDataStructHelper {
public:
void init(CKParameterManager* paramManager);
void dispose();
@ -162,11 +174,31 @@ class dbDataStructHelper {
db_eLink* _db_eLink;
};
class dbEnvDataStructHelper {
public:
void init();
void dispose();
db_envOp* _db_envOp;
};
class database {
public:
void open(const char* file);
void close();
protected:
virtual BOOL init() { return TRUE; }
virtual BOOL finalJob() { return TRUE; }
sqlite3* db;
char* errmsg;
char* commandStr;
};
class scriptDatabase : public database {
public:
void write_CKBehavior(dbCKBehavior* data);
void write_CKScript(dbCKScript* data);
void write_pTarget(db_pTarget* data);
@ -181,10 +213,18 @@ class database {
void write_pOper(db_pOper* data);
void write_eLink(db_eLink* data);
private:
sqlite3* db;
char* errmsg;
char* commandStr;
protected:
BOOL init();
BOOL finalJob();
};
class envDatabase : public database {
public:
void write_envOp(db_envOp* data);
protected:
BOOL init();
BOOL finalJob();
};
#endif

View File

@ -0,0 +1,41 @@
#include "env_export.h"
//disable shit tip
#pragma warning(disable:26812)
void IterateParameterOperation(CKParameterManager* parameterManager, envDatabase* db, dbEnvDataStructHelper* helper) {
int count = parameterManager->GetParameterOperationCount();
CKOperationDesc* opList = NULL;
int listCount = 0, cacheListCount = 0;
CKGUID _guid;
for (int i = 0; i < count; i++) {
//fill basic data
helper->_db_envOp->op_code = i;
_guid = parameterManager->OperationCodeToGuid(i);
helper->_db_envOp->op_guid[0] = _guid.d1;
helper->_db_envOp->op_guid[1] = _guid.d2;
strcpy(helper->_db_envOp->op_name, parameterManager->OperationCodeToName(i));
//allocate mem
cacheListCount = parameterManager->GetAvailableOperationsDesc(_guid, NULL, NULL, NULL, NULL);
if (cacheListCount > listCount) {
listCount = cacheListCount;
opList = (CKOperationDesc*)realloc(opList, listCount * sizeof(CKOperationDesc));
assert(opList != NULL);
}
parameterManager->GetAvailableOperationsDesc(_guid, NULL, NULL, NULL, opList);
for (int j = 0; j < cacheListCount; j++) {
helper->_db_envOp->in1_guid[0] = opList[j].P1Guid.d1;
helper->_db_envOp->in1_guid[1] = opList[j].P1Guid.d2;
helper->_db_envOp->in2_guid[0] = opList[j].P2Guid.d1;
helper->_db_envOp->in2_guid[1] = opList[j].P2Guid.d2;
helper->_db_envOp->out_guid[0] = opList[j].ResGuid.d1;
helper->_db_envOp->out_guid[1] = opList[j].ResGuid.d2;
helper->_db_envOp->funcPtr = opList[j].Fct;
db->write_envOp(helper->_db_envOp);
}
}
if (opList != NULL) free(opList);
}

View File

@ -0,0 +1,9 @@
#if !defined(_YYCDLL_HELP_EXPORT_H__IMPORTED_)
#define _YYCDLL_HELP_EXPORT_H__IMPORTED_
#include "stdafx.h"
#include "database.h"
void IterateParameterOperation(CKParameterManager* parameterManager, envDatabase* db, dbEnvDataStructHelper* helper);
#endif

View File

@ -6,7 +6,7 @@
#pragma region inline func
inline void generate_pLink_in_pIn(CKContext* ctx, CKParameterIn* cache, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents, int index, BOOL executedFromBB, BOOL isTarget) {
inline void generate_pLink_in_pIn(CKContext* ctx, CKParameterIn* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents, int index, BOOL executedFromBB, BOOL isTarget) {
//WARNING: i only choose one between [DirectSource] and [SharedSource] bucause i don't find any pIn both have these two field
CKParameter* directSource = NULL;
CKObject* ds_Owner = NULL;
@ -71,7 +71,7 @@ inline void generate_pLink_in_pIn(CKContext* ctx, CKParameterIn* cache, database
}
}
inline void proc_pTarget(CKContext* ctx, CKParameterIn* cache, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents) {
inline void proc_pTarget(CKContext* ctx, CKParameterIn* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents) {
helper->_db_pTarget->thisobj = cache->GetID();
strcpy(helper->_db_pTarget->name, cache->GetName());
strcpy(helper->_db_pTarget->type, helper->_parameterManager->ParameterTypeToName(cache->GetType()));
@ -87,7 +87,7 @@ inline void proc_pTarget(CKContext* ctx, CKParameterIn* cache, database* db, dbD
generate_pLink_in_pIn(ctx, cache, db, helper, parents, grandparents, -1, TRUE, TRUE);
}
inline void proc_pIn(CKContext* ctx, CKParameterIn* cache, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents, int index, BOOL executedFromBB) {
inline void proc_pIn(CKContext* ctx, CKParameterIn* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents, int index, BOOL executedFromBB) {
helper->_db_pIn->thisobj = cache->GetID();
helper->_db_pIn->index = index;
strcpy(helper->_db_pIn->name, cache->GetName());
@ -119,7 +119,7 @@ inline void proc_pIn(CKContext* ctx, CKParameterIn* cache, database* db, dbDataS
}
inline void proc_pOut(CKContext* ctx, CKParameterOut* cache, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents, int index, BOOL executedFromBB) {
inline void proc_pOut(CKContext* ctx, CKParameterOut* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents, int index, BOOL executedFromBB) {
helper->_db_pOut->thisobj = cache->GetID();
helper->_db_pOut->index = index;
strcpy(helper->_db_pOut->name, cache->GetName());
@ -181,7 +181,7 @@ inline void proc_pOut(CKContext* ctx, CKParameterOut* cache, database* db, dbDat
}
}
inline void proc_bIn(CKBehaviorIO* cache, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents, int index) {
inline void proc_bIn(CKBehaviorIO* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, int index) {
helper->_db_bIn->thisobj = cache->GetID();
helper->_db_bIn->index = index;
strcpy(helper->_db_bIn->name, cache->GetName());
@ -190,7 +190,7 @@ inline void proc_bIn(CKBehaviorIO* cache, database* db, dbDataStructHelper* help
db->write_bIn(helper->_db_bIn);
}
inline void proc_bOut(CKBehaviorIO* cache, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents, int index) {
inline void proc_bOut(CKBehaviorIO* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, int index) {
helper->_db_bOut->thisobj = cache->GetID();
helper->_db_bOut->index = index;
strcpy(helper->_db_bOut->name, cache->GetName());
@ -199,7 +199,7 @@ inline void proc_bOut(CKBehaviorIO* cache, database* db, dbDataStructHelper* hel
db->write_bOut(helper->_db_bOut);
}
inline void proc_bLink(CKBehaviorLink* cache, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents) {
inline void proc_bLink(CKBehaviorLink* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents) {
CKBehaviorIO* io = cache->GetInBehaviorIO();
CKBehavior* beh = io->GetOwner();
helper->_db_bLink->input = io->GetID();
@ -219,7 +219,7 @@ inline void proc_bLink(CKBehaviorLink* cache, database* db, dbDataStructHelper*
db->write_bLink(helper->_db_bLink);
}
inline void proc_pLocal(CKParameterLocal* cache, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents, BOOL is_setting) {
inline void proc_pLocal(CKParameterLocal* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, BOOL is_setting) {
helper->_db_pLocal->thisobj = cache->GetID();
strcpy(helper->_db_pLocal->name, cache->GetName() ? cache->GetName() : "");
CKParameterType vaildTypeChecker = cache->GetType();
@ -236,7 +236,7 @@ inline void proc_pLocal(CKParameterLocal* cache, database* db, dbDataStructHelpe
IteratepLocalData(cache, db, helper, cache->GetID());
}
inline void proc_pOper(CKContext* ctx, CKParameterOperation* cache, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents) {
inline void proc_pOper(CKContext* ctx, CKParameterOperation* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents) {
helper->_db_pOper->thisobj = cache->GetID();
strcpy(helper->_db_pOper->op, helper->_parameterManager->OperationGuidToName(cache->GetOperationGuid()));
helper->_db_pOper->op_guid[0] = cache->GetOperationGuid().d1;
@ -253,19 +253,19 @@ inline void proc_pOper(CKContext* ctx, CKParameterOperation* cache, database* db
//============================helper for pLocal data export
inline void helper_pLocalDataExport(const char* field, const char* data, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents) {
inline void helper_pLocalDataExport(const char* field, const char* data, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents) {
strcpy(helper->_db_pLocalData->field, field);
strcpy(helper->_db_pLocalData->data, data);
helper->_db_pLocalData->belong_to = parents;
db->write_pLocalData(helper->_db_pLocalData);
}
inline void helper_pLocalDataExport(const char* field, float data, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents) {
inline void helper_pLocalDataExport(const char* field, float data, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents) {
char str[32];
sprintf(str, "%f", data);
helper_pLocalDataExport(field, str, db, helper, parents);
}
inline void helper_pLocalDataExport(const char* field, long data, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents) {
inline void helper_pLocalDataExport(const char* field, long data, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents) {
char str[32];
ltoa(data, str, 10);
helper_pLocalDataExport(field, str, db, helper, parents);
@ -277,7 +277,7 @@ inline void helper_pLocalDataExport(const char* field, long data, database* db,
#pragma region normal func
void IterateScript(CKContext* ctx, database* db, dbDataStructHelper* helper) {
void IterateScript(CKContext* ctx, scriptDatabase* db, dbScriptDataStructHelper* helper) {
CKBeObject* beobj = NULL;
CKBehavior* beh = NULL;
XObjectPointerArray objArray = ctx->GetObjectListByType(CKCID_BEOBJECT, TRUE);
@ -302,7 +302,7 @@ void IterateScript(CKContext* ctx, database* db, dbDataStructHelper* helper) {
}
}
void IterateBehavior(CKContext* ctx, CKBehavior* bhv, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents) {
void IterateBehavior(CKContext* ctx, CKBehavior* bhv, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents) {
//write self data
helper->_dbCKBehavior->thisobj = bhv->GetID();
strcpy(helper->_dbCKBehavior->name, bhv->GetName());
@ -355,7 +355,7 @@ void IterateBehavior(CKContext* ctx, CKBehavior* bhv, database* db, dbDataStruct
IterateBehavior(ctx, bhv->GetSubBehavior(i), db, helper, bhv->GetID());
}
void IteratepLocalData(CKParameterLocal* p, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents) {
void IteratepLocalData(CKParameterLocal* p, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents) {
CKGUID t = p->GetGUID();
BOOL unknowType = FALSE;

View File

@ -4,22 +4,22 @@
#include "stdafx.h"
#include "database.h"
inline void generate_pLink_in_pIn(CKContext* ctx, CKParameterIn* cache, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents, int index, BOOL executedFromBB, BOOL isTarget);
inline void proc_pTarget(CKContext* ctx, CKParameterIn* cache, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents);
inline void proc_pIn(CKContext* ctx, CKParameterIn* cache, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents, int index, BOOL executedFromBB);
inline void proc_pOut(CKContext* ctx, CKParameterOut* cache, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents, int index, BOOL executedFromBB);
inline void proc_bIn(CKBehaviorIO* cache, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents, int index);
inline void proc_bOut(CKBehaviorIO* cache, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents, int index);
inline void proc_bLink(CKBehaviorLink* cache, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents);
inline void proc_pLocal(CKParameterLocal* cache, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents, BOOL is_setting);
inline void proc_pOper(CKContext* ctx, CKParameterOperation* cache, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents);
inline void generate_pLink_in_pIn(CKContext* ctx, CKParameterIn* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents, int index, BOOL executedFromBB, BOOL isTarget);
inline void proc_pTarget(CKContext* ctx, CKParameterIn* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents);
inline void proc_pIn(CKContext* ctx, CKParameterIn* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents, int index, BOOL executedFromBB);
inline void proc_pOut(CKContext* ctx, CKParameterOut* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, EXPAND_CK_ID grandparents, int index, BOOL executedFromBB);
inline void proc_bIn(CKBehaviorIO* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, int index);
inline void proc_bOut(CKBehaviorIO* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, int index);
inline void proc_bLink(CKBehaviorLink* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents);
inline void proc_pLocal(CKParameterLocal* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents, BOOL is_setting);
inline void proc_pOper(CKContext* ctx, CKParameterOperation* cache, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents);
inline void helper_pLocalDataExport(const char* field, long data, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents);
inline void helper_pLocalDataExport(const char* field, float data, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents);
inline void helper_pLocalDataExport(const char* field, const char* data, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents);
inline void helper_pLocalDataExport(const char* field, long data, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents);
inline void helper_pLocalDataExport(const char* field, float data, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents);
inline void helper_pLocalDataExport(const char* field, const char* data, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents);
void IterateBehavior(CKContext* ctx, CKBehavior* bhv, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents);
void IterateScript(CKContext* ctx, database* db, dbDataStructHelper* helper);
void IteratepLocalData(CKParameterLocal* pl, database* db, dbDataStructHelper* helper, EXPAND_CK_ID parents);
void IterateBehavior(CKContext* ctx, CKBehavior* bhv, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents);
void IterateScript(CKContext* ctx, scriptDatabase* db, dbScriptDataStructHelper* helper);
void IteratepLocalData(CKParameterLocal* pl, scriptDatabase* db, dbScriptDataStructHelper* helper, EXPAND_CK_ID parents);
#endif

View File

@ -1,6 +1,7 @@
#include "vt_menu.h"
#include "database.h"
#include "script_export.h"
#include "env_export.h"
extern PluginInterface* s_Plugininterface;
CMenu* s_MainMenu = NULL;
@ -45,6 +46,7 @@ void UpdateMenu() {
s_Plugininterface->ClearPluginMenu(s_MainMenu); //clear menu
s_Plugininterface->AddPluginMenuItem(s_MainMenu, 0, "Export all scripts");
s_Plugininterface->AddPluginMenuItem(s_MainMenu, 1, "Export environment");
//===========================freeze chirs241097 code for future expand
//s_Plugininterface->AddPluginMenuItem(s_MainMenu, -1, NULL, TRUE);
@ -63,32 +65,32 @@ void UpdateMenu() {
}
void PluginMenuCallback(int commandID) {
switch (commandID) {
case 0:
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CKContext* ctx = s_Plugininterface->GetCKContext();
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CKContext* ctx = s_Plugininterface->GetCKContext();
OPENFILENAME ofn;
char* file = (char*)malloc(1024 * sizeof(char));
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.lpstrFile = file;
ofn.lpstrFile[0] = '\0';
ofn.nMaxFile = 1024;
ofn.lpstrFilter = "Database file(*.db)\0*.db\0All files(*.*)\0*.*";
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_EXPLORER;
if (GetSaveFileName(&ofn)) {
//make sure file is not exist
DeleteFile(file);
OPENFILENAME ofn;
char* file = (char*)malloc(1024 * sizeof(char));
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.lpstrFile = file;
ofn.lpstrFile[0] = '\0';
ofn.nMaxFile = 1024;
ofn.lpstrFilter = "Database file(*.db)\0*.db\0All files(*.*)\0*.*\0";
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_EXPLORER;
if (GetSaveFileName(&ofn)) {
//make sure file is not exist
DeleteFile(file);
//switch mode
switch (commandID) {
case 0:
{
//init resources
database* _db = new database();
dbDataStructHelper* _helper = new dbDataStructHelper();
scriptDatabase* _db = new scriptDatabase();
dbScriptDataStructHelper* _helper = new dbScriptDataStructHelper();
_db->open(file);
_helper->init(ctx->GetParameterManager());
@ -100,11 +102,28 @@ void PluginMenuCallback(int commandID) {
_db->close();
delete _helper;
delete _db;
ctx->OutputToConsole("[Super Script Materializer] Done");
}
free(file);
break;
case 1:
{
//init
envDatabase* _db = new envDatabase();
dbEnvDataStructHelper* _helper = new dbEnvDataStructHelper();
_db->open(file);
_helper->init();
//iterate parameter operation
IterateParameterOperation(ctx->GetParameterManager(), _db, _helper);
//release all
_helper->dispose();
_db->close();
delete _helper;
delete _db;
}
break;
}
break;
ctx->OutputToConsole("[Super Script Materializer] Done");
}
free(file);
}