finish adaptation of Virtools 2.1 with BML

* Add some `if` preprocessor to get unique build for virtools 2.1
* Adapt upstream update
This commit is contained in:
yyc12345 2021-09-03 15:58:11 +08:00
parent 740964f837
commit 2b20f280eb
8 changed files with 40 additions and 7 deletions

View File

@ -19,7 +19,15 @@
* `SuperScriptViewer`一个Python工程使用Flask提供一个本地Web界面进行脚本以供快速查看通常是用于本地快速查看解析后脚本的数据。
* `SuperScriptEnterprise`一个PHP工程相对于`SuperScriptViewer`更适合部署于服务器上进行数据的展示和浏览。
整个工程所作的事情就是将Virtools文档中的所有脚本导出成一个SQLite数据库文件然后经过Python进行排布处理最后提供一个本地Web前端查看脚本。这同样适用于`Script Hidden`的Virtools脚本也适用于其中含有不可展开的`Behavior Graph`的脚本。
<img src='https://g.gravizo.com/svg?
digraph G {
rankdir=LR;
Materializer -> Decorator -> Viewer;
Decorator -> Exterprise;
}
'/>
四个部分组成的工作流程如上图所示。整个工程所作的事情就是将Virtools文档中的所有脚本导出成一个SQLite数据库文件然后经过Python进行排布处理最后提供一个本地Web前端查看脚本。这同样适用于`Script Hidden`的Virtools脚本也适用于其中含有不可展开的`Behavior Graph`的脚本。
物化器不能完全恢复脚本的原有排布无论原有排布是否存在物化器都将重新自动生成脚本中的各个元素的位置。某些结构的关系可能会改变例如Export parameter亦或者是与Virtools中的呈现不同但是逻辑思路将不会改变。同时物化器不能将已经生成的结构回写成Virtools可接受的格式因此物化器只能提供无视脚本隐藏的分析功能。

View File

@ -601,6 +601,7 @@ void envDatabase::write_envPlugin(db_envPlugin* data) {
void envDatabase::write_envVariable(db_envVariable* data) {
if (db == NULL) return;
#if !defined(VIRTOOLS_21)
sqlite3_stmt* stmt = NULL;
tryGetStmt(5, "INSERT INTO [variable] VALUES (?, ?, ?, ?, ?, ?)");
sqlite3_reset(stmt);
@ -612,6 +613,7 @@ void envDatabase::write_envVariable(db_envVariable* data) {
sqlite3_bind_text(stmt, 5, data->representation.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 6, data->data.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_step(stmt);
#endif
}
#undef tryGetStmt

View File

@ -6,6 +6,7 @@
#include <string>
#include <vector>
#include <set>
#include "virtools_compatible.h"
#define STRINGCACHE_SIZE 25565
@ -221,7 +222,7 @@ typedef struct {
std::string name;
std::string desciption;
XWORD flags;
CKVariableManager::Variable::Type type;
UNIVERSAL_VAR_TYPE type;
std::string representation;
std::string data;
}db_envVariable;

View File

@ -126,6 +126,7 @@ void IteratePlugin(CKPluginManager* plgManager, envDatabase* db, dbEnvDataStruct
}
}
#if !defined(VIRTOOLS_21)
void IterateVariable(CKVariableManager* varManager, envDatabase* db, dbEnvDataStructHelper* helper) {
CKVariableManager::Iterator it = varManager->GetVariableIterator();
CKVariableManager::Variable* varobj = NULL;
@ -142,4 +143,5 @@ void IterateVariable(CKVariableManager* varManager, envDatabase* db, dbEnvDataSt
db->write_envVariable(helper->_db_envVariable);
}
}
}
#endif

View File

@ -2,6 +2,9 @@
//disable shit tip
#pragma warning(disable:26812)
// disable microsoft shitty macro to avoid build error
#undef GetClassName
#define changeSuffix(a) prefix[endIndex]='\0';strcat(prefix,a)
#define copyGuid(guid,str) sprintf(helper->_stringCache,"%d,%d",guid.d1,guid.d2);str=helper->_stringCache;
#define safeStringCopy(storage,str) storage=(str)?(str):"";
@ -104,7 +107,7 @@ void proc_pTarget(CKContext* ctx, CKParameterIn* cache, scriptDatabase* db, dbSc
db->write_pTarget(helper->_db_pTarget);
//judge whether expoer parameter and write database
if (((CKBehavior*)ctx->GetObjectA(grandparents))->GetInputParameterPosition(cache) != -1) {
if (((CKBehavior*)ctx->GetObject(grandparents))->GetInputParameterPosition(cache) != -1) {
helper->_db_eLink->export_obj = cache->GetID();
helper->_db_eLink->internal_obj = parents;
helper->_db_eLink->is_in = TRUE;
@ -134,7 +137,7 @@ void proc_pIn(CKContext* ctx, CKParameterIn* cache, scriptDatabase* db, dbScript
db->write_pIn(helper->_db_pIn);
//judge whether expoer parameter and write database
if (((CKBehavior*)ctx->GetObjectA(grandparents))->GetInputParameterPosition(cache) != -1) {
if (((CKBehavior*)ctx->GetObject(grandparents))->GetInputParameterPosition(cache) != -1) {
helper->_db_eLink->export_obj = cache->GetID();
helper->_db_eLink->internal_obj = parents;
helper->_db_eLink->is_in = TRUE;
@ -163,7 +166,7 @@ void proc_pOut(CKContext* ctx, CKParameterOut* cache, scriptDatabase* db, dbScri
db->write_pOut(helper->_db_pOut);
//judge whether expoer parameter and write database
if (((CKBehavior*)ctx->GetObjectA(grandparents))->GetOutputParameterPosition(cache) != -1) {
if (((CKBehavior*)ctx->GetObject(grandparents))->GetOutputParameterPosition(cache) != -1) {
helper->_db_eLink->export_obj = cache->GetID();
helper->_db_eLink->internal_obj = parents;
helper->_db_eLink->is_in = FALSE;
@ -411,7 +414,10 @@ void DigParameterData(CKParameterLocal* p, scriptDatabase* db, dbScriptDataStruc
if (p->GetParameterClassID() && p->GetValueObject(false)) {
helper_pDataExport("id", (long)p->GetValueObject(false)->GetID(), db, helper, parents);
helper_pDataExport("name", p->GetValueObject(false)->GetName(), db, helper, parents);
helper_pDataExport("type", p->GetValueObject(false)->GetClassNameA(), db, helper, parents);
CK_CLASSID none_classid = p->GetValueObject(false)->GetClassID();
CKParameterType none_type = helper->_parameterManager->ClassIDToType(none_classid);
helper_pDataExport("type",helper->_parameterManager->ParameterTypeToName(none_type), db, helper, parents);
return;
}
//float

View File

@ -5,4 +5,10 @@
//void __declspec(noreturn) FAKE_THROW();
#if defined(VIRTOOLS_21)
#define UNIVERSAL_VAR_TYPE void*
#elif defined(VIRTOOLS_25) || defined(VIRTOOLS_35) || defined(VIRTOOLS_40) || defined(VIRTOOLS_50)
#define UNIVERSAL_VAR_TYPE CKVariableManager::Variable::Type
#endif
#endif

View File

@ -126,7 +126,9 @@ void PluginMenuCallback(int commandID) {
IterateMessage(ctx->GetMessageManager(), _db, _helper);
IterateAttribute(ctx->GetAttributeManager(), _db, _helper);
IteratePlugin(CKGetPluginManager(), _db, _helper);
#if !defined(VIRTOOLS_21)
IterateVariable(ctx->GetVariableManager(), _db, _helper);
#endif
//release all
_helper->dispose();

View File

@ -10,6 +10,10 @@ void PlayerMain(const char* virtools_composition, const char* script_db_path, co
printf("Report bug: https://github.com/yyc12345/SuperScriptMaterializer/issues\n");
// ====================== init ck2 engine
#if defined(VIRTOOLS_21)
CommonAssert(LoadLibrary("CK2.dll") != NULL, "Error loading CK2.dll");
#endif
CommonAssert(!CKStartUp(), "CKStartUp Error");
CKPluginManager* pluginManager = CKGetPluginManager();
CommonAssert(pluginManager != NULL, "PluginManager = null");
@ -52,7 +56,9 @@ void PlayerMain(const char* virtools_composition, const char* script_db_path, co
IterateMessage(context->GetMessageManager(), _env_db, _env_helper);
IterateAttribute(context->GetAttributeManager(), _env_db, _env_helper);
IteratePlugin(CKGetPluginManager(), _env_db, _env_helper);
#if !defined(VIRTOOLS_21)
IterateVariable(context->GetVariableManager(), _env_db, _env_helper);
#endif
// free
_script_helper->dispose();