aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2018-02-27 01:00:47 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2018-02-27 01:00:47 +0800
commit1948342aa869ad284d3bed11abbec03bc56ac612 (patch)
treeddda137e56aa1086be0f3edb67e1ffcc5be17b5a
downloadScript-Materializer-1948342aa869ad284d3bed11abbec03bc56ac612.tar.xz
the fscking initial commit.
-rw-r--r--Callback.cpp32
-rw-r--r--Callback.h3
-rw-r--r--Editor.cpp108
-rw-r--r--Editor.def8
-rw-r--r--Editor.h51
-rw-r--r--Fsck.rc286
-rw-r--r--Fsck.vcxproj187
-rw-r--r--LICENSE.TXT24
-rw-r--r--Menu.cpp652
-rw-r--r--Menu.h13
-rw-r--r--README.md16
-rw-r--r--Script Materializer.sln25
-rw-r--r--StdAfx.cpp8
-rw-r--r--StdAfx.h40
-rw-r--r--icon1.icobin0 -> 1406 bytes
-rw-r--r--resource.h18
16 files changed, 1471 insertions, 0 deletions
diff --git a/Callback.cpp b/Callback.cpp
new file mode 100644
index 0000000..b96a30a
--- /dev/null
+++ b/Callback.cpp
@@ -0,0 +1,32 @@
+#include "stdafx.h"
+#include "Callback.h"
+#include "Menu.h"
+
+//static plugin interface that allow direct communication with Virtools Dev
+PluginInterface* s_Plugininterface = NULL;
+
+
+//main plugin callback for Virtools Dev
+void PluginCallback(PluginInfo::CALLBACK_REASON reason,PluginInterface* plugininterface)
+{
+ switch(reason)
+ {
+ case PluginInfo::CR_LOAD:
+ {
+ s_Plugininterface = plugininterface;
+ InitMenu();
+ UpdateMenu();
+ }break;
+ case PluginInfo::CR_UNLOAD:
+ {
+ RemoveMenu();
+ s_Plugininterface = NULL;
+ }break;
+ case PluginInfo::CR_NEWCOMPOSITIONNAME:
+ {
+ }break;
+ case PluginInfo::CR_NOTIFICATION:
+ {
+ }break;
+ }
+}
diff --git a/Callback.h b/Callback.h
new file mode 100644
index 0000000..f023e88
--- /dev/null
+++ b/Callback.h
@@ -0,0 +1,3 @@
+#pragma once
+
+void PluginCallback(PluginInfo::CALLBACK_REASON reason,PluginInterface* plugininterface);
diff --git a/Editor.cpp b/Editor.cpp
new file mode 100644
index 0000000..2441245
--- /dev/null
+++ b/Editor.cpp
@@ -0,0 +1,108 @@
+// Editor.cpp : Defines the initialization routines for the DLL.
+//
+
+#include "stdafx.h"
+#include "Editor.h"
+#include "Callback.h"
+
+#ifdef _MFCDEBUGNEW
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+#endif
+
+TestEditorDlg* g_Editor = NULL;
+TestToolbarDlg* g_Toolbar = NULL;
+
+//----------------------------------------
+//The Plugin Info structure that must be filled for Virtools Dev to load effectively the plugin
+PluginInfo g_PluginInfo0;
+
+//Returns the number of plugin contained in this dll
+//this function must be exported (have a .def file with its name or use __declspec( dllexport )
+int GetVirtoolsPluginInfoCount()
+{
+ return 1;
+}
+
+//returns the ptr of the (index)th plugininfo structure of this dll
+//this function must be exported (have a .def file with its name or use __declspec( dllexport )
+PluginInfo* GetVirtoolsPluginInfo(int index)
+{
+ switch(index)
+ {
+ case 0:
+ return &g_PluginInfo0;
+ }
+ return NULL;
+}
+
+//
+// Note!
+//
+// If this DLL is dynamically linked against the MFC
+// DLLs, any functions exported from this DLL which
+// call into MFC must have the AFX_MANAGE_STATE macro
+// added at the very beginning of the function.
+//
+// For example:
+//
+// extern "C" BOOL PASCAL EXPORT ExportedFunction()
+// {
+// AFX_MANAGE_STATE(AfxGetStaticModuleState());
+// // normal function body here
+// }
+//
+// It is very important that this macro appear in each
+// function, prior to any calls into MFC. This means that
+// it must appear as the first statement within the
+// function, even before any object variable declarations
+// as their constructors may generate calls into the MFC
+// DLL.
+//
+// Please see MFC Technical Notes 33 and 58 for additional
+// details.
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CTestEditorApp
+
+BEGIN_MESSAGE_MAP(CTestEditorApp, CWinApp)
+ //{{AFX_MSG_MAP(CTestEditorApp)
+ // NOTE - the ClassWizard will add and remove mapping macros here.
+ // DO NOT EDIT what you see in these blocks of generated code!
+ //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CTestEditorApp construction
+
+CTestEditorApp::CTestEditorApp()
+{
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// The one and only CTestEditorApp object
+
+CTestEditorApp theApp;
+
+BOOL CTestEditorApp::InitInstance()
+{
+ // TODO: Add your specialized code here and/or call the base class
+
+ strcpy(g_PluginInfo0.m_Name,"Script Materializer");
+ g_PluginInfo0.m_PluginType = PluginInfo::PT_EDITOR;
+ g_PluginInfo0.m_PluginType = (PluginInfo::PLUGIN_TYPE)(g_PluginInfo0.m_PluginType | PluginInfo::PTF_RECEIVENOTIFICATION);
+ g_PluginInfo0.m_PluginCallback = PluginCallback;
+
+ return CWinApp::InitInstance();
+}
+
+int CTestEditorApp::ExitInstance()
+{
+ // TODO: Add your specialized code here and/or call the base class
+
+ return CWinApp::ExitInstance();
+}
diff --git a/Editor.def b/Editor.def
new file mode 100644
index 0000000..3ac3e6d
--- /dev/null
+++ b/Editor.def
@@ -0,0 +1,8 @@
+; Editor.def : Declares the module parameters for the DLL.
+
+LIBRARY "Editor"
+DESCRIPTION 'Editor Windows Dynamic Link Library'
+
+EXPORTS
+ GetVirtoolsPluginInfoCount
+ GetVirtoolsPluginInfo
diff --git a/Editor.h b/Editor.h
new file mode 100644
index 0000000..17aa73a
--- /dev/null
+++ b/Editor.h
@@ -0,0 +1,51 @@
+// TestEditor.h : main header file for the EDITOR DLL
+//
+
+#pragma once
+
+#ifndef __AFXWIN_H__
+ #error include 'stdafx.h' before including this file for PCH
+#endif
+
+#include "resource.h" // main symbols
+
+class TestEditorDlg;
+class TestToolbarDlg;
+
+extern TestEditorDlg* g_Editor;
+extern TestToolbarDlg* g_Toolbar;
+
+//plugin interface for communication with Virtools Dev
+extern PluginInterface* s_Plugininterface;
+
+/////////////////////////////////////////////////////////////////////////////
+// CEditorApp
+// See Editor.cpp for the implementation of this class
+//
+
+class CTestEditorApp : public CWinApp
+{
+
+public:
+ CTestEditorApp();
+
+// Overrides
+ // ClassWizard generated virtual function overrides
+ //{{AFX_VIRTUAL(TestCEditorApp)
+ public:
+ virtual BOOL InitInstance();
+ virtual int ExitInstance();
+ //}}AFX_VIRTUAL
+
+ //{{AFX_MSG(TestCEditorApp)
+ // NOTE - the ClassWizard will add and remove member functions here.
+ // DO NOT EDIT what you see in these blocks of generated code !
+ //}}AFX_MSG
+ DECLARE_MESSAGE_MAP()
+};
+
+
+/////////////////////////////////////////////////////////////////////////////
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
diff --git a/Fsck.rc b/Fsck.rc
new file mode 100644
index 0000000..6061dc8
--- /dev/null
+++ b/Fsck.rc
@@ -0,0 +1,286 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#include ""afxres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#define _AFX_NO_SPLITTER_RESOURCES\r\n"
+ "#define _AFX_NO_OLE_RESOURCES\r\n"
+ "#define _AFX_NO_TRACKER_RESOURCES\r\n"
+ "#define _AFX_NO_PROPERTY_RESOURCES\r\n"
+ "\r\n"
+ "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
+ "#ifdef _WIN32\r\n"
+ "LANGUAGE 9, 1\r\n"
+ "#pragma code_page(1252)\r\n"
+ "#endif //_WIN32\r\n"
+// "#include ""res\\TestEditor.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
+ "#include ""afxres.rc"" // Standard components\r\n"
+ "#endif\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+#ifndef _MAC
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 0,01
+ PRODUCTVERSION 0,01
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904B0"
+ BEGIN
+ VALUE "CompanyName", "Chrisoft\0"
+ VALUE "FileDescription", "Fsck DLL\0"
+ VALUE "FileVersion", "0.01\0"
+ VALUE "InternalName", "Script Materializer\0"
+ VALUE "LegalCopyright", "2018 Chrisoft\0"
+ VALUE "OriginalFilename", "Script Materializer.dll\0"
+ VALUE "ProductName", "Fsck for Virtools\0"
+ VALUE "ProductVersion", "0.01\0"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
+
+#endif // !_MAC
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_EDITOR DIALOG DISCARDABLE 0, 0, 186, 97
+STYLE WS_CHILD
+FONT 8, "MS Sans Serif"
+BEGIN
+END
+
+IDD_TOOLBAR DIALOG DISCARDABLE 0, 0, 186, 97
+STYLE WS_CHILD
+FONT 8, "MS Sans Serif"
+BEGIN
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_EDITORICON ICON DISCARDABLE "icon1.ico"
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+#define _AFX_NO_SPLITTER_RESOURCES
+#define _AFX_NO_OLE_RESOURCES
+#define _AFX_NO_TRACKER_RESOURCES
+#define _AFX_NO_PROPERTY_RESOURCES
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE 9, 1
+#pragma code_page(1252)
+#endif //_WIN32
+//#include "res\TestEditor.rc2" // non-Microsoft Visual C++ edited resources
+#include "afxres.rc" // Standard components
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Fsck.vcxproj b/Fsck.vcxproj
new file mode 100644
index 0000000..2656938
--- /dev/null
+++ b/Fsck.vcxproj
@@ -0,0 +1,187 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{D20B1C85-814D-4F05-A840-634F9E062019}</ProjectGuid>
+ <SccProjectName />
+ <SccAuxPath />
+ <SccLocalPath>.</SccLocalPath>
+ <SccProvider />
+ <Keyword>MFCProj</Keyword>
+ <ProjectName>Script Materializer</ProjectName>
+ <WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <PlatformToolset>v141</PlatformToolset>
+ <UseOfMfc>Dynamic</UseOfMfc>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <PlatformToolset>v141</PlatformToolset>
+ <UseOfMfc>Dynamic</UseOfMfc>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>15.0.27130.2020</_ProjectFileVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <OutDir>..\..\..\Temp\$(Platform)\$(ProjectName)\$(Configuration)\</OutDir>
+ <IntDir>..\..\..\Temp\$(Platform)\$(ProjectName)\$(Configuration)\</IntDir>
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <OutDir>..\..\..\Temp\$(Platform)\$(ProjectName)\$(Configuration)\</OutDir>
+ <IntDir>..\..\..\Temp\$(Platform)\$(ProjectName)\$(Configuration)\</IntDir>
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <AdditionalIncludeDirectories>..\..\InterfaceControls\include;..\..\..\Includes;..\..\CKControls;..\..\..\Behaviors\VSLManager;..\..\..\VSL;../DllEditorLib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
+ <PrecompiledHeaderOutputFile>$(IntDir)$(ProjectName).pch</PrecompiledHeaderOutputFile>
+ <AssemblerListingLocation />
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)$(ProjectName).pdb</ProgramDataBaseFileName>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <CompileAs>Default</CompileAs>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>vxmath.lib;DllEditor.lib;ck2.lib;InterfaceControls.lib;CKControls.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>..\..\..\..\InterfacePlugins\$(ProjectName).dll</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <AdditionalLibraryDirectories>..\..\..\Lib\$(Platform)\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <ModuleDefinitionFile>.\TestEditor.def</ModuleDefinitionFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>..\..\..\..\InterfacePlugins\$(ProjectName).pdb</ProgramDatabaseFile>
+ <SubSystem>Windows</SubSystem>
+ <ImportLibrary>$(OutDir)$(ProjectName).lib</ImportLibrary>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ <Midl>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>true</MkTypLibCompatible>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <TargetEnvironment>Win32</TargetEnvironment>
+ <TypeLibraryName>.\Release/Test.tlb</TypeLibraryName>
+ <HeaderFileName />
+ </Midl>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x0409</Culture>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\InterfaceControls\include;E:\Virtools Dev 3.5 Full\Sdk\Includes;..\..\CKControls;..\..\..\Behaviors\VSLManager;..\..\..\VSL;../DllEditorLib;\\devserver\dev\PlatformSDK\include;.\jsoncpp-1.8.4\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_WINDOWS;_USRDLL;VX_MEM_RELEASE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
+ <PrecompiledHeaderOutputFile>$(IntDir)$(ProjectName).pch</PrecompiledHeaderOutputFile>
+ <AssemblerListingLocation />
+ <ObjectFileName>$(IntDir)</ObjectFileName>
+ <ProgramDataBaseFileName>$(OutDir)$(ProjectName).pdb</ProgramDataBaseFileName>
+ <WarningLevel>Level3</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ <CompileAs>Default</CompileAs>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>vxmath.lib;DllEditor.lib;ck2.lib;InterfaceControls.lib;CKControls.lib;lib_json.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OutputFile>E:\Virtools Dev 3.5 Full\InterfacePlugins\$(ProjectName).dll</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <AdditionalLibraryDirectories>E:\Virtools Dev 3.5 Full\Sdk\Lib\$(Platform)\Release;.\jsoncpp-1.8.4\makefiles\msvc2010\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <ModuleDefinitionFile>.\Editor.def</ModuleDefinitionFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>..\..\..\..\InterfacePlugins\$(ProjectName).pdb</ProgramDatabaseFile>
+ <SubSystem>Windows</SubSystem>
+ <ImportLibrary>$(OutDir)$(ProjectName).lib</ImportLibrary>
+ <TargetMachine>MachineX86</TargetMachine>
+ <IgnoreSpecificDefaultLibraries>
+ </IgnoreSpecificDefaultLibraries>
+ </Link>
+ <Midl>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>true</MkTypLibCompatible>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <TargetEnvironment>Win32</TargetEnvironment>
+ <TypeLibraryName>.\Debug/Test.tlb</TypeLibraryName>
+ <HeaderFileName />
+ </Midl>
+ <ResourceCompile>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x0409</Culture>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="StdAfx.cpp">
+ <Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
+ <BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
+ <Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
+ </ClCompile>
+ <ClCompile Include="Callback.cpp">
+ <Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
+ <BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
+ <Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
+ </ClCompile>
+ <ClCompile Include="Editor.cpp" />
+ <ClCompile Include="Menu.cpp">
+ <Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
+ <BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
+ <Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="Fsck.rc" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Editor.def" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="resource.h" />
+ <ClInclude Include="StdAfx.h" />
+ <ClInclude Include="Callback.h" />
+ <ClInclude Include="Editor.h" />
+ <ClInclude Include="Menu.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <Image Include="icon1.ico" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets" />
+</Project> \ No newline at end of file
diff --git a/LICENSE.TXT b/LICENSE.TXT
new file mode 100644
index 0000000..e9d14b5
--- /dev/null
+++ b/LICENSE.TXT
@@ -0,0 +1,24 @@
+Copyright (c) 2018, Chris Xiong
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of the copyright holder nor the names of its
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/Menu.cpp b/Menu.cpp
new file mode 100644
index 0000000..0a34679
--- /dev/null
+++ b/Menu.cpp
@@ -0,0 +1,652 @@
+//Interface plugin for Virtools Dev/3DVIA Virtools
+//Virtools Script2Json & Building Block toolbox
+//By Chris Xiong, 2018
+//License: 3-Clause BSD
+/*
+Copyright (c) 2018, Chris Xiong
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of the copyright holder nor the names of its
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+#include "stdafx.h"
+#include "Menu.h"
+#include <map>
+#include <utility>
+#include <sstream>
+#include <string>
+#include "json/json.h"
+
+extern PluginInterface* s_Plugininterface;
+
+void PluginMenuCallback(int commandID);
+
+//static main menu
+CMenu* s_MainMenu = NULL;
+
+#define PLUGINMENU_MAXENTRIES 20 //put there the max entries your menu may use
+
+//adds the menu to Virtools Dev main menu
+void InitMenu()
+{
+ if (!s_Plugininterface)
+ return;
+
+ s_MainMenu = s_Plugininterface->AddPluginMenu(STR_MAINMENUNAME,PLUGINMENU_MAXENTRIES,NULL,(VoidFunc1Param)PluginMenuCallback);
+}
+
+//removes the menu from Virtools Dev main menu
+void RemoveMenu()
+{
+ if (!s_Plugininterface || !s_MainMenu)
+ return;
+
+ s_Plugininterface->RemovePluginMenu(s_MainMenu);
+}
+
+//up to user.
+//(May be called on new composition notification for instance)
+//Note that first commandID can be 0
+//but last command ID must be lesser thanPLUGINMENU_MAXENTRIES
+void UpdateMenu()
+{
+ s_Plugininterface->ClearPluginMenu(s_MainMenu); //clear menu
+
+ s_Plugininterface->AddPluginMenuItem(s_MainMenu,0,"Fsck /dev/sda1");//dump to json
+ s_Plugininterface->AddPluginMenuItem(s_MainMenu,-1,NULL,TRUE);
+
+ //note : sub menu must have independent command ids that must be >=0
+ CMenu* sub0 = s_Plugininterface->AddPluginMenuItem(s_MainMenu,0,"Fsck /dev/sdb",FALSE,TRUE);//bb manipulation
+
+ s_Plugininterface->AddPluginMenuItem(sub0,1,"Fsck /dev/sdb1");//modify bb proto
+ s_Plugininterface->AddPluginMenuItem(sub0,2,"Fsck /dev/sdb2");//not implemented
+
+ s_Plugininterface->AddPluginMenuItem(s_MainMenu,-1,NULL,TRUE);
+ s_Plugininterface->AddPluginMenuItem(s_MainMenu,10,"Exit Fsck");
+
+ s_Plugininterface->UpdatePluginMenu(s_MainMenu); //update menu,always needed when you finished to update the menu
+ //unless you want the menu not to have Virtools Dev main menu color scheme.
+}
+
+//bool clone_script(CKParameter* source_script,CKParameter* dest_script);
+//bool clone_behavior(CKBehavior* src,CKBehavior* dest,CKBehavior* destpar);
+bool dump_script(CKParameter* script);
+bool dump_behavior(CKBehavior* src,Json::Value* dest,Json::Value* destpar);
+bool CKParameter2Json(CKParameter* p,Json::Value &v);
+void modify_bb_guid();
+
+//fill with your command IDs and your actions
+void PluginMenuCallback(int commandID)
+{
+ switch(commandID)
+ {
+ case 0:
+ {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ CKContext* ctx=s_Plugininterface->GetCKContext();
+ ParamEditDlg shitdialog(ctx);
+ shitdialog.SetTitle("Pick the shit you want to materialize");
+ CKParameter* srcshit=(CKParameter*)ctx->CreateObject(CKCID_PARAMETER,"source shit");
+ //CKParameter* destshit=(CKParameter*)ctx->CreateObject(CKCID_PARAMETER,"dest shit");
+ srcshit->SetGUID(CKPGUID_SCRIPT);
+ //destshit->SetGUID(CKPGUID_SCRIPT);
+ shitdialog.SetParameter(srcshit);
+ shitdialog.DoModal();
+ //shitdialog.SetParameter(destshit);
+ //shitdialog.DoModal();
+ //clone_script(srcshit,destshit);
+ dump_script(srcshit);
+ ctx->DestroyObject(srcshit);
+ //ctx->DestroyObject(destshit);
+ }
+ break;
+ case 1:
+ modify_bb_guid();
+ break;
+ case 10:
+ s_Plugininterface->GetCKContext()->OutputToConsole(
+ "Fsck for Virtools 0.01\n"
+ "A FileSystem Consistency Korruption tool.\n"
+ "By Chris Xiong, 2018\n"
+ "No warranty of any fscking kind comes with this fsck.\n\n"
+ "Copyright (c) 2018, Chris Xiong\n"
+ "All rights reserved.\n"
+ "\n"
+ "Redistribution and use in source and binary forms, with or without\n"
+ "modification, are permitted provided that the following conditions are met:\n"
+ " * Redistributions of source code must retain the above copyright\n"
+ " notice, this list of conditions and the following disclaimer.\n"
+ " * Redistributions in binary form must reproduce the above copyright\n"
+ " notice, this list of conditions and the following disclaimer in the\n"
+ " documentation and/or other materials provided with the distribution.\n"
+ " * Neither the name of the copyright holder nor the names of its\n"
+ " contributors may be used to endorse or promote products derived from\n"
+ " this software without specific prior written permission.\n"
+ "\n"
+ "THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n"
+ "ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n"
+ "WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n"
+ "DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\n"
+ "FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n"
+ "DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n"
+ "SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED\n"
+ "AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n"
+ "(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n"
+ "SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+ );
+ break;
+ }
+}
+
+template<typename Tag,typename Tag::type M>
+struct rob
+{
+ friend typename Tag::type get(Tag)
+ {return M;}
+};
+struct Behavior_blockdata
+{
+ typedef BehaviorBlockData* CKBehavior::*type;
+ friend type get(Behavior_blockdata);
+};
+template struct rob<Behavior_blockdata,&CKBehavior::m_BlockData>;
+void modify_bb_guid()
+{
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ CKContext* ctx=s_Plugininterface->GetCKContext();
+ MultiParamEditDlg shitdialog(ctx);
+ CKParameter* bb=(CKParameter*)ctx->CreateObject(CKCID_PARAMETER,"Building block");
+ CKParameter* g1=(CKParameter*)ctx->CreateObject(CKCID_PARAMETER,"GUID upper part (as int32_t)");
+ CKParameter* g2=(CKParameter*)ctx->CreateObject(CKCID_PARAMETER,"GUID lower part (as int32_t)");
+ bb->SetGUID(CKPGUID_BEHAVIOR);
+ g1->SetGUID(CKPGUID_INT);
+ g2->SetGUID(CKPGUID_INT);
+ shitdialog.AddParameter(bb);
+ shitdialog.AddParameter(g1);
+ shitdialog.AddParameter(g2);
+ shitdialog.SetTitle("Fscking a building block up");
+ shitdialog.DoModal();
+ CKBehavior* bbr=(CKBehavior*)bb->GetValueObject();
+ /*Some stupid reverse engineering goes on here
+ CKFile* f=bb->GetCKContext()->CreateCKFile();
+ bbr->PreSave(f,0);
+ CKStateChunk* c=bbr->Save(f,0);
+ int dl=c->ConvertToBuffer(NULL);
+ char* dump=new char[dl+1];
+ c->ConvertToBuffer((void*)dump);
+ if(bbr->GetPrototypeGuid().d1&&bbr->GetPrototypeGuid().d2)
+ {//looks for proto GUID
+ CKGUID og=bbr->GetPrototypeGuid();
+ for(int i=0;i<dl-8;++i)
+ {
+ if(CKGUID(*reinterpret_cast<DWORD*>(dump+i),*reinterpret_cast<DWORD*>(dump+i+4))==og)
+ ctx->OutputToConsoleEx("found proto GUID at offset %d",i);
+ }
+ }
+ if(bbr->GetOwner())
+ {//looks for owner
+ CK_ID ow=bbr->GetOwner()->GetID();
+ for(int i=0;i<dl-4;++i)
+ {
+ if(*reinterpret_cast<DWORD*>(dump+i)==ow)
+ ctx->OutputToConsoleEx("found owner id at offset %d",i);
+ }
+ }
+ if(bbr->GetParent())
+ {//looks for parent behavior
+ CK_ID par=bbr->GetParent()->GetID();
+ for(int i=0;i<dl-4;++i)
+ {
+ if(*reinterpret_cast<DWORD*>(dump+i)==par)
+ ctx->OutputToConsoleEx("found parent behavior id at offset %d",i);
+ }
+ }
+ delete[] dump;*/
+ BehaviorBlockData* bbd=bbr->*get(Behavior_blockdata());
+ /*char dump[128];memcpy(dump,bbd,sizeof(dump));
+ CKGUID og=bbr->GetPrototypeGuid();int f=-10000000;
+ for(int i=0;i<31;++i){
+ if(CKGUID(dump[i],dump[i+1])==og){f=i;break;}
+ if(CKGUID(dump[i+1],dump[i])==og){f=-i-1;break;}
+ }
+ ctx->OutputToConsoleEx(f>-10000000?"found at offset %d!":"not found",f);*/
+ CKGUID g;memcpy(&g.d1,g1->GetReadDataPtr(),sizeof(g.d1));
+ memcpy(&g.d2,g2->GetReadDataPtr(),sizeof(g.d2));
+ if(bbd)memcpy(bbd,&g.d,sizeof(&g.d));
+ bbr->NotifyEdition();//does not work... shit
+ ctx->OutputToConsole("Copy and paste the selected behavior to generate modified building blocks!");
+ ctx->DestroyObject(bb);
+ ctx->DestroyObject(g1);
+ ctx->DestroyObject(g2);
+}
+
+//static CKBeObject *destowner=NULL;
+
+/*bool clone_script(CKParameter* source_script,CKParameter* dest_script)
+{
+ CKContext* ctx=source_script->GetCKContext();
+ CKBehavior* src=(CKBehavior*)source_script->GetValueObject();
+ CKBehavior* dest=(CKBehavior*)dest_script->GetValueObject();
+ if(!src||!dest)return false;
+ destowner=NULL;
+ clone_behavior(src,dest,NULL);
+ return false;
+}*/
+bool dump_script(CKParameter* script)
+{
+ Json::Value ret;
+ CKContext* ctx=script->GetCKContext();
+ CKBehavior* src=(CKBehavior*)script->GetValueObject();
+ if(!src)return false;
+ dump_behavior(src,&ret,NULL);
+ Json::StreamWriterBuilder w;
+ std::ostringstream os;
+ Json::StreamWriter* sw=w.newStreamWriter();
+ sw->write(ret,&os);
+ std::string stret=os.str();
+ char* ck2isstupid=new char[stret.length()+1];
+ ck2isstupid[stret.length()]=0;
+ memcpy(ck2isstupid,stret.c_str(),stret.length());
+ char strFilter[]={"JSON (*.json)|*.json|"};
+ CFileDialog FileDlg(FALSE,CString(".json"),NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,CString(strFilter));
+ FileDlg.m_ofn.lpstrTitle="Save the fucking JSON";
+ FileDlg.DoModal();
+ CString p=FileDlg.GetFolderPath()+TEXT("\\")+FileDlg.GetFileName();
+ CFile f;f.Open(p.GetString(),CFile::modeCreate|CFile::modeReadWrite);
+ f.Write(ck2isstupid,stret.length());f.Close();
+ ctx->OutputToConsole("Done!",true);
+ OutputDebugStringA(ck2isstupid);
+ delete[] ck2isstupid;
+ delete sw;
+ return true;
+}
+
+const char* beht2str(CK_BEHAVIOR_TYPE t)
+{
+ switch(t)
+ {
+ case CKBEHAVIORTYPE_BASE:return "block";
+ case CKBEHAVIORTYPE_BEHAVIOR:return "graph";
+ case CKBEHAVIORTYPE_SCRIPT:return "script";
+ }
+ return "shit";
+}
+
+void printdumb(const char* fmt,...)
+{
+ char s[1024];
+ va_list args;
+ va_start(args,fmt);
+ vsnprintf(s,1024,fmt,args);
+ OutputDebugStringA(s);
+ va_end(args);
+}
+
+#define rienabranler(a,b) (a?a->b()?a->b():"(noname)":"--NULL--")
+#define rienabranleri(a,b) (a?a->b()?a->b():-1:-1)
+void dump_parameter_in(CKParameterIn* pin,Json::Value& v)
+{
+ v["id"]=Json::Value(pin->GetID());
+ v["name"]=Json::Value(pin->GetName());
+ v["type"]=Json::Value(pin->GetCKContext()->GetParameterManager()->ParameterGuidToName(pin->GetGUID()));
+ v["type_guid"]=Json::Value();
+ v["type_guid"][0]=Json::Value(pin->GetGUID().d1);
+ v["type_guid"][1]=Json::Value(pin->GetGUID().d2);
+ v["real_source_id"]=Json::Value(rienabranleri(pin->GetRealSource(),GetID));
+ v["direct_source_id"]=Json::Value(rienabranleri(pin->GetDirectSource(),GetID));
+ v["shared_source_id"]=Json::Value(rienabranleri(pin->GetSharedSource(),GetID));
+}
+void dump_parameter_out(CKParameterOut* pout,Json::Value& v)
+{
+ v["id"]=Json::Value(pout->GetID());
+ v["name"]=Json::Value(pout->GetName());
+ v["type"]=Json::Value(pout->GetCKContext()->GetParameterManager()->ParameterGuidToName(pout->GetGUID()));
+ v["type_guid"]=Json::Value();
+ v["type_guid"][0]=Json::Value(pout->GetGUID().d1);
+ v["type_guid"][1]=Json::Value(pout->GetGUID().d2);
+ v["dest"]=Json::Value();
+ for(int i=0,c=pout->GetDestinationCount();i<c;++i)
+ v["dest"][i]=pout->GetDestination(i)->GetID();
+}
+bool dump_behavior(CKBehavior* src,Json::Value* dest,Json::Value* destpar)
+{
+ printdumb("type: %s, sub count: %d, name: %s, proto: %s\n",beht2str(src->GetType()),
+ src->GetSubBehaviorCount(),
+ src->GetName(),
+ src->GetPrototypeName()?src->GetPrototypeName():"null"
+ );
+ Json::Value& dst=*dest;
+ dst["type"]=Json::Value(src->GetType());
+ if(src->GetType()==CKBEHAVIORTYPE_BASE)
+ {
+ dst["proto_guid"]=Json::Value();
+ dst["proto_guid"][0]=Json::Value(src->GetPrototypeGuid().d1);
+ dst["proto_guid"][1]=Json::Value(src->GetPrototypeGuid().d2);
+ }
+ dst["name"]=Json::Value(std::string(src->GetName()));
+ dst["flags"]=Json::Value(Json::UInt(src->GetFlags()));
+ dst["priority"]=Json::Value(src->GetPriority());
+ dst["version"]=Json::Value(src->GetVersion());
+ if(src->IsUsingTarget())
+ {
+ dst["target"]=src->GetTargetParameter()->GetRealSource()->GetID();
+ }
+ if(std::string(src->GetName())==std::string("Op")&&src->GetLocalParameterCount()>2)
+ {
+ CKGUID g;memcpy(&g.d1,src->GetLocalParameter(1)->GetReadDataPtr(false),sizeof(g.d1));
+ memcpy(&g.d2,src->GetLocalParameter(2)->GetReadDataPtr(false),sizeof(g.d2));
+ dst["op_type"]=Json::Value(std::string(src->GetCKContext()->GetParameterManager()->
+ OperationGuidToName(g)));
+ }
+ if(src->GetInputCount())
+ {
+ dst["inputs"]=Json::Value();
+ for(int i=0,c=src->GetInputCount();i<c;++i)
+ {
+ Json::Value &v=dst["inputs"][i]=Json::Value();
+ v["name"]=Json::Value(std::string(src->GetInput(i)->GetName()));
+ v["id"]=Json::Value(src->GetInput(i)->GetID());
+ }
+ }
+ if(src->GetOutputCount())
+ {
+ dst["outputs"]=Json::Value();
+ for(int i=0,c=src->GetOutputCount();i<c;++i)
+ {
+ Json::Value &v=dst["outputs"][i]=Json::Value();
+ v["name"]=Json::Value(std::string(src->GetOutput(i)->GetName()));
+ v["id"]=Json::Value(src->GetOutput(i)->GetID());
+ }
+ }
+ if(src->GetSubBehaviorCount())
+ {
+ dst["subbehavior"]=Json::Value();
+ for(int i=0,c=src->GetSubBehaviorCount();i<c;++i)
+ {
+ dst["subbehavior"][i]=Json::Value();
+ dump_behavior(src->GetSubBehavior(i),&dst["subbehavior"][i],NULL);
+ }
+ }
+ if(src->GetSubBehaviorLinkCount())
+ {
+ dst["behavior_link"]=Json::Value();
+ for(int i=0,c=src->GetSubBehaviorLinkCount();i<c;++i)
+ {
+ Json::Value &v=dst["behavior_link"][i]=Json::Value();
+ v["in"]=Json::Value(src->GetSubBehaviorLink(i)->GetInBehaviorIO()->GetID());
+ v["out"]=Json::Value(src->GetSubBehaviorLink(i)->GetOutBehaviorIO()->GetID());
+ v["delay"]=Json::Value(src->GetSubBehaviorLink(i)->GetInitialActivationDelay());
+ }
+ }
+ if(src->GetLocalParameterCount())
+ {
+ dst["local_parameter"]=Json::Value();
+ for(int i=0,c=src->GetLocalParameterCount();i<c;++i)
+ {
+ Json::Value &v=dst["local_parameter"][i]=Json::Value();
+ v["id"]=Json::Value(src->GetLocalParameter(i)->GetID());
+ v["name"]=Json::Value(rienabranler(src->GetLocalParameter(i),GetName));
+ if(src->IsLocalParameterSetting(i))
+ v["issetting"]=Json::Value(1);
+ CKParameter2Json(src->GetLocalParameter(i),v);
+ }
+ }
+ if(src->GetInputParameterCount())
+ {
+ dst["input_parameter"]=Json::Value();
+ for(int i=0,c=src->GetInputParameterCount();i<c;++i)
+ {
+ Json::Value &v=dst["input_parameter"][i]=Json::Value();
+ dump_parameter_in(src->GetInputParameter(i),v);
+ }
+ }
+ if(src->GetOutputParameterCount())
+ {
+ dst["output_parameter"]=Json::Value();
+ for(int i=0,c=src->GetOutputParameterCount();i<c;++i)
+ {
+ Json::Value &v=dst["output_parameter"][i]=Json::Value();
+ dump_parameter_out(src->GetOutputParameter(i),v);
+ }
+ }
+ if(src->GetParameterOperationCount())
+ {
+ dst["parameter_operation"]=Json::Value();
+ for(int i=0,c=src->GetParameterOperationCount();i<c;++i)
+ {
+ Json::Value &v=dst["parameter_operation"][i]=Json::Value();
+ v["op"]=Json::Value(std::string(src->GetCKContext()->GetParameterManager()->
+ OperationGuidToName(src->GetParameterOperation(i)->GetOperationGuid())));
+ CKGUID g=src->GetParameterOperation(i)->GetOperationGuid();
+ char s[64];snprintf(s,64,"0x%x,0x%x",g.d1,g.d2);
+ v["op_guid"]=Json::Value(s);
+ v["p1"]=Json::Value();
+ dump_parameter_in(src->GetParameterOperation(i)->GetInParameter1(),v["p1"]);
+ dump_parameter_in(src->GetParameterOperation(i)->GetInParameter2(),v["p2"]);
+ dump_parameter_out(src->GetParameterOperation(i)->GetOutParameter(),v);
+ }
+ }
+ return true;
+}
+
+//typedef std::map<CKBehaviorIO*,std::pair<CKBehavior*,int>> shitmap;
+
+/*bool clone_behavior(CKBehavior* src,CKBehavior* dest,CKBehavior* destpar)
+//This is still incomplete (does not clone any parameters), yet it refuses to work.
+{
+ printdumb("type: %s, sub count: %d, proto: %s\n",beht2str(src->GetType()),
+ src->GetSubBehaviorCount(),
+ src->GetPrototypeName()?src->GetPrototypeName():"null"
+ );
+ //copy properties src -> dest
+ shitmap sm;
+ if(src->GetType()==CKBEHAVIORTYPE_BASE)
+ {
+ dest->InitFromPrototype(src->GetPrototype());
+ dest->InitFctPtrFromPrototype(src->GetPrototype());
+ }
+ else dest->SetType(src->GetType());
+ dest->SetFlags(src->GetFlags());
+ dest->SetPriority(src->GetPriority());
+ dest->SetVersion(src->GetVersion());
+ //if(dest->GetOwner())destowner=dest->GetOwner();
+ //else if(destowner)destowner->AddScript(dest);else printdumb("fuck\n");
+ if(src->GetType()==CKBEHAVIORTYPE_BEHAVIOR)
+ {
+ for(int i=0;i<src->GetOutputCount();++i)
+ {
+ dest->AddOutput(src->GetOutput(i)->GetName());
+ sm[src->GetOutput(i)]=std::make_pair(dest,-i-1);
+ }
+ for(int i=0;i<src->GetInputCount();++i)
+ {
+ dest->AddInput(src->GetInput(i)->GetName());
+ sm[src->GetInput(i)]=std::make_pair(dest,i);
+ }
+ //also do this for parameters
+ }
+ if(src->GetType()==CKBEHAVIORTYPE_SCRIPT)
+ {
+ sm[src->GetInput(0)]=std::make_pair(dest,0);
+ }
+ if(destpar){CKERROR r=destpar->AddSubBehavior(dest);if(r!=CK_OK)printdumb("add sub behavior failed: %d - %s\n",r,CKErrorToString(r));}
+ printdumb("src fnc: %p, dest fnc: %p\n",src->GetFunction(),dest->GetFunction());
+ printdumb("src owner: %s, dest owner: %s\n",rienabranler(src->GetOwner(),GetName),rienabranler(dest->GetOwner(),GetName));
+ printdumb("src target: %s, dest target: %s\n",rienabranler(src->GetTarget(),GetName),rienabranler(dest->GetTarget(),GetName));
+ printdumb("src ver: %x, dest ver: %x\n",src->GetVersion(),dest->GetVersion());
+ printdumb("src root: %s, dest root: %s\n",rienabranler(src->GetOwnerScript(),GetName),rienabranler(dest->GetOwnerScript(),GetName));
+ printdumb("==============================================\n");
+ int c=src->GetSubBehaviorCount();
+ for(int i=0;i<c;++i)
+ {
+ CKBehavior* cur=src->GetSubBehavior(i);
+ //create dest for current shit
+ CKBehavior* curdest=(CKBehavior*)src->GetCKContext()->CreateObject(CKCID_BEHAVIOR,cur->GetName());
+ int ic=cur->GetInputCount(),oc=cur->GetOutputCount();
+ for(int j=0;j<ic;++j)
+ sm[cur->GetInput(j)]=std::make_pair(curdest,j);
+ for(int j=0;j<oc;++j)
+ sm[cur->GetOutput(j)]=std::make_pair(curdest,-j-1);
+ clone_behavior(cur,curdest,dest);
+ }
+ c=src->GetSubBehaviorLinkCount();
+ for(int i=0;i<c;++i)
+ {
+ CKBehaviorLink* cur=src->GetSubBehaviorLink(i);
+ CKBehaviorLink* dst=(CKBehaviorLink*)src->GetCKContext()->CreateObject(CKCID_BEHAVIORLINK,"");
+ dst->SetInitialActivationDelay(cur->GetInitialActivationDelay());
+ dst->SetActivationDelay(cur->GetActivationDelay());
+ if(sm.find(cur->GetInBehaviorIO())==sm.end()||sm.find(cur->GetOutBehaviorIO())==sm.end())
+ {
+ printdumb("fuck shit! at least one of these behavior io is not found in the map:"
+ " %s:%s %s:%s\n",cur->GetInBehaviorIO()->GetOwner()->GetName(),cur->GetInBehaviorIO()->GetName(),
+ cur->GetOutBehaviorIO()->GetOwner()->GetName(),cur->GetOutBehaviorIO()->GetName());
+ continue;
+ }
+ dst->SetInBehaviorIO(
+ sm[cur->GetInBehaviorIO()].second<0?
+ sm[cur->GetInBehaviorIO()].first->GetOutput(-sm[cur->GetInBehaviorIO()].second-1):
+ sm[cur->GetInBehaviorIO()].first->GetInput(sm[cur->GetInBehaviorIO()].second)
+ );
+ dst->SetOutBehaviorIO(
+ sm[cur->GetOutBehaviorIO()].second<0?
+ sm[cur->GetOutBehaviorIO()].first->GetOutput(-sm[cur->GetOutBehaviorIO()].second-1):
+ sm[cur->GetOutBehaviorIO()].first->GetInput(sm[cur->GetOutBehaviorIO()].second)
+ );
+ }
+ return true;
+}*/
+
+bool CKParameter2Json(CKParameter* p,Json::Value &v)
+{
+ CKGUID t=p->GetGUID();bool u=0;
+ if(t.d1&t.d2)
+ v["type"]=Json::Value(std::string(p->GetCKContext()->GetParameterManager()->ParameterGuidToName(t)));
+ else v["type"]=Json::Value("unknown");
+ if(v["type"]==Json::Value("unknown"))
+ {
+ char s[64];snprintf(s,64,"unknown: 0x%x, 0x%x",p->GetGUID().d1,p->GetGUID().d2);
+ v["type"]=Json::Value(s);
+ u=1;
+ }
+ //nothing
+ if(t==CKPGUID_NONE)
+ {return true;}
+ if(p->GetParameterClassID()&&p->GetValueObject(false))
+ {
+ v["data"]=Json::Value();
+ v["data"]["id"]=Json::Value(p->GetValueObject(false)->GetID());
+ v["data"]["name"]=p->GetValueObject(false)->GetName();
+ v["data"]["type"]=p->GetValueObject(false)->GetClassNameA();
+ return true;
+ }
+ //float
+ if(t==CKPGUID_FLOAT||t==CKPGUID_ANGLE||t==CKPGUID_PERCENTAGE||t==CKPGUID_TIME
+ ||t==CKPGUID_FLOATSLIDER)
+ {
+ v["data"]=Json::Value(*(float*)(p->GetReadDataPtr(false)));
+ return true;
+ }
+ //int
+ if(t==CKPGUID_INT||t==CKPGUID_KEY||t==CKPGUID_BOOL||t==CKPGUID_ID||t==CKPGUID_POINTER
+ ||t==CKPGUID_MESSAGE||t==CKPGUID_ATTRIBUTE||t==CKPGUID_BLENDMODE||t==CKPGUID_FILTERMODE
+ ||t==CKPGUID_BLENDFACTOR||t==CKPGUID_FILLMODE||t==CKPGUID_LITMODE||t==CKPGUID_SHADEMODE
+ ||t==CKPGUID_ADDRESSMODE||t==CKPGUID_WRAPMODE||t==CKPGUID_3DSPRITEMODE||t==CKPGUID_FOGMODE
+ ||t==CKPGUID_LIGHTTYPE||t==CKPGUID_SPRITEALIGN||t==CKPGUID_DIRECTION||t==CKPGUID_LAYERTYPE
+ ||t==CKPGUID_COMPOPERATOR||t==CKPGUID_BINARYOPERATOR||t==CKPGUID_SETOPERATOR
+ ||t==CKPGUID_OBSTACLEPRECISION||t==CKPGUID_OBSTACLEPRECISIONBEH)
+ {
+ v["data"]=Json::Value(*(int*)(p->GetReadDataPtr(false)));
+ return true;
+ }
+ if(t==CKPGUID_VECTOR)
+ {
+ VxVector vec;
+ memcpy(&vec,p->GetReadDataPtr(false),sizeof(vec));
+ v["data"]=Json::Value();v["data"]["x"]=vec.x;
+ v["data"]["y"]=vec.y;v["data"]["z"]=vec.z;
+ return true;
+ }
+ if(t==CKPGUID_2DVECTOR)
+ {
+ Vx2DVector vec;
+ memcpy(&vec,p->GetReadDataPtr(false),sizeof(vec));
+ v["data"]=Json::Value();v["data"]["x"]=vec.x;
+ v["data"]["y"]=vec.y;
+ return true;
+ }
+ if(t==CKPGUID_MATRIX)
+ {
+ VxMatrix mat;
+ memcpy(&mat,p->GetReadDataPtr(false),sizeof(mat));
+ v["data"]=Json::Value();for(int i=0;i<4;++i)v["data"][i]=Json::Value();
+ for(int i=0;i<4;++i)for(int j=0;j<4;++j)v["data"][i][j]=Json::Value(mat[i][j]);
+ return true;
+ }
+ if(t==CKPGUID_COLOR)
+ {
+ VxColor col;
+ memcpy(&col,p->GetReadDataPtr(false),sizeof(col));
+ v["data"]=Json::Value();v["data"]["r"]=col.r;
+ v["data"]["g"]=col.g;v["data"]["b"]=col.b;
+ v["data"]["a"]=col.a;
+ return true;
+ }
+ if(t==CKPGUID_2DCURVE)
+ {
+ Json::Value &vv=v["data"]=Json::Value();
+ CK2dCurve *c;memcpy(&c,p->GetReadDataPtr(false),sizeof(c));
+ for(int i=0,cc=c->GetControlPointCount();i<cc;++i)
+ {
+ vv[i]=Json::Value();
+ vv[i]["pos"]=Json::Value();
+ vv[i]["pos"]["x"]=Json::Value(c->GetControlPoint(i)->GetPosition().x);
+ vv[i]["pos"]["y"]=Json::Value(c->GetControlPoint(i)->GetPosition().y);
+ vv[i]["islinear"]=Json::Value(c->GetControlPoint(i)->IsLinear());
+ if(c->GetControlPoint(i)->IsTCB())
+ {
+ vv[i]["bias"]=Json::Value(c->GetControlPoint(i)->GetBias());
+ vv[i]["continuity"]=Json::Value(c->GetControlPoint(i)->GetContinuity());
+ vv[i]["tension"]=Json::Value(c->GetControlPoint(i)->GetTension());
+ }
+ else
+ {
+ vv[i]["intangent"]=Json::Value();
+ vv[i]["intangent"]["x"]=Json::Value(c->GetControlPoint(i)->GetInTangent().x);
+ vv[i]["intangent"]["y"]=Json::Value(c->GetControlPoint(i)->GetInTangent().y);
+ vv[i]["outtangent"]=Json::Value();
+ vv[i]["outtangent"]["x"]=Json::Value(c->GetControlPoint(i)->GetOutTangent().x);
+ vv[i]["outtangent"]["y"]=Json::Value(c->GetControlPoint(i)->GetOutTangent().y);
+ }
+ }
+ }
+ u=1;//if it gets here, we have no idea what it really is. so simply dump it.
+ //buffer-like
+ if(u||t==CKPGUID_VOIDBUF||t==CKPGUID_STRING||t==CKPGUID_SHADER||t==CKPGUID_TECHNIQUE||t==CKPGUID_PASS)
+ {
+ std::string d((char*)p->GetReadDataPtr(false),p->GetDataSize());
+ v["data"]=Json::Value(d);
+ v["length"]=Json::Value(p->GetDataSize());
+ return true;
+ }
+ return false;
+} \ No newline at end of file
diff --git a/Menu.h b/Menu.h
new file mode 100644
index 0000000..90e4fa5
--- /dev/null
+++ b/Menu.h
@@ -0,0 +1,13 @@
+#pragma once
+
+//by default these functions are called in Testcallback.cpp
+//if you do not use callback (do not have Testcallback.cpp), you should call these functions manually
+
+//to add a menu in Virtools Dev main menu.
+void InitMenu();
+//to remove the menu from Virtools Dev main menu
+void RemoveMenu();
+//to fill menu with your own commands
+void UpdateMenu();
+
+#define STR_MAINMENUNAME "Fsck"
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..88e4f7d
--- /dev/null
+++ b/README.md
@@ -0,0 +1,16 @@
+# Script Materializer
+a.k.a. Fsck for Virtools
+
+## Functionality
+ - Dumping behavior scripts to JSON
+ - Spawning building blocks with custom GUID (may not work)
+ - ~~Destroying your hard disk~~
+
+## Building
+ 0. Dependencies: Virtools SDK and jsoncpp
+ 1. Change those fscking hardcoded absolute paths in the project
+ 2. Hit "Build Solution"!
+ 3. ~~Wait for your hard disk to be destroyed~~
+
+## License
+ 3-Clause BSD
diff --git a/Script Materializer.sln b/Script Materializer.sln
new file mode 100644
index 0000000..9e5ada5
--- /dev/null
+++ b/Script Materializer.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.27130.2027
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Script Materializer", "Fsck.vcxproj", "{D20B1C85-814D-4F05-A840-634F9E062019}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x86 = Debug|x86
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {D20B1C85-814D-4F05-A840-634F9E062019}.Debug|x86.ActiveCfg = Debug|Win32
+ {D20B1C85-814D-4F05-A840-634F9E062019}.Debug|x86.Build.0 = Debug|Win32
+ {D20B1C85-814D-4F05-A840-634F9E062019}.Release|x86.ActiveCfg = Release|Win32
+ {D20B1C85-814D-4F05-A840-634F9E062019}.Release|x86.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {B5AF39CC-9760-44F6-82D9-A1734AE804FD}
+ EndGlobalSection
+EndGlobal
diff --git a/StdAfx.cpp b/StdAfx.cpp
new file mode 100644
index 0000000..fe8433d
--- /dev/null
+++ b/StdAfx.cpp
@@ -0,0 +1,8 @@
+// stdafx.cpp : source file that includes just the standard includes
+// Editor.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+
+
diff --git a/StdAfx.h b/StdAfx.h
new file mode 100644
index 0000000..24177be
--- /dev/null
+++ b/StdAfx.h
@@ -0,0 +1,40 @@
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+#pragma once
+
+#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
+
+//PLUGIN PRECOMPILED HEADER INCLUDED
+#include "CKAll.h"
+#include "VIControls.h"
+#include "CKControlsAll.h"
+#include "VEP_ScriptActionMenu.h"
+#include "VEP_KeyboardShortcutManager.h"
+#include "VEP_All.h"
+
+using namespace CKControl;
diff --git a/icon1.ico b/icon1.ico
new file mode 100644
index 0000000..fbd3e17
--- /dev/null
+++ b/icon1.ico
Binary files differ
diff --git a/resource.h b/resource.h
new file mode 100644
index 0000000..be2a9de
--- /dev/null
+++ b/resource.h
@@ -0,0 +1,18 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by Editor.rc
+//
+//#define IDD_EDITOR 10000
+//#define IDD_TOOLBAR 10001
+//#define IDI_EDITORICON 10002
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 10003
+#define _APS_NEXT_COMMAND_VALUE 32771
+#define _APS_NEXT_CONTROL_VALUE 10000
+#define _APS_NEXT_SYMED_VALUE 10000
+#endif
+#endif