From d601cef30f240ade9064c10150713d66b9826071 Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Thu, 23 Apr 2020 22:54:37 +0800 Subject: [PATCH] add param export and add some id attr in html --- SuperScriptMaterializer/database.cpp | 38 +++++++++++++++++++++-- SuperScriptMaterializer/database.h | 22 ++++++++++++++ SuperScriptMaterializer/env_export.cpp | 40 ++++++++++++++++++++----- SuperScriptMaterializer/env_export.h | 3 ++ SuperScriptMaterializer/vt_menu.cpp | 3 +- SuperScriptViewer/templates/viewer.html | 6 ++-- 6 files changed, 98 insertions(+), 14 deletions(-) diff --git a/SuperScriptMaterializer/database.cpp b/SuperScriptMaterializer/database.cpp index 68ba519..0bcd7a0 100644 --- a/SuperScriptMaterializer/database.cpp +++ b/SuperScriptMaterializer/database.cpp @@ -38,10 +38,12 @@ void dbScriptDataStructHelper::dispose() { void dbEnvDataStructHelper::init() { _db_envOp = new db_envOp; + _db_envParam = new db_envParam; } void dbEnvDataStructHelper::dispose() { delete _db_envOp; + delete _db_envParam; } #pragma endregion @@ -175,7 +177,11 @@ BOOL envDatabase::init() { 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);", + "CREATE TABLE op([funcptr] INTEGER, [in1_guid] TEXT, [in2_guid] TEXT, [out_guid] TEXT, [op_guid] INTEGER, [op_name] TEXT, [op_code] INTEGER);", + NULL, NULL, &errmsg); + if (result != SQLITE_OK) return FALSE; + result = sqlite3_exec(db, + "CREATE TABLE param([index] INTEGER, [guid] TEXT, [derived_from] TEXT, [type_name] TEXT, [default_size] INTEGER, [func_CreateDefault] INTEGER, [func_Delete] INTEGER, [func_SaveLoad] INTEGER, [func_Check] INTEGER, [func_Copy] INTEGER, [func_String] INTEGER, [func_UICreator] INTEGER, [creator_plugin_id] INTEGER, [dw_param] INTEGER, [dw_flags] INTEGER, [cid] INTEGER, [saver_manager] TEXT);", NULL, NULL, &errmsg); if (result != SQLITE_OK) return FALSE; @@ -394,7 +400,7 @@ void scriptDatabase::write_eLink(db_eLink* data) { 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);", + 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], @@ -410,5 +416,33 @@ void envDatabase::write_envOp(db_envOp* data) { sqlite3_exec(db, commandStr, NULL, NULL, &errmsg); } +void envDatabase::write_envParam(db_envParam* data) { + if (db == NULL) return; + + sprintf(commandStr, "INSERT INTO param VALUES (%d, '%d,%d', '%d,%d', '%s', %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, '%d,%d');", + data->index, + data->guid[0], + data->guid[1], + data->derived_from[0], + data->derived_from[1], + data->type_name, + data->default_size, + data->func_CreateDefault, + data->func_Delete, + data->func_SaveLoad, + data->func_Check, + data->func_Copy, + data->func_String, + data->func_UICreator, + data->creator_plugin_id, + data->dw_param, + data->dw_flags, + data->cid, + data->saver_manager[0], + data->saver_manager[1]); + + sqlite3_exec(db, commandStr, NULL, NULL, &errmsg); +} + #pragma endregion diff --git a/SuperScriptMaterializer/database.h b/SuperScriptMaterializer/database.h index 3aeabf5..caa0d08 100644 --- a/SuperScriptMaterializer/database.h +++ b/SuperScriptMaterializer/database.h @@ -151,6 +151,26 @@ typedef struct { CKOperationType op_code; }db_envOp; +typedef struct { + CKParameterType index; + CKDWORD guid[2]; + CKDWORD derived_from[2]; + char type_name[1024]; + int default_size; + CK_PARAMETERCREATEDEFAULTFUNCTION func_CreateDefault; + CK_PARAMETERDELETEFUNCTION func_Delete; + CK_PARAMETERSAVELOADFUNCTION func_SaveLoad; + CK_PARAMETERCHECKFUNCTION func_Check; + CK_PARAMETERCOPYFUNCTION func_Copy; + CK_PARAMETERSTRINGFUNCTION func_String; + CK_PARAMETERUICREATORFUNCTION func_UICreator; + int creator_plugin_id; + CKDWORD dw_param; + CKDWORD dw_flags; + CKDWORD cid; + CKDWORD saver_manager[2]; +}db_envParam; + #pragma endregion class dbScriptDataStructHelper { @@ -180,6 +200,7 @@ class dbEnvDataStructHelper { void dispose(); db_envOp* _db_envOp; + db_envParam* _db_envParam; }; @@ -221,6 +242,7 @@ class scriptDatabase : public database { class envDatabase : public database { public: void write_envOp(db_envOp* data); + void write_envParam(db_envParam* data); protected: BOOL init(); diff --git a/SuperScriptMaterializer/env_export.cpp b/SuperScriptMaterializer/env_export.cpp index b0f12a9..44b9776 100644 --- a/SuperScriptMaterializer/env_export.cpp +++ b/SuperScriptMaterializer/env_export.cpp @@ -11,8 +11,7 @@ void IterateParameterOperation(CKParameterManager* parameterManager, envDatabase //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; + cp_guid(helper->_db_envOp->op_guid, _guid); strcpy(helper->_db_envOp->op_name, parameterManager->OperationCodeToName(i)); //allocate mem @@ -25,12 +24,9 @@ void IterateParameterOperation(CKParameterManager* parameterManager, envDatabase 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; + cp_guid(helper->_db_envOp->in1_guid, opList[j].P1Guid); + cp_guid(helper->_db_envOp->in2_guid, opList[j].P2Guid); + cp_guid(helper->_db_envOp->out_guid, opList[j].ResGuid); helper->_db_envOp->funcPtr = opList[j].Fct; db->write_envOp(helper->_db_envOp); @@ -38,4 +34,32 @@ void IterateParameterOperation(CKParameterManager* parameterManager, envDatabase } if (opList != NULL) free(opList); +} + +void IterateParameter(CKParameterManager* parameterManager, envDatabase* db, dbEnvDataStructHelper* helper) { + int count = parameterManager->GetParameterTypesCount(); + CKParameterTypeDesc* desc = NULL; + for (int i = 0; i < count; i++) { + desc = parameterManager->GetParameterTypeDescription(i); + + helper->_db_envParam->index = desc->Index; + cp_guid(helper->_db_envParam->guid, desc->Guid); + cp_guid(helper->_db_envParam->derived_from, desc->DerivedFrom); + strcpy(helper->_db_envParam->type_name, desc->TypeName.CStr()); + helper->_db_envParam->default_size = desc->DefaultSize; + helper->_db_envParam->func_CreateDefault = desc->CreateDefaultFunction; + helper->_db_envParam->func_Delete = desc->DeleteFunction; + helper->_db_envParam->func_SaveLoad = desc->SaveLoadFunction; + helper->_db_envParam->func_Check = desc->CheckFunction; + helper->_db_envParam->func_Copy = desc->CopyFunction; + helper->_db_envParam->func_String = desc->StringFunction; + helper->_db_envParam->func_UICreator = desc->UICreatorFunction; + helper->_db_envParam->creator_plugin_id = desc->CreatorDll != NULL ? desc->CreatorDll->m_PluginDllIndex : -1; + helper->_db_envParam->dw_param = desc->dwParam; + helper->_db_envParam->dw_flags = desc->dwFlags; + helper->_db_envParam->cid = desc->Cid; + cp_guid(helper->_db_envParam->saver_manager, desc->Saver_Manager); + + db->write_envParam(helper->_db_envParam); + } } \ No newline at end of file diff --git a/SuperScriptMaterializer/env_export.h b/SuperScriptMaterializer/env_export.h index 8c58c4f..bb30a87 100644 --- a/SuperScriptMaterializer/env_export.h +++ b/SuperScriptMaterializer/env_export.h @@ -4,6 +4,9 @@ #include "stdafx.h" #include "database.h" +#define cp_guid(x,y) x[0]=y.d1;x[1]=y.d2 + void IterateParameterOperation(CKParameterManager* parameterManager, envDatabase* db, dbEnvDataStructHelper* helper); +void IterateParameter(CKParameterManager* parameterManager, envDatabase* db, dbEnvDataStructHelper* helper); #endif \ No newline at end of file diff --git a/SuperScriptMaterializer/vt_menu.cpp b/SuperScriptMaterializer/vt_menu.cpp index cb8634b..ec8b4ec 100644 --- a/SuperScriptMaterializer/vt_menu.cpp +++ b/SuperScriptMaterializer/vt_menu.cpp @@ -112,8 +112,9 @@ void PluginMenuCallback(int commandID) { _db->open(file); _helper->init(); - //iterate parameter operation + //iterate parameter operation/param IterateParameterOperation(ctx->GetParameterManager(), _db, _helper); + IterateParameter(ctx->GetParameterManager(), _db, _helper); //release all _helper->dispose(); diff --git a/SuperScriptViewer/templates/viewer.html b/SuperScriptViewer/templates/viewer.html index 4f9152e..cb8ab1a 100644 --- a/SuperScriptViewer/templates/viewer.html +++ b/SuperScriptViewer/templates/viewer.html @@ -11,7 +11,7 @@
-
+

Script Hierarchy

@@ -25,7 +25,7 @@
-
+
{# blocks content #} {% for i in blocks %} @@ -79,7 +79,7 @@
-
+
Properties
Display