fix: fix various compile error.
- fix various compile error to let plugin now can be compiled.
This commit is contained in:
@@ -95,8 +95,7 @@ INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${VIRTOOLS_HEADER_PATH}"
|
||||
)
|
||||
# Setup lib files
|
||||
set_target_properties(VirtoolsSDK PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES
|
||||
set(VirtoolsSDK_LIBS_LIST
|
||||
# Both standalone and plugin build type needed
|
||||
"${VIRTOOLS_LIB_PATH}/CK2.lib"
|
||||
"${VIRTOOLS_LIB_PATH}/VxMath.lib"
|
||||
@@ -104,6 +103,11 @@ INTERFACE_LINK_LIBRARIES
|
||||
"$<$<STREQUAL:${MATERIALIZER_BUILD_TYPE},plugin>:${VIRTOOLS_LIB_PATH}/DllEditor.lib>"
|
||||
"$<$<STREQUAL:${MATERIALIZER_BUILD_TYPE},plugin>:${VIRTOOLS_LIB_PATH}/InterfaceControls.lib>"
|
||||
"$<$<STREQUAL:${MATERIALIZER_BUILD_TYPE},plugin>:${VIRTOOLS_LIB_PATH}/CKControls.lib>"
|
||||
# Virtools 5.0 special
|
||||
"$<$<STREQUAL:${VIRTOOLS_VERSION},50>:${VIRTOOLS_LIB_PATH}/CKKernelInit.lib>"
|
||||
)
|
||||
set_target_properties(VirtoolsSDK PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES "${VirtoolsSDK_LIBS_LIST}"
|
||||
)
|
||||
# Setup compile macros
|
||||
target_compile_definitions(VirtoolsSDK
|
||||
@@ -111,7 +115,7 @@ INTERFACE
|
||||
# Virtools version macro
|
||||
"VIRTOOLS_${VIRTOOLS_VERSION}"
|
||||
# Virtools 5.0 standalone mode need an extra macro
|
||||
"$<$<AND:$<STREQUAL:${MATERIALIZER_BUILD_TYPE},plugin>,$<STREQUAL:${VIRTOOLS_VERSION},50>>:VIRTOOLS_USER_SDK>"
|
||||
"$<$<AND:$<STREQUAL:${MATERIALIZER_BUILD_TYPE},standalone>,$<STREQUAL:${VIRTOOLS_VERSION},50>>:VIRTOOLS_USER_SDK>"
|
||||
)
|
||||
# Setup compiler options
|
||||
target_compile_options(VirtoolsSDK
|
||||
|
||||
@@ -17,14 +17,14 @@ FILES
|
||||
target_include_directories(VSWDecorator
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
YYCCommonplace
|
||||
YYCC::YYCCommonplace
|
||||
SQLite3::SQLite3
|
||||
VSWShared
|
||||
)
|
||||
# Setup linked library
|
||||
target_link_libraries(VSWDecorator
|
||||
PRIVATE
|
||||
YYCCommonplace
|
||||
YYCC::YYCCommonplace
|
||||
SQLite3::SQLite3
|
||||
VSWShared
|
||||
)
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/../cmake/init_materializer_env.cmake)
|
||||
|
||||
# Create library or executable according to build type
|
||||
if (VSW_MATERIALIZER_BUILD_TYPE STREQUAL "plugin")
|
||||
add_library(VSWMaterializer STATIC "")
|
||||
if (MATERIALIZER_BUILD_TYPE STREQUAL "plugin")
|
||||
add_library(VSWMaterializer SHARED "")
|
||||
else ()
|
||||
add_executable(VSWMaterializer "")
|
||||
endif ()
|
||||
@@ -12,6 +12,10 @@ target_sources(VSWMaterializer
|
||||
PRIVATE
|
||||
# Sources
|
||||
main.cpp
|
||||
PluginMain.cpp
|
||||
StandaloneMain.cpp
|
||||
# Defination file
|
||||
"$<$<STREQUAL:${MATERIALIZER_BUILD_TYPE},plugin>:Materializer.def>"
|
||||
)
|
||||
# Setup header files
|
||||
target_sources(VSWMaterializer
|
||||
@@ -21,12 +25,14 @@ FILES
|
||||
# Headers
|
||||
stdafx.hpp
|
||||
resource.h
|
||||
PluginMain.hpp
|
||||
StandaloneMain.hpp
|
||||
)
|
||||
# Setup header infomations
|
||||
target_include_directories(VSWMaterializer
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
YYCCommonplace
|
||||
YYCC::YYCCommonplace
|
||||
SQLite3::SQLite3
|
||||
VirtoolsSDK
|
||||
VSWShared
|
||||
@@ -34,7 +40,7 @@ PRIVATE
|
||||
# Setup linked library
|
||||
target_link_libraries(VSWMaterializer
|
||||
PRIVATE
|
||||
YYCCommonplace
|
||||
YYCC::YYCCommonplace
|
||||
SQLite3::SQLite3
|
||||
VirtoolsSDK
|
||||
VSWShared
|
||||
@@ -46,9 +52,22 @@ PROPERTIES
|
||||
CXX_STANDARD_REQUIRED 17
|
||||
CXX_EXTENSION OFF
|
||||
)
|
||||
# Setup MFC use
|
||||
set_target_properties(VSWMaterializer
|
||||
PROPERTIES
|
||||
CMAKE_MFC_FLAG 2
|
||||
)
|
||||
# MSVC specific correction
|
||||
target_compile_definitions(VSWMaterializer
|
||||
PRIVATE
|
||||
# MFC macro
|
||||
_AFXDLL
|
||||
# Materializer build type
|
||||
"MATERIALIZER_$<UPPER_CASE:${MATERIALIZER_BUILD_TYPE}>"
|
||||
# Materializer debug or release
|
||||
"$<$<CONFIG:Debug>:MATERIALIZER_DEBUG>"
|
||||
"$<$<CONFIG:Release,RelWithDebInfo,MinSizeRel>:MATERIALIZER_DEBUG>"
|
||||
# Multibyte encoding
|
||||
$<$<CXX_COMPILER_ID:MSVC>:MBCS>
|
||||
$<$<CXX_COMPILER_ID:MSVC>:_MBCS>
|
||||
)
|
||||
|
||||
114
materializer/PluginMain.cpp
Normal file
114
materializer/PluginMain.cpp
Normal file
@@ -0,0 +1,114 @@
|
||||
#include "PluginMain.hpp"
|
||||
|
||||
namespace VSW::Materializer::PluginMain {
|
||||
|
||||
#ifdef MATERIALIZER_PLUGIN
|
||||
|
||||
PluginInterface* g_Plugininterface = nullptr;
|
||||
PluginInfo g_PluginInfo;
|
||||
CMenu* g_MainMenu = nullptr;
|
||||
|
||||
static void PluginMenuCallback(int command_id) {
|
||||
AFX_MANAGE_STATE(AfxGetStaticModuleState());
|
||||
|
||||
switch (command_id) {
|
||||
case 0:
|
||||
{
|
||||
MessageBoxW(nullptr, L"Work in Progress", L"WIP", MB_ICONINFORMATION + MB_OK);
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
MessageBoxW(nullptr, L"Work in Progress", L"WIP", MB_ICONINFORMATION + MB_OK);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
MessageBoxW(nullptr, L"Work in Progress", L"WIP", MB_ICONINFORMATION + MB_OK);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
ShellExecuteW(NULL, L"open", L"https://github.com/yyc12345/SuperScriptMaterializer/issues", NULL, NULL, SW_SHOWNORMAL);
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
const wchar_t* body =
|
||||
L"VSW Materializer v2.0.0 - Virtools Schematic Weaver Materializer.\n"
|
||||
L"The exporter of universal Virtools scripts analyser.\n"
|
||||
L"Under GPL v3 License.\n"
|
||||
L"Project Home Page: https://github.com/yyc12345/SuperScriptMaterializer";
|
||||
MessageBoxW(nullptr, body, L"About VSW Materializer", MB_ICONINFORMATION + MB_OK);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void InitMenu() {
|
||||
if (!g_Plugininterface)
|
||||
return;
|
||||
|
||||
g_MainMenu = g_Plugininterface->AddPluginMenu("VSW Materializer", 20, NULL, (VoidFunc1Param)PluginMenuCallback);
|
||||
}
|
||||
|
||||
static void RemoveMenu() {
|
||||
if (!g_Plugininterface || !g_MainMenu)
|
||||
return;
|
||||
g_Plugininterface->RemovePluginMenu(g_MainMenu);
|
||||
}
|
||||
|
||||
static void UpdateMenu() {
|
||||
g_Plugininterface->ClearPluginMenu(g_MainMenu);
|
||||
|
||||
g_Plugininterface->AddPluginMenuItem(g_MainMenu, 0, "Export Scripts");
|
||||
g_Plugininterface->AddPluginMenuItem(g_MainMenu, 1, "Export Context");
|
||||
g_Plugininterface->AddPluginMenuItem(g_MainMenu, 2, "Export Environment");
|
||||
g_Plugininterface->AddPluginMenuItem(g_MainMenu, -1, NULL, TRUE);
|
||||
g_Plugininterface->AddPluginMenuItem(g_MainMenu, 3, "Report Bug");
|
||||
g_Plugininterface->AddPluginMenuItem(g_MainMenu, 4, "About VSW Materializer");
|
||||
|
||||
|
||||
g_Plugininterface->UpdatePluginMenu(g_MainMenu);
|
||||
}
|
||||
|
||||
static void PluginCallback(PluginInfo::CALLBACK_REASON reason, PluginInterface* plugininterface) {
|
||||
switch (reason) {
|
||||
case PluginInfo::CR_LOAD:
|
||||
{
|
||||
g_Plugininterface = plugininterface;
|
||||
InitMenu();
|
||||
UpdateMenu();
|
||||
break;
|
||||
}
|
||||
case PluginInfo::CR_UNLOAD:
|
||||
{
|
||||
RemoveMenu();
|
||||
g_Plugininterface = nullptr;
|
||||
break;
|
||||
}
|
||||
case PluginInfo::CR_NEWCOMPOSITIONNAME:
|
||||
break;
|
||||
case PluginInfo::CR_NOTIFICATION:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void InitializePluginInfo() {
|
||||
strcpy(g_PluginInfo.m_Name, "VSW Materializer");
|
||||
g_PluginInfo.m_PluginType = PluginInfo::PT_EDITOR;
|
||||
g_PluginInfo.m_PluginType = (PluginInfo::PLUGIN_TYPE)(g_PluginInfo.m_PluginType | PluginInfo::PTF_RECEIVENOTIFICATION);
|
||||
g_PluginInfo.m_PluginCallback = PluginCallback;
|
||||
}
|
||||
|
||||
PluginInfo* GetPluginInfo() {
|
||||
return &g_PluginInfo;
|
||||
}
|
||||
PluginInterface* GetPluginInterface() {
|
||||
return g_Plugininterface;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
12
materializer/PluginMain.hpp
Normal file
12
materializer/PluginMain.hpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
#include "stdafx.hpp"
|
||||
|
||||
namespace VSW::Materializer::PluginMain {
|
||||
|
||||
#ifdef MATERIALIZER_PLUGIN
|
||||
void InitializePluginInfo();
|
||||
PluginInfo* GetPluginInfo();
|
||||
PluginInterface* GetPluginInterface();
|
||||
#endif
|
||||
|
||||
}
|
||||
89
materializer/StandaloneMain.cpp
Normal file
89
materializer/StandaloneMain.cpp
Normal file
@@ -0,0 +1,89 @@
|
||||
#include "StandaloneMain.hpp"
|
||||
|
||||
namespace VSW::Materializer::StandaloneMain {
|
||||
|
||||
#ifdef MATERIALIZER_STANDALONE
|
||||
|
||||
void PlayerMain(int argc, char* argv[]) {
|
||||
printf("Super Script Materializer\n");
|
||||
printf("Homepage: https://github.com/yyc12345/SuperScriptMaterializer\n");
|
||||
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");
|
||||
CommonAssert(pluginManager->ParsePlugins("RenderEngines") > 0, "Error loading RenderEngines");
|
||||
CommonAssert(pluginManager->ParsePlugins("Managers") > 0, "Error loading Managers");
|
||||
CommonAssert(pluginManager->ParsePlugins("BuildingBlocks") > 0, "Error loading BuildingBlocks");
|
||||
CommonAssert(pluginManager->ParsePlugins("Plugins") > 0, "Error loading Plugins");
|
||||
|
||||
// ====================== create context and load file
|
||||
CKContext* context = NULL;
|
||||
CommonAssert(!CKCreateContext(&context, NULL), "CKCreateContext Error");
|
||||
|
||||
CKObjectArray* array = CreateCKObjectArray();
|
||||
CommonAssert(!context->Load((char*)virtools_composition, array), "CKContext->Load() Error");
|
||||
|
||||
printf("Parsing %s...\n", virtools_composition);
|
||||
|
||||
// ====================== do SSMaterializerDatabase export
|
||||
// define and Init
|
||||
scriptDatabase* _script_db = new scriptDatabase();
|
||||
dbScriptDataStructHelper* _script_helper = new dbScriptDataStructHelper();
|
||||
envDatabase* _env_db = new envDatabase();
|
||||
dbEnvDataStructHelper* _env_helper = new dbEnvDataStructHelper();
|
||||
|
||||
DeleteFile(script_db_path);
|
||||
DeleteFile(env_db_path);
|
||||
_script_db->open(script_db_path);
|
||||
_script_helper->init(context->GetParameterManager());
|
||||
_env_db->open(env_db_path);
|
||||
_env_helper->init();
|
||||
|
||||
// export
|
||||
IterateScript(context, _script_db, _script_helper);
|
||||
|
||||
IterateParameterOperation(context->GetParameterManager(), _env_db, _env_helper);
|
||||
IterateParameter(context->GetParameterManager(), _env_db, _env_helper);
|
||||
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();
|
||||
_script_db->close();
|
||||
_env_helper->dispose();
|
||||
_env_db->close();
|
||||
delete _script_helper;
|
||||
delete _script_db;
|
||||
delete _env_helper;
|
||||
delete _env_db;
|
||||
|
||||
printf("Done!");
|
||||
|
||||
// ====================== free resources and shutdown engine
|
||||
DeleteCKObjectArray(array);
|
||||
context->Reset();
|
||||
context->ClearAll();
|
||||
|
||||
// todo: Virtools 4.0 standalone version throw exception in there, but i don't knwo why
|
||||
// but it doesn't affect SSMaterializerDatabase export, perhaps
|
||||
CKCloseContext(context);
|
||||
|
||||
CKShutdown();
|
||||
|
||||
// todo: Virtools 2.5 standalone version throw exception in there, but i don't knwo why
|
||||
// but it doesn't affect SSMaterializerDatabase export, perhaps
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
10
materializer/StandaloneMain.hpp
Normal file
10
materializer/StandaloneMain.hpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
#include "stdafx.hpp"
|
||||
|
||||
namespace VSW::Materializer::StandaloneMain {
|
||||
|
||||
#ifdef MATERIALIZER_STANDALONE
|
||||
void PlayerMain(int argc, char* argv[]);
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
#include "stdafx.hpp"
|
||||
#include "PluginMain.hpp"
|
||||
#include "StandaloneMain.hpp"
|
||||
|
||||
#if defined(MATERIALIZER_PLUGIN)
|
||||
|
||||
int GetVirtoolsPluginInfoCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
PluginInfo* GetVirtoolsPluginInfo(int index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return VSW::Materializer::PluginMain::GetPluginInfo();
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
class CMaterializer : CWinApp {
|
||||
public:
|
||||
virtual BOOL InitInstance() override {
|
||||
// register unhandler exception handler
|
||||
#ifdef MATERIALIZER_RELEASE
|
||||
YYCC::ExceptionHelper::Register(vtobjplugin::VirtoolsMenu::UnhandledExceptionCallback);
|
||||
#endif
|
||||
|
||||
// init plugin info
|
||||
VSW::Materializer::PluginMain::InitializePluginInfo();
|
||||
|
||||
return CWinApp::InitInstance();
|
||||
}
|
||||
virtual int ExitInstance() override {
|
||||
|
||||
// unregister unhandler exception handler
|
||||
#ifdef MATERIALIZER_RELEASE
|
||||
YYCC::ExceptionHelper::Unregister();
|
||||
#endif
|
||||
|
||||
return CWinApp::ExitInstance();
|
||||
}
|
||||
};
|
||||
CMaterializer theApp;
|
||||
|
||||
#else
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
VSW::Materializer::StandaloneMain::PlayerMain(argc, argv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
#pragma once
|
||||
|
||||
// Check build macros
|
||||
#if !defined(MATERIALIZER_PLUGIN) && !defined(MATERIALIZER_STANDALONE)
|
||||
#error "You must define one of MATERIALIZER_PLUGIN or MATERIALIZER_STANDALONE to represent the build type of materializer!"
|
||||
#endif
|
||||
#if !defined(MATERIALIZER_DEBUG) && !defined(MATERIALIZER_RELEASE)
|
||||
#error "You must define one of MATERIALIZER_DEBUG or MATERIALIZER_RELEASE!"
|
||||
#endif
|
||||
#if !defined(VIRTOOLS_50) && !defined(VIRTOOLS_40) && !defined(VIRTOOLS_35) && !defined(VIRTOOLS_30) && !defined(VIRTOOLS_25) && !defined(VIRTOOLS_21)
|
||||
#error "Lost essential Virtools version macro!"
|
||||
#endif
|
||||
|
||||
#pragma region Windows and Virtools
|
||||
#include <WinImportPrefix.hpp>
|
||||
|
||||
#pragma region Windows Headers
|
||||
|
||||
#include <SDKDDKVer.h>
|
||||
|
||||
// Only plugin mode involve MFC headers
|
||||
#if defined(MATERIALIZER_PLUGIN)
|
||||
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
|
||||
|
||||
#include <afxwin.h> // MFC core and standard components
|
||||
#include <afxext.h> // MFC extensions
|
||||
|
||||
#ifndef _AFX_NO_OLE_SUPPORT
|
||||
#include <afxole.h> // MFC OLE classes
|
||||
#include <afxodlgs.h> // MFC OLE dialog classes
|
||||
#include <afxdisp.h> // MFC Automation classes
|
||||
#endif // _AFX_NO_OLE_SUPPORT
|
||||
|
||||
|
||||
#ifndef _AFX_NO_DB_SUPPORT
|
||||
#include <afxdb.h> // MFC ODBC database classes
|
||||
#endif // _AFX_NO_DB_SUPPORT
|
||||
|
||||
#ifndef _AFX_NO_DAO_SUPPORT
|
||||
#include <afxdao.h> // MFC DAO database classes
|
||||
#endif // _AFX_NO_DAO_SUPPORT
|
||||
|
||||
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
|
||||
#ifndef _AFX_NO_AFXCMN_SUPPORT
|
||||
#include <afxcmn.h> // MFC support for Windows Common Controls
|
||||
#endif // _AFX_NO_AFXCMN_SUPPORT
|
||||
#endif
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Virtools Headers
|
||||
|
||||
#include "CKAll.h"
|
||||
|
||||
// Only plugi mode need include extra headers
|
||||
#if defined(MATERIALIZER_PLUGIN)
|
||||
#include "VIControls.h"
|
||||
#include "CKControlsAll.h"
|
||||
#include "VEP_ScriptActionMenu.h"
|
||||
#include "VEP_KeyboardShortcutManager.h"
|
||||
#include "VEP_All.h"
|
||||
#endif
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#include <WinImportSuffix.hpp>
|
||||
#pragma endregion
|
||||
|
||||
#pragma region YYCC Headers
|
||||
#include <YYCCommonplace.hpp>
|
||||
#pragma endregion
|
||||
|
||||
|
||||
Reference in New Issue
Block a user