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:
parent
740964f837
commit
2b20f280eb
10
README_ZH.md
10
README_ZH.md
|
@ -19,7 +19,15 @@
|
||||||
* `SuperScriptViewer`:一个Python工程,使用Flask提供一个本地Web界面进行脚本以供快速查看,通常是用于本地快速查看解析后脚本的数据。
|
* `SuperScriptViewer`:一个Python工程,使用Flask提供一个本地Web界面进行脚本以供快速查看,通常是用于本地快速查看解析后脚本的数据。
|
||||||
* `SuperScriptEnterprise`:一个PHP工程,相对于`SuperScriptViewer`更适合部署于服务器上进行数据的展示和浏览。
|
* `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可接受的格式,因此物化器只能提供无视脚本隐藏的分析功能。
|
物化器不能完全恢复脚本的原有排布,无论原有排布是否存在,物化器都将重新自动生成脚本中的各个元素的位置。某些结构的关系可能会改变(例如Export parameter),亦或者是与Virtools中的呈现不同,但是逻辑思路将不会改变。同时物化器不能将已经生成的结构回写成Virtools可接受的格式,因此物化器只能提供无视脚本隐藏的分析功能。
|
||||||
|
|
||||||
|
|
|
@ -601,6 +601,7 @@ void envDatabase::write_envPlugin(db_envPlugin* data) {
|
||||||
void envDatabase::write_envVariable(db_envVariable* data) {
|
void envDatabase::write_envVariable(db_envVariable* data) {
|
||||||
if (db == NULL) return;
|
if (db == NULL) return;
|
||||||
|
|
||||||
|
#if !defined(VIRTOOLS_21)
|
||||||
sqlite3_stmt* stmt = NULL;
|
sqlite3_stmt* stmt = NULL;
|
||||||
tryGetStmt(5, "INSERT INTO [variable] VALUES (?, ?, ?, ?, ?, ?)");
|
tryGetStmt(5, "INSERT INTO [variable] VALUES (?, ?, ?, ?, ?, ?)");
|
||||||
sqlite3_reset(stmt);
|
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, 5, data->representation.c_str(), -1, SQLITE_TRANSIENT);
|
||||||
sqlite3_bind_text(stmt, 6, data->data.c_str(), -1, SQLITE_TRANSIENT);
|
sqlite3_bind_text(stmt, 6, data->data.c_str(), -1, SQLITE_TRANSIENT);
|
||||||
sqlite3_step(stmt);
|
sqlite3_step(stmt);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef tryGetStmt
|
#undef tryGetStmt
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include "virtools_compatible.h"
|
||||||
|
|
||||||
#define STRINGCACHE_SIZE 25565
|
#define STRINGCACHE_SIZE 25565
|
||||||
|
|
||||||
|
@ -221,7 +222,7 @@ typedef struct {
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string desciption;
|
std::string desciption;
|
||||||
XWORD flags;
|
XWORD flags;
|
||||||
CKVariableManager::Variable::Type type;
|
UNIVERSAL_VAR_TYPE type;
|
||||||
std::string representation;
|
std::string representation;
|
||||||
std::string data;
|
std::string data;
|
||||||
}db_envVariable;
|
}db_envVariable;
|
||||||
|
|
|
@ -126,6 +126,7 @@ void IteratePlugin(CKPluginManager* plgManager, envDatabase* db, dbEnvDataStruct
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(VIRTOOLS_21)
|
||||||
void IterateVariable(CKVariableManager* varManager, envDatabase* db, dbEnvDataStructHelper* helper) {
|
void IterateVariable(CKVariableManager* varManager, envDatabase* db, dbEnvDataStructHelper* helper) {
|
||||||
CKVariableManager::Iterator it = varManager->GetVariableIterator();
|
CKVariableManager::Iterator it = varManager->GetVariableIterator();
|
||||||
CKVariableManager::Variable* varobj = NULL;
|
CKVariableManager::Variable* varobj = NULL;
|
||||||
|
@ -143,3 +144,4 @@ void IterateVariable(CKVariableManager* varManager, envDatabase* db, dbEnvDataSt
|
||||||
db->write_envVariable(helper->_db_envVariable);
|
db->write_envVariable(helper->_db_envVariable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
|
@ -2,6 +2,9 @@
|
||||||
//disable shit tip
|
//disable shit tip
|
||||||
#pragma warning(disable:26812)
|
#pragma warning(disable:26812)
|
||||||
|
|
||||||
|
// disable microsoft shitty macro to avoid build error
|
||||||
|
#undef GetClassName
|
||||||
|
|
||||||
#define changeSuffix(a) prefix[endIndex]='\0';strcat(prefix,a)
|
#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 copyGuid(guid,str) sprintf(helper->_stringCache,"%d,%d",guid.d1,guid.d2);str=helper->_stringCache;
|
||||||
#define safeStringCopy(storage,str) storage=(str)?(str):"";
|
#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);
|
db->write_pTarget(helper->_db_pTarget);
|
||||||
|
|
||||||
//judge whether expoer parameter and write database
|
//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->export_obj = cache->GetID();
|
||||||
helper->_db_eLink->internal_obj = parents;
|
helper->_db_eLink->internal_obj = parents;
|
||||||
helper->_db_eLink->is_in = TRUE;
|
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);
|
db->write_pIn(helper->_db_pIn);
|
||||||
|
|
||||||
//judge whether expoer parameter and write database
|
//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->export_obj = cache->GetID();
|
||||||
helper->_db_eLink->internal_obj = parents;
|
helper->_db_eLink->internal_obj = parents;
|
||||||
helper->_db_eLink->is_in = TRUE;
|
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);
|
db->write_pOut(helper->_db_pOut);
|
||||||
|
|
||||||
//judge whether expoer parameter and write database
|
//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->export_obj = cache->GetID();
|
||||||
helper->_db_eLink->internal_obj = parents;
|
helper->_db_eLink->internal_obj = parents;
|
||||||
helper->_db_eLink->is_in = FALSE;
|
helper->_db_eLink->is_in = FALSE;
|
||||||
|
@ -411,7 +414,10 @@ void DigParameterData(CKParameterLocal* p, scriptDatabase* db, dbScriptDataStruc
|
||||||
if (p->GetParameterClassID() && p->GetValueObject(false)) {
|
if (p->GetParameterClassID() && p->GetValueObject(false)) {
|
||||||
helper_pDataExport("id", (long)p->GetValueObject(false)->GetID(), db, helper, parents);
|
helper_pDataExport("id", (long)p->GetValueObject(false)->GetID(), db, helper, parents);
|
||||||
helper_pDataExport("name", p->GetValueObject(false)->GetName(), 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;
|
return;
|
||||||
}
|
}
|
||||||
//float
|
//float
|
||||||
|
|
|
@ -5,4 +5,10 @@
|
||||||
|
|
||||||
//void __declspec(noreturn) FAKE_THROW();
|
//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
|
#endif
|
|
@ -126,7 +126,9 @@ void PluginMenuCallback(int commandID) {
|
||||||
IterateMessage(ctx->GetMessageManager(), _db, _helper);
|
IterateMessage(ctx->GetMessageManager(), _db, _helper);
|
||||||
IterateAttribute(ctx->GetAttributeManager(), _db, _helper);
|
IterateAttribute(ctx->GetAttributeManager(), _db, _helper);
|
||||||
IteratePlugin(CKGetPluginManager(), _db, _helper);
|
IteratePlugin(CKGetPluginManager(), _db, _helper);
|
||||||
|
#if !defined(VIRTOOLS_21)
|
||||||
IterateVariable(ctx->GetVariableManager(), _db, _helper);
|
IterateVariable(ctx->GetVariableManager(), _db, _helper);
|
||||||
|
#endif
|
||||||
|
|
||||||
//release all
|
//release all
|
||||||
_helper->dispose();
|
_helper->dispose();
|
||||||
|
|
|
@ -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");
|
printf("Report bug: https://github.com/yyc12345/SuperScriptMaterializer/issues\n");
|
||||||
|
|
||||||
// ====================== init ck2 engine
|
// ====================== init ck2 engine
|
||||||
|
#if defined(VIRTOOLS_21)
|
||||||
|
CommonAssert(LoadLibrary("CK2.dll") != NULL, "Error loading CK2.dll");
|
||||||
|
#endif
|
||||||
|
|
||||||
CommonAssert(!CKStartUp(), "CKStartUp Error");
|
CommonAssert(!CKStartUp(), "CKStartUp Error");
|
||||||
CKPluginManager* pluginManager = CKGetPluginManager();
|
CKPluginManager* pluginManager = CKGetPluginManager();
|
||||||
CommonAssert(pluginManager != NULL, "PluginManager = null");
|
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);
|
IterateMessage(context->GetMessageManager(), _env_db, _env_helper);
|
||||||
IterateAttribute(context->GetAttributeManager(), _env_db, _env_helper);
|
IterateAttribute(context->GetAttributeManager(), _env_db, _env_helper);
|
||||||
IteratePlugin(CKGetPluginManager(), _env_db, _env_helper);
|
IteratePlugin(CKGetPluginManager(), _env_db, _env_helper);
|
||||||
|
#if !defined(VIRTOOLS_21)
|
||||||
IterateVariable(context->GetVariableManager(), _env_db, _env_helper);
|
IterateVariable(context->GetVariableManager(), _env_db, _env_helper);
|
||||||
|
#endif
|
||||||
|
|
||||||
// free
|
// free
|
||||||
_script_helper->dispose();
|
_script_helper->dispose();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user