diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..412eeda --- /dev/null +++ b/.gitattributes @@ -0,0 +1,22 @@ +# Auto detect text files and perform LF normalization +* text=auto + +# Custom for Visual Studio +*.cs diff=csharp +*.sln merge=union +*.csproj merge=union +*.vbproj merge=union +*.fsproj merge=union +*.dbproj merge=union + +# Standard to msysgit +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore index 618f42f..15604e6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,170 @@ -#Ignore any local extensions -Extensions/ +# Only keep template projects +/Extensions/* +!/Extensions/Template*/ +!/Extensions/AutoInstall.bat +!/Extensions/README.md + + +################# +## Eclipse +################# + +*.pydevproject +.project +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.classpath +.settings/ +.loadpath + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# CDT-specific +.cproject + +# PDT-specific +.buildpath + + +################# +## Visual Studio +################# + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.sln.docstates + +# Build results +[Dd]ebug/ +[Rr]elease/ +*_i.c +*_p.c +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.vspscc +.builds +*.dotCover + +## TODO: If you have NuGet Package Restore enabled, uncomment this +#packages/ + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf + +# Visual Studio profiler +*.psess +*.vsp + +# ReSharper is a .NET coding add-in +_ReSharper* + +# Installshield output folder +[Ee]xpress + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish + +# Others +[Bb]in +[Oo]bj +sql +TestResults +*.Cache +ClientBin +stylecop.* +~$* +*.dbmdl +Generated_Code #added for RIA/Silverlight projects + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML + + + +############ +## Windows +############ + +# Windows image file caches +Thumbs.db + +# Folder config file +Desktop.ini + + +############# +## Python +############# + +*.py[co] + +# Packages +*.egg +*.egg-info +dist +build +eggs +parts +bin +var +sdist +develop-eggs +.installed.cfg + +# Installer logs +pip-log.txt + +# Unit test / coverage reports +.coverage +.tox + +#Translations +*.mo + +#Mr Developer +.mr.developer.cfg + +# Mac crap +.DS_Store diff --git a/Extensions/AutoInstall.bat b/Extensions/AutoInstall.bat index 9bffb35..6101c81 100644 --- a/Extensions/AutoInstall.bat +++ b/Extensions/AutoInstall.bat @@ -1,44 +1,87 @@ -echo MFX File: %1 -echo MFX Destination: %2 - -:mfd -set status=ERROR -for /F "tokens=*" %%A in ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Clickteam\Multimedia Fusion Developer 2\Settings" /v "ProPath"') do set status=%%A -set status=%status:~0,5% -if %status%==ERROR goto nmfd - -for /F "tokens=3* delims= " %%A in ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Clickteam\Multimedia Fusion Developer 2\Settings" /v "ProPath" ^| find "REG_SZ"') do set mmfpath=%%A %%B - -echo MMF2 Dev Path: %mmfpath% - -copy /y "%1" "%mmfpath%%2" - -set mmfpath= -set status= - -goto mfs - -:nmfd -echo You don't have MMF2 Developer :( - -:mfs -set status=ERROR -for /F "tokens=1 delims=:" %%A in ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Clickteam\Multimedia Fusion 2\Settings" /v "StdPath"') do set status=%%A -set status=%status:~0,5% -if %status%==ERROR goto nmfs - -for /F "tokens=3* delims= " %%A in ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Clickteam\Multimedia Fusion 2\Settings" /v "StdPath" ^| find "REG_SZ"') do set mmfpath=%%A %%B - -echo MMF2 Std Path: %mmfpath% - -copy /y "%1" "%mmfpath%%2" - -set mmfpath= -set status= - -goto end - -:nmfs -echo You don't have MMF2 Standard - -:end +echo MFX File: %1 +echo MFX Destination: %2 + +:mfd +set status=ERROR +for /F "tokens=*" %%A in ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Clickteam\Multimedia Fusion Developer 2\Settings" /v "ProPath"') do set status=%%A +set status=%status:~0,5% +if %status%==ERROR goto nmfd + +for /F "tokens=3* delims= " %%A in ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Clickteam\Multimedia Fusion Developer 2\Settings" /v "ProPath" ^| find "REG_SZ"') do set mmfpath=%%A %%B + +echo MMF2.0 Dev Path: %mmfpath% + +copy /y "%1" "%mmfpath%%2" + +set mmfpath= +set status= + +goto mfs + +:nmfd +echo You don't have MMF2.0 Developer :( + +:mfs +set status=ERROR +for /F "tokens=1 delims=:" %%A in ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Clickteam\Multimedia Fusion 2\Settings" /v "StdPath"') do set status=%%A +set status=%status:~0,5% +if %status%==ERROR goto nmfs + +for /F "tokens=3* delims= " %%A in ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Clickteam\Multimedia Fusion 2\Settings" /v "StdPath" ^| find "REG_SZ"') do set mmfpath=%%A %%B + +echo MMF2.0 Std Path: %mmfpath% + +copy /y "%1" "%mmfpath%%2" + +set mmfpath= +set status= + +goto cfd + +:nmfs +echo You don't have MMF2.0 Standard + +:cfd +set status=ERROR +for /F "tokens=1 delims=:" %%A in ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Clickteam\Fusion Developer 2.5\Settings" /v "InstallPath"') do set status=%%A +set status=%status:~0,5% +if %status%==ERROR goto ncfd + +for /F "tokens=3* delims= " %%A in ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Clickteam\Fusion Developer 2.5\Settings" /v "InstallPath" ^| find "REG_SZ"') do set mmfpath=%%A %%B + +echo CTF2.5 Dev Path: %mmfpath% + +copy /y "%1" "%mmfpath%%2" + +set mmfpath= +set status= + +goto cfs + +:ncfd +echo You don't have CTF2.5 Developer :( + +:cfs +set status=ERROR +for /F "tokens=1 delims=:" %%A in ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Clickteam\Fusion 2.5\Settings" /v "InstallPath"') do set status=%%A +set status=%status:~0,5% +if %status%==ERROR goto ncfs + +for /F "tokens=3* delims= " %%A in ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Clickteam\Fusion 2.5\Settings" /v "InstallPath" ^| find "REG_SZ"') do set mmfpath=%%A %%B + +echo CTF2.5 Std Path: %mmfpath% + +copy /y "%1" "%mmfpath%%2" + +set mmfpath= +set status= + +goto end + +:ncfs +echo You don't have CTF2.5 Standard + +:end + +(call ) +exit /b 0 diff --git a/Extensions/README.md b/Extensions/README.md new file mode 100644 index 0000000..440497e --- /dev/null +++ b/Extensions/README.md @@ -0,0 +1,4 @@ +Extensions Directory +==================== + +This folder is where your extensions will stay. Copy the Template folder and rename it to start a new extension. diff --git a/Extensions/Template/.gitignore b/Extensions/Template/.gitignore index a85b118..999b623 100644 --- a/Extensions/Template/.gitignore +++ b/Extensions/Template/.gitignore @@ -1,5 +1,49 @@ -#Ignore MFX builds -MFX/ +# Template project built files +MFX/Data +MFX/Extensions +*.0* +Debug*/ +Edittime*/ +Runtime*/ + +*.opendb +*.VC.db +.vs/ + +################# +## Eclipse +################# + +*.pydevproject +.project +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.classpath +.settings/ +.loadpath + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# CDT-specific +.cproject + +# PDT-specific +.buildpath + + +################# +## Visual Studio +################# ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. @@ -10,19 +54,8 @@ MFX/ *.sln.docstates # Build results - -[Dd]ebug*/ -[Rr]elease*/ -Run_Only*/ -[Rr]untime*/ -[Ee]dittime*/ - -build/ - - -[Tt]est[Rr]esult -[Bb]uild[Ll]og.* - +[Dd]ebug/ +[Rr]elease/ *_i.c *_p.c *.ilk @@ -39,13 +72,12 @@ build/ *.tlh *.tmp *.vspscc -*.vssscc .builds +*.dotCover -*.pidb +## TODO: If you have NuGet Package Restore enabled, uncomment this +#packages/ -*.log -*.scc # Visual C++ cache files ipch/ *.aps @@ -57,17 +89,8 @@ ipch/ *.psess *.vsp -# Guidance Automation Toolkit -*.gpState - # ReSharper is a .NET coding add-in -_ReSharper*/ - -*.[Rr]e[Ss]harper - -# NCrunch -*.ncrunch* -.*crunch*.local.xml +_ReSharper* # Installshield output folder [Ee]xpress @@ -85,23 +108,16 @@ DocProject/Help/html # Click-Once directory publish -# Publish Web Output -*.Publish.xml - # Others [Bb]in [Oo]bj sql TestResults -[Tt]est[Rr]esult* *.Cache ClientBin -[Ss]tyle[Cc]op.* +stylecop.* ~$* *.dbmdl - -*.[Pp]ublish.xml - Generated_Code #added for RIA/Silverlight projects # Backup & report files from converting an old project file to a newer @@ -110,7 +126,50 @@ _UpgradeReport_Files/ Backup*/ UpgradeLog*.XML -# NuGet -packages/ +############ +## Windows +############ + +# Windows image file caches +Thumbs.db + +# Folder config file +Desktop.ini + + +############# +## Python +############# + +*.py[co] + +# Packages +*.egg +*.egg-info +dist +build +eggs +parts +bin +var +sdist +develop-eggs +.installed.cfg + +# Installer logs +pip-log.txt + +# Unit test / coverage reports +.coverage +.tox + +#Translations +*.mo + +#Mr Developer +.mr.developer.cfg + +# Mac crap +.DS_Store diff --git a/Extensions/Template/Actions.cpp b/Extensions/Template/Actions.cpp index e798f4c..4e38040 100644 --- a/Extensions/Template/Actions.cpp +++ b/Extensions/Template/Actions.cpp @@ -1,3 +1,10 @@ +/* Actions.cpp + * This is where you should define the + * behavior of your actions. Make sure + * the parameters match those in the JSON + * exactly! Double check Extension.h + * as well. + */ #include "Common.h" diff --git a/Extensions/Template/Common.h b/Extensions/Template/Common.h index 95add92..3704c95 100644 --- a/Extensions/Template/Common.h +++ b/Extensions/Template/Common.h @@ -1,23 +1,37 @@ -#pragma once - -// #define TGFEXT // TGF2, MMF2, MMF2 Dev - #define MMFEXT // MMF2, MMF2 Dev -// #define PROEXT // MMF2 Dev only +/* Common.h + * This is the common header file included + * by almost all other *.cpp files in + * the project. Anything that gets put or + * included in here will be available to you + * everywhere else. You shouldn't need to + * change anything in this file except + * to include headers that you want and + * to change the edition of Fusion you want + * to support. + */ -#include "Edif.h" -#include "Resource.h" +#pragma once -// edPtr : Used at edittime and saved in the MFA/CCN/EXE files +//Only define one of these at once: +// #define TGFEXT //TGF2.0, MMF2.0, CTF2.5, MMF2.0 Dev, CTF2.5 Dev + #define MMFEXT // MMF2.0, CTF2.5, MMF2.0 Dev, CTF2.5 Dev +// #define PROEXT // MMF2.0 Dev, CTF2.5 Dev -struct EDITDATA -{ - // Header - required - extHeader eHeader; +#include "Edif.h" +#include "Resource.h" - // Object's data -// short swidth; -// short sheight; +#include +//#include +//#include "YourHeader.hpp" -}; +/* stdtstring + * A std::string that knows if you're using + * unicode or not. (Protip: strings passed + * to your extension A/C/Es still need to be + * const TCHAR *, and the same goes for strings + * returned from expressions and conditions). + */ +typedef std::basic_string stdtstring; -#include "Extension.h" +#include "EditData.hpp" +#include "Extension.hpp" diff --git a/Extensions/Template/Conditions.cpp b/Extensions/Template/Conditions.cpp index 00f3a10..41b2b7b 100644 --- a/Extensions/Template/Conditions.cpp +++ b/Extensions/Template/Conditions.cpp @@ -1,9 +1,14 @@ +/* Conditions.cpp + * This is where you should define the + * behavior of your conditions. Make sure + * the parameters and return types match those + * in the JSON exactly! Double check Extension.h + * as well. + */ #include "Common.h" bool Extension::AreTwoNumbersEqual(int First, int Second) { - return First == Second; + return First == Second; } - - diff --git a/Extensions/Template/CustomParams.cpp b/Extensions/Template/CustomParams.cpp new file mode 100644 index 0000000..afab8b4 --- /dev/null +++ b/Extensions/Template/CustomParams.cpp @@ -0,0 +1,108 @@ +/* CustomParams.cpp + * Just as with all the other SDKs, EDIF + * supports the creation and use of custom, + * you-defined parameters. Your own dialog, + * your own display string, your own sense + * of control. Read the MMF2SDK Help file + * for more information. To use custom + * parameters with EDIF, the parameter type + * must be "Custom" or "Custom#" where # is + * the number of the custom parameter. + * Functions defined here: + * InitParameter + * EditParameter + * GetParameterString + */ + +#include "Common.h" + +/* InitParameter + * Like with the editdata, this data will + * be written as-is to disk and later read + * back. The most you can store is defined + * by PARAM_EXTMAXSIZE, which currently is + * 512 bytes. Use them wisely! + */ +void MMF2Func InitParameter(mv *mV, short ID, paramExt *ParamData) +{ +#ifndef RUN_ONLY + //store data in ParamData->pextData + //store the size of the data in ParamData->pextSize +#endif +} + +// Example of custom parameter setup proc +// -------------------------------------- +/* +#ifndef RUN_ONLY +BOOL CALLBACK SetupProc(HWND hDlg, UINT msgType, WPARAM wParam, LPARAM lParam) +{ + paramExt* pExt; + + switch (msgType) + { + case WM_INITDIALOG: // Init dialog + + // Save edptr + SetWindowLong(hDlg, DWL_USER, lParam); + pExt=(paramExt*)lParam; + + SetDlgItemText(hDlg, IDC_EDIT, pExt->pextData); + return TRUE; + + case WM_COMMAND: // Command + + // Retrieve edptr + pExt = (paramExt *)GetWindowLong(hDlg, DWL_USER); + + switch (wmCommandID) + { + case IDOK: // Exit + GetDlgItemText(hDlg, IDC_EDIT, pExt->pextData, 500); + pExt->pextSize=sizeof(paramExt)+strlen(pExt->pextData)+1; + EndDialog(hDlg, TRUE); + return TRUE; + + default: + break; + } + break; + + default: + break; + } + return FALSE; +} +#endif +*/ + +/* EditParameter + * This is where you actually bring up + * the dialog and take input from + * the user and store it. + */ +void MMF2Func EditParameter(mv _far *mV, short code, paramExt* pExt) +{ +#ifndef RUN_ONLY + // Example + // ------- + // DialogBoxParam(hInstLib, MAKEINTRESOURCE(DB_TRYPARAM), mV->mvHEditWin, SetupProc, (LPARAM)(LPBYTE)pExt); +#endif +} + +/* GetParameterString + * This is where you give Fusion the display + * string for your custom parameter. Remember, + * this is the display for ONE PARAMETER. It + * will appear amongst all the other parameter + * displays depending on the A/C's display + * string. + */ +void MMF2Func GetParameterString(mv _far *mV, short code, paramExt* pExt, LPSTR pDest, short size) +{ +#ifndef RUN_ONLY + // Example + // ------- + // wsprintf(pDest, "Super parameter %s", pExt->pextData); +#endif +} diff --git a/Extensions/Template/Debugger.cpp b/Extensions/Template/Debugger.cpp new file mode 100644 index 0000000..2e4c3d0 --- /dev/null +++ b/Extensions/Template/Debugger.cpp @@ -0,0 +1,141 @@ +/* Debugger.cpp + * Here you will be able to interact + * with the Fusion debugger (that thing + * in the top left when you run your + * MFA from Fusion). You can add your own + * fields of your choice to your object's + * debugger tree. + * Functions defined here: + * GetDebugTree + * GetDebugItem + * EditDebugItem + */ + +#include "Common.h" + +#ifndef RUN_ONLY //The debugger is only available when running from Fusion, which uses the Edittime MFX + +/* DB + * This is the namespace the debugger identifiers + * are stored in. It keeps them out of the global + * namespace and it helps with intellisense. + */ +namespace DB +{ + /* + * The debugger identitifers. + */ + enum + { +// MyString, +// MyInt, + }; +} + +/* DebugTree + * The list of items to be displayed + * in the debugger tree. + */ +WORD DebugTree[] = +{ +// DB::MyString|DB_EDITABLE, +// DB::MyInt|DB_EDITABLE, +// DB::SomethingThatIDontWantTheUserToBeAbleToEditAtRuntime, + DB_END +}; + +#endif + +/* GetDerbugTree + * Plain and simple, just return the debug + * tree pointer from above. If you really + * want to you can create the debug tree + * dynamically and return that, but you'll + * need to store the pointer in your extension + * class every time so that you can release + * the memory in your extension class' destructor. + */ +LPWORD MMF2Func GetDebugTree(RD *rd) +{ +#ifndef RUN_ONLY + return DebugTree; +#endif + return NULL; +} + +/* GetDebugItem + * With respect to DB_BUFFERSIZE, give + * Fusion the string to display in the + * debugger. You must include both the + * name and the value in the string, + * or any format you want. + */ +void MMF2Func GetDebugItem(LPSTR Buffer, RD *rd, int ID) +{ +#ifndef RUN_ONLY +// char temp[DB_BUFFERSIZE]; +// switch (ID) +// { +// case DB::MyString: +// { +// LoadString(hInstLib, IDS_CURRENTSTRING, temp, DB_BUFFERSIZE); +// wsprintf(pBuffer, temp, rdPtr->text); +// break; +// } +// case DB::MyInt: +// { +// LoadString(hInstLib, IDS_CURRENTVALUE, temp, DB_BUFFERSIZE); +// wsprintf(pBuffer, temp, rdPtr->value); +// break; +// } +// } +#endif +} + +/* EditDebugItem + * When the user chooses to edit an + * editable debug item, this function + * is called. You can use the RFUNCTIONs + * provided by Fusion to do simple text and + * number edits, or you can do whatever you + * want, such as creating a dialog that lets + * the user enter more sophisticated input to + * the debug item, or simply display more info. + */ +void MMF2Func EditDebugItem(RD *rd, int ID) +{ +#ifndef RUN_ONLY +/* + switch(ID) + { + case DB::MyString: + { + EditDebugInfo dbi; + char buffer[256]; + + dbi.pText=buffer; + dbi.lText=TEXT_MAX; + dbi.pTitle=NULL; + + strcpy(buffer, rdPtr->text); + long ret=callRunTimeFunction(rdPtr, RFUNCTION_EDITTEXT, 0, (LPARAM)&dbi); + if (ret) + strcpy(rdPtr->text, dbi.pText); + } + break; + case DB::MyInt: + { + EditDebugInfo dbi; + + dbi.value=rdPtr->value; + dbi.pTitle=NULL; + + long ret=callRunTimeFunction(rdPtr, RFUNCTION_EDITINT, 0, (LPARAM)&dbi); + if (ret) + rdPtr->value=dbi.value; + } + break; + } +*/ +#endif +} diff --git a/Extensions/Template/EditData.hpp b/Extensions/Template/EditData.hpp new file mode 100644 index 0000000..5329595 --- /dev/null +++ b/Extensions/Template/EditData.hpp @@ -0,0 +1,131 @@ +/* EditData.hpp + * This is where you control what data + * you want to have at edittime. You + * are responsible for serializing and + * deserializing (saving/loading) the + * data to/from the SerializedED structure + * as if it were a file on the hard drive. + * It doesn't need to be efficient; this + * is just at edittime and once at the + * start of the runtime. + */ + +struct EditData final +{ + /* MyString, MyInt, MyArray_t, MyArray + * Example data + */ +// stdtstring MyString; +// int MyInt; +// typedef std::vector MyArray_t; +// MyArray_t MyArray; + + /* + * This is where you provide default values for + * your editdata. This constructor is used + * when your extension is first created and + * default values are needed. + */ + EditData() // : MyString(_T("Hello, world!")), MyInt(1337) + { + //MyArray.push_back(3.1415926f); + } + + /* + * As a convenience in other parts of your code, + * you should copy data from another instance + * of the EditData class. Make sure you deep-copy + * dynamically allocated memory e.g. with pointers. + */ + EditData(const EditData &from) // : MyString(from.MyString), MyInt(from.MyInt), MyArray(from.MyArray) + { + // + } + + /* operator= + * This is essentially the same as the copy + * constructor above, except you are working + * with an instance that is already + * constructed. + */ + EditData &operator=(const EditData &from) + { +// MyString = from.MyString; +// MyInt = from.MyInt; +// MyArray = from.MyArray; + } + +#ifndef RUN_ONLY + /* Serialize + * This is where you need to "write" data + * to SerializedED like a file. Make sure + * you can read the data back in the + * constructor below! + */ + bool Serialize(mv *mV, SerializedED *&SED) const + { + //Create an instance of EDOStream, a helper class + EDOStream os (mV, SED); + + //Write the data you need to save in binary format + //(you can use text format, but binary is recommended) +// os.write_string(MyString); //works for c-strings too +// os.write_value(MyInt); //only works for primitives! +// os.write_value(MyArray.size()); //need to know how many to load later +// os.write_sequence(MyArray.begin(), MyArray.end()); //works for c-style arrays too + + //That's it! EDOStream automatically stores the data in your extension's editdata + return true; //return false in the event of an error + } +#endif + + /* + * This is the primary constructor for the + * EditData class. Here you will have to + * "read" SerializedED like a file and + * load back everything that gets saved + * above in Serialize. Make sure you check + * the version information first, this + * constructor is used to update from + * older versions of your editdata as well. + */ + EditData(SerializedED *SED) + { + if(SED->Header.extVersion == 0) //older version + { + //code to update from an older version + } + else if(SED->Header.extVersion == 1) //current version + { + //Create an instance of EDIStream, a helper class + EDIStream is (SED); + //Read back the data in the same format that you stored it above +// MyString = is.read_string(); +// MyInt = is.read_value(); //need to specify the type here +// MyArray_t::size_type MyArray_size = is.read_value(); +// for(MyArray_t::size_type i = 0; i < MyArray_size; ++i) +// { +// MyArray.push_back(is.read_value()); +// } + } + else //the version is newer than current + { + //Either try to load the data anyway assuming your + //future self was smart enough to keep the data in + //the same format with new data at the end, or + //make an error dialog and load some default data. +// MessageBox(NULL, _T("The MFA you are trying to load was saved") +// _T("with a newer version of this extension."), +// _T("Error Loading My Extension"), MB_OK); + } + } + + /* + * If you grabbed any memory e.g. with new, + * make sure to e.g. delete it in here. + */ + ~EditData() + { + // + } +}; diff --git a/Extensions/Template/Edittime.cpp b/Extensions/Template/Edittime.cpp index ce41fa8..8fd6728 100644 --- a/Extensions/Template/Edittime.cpp +++ b/Extensions/Template/Edittime.cpp @@ -1,799 +1,337 @@ - -// ============================================================================ -// -// This file contains routines that are handled only during the Edittime, -// under the Frame and Event editors. -// -// Including creating, display, and setting up your object. -// -// ============================================================================ +/* Edittime.cpp + * This file contains functions for the + * New Object dialog and the Frame Editor. + * For properties, see Properties.cpp. For + * custom parameters, see CustomParams.cpp. + * For text properties, see TextProps.cpp. + * Functions defined here: + * MakeIconEx + * UsesFile + * CreateFromFile + * CreateObject + * EditObject + * SetEditSize + * PutObject + * RemoveObject + * CloneObject + * GetObjectRect + * EditorDisplay + * IsTransparent + * PrepareToWriteObject + * GetFilters + */ #include "Common.h" -#if !defined(RUN_ONLY) - -// PROPERTIES ///////////////////////////////////////////////////////////////// - -// Property identifiers -enum { - PROPID_SETTINGS = PROPID_EXTITEM_CUSTOM_FIRST, - -// Example -// ------- -// PROPID_TEXTTITLE, -// PROPID_TEXT, -// PROPID_CHECK, -// PROPID_COMBO, -// PROPID_COLOR, - -}; - -// Example of content of the PROPID_COMBO combo box -//LPCSTR ComboList[] = { -// 0, // reserved -// MAKEINTRESOURCE(IDS_FIRSTOPTION), -// MAKEINTRESOURCE(IDS_SECONDOPTION), -// MAKEINTRESOURCE(IDS_THIRDOPTION), -// NULL -//}; - -// Property definitions -// -// Type, ID, Text, Text of Info box [, Options, Init Param] -// -PropData Properties[] = { - -// Example -// ------- -// PropData_Group (PROPID_TEXTTITLE, IDS_PROP_TEXTTITLE, IDS_PROP_TEXTTITLE), -// PropData_EditString (PROPID_TEXT, IDS_PROP_TEXT, IDS_PROP_TEXT_INFO), -// PropData_CheckBox (PROPID_CHECK, IDS_PROP_CHECK, IDS_PROP_CHECK_INFO), -// PropData_ComboBox (PROPID_COMBO, IDS_PROP_COMBO, IDS_PROP_COMBO, ComboList), -// PropData_Color (PROPID_COLOR, IDS_PROP_COLOR, IDS_PROP_COLOR_INFO), - - - // End of table (required) - PropData_End() -}; - - -#endif // !defined(RUN_ONLY) - - -// ============================================================================ -// -// ROUTINES USED UNDER FRAME EDITOR -// -// ============================================================================ - - -// -------------------- -// MakeIcon -// -------------------- -// Called once object is created or modified, just after setup. -// Also called before showing the "Insert an object" dialog if your object -// has no icon resource - -int WINAPI DLLExport MakeIconEx ( mv _far *mV, cSurface* pIconSf, LPTSTR lpName, fpObjInfo oiPtr, LPEDATA edPtr ) +/* CreateObject + * This is the first time you have + * access to the editdata, so it + * needs to be initialized with + * default values. Just be aware + * that if the user chooses to + * create your object from a file, + * CreateFromFile will be called + * instead of this function. + */ +int MMF2Func CreateObject(mv *mV, LO *lo, SerializedED *SED) { #ifndef RUN_ONLY + if(IS_COMPATIBLE(mV)) //Make sure Fusion hasn't changed in a way that makes your extension incompatible + { + Edif::Init(mV, SED); - pIconSf->Delete(); - pIconSf->Clone(*SDK->Icon); - - pIconSf->SetTransparentColor(RGB(255, 0, 255)); + EditData().Serialize(mV, SED); //create & store the default editdata -#endif // !defined(RUN_ONLY) - return 0; + return 0; + } +#endif + return -1; } - -// -------------------- -// CreateObject -// -------------------- -// Called when you choose "Create new object". It should display the setup box -// and initialize everything in the datazone. - -int WINAPI DLLExport CreateObject(mv _far *mV, fpLevObj loPtr, LPEDATA edPtr) +/* MakeIconEx + * Lets you draw the icon dynamically + * by drawing into the Icon surface. The + * current example just uses the + * Icon.png from the resources. + */ +int MMF2Func MakeIconEx(mv *mV, cSurface *Icon, LPTSTR Name, OI *oi, SerializedED *SED) { #ifndef RUN_ONLY - - // Check compatibility - if ( IS_COMPATIBLE(mV) ) - { - Edif::Init(mV, edPtr); - - // Set default object settings -// edPtr->swidth = 48; -// edPtr->sheight = 48; - - return 0; - } -#endif // !defined(RUN_ONLY) - - // Error + Icon->Delete(); + Icon->Clone(*SDK->Icon); + Icon->SetTransparentColor(RGB(255, 0, 255)); + return 0; +#endif return -1; } -// -------------------- -// EditObject -// -------------------- -// Called when the user selects the Edit command in the object's popup menu -// -BOOL WINAPI EditObject (mv _far *mV, fpObjInfo oiPtr, fpLevObj loPtr, LPEDATA edPtr) +/* UsesFile + * When the user chooses "Create From + * File", Fusion asks each extension if + * it supports being created from that + * file. Here you should investigate + * the file and see if your extension + * can be created from it in the + * CreateFromFile function below. You + * can simply check the file extension, + * for example. + */ +BOOL MMF2Func UsesFile(mv *mV, LPTSTR FileName) { #ifndef RUN_ONLY - // Check compatibility - if ( IS_COMPATIBLE(mV) ) + if(IS_COMPATIBLE(mV)) //check for compatibility, since you can't return an error from CreateFromFile { - +// char ext[_MAX_EXT]; +// _tsplitpath(FileName, 0, 0, 0, ext); +// if(stdtstring(".iherebydeclarethatthisfilecontainsmyintmystringandmyarray") == ext) +// { +// return TRUE; +// } } -#endif // !defined(RUN_ONLY) +#endif return FALSE; } -// -------------------- -// SetEditSize -// -------------------- -// Called when the object has been resized -// -// Note: remove the comments if your object can be resized (and remove the comments in the .def file) -/* -BOOL WINAPI SetEditSize(LPMV mv, LPEDATA edPtr, int cx, int cy) -{ -#ifndef RUN_ONLY - edPtr->swidth = cx; - edPtr->sheight = cy; -#endif // !defined(RUN_ONLY) - return TRUE; // OK -} -*/ - -// -------------------- -// PutObject -// -------------------- -// Called when each individual object is dropped in the frame. -// -void WINAPI DLLExport PutObject(mv _far *mV, fpLevObj loPtr, LPEDATA edPtr, ushort cpt) +/* CreateFromFile + * If the user decides to create your object + * from the file you said you were OK with + * above, this is where you take that file + * and actually create your object from it. + * The CreateObject function up above will + * not have executed, so you need to initialize + * the editdata just as you would in CreateObject. + */ +void MMF2Func CreateFromFile(mv *mV, LPTSTR FileName, SerializedED *SED) { #ifndef RUN_ONLY -#endif // !defined(RUN_ONLY) + Edif::Init(mV, SED); + + EditData ed; //default EditData +// std::ifstream in (FileName); +// EditData::MyArray_t::size_type MyArray_size; +// in >> ed.MyString >> ed.MyInt >> MyArray_size; +// ed.MyArray.clear(); +// for(EditData::MyArray_t::size_type i = 0; i < MyArray_size; ++i) +// { +// ed.MyArray.push_back(0); +// in >> ed.MyArray.back(); +// } + ed.Serialize(mV, SED); +#endif } -// -------------------- -// RemoveObject -// -------------------- -// Called when each individual object is removed from the frame. -// -void WINAPI DLLExport RemoveObject(mv _far *mV, fpLevObj loPtr, LPEDATA edPtr, ushort cpt) +/* PutObject + * Each time a duplicate is made of your + * object, Fusion calls this function to + * let you know. You still share the same + * editdata, the difference is the + * LevelObject pointer and the number of + * duplicates. + */ +void MMF2Func PutObject(mv *mV, LO *lo, SerializedED *SED, ushort NDup) { #ifndef RUN_ONLY - // Is the last object removed? - if (0 == cpt) + if(NDup == 1) //is this the first object being created? { - Edif::Free(edPtr); - - // Do whatever necessary to remove our data + //You can put common code to both + //CreateObject and CreateFromFile + //as this function will execute + //after either one. } -#endif // !defined(RUN_ONLY) +#endif } -// -------------------- -// DuplicateObject -// -------------------- -// Called when an object is created from another one (note: should be called CloneObject instead...) -// -void WINAPI DLLExport DuplicateObject(mv __far *mV, fpObjInfo oiPtr, LPEDATA edPtr) +/* RemoveObject + * Just the opposite of the above, when + * the user removes an instance of your + * object. This also functions as a + * DestroyObject function of sorts when + * NDup == 1. + */ +void MMF2Func RemoveObject(mv *mV, LO *lo, SerializedED *SED, ushort NDup) { #ifndef RUN_ONLY -#endif // !defined(RUN_ONLY) -} - -// -------------------- -// GetObjectRect -// -------------------- -// Returns the size of the rectangle of the object in the frame editor. -// -void WINAPI DLLExport GetObjectRect(mv _far *mV, RECT FAR *rc, fpLevObj loPtr, LPEDATA edPtr) -{ -#ifndef RUN_ONLY - rc->right = rc->left + SDK->Icon->GetWidth(); // edPtr->swidth; - rc->bottom = rc->top + SDK->Icon->GetHeight(); // edPtr->sheight; -#endif // !defined(RUN_ONLY) - return; -} - - -// -------------------- -// EditorDisplay -// -------------------- -// Displays the object under the frame editor -// - -void WINAPI DLLExport EditorDisplay(mv _far *mV, fpObjInfo oiPtr, fpLevObj loPtr, LPEDATA edPtr, RECT FAR *rc) -{ -#ifndef RUN_ONLY - - LPSURFACE Surface = WinGetSurface((int) mV->mvIdEditWin); - - if(!Surface) - return; - - SDK->Icon->Blit(*Surface, rc->left, rc->top, BMODE_TRANSP, BOP_COPY, 0); - -#endif // !defined(RUN_ONLY) -} - - -// -------------------- -// IsTransparent -// -------------------- -// This routine tells MMF2 if the mouse pointer is over a transparent zone of the object. -// - -extern "C" BOOL WINAPI DLLExport IsTransparent(mv _far *mV, fpLevObj loPtr, LPEDATA edPtr, int dx, int dy) -{ -#ifndef RUN_ONLY - // Write your code here -#endif // !defined(RUN_ONLY) - return FALSE; + if(NDup == 1) //is this the last object being removed? + { + Edif::Free(SED); + // + } +#endif } -// -------------------- -// PrepareToWriteObject -// -------------------- -// Just before writing the datazone when saving the application, MMF2 calls this routine. -// -void WINAPI DLLExport PrepareToWriteObject(mv _far *mV, LPEDATA edPtr, fpObjInfo adoi) +/* CloneObject + * When the user makes a clone of your object + * (not just another instance), Fusion copies the + * contents of the editdata and then lets you + * know that the editdata in question is in + * new hands. Here you can 'fix' anything that + * might be caused by directly copying the + * editdata, though you should never have + * any problems like that in the first place. + */ +void MMF2Func CloneObject(mv *mV, OI *oi, SerializedED *SED) { #ifndef RUN_ONLY - - // Write your code here -#endif // !defined(RUN_ONLY) + // +#endif } -// -------------------- -// GetFilters -// -------------------- - -BOOL WINAPI GetFilters(LPMV mV, LPEDATA edPtr, DWORD dwFlags, LPVOID pReserved) +/* EditObject + * If the user double-clicks your object icon + * or chooses the Edit option from a context + * menu, this function is called. This is useful + * as a que to bring up an animation editor for + * animations in your object. Return TRUE if + * changes were made to the editdata, and FALSE + * otherwise. + */ +BOOL MMF2Func EditObject (mv *mV, OI *oi, LO *lo, SerializedED *SED) { #ifndef RUN_ONLY - // If your extension uses image filters -// if ( (dwFlags & GETFILTERS_IMAGES) != 0 ) -// return TRUE; - - // If your extension uses sound filters -// if ( (dwFlags & GETFILTERS_SOUNDS) != 0 ) -// return TRUE; -#endif // RUN_ONLY + // +#endif return FALSE; } -// -------------------- -// UsesFile -// -------------------- -// Triggers when a file is dropped onto the frame -// Return TRUE if you can create an object from the given file -// -BOOL WINAPI DLLExport UsesFile (LPMV mV, LPTSTR fileName) +/* SetEditSize + * If your object is resizeable, Fusion calls this + * to let you know that the user has just requested + * a resize of the object. You can take the new + * size as is, or if it reminds you too much of + * 500 page essays you can limit the size to whatever + * you want. If you uncomment this function, make + * sure you also uncomment it in Ext.def. The + * presence of this function tells Fusion that your + * object can be resized; otherwise it can't. + */ +/*BOOL MMF2Func SetEditSize(mv *mV, SerializedED *SED, int x, int y) { - BOOL r = FALSE; #ifndef RUN_ONLY - - // Example: return TRUE if file extension is ".txt" -/* - LPSTR ext, npath; - - if ( fileName != NULL ) - { - if ( (ext=(LPSTR)malloc(_MAX_EXT)) != NULL ) - { - if ( (npath=(LPSTR)malloc(_MAX_PATH)) != NULL ) - { - strcpy(npath, fileName); - _splitpath(npath, NULL, NULL, NULL, ext); - if ( _stricmp(ext, ".txt") == 0 ) - r = TRUE; - free(npath); - } - free(ext); - } - } */ -#endif // !defined(RUN_ONLY) - return r; -} - - -// -------------------- -// CreateFromFile -// -------------------- -// Creates a new object from file -// -void WINAPI DLLExport CreateFromFile (LPMV mV, LPTSTR fileName, LPEDATA edPtr) -{ -#ifndef RUN_ONLY - // Initialize your extension data from the given file -// edPtr->swidth = 48; -// edPtr->sheight = 48; - - // Example: store the filename - // strcpy(edPtr->myFileName, fileName); -#endif // !defined(RUN_ONLY) -} - -// ============================================================================ -// -// PROPERTIES -// -// ============================================================================ - -// -------------------- -// GetProperties -// -------------------- -// Inserts properties into the properties of the object. -// -BOOL WINAPI DLLExport GetProperties(LPMV mV, LPEDATA edPtr, BOOL bMasterItem) -{ -#ifndef RUN_ONLY - mvInsertProps(mV, edPtr, Properties, PROPID_TAB_GENERAL, TRUE); -#endif // !defined(RUN_ONLY) - - // OK + EditData ed (SED); + ed.Width = x; + ed.Height = y; + ed.Serialize(mV, SED); return TRUE; -} - -// -------------------- -// ReleaseProperties -// -------------------- -// Called when the properties are removed from the property window. -// -void WINAPI DLLExport ReleaseProperties(LPMV mV, LPEDATA edPtr, BOOL bMasterItem) -{ -#ifndef RUN_ONLY - // Write your code here -#endif // !defined(RUN_ONLY) -} - -// -------------------- -// GetPropCreateParam -// -------------------- -// Called when a property is initialized and its creation parameter is NULL (in the PropData). -// Allows you, for example, to change the content of a combobox property according to specific settings in the EDITDATA structure. -// -LPARAM WINAPI DLLExport GetPropCreateParam(LPMV mV, LPEDATA edPtr, UINT nPropID) -{ -#ifndef RUN_ONLY - // Example - // ------- -// if ( nPropID == PROPID_COMBO ) -// { -// switch (edPtr->sType) -// { -// case TYPE1: -// return (LPARAM)ComboList1; -// case TYPE2: -// return (LPARAM)ComboList2; -// } -// } -#endif // !defined(RUN_ONLY) - return NULL; -} - -// ---------------------- -// ReleasePropCreateParam -// ---------------------- -// Called after a property has been initialized. -// Allows you, for example, to free memory allocated in GetPropCreateParam. -// -void WINAPI DLLExport ReleasePropCreateParam(LPMV mV, LPEDATA edPtr, UINT nPropID, LPARAM lParam) -{ -#ifndef RUN_ONLY -#endif // !defined(RUN_ONLY) -} +#endif + return FALSE; +}*/ -// -------------------- -// GetPropValue -// -------------------- -// Returns the value of properties that have a value. -// Note: see GetPropCheck for checkbox properties -// -LPVOID WINAPI DLLExport GetPropValue(LPMV mV, LPEDATA edPtr, UINT nPropID) +/* GetObjectRect + * Fusion wants to know from time to time how much + * space your object is taking up on the frame + * editor. Currently this just gives the size of + * your Icon.png, but you can change it to parallel + * with the SetEditSize function above. + */ +void MMF2Func GetObjectRect(mv *mV, RECT *rect, LO *lo, SerializedED *SED) { #ifndef RUN_ONLY - // Example - // ------- -// switch (nPropID) { -// -// // Returns a color. -// case PROPID_COLOR: -// return new CPropDWordValue(edPtr->dwColor); -// -// // Returns a string -// case PROPID_TEXT: -// return new CPropDataValue(&edPtr->szText[0]); -// -// // Returns the value of the combo box -// case PROPID_COMBO: -// return new CPropDWordValue(edPtr->nComboIndex); -// } - -#endif // !defined(RUN_ONLY) - return NULL; + rect->right = rect->left + SDK->Icon->GetWidth(); + rect->bottom = rect->top + SDK->Icon->GetHeight(); +#endif } -// -------------------- -// GetPropCheck -// -------------------- -// Returns the checked state of properties that have a check box. -// -BOOL WINAPI DLLExport GetPropCheck(LPMV mV, LPEDATA edPtr, UINT nPropID) -{ -#ifndef RUN_ONLY - // Example - // ------- -// switch (nPropID) { -// -// // Return 0 (unchecked) or 1 (checked) -// case PROPID_CHECK: -// return edPtr->nCheck; -// } - -#endif // !defined(RUN_ONLY) - return 0; // Unchecked -} -// -------------------- -// SetPropValue -// -------------------- -// This routine is called by MMF after a property has been modified. -// -void WINAPI DLLExport SetPropValue(LPMV mV, LPEDATA edPtr, UINT nPropID, LPVOID lParam) +/* EditorDisplay + * This function does the work of drawing your + * object on the frame editor. In this example, + * the Icon.png file is simply drawn to the + * frame, but you can change this to draw + * anything you want. + */ +void MMF2Func EditorDisplay(mv *mV, OI *oi, LO *lo, SerializedED *SED, RECT *rect) { #ifndef RUN_ONLY - // Gets the pointer to the CPropValue structure - CPropValue* pValue = (CPropValue*)lParam; - - // Example - // ------- -// switch (nPropID) { -// -// case PROPID_COMBO: -// // Simply grab the value -// edPtr->nComboIndex = ((CPropDWordValue*)pValue)->m_dwValue; -// break; - -// case PROPID_COLOR: -// // Here too, gets the value -// edPtr->dwColor = ((CPropDWordValue*)pValue)->m_dwValue; -// break; - -// case PROPID_TEXT: -// { -// // Gets the string -// LPSTR pStr = (LPSTR)((CPropDataValue*)pValue)->m_pData; -// -// // You can simply poke the string if your EDITDATA structure has a fixed size, -// // or have an adaptive size of structure like below -// -// // If the length is different -// if (strlen(pStr)!=strlen(edPtr->text)) -// { -// // Asks MMF to reallocate the structure with the new size -// LPEDATA pNewPtr = (LPEDATA)mvReAllocEditData(mV, edPtr, sizeof(EDITDATA)+strlen(pStr)); -// -// // If reallocation worked -// if (pNewPtr!=NULL) -// { -// // Copy the string -// edPtr=pNewPtr; -// strcpy(edPtr->text, pStr); -// } -// } -// else -// { -// // Same size : simply copy -// strcpy(edPtr->text, pStr); -// } -// } -// break; -// } - - // You may want to have your object redrawn in the frame editor after the modifications, - // in this case, just call this function - // mvInvalidateObject(mV, edPtr); - -#endif // !defined(RUN_ONLY) -} - -// -------------------- -// SetPropCheck -// -------------------- -// This routine is called by MMF when the user modifies a checkbox in the properties. -// -void WINAPI DLLExport SetPropCheck(LPMV mV, LPEDATA edPtr, UINT nPropID, BOOL nCheck) + cSurface *Surface = WinGetSurface(int(mV->mvIdEditWin)); //get access to the frame editor surface + if(!Surface) return; //failure + SDK->Icon->Blit(*Surface, rect->left, rect->top, BMODE_TRANSP, BOP_COPY, 0); //copy the icon onto the frame editor surface +#endif +} + + +/* IsTransparent + * Fusion calls this to ask if the mouse pointer + * is over a transparent part of your object. + * Don't ask why this isn't called "IsOpaque", + * just accept that it isn't and move on. If the + * given coordinates are over an opaque part of + * your object, return TRUE, otherwise return + * FALSE. (Protip: Fusion calls this function a + * LOT. Don't put a MessageBox function in here + * or any other kind of debug function.) + */ +extern "C" BOOL MMF2Func IsTransparent(mv *mV, LO *lo, SerializedED *SED, int x, int y) { #ifndef RUN_ONLY - // Example - // ------- -// switch (nPropID) -// { -// case PROPID_CHECK: -// edPtr->nCheck = nCheck; -// mvInvalidateObject(mV, edPtr); -// mvRefreshProp(mV, edPtr, PROPID_COMBO, TRUE); -// break; -// } -#endif // !defined(RUN_ONLY) + // +#endif + return FALSE; } -// -------------------- -// EditProp -// -------------------- -// This routine is called when the user clicks the button of a Button or EditButton property. -// -BOOL WINAPI DLLExport EditProp(LPMV mV, LPEDATA edPtr, UINT nPropID) +/* PrepareToWriteObject (DEPRECATED) + * Just before Fusion writes the editdata to the MFA, + * it calls this function to let you clean up + * a temporary copy of the editdata. Because you + * intelligently designed your EditData::Serialize + * function to always save cleaned data anyway, + * this function is useless. + */ +void MMF2Func PrepareToWriteObject(mv *, SerializedED *, OI *){} + +/* GetFilters + * When the MFA filters are set to Automatic, Fusion + * asks your extension if it uses filters or not. + * If you use any of either kind of filters, return + * TRUE for that kind. + */ +BOOL MMF2Func GetFilters(mv *mV, SerializedED *SED, DWORD Flags, void *) { #ifndef RUN_ONLY + //If your extension uses image filters +// if((dwFlags & GETFILTERS_IMAGES) != 0) return TRUE; - // Example - // ------- -/* - if (nPropID==PROPID_EDITCONTENT) - { - if ( EditObject(mV, NULL, NULL, edPtr) ) - return TRUE; - } -*/ - -#endif // !defined(RUN_ONLY) + //If your extension uses sound filters +// if((dwFlags & GETFILTERS_SOUNDS) != 0) return TRUE; +#endif return FALSE; } -// -------------------- -// IsPropEnabled -// -------------------- -// This routine returns the enabled state of a property. -// -BOOL WINAPI IsPropEnabled(LPMV mV, LPEDATA edPtr, UINT nPropID) -{ #ifndef RUN_ONLY - // Example - // ------- -/* - switch (nPropID) { - - case PROPID_CHECK: - return (edPtr->nComboIndex != 0); - } -*/ -#endif // !defined(RUN_ONLY) - return TRUE; -} - -// ============================================================================ -// -// TEXT PROPERTIES -// -// ============================================================================ - -// -------------------- -// GetTextCaps -// -------------------- -// Return the text capabilities of the object under the frame editor. -// -DWORD WINAPI DLLExport GetTextCaps(mv _far *mV, LPEDATA edPtr) +/* InterceptActionSelection + * This function is called after the user has selected a + * menu item from the actions popup menu. You can show + * a dialog or allow the user to make a choice, and + * return a different ID to Fusion. Be aware, there + * is no way to cancel this operation. + */ +short InterceptActionSelection(mv *mV, short selectedId) { - return 0; // (TEXT_ALIGN_LEFT|TEXT_ALIGN_HCENTER|TEXT_ALIGN_RIGHT|TEXT_ALIGN_TOP|TEXT_ALIGN_VCENTER|TEXT_ALIGN_BOTTOM|TEXT_FONT|TEXT_COLOR); + return selectedId; } -// -------------------- -// GetTextFont -// -------------------- -// Return the font used the object. -// Note: the pStyle and cbSize parameters are obsolete and passed for compatibility reasons only. -// -BOOL WINAPI DLLExport GetTextFont(mv _far *mV, LPEDATA edPtr, LPLOGFONT plf, LPTSTR pStyle, UINT cbSize) +/* InterceptActionSelection + * This function is called after the user has selected a + * menu item from the conditions popup menu. You can show + * a dialog or allow the user to make a choice, and + * return a different ID to Fusion. Be aware, there + * is no way to cancel this operation. + */ +short InterceptConditionSelection(mv *mV, short selectedId) { -#if !defined(RUN_ONLY) - // Example: copy LOGFONT structure from EDITDATA - // memcpy(plf, &edPtr->m_lf, sizeof(LOGFONT)); -#endif // !defined(RUN_ONLY) - - return TRUE; + return selectedId; } -// -------------------- -// SetTextFont -// -------------------- -// Change the font used the object. -// Note: the pStyle parameter is obsolete and passed for compatibility reasons only. -// -BOOL WINAPI DLLExport SetTextFont(mv _far *mV, LPEDATA edPtr, LPLOGFONT plf, LPCSTR pStyle) +/* InterceptActionSelection + * This function is called after the user has selected a + * menu item from the expressions popup menu. You can show + * a dialog or allow the user to make a choice, and + * return a different ID to Fusion. Be aware, there + * is no way to cancel this operation. + */ +short InterceptExpressionSelection(mv *mV, short selectedId) { -#if !defined(RUN_ONLY) - // Example: copy LOGFONT structure to EDITDATA - // memcpy(&edPtr->m_lf, plf, sizeof(LOGFONT)); -#endif // !defined(RUN_ONLY) - - return TRUE; + return selectedId; } -// -------------------- -// GetTextClr -// -------------------- -// Get the text color of the object. -// -COLORREF WINAPI DLLExport GetTextClr(mv _far *mV, LPEDATA edPtr) -{ - // Example - return 0; // edPtr->fontColor; -} - -// -------------------- -// SetTextClr -// -------------------- -// Set the text color of the object. -// -void WINAPI DLLExport SetTextClr(mv _far *mV, LPEDATA edPtr, COLORREF color) -{ - // Example - //edPtr->fontColor = color; -} - -// -------------------- -// GetTextAlignment -// -------------------- -// Get the text alignment of the object. -// -DWORD WINAPI DLLExport GetTextAlignment(mv _far *mV, LPEDATA edPtr) -{ - DWORD dw = 0; -#if !defined(RUN_ONLY) - // Example - // ------- -/* if ( (edPtr->eData.dwFlags & ALIGN_LEFT) != 0 ) - dw |= TEXT_ALIGN_LEFT; - if ( (edPtr->eData.dwFlags & ALIGN_HCENTER) != 0 ) - dw |= TEXT_ALIGN_HCENTER; - if ( (edPtr->eData.dwFlags & ALIGN_RIGHT) != 0 ) - dw |= TEXT_ALIGN_RIGHT; - if ( (edPtr->eData.dwFlags & ALIGN_TOP) != 0 ) - dw |= TEXT_ALIGN_TOP; - if ( (edPtr->eData.dwFlags & ALIGN_VCENTER) != 0 ) - dw |= TEXT_ALIGN_VCENTER; - if ( (edPtr->eData.dwFlags & ALIGN_BOTTOM) != 0 ) - dw |= TEXT_ALIGN_BOTTOM; -*/ -#endif // !defined(RUN_ONLY) - return dw; -} - -// -------------------- -// SetTextAlignment -// -------------------- -// Set the text alignment of the object. -// -void WINAPI DLLExport SetTextAlignment(mv _far *mV, LPEDATA edPtr, DWORD dwAlignFlags) -{ -#if !defined(RUN_ONLY) - // Example - // ------- -/* DWORD dw = edPtr->eData.dwFlags; - - if ( (dwAlignFlags & TEXT_ALIGN_LEFT) != 0 ) - dw = (dw & ~(ALIGN_LEFT|ALIGN_HCENTER|ALIGN_RIGHT)) | ALIGN_LEFT; - if ( (dwAlignFlags & TEXT_ALIGN_HCENTER) != 0 ) - dw = (dw & ~(ALIGN_LEFT|ALIGN_HCENTER|ALIGN_RIGHT)) | ALIGN_HCENTER; - if ( (dwAlignFlags & TEXT_ALIGN_RIGHT) != 0 ) - dw = (dw & ~(ALIGN_LEFT|ALIGN_HCENTER|ALIGN_RIGHT)) | ALIGN_RIGHT; - - if ( (dwAlignFlags & TEXT_ALIGN_TOP) != 0 ) - dw = (dw & ~(ALIGN_TOP|ALIGN_VCENTER|ALIGN_BOTTOM)) | ALIGN_TOP; - if ( (dwAlignFlags & TEXT_ALIGN_VCENTER) != 0 ) - dw = (dw & ~(ALIGN_TOP|ALIGN_VCENTER|ALIGN_BOTTOM)) | ALIGN_VCENTER; - if ( (dwAlignFlags & TEXT_ALIGN_BOTTOM) != 0 ) - dw = (dw & ~(ALIGN_TOP|ALIGN_VCENTER|ALIGN_BOTTOM)) | ALIGN_BOTTOM; - - edPtr->eData.dwFlags = dw; -*/ -#endif // !defined(RUN_ONLY) -} - - -// ---------------------------------------------------------- -// Custom Parameters -// ---------------------------------------------------------- - -// -------------------- -// InitParameter -// -------------------- -// Initialize the parameter. -// -void WINAPI InitParameter(mv _far *mV, short code, paramExt* pExt) -{ -#if !defined(RUN_ONLY) - // Example - // ------- - // strcpy(&pExt->pextData[0], "Parameter Test"); - // pExt->pextSize = sizeof(paramExt) + strlen(pExt->pextData)+1; -#endif // !defined(RUN_ONLY) -} - -// Example of custom parameter setup proc -// -------------------------------------- -/* -#if !defined(RUN_ONLY) -BOOL CALLBACK DLLExport SetupProc(HWND hDlg, UINT msgType, WPARAM wParam, LPARAM lParam) -{ - paramExt* pExt; - - switch (msgType) - { - case WM_INITDIALOG: // Init dialog - - // Save edptr - SetWindowLong(hDlg, DWL_USER, lParam); - pExt=(paramExt*)lParam; - - SetDlgItemText(hDlg, IDC_EDIT, pExt->pextData); - return TRUE; - - case WM_COMMAND: // Command - - // Retrieve edptr - pExt = (paramExt *)GetWindowLong(hDlg, DWL_USER); - - switch (wmCommandID) - { - case IDOK: // Exit - GetDlgItemText(hDlg, IDC_EDIT, pExt->pextData, 500); - pExt->pextSize=sizeof(paramExt)+strlen(pExt->pextData)+1; - EndDialog(hDlg, TRUE); - return TRUE; - - default: - break; - } - break; - - default: - break; - } - return FALSE; -} -#endif // !defined(RUN_ONLY) -*/ - -// -------------------- -// EditParameter -// -------------------- -// Edit the parameter. -// -void WINAPI EditParameter(mv _far *mV, short code, paramExt* pExt) -{ -#if !defined(RUN_ONLY) - - // Example - // ------- - // DialogBoxParam(hInstLib, MAKEINTRESOURCE(DB_TRYPARAM), mV->mvHEditWin, SetupProc, (LPARAM)(LPBYTE)pExt); - -#endif // !defined(RUN_ONLY) -} - -// -------------------- -// GetParameterString -// -------------------- -// Initialize the parameter. -// -void WINAPI GetParameterString(mv _far *mV, short code, paramExt* pExt, LPSTR pDest, short size) -{ -#if !defined(RUN_ONLY) - - // Example - // ------- - // wsprintf(pDest, "Super parameter %s", pExt->pextData); - -#endif // !defined(RUN_ONLY) -} +#endif diff --git a/Extensions/Template/Expressions.cpp b/Extensions/Template/Expressions.cpp index 6ddc908..cad6ed0 100644 --- a/Extensions/Template/Expressions.cpp +++ b/Extensions/Template/Expressions.cpp @@ -1,12 +1,20 @@ +/* Expressions.cpp + * This is where you should define the + * behavior of your expressions. Make sure + * the parameters and return types match those + * in the JSON exactly! Double check Extension.h + * as well. + */ #include "Common.h" int Extension::Add(int First, int Second) { - return First + Second; + return First + Second; } -const char * Extension::HelloWorld() +TCHAR const * Extension::HelloWorld() { - return "Hello world!"; -} \ No newline at end of file + return _T("Hello world!"); + //return Runtime.CopyString(MyString.c_str()); //for stdtstrings +} diff --git a/Extensions/Template/Ext.def b/Extensions/Template/Ext.def index 9c45d91..9e654a0 100644 --- a/Extensions/Template/Ext.def +++ b/Extensions/Template/Ext.def @@ -1,110 +1,118 @@ +; Ext.def +; This is how the linker knows +; which functions to export and +; what names and ordinals the +; exported functions should +; have. If you implemented a +; function that was commented +; out, remove the semicolon comment +; before it in this file. +; EXPORTS - GetInfos @2 - LoadObject @6 - UnloadObject @7 - PutObject @8 - RemoveObject @9 - MakeIconEx @11 + GetInfos @2 + LoadObject @6 + UnloadObject @7 + PutObject @8 + RemoveObject @9 + MakeIconEx @11 - CreateObject @14 - GetHelpFileName @16 - EditObject @18 - GetObjectRect @19 - EditorDisplay @20 - IsTransparent @21 - PrepareToWriteObject @22 - UpdateFileNames @23 -; EnumElts @24 - Initialize @25 - Free @26 -; ExportTexts @27 -; ImportTexts @28 -; GetSubType @29 - UsesFile @30 - CreateFromFile @31 - DuplicateObject @32 - GetObjInfos @36 + CreateObject @14 + GetHelpFileName @16 + EditObject @18 + GetObjectRect @19 + EditorDisplay @20 + IsTransparent @21 + PrepareToWriteObject @22 + UpdateFileNames @23 +; EnumElts @24 + Initialize=InitExtension @25 + Free=FreeExtension @26 +; ExportTexts @27 +; ImportTexts @28 +; GetSubType @29 + UsesFile @30 + CreateFromFile @31 + DuplicateObject=CloneObject @32 + GetObjInfos @36 - GetTextCaps @37 - GetTextAlignment @38 - SetTextAlignment @39 - GetTextFont @40 - SetTextFont @41 - GetTextClr @42 - SetTextClr @43 + GetTextCaps @37 + GetTextAlignment @38 + SetTextAlignment @39 + GetTextFont @40 + SetTextFont @41 + GetTextClr @42 + SetTextClr @43 - GetDependencies @44 - GetFilters @45 + GetDependencies @44 + GetFilters @45 -; conditionsTable @47 -; actionsTable @48 -; expressionsTable @49 +; conditionsTable @47 +; actionsTable @48 +; expressionsTable @49 - CreateRunObject @50 - DestroyRunObject @51 - HandleRunObject @52 - DisplayRunObject @53 - PauseRunObject @57 - ContinueRunObject @58 - GetRunObjectInfos @59 + CreateRunObject @50 + DestroyRunObject @51 + HandleRunObject @52 + DisplayRunObject @53 + PauseRunObject @57 + ContinueRunObject @58 + GetRunObjectInfos @59 - GetConditionMenu @60 - GetActionMenu @61 - GetExpressionMenu @62 - GetConditionCodeFromMenu @63 - GetActionCodeFromMenu @64 - GetExpressionCodeFromMenu @65 - GetConditionString @66 - GetActionString @67 - GetExpressionString @68 - InitParameter @69 - EditParameter @70 - GetParameterString @71 - GetConditionTitle @72 - GetActionTitle @73 - GetExpressionTitle @74 - GetConditionInfos @75 - GetActionInfos @76 - GetExpressionInfos @77 - UpdateEditStructure @78 - GetRunObjectDataSize @80 -; SaveBackground @81 -; RestoreBackground @82 -; KillBackground @83 -; WindowProc @84 - StartApp @85 - EndApp @86 - StartFrame @87 - EndFrame @88 - GetExpressionParam @89 + GetConditionMenu @60 + GetActionMenu @61 + GetExpressionMenu @62 + GetConditionCodeFromMenu @63 + GetActionCodeFromMenu @64 + GetExpressionCodeFromMenu @65 + GetConditionString @66 + GetActionString @67 + GetExpressionString @68 + InitParameter @69 + EditParameter @70 + GetParameterString @71 + GetConditionTitle @72 + GetActionTitle @73 + GetExpressionTitle @74 + GetConditionInfos @75 + GetActionInfos @76 + GetExpressionInfos @77 + UpdateEditStructure @78 + GetRunObjectDataSize @80 +; SaveBackground @81 +; RestoreBackground @82 +; KillBackground @83 +; WindowProc @84 + StartApp @85 + EndApp @86 + StartFrame @87 + EndFrame @88 + GetExpressionParam @89 -; GetRunObjectSurface @90 -; GetRunObjectCollisionMask @91 +; GetRunObjectSurface @90 +; GetRunObjectCollisionMask @91 -; GetRunObjectFont @92 -; SetRunObjectFont @93 -; GetRunObjectTextColor @94 -; SetRunObjectTextColor @95 +; GetRunObjectFont @92 +; SetRunObjectFont @93 +; GetRunObjectTextColor @94 +; SetRunObjectTextColor @95 -; SetEditSize @99 - GetProperties @100 - ReleaseProperties @101 - GetPropValue @102 - SetPropValue @103 - IsPropEnabled @104 - GetPropCheck @105 - SetPropCheck @106 - GetPropCreateParam @107 - ReleasePropCreateParam @108 - EditProp @109 - GetDebugTree @110 - GetDebugItem @111 - EditDebugItem @112 +; SetEditSize @99 + GetProperties @100 + ReleaseProperties @101 + GetPropValue @102 + SetPropValue @103 + IsPropEnabled @104 + GetPropCheck @105 + SetPropCheck @106 + GetPropCreateParam @107 + ReleasePropCreateParam @108 + EditProp @109 + GetDebugTree @110 + GetDebugItem @111 + EditDebugItem @112 - SaveRunObject @113 - LoadRunObject @114 + SaveRunObject @113 + LoadRunObject @114 - PrepareFlexBuild @115 - - \ No newline at end of file + PrepareFlexBuild @115 diff --git a/Extensions/Template/Ext.json b/Extensions/Template/Ext.json index 6f11221..8e07e5b 100644 --- a/Extensions/Template/Ext.json +++ b/Extensions/Template/Ext.json @@ -1,91 +1,75 @@ { - "About": { - "Name": "Example object", - "Author": "Your Name", - "Copyright": "Copyright (C) 2013 Your Name", - "Comment": "A sentence or two to describe your extension", - "URL": "http://www.example.com", - "Help": "Help/Example.chm", - "Identifier": "EXMP" - }, - "ActionMenu": [ - [ - 0, - "Action Example" - ], - "Separator", - [ - "Sub Menu", - [ - 1, - "Second Action Example" - ] - ] - ], - "ConditionMenu": [ - [ - 0, - "Are two numbers equal?" - ] - ], - "ExpressionMenu": [ - [ - 0, - "Add two numbers" - ], - [ - 1, - "Hello world" - ] - ], - "Actions": [ - { - "Title": "Action Example with parameter %0", - "Parameters": [ - [ - "Integer", - "Example Parameter" - ] - ] - }, - { - "Title": "Second Action Example" - } - ], - "Conditions": [ - { - "Title": "%o : Are %0 and %1 equal?", - "Parameters": [ - [ - "Integer", - "First number" - ], - [ - "Integer", - "Second number" - ] - ], - "Triggered": false - } - ], - "Expressions": [ - { - "Title": "Add(", - "Returns": "Integer", - "Parameters": [ - [ - "Integer", - "First number" - ], - [ - "Integer", - "Second number" - ] - ] - }, - { - "Title": "HelloWorld$(", - "Returns": "Text" - } - ] + "About": + { + "Name": "EDIF Template Object", + "Author": "Your Name", + "Copyright": "Copyright © 2014 Your Name", + "Comment": "A sentence or two to describe your extension,\nwith up to four lines of text.", + "URL": "http://www.example.com/", + "Help": "Help/My New EDIF Extension/Help.chm", + "Identifier": "X&pl" + }, + + "ActionMenu": + [ + "Separator", + [0, "Action Example"], + "Separator", + ["Sub Menu", + [1, "Second Action Example"] + ], + "Separator", + [0, "A Disabled Menu Item", true], + "Separator" + ], + "ConditionMenu": + [ + "Separator", + [0, "Are two numbers equal?"], + "Separator" + ], + "ExpressionMenu": + [ + "Separator", + [0, "Add two numbers"], + [1, "Hello world"], + "Separator" + ], + + "Actions": + [ + { "Title": "Action Example with parameter %0", + "Parameters": + [ + ["Integer", "Example Parameter"] + ] + }, + { "Title": "Second Action Example" + } + ], + "Conditions": + [ + { "Title": "%o: Are %0 and %1 equal?", + "Parameters": + [ + ["Integer", "First number"], + ["Integer", "Second number"] + ], + "Triggered": false + } + ], + "Expressions": + [ + { "Title": "Add(", + "Returns": "Integer", + "Parameters": + [ + ["Integer", "First number"], + ["Integer", "Second number"] + ] + }, + { "Title": "HelloWorld$(", + "Returns": "Text" + } + ] } diff --git a/Extensions/Template/Ext.rc b/Extensions/Template/Ext.rc index c4b5941..5d6f17e 100644 --- a/Extensions/Template/Ext.rc +++ b/Extensions/Template/Ext.rc @@ -42,24 +42,24 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US FILETYPE 0x1L FILESUBTYPE 0x0L BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904e4" - BEGIN - VALUE "CompanyName", "Clickteam" - VALUE "FileDescription", "Edif Object" - VALUE "FileVersion", "2.00" - VALUE "InternalName", "EdifExt" - VALUE "LegalCopyright", "Copyright © 2012 Clickteam" - VALUE "OriginalFilename", "EdifExt.mfx" - VALUE "ProductVersion", "1, 0, 0, 1" - VALUE "SpecialBuild", "00000001" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1252 - END + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904e4" + BEGIN + VALUE "CompanyName", "Clickteam" + VALUE "FileDescription", "Edif Object" + VALUE "FileVersion", "2.00" + VALUE "InternalName", "EdifExt" + VALUE "LegalCopyright", "Copyright © 2012 Clickteam" + VALUE "OriginalFilename", "EdifExt.mfx" + VALUE "ProductVersion", "1, 0, 0, 1" + VALUE "SpecialBuild", "00000001" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END END @@ -70,7 +70,7 @@ END KPX_MAGICNUMBER RCDATA BEGIN - 0x2516, 0x5908 + 0x2516, 0x5908 END @@ -82,25 +82,25 @@ END 1 TEXTINCLUDE BEGIN - "resource.h\0" + "resource.h\0" END 2 TEXTINCLUDE BEGIN - "#include ""..\\..\\Inc\\ccx.h""\r\n" - "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" - "#include ""windows.h""\r\n" - "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" - "\0" + "#include ""..\\..\\Inc\\ccx.h""\r\n" + "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" + "#include ""windows.h""\r\n" + "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" + "\0" END 3 TEXTINCLUDE BEGIN - "\r\n" - "\0" + "\r\n" + "\0" END -#endif // APSTUDIO_INVOKED +#endif // APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// @@ -110,10 +110,10 @@ END STRINGTABLE BEGIN - KPX_MARK "MF2" + KPX_MARK "MF2" END -#endif // English (U.S.) resources +#endif // English (U.S.) resources ///////////////////////////////////////////////////////////////////////////// @@ -133,13 +133,13 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK #if defined(APSTUDIO_INVOKED) || defined(EDITOR) #if defined(APSTUDIO_INVOKED) -IDR_EDIF_ICON$(EDITOR) EDIF "Icon.png" +IDR_EDIF_ICON$(EDITOR) EDIF "Icon.png" #else -IDR_EDIF_ICON EDIF "Icon.png" +IDR_EDIF_ICON EDIF "Icon.png" #endif #endif -IDR_EDIF_JSON EDIF "Ext.json" -#endif // English (U.K.) resources +IDR_EDIF_JSON EDIF "Ext.json" +#endif // English (U.K.) resources ///////////////////////////////////////////////////////////////////////////// @@ -152,5 +152,5 @@ IDR_EDIF_JSON EDIF "Ext.json" ///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED +#endif // not APSTUDIO_INVOKED diff --git a/Extensions/Template/Extension.cpp b/Extensions/Template/Extension.cpp index 287df33..1f09854 100644 --- a/Extensions/Template/Extension.cpp +++ b/Extensions/Template/Extension.cpp @@ -1,160 +1,191 @@ +/* Extension.cpp + * This file contains the definitions for + * your extension's general runtime functions, + * such as the constructor and destructor, + * handling routines, etc. + * Functions defined here: + * Extension::Extension + * Extension::~Extension + * Extension::Handle + * Extension::Display + * Extension::Pause + * Extension::Continue + * Extension::Save + * Extension::Load + * Extension::Action <--| + * Extension::Condition <--|- not what you think! + * Extension::Expression <--| + */ #include "Common.h" - -/// -/// EXTENSION CONSTRUCTOR/DESTRUCTOR -/// - -Extension::Extension(LPRDATA _rdPtr, LPEDATA edPtr, fpcob cobPtr) - : rdPtr(_rdPtr), rhPtr(_rdPtr->rHo.hoAdRunHeader), Runtime(_rdPtr) +/* + * This is your extension's constructor, which + * is the replacement for the old CreateRunObject + * function. You don't need to manually call + * constructors or pointlessly initialize + * pointers with dynamic memory. Just link + * your A/C/Es, perform initialization steps, and + * you're good to go. + */ +Extension::Extension(RD *rd, SerializedED *SED, createObjectInfo *COB) +: rd(rd) +, rh(rd->rHo.hoAdRunHeader) +, Runtime(rd) { - /* - Link all your action/condition/expression functions to their IDs to match the - IDs in the JSON here - */ - - LinkAction(0, ActionExample); - LinkAction(1, SecondActionExample); - - LinkCondition(0, AreTwoNumbersEqual); + //Link all your action/condition/expression functions + //to their IDs to match the IDs in the JSON here. + LinkAction(0, ActionExample); + LinkAction(1, SecondActionExample); - LinkExpression(0, Add); - LinkExpression(1, HelloWorld); + LinkCondition(0, AreTwoNumbersEqual); + LinkExpression(0, Add); + LinkExpression(1, HelloWorld); - /* - This is where you'd do anything you'd do in CreateRunObject in the original SDK - It's the only place you'll get access to edPtr at runtime, so you should transfer - anything from edPtr to the extension class here. - - */ + //This is where you'd do anything you'd do in CreateRunObject in the original SDK. + //It's the only place you'll get access to the editdata at runtime, so you should + //transfer anything from the editdata to the extension class here. For example: +// EditData ed (SED); +// MyString = ed.MyString; +// MyInt = ed.MyInt; +// MyArray = ed.MyArray; - - + // } +/* + * This is your extension's destructor, the + * replacement for DestroyRunObject. No calling + * destructors manually or deallocating pointless + * dynamic memory - in most cases this function + * won't need any code written. + */ Extension::~Extension() { - /* - This is where you'd do anything you'd do in DestroyRunObject in the original SDK. - (except calling destructors and other such atrocities, because that's automatic in Edif) - */ - - - + // } - +/* Handle + * Fusion calls this function to let your extension + * "live" - if you want, you can have Fusion call this + * every frame. This is where you'd, for instance, + * simulate physics or move an object. This is + * the analagous function to the old HandleRunObject. + */ short Extension::Handle() { - /* - If your extension will draw to the MMF window you should first - check if anything about its display has changed : + /* + If your extension will draw to the MMF window you should first + check if anything about its display has changed : - if (rdPtr->roc.rcChanged) - return REFLAG_DISPLAY; - else - return 0; + if (rd->roc.rcChanged) return REFLAG_DISPLAY; + else return 0; - You will also need to make sure you change this flag yourself - to 1 whenever you want to redraw your object - - If your extension won't draw to the window, but it still needs - to do something every MMF loop use : + You will also need to make sure you change this flag yourself + to 1 whenever you want to redraw your object - return 0; + If your extension won't draw to the window, but it still needs + to do something every Fusion loop use: - If you don't need to do something every loop, use : + return 0; - return REFLAG_ONESHOT; + If you don't need to do something every loop, use : - This doesn't mean this function can never run again. If you want MMF - to handle your object again (causing this code to run) use this function: + return REFLAG_ONESHOT; - Runtime.Rehandle(); + This doesn't mean this function can never run again. If you want Fusion + to handle your object again (causing this code to run) use this function: - At the end of the loop this code will run + Runtime.Rehandle(); - */ + At the end of the event loop this code will run. + */ - // Will not be called next loop + //Will not be called next loop return REFLAG_ONESHOT; } - +/* Display + * This is the analagous function to + * DisplayRunObject. If you return + * REFLAG_DISPLAY in Handle() this + * routine will run. If you want Fusion + * to apply ink effects for you, then + * implement GetRunObjectSurface in + * Runtime.cpp instead. + */ short Extension::Display() { - /* - If you return REFLAG_DISPLAY in Handle() this routine will run. - */ - - // Ok - return 0; + return 0; } +/* Pause + * If your extension plays sound, for + * example, then Fusion calls this to + * let you know to pause the music, + * usually by another extension's request + * or by the player pausing the applcation. + */ short Extension::Pause() { - - // Ok - return 0; + return 0; } +/* Continue + * Opposite to the above, Fusion lets + * you know that the silence is over; + * your extension may live again. + */ short Extension::Continue() { - - // Ok - return 0; + return 0; } +/* Save + * When the user uses the Save + * Frame Position action, you need + * so serialize your runtime data to + * the File given. It is a Windows + * file handle, but you can use some + * of Fusion's built-in functions for + * writing files. Check the MMF2SDK + * Help file for more information. + */ bool Extension::Save(HANDLE File) { - bool OK = false; - - #ifndef VITALIZE - - // Save the object's data here - - OK = true; - - #endif - - return OK; + return true; } +/* Load + * As opposed to above, here you need to + * restore your extension's runtime state + * from the given file. Only read what you + * wrote! + */ bool Extension::Load(HANDLE File) { - bool OK = false; - - #ifndef VITALIZE - - // Load the object's data here - - OK = true; - - #endif - - return OK; + return true; } -// These are called if there's no function linked to an ID - -void Extension::Action(int ID, LPRDATA rdPtr, long param1, long param2) +/* Action, Condition, Expression + * These are called if there's no function linked + * to an ID. You may want to put MessageBox calls + * to let you know that the ID is unlinked, or you + * may just want to use unlinked A/C/Es as a feature. + */ +void Extension::Action(int ID, RD *rd, long param1, long param2) { - } -long Extension::Condition(int ID, LPRDATA rdPtr, long param1, long param2) +long Extension::Condition(int ID, RD *rd, long param1, long param2) { - - return false; + return false; //hopefully StringComparison (PARAM_CMPSTRING) is not used, or this may crash } -long Extension::Expression(int ID, LPRDATA rdPtr, long param) +long Extension::Expression(int ID, RD *rd, long param) { - - return 0; + return long(_T("")); //so that unlinked expressions that return strings won't crash } - diff --git a/Extensions/Template/Extension.h b/Extensions/Template/Extension.h deleted file mode 100644 index c3fee2e..0000000 --- a/Extensions/Template/Extension.h +++ /dev/null @@ -1,83 +0,0 @@ - -class Extension -{ -public: - - LPRDATA rdPtr; - LPRH rhPtr; - - Edif::Runtime Runtime; - - static const int MinimumBuild = 251; - static const int Version = 1; - - static const int OEFLAGS = 0; - static const int OEPREFS = 0; - - static const int WindowProcPriority = 100; - - Extension(LPRDATA rdPtr, LPEDATA edPtr, fpcob cobPtr); - ~Extension(); - - - /* Add any data you want to store in your extension to this class - (eg. what you'd normally store in rdPtr) - - Unlike rdPtr, you can store real C++ objects with constructors - and destructors, without having to call them manually or store - a pointer. - */ - - // int MyVariable; - - - - - /* Add your actions, conditions and expressions as real class member - functions here. The arguments (and return type for expressions) must - match EXACTLY what you defined in the JSON. - - Remember to link the actions, conditions and expressions to their - numeric IDs in the class constructor (Extension.cpp) - */ - - /// Actions - - void ActionExample(int ExampleParameter); - void SecondActionExample(); - - /// Conditions - - bool AreTwoNumbersEqual(int FirstNumber, int SecondNumber); - - /// Expressions - - int Add(int FirstNumber, int SecondNumber); - const char * HelloWorld(); - - - - /* These are called if there's no function linked to an ID */ - - void Action(int ID, LPRDATA rdPtr, long param1, long param2); - long Condition(int ID, LPRDATA rdPtr, long param1, long param2); - long Expression(int ID, LPRDATA rdPtr, long param); - - - - - /* These replace the functions like HandleRunObject that used to be - implemented in Runtime.cpp. They work exactly the same, but they're - inside the extension class. - */ - - short Handle(); - short Display(); - - short Pause(); - short Continue(); - - bool Save(HANDLE File); - bool Load(HANDLE File); - -}; \ No newline at end of file diff --git a/Extensions/Template/Extension.hpp b/Extensions/Template/Extension.hpp new file mode 100644 index 0000000..42935b1 --- /dev/null +++ b/Extensions/Template/Extension.hpp @@ -0,0 +1,133 @@ +/* Extension.h + * This is where you define your extension + * class. Runtime variables and function + * declarations go in here; A/C/E function + * definitions go in their respective .cpp + * files, other function definitions go in + * Extension.cpp. This header is included + * at the bottom of Common.h, so you have + * access to everything included by it. + */ + +class Extension final +{ +public: + /* rd + * This is a pointer to the classic + * RunData structure. Some things still + * have to be stored there for Fusion's + * sake, so you need to have acces to + * that data. You should not modify + * the rundata structure, however, + * as it is global to all extensions. + */ + RD *rd; + + /* rh + * This is a pointer to the RunHeader + * structure, which contains some + * application information. + */ + RunHeader *rh; + + /* Runtime + * This is EDIF's compendium of useful + * functions for every day life as an + * extension. You can trigger immediate + * events, read and write global data, + * etc. See the EDIF wiki for more + * information. + */ + Edif::Runtime Runtime; + + /* MinimumBuild + * Always set this to the latest build + * of Fusion that has been released, unless + * you need to set it higher for a beta + * version of Fusion to get access to some + * new SDK feature. + */ + static const int MinimumBuild = 257; + + /* Version + * This is the version of your extension + * that is stored in the editdata. You should + * only change this when your editdata structure + * changes, not just when you have a new version + * of your extension with new features. + */ + static const int Version = 1; + + /* OEFLAGS, OEPREFS + * These are settings for your extension + * that tell Fusion how to treat your extension + * and what behaviors and responsibilities + * to add. Check the MMF2SDK Help file for + * more detailed information on the flags you + * can set and what they implicate. + */ + static const int OEFLAGS = OEFLAG_VALUES|OEFLAG_RUNBEFOREFADEIN|OEFLAG_NEVERKILL; + static const int OEPREFS = 0; + + /* WindowProcPriority + * If your extension creates a Window + * and implements the WindowProc function, + * this is the priority for that stuff. + */ + static const int WindowProcPriority = 100; + + Extension(RD *rd, SerializedED *SED, createObjectInfo *COB); //defined & documented in Extension.cpp + ~Extension(); //defined & documented in Extension.cpp + + + /* Add any data you want to store in your + * extension to this class (eg. what you'd + * normally store in the rundata). Unlike + * other SDKs, you can store real C++ + * objects with constructors and destructors, + * without having to call them manually or + * store a pointer. + */ + + //stdtstring MyString; + //int MyInt; + //std::vector MyArray; + + + /* Add your actions, conditions, and expressions + * as real class member functions here. The arguments + * (and return types for expressions/conditions) + * must match EXACTLY what you defined in the JSON. + * As a handy tip, all parameters will be either + * a pointer, an int, or a float (each only 4 bytes) + * and the same applies to return types. Remember to + * link the actions, conditions and expressions to their + * numeric IDs in the class constructor in Extension.cpp. + */ + + //Actions - Defined in Actions.cpp + void ActionExample(int ExampleParameter); + void SecondActionExample(); + + //Conditions - Defined in Conditions.cpp + bool AreTwoNumbersEqual(int FirstNumber, int SecondNumber); + + //Expressions - Defined in Expressions.cpp + int Add(int FirstNumber, int SecondNumber); + const TCHAR * HelloWorld(); + + + short Handle(); //defined & documented in Extension.cpp + short Display(); //defined & documented in Extension.cpp + + short Pause(); //defined & documented in Extension.cpp + short Continue(); //defined & documented in Extension.cpp + + bool Save(HANDLE File); //defined & documented in Extension.cpp + bool Load(HANDLE File); //defined & documented in Extension.cpp + + //defined & documented in Extension.cpp + void Action(int ID, RD *rd, long param1, long param2); + long Condition(int ID, RD *rd, long param1, long param2); + long Expression(int ID, RD *rd, long param); +}; diff --git a/Extensions/Template/General.cpp b/Extensions/Template/General.cpp index 41f53af..8afed86 100644 --- a/Extensions/Template/General.cpp +++ b/Extensions/Template/General.cpp @@ -1,165 +1,165 @@ - -// ============================================================================ -// -// The following routines are used internally by MMF, and should not need to -// be modified. -// -// -// ============================================================================ +/* General.cpp + * Contains functions common to both edittime and runtime. + * Functions defined here: + * DllMain + * InitExtension + * FreeExtension + * LoadObject + * UnloadObject + * UpdateEditStrucrure + * UpdateFileNames + * EnumElts + */ #include "Common.h" +/* hInstLib + * This is the HINSTANCE for your extension's DLL. + * It is set by DllMain and used later for anything + * that requires it, such as some Windows API + * functions and some internal EDIF code. You + * shouldn't change its value, ever. + */ HINSTANCE hInstLib; -// ============================================================================ -// -// LIBRARY ENTRY & QUIT POINTS -// -// ============================================================================ - -// ----------------- -// Entry points -// ----------------- -// Usually you do not need to do any initialization here: you will prefer to -// do them in "Initialize" found in Edittime.cpp -BOOL WINAPI DllMain(HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved) +/* DllMain + * This is a required function for Windows DLLs. You + * should not need to edit this function - if you do, + * refer to MSDN for information. + */ +BOOL WINAPI DllMain(HINSTANCE DLL, DWORD Reason, LPVOID) { - switch (dwReason) + switch (Reason) { - // DLL is attaching to the address space of the current process. - case DLL_PROCESS_ATTACH: - - hInstLib = hDLL; // Store HINSTANCE + case DLL_PROCESS_ATTACH: //DLL is attaching to the address space of the current process. + { + hInstLib = DLL; //Store HINSTANCE break; - - // A new thread is being created in the current process. - case DLL_THREAD_ATTACH: + } + case DLL_THREAD_ATTACH: //A new thread is being created in the current process. + { + // break; - - // A thread is exiting cleanly. - case DLL_THREAD_DETACH: + } + case DLL_THREAD_DETACH: //A thread is exiting cleanly. + { + // break; - - // The calling process is detaching the DLL from its address space. - case DLL_PROCESS_DETACH: + } + case DLL_PROCESS_DETACH: //The calling process is detaching the DLL from its address space. + { + // break; + } } - return TRUE; } -// ----------------- -// Initialize -// ----------------- -// Where you want to do COLD-START initialization. -// Called when the extension is loaded into memory. -// -extern "C" int WINAPI DLLExport Initialize(mv _far *mV, int quiet) +/* InitExtension + * Fusion calls this before anything else when it loads your + * extension. This includes during the splash screen, in which + * case "Quiet" is true. This is where you should initialize + * global information for either edittime or runtime. Be aware, + * though, that at edittime, multiple open MFAs with your + * extension will share the same global information. You can + * use mV->mvEditApp to tell apart different MFAs from each + * other. If an error occurs during this function, return + * -1 and Fusion will not load your extension. + */ +int MMF2Func InitExtension(mv *mV, int Quiet) { - return Edif::Init(mV); - - - // No error - return 0; + return Edif::Init(mV); } -// ----------------- -// Free -// ----------------- -// Where you want to kill and initialized data opened in the above routine -// Called just before freeing the DLL. -// -extern "C" int WINAPI DLLExport Free(mv _far *mV) +/* FreeExtension + * Called just before Fusion unloads your extension. You + * should release any memory you allocated above in + * the InitializeExtension function. You should always + * return a value of 0. + */ +int MMF2Func FreeExtension(mv *mV) { - Edif::Free(mV); - - // No error + // + Edif::Free(mV); return 0; } -// ============================================================================ -// -// GENERAL INFO -// -// ============================================================================ - -// ----------------- -// LoadObject -// ----------------- -// Routine called for each object when the object is read from the MFA file (edit time) -// or from the CCN or EXE file (run time). -// You can load data here, reserve memory etc... -// -int WINAPI DLLExport LoadObject(mv _far *mV, LPCSTR fileName, LPEDATA edPtr, int reserved) +/* LoadObject + * This is called at both edittime and runtime when Fusion + * loads each unique instance of your object. (Each one + * with a different name, not each instance of the same + * one). Not much needs to be done here. + */ +int MMF2Func LoadObject(mv *mV, LPCSTR FileName, SerializedED *SED, int) { - Edif::Init(mV, edPtr); - - + Edif::Init(mV, SED); return 0; } -// ----------------- -// UnloadObject -// ----------------- -// The counterpart of the above routine: called just before the object is -// deleted from the frame. -// -void WINAPI DLLExport UnloadObject(mv _far *mV, LPEDATA edPtr, int reserved) +/* UnloadObject + * new is to delete as LoadObject is to this functon. + * If you initialized stuff above, deinitialize it here. + */ +void MMF2Func UnloadObject(mv *mV, SerializedED *SED, int) { + // } -// -------------------- -// UpdateEditStructure -// -------------------- -// For you to update your object structure to newer versions -// Called at both edit time and run time -// -HGLOBAL WINAPI DLLExport UpdateEditStructure(mv __far *mV, void __far * OldEdPtr) +/* UpdateEditStructure (DEPRECATED) + * This is called when Fusion notices that your + * extension has a newer version number than + * the one in the header of the SerializedED. + * Thankfully, however, we don't need this + * function at all - the EditData class is + * as smart as you programmed it to be and + * it changes the size dynamically rather + * than statically. So, you can safely + * ignore this function all together. + * (It would be a pain to write anyway - + * see the MMF2SDK help for an example) + */ +HGLOBAL MMF2Func UpdateEditStructure(mv *mV, SerializedED *OldSED) { - // We do nothing here return 0; } -// -------------------- -// UpdateFileNames -// -------------------- -// If you store file names in your datazone, they have to be relocated when the -// application is moved to a different directory: this routine does it. -// Called at edit time and run time. -// -// Call lpfnUpdate to update your file pathname (refer to the documentation) -// -void WINAPI DLLExport UpdateFileNames(mv _far *mV, LPSTR appName, LPEDATA edPtr, void (WINAPI * lpfnUpdate)(LPSTR, LPSTR)) +/* UpdateFileNames + * When the application is moved to a new directory, + * Fusion asks your extension to ensure that its file + * paths are moving with it. Just call Update for + * each file path - you will need to create buffers + * of size MAX_PATH if you use C++ strings for + * the paths. + */ +void MMF2Func UpdateFileNames(mv *mV, LPSTR appName, SerializedED *SED, void (WINAPI *Update)(LPSTR, LPSTR)) { + // } -// --------------------- -// EnumElts -// --------------------- -// -// Uncomment this function if you need to store an image in the image bank. -// -// Note: do not forget to enable the function in the .def file -// if you remove the comments below. -// -/* -int WINAPI DLLExport EnumElts (mv __far *mV, LPEDATA edPtr, ENUMELTPROC enumProc, ENUMELTPROC undoProc, LPARAM lp1, LPARAM lp2) +/* EnumElts + * That whacky function that Fusion uses to enumerate all the + * animation frames associated with your object, because Fusion + * is nice enough to deal with them for you so you can't-er, + * don't have to. Refer to the MMF2SDK Help file for + * information on how not to misuse this function. + * You must also uncomment the entry in the Ext.def + * file if you uncomment this function. + */ +/*int MMF2Func EnumElts (mv *mV, SerializedED *SED, ENUMELTPROC enumProc, ENUMELTPROC undoProc, LPARAM lp1, LPARAM lp2) { int error = 0; - // Replace wImgIdx with the name of the WORD variable you create within the edit structure + //Replace wImgIdx with the name of the WORD variable you create within the edit structure - // Enum images - if ( (error = enumProc(&edPtr->wImgIdx, IMG_TAB, lp1, lp2)) != 0 ) + //Enum images + if((error = enumProc(&edPtr->wImgIdx, IMG_TAB, lp1, lp2)) != 0) { - // Undo enum images - undoProc (&edPtr->wImgIdx, IMG_TAB, lp1, lp2); + //Undo enum images + undoProc(&edPtr->wImgIdx, IMG_TAB, lp1, lp2); } return error; -} -*/ - +}*/ diff --git a/Extensions/Template/Properties.cpp b/Extensions/Template/Properties.cpp new file mode 100644 index 0000000..66efe2e --- /dev/null +++ b/Extensions/Template/Properties.cpp @@ -0,0 +1,293 @@ +/* Properties.cpp + * In this file you will define the edittime + * properties for your extension. By default + * only a version number is displayed. + * Functions defined here: + * GetProperties + * ReleaseProperties + * GetPropCreateParam + * ReleasePropCreateParam + * GetPropValue + * SetPropValue + * GetPropCheck + * SetPropCheck + * EditProp + * IsPropEnabled + */ + +#include "Common.h" + +#ifndef RUN_ONLY + +/* Prop + * This is the namespace the property identifiers + * are stored in. It keeps them out of the global + * namespace and it helps with intellisense. + */ +namespace Prop +{ + /* + * The property identitifers. + */ + enum + { + zNOT_USED = PROPID_EXTITEM_CUSTOM_FIRST, + Version, + //MyString, + //MyInt, + }; +} + +PropData Properties[] = //See the MMF2SDK help file for information on PropData_ macros. +{ + PropData_StaticString(Prop::Version, (UINT_PTR)_T("Version #"), (UINT_PTR)_T("This is the current version of the EDIF Template object.")), + //PropData_EditMultiLine(Prop::MyString, (UINT_PTR)_T("My String"), (UINT_PTR)_T("The contents of my string.")), + //PropData_EditNumber(Prop::MyInt, (UINT_PTR)_T("My Integer"), (UINT_PTR)_T("The value of my integer.")), + PropData_End() +}; + +#endif + +/* GetProperties + * Here, you choose what proeprties to insert + * into which tabs. Lots of dynamic things can + * be done in here, such as dynamically + * generating the properties based on the + * number of stored values in the editdata. + */ +BOOL MMF2Func GetProperties(mv *mV, SerializedED *SED, BOOL MasterItem) +{ +#ifndef RUN_ONLY + //EditData ed (SED); + //ed.stuff; + mvInsertProps(mV, SED, Properties, PROPID_TAB_GENERAL, TRUE); + //if you changed ed: + //ed.Serialize(mV, SED); + return TRUE; +#endif + return FALSE; +} + +/* ReleaseProperties + * If you dynamically allocated memory for + * property arrays in GetProperties, release + * that memory in this function. + */ +void MMF2Func ReleaseProperties(mv *mV, SerializedED *SED, BOOL MasterItem) +{ +#ifndef RUN_ONLY + //EditData ed (SED); + //ed.stuff; + // + //if you changed ed: + //ed.Serialize(mV, SED); +#endif +} + +/* GetPropCreateParam + * A convenience function if you use the + * hard-coded Properties array above. Allows + * you to dynamically create e.g. combo + * lists and other things that have + * additional parameters for their + * properties. However if you dynamically + * allocated everything in GetProperties, + * this function is useless. + */ +LPARAM MMF2Func GetPropCreateParam(mv *mV, SerializedED *SED, UINT PropID) +{ +#ifndef RUN_ONLY + //EditData ed (SED); + //ed.stuff; + //return (LPARAM)TheParameter; + //if you changed ed: + //ed.Serialize(mV, SED); +#endif + return 0; +} + +/* ReleasePropCreateParam + * If you found a useful way to use the + * above function and you dynamically + * allocated memory, release it here. + */ +void MMF2Func ReleasePropCreateParam(mv *mV, SerializedED *SED, UINT PropID, LPARAM lParam) +{ +#ifndef RUN_ONLY + //EditData ed (SED); + //ed.stuff; + //MyAwesomeMemoryFreeingFunction(lParam); + //if you changed ed: + //ed.Serialize(mV, SED); +#endif +} + +/* GetPropValue + * This is where you return the display + * values for the properties you defined. + * Refer to the MMF2SDK Help file for + * information on what to return for + * each kind of property. + */ +void *MMF2Func GetPropValue(mv *mV, SerializedED *SED, UINT PropID) +{ +#ifndef RUN_ONLY + //EditData ed (SED); + switch(PropID) + { + case Prop::Version: + { + return new CPropStringValue(_T("Default.EDIF.Template.0")); + } + //case Prop::MyString: + // { + // return new CPropStringValue(ed.MyString.c_str()); + // } + //case Prop::MyInt: + // { + // return new CPropDWordValue(ed.MyInt); + // } + } + //if you changed ed: + //ed.Serialize(mV, SED); +#endif + return NULL; +} + +/* SetPropValue + * The user has just finished entering their + * 500 page essay into your MyString field. + * Fusion isn't so kind as to save that for them, + * so it entrusts it with you. Store it! + */ +void MMF2Func SetPropValue(mv *mV, SerializedED *SED, UINT PropID, CPropValue *PropVal) +{ +#ifndef RUN_ONLY + //EditData ed (SED); + //switch(PropID) + //{ + //case Prop::MyString: + // { + // ed.MyString = ((CPropStringValue*)PropVal)->GetString(); + // break; + // } + //case Prop::MyInt: + // { + // ed.MyInt = (CPropDWordValue*)PropVal)->m_dwValue; + // break; + // } + //} + //since you changed ed: + //ed.Serialize(mV, SED); + + //You may want to have your object redrawn in the + //frame editor after the modifications; in this + //case, just call this function: + //mvInvalidateObject(mV, SED); +#endif +} + +/* GetPropCheck + * There are checkbox properties, and + * there are properties that have their + * own checkbox as an option. This is + * where you tell Fusion whether those + * boxes are ticked or not. + */ +BOOL MMF2Func GetPropCheck(mv *mV, SerializedED *SED, UINT PropID) +{ +#ifndef RUN_ONLY + //EditData ed (SED); + //switch(PropID) + //{ + //case Prop::MyCheckBoxPropertyOrPropertyThatHasTheCheckboxOptionSet: + // { + // return ed.WhetherOrNotThatPropertyOfMineIsTicked ? TRUE : FALSE; + // } + //} + //if you changed ed: + //ed.Serialize(mV, SED); +#endif + return FALSE; +} + +/* SetPropCheck + * The user has painstakingly moved the + * mouse cursor over the checkbox and + * expended the immense effort required + * to click the mouse and toggle the + * state of the tickbox. Don't let their + * effort be all for naught! + */ +void MMF2Func SetPropCheck(mv *mV, SerializedED *SED, UINT PropID, BOOL Ticked) +{ +#ifndef RUN_ONLY + //EditData ed (SED); + //switch(PropID) + //{ + //case Prop::MyCheckBoxPropertyOrPropertyThatHasTheCheckboxOptionSet: + // { + // ed.WhetherOrNotThatPropertyOfMineIsTicked = (Ticked != FALSE ? true : false); + // break; + // } + //} + //since you changed ed: + //ed.Serialize(mV, SED); +#endif +} + +/* EditProp + * If you use a button proeprty or a + * property that has a button, then + * you would be impolite to ignore + * the user when they click on that + * button. Here is where you respond + * to that button press e.g. with + * a dialog. + */ +BOOL MMF2Func EditProp(mv *mV, SerializedED *SED, UINT PropID) +{ +#ifndef RUN_ONLY + //EditData ed (SED); + //switch(PropID) + //{ + //case Prop::MyButtonPropertyOrPropertyThatHasAButtonWithIt: + // { + // // + // break; + // } + //} + //if you changed ed: + //ed.Serialize(mV, SED); +#endif + return FALSE; +} + +/* IsPropEnabled + * Let's say you're tired of having to deal + * with the user's various 500 page essays, + * tickbox toggles, and button clicks. Here, + * you can simply disable a property by + * returning FALSE for that property. + */ +BOOL MMF2Func IsPropEnabled(mv *mV, SerializedED *SED, UINT PropID) +{ +#ifndef RUN_ONLY + //EditData ed (SED); + switch(PropID) + { + case Prop::Version: + { + return FALSE; //Makes the version property greyed out + } + //case Prop::MyString: //intentional\\ + //case Prop::MyInt: //fallthrough\\ + // { + // return TRUE; //allows the user to interact with these proeprties + // } + } + //if you changed ed: + //ed.Serialize(mV, SED); +#endif + return FALSE; +} diff --git a/Extensions/Template/Resource.h b/Extensions/Template/Resource.h new file mode 100644 index 0000000..ca96268 --- /dev/null +++ b/Extensions/Template/Resource.h @@ -0,0 +1,18 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by Ext.rc +// +#define IDR_EDIF_ICON 101 +#define IDR_EDIF_JSON 102 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NO_MFC 1 +#define _APS_NEXT_RESOURCE_VALUE 103 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/Extensions/Template/Runtime.cpp b/Extensions/Template/Runtime.cpp index 44a0d48..b919a34 100644 --- a/Extensions/Template/Runtime.cpp +++ b/Extensions/Template/Runtime.cpp @@ -1,68 +1,48 @@ +/* Runtime.cpp + * This file contains general runtime functions + * that aren't part of the Extension class. + * Functions defined here: + * GetRunObjectSurface + * GetRunObjectCollisionMask + * StartApp + * EndApp + * StartFrame + * EndFrame + * WindowProc + */ #include "Common.h" -// DEBUGGER ///////////////////////////////////////////////////////////////// - -#if !defined(RUN_ONLY) -// Identifiers of items displayed in the debugger -enum -{ -// Example -// ------- -// DB_CURRENTSTRING, -// DB_CURRENTVALUE, -// DB_CURRENTCHECK, -// DB_CURRENTCOMBO -}; - -// Items displayed in the debugger -WORD DebugTree[]= -{ -// Example -// ------- -// DB_CURRENTSTRING|DB_EDITABLE, -// DB_CURRENTVALUE|DB_EDITABLE, -// DB_CURRENTCHECK, -// DB_CURRENTCOMBO, - - // End of table (required) - DB_END -}; - -#endif // !defined(RUN_ONLY) - - - -// ------------------- -// GetRunObjectSurface -// ------------------- -// Implement this function instead of DisplayRunObject if your extension -// supports ink effects and transitions. Note: you can support ink effects -// in DisplayRunObject too, but this is automatically done if you implement -// GetRunObjectSurface (MMF applies the ink effect to the surface). -// -// Note: do not forget to enable the function in the .def file -// if you remove the comments below. -/* -cSurface* WINAPI DLLExport GetRunObjectSurface(LPRDATA rdPtr) +/* GetRunObjectSurface + * Implement this function instead of + * Extension::Display if your extension + * supports ink effects and transitions. + * You can support ink effects in + * DisplayRunObject too, but this is + * done automatically if you implement + * GetRunObjectSurface (Fusion applies the + * ink effects to the surface). Don't + * forget to enable the function in the + * .def file if you uncomment & implement + * this function. + */ +/*cSurface* MMF2Func GetRunObjectSurface(RD *rd) { return NULL; -} -*/ - -// ------------------------- -// GetRunObjectCollisionMask -// ------------------------- -// Implement this function if your extension supports fine collision mode (OEPREFS_FINECOLLISIONS), -// Or if it's a background object and you want Obstacle properties for this object. -// -// Should return NULL if the object is not transparent. -// -// Note: do not forget to enable the function in the .def file -// if you remove the comments below. -// -/* -LPSMASK WINAPI DLLExport GetRunObjectCollisionMask(LPRDATA rdPtr, LPARAM lParam) +}*/ + +/* GetRunObjectCollisionMask + * Implement this function if your extension + * supports fine collision detection + * (OEPREFS_FINECOLLISIONS), rr if it's a + * background object and you want Obstacle + * properties for this object. You should + * return NULL if the object is not transparent. + * Don't forget to enable the function in the + * .def file if you uncomment & implement this + * function. + */ +/*LPSMASK MMF2Func GetRunObjectCollisionMask(RD *rd, LPARAM lParam) { // Typical example for active objects // ---------------------------------- @@ -89,146 +69,76 @@ LPSMASK WINAPI DLLExport GetRunObjectCollisionMask(LPRDATA rdPtr, LPARAM lParam) } } - // Note: for active objects, lParam is always the same. - // For background objects (OEFLAG_BACKGROUND), lParam maybe be different if the user uses your object - // as obstacle and as platform. In this case, you should store 2 collision masks - // in your data: one if lParam is 0 and another one if lParam is different from 0. + //Note: for active objects, lParam is always the same. + //For background objects (OEFLAG_BACKGROUND), lParam maybe be different if the user uses your object + //as obstacle and as platform. In this case, you should store 2 collision masks + //in your data: one if lParam is 0 and another one if lParam is different from 0. return pMask; +}*/ + +/* StartApp + * Called when the application initially + * starts or when it restarts (EndApp will + * NOT be called beforehand in the case + * of a restart). This is useful if you + * need to store global data across + * frames. + */ +void MMF2Func StartApp(mv *mV, CRunApp *App) +{ +// delete (MyGlobalData *)Edif::Runtime::ReadGlobal(mV, App, "My Global Data"); +// Edif::Runtime::WriteGlobal(mV, App, "My Global Data", new MyGlobalData()); } -*/ - - -// ============================================================================ -// -// START APP / END APP / START FRAME / END FRAME routines -// -// ============================================================================ -// ------------------- -// StartApp -// ------------------- -// Called when the application starts or restarts. -// Useful for storing global data -// -void WINAPI DLLExport StartApp(mv _far *mV, CRunApp* pApp) -{ - // Example - // ------- - // Delete global data (if restarts application) -// CMyData* pData = (CMyData*)mV->mvGetExtUserData(pApp, hInstLib); -// if ( pData != NULL ) -// { -// delete pData; -// mV->mvSetExtUserData(pApp, hInstLib, NULL); -// } +/* EndApp + * Called when the application is ending + * and about to close. This is NOT called + * in the event of a Restart Application + * action. You can release any memory you + * aqquired above in StartApp. + */ +void MMF2Func EndApp(mv *mV, CRunApp *App) +{ +// delete (MyGlobalData *)Edif::Runtime::ReadGlobal(mV, App, "My Global Data"); +// Edif::Runtime:WriteGlobal(mV, App, "My Global Data", 0); //clear dangling pointer } -// ------------------- -// EndApp -// ------------------- -// Called when the application ends. -// -void WINAPI DLLExport EndApp(mv _far *mV, CRunApp* pApp) -{ - // Example - // ------- - // Delete global data -// CMyData* pData = (CMyData*)mV->mvGetExtUserData(pApp, hInstLib); -// if ( pData != NULL ) +/* StartFrame + * Called at the start of a frame. If you + * store global data above, you should make + * a copy of it so that it may be restored + * when the frame restarts. This function is + * also called when the frame restarts. + * EndFrame is NOT called when the frame + * restarts. + */ +void MMF2Func StartFrame(mv *mV, CRunApp *App, int FrameIndex) +{ +// if(!Edif::Runtime::ReadGlobal(mV, App, "My Global Data Backup")) //first time on this frame // { -// delete pData; -// mV->mvSetExtUserData(pApp, hInstLib, NULL); +// Edif::Runtime::WriteGlobal(mV, App, "My Global Data Backup", +// new MyGlobalData(*(MyGlobalData *)Edif::Runtime::ReadGlobal(mV, App, "My Global Data"))); //copy // } -} - -// ------------------- -// StartFrame -// ------------------- -// Called when the frame starts or restarts. -// -void WINAPI DLLExport StartFrame(mv _far *mV, DWORD dwReserved, int nFrameIndex) -{ -} - -// ------------------- -// EndFrame -// ------------------- -// Called when the frame ends. -// -void WINAPI DLLExport EndFrame(mv _far *mV, DWORD dwReserved, int nFrameIndex) -{ -} - -// ============================================================================ -// -// TEXT ROUTINES (if OEFLAG_TEXT) -// -// ============================================================================ - -// ------------------- -// GetRunObjectFont -// ------------------- -// Return the font used by the object. -// -/* - - // Note: do not forget to enable the functions in the .def file - // if you remove the comments below. - -void WINAPI GetRunObjectFont(LPRDATA rdPtr, LOGFONT* pLf) -{ - // Example - // ------- - // GetObject(rdPtr->m_hFont, sizeof(LOGFONT), pLf); -} - -// ------------------- -// SetRunObjectFont -// ------------------- -// Change the font used by the object. -// -void WINAPI SetRunObjectFont(LPRDATA rdPtr, LOGFONT* pLf, RECT* pRc) -{ - // Example - // ------- -// HFONT hFont = CreateFontIndirect(pLf); -// if ( hFont != NULL ) +// else //frame restarting, restore initial global data // { -// if (rdPtr->m_hFont!=0) -// DeleteObject(rdPtr->m_hFont); -// rdPtr->m_hFont = hFont; -// SendMessage(rdPtr->m_hWnd, WM_SETFONT, (WPARAM)rdPtr->m_hFont, FALSE); +// delete (MyGlobalData *)Edif::Runtime::ReadGlobal(mV, App, "My Global Data"); +// Edif::Runtime::WriteGlobal(mV, App, "My Global Data", +// new MyGlobalData(*(MyGlobalData *)Edif::Runtime::ReadGlobal(mV, App, "My Global Data Backup"))); //copy // } - } -// --------------------- -// GetRunObjectTextColor -// --------------------- -// Return the text color of the object. -// -COLORREF WINAPI GetRunObjectTextColor(LPRDATA rdPtr) +/* EndFrame + * Called when the frame ends. Fusion + * does NOT call this function in the + * event of a "Restart Frame" action. + */ +void MMF2Func EndFrame(mv *mV, CRunApp *App, int FrameIndex) { - // Example - // ------- - return 0; // rdPtr->m_dwColor; +// delete (MyGlobalData *)Edif::Runtime::ReadGlobal(mV, App, "My Global Data Backup"); +// Edif::Runtime:WriteGlobal(mV, App, "My Global Data Backup", 0); //clear dangling pointer } -// --------------------- -// SetRunObjectTextColor -// --------------------- -// Change the text color of the object. -// -void WINAPI SetRunObjectTextColor(LPRDATA rdPtr, COLORREF rgb) -{ - // Example - // ------- - rdPtr->m_dwColor = rgb; - InvalidateRect(rdPtr->m_hWnd, NULL, TRUE); -} -*/ - // ============================================================================ // @@ -283,112 +193,3 @@ LRESULT CALLBACK DLLExport WindowProc(LPRH rhPtr, HWND hWnd, UINT nMsg, WPARAM w return 0; } */ - -// ============================================================================ -// -// DEBUGGER ROUTINES -// -// ============================================================================ - -// ----------------- -// GetDebugTree -// ----------------- -// This routine returns the address of the debugger tree -// -LPWORD WINAPI DLLExport GetDebugTree(LPRDATA rdPtr) -{ -#if !defined(RUN_ONLY) - return DebugTree; -#else - return NULL; -#endif // !defined(RUN_ONLY) -} - -// ----------------- -// GetDebugItem -// ----------------- -// This routine returns the text of a given item. -// -void WINAPI DLLExport GetDebugItem(LPSTR pBuffer, LPRDATA rdPtr, int id) -{ -#if !defined(RUN_ONLY) - - // Example - // ------- -/* - char temp[DB_BUFFERSIZE]; - - switch (id) - { - case DB_CURRENTSTRING: - LoadString(hInstLib, IDS_CURRENTSTRING, temp, DB_BUFFERSIZE); - wsprintf(pBuffer, temp, rdPtr->text); - break; - case DB_CURRENTVALUE: - LoadString(hInstLib, IDS_CURRENTVALUE, temp, DB_BUFFERSIZE); - wsprintf(pBuffer, temp, rdPtr->value); - break; - case DB_CURRENTCHECK: - LoadString(hInstLib, IDS_CURRENTCHECK, temp, DB_BUFFERSIZE); - if (rdPtr->check) - wsprintf(pBuffer, temp, "TRUE"); - else - wsprintf(pBuffer, temp, "FALSE"); - break; - case DB_CURRENTCOMBO: - LoadString(hInstLib, IDS_CURRENTCOMBO, temp, DB_BUFFERSIZE); - wsprintf(pBuffer, temp, rdPtr->combo); - break; - } -*/ - -#endif // !defined(RUN_ONLY) -} - -// ----------------- -// EditDebugItem -// ----------------- -// This routine allows to edit editable items. -// -void WINAPI DLLExport EditDebugItem(LPRDATA rdPtr, int id) -{ -#if !defined(RUN_ONLY) - - // Example - // ------- -/* - switch (id) - { - case DB_CURRENTSTRING: - { - EditDebugInfo dbi; - char buffer[256]; - - dbi.pText=buffer; - dbi.lText=TEXT_MAX; - dbi.pTitle=NULL; - - strcpy(buffer, rdPtr->text); - long ret=callRunTimeFunction(rdPtr, RFUNCTION_EDITTEXT, 0, (LPARAM)&dbi); - if (ret) - strcpy(rdPtr->text, dbi.pText); - } - break; - case DB_CURRENTVALUE: - { - EditDebugInfo dbi; - - dbi.value=rdPtr->value; - dbi.pTitle=NULL; - - long ret=callRunTimeFunction(rdPtr, RFUNCTION_EDITINT, 0, (LPARAM)&dbi); - if (ret) - rdPtr->value=dbi.value; - } - break; - } -*/ -#endif // !defined(RUN_ONLY) -} - - diff --git a/Extensions/Template/Template.sln b/Extensions/Template/Template.sln deleted file mode 100644 index 9c29735..0000000 --- a/Extensions/Template/Template.sln +++ /dev/null @@ -1,41 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual C++ Express 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Template", "Template.vcproj", "{3BCB4C73-71F6-43B6-803D-41411F92652A}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug HWA|Win32 = Debug HWA|Win32 - Debug Unicode|Win32 = Debug Unicode|Win32 - Debug|Win32 = Debug|Win32 - Edittime HWA|Win32 = Edittime HWA|Win32 - Edittime Unicode|Win32 = Edittime Unicode|Win32 - Edittime|Win32 = Edittime|Win32 - Runtime HWA|Win32 = Runtime HWA|Win32 - Runtime Unicode|Win32 = Runtime Unicode|Win32 - Runtime|Win32 = Runtime|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {3BCB4C73-71F6-43B6-803D-41411F92652A}.Debug HWA|Win32.ActiveCfg = Debug HWA|Win32 - {3BCB4C73-71F6-43B6-803D-41411F92652A}.Debug HWA|Win32.Build.0 = Debug HWA|Win32 - {3BCB4C73-71F6-43B6-803D-41411F92652A}.Debug Unicode|Win32.ActiveCfg = Debug Unicode|Win32 - {3BCB4C73-71F6-43B6-803D-41411F92652A}.Debug Unicode|Win32.Build.0 = Debug Unicode|Win32 - {3BCB4C73-71F6-43B6-803D-41411F92652A}.Debug|Win32.ActiveCfg = Debug|Win32 - {3BCB4C73-71F6-43B6-803D-41411F92652A}.Debug|Win32.Build.0 = Debug|Win32 - {3BCB4C73-71F6-43B6-803D-41411F92652A}.Edittime HWA|Win32.ActiveCfg = Edittime HWA|Win32 - {3BCB4C73-71F6-43B6-803D-41411F92652A}.Edittime HWA|Win32.Build.0 = Edittime HWA|Win32 - {3BCB4C73-71F6-43B6-803D-41411F92652A}.Edittime Unicode|Win32.ActiveCfg = Edittime Unicode|Win32 - {3BCB4C73-71F6-43B6-803D-41411F92652A}.Edittime Unicode|Win32.Build.0 = Edittime Unicode|Win32 - {3BCB4C73-71F6-43B6-803D-41411F92652A}.Edittime|Win32.ActiveCfg = Edittime|Win32 - {3BCB4C73-71F6-43B6-803D-41411F92652A}.Edittime|Win32.Build.0 = Edittime|Win32 - {3BCB4C73-71F6-43B6-803D-41411F92652A}.Runtime HWA|Win32.ActiveCfg = Runtime HWA|Win32 - {3BCB4C73-71F6-43B6-803D-41411F92652A}.Runtime HWA|Win32.Build.0 = Runtime HWA|Win32 - {3BCB4C73-71F6-43B6-803D-41411F92652A}.Runtime Unicode|Win32.ActiveCfg = Runtime Unicode|Win32 - {3BCB4C73-71F6-43B6-803D-41411F92652A}.Runtime Unicode|Win32.Build.0 = Runtime Unicode|Win32 - {3BCB4C73-71F6-43B6-803D-41411F92652A}.Runtime|Win32.ActiveCfg = Runtime|Win32 - {3BCB4C73-71F6-43B6-803D-41411F92652A}.Runtime|Win32.Build.0 = Runtime|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/Extensions/Template/Template.vcproj b/Extensions/Template/Template.vcproj deleted file mode 100644 index 5100407..0000000 --- a/Extensions/Template/Template.vcproj +++ /dev/null @@ -1,1560 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Extensions/Template/Template2015.sln b/Extensions/Template/Template2015.sln new file mode 100644 index 0000000..210e26a --- /dev/null +++ b/Extensions/Template/Template2015.sln @@ -0,0 +1,43 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25123.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Template", "Template2015.vcxproj", "{87325274-EF61-43D2-85A3-FF7CE13EDD69}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Fusion 2.0 ANSI = Debug|Fusion 2.0 ANSI + Debug|Fusion-2.0 ANSI+HWA = Debug|Fusion-2.0 ANSI+HWA + Debug|Fusion-2.x Unicode+HWA = Debug|Fusion-2.x Unicode+HWA + Edittime|Fusion 2.0 ANSI = Edittime|Fusion 2.0 ANSI + Edittime|Fusion-2.0 ANSI+HWA = Edittime|Fusion-2.0 ANSI+HWA + Edittime|Fusion-2.x Unicode+HWA = Edittime|Fusion-2.x Unicode+HWA + Runtime|Fusion 2.0 ANSI = Runtime|Fusion 2.0 ANSI + Runtime|Fusion-2.0 ANSI+HWA = Runtime|Fusion-2.0 ANSI+HWA + Runtime|Fusion-2.x Unicode+HWA = Runtime|Fusion-2.x Unicode+HWA + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {87325274-EF61-43D2-85A3-FF7CE13EDD69}.Debug|Fusion 2.0 ANSI.ActiveCfg = Debug ANSI|Win32 + {87325274-EF61-43D2-85A3-FF7CE13EDD69}.Debug|Fusion 2.0 ANSI.Build.0 = Debug ANSI|Win32 + {87325274-EF61-43D2-85A3-FF7CE13EDD69}.Debug|Fusion-2.0 ANSI+HWA.ActiveCfg = Debug ANSI+HWA|Win32 + {87325274-EF61-43D2-85A3-FF7CE13EDD69}.Debug|Fusion-2.0 ANSI+HWA.Build.0 = Debug ANSI+HWA|Win32 + {87325274-EF61-43D2-85A3-FF7CE13EDD69}.Debug|Fusion-2.x Unicode+HWA.ActiveCfg = Debug Unicode+HWA|Win32 + {87325274-EF61-43D2-85A3-FF7CE13EDD69}.Debug|Fusion-2.x Unicode+HWA.Build.0 = Debug Unicode+HWA|Win32 + {87325274-EF61-43D2-85A3-FF7CE13EDD69}.Edittime|Fusion 2.0 ANSI.ActiveCfg = Edittime ANSI|Win32 + {87325274-EF61-43D2-85A3-FF7CE13EDD69}.Edittime|Fusion 2.0 ANSI.Build.0 = Edittime ANSI|Win32 + {87325274-EF61-43D2-85A3-FF7CE13EDD69}.Edittime|Fusion-2.0 ANSI+HWA.ActiveCfg = Edittime ANSI+HWA|Win32 + {87325274-EF61-43D2-85A3-FF7CE13EDD69}.Edittime|Fusion-2.0 ANSI+HWA.Build.0 = Edittime ANSI+HWA|Win32 + {87325274-EF61-43D2-85A3-FF7CE13EDD69}.Edittime|Fusion-2.x Unicode+HWA.ActiveCfg = Edittime Unicode+HWA|Win32 + {87325274-EF61-43D2-85A3-FF7CE13EDD69}.Edittime|Fusion-2.x Unicode+HWA.Build.0 = Edittime Unicode+HWA|Win32 + {87325274-EF61-43D2-85A3-FF7CE13EDD69}.Runtime|Fusion 2.0 ANSI.ActiveCfg = Runtime ANSI|Win32 + {87325274-EF61-43D2-85A3-FF7CE13EDD69}.Runtime|Fusion 2.0 ANSI.Build.0 = Runtime ANSI|Win32 + {87325274-EF61-43D2-85A3-FF7CE13EDD69}.Runtime|Fusion-2.0 ANSI+HWA.ActiveCfg = Runtime ANSI+HWA|Win32 + {87325274-EF61-43D2-85A3-FF7CE13EDD69}.Runtime|Fusion-2.0 ANSI+HWA.Build.0 = Runtime ANSI+HWA|Win32 + {87325274-EF61-43D2-85A3-FF7CE13EDD69}.Runtime|Fusion-2.x Unicode+HWA.ActiveCfg = Runtime Unicode+HWA|Win32 + {87325274-EF61-43D2-85A3-FF7CE13EDD69}.Runtime|Fusion-2.x Unicode+HWA.Build.0 = Runtime Unicode+HWA|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Extensions/Template/Template2015.vcxproj b/Extensions/Template/Template2015.vcxproj new file mode 100644 index 0000000..28cf5cb --- /dev/null +++ b/Extensions/Template/Template2015.vcxproj @@ -0,0 +1,694 @@ + + + + + Debug ANSI+HWA + Win32 + + + Debug ANSI + Win32 + + + Debug Unicode+HWA + Win32 + + + Edittime ANSI+HWA + Win32 + + + Edittime ANSI + Win32 + + + Edittime Unicode+HWA + Win32 + + + Runtime ANSI+HWA + Win32 + + + Runtime ANSI + Win32 + + + Runtime Unicode+HWA + Win32 + + + + {87325274-EF61-43D2-85A3-FF7CE13EDD69} + Template2015 + Template + 8.1 + + + + DynamicLibrary + true + v140 + Unicode + + + DynamicLibrary + true + v140 + MultiByte + + + DynamicLibrary + true + v140 + MultiByte + + + DynamicLibrary + false + v140_xp + FastLTCG + Unicode + + + DynamicLibrary + false + v140_xp + FastLTCG + MultiByte + + + DynamicLibrary + false + v140_xp + FastLTCG + MultiByte + + + DynamicLibrary + false + v140_xp + FastLTCG + Unicode + + + DynamicLibrary + false + v140_xp + FastLTCG + MultiByte + + + DynamicLibrary + false + v140_xp + FastLTCG + MultiByte + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + .mfx + false + C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\Rule Sets\NativeRecommendedRules.ruleset + true + $(ProjectDir)\MFX\Extensions\Unicode\ + false + + + .mfx + false + C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\Rule Sets\NativeRecommendedRules.ruleset + true + $(ProjectDir)\MFX\Extensions\Hwa\ + false + + + .mfx + false + C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\Rule Sets\NativeRecommendedRules.ruleset + true + $(ProjectDir)\MFX\Extensions\ + false + + + .mfx + false + $(ProjectDir)\MFX\Extensions\Unicode\ + false + + + .mfx + false + $(ProjectDir)\MFX\Extensions\Hwa\ + false + + + .mfx + false + $(ProjectDir)\MFX\Extensions\ + false + + + .mfx + false + $(ProjectDir)MFX\Data\Runtime\Unicode\ + false + + + .mfx + false + $(ProjectDir)MFX\Data\Runtime\Hwa\ + false + + + .mfx + false + $(ProjectDir)MFX\Data\Runtime\ + false + + + + Level3 + Disabled + true + ..\..\Inc;.\; + DEBUG;EDITOR;HWABETA;COXSDK;IN_EXT_VERSION2;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_WINDOWS;%(PreprocessorDefinitions) + min;max;%(UndefinePreprocessorDefinitions) + true + Guard + true + true + CompileAsCpp + MultiThreadedDebug + true + ProgramDatabase + + + true + $(ProjectDir)\MFX\Extensions\Unicode\$(ProjectName)$(TargetExt) + ..\..\lib\mmfs2.5.lib;%(AdditionalDependencies) + false + ./Ext.def + $(IntDir)$(TargetName).pdb + $(IntDir)$(TargetName).lib + false + $(IntDir)$(TargetName).pgd + Default + Windows + + + ..\AutoInstall.bat "$(TargetPath)" \Extensions\Unicode 2> nul + Automatically installs the extension to Fusion once it is built. + + + EDITOR;%(PreprocessorDefinitions) + + + $(IntDir)$(TargetName).xml + + + $(IntDir)$(TargetName).bsc + + + + + Level3 + Disabled + true + ..\..\Inc;.\; + DEBUG;EDITOR;HWABETA;COXSDK;IN_EXT_VERSION2;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_WINDOWS;%(PreprocessorDefinitions) + min;max;%(UndefinePreprocessorDefinitions) + true + Guard + true + true + CompileAsCpp + MultiThreadedDebug + true + ProgramDatabase + + + true + $(ProjectDir)\MFX\Extensions\Hwa\$(ProjectName)$(TargetExt) + ..\..\lib\mmfs2.0hwa.lib;%(AdditionalDependencies) + false + ./Ext.def + $(IntDir)$(TargetName).pdb + $(IntDir)$(TargetName).lib + false + $(IntDir)$(TargetName).pgd + Default + Windows + + + ..\AutoInstall.bat "$(TargetPath)" \Extensions\Hwa 2> nul + Automatically installs the extension to Fusion once it is built. + + + EDITOR;%(PreprocessorDefinitions) + + + $(IntDir)$(TargetName).xml + + + $(IntDir)$(TargetName).bsc + + + + + Level3 + Disabled + true + ..\..\Inc;.\; + DEBUG;EDITOR;COXSDK;IN_EXT_VERSION2;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_WINDOWS;%(PreprocessorDefinitions) + min;max;%(UndefinePreprocessorDefinitions) + true + Guard + true + true + CompileAsCpp + MultiThreadedDebug + true + ProgramDatabase + + + true + $(ProjectDir)\MFX\Extensions\$(ProjectName)$(TargetExt) + ..\..\lib\mmfs2.0.lib;%(AdditionalDependencies) + false + ./Ext.def + $(IntDir)$(TargetName).pdb + $(IntDir)$(TargetName).lib + false + $(IntDir)$(TargetName).pgd + Default + Windows + + + ..\AutoInstall.bat "$(TargetPath)" \Extensions 2> nul + Automatically installs the extension to Fusion once it is built. + + + EDITOR;%(PreprocessorDefinitions) + + + $(IntDir)$(TargetName).xml + + + $(IntDir)$(TargetName).bsc + + + + + Level3 + MaxSpeed + true + true + true + ..\..\Inc;.\; + EDITOR;HWABETA;COXSDK;IN_EXT_VERSION2;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_WINDOWS;%(PreprocessorDefinitions) + min;max;%(UndefinePreprocessorDefinitions) + true + Guard + true + true + CompileAsCpp + None + MultiThreaded + /Zc:threadSafeInit- + + + No + true + true + $(ProjectDir)\MFX\Extensions\Unicode\$(ProjectName)$(TargetExt) + ..\..\lib\mmfs2.5.lib;%(AdditionalDependencies) + false + ./Ext.def + $(IntDir)$(TargetName).pdb + $(IntDir)$(TargetName).lib + false + $(IntDir)$(TargetName).pgd + Default + Windows + + + ..\AutoInstall.bat "$(TargetPath)" \Extensions\Unicode 2> nul + Automatically installs the extension to Fusion once it is built. + + + EDITOR;%(PreprocessorDefinitions) + + + $(IntDir)$(TargetName).xml + + + $(IntDir)$(TargetName).bsc + + + + + Level3 + MaxSpeed + true + true + true + ..\..\Inc;.\; + EDITOR;HWABETA;COXSDK;IN_EXT_VERSION2;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_WINDOWS;%(PreprocessorDefinitions) + min;max;%(UndefinePreprocessorDefinitions) + true + Guard + true + true + CompileAsCpp + None + MultiThreaded + /Zc:threadSafeInit- + + + No + true + true + $(ProjectDir)\MFX\Extensions\Hwa\$(ProjectName)$(TargetExt) + ..\..\lib\mmfs2.0hwa.lib;%(AdditionalDependencies) + false + ./Ext.def + $(IntDir)$(TargetName).pdb + $(IntDir)$(TargetName).lib + false + $(IntDir)$(TargetName).pgd + Default + Windows + + + ..\AutoInstall.bat "$(TargetPath)" \Extensions\Hwa 2> nul + Automatically installs the extension to Fusion once it is built. + + + EDITOR;%(PreprocessorDefinitions) + + + $(IntDir)$(TargetName).xml + + + $(IntDir)$(TargetName).bsc + + + + + Level3 + MaxSpeed + true + true + true + ..\..\Inc;.\; + EDITOR;HWABETA;COXSDK;IN_EXT_VERSION2;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_WINDOWS;%(PreprocessorDefinitions) + min;max;%(UndefinePreprocessorDefinitions) + true + Guard + true + true + CompileAsCpp + None + MultiThreaded + /Zc:threadSafeInit- + + + No + true + true + $(ProjectDir)\MFX\Extensions\$(ProjectName)$(TargetExt) + ..\..\lib\mmfs2.0.lib;%(AdditionalDependencies) + false + ./Ext.def + $(IntDir)$(TargetName).pdb + $(IntDir)$(TargetName).lib + false + $(IntDir)$(TargetName).pgd + Default + Windows + + + ..\AutoInstall.bat "$(TargetPath)" \Extensions 2> nul + Automatically installs the extension to Fusion once it is built. + + + EDITOR;%(PreprocessorDefinitions) + + + $(IntDir)$(TargetName).xml + + + $(IntDir)$(TargetName).bsc + + + + + Level3 + MaxSpeed + true + true + true + ..\..\Inc;.\; + _NDEBUG;RUN_ONLY;HWABETA;COXSDK;IN_EXT_VERSION2;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_WINDOWS;%(PreprocessorDefinitions) + min;max;%(UndefinePreprocessorDefinitions) + true + Guard + true + true + CompileAsCpp + None + MultiThreaded + /Zc:threadSafeInit- + + + No + true + true + $(ProjectDir)MFX\Data\Runtime\Unicode\$(ProjectName)$(TargetExt) + ..\..\lib\mmfs2.5.lib;%(AdditionalDependencies) + false + ./Ext.def + $(IntDir)$(TargetName).pdb + $(IntDir)$(TargetName).lib + false + $(IntDir)$(TargetName).pgd + Default + Windows + + + ..\AutoInstall.bat "$(TargetPath)" \Data\Runtime\Unicode 2> nul + Automatically installs the extension to Fusion once it is built. + + + $(IntDir)$(TargetName).xml + + + $(IntDir)$(TargetName).bsc + + + + + Level3 + MaxSpeed + true + true + true + ..\..\Inc;.\; + _NDEBUG;RUN_ONLY;HWABETA;COXSDK;IN_EXT_VERSION2;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_WINDOWS;%(PreprocessorDefinitions) + min;max;%(UndefinePreprocessorDefinitions) + true + Guard + true + true + CompileAsCpp + None + MultiThreaded + /Zc:threadSafeInit- + + + No + true + true + $(ProjectDir)MFX\Data\Runtime\Hwa\$(ProjectName)$(TargetExt) + ..\..\lib\mmfs2.0hwa.lib;%(AdditionalDependencies) + false + ./Ext.def + $(IntDir)$(TargetName).pdb + $(IntDir)$(TargetName).lib + false + $(IntDir)$(TargetName).pgd + Default + Windows + + + ..\AutoInstall.bat "$(TargetPath)" \Data\Runtime\Hwa 2> nul + Automatically installs the extension to Fusion once it is built. + + + $(IntDir)$(TargetName).xml + + + $(IntDir)$(TargetName).bsc + + + + + Level3 + MaxSpeed + true + true + true + ..\..\Inc;.\; + _NDEBUG;RUN_ONLY;COXSDK;IN_EXT_VERSION2;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_WINDOWS;%(PreprocessorDefinitions) + min;max;%(UndefinePreprocessorDefinitions) + true + Guard + true + true + CompileAsCpp + None + MultiThreaded + /Zc:threadSafeInit- + + + No + true + true + $(ProjectDir)MFX\Data\Runtime\$(ProjectName)$(TargetExt) + ..\..\lib\mmfs2.0.lib;%(AdditionalDependencies) + false + ./Ext.def + $(IntDir)$(TargetName).pdb + $(IntDir)$(TargetName).lib + false + $(IntDir)$(TargetName).pgd + Default + Windows + + + ..\AutoInstall.bat "$(TargetPath)" \Data\Runtime 2> nul + Automatically installs the extension to Fusion once it is built. + + + $(IntDir)$(TargetName).xml + + + $(IntDir)$(TargetName).bsc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Extensions/Template/Template2015.vcxproj.filters b/Extensions/Template/Template2015.vcxproj.filters new file mode 100644 index 0000000..468f3ad --- /dev/null +++ b/Extensions/Template/Template2015.vcxproj.filters @@ -0,0 +1,251 @@ + + + + + {2f2987a7-e80a-4858-ada9-cc257cdada00} + + + {187fb9d6-9e49-489c-b9e8-a933212aff49} + + + {343d78a4-26f2-421a-aaf4-60d9cd560080} + + + {cd4e03ba-2d8b-4bd6-a680-fb7550b15e72} + + + {61e65ed1-83c8-4a25-8f07-fec01e952a99} + + + {11227bd0-77c9-4d0c-8fec-69a9456c064f} + + + {90bc3fe8-d446-4fdb-b429-be33a75f253c} + + + {5623edff-2f18-496b-acd6-3401edf475b7} + + + {e7feb950-1a6f-4ae0-bef7-6c7e2f50db95} + + + {a6e4a40f-2b93-4e5d-8d54-66a39bb084f3} + + + {aa6d4c30-b593-47da-80aa-802a1f1cef4d} + + + + + Global to All Extensions\Edif\json + + + Global to All Extensions\Edif\Riggs + + + Global to All Extensions\Edif + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions\Fusion SDK + + + Global to All Extensions + + + This Extension\Edittime + + + This Extension\General + + + This Extension\Resource Files + + + This Extension\The Extension Class + + + + + Global to All Extensions\Edif\json + + + Global to All Extensions\Edif\Riggs + + + Global to All Extensions\Edif + + + Global to All Extensions\Edif + + + Global to All Extensions\Edif + + + Global to All Extensions\Edif + + + This Extension\Edittime + + + This Extension\Edittime + + + This Extension\Edittime + + + This Extension\Edittime + + + This Extension\General + + + This Extension\Runtime + + + This Extension\Runtime + + + This Extension\Runtime + + + This Extension\The Extension Class + + + This Extension\The Extension Class + + + This Extension\The Extension Class + + + This Extension\The Extension Class + + + + + Global to All Extensions\Fusion SDK + + + + + This Extension\Resource Files + + + This Extension + + + + + This Extension\Resource Files + + + + + This Extension\Resource Files + + + \ No newline at end of file diff --git a/Extensions/Template/Text.cpp b/Extensions/Template/Text.cpp new file mode 100644 index 0000000..a224b17 --- /dev/null +++ b/Extensions/Template/Text.cpp @@ -0,0 +1,63 @@ +/* Text.cpp + * If you define the OEFLAG_TEXT flag, + * then this file is for you. Here you + * will deal with text at runtime similarly + * to how you dealt with it at edittime. + * By default all functions are commented + * out, if you implement them (and you + * should implement them in an all-or- + * nothing fashion), then you need to + * uncomment them in Ext.def as well. + * Functions defined here: + * GetRunObjectFont + * SetRunObjectFont + * GetRunObjectTextColor + * SetRunObjectTextColor + */ + +#include "Common.h" + +/* GetRunObjectFont + * Copy the current font into the Lf parameter. + */ +/*void MMF2Func GetRunObjectFont(RD *rd, LOGFONT *Lf) +{ + //GetObject(rd->pExtension->MyHFont, sizeof(LOGFONT), Lf); +}*/ + +/* SetRunObjectFont + * Store the font set by the user. Some + * action needs to be taken when rect is + * not null - read the MMF2SDK Help file + * for more information. + */ +/*void MMF2Func SetRunObjectFont(RD *rd, LOGFONT *Lf, RECT *rect) +{ +// Extension &ext = *(rd->pExtension); +// HFONT HFont = CreateFontIndirect(Lf); +// if(hFont != NULL) +// { +// if(ext.MyHFont != 0) DeleteObject(ext.MyHFont); +// ext.MyHFont = HFont; +// SendMessage(ext.MyHWindow, WM_SETFONT, WPARAM(ext.MyHFont), FALSE); +// } +}*/ + +/* GetRunObjectTextColor + * Plain and simple, return the color + * of the text. + */ +/*COLORREF MMF2Func GetRunObjectTextColor(RD *rd) +{ + return 0; +}*/ + +/* SetRunObjectTextColor + * Store the new color of the text + * and force and update on your window. + */ +/*void MMF2Func SetRunObjectTextColor(RD *rd, COLORREF color) +{ +// rd->pExtension->MyTextColor = color; +// InvalidateRect(rd->pExtension->MyHWindow, NULL, TRUE); +}*/ diff --git a/Extensions/Template/TextProps.cpp b/Extensions/Template/TextProps.cpp new file mode 100644 index 0000000..168f457 --- /dev/null +++ b/Extensions/Template/TextProps.cpp @@ -0,0 +1,116 @@ +/* TextProps.cpp + * If you plan on allowing Fusion to manage + * your extension's text display properties + * for you, this is the file to look into. + * Functions defined here: + * GetTextCaps + * GetTextFont + * SetTextFont + * GetTextClr + * SetTextClr + * GetTextAlignment + * SetTextAlignment + */ + +#include "Common.h" + +/* GetTextCaps + * Return the text capabilities + * of your extension at edittime. + */ +DWORD MMF2Func GetTextCaps(mv *mV, SerializedED *SED) +{ +#ifndef RUN_ONLY +// return TEXT_ALIGN_LEFT|TEXT_ALIGN_HCENTER|TEXT_ALIGN_RIGHT +// |TEXT_ALIGN_TOP|TEXT_ALIGN_VCENTER|TEXT_ALIGN_BOTTOM +// |TEXT_FONT|TEXT_COLOR; +#endif + return 0; +} + +/* GetTextFont + * Return the font used by your extension. + */ +BOOL MMF2Func GetTextFont(mv *mV, SerializedED *SED, LOGFONT *lf, LPTSTR, UINT) +{ +#ifndef RUN_ONLY + // + return TRUE; +#endif + return FALSE; +} + +/* SetTextFont + * Changes the font used by your extension. + */ +BOOL MMF2Func SetTextFont(mv *mV, SerializedED *SED, LOGFONT *lf, LPCSTR) +{ +#ifndef RUN_ONLY + // + return TRUE; +#endif + return FALSE; +} + +/* GetTextClr + * Return the RGB color value of the text color. + */ +COLORREF MMF2Func GetTextClr(mv *mV, SerializedED *SED) +{ +#ifndef RUN_ONLY + // + return 200<<8; //green +#endif + return 0; +} + +/* SetTextClr + * Sets the color of the text. + */ +void MMF2Func SetTextClr(mv *mV, SerializedED *SED, COLORREF Color) +{ +#ifndef RUN_ONLY + // +#endif +} + +/* GetTextAlignment + * Return the alignment of the text. + */ +DWORD MMF2Func GetTextAlignment(mv *mV, SerializedED *SED) +{ +#ifndef RUN_ONLY +// DWORD dw = 0; + +// if((ed.Flags & ALIGN_LEFT) != 0) dw |= TEXT_ALIGN_LEFT; +// if((ed.Flags & ALIGN_HCENTER) != 0) dw |= TEXT_ALIGN_HCENTER; +// if((ed.Flags & ALIGN_RIGHT) != 0) dw |= TEXT_ALIGN_RIGHT; + +// if((ed.Flags & ALIGN_TOP) != 0) dw |= TEXT_ALIGN_TOP; +// if((ed.Flags & ALIGN_VCENTER) != 0) dw |= TEXT_ALIGN_VCENTER; +// if((ed.Flags & ALIGN_BOTTOM) != 0) dw |= TEXT_ALIGN_BOTTOM; + +// return dw; +#endif + return 0; +} + +/* SetTextAlignment + * Sets the alignment of the text. + */ +void MMF2Func SetTextAlignment(mv *mV, SerializedED *SED, DWORD AlignFlags) +{ +#ifndef RUN_ONLY +// DWORD dw = ed.Flags; + +// if((AlignFlags & TEXT_ALIGN_LEFT) != 0) dw = (dw & ~(ALIGN_LEFT|ALIGN_HCENTER|ALIGN_RIGHT)) | ALIGN_LEFT; +// if((AlignFlags & TEXT_ALIGN_HCENTER)!= 0) dw = (dw & ~(ALIGN_LEFT|ALIGN_HCENTER|ALIGN_RIGHT)) | ALIGN_HCENTER; +// if((AlignFlags & TEXT_ALIGN_RIGHT) != 0) dw = (dw & ~(ALIGN_LEFT|ALIGN_HCENTER|ALIGN_RIGHT)) | ALIGN_RIGHT; + +// if((AlignFlags & TEXT_ALIGN_TOP) != 0) dw = (dw & ~(ALIGN_TOP|ALIGN_VCENTER|ALIGN_BOTTOM)) | ALIGN_TOP; +// if((AlignFlags & TEXT_ALIGN_VCENTER)!= 0) dw = (dw & ~(ALIGN_TOP|ALIGN_VCENTER|ALIGN_BOTTOM)) | ALIGN_VCENTER; +// if((AlignFlags & TEXT_ALIGN_BOTTOM) != 0) dw = (dw & ~(ALIGN_TOP|ALIGN_VCENTER|ALIGN_BOTTOM)) | ALIGN_BOTTOM; + +// edFlags = dw; +#endif +} diff --git a/Extensions/Template/resource.h b/Extensions/Template/resource.h deleted file mode 100644 index 2b0d9f0..0000000 --- a/Extensions/Template/resource.h +++ /dev/null @@ -1,18 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by Ext.rc -// -#define IDR_EDIF_ICON 101 -#define IDR_EDIF_JSON 102 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NO_MFC 1 -#define _APS_NEXT_RESOURCE_VALUE 103 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/Inc/Ccxhdr.h b/Inc/Ccxhdr.h index a983589..6581fa7 100644 --- a/Inc/Ccxhdr.h +++ b/Inc/Ccxhdr.h @@ -12,21 +12,13 @@ #pragma comment(linker,"/RELEASE") -#ifdef _MERGE_DATA_ // Not set by default -#ifdef _MERGE_RDATA_ -#pragma comment(linker,"/merge:.rdata=.data") -#endif // _MERGE_RDATA_ -#pragma comment(linker,"/merge:.text=.data") -#pragma comment(linker,"/merge:.reloc=.data") -#pragma comment(linker,"/ignore:4078") -#endif // _MERGE_DATA_ - #if _MSC_VER >= 1000 // Slightly slower loading time under Windows 9x, but may save some Kb #pragma comment(linker,"/opt:nowin98") #endif // _MSC_VER >= 1000 #endif // NDEBUG #endif // COMPILE_SMALL + // end of z33z stuff // MAIN INCLUDES @@ -47,6 +39,7 @@ #include #include #include +#include #include #include #ifndef _LINUX @@ -54,7 +47,6 @@ #else #include #endif -#include #if !defined(ASSERT) #ifdef _DEBUG diff --git a/Inc/Cncf.h b/Inc/Cncf.h index 535f5e2..d6d36a6 100644 --- a/Inc/Cncf.h +++ b/Inc/Cncf.h @@ -791,11 +791,66 @@ typedef eventInfosOffsets * LPEVO; #define OBJ_FIRST_C_OBJECT 8 #define OBJ_LAST NB_SYSOBJ +#ifndef COXSDK +// FAST LOOP ACCELERATION +/////////////////////////////////////////////////////////////// +class CPosStartLoop +{ +public: + CPosStartLoop(LPEVP pEvp, LPTSTR pName) + { + m_pEvp = pEvp; + m_name = (LPTSTR)malloc((_tcslen(pName) + 1) * sizeof(TCHAR)); + _tcscpy(m_name, pName); + } + ~CPosStartLoop() + { + free(m_name); + } + LPEVP m_pEvp; + LPTSTR m_name; +}; +class CPosOnLoop +{ +public: + enum + { + POL_STEP = 4 + }; + LPDWORD m_deltas; + int m_length; + int m_position; + LPTSTR m_name; + BOOL m_bOR; + CPosOnLoop(LPTSTR pName) + { + m_name = pName; + m_length = 1; + m_deltas = (LPDWORD)malloc( (m_length * 2 + 1 )* sizeof(DWORD)); + m_position = 0; + m_bOR = FALSE; + } + ~CPosOnLoop() + { + free(m_deltas); + } + void AddOnLoop(DWORD delta1, BOOL delta2) + { + if (m_position == m_length) + { + m_length += POL_STEP; + m_deltas = (LPDWORD)realloc(m_deltas, (m_length *2 + 1) * sizeof(DWORD)); + } + m_deltas[m_position * 2] = delta1; + m_deltas[m_position * 2 + 1] = delta2; + m_position++; + m_deltas[m_position * 2] = 0xFFFFFFFF; + } +}; - - +#endif // ------------------------------------------------------------ @@ -819,6 +874,8 @@ typedef eventInfosOffsets * LPEVO; #define OEFLAG_NEVERKILL 0x2000 #define OEFLAG_NEVERSLEEP 0x4000 #define OEFLAG_MANUALSLEEP 0x8000 +#define OEFLAG_FAKESPRITE 0x40000 +#define OEFLAG_FAKECOLLISIONS 0x80000 #define OEFLAG_TEXT 0x10000 #define OEFLAG_DONTCREATEATSTART 0x20000 @@ -861,6 +918,8 @@ typedef eventInfosOffsets * LPEVO; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //#define OBJ_SYSTEM -1 //-1&255=255 +#define CND_ELSEIF ((-27<<8)|255) +#define CNDL_ELSEIF ((-27<<16)|65535) #define CND_CHANCE ((-26<<8)|255) #define CND_ORLOGICAL ((-25<<8)|255) #define CNDL_ORLOGICAL ((-25<<16)|65535) @@ -931,6 +990,7 @@ typedef eventInfosOffsets * LPEVO; #define ACTL_MENUSHOW ((12<<16)|65535) #define ACT_MENUHIDE ((13<<8)|255) #define ACTL_MENUHIDE ((13<<16)|65535) +#define ACTL_STARTLOOP ((14<<16)|65535) #define ACT_STARTLOOP ((14<<8)|255) #define ACT_STOPLOOP ((15<<8)|255) #define ACT_SETLOOPINDEX ((16<<8)|255) @@ -950,6 +1010,7 @@ typedef eventInfosOffsets * LPEVO; #define EXPL_LONG ((0<<16)|65535) #define EXP_RANDOM ((1<<8)|255) #define EXPL_RANDOM ((1<<16)|65535) +#define EXPNUM_RANDOM 1 #define EXP_VARGLO ((2<<8)|255) #define EXPL_VARGLO ((2<<16)|65535) #define EXP_STRING ((3<<8)|255) @@ -1067,6 +1128,10 @@ typedef eventInfosOffsets * LPEVO; #define EXPL_ZERO ((60<<16)|65535) #define EXP_EMPTY ((61<<8)|255) #define EXPL_EMPTY ((61<<16)|65535) +#define EXP_DISTANCE ((62<<8)|255) +#define EXP_ANGLE ((63<<8)|255) +#define EXP_RANGE ((64<<8)|255) +#define EXP_RANDOMRANGE ((65<<8)|255) #define EXP_PARENTH1 ((-1<<8)|255) #define EXPL_PARENTH1 ((-1<<16)|65535) @@ -1234,6 +1299,7 @@ typedef eventInfosOffsets * LPEVO; #define ACT_SETFRAMEEFFECT ((32<<8)|253) #define ACT_SETFRAMEEFFECTPARAM ((33<<8)|253) #define ACT_SETFRAMEEFFECTPARAMTEXTURE ((34<<8)|253) +#define ACTL_SETFRAMEEFFECTPARAMTEXTURE ((34<<16)|65533) #define ACT_SETFRAMEALPHACOEF ((35<<8)|253) #define ACT_SETFRAMERGBCOEF ((36<<8)|253) @@ -1260,6 +1326,9 @@ typedef eventInfosOffsets * LPEVO; // TIMER Conditions / Actions // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +#define CND_EVERY2 ((-8<<8)|(OBJ_TIMER&255)) +#define CND_TIMEREQUALS ((-7<<8)|(OBJ_TIMER&255)) +#define CND_ONEVENT ((-6<<8)|(OBJ_TIMER&255)) #define CND_TIMEOUT ((-5<<8)|(OBJ_TIMER&255)) #define CND_EVERY ((-4<<8)|(OBJ_TIMER&255)) #define CNDL_EVERY ((-4<<16)|(OBJ_TIMER&0xFFFF)) @@ -1270,11 +1339,16 @@ typedef eventInfosOffsets * LPEVO; #define CND_TIMERSUP ((-1<<8)|(OBJ_TIMER&255)) #define CNDL_TIMERSUP ((-1<<16)|(OBJ_TIMER&0xFFFF)) #define ACT_SETTIMER ((0<<8)|(OBJ_TIMER&255)) +#define ACT_EVENTAFTER ((1<<8)|(OBJ_TIMER&255)) +#define ACT_NEVENTSAFTER ((2<<8)|(OBJ_TIMER&255)) +#define ACT_SETTIMER ((0<<8)|(OBJ_TIMER&255)) #define EXP_TIMVALUE ((0<<8)|(OBJ_TIMER&255)) #define EXP_TIMCENT ((1<<8)|(OBJ_TIMER&255)) #define EXP_TIMSECONDS ((2<<8)|(OBJ_TIMER&255)) #define EXP_TIMHOURS ((3<<8)|(OBJ_TIMER&255)) #define EXP_TIMMINITS ((4<<8)|(OBJ_TIMER&255)) +#define EXP_EVENTAFTER ((5<<8)|(OBJ_TIMER&255)) +#define NUM_ONEVENT -6 #define NUM_EVERY -4 #define NUM_TIMER -3 #define NUM_TIMERINF -2 @@ -1363,6 +1437,8 @@ typedef eventInfosOffsets * LPEVO; #define CND_NUMOFALLOBJECT_OLD ((-3<<8)|(OBJ_CREATE&255)) #define CND_NUMOFALLZONE_OLD ((-2<<8)|(OBJ_CREATE&255)) #define CND_NOMOREALLZONE_OLD ((-1<<8)|(OBJ_CREATE&255)) +#define ACT_CREATEBYNAME ((1<<8)|(OBJ_CREATE&255)) +#define ACTL_CREATEBYNAME ((1<<16)|(OBJ_CREATE&0xFFFF)) #define ACT_CREATE ((0<<8)|(OBJ_CREATE&255)) #define EXP_CRENUMBERALL ((0<<8)|(OBJ_CREATE&255)) #define NUM_END -2 @@ -1546,12 +1622,13 @@ typedef struct tagMV { } Movement; typedef Movement * LPMOVEMENT; -#ifndef IN_KPX // COMMON CONDITIONS FOR NORMAL OBJECTS ////////////////////////////////////////// #define EVENTS_EXTBASE 80 +#define CND_EXTONLOOP (-41<<8) +#define CNDL_EXTONLOOP (-41<<16) #define CND_EXTISSTRIKEOUT (-40<<8) #define CND_EXTISUNDERLINE (-39<<8) #define CND_EXTISITALIC (-38<<8) @@ -1574,6 +1651,7 @@ typedef Movement * LPMOVEMENT; #define CND_EXTFLAGSET (-25<<8) #define CND_EXTFLAGRESET (-24<<8) #define CND_EXTISCOLBACK (-23<<8) +#define CNDL_EXTISCOLBACK (-23<<16) #define CND_EXTNEARBORDERS (-22<<8) #define CND_EXTENDPATH (-21<<8) #define CNDL_EXTENDPATH (-21<<16) @@ -1686,6 +1764,21 @@ typedef Movement * LPMOVEMENT; #define ACT_EXTSETALPHACOEF (65<<8) #define ACT_EXTSETRGBCOEF (66<<8) #define ACT_EXTSETEFFECTPARAMTEXTURE (67<<8) +#define ACTL_EXTSETEFFECTPARAMTEXTURE (67<<16) +#define ACT_EXTSETFRICTION (68<<8) +#define ACT_EXTSETELASTICITY (69<<8) +#define ACT_EXTAPPLYIMPULSE (70<<8) +#define ACT_EXTAPPLYANGULARIMPULSE (71<<8) +#define ACT_EXTAPPLYFORCE (72<<8) +#define ACT_EXTAPPLYTORQUE (73<<8) +#define ACT_EXTSETLINEARVELOCITY (74<<8) +#define ACT_EXTSETANGULARVELOCITY (75<<8) +#define ACT_EXTFOREACH (76<<8) +#define ACT_EXTFOREACH2 (77<<8) +#define ACT_EXTSTOPFORCE (78<<8) +#define ACT_EXTSTOPTORQUE (79<<8) +#define ACT_EXTSETDENSITY (80<<8) // NOT USED IN PHYSCS ACTI0N MENU +#define ACT_EXTSETGRAVITYSCALE (81<<8) // NOT USED IN PHYSCS ACTI0N MENU #define EXP_EXTYSPR ( 1<<8) #define EXP_EXTISPR ( 2<<8) @@ -1720,6 +1813,18 @@ typedef Movement * LPMOVEMENT; #define EXP_EXTEFFECTPARAM (29<<8) #define EXP_EXTVARBYINDEX (30<<8) #define EXP_EXTVARSTRINGBYINDEX (31<<8) +#define EXP_EXTDISTANCE (32<<8) +#define EXP_EXTANGLE (33<<8) +#define EXP_EXTLOOPINDEX (34<<8) +#define EXP_EXTGETFRICTION (35<<8) +#define EXP_EXTGETRESTITUTION (36<<8) +#define EXP_EXTGETDENSITY (37<<8) +#define EXP_EXTGETVELOCITY (38<<8) +#define EXP_EXTGETANGLE (39<<8) +#define EXP_EXTWIDTH (40<<8) +#define EXP_EXTHEIGHT (41<<8) + +#ifndef IN_KPX // TEXT Conditions / Actions //////////////////////////////////////////// @@ -1875,6 +1980,8 @@ typedef Movement * LPMOVEMENT; #define ACT_CCASETGLOBALSTRING (((EVENTS_EXTBASE+10)<<8)|(OBJ_CCA&0x00FF)) #define ACT_CCAPAUSEAPP (((EVENTS_EXTBASE+11)<<8)|(OBJ_CCA&0x00FF)) #define ACT_CCARESUMEAPP (((EVENTS_EXTBASE+12)<<8)|(OBJ_CCA&0x00FF)) +#define ACT_CCASETWIDTH (((EVENTS_EXTBASE+13)<<8)|(OBJ_CCA&0x00FF)) +#define ACT_CCASETHEIGHT (((EVENTS_EXTBASE+14)<<8)|(OBJ_CCA&0x00FF)) #define EXP_CCAGETFRAMENUMBER (((EVENTS_EXTBASE+0)<<8)|(OBJ_CCA&0x00FF)) #define EXP_CCAGETGLOBALVALUE (((EVENTS_EXTBASE+1)<<8)|(OBJ_CCA&0x00FF)) #define EXP_CCAGETGLOBALSTRING (((EVENTS_EXTBASE+2)<<8)|(OBJ_CCA&0x00FF)) @@ -2373,6 +2480,18 @@ typedef prgParam2 * LPPRG2; #define PS_EFFECT 2 // B name of the effect +// -------------------------------- Character encoding for reading text files +#define PARAM_CHAR_ENCODING_INPUT 65 +#define PS_CHAR_ENCODING_INPUT 6 +typedef struct { + WORD wCharEncoding; + DWORD dwUnusedParam; +} charEncodingParam; + +// -------------------------------- Character encoding for saving text files +#define PARAM_CHAR_ENCODING_OUTPUT 66 +#define PS_CHAR_ENCODING_OUTPUT 6 + // STRUCTURE FOR FAST LOOPS /////////////////////////////////////////////////////////////////////// @@ -2588,6 +2707,21 @@ typedef struct #define EditDebugInfo EditDebugInfoA #endif +typedef struct tagTimerEvent +{ + void* next; + int type; + LPTSTR name; + UINT timer; + UINT timerNext; + UINT timerPosition; + int loops; + int index; +}TimerEvent; +typedef TimerEvent* LPTIMEREVENT; +#define TIMEREVENTTYPE_ONESHOT 0 +#define TIMEREVENTTYPE_REPEAT 1 + /////////////////////////////////////////////////////////////////////// // // RUNTIME BUFFER @@ -2746,6 +2880,9 @@ typedef struct tagKPXLIB { #define RFUNCTION_CALLMOVEMENT 22 #define RFUNCTION_SETPOSITION 23 #define RFUNCTION_GETCALLTABLES 24 +#define RFUNCTION_GENERATECOMMONEVENT 25 +#define RFUNCTION_RANDOM 26 +#define RFUNCTION_ADDCURRENTOBJECT 27 #define CNC_GetParameter(rdPtr) callRunTimeFunction(rdPtr, RFUNCTION_GETPARAM, 0xFFFFFFFF, 0) #define CNC_GetIntParameter(rdPtr) callRunTimeFunction(rdPtr, RFUNCTION_GETPARAM, 0, 0) @@ -2828,8 +2965,15 @@ typedef struct tagRH4 { double rh4MvtTimerCoef; CIPhoneJoystick* rh4IPhoneJoystick; CIPhoneAd* rh4IPhoneAd; - char rh4QuitString[32]; // FREE!!!! GREAT! - + void* rh4Box2DBase; + short rh4Box2DSearched; + void* rh4ForEachs; + void* rh4CurrentForEach; + void* rh4CurrentForEach2; + void* rh4TimerEvents; + void* rh4PosOnLoop; + short rh4ComplexOnLoop; + char rh4QuitString[4]; // FREE!!!! GREAT! DWORD rh4PickFlags0; // 00-31 DWORD rh4PickFlags1; // 31-63 @@ -3125,7 +3269,6 @@ typedef headerObject* LPHO; #define HOF_FLOAT 0x4000 #define HOF_STRING 0x8000 - // -------------------------------------- // Object's movement structure // -------------------------------------- @@ -3231,6 +3374,8 @@ typedef struct tagRM { { int MBul_Wait; LPHO MBul_ShootObject; + void* MBul_Body; + void* MBul_MBase; }; struct { @@ -3350,11 +3495,7 @@ typedef rVal * LPRVAL; // Objects animation and movement structure // ----------------------------------------------- #if !defined(ANGLETYPE) -#if defined(HWABETA) #define ANGLETYPE float -#else -#define ANGLETYPE int -#endif #endif typedef void (* RCROUTINE)(LPHO); typedef struct tagRCOM { @@ -3882,6 +4023,7 @@ typedef struct tagCallTables #undef pev typedef struct pev { #endif + pev* pevNext; long pevCode; PEV_ROUTINE pevRoutine; long pevParam; @@ -3903,6 +4045,22 @@ typedef struct tagCallTables } qualifierLoad; typedef qualifierLoad * LPQLOAD; +#define STEPFOREACH 10 +typedef struct tagForEach +{ + void* next; + int length; + OINUM oi; + int index; + LPTSTR name; + int number; + BOOL stop; + BOOL toDelete; + LPHO objects[STEPFOREACH]; +}ForEach; +typedef ForEach* LPFOREACH; + + #endif // RUN_TIME #ifndef __cplusplus diff --git a/Inc/Cncy.h b/Inc/Cncy.h index ed97cba..56996c9 100644 --- a/Inc/Cncy.h +++ b/Inc/Cncy.h @@ -231,8 +231,8 @@ typedef struct AppHeader { // Other flags #define GAOF_DEBUGGERSHORTCUTS 0x0001 -#define GAOF_DDRAW 0x0002 -#define GAOF_DDRAWVRAM 0x0004 +//#define GAOF_DDRAW 0x0002 +//#define GAOF_DDRAWVRAM 0x0004 #define GAOF_OBSOLETE 0x0008 #define GAOF_AUTOIMGFLT 0x0010 #define GAOF_AUTOSNDFLT 0x0020 @@ -255,7 +255,8 @@ typedef struct AppHeader2 { DWORD dwBuildFlags; WORD wScreenRatioTolerance; WORD wScreenAngle; // 0 (no rotation/portrait), 1 (90 clockwise/landscape left), 2 (90 anticlockwise/landscape right), 3 (automatic portrait), 4 (automatic landscape), 5 (fully automatic) - DWORD dwUnused2; + WORD iPhoneDisplayOption; + WORD wUnused; } AppHeader2; @@ -273,6 +274,16 @@ typedef struct AppHeader2 { #define AH2OPT_DISABLEBACKBUTTON 0x0800 // (Android) Disable Back button behavior #define AH2OPT_ANTIALIASED 0x1000 // (iPhone) Smooth resizing on bigger screens #define AH2OPT_CRASHREPORTING 0x2000 // (Android) Enable online crash reporting +#define AH2OPT_REQUIREGPU 0x4000 // (Android) Application requires a GPU +#define AH2OPT_KEEPRESOURCESBETWEENFRAMES 0x8000 // (HTML5) Keep resources between frames +#define AH2OPT_WEBGL 0x10000 // (HTML5) WebGL +#define AH2OPT_OPENGL1 0x10000 // (Android) Open GL 1.1 +#define AH2OPT_RESERVED 0x20000 // (Android) for future use +#define AH2OPT_NOSCREENBORDERS 0x40000 // (Android) No screen borders when KeepScreenRatio is selected (note: will be implemented in other exporters later) +#define AH2OPT_SYSTEMFONT 0x80000 // (Android) Use system font in text objects +#define AH2OPT_RUNEVENIFNOTFOCUS 0x100000 // (HTML5) Run even if not focus +#define AH2OPT_KEYBOVERAPPWINDOW 0x200000 // (Android) Display keyboard over app window +#define AH2OPT_OUYA 0x400000 // (Android) OUYA application enum { SCREENORIENTATION_PORTRAIT, @@ -310,7 +321,14 @@ enum { BUILDTYPE_XNA_PHONE, BUILDTYPE_XNA_XBOX_APP, BUILDTYPE_XNA_PHONE_APP, - BUILDTYPE_STDMAX, // end of standard build types + BUILDTYPE_HTML5, + BUILDTYPE_VITA, + BUILDTYPE_VITADEVEL, + BUILDTYPE_VITAFINAL, // no longer used + BUILDTYPE_HTML5DEVEL, + BUILDTYPE_HTML5FINAL, + BUILDTYPE_OUYA, + BUILDTYPE_MAX, // end of standard build types }; // Build flag values @@ -324,6 +342,32 @@ enum { #define BUILDFLAG_TEST 0x0080 #define BUILDFLAG_NOWARNINGS 0x0100 +// Bluray options +#define BRFLAGS_DISPLAYLOADANIM 0x0001 +#define BRFLAGS_GRAPHICSNOTINJAR 0x0002 +#define BRFLAGS_BACKSURFACE 0x0004 +#define BRFLAGS_EXTERNALSOUNDS 0x0008 + +#define BRLOADANIM_NIMAGES_DEFAULT 4 + +typedef struct BlurayAppOptions { + + DWORD dwOpacity; + DWORD dwFlags; + DWORD dwLoadAnimNImages; + WORD wLoadAnimImage; + WORD wReserved; + +} BlurayAppOptions; +typedef BlurayAppOptions *LPPLURAYAPPOPTIONS; + +typedef struct BlurayFrameOptions { + + DWORD dwOpacity; + DWORD dwKeyReleaseTimeOut; + +} BlurayFrameOptions; +typedef BlurayFrameOptions *LPPLURAYFRAMEOPTIONS; #endif ////////////////////////////////////////////////////////////////////////////// @@ -1029,11 +1073,12 @@ enum { #define MMFVERFLAG_MASK 0x0000F000 #define MMFVERFLAG_HOME 0x00008000 // TGF #define MMFVERFLAG_PRO 0x00004000 // MMF Pro -#define MMFVERFLAG_DEMO 0x00002000 // Demo +#define MMFVERFLAG_ATX 0x00002000 // Not used #define MMFVERFLAG_PLUGIN 0x00001000 // Plugin #define MMFVERSION_15 0x01050000 // MMF 1.5 #define MMFVERSION_20 0x02000000 // MMF 2.0 -#define MMF_CURRENTVERSION MMFVERSION_20 +#define MMFVERSION_25 0x02050000 // MMF 2.5 +#define MMF_CURRENTVERSION MMFVERSION_25 // Build numbers #define MMF_BUILD_NONAME 203 @@ -1088,19 +1133,20 @@ enum { #define MMF_BUILD_252 252 #define MMF_BUILD_253 253 #define MMF_BUILD_254 254 -#define MMF_CURRENTBUILD MMF_BUILD_254 +#define MMF_BUILD_255 255 +#define MMF_BUILD_256 256 +#define MMF_BUILD_257 257 +#define MMF_BUILD_MMF25 280 +#define MMF_CURRENTBUILD MMF_BUILD_MMF25 // MFA file format versions #define MFA_BUILD_ALTSTR 1 // Alterable strings #define MFA_BUILD_COUNTERTEXT 2 // Text mode in counters #define MFA_BUILD_LASTFRAMEOFFSET 3 // Additional frame offset #define MFA_BUILD_FIXQUALIF 4 // Fix in qualifiers + prd version -#ifdef _UNICODE #define MFA_BUILD_LANGID 5 // Language ID -#define MFA_CURRENTBUILD MFA_BUILD_LANGID -#else -#define MFA_CURRENTBUILD MFA_BUILD_FIXQUALIF -#endif +#define MFA_BUILD_MMF25 6 // MMF 2.5 +#define MFA_CURRENTBUILD MFA_BUILD_MMF25 // Structures for picture editor typedef struct EditSurfaceParamsA { @@ -1267,7 +1313,9 @@ typedef struct mv { HHOOK mvHMsgHook; int mvModalLoop; int mvModalSubAppCount; - LPVOID mvFree[5]; + UINT mvLanguageID; + LPCWSTR mvModuleTextsPathname; + LPVOID mvFree[3]; // Functions //////////// @@ -1421,6 +1469,8 @@ enum { EF_ISUNICODEAPP, // Returns TRUE if the application being loaded is a Unicode application EF_GETAPPCODEPAGE, // Returns the code page of the application EF_CREATEIMAGEFROMFILEW,// Create image from file (runtime only) + EF_LOADTEXT, + EF_SAVETEXT, }; // 3rd parameter of EF_CREATEIMAGEFROMFILE @@ -1522,7 +1572,7 @@ __inline LPVOID mvGetNextItem(LPMV mV, LPVOID edPtr, LPVOID edPtr1, LPCSTR extNa #ifdef HWABETA -__inline BOOL mvCreateEffect(LPMV mV, LPCSTR pEffectName, LPINT pEffect, LPARAM* pEffectParam) \ +__inline BOOL mvCreateEffect(LPMV mV, LPCTSTR pEffectName, LPINT pEffect, LPARAM* pEffectParam) \ { return (BOOL)mV->mvCallFunction(NULL, EF_CREATEEFFECT, (LPARAM)pEffectName, (LPARAM)pEffect, (LPARAM)pEffectParam); } __inline void mvDeleteEffect(LPMV mV, int nEffect, LPARAM lEffectParam) \ @@ -1551,12 +1601,30 @@ __inline BOOL mvIsUnicodeApp(LPMV mV, LPVOID pApp) \ __inline int mvGetAppCodePage(LPMV mV, LPVOID pApp) \ { return mV->mvCallFunction(NULL, EF_GETAPPCODEPAGE, (LPARAM)pApp, (LPARAM)0, (LPARAM)0); } +__inline LPWSTR mvLoadTextFile(LPMV mV, LPCWSTR fname, UINT encoding, BOOL bBinaryFile) \ + { return (LPWSTR)mV->mvCallFunction(NULL, EF_LOADTEXT, (LPARAM)fname, (LPARAM)encoding, (LPARAM)bBinaryFile); } + +__inline int mvSaveTextFile(LPMV mV, LPCWSTR fname, LPCWSTR text, UINT encoding) \ + { return (int)mV->mvCallFunction(NULL, EF_SAVETEXT, (LPARAM)fname, (LPARAM)text, (LPARAM)encoding); } + #ifdef _UNICODE #define mvCreateImageFromFile mvCreateImageFromFileW #else #define mvCreateImageFromFile mvCreateImageFromFileA #endif +enum { + CHARENC_ANSI, + CHARENC_UTF8_W_BOM, + CHARENC_UTF8_WO_BOM, + CHARENC_UTF16_W_BOM, + CHARENC_UTF16_WO_BOM, + CHARENC_UTF16B_W_BOM, + CHARENC_UTF16B_WO_BOM, + CHARENC_MAX, +}; +#define CHARENC_DEFAULT ((UINT)-1) + #endif // __cplusplus // Options for OpenHFile @@ -1600,6 +1668,7 @@ typedef struct MvxFnc { LPTSTR mvxFileTitle; CMvt* ( CALLBACK * mvxCreateMvt) (DWORD); + void ( CALLBACK * mvxGetMvtName)(int nMvt, LPTSTR pName, int cbSize); #if defined(VITALIZE) BOOL bValidated; diff --git a/Inc/Cnpdll.h b/Inc/Cnpdll.h index 2d32f1c..063e231 100644 --- a/Inc/Cnpdll.h +++ b/Inc/Cnpdll.h @@ -66,7 +66,7 @@ struct sMask; // Current build -#define MMFS2_CURRENT_BUILD 250 +#define MMFS2_CURRENT_BUILD 280 #define MMFS2_BUILD_MASK 0x0000FFFF #define MMFS2_BUILD_FLAG_UNICODE 0x00010000 // Unicode support #define MMFS2_BUILD_FLAG_HWA 0x00020000 // HWA support @@ -77,6 +77,9 @@ struct sMask; #define DWORDSTR(c1,c2,c3,c4) ((DWORD)((DWORD)c4<<24|(DWORD)c3<<16|(DWORD)c2<<8|(DWORD)c1)) #endif +#define ANGLEFLOAT +#define ANGLETYPE float // int + // Definitions differentes si WIN32 // ================== @@ -194,8 +197,8 @@ enum { #define MAX_MODE SM_32 #define SM_D3D 0x10 -#define SM_DDRAW 0x20 // Flag "Direct Draw" -#define SM_VRAM 0x40 // Flag "Video RAM" +//#define SM_DDRAW 0x20 // Flag "Direct Draw" +//#define SM_VRAM 0x40 // Flag "Video RAM" #define SM_D3D8 0x80 #define SM_NOTDIB (SM_DDRAW | SM_VRAM) #define SM_MASK 0x0F // Mask mode @@ -218,8 +221,10 @@ enum { // Hauteur des plateformes #define HEIGHT_PLATFORM 6 -#define GCMF_OBSTACLE 0x0000 -#define GCMF_PLATFORM 0x0001 +#define GCMF_OBSTACLE 0x0000 +#define GCMF_PLATFORM 0x0001 +#define GCMF_TYPEMASK 0x0FFF +#define GCMF_NOROTATEORSTRETCH 0x1000 // Flags pour GetImageSize #define GIS_WITHMASK 0x8000 @@ -431,7 +436,7 @@ typedef Box *fpBox; typedef struct tagSMI { UINT totalBitCount; // I.e. 16 UINT usedBitCount; // I.e. 15 - UINT mainMode; // SM_4, SM_8, SM_etc... avec flags SM_DDRAW + UINT mainMode; // SM_4, SM_8, SM_etc... avec flags SM_D3D, etc UINT subMode; // sous-mode DWORD rMask; DWORD gMask; @@ -495,6 +500,7 @@ typedef struct tagSMI { #define SF_OWNERCOLMASK 0x00800000 // Owner-draw sprite supports collision masks #define SF_UPDATECOLLIST 0x10000000 +#define SF_HWA 0x20000000 // SpriteCol_TestPoint / SpriteCol_TestSprite #define SCF_OBSTACLE 0x01 @@ -502,6 +508,7 @@ typedef struct tagSMI { #define SCF_EVENNOCOL 0x04 // Flag: returns even sprites that haven't the SF_RAMBO flag #define SCF_BACKGROUND 0x08 // Flag: if 0, returns active sprites, otherwise returns background sprites #define SCF_TESTFEET 0x10 // Test only the bottom of the sprite +#define SCF_TESTLIST 0x20 #define LAYER_ALL (-1) @@ -560,18 +567,29 @@ class Spr typedef struct Spr { #endif -#ifndef SPRLIST - Obj sprObj; -#endif + #ifndef SPRLIST + Obj sprObj; + #endif DWORD sprFlags; // Flags WORD sprLayer; // Sprite plane (layer) - short sprAngle; // Angle + WORD sprUnused; // Angle (Int format) .. int sprZOrder; // Z-order value // Coordinates int sprX; int sprY; + // Hot spot and dimensions + int sprHotSpotX; // TODO: mettre en commentaires ceux qui ne sont pas utilisés + int sprHotSpotY; + int sprWidth; + int sprHeight; + + // Scale & Angle + float sprScaleX; + float sprScaleY; + ANGLETYPE sprAngle; + // Bounding box int sprX1; int sprY1; @@ -582,6 +600,17 @@ typedef struct Spr int sprXnew; int sprYnew; + // New hot spot and dimensions + int sprHotSpotXnew; + int sprHotSpotYnew; + int sprWidthNew; + int sprHeightNew; + + // New scale & angle + float sprScaleXnew; + float sprScaleYnew; + ANGLETYPE sprAngleNew; + // New bounding box int sprX1new; int sprY1new; @@ -595,14 +624,14 @@ typedef struct Spr int sprY2z; // Scale & Angle - float sprScaleX; - float sprScaleY; +// float sprScaleX; +// float sprScaleY; // Temporary values for collisions - WORD sprTempImg; // TODO: use DWORD later? - short sprTempAngle; - float sprTempScaleX; - float sprTempScaleY; +// WORD sprTempImg; // TODO: use DWORD later? +// short sprTempAngleInt; +// float sprTempScaleX; +// float sprTempScaleY; // Image or owner-draw routine union { @@ -624,10 +653,10 @@ typedef struct Spr cSurfaceImplementation* sprBackSurf; // Background surface, if no general background surface cSurfaceImplementation* sprSf; // Surface (if stretched or rotated) - sMask* sprColMask; // Collision mask (if stretched or rotated) +// sMask* sprColMask; // Collision mask (if stretched or rotated) - cSurfaceImplementation* sprTempSf; // Temp surface (if stretched or rotated) - sMask* sprTempColMask; // Temp collision mask (if stretched or rotated) +// cSurfaceImplementation* sprTempSf; // Temp surface (if stretched or rotated) +// sMask* sprTempColMask; // Temp collision mask (if stretched or rotated) // User data LPARAM sprExtraInfo; @@ -649,6 +678,7 @@ typedef struct Spr typedef Spr *npSpr; typedef Spr *fpSpr; + // Structure "taille d'une appli" typedef struct tagAppSize { DWORD asInternal; // Place occupee dans le segment DLL @@ -910,18 +940,19 @@ DLLExport32 long WINAPI DelImage (npAppli, DWORD); DLLExport32 sMask* WINAPI AddMask (npAppli ptApp, DWORD iNum, UINT nFlags); DLLExport32 long WINAPI DelMask (npAppli, DWORD); DLLExport32 int WINAPI GetImageInfos (npAppli, DWORD, fpImg); -DLLExport32 int WINAPI GetImageInfoEx (npAppli pApp, DWORD nImage, int nAngle, float fScaleX, float fScaleY, fpImg pIfo); +DLLExport32 int WINAPI GetImageInfoEx (npAppli pApp, DWORD nImage, ANGLETYPE nAngle, float fScaleX, float fScaleY, fpImg pIfo); DLLExport32 DWORD WINAPI GetImageSize (WORD, WORD, WORD); DLLExport32 sMask* WINAPI GetImageMask (npAppli ptApp, DWORD dwImage, UINT nFlags); DLLExport32 sMask* WINAPI CompleteSpriteColMask (npWin ptrWin, npSpr ptSpr, DWORD dwPSCFlags, UINT nWidth, UINT nHeight); -DLLExport32 DWORD WINAPI PrepareSpriteColMask (npWin ptrWin, npSpr ptSpr, DWORD newImg, int newX, int newY, int newAngle, float newScaleX, float newScaleY, RECT* prc, sMask** ppMask); +DLLExport32 DWORD WINAPI PrepareSpriteColMask (npWin ptrWin, npSpr ptSpr, DWORD newImg, int newX, int newY, ANGLETYPE newAngle, float newScaleX, float newScaleY, RECT* prc, sMask** ppMask); +DLLExport32 void WINAPI DelImageTexture (npAppli ptApp, DWORD iNum); // Sprites // ------- DLLExport32 npSpr WINAPI AddSprite (npWin ptrWin, int xSpr, int ySpr, DWORD iSpr, WORD wLayer, int nZOrder, DWORD backSpr, DWORD sFlags, LPARAM extraInfo); DLLExport32 npSpr WINAPI AddOwnerDrawSprite (npWin ptrWin, int x1, int y1, int x2, int y2, WORD wLayer, int nZOrder, DWORD backSpr, DWORD sFlags, LPARAM extraInfo, LPARAM sprProc); DLLExport32 npSpr WINAPI ModifSprite (npWin ptrWin, npSpr ptSpr, int xSpr, int ySpr, DWORD iSpr); -DLLExport32 npSpr WINAPI ModifSpriteEx (npWin ptrWin, npSpr ptSpr, int xSpr, int ySpr, DWORD iSpr, float fScaleX, float fScaleY, BOOL bResample, int nAngle, BOOL bAntiA); +DLLExport32 npSpr WINAPI ModifSpriteEx (npWin ptrWin, npSpr ptSpr, int xSpr, int ySpr, DWORD iSpr, float fScaleX, float fScaleY, BOOL bResample, ANGLETYPE nAngle, BOOL bAntiA); DLLExport32 npSpr WINAPI ModifSpriteEffect (npWin ptrWin, npSpr ptSpr, DWORD effect, LPARAM effectParam); DLLExport32 npSpr WINAPI ModifOwnerDrawSprite (npWin ptrWin, npSpr ptSprModif, int x1, int y1, int x2, int y2); DLLExport32 void WINAPI ShowSprite (npWin, npSpr, int); @@ -939,9 +970,10 @@ DLLExport32 void WINAPI ScreenUpdate (npWin); DLLExport32 void WINAPI GetSpriteScale (npWin ptrWin, npSpr ptSpr, float* pScaleX, float* pScaleY, BOOL* pResample); DLLExport32 void WINAPI SetSpriteScale (npWin ptrWin, npSpr ptSpr, float fScaleX, float fScaleY, BOOL bResample); -DLLExport32 int WINAPI GetSpriteAngle (npWin ptrWin, npSpr ptSpr, BOOL* pAntiA); -DLLExport32 void WINAPI SetSpriteAngle (npWin ptrWin, npSpr ptSpr, int nAngle, BOOL bAntiA); +DLLExport32 ANGLETYPE WINAPI GetSpriteAngle (npWin ptrWin, npSpr ptSpr, BOOL* pAntiA); +DLLExport32 void WINAPI SetSpriteAngle (npWin ptrWin, npSpr ptSpr, ANGLETYPE nAngle, BOOL bAntiA); DLLExport32 void WINAPI GetSpriteRect (npWin ptrWin, npSpr ptSpr, RECT* prc); +DLLExport32 void WINAPI GetSpriteRectNew (npWin ptrWin, npSpr ptSpr, RECT* prc); DLLExport32 void WINAPI MoveSpriteToFront(npWin ptrWin, npSpr pSpr); DLLExport32 void WINAPI MoveSpriteToBack (npWin ptrWin, npSpr pSpr); DLLExport32 void WINAPI MoveSpriteBefore (npWin ptrWin, npSpr pSprToMove, npSpr pSprDest); @@ -974,8 +1006,8 @@ DLLExport32 void WINAPI WinEnableUpdate (npWin, int); DLLExport32 DWORD WINAPI SetSpriteColFlag (npWin, npSpr, DWORD); // UINT = SF_xxxx DLLExport32 npSpr WINAPI SpriteCol_TestPoint (npWin, npSpr, int, int, int, DWORD); // Entre 1 pixel et les sprites sauf un DLLExport32 npSpr WINAPI SpriteCol_TestRect (npWin, npSpr, int, int, int, int, int, DWORD); // Entre 1 rectangle et les sprites sauf un -DLLExport32 npSpr WINAPI SpriteCol_TestSprite (npWin ptrWin, npSpr ptSpr, DWORD newImg, int newX, int newY, int newAngle, float newScaleX, float newScaleY, int subHt, DWORD dwFlags); -DLLExport32 UINT WINAPI SpriteCol_TestSprite_All (npWin, npSpr, LPVOID*, DWORD, int, int, int, float, float, DWORD); +DLLExport32 npSpr WINAPI SpriteCol_TestSprite (npWin ptrWin, npSpr ptSpr, DWORD newImg, int newX, int newY, ANGLETYPE newAngle, float newScaleX, float newScaleY, int subHt, DWORD dwFlags); +DLLExport32 UINT WINAPI SpriteCol_TestSprite_All (npWin, npSpr, LPVOID*, DWORD, int, int, ANGLETYPE, float, float, DWORD); DLLExport32 int WINAPI WinSetColMode (npWin, WORD); // Mode BOX ou BITMAP DLLExport32 BOOL WINAPI ColMask_Create (npWin, UINT, UINT, DWORD); // Creation bitmap masque fond @@ -993,7 +1025,7 @@ DLLExport32 void WINAPI ColMask_ToLog (npWin ptrWin, UINT nPlane); DLLExport32 void WINAPI ColMask_SetClip (npWin, RECT *); DLLExport32 BOOL WINAPI ColMask_TestPoint (npWin ptrWin, int x, int y, UINT nPlane); -DLLExport32 BOOL WINAPI ColMask_TestSprite (npWin ptrWin, npSpr pSpr, int newImg, int newX, int newY, int newAngle, float newScaleX, float newScaleY, int subHt, UINT nPlane); +DLLExport32 BOOL WINAPI ColMask_TestSprite (npWin ptrWin, npSpr pSpr, int newImg, int newX, int newY, ANGLETYPE newAngle, float newScaleX, float newScaleY, int subHt, UINT nPlane); DLLExport32 int WINAPI ColMask_TestRect (npWin, int, int, int, int, UINT nPlane); DLLExport32 BOOL WINAPI Mask_TestPoint (LPBYTE pMask, int x, int y, int nMaskWidth, int nMaskHeight); @@ -1027,6 +1059,9 @@ DLLExport32 void WINAPI DelPalette (HCSPALETTE pCsPal); DLLExport32 void WINAPI SetAppCSPalette (npAppli ptrApp, HPALETTE hpal, HCSPALETTE pCsPal); DLLExport32 HCSPALETTE WINAPI GetAppCSPalette (npAppli ptrApp); + // HWA +DLLExport32 void WINAPI WinSizeChanged ( npWin ptrWin ); + // Sounds #ifdef __cplusplus @@ -1083,6 +1118,7 @@ DLLExport32 long WINAPI GetSoundData (npAppli, UINT, LPBYTE); DLLExport32 LPBYTE WINAPI GetSoundDataPtr (npAppli, UINT); DLLExport32 long WINAPI DelSound (npAppli, UINT); +DLLExport32 int WINAPI WaveSetChannels (npAppli ptApp, int nChannels); DLLExport32 UINT WINAPI AddSoundW (npAppli, UINT, LPWSTR, LPBYTE, DWORD); DLLExport32 UINT WINAPI ReplaceSoundW (npAppli ptApp, UINT sFlags, UINT nSound, LPWSTR fpName, LPBYTE lpData, DWORD dwDataSize); DLLExport32 int WINAPI GetSoundNameW (npAppli, UINT, LPWSTR, UINT); @@ -1104,7 +1140,50 @@ DLLExport32 int WINAPI GetSoundInfoW (npAppli, UINT, fpSound); #define PlaySnd PlaySndA #endif -DLLExport32 int WINAPI WaveSetChannels (npAppli ptApp, int nChannels); +// Layer functions +// Layer +#ifdef __cplusplus +class WinLayer +{ +public: +#else +typedef struct WinLayer +{ +#endif + // Structure size + DWORD layerSize; + + // Effect + DWORD layerEffect; + LPARAM layerEffectParam; + + // Options + DWORD dwLayerOptions; + + // Scale & angle + float xScale; + float yScale; + float scale; // not used for display + float angle; + + // Hotspot + POINT hotSpot; + + // Destination point + POINT destPoint; + +#ifdef __cplusplus +}; +#else +} WinLayer; +#endif + +// Layer options +#define WLF_PREVIOUSEFFECT 1 + +DLLExport32 void WINAPI WinCreateLayers (npWin ptrWin, int nLayers); +DLLExport32 void WINAPI WinSetLayerEffect (npWin ptrWin, int nLayer, DWORD dwEffect, LPARAM dwEffectParam, DWORD dwOptions); +DLLExport32 WinLayer* WINAPI WinGetLayerAt (npWin ptrWin, int nLayer); #ifdef __cplusplus } @@ -1130,6 +1209,7 @@ enum { WSURF_BACKSAVE }; DLLExport32 cSurface * WINAPI WinGetSurface (int idWin, int surfID=WSURF_LOGSCREEN); +DLLExport32 void WINAPI WinSetCurrent (int idWin); #endif // __cplusplus #endif // !defined(_H2INC) diff --git a/Inc/EDStream.hpp b/Inc/EDStream.hpp new file mode 100644 index 0000000..a8d5b1f --- /dev/null +++ b/Inc/EDStream.hpp @@ -0,0 +1,163 @@ +/* Note: + * This is not an independent header! + */ + +#ifndef __EditDataStream_HeaderPlusPlus__ +#define __EditDataStream_HeaderPlusPlus__ + +#include +#include +#include +#include +#include + +struct EDIStream : std::basic_istream +{ + struct Buf : std::basic_streambuf + { + Buf(SerializedED const&SED, std::size_t putback = 8) : pb(putback), b(putback) + { + std::size_t const edsize = SED.Header.extSize - sizeof(SerializedED); + b.reserve(pb + edsize); + for(std::size_t i = 0; i < edsize; ++i) + { + b.push_back(SED.data[i]); + } + setg(&b.front(), &b.front() + pb, &b.front() + b.size()); + } + virtual ~Buf() + { + } + + private: + std::size_t pb; + std::vector b; + + virtual int_type underflow() + { + if(gptr() < egptr()) + { + return traits_type::to_int_type(*gptr()); + } + return traits_type::eof(); + } + + Buf(Buf const&); + Buf &operator=(Buf const&); + }; + + EDIStream(SerializedED const*SED) : b(*SED), std::basic_istream(&b) + { + } + virtual ~EDIStream() + { + } + + template + T read_value() + { + T t = T(); + this->read(reinterpret_cast(&t), sizeof(T)); + return t; + } + std::basic_string read_string() + { + std::basic_string s; + while(TCHAR c = read_value()) + { + s += c; + } + return s; + } + +private: + Buf b; + + EDIStream(EDIStream const&); + EDIStream &operator=(EDIStream const&); +}; + +struct EDOStream : std::basic_ostream +{ + struct Buf : std::basic_streambuf + { + Buf(mv *mV, SerializedED *&SED) : mV(mV), SED(SED) + { + setp(0, 0); + } + virtual ~Buf() + { + if(b.empty()) + { + return; + } + std::size_t size = (&b.back() + 1) - &b.front(); + SerializedED *t = (SerializedED *)mvReAllocEditData(mV, SED, sizeof(SerializedED)+size); + if(t) + { + SED = t; + memcpy(&(SED->data[0]), &b.front(), size); + } + else + { + MessageBox(NULL, _T("There isn't enough from to store the editdata!"), _T("EDIF Extension"), MB_ICONWARNING); + } + } + private: + mv *mV; + SerializedED *&SED; + std::vector b; + + virtual int_type overflow(int_type ch) + { + if(ch != traits_type::eof()) + { + b.push_back(char_type(ch)); + } + return 0; + } + + Buf(Buf const&); + Buf &operator=(Buf const&); + }; + + EDOStream(mv *mV, SerializedED *&SED) : b(mV, SED), std::basic_ostream(&b) + { + } + virtual ~EDOStream() + { + } + + template + EDOStream &write_value(T t) + { + this->write(reinterpret_cast(&t), sizeof(T)); + return *this; + } + EDOStream &write_string(std::basic_string const&s) + { + for(std::basic_string::const_iterator it = s.begin(); it != s.end(); ++it) + { + write_value(*it); + } + write_value(TCHAR()); + return *this; + } + template + EDOStream &write_sequence(ForwardIterator first, ForwardIterator pastlast) + { + for(; first != pastlast; ++first) + { + this->write(reinterpret_cast(&*first), sizeof(*first)); + } + return *this; + } + +private: + Buf b; + + EDOStream(EDOStream const&); + EDOStream &operator=(EDOStream const&); +}; + +#endif diff --git a/Inc/Edif.h b/Inc/Edif.h index d911f1a..8a5b699 100644 --- a/Inc/Edif.h +++ b/Inc/Edif.h @@ -1,233 +1,298 @@ -#pragma once - -#include "json.h" - -#include "ccxhdr.h" -#include "CfcFile.h" -#include "ImageFlt.h" -#include "ImgFlt.h" -#include "Surface.h" -#include "Cncf.h" -#include "Patch.h" - -#include -#include -#include -using namespace std; - -class Extension; - -#include "ObjectSelection.h" - -#if defined(MMFEXT) -#define IS_COMPATIBLE(v) (v->mvGetVersion != NULL && (v->mvGetVersion() & MMFBUILD_MASK) >= Extension::MinimumBuild && (v->mvGetVersion() & MMFVERSION_MASK) >= MMFVERSION_20 && ((v->mvGetVersion() & MMFVERFLAG_MASK) & MMFVERFLAG_HOME) == 0) -#elif defined(PROEXT) -#define IS_COMPATIBLE(v) (v->mvGetVersion != NULL && (v->mvGetVersion() & MMFBUILD_MASK) >= Extension::MinimumBuild && (v->mvGetVersion() & MMFVERSION_MASK) >= MMFVERSION_20 && ((v->mvGetVersion() & MMFVERFLAG_MASK) & MMFVERFLAG_PRO) != 0) -#else -#define IS_COMPATIBLE(v) (v->mvGetVersion != NULL && (v->mvGetVersion() & MMFBUILD_MASK) >= Extension::MinimumBuild && (v->mvGetVersion() & MMFVERSION_MASK) >= MMFVERSION_20) -#endif - -#define LinkAction(ID, Function) \ - SDK->ActionFunctions[ID] = Edif::MemberFunctionPointer(&Extension::Function); - -#define LinkCondition(ID, Function) \ - SDK->ConditionFunctions[ID] = Edif::MemberFunctionPointer(&Extension::Function); - -#define LinkExpression(ID, Function) \ - SDK->ExpressionFunctions[ID] = Edif::MemberFunctionPointer(&Extension::Function); - -extern HINSTANCE hInstLib; - -struct RUNDATA; -struct EDITDATA; - -typedef RUNDATA * LPRDATA; -typedef EDITDATA * LPEDATA; - -LPEVENTINFOS2 GetEventInformations(LPEVENTINFOS2 eiPtr, short code); - -namespace Edif -{ - - class SDK - { - public: - - json_value &json; - - SDK (mv * mV, json_value &); - ~SDK (); - - vector ActionInfos; - vector ConditionInfos; - vector ExpressionInfos; - - void ** ActionJumps; - void ** ConditionJumps; - void ** ExpressionJumps; - - vector ActionFunctions; - vector ConditionFunctions; - vector ExpressionFunctions; - - vector ExpressionTypes; - - vector ActionFloatFlags; - vector ConditionFloatFlags; - vector ExpressionFloatFlags; - - unsigned char * FunctionMemory; - - mv* mV; -#ifndef RUN_ONLY - cSurface * Icon; -#endif - }; - - class Runtime - { - protected: - - LPRDATA rdPtr; - - public: - - long param1, param2; - - Runtime(LPRDATA _rdPtr); - ~Runtime(); - - void Rehandle(); - - void GenerateEvent(int EventID); - void PushEvent(int EventID); - - void * Allocate(size_t); - TCHAR * CopyString(const TCHAR *); - - void Pause(); - void Resume(); - - void Redisplay(); - void Redraw(); - LPRO LPROFromFixed(int fixedValue); - int FixedFromLPRO(LPRO object); - - void SetAngleOfObject(LPRO object, float acAngle); - - void SetPosition(int X, int Y); - CallTables* GetCallTables(); - void CallMovement(int ID, long Parameter); - - void Destroy(); - - void GetApplicationDrive(TCHAR * Buffer); - void GetApplicationDirectory(TCHAR * Buffer); - void GetApplicationPath(TCHAR * Buffer); - void GetApplicationName(TCHAR * Buffer); - void GetApplicationTempPath(TCHAR * Buffer); - - void ExecuteProgram(prgParam * Program); - - long EditInteger(EditDebugInfo *); - long EditText(EditDebugInfo *); - - bool IsHWA(); - bool IsUnicode(); - - event &CurrentEvent(); - - Riggs::ObjectSelection ObjectSelection; - - void WriteGlobal(const TCHAR * Name, void * Value); - void * ReadGlobal(const TCHAR * Name); - - #ifdef EdifUseJS - - JSContext * GetJSContext(); - - #endif - - }; - - extern bool ExternalJSON; - - void GetSiblingPath (TCHAR * Buffer, const TCHAR * Extension); - - const int DependencyNotFound = 0; - const int DependencyWasFile = 1; - const int DependencyWasResource = 2; - - int GetDependency (char *& Buffer, size_t &Size, const TCHAR * FileExtension, int Resource); - - TCHAR* ConvertString(const char* urf8String); - TCHAR* ConvertAndCopyString(TCHAR* tstr, const char* urf8String, int maxLength); - inline void FreeString(TCHAR* s) - { - free(s); - } - - extern TCHAR LanguageCode[3]; - extern bool IsEdittime; - - extern HMENU ActionMenu, ConditionMenu, ExpressionMenu; - - HMENU LoadMenuJSON (int BaseID, const json_value &Source, HMENU Parent = 0); - - int Init(mv _far * mV); - void Init(mv _far * mV, LPEDATA edPtr); - - void Free(mv _far * mV); - void Free(LPEDATA edPtr); - - long __stdcall Condition (LPRDATA rdPtr, long param1, long param2); - short __stdcall Action (LPRDATA rdPtr, long param1, long param2); - long __stdcall Expression (LPRDATA rdPtr, long param); - - inline int ActionID(int ID) - { - return 25000 + ID; - } - - inline int ConditionID(int ID) - { - return 26000 + ID; - } - - inline int ExpressionID(int ID) - { - return 27000 + ID; - } - - template inline void * MemberFunctionPointer(T Function) - { - T _Function = Function; - return *(void **) &_Function; - } -} - -extern Edif::SDK * SDK; - - -class Extension; - -struct RUNDATA -{ - //Main header - headerObject rHo; - - char r //Placeholder for the optional structures - [ - sizeof(rCom)+ - sizeof(rMvt)+ - sizeof(rSpr)+ - sizeof(rVal) - ]; - //Pointers to the optional structures, null values mean that that OEFLAG was not specified. - rCom *rc; // Common structure for movements & animations - rMvt *rm; // Movements (OEFLAG_MOVEMENTS) - rSpr *rs; // Sprite (displayable objects) (OEFLAG_SPRITES) - rVal *rv; // Alterable values (OEFLAG_VALUES) - - Extension * pExtension; -}; +#pragma once + +#include "MinGW.hpp" + +#include "json.h" + +#include "ccxhdr.h" +#include "CfcFile.h" +#include "ImageFlt.h" +#include "ImgFlt.h" +#include "Surface.h" +#include "Cncf.h" +#include "Patch.h" + +#include +#include + +class Extension; + +#include "ObjectSelection.h" + +#if defined(MMFEXT) +#define IS_COMPATIBLE(v) (v->mvGetVersion != NULL && (v->mvGetVersion() & MMFBUILD_MASK) >= Extension::MinimumBuild && (v->mvGetVersion() & MMFVERSION_MASK) >= MMFVERSION_20 && ((v->mvGetVersion() & MMFVERFLAG_MASK) & MMFVERFLAG_HOME) == 0) +#elif defined(PROEXT) +#define IS_COMPATIBLE(v) (v->mvGetVersion != NULL && (v->mvGetVersion() & MMFBUILD_MASK) >= Extension::MinimumBuild && (v->mvGetVersion() & MMFVERSION_MASK) >= MMFVERSION_20 && ((v->mvGetVersion() & MMFVERFLAG_MASK) & MMFVERFLAG_PRO) != 0) +#else +#define IS_COMPATIBLE(v) (v->mvGetVersion != NULL && (v->mvGetVersion() & MMFBUILD_MASK) >= Extension::MinimumBuild && (v->mvGetVersion() & MMFVERSION_MASK) >= MMFVERSION_20) +#endif + +#define LinkAction(ID, Function) \ + SDK->ActionFunctions[ID] = Edif::MemberFunctionPointer(&Extension::Function); + +#define LinkCondition(ID, Function) \ + SDK->ConditionFunctions[ID] = Edif::MemberFunctionPointer(&Extension::Function); + +#define LinkExpression(ID, Function) \ + SDK->ExpressionFunctions[ID] = Edif::MemberFunctionPointer(&Extension::Function); + +extern HINSTANCE hInstLib; + +struct RD; +typedef RD RUNDATA; +typedef RUNDATA * LPRDATA; +#ifndef EDIF_PLAIN_EDITDATA +struct SerializedED; +typedef SerializedED EDITDATA; +#else +struct EDITDATA; +typedef EDITDATA SerializedED; +#endif +typedef EDITDATA * LPEDATA; + +LPEVENTINFOS2 GetEventInformations(LPEVENTINFOS2 eiPtr, short code); + +namespace Edif +{ + class SDK + { + public: + + json_value &json; + + SDK (mv * mV, json_value &); + ~SDK (); + + std::vector ActionInfos; + std::vector ConditionInfos; + std::vector ExpressionInfos; + + void ** ActionJumps; + void ** ConditionJumps; + void ** ExpressionJumps; + + std::vector ActionFunctions; + std::vector ConditionFunctions; + std::vector ExpressionFunctions; + + std::vector ExpressionTypes; + + std::vector ActionFloatFlags; + std::vector ConditionFloatFlags; + std::vector ExpressionFloatFlags; + + unsigned char * FunctionMemory; + + mv* mV; +#ifndef RUN_ONLY + cSurface * Icon; +#endif + }; + + class Runtime + { + protected: + + LPRDATA rdPtr; + + public: + + long param1, param2; + + Runtime(LPRDATA _rdPtr); + ~Runtime(); + + void Rehandle(); + + void GenerateEvent(int EventID); + void PushEvent(int EventID); + + void * Allocate(size_t); + TCHAR * CopyString(const TCHAR *); + + void Pause(); + void Resume(); + + void Redisplay(); + void Redraw(); + LPRO LPROFromFixed(int fixedValue); + int FixedFromLPRO(LPRO object); + + void SetAngleOfObject(LPRO object, float acAngle); + + void SetPosition(int X, int Y); + CallTables* GetCallTables(); + void CallMovement(int ID, long Parameter); + + void Destroy(); + + void GetApplicationDrive(TCHAR * Buffer); + void GetApplicationDirectory(TCHAR * Buffer); + void GetApplicationPath(TCHAR * Buffer); + void GetApplicationName(TCHAR * Buffer); + void GetApplicationTempPath(TCHAR * Buffer); + + void ExecuteProgram(prgParam * Program); + + long EditInteger(EditDebugInfo *); + long EditText(EditDebugInfo *); + + bool IsHWA(); + bool IsUnicode(); + + event &CurrentEvent(); + + Riggs::ObjectSelection ObjectSelection; + + void WriteGlobal(const TCHAR * Name, void * Value); + void * ReadGlobal(const TCHAR * Name); + static void WriteGlobal(mv * mV, CRunApp * App, const TCHAR * Name, void * Value); + static void * ReadGlobal(mv * mV, CRunApp * App, const TCHAR * Name); + + #ifdef EdifUseJS + + JSContext * GetJSContext(); + + #endif + + }; + + extern bool ExternalJSON; + + void GetSiblingPath (TCHAR * Buffer, const TCHAR * Extension); + + const int DependencyNotFound = 0; + const int DependencyWasFile = 1; + const int DependencyWasResource = 2; + + int GetDependency (std::vector &Buffer, const TCHAR * FileExtension, int Resource); + + TCHAR* ConvertString(const char* utf8String); + TCHAR* ConvertAndCopyString(TCHAR* tstr, const char* utf8String, int maxLength); + inline void FreeString(TCHAR* s) + { + free(s); + } + + extern TCHAR LanguageCode[3]; + extern bool IsEdittime; + + extern HMENU ActionMenu, ConditionMenu, ExpressionMenu; + + HMENU LoadMenuJSON (int BaseID, const json_value &Source, HMENU Parent = 0); + + int Init(mv _far * mV); + void Init(mv _far * mV, LPEDATA edPtr); + + void Free(mv _far * mV); + void Free(LPEDATA edPtr); + + long __stdcall Condition (LPRDATA rdPtr, long param1, long param2); + short __stdcall Action (LPRDATA rdPtr, long param1, long param2); + long __stdcall Expression (LPRDATA rdPtr, long param); + + inline int ActionID(int ID) + { + return 25000 + ID; + } + + inline int ConditionID(int ID) + { + return 26000 + ID; + } + + inline int ExpressionID(int ID) + { + return 27000 + ID; + } + + template inline void * MemberFunctionPointer(T Function) + { + T _Function = Function; + return *(void **) &_Function; + } +} + +extern Edif::SDK * SDK; + + +class Extension; + +/* RD + * This is the extension runtime data. + * Because all your runtime data is + * stored in your Extension class, this + * class is global to all extensions and + * should not be changed. Some functions + * will give you a pointer to this class, + * and from it you can get a pointer to + * your extension class' instance. + */ +struct RD +{ + headerObject rHo; //Main header + + char r //Placeholder for the optional structures + [ + sizeof(rCom)+ + sizeof(rMvt)+ + sizeof(rSpr)+ + sizeof(rVal) + ]; + +#ifdef RunDataPreInject + PreInjectRD pre; +#endif + + //Pointers to the optional structures, null values mean that that OEFLAG was not specified. + rCom *rc; // Common structure for movements & animations + rMvt *rm; // Movements (OEFLAG_MOVEMENTS) + rSpr *rs; // Sprite (displayable objects) (OEFLAG_SPRITES) + rVal *rv; // Alterable values (OEFLAG_VALUES) + + Extension * pExtension; + + void *ReservedForFutureUseByTheEdifSdk; + +#ifdef RunDataPostInject + PostInjectRD post; +#endif +}; + +#ifndef EDIF_PLAIN_EDITDATA +/* SerializedED + * This is the editdata. The class + * name is a reminder - any data in + * here is fully serialized, ready + * to be written to a file on disk, + * such as the MFA or EXE file. It + * will also be this way when you + * get access to it in other runtimes. + * You should not change this class + * as the change will affect all other + * extensions as well. Instead, open + * EditData.hpp and read about how to + * implement the editdata there. + */ +struct SerializedED +{ + /* Header + * This required data member contains + * information about your extension for + * Fusion, such as the version number + * from Extension::Version. + */ + extHeader Header; + + /* data + * This is used as a pointer to + * the start of the serialized + * data. See the EditData class + * for more information. + */ + char data[1]; +}; +#include "EDStream.hpp" +#endif + +#define MMF2Func WINAPI DLLExport diff --git a/Inc/FilterMgr.h b/Inc/FilterMgr.h index 57a488a..7fc1a66 100644 --- a/Inc/FilterMgr.h +++ b/Inc/FilterMgr.h @@ -17,7 +17,7 @@ class CInputFile; // Filter Manager base class // -#define FILTERID_PNG DWORDSTR('P','N','G',' ') +#define FILTERID_PNG DWORDSTR('P','N','G',' ') // Filter Manager class STDDLL_API CFilterMgr diff --git a/Inc/ImgFlt.h b/Inc/ImgFlt.h index 574459d..4197528 100644 --- a/Inc/ImgFlt.h +++ b/Inc/ImgFlt.h @@ -4,24 +4,22 @@ // Image filters #define IMPORT_IMAGE_USESURFACEDEPTH 0x0001 #define IMPORT_IMAGE_USESURFACEPALETTE 0x0002 + #define IMPORT_IMAGE_FIRSTPIXELTRANSP 0x0004 #define IMPORT_IMAGE_OPAQUE 0x0008 -DLLExport32 BOOL WINAPI ImportImageFromInputFile(CImageFilterMgr* pImgMgr, CInputFile* pf, cSurface* psf, LPDWORD pDWFilterID, DWORD dwFlags); -DLLExport32 BOOL WINAPI GetNextAnimationFrame(CImageFilterMgr* pImgMgr, cSurface* psf, CImageFilter* pFilter); -DLLExport32 void WINAPI EndAnimationImport(CImageFilterMgr* pImgMgr, CImageFilter* pFilter); -DLLExport32 BOOL WINAPI ExportNextFrame(CImageFilterMgr* pImgMgr, cSurface* psf, CImageFilter* pFilter, int msFrameDuration); -DLLExport32 void WINAPI EndAnimationExport(CImageFilterMgr* pImgMgr, CImageFilter* pFilter); - -#ifdef _UNICODE - DLLExport32 BOOL WINAPI ImportImageA(CImageFilterMgr* pImgMgr, LPCSTR fileName, cSurface* psf, LPDWORD pDWFilterID, DWORD dwFlags); +DLLExport32 BOOL WINAPI ImportImageFromInputFile(CImageFilterMgr* pImgMgr, CInputFile* pf, cSurface* psf, LPDWORD pDWFilterID, DWORD dwFlags); DLLExport32 BOOL WINAPI CanImportImageA(CImageFilterMgr* pImgMgr, LPCSTR fileName); DLLExport32 BOOL WINAPI ImportPaletteA(CImageFilterMgr* pImgMgr, LPCSTR fileName, LPLOGPALETTE pPal); DLLExport32 BOOL WINAPI ExportImageA(CImageFilterMgr* pImgMgr, LPCSTR pFileName, cSurface* psf, DWORD dwFilterID); DLLExport32 BOOL WINAPI CanImportAnimationA(CImageFilterMgr* pImgMgr, LPCSTR fileName, BOOL* bNeedConversion); DLLExport32 BOOL WINAPI BeginAnimationImportA(CImageFilterMgr* pImgMgr, LPCSTR pFileName, cSurface* psf, CImageFilter* pFilter, DWORD dwFlags); +DLLExport32 BOOL WINAPI GetNextAnimationFrame(CImageFilterMgr* pImgMgr, cSurface* psf, CImageFilter* pFilter); +DLLExport32 void WINAPI EndAnimationImport(CImageFilterMgr* pImgMgr, CImageFilter* pFilter); DLLExport32 BOOL WINAPI BeginAnimationExportA(CImageFilterMgr* pImgMgr, LPCSTR pFileName, cSurface* psf, CImageFilter* pFilter, int nFrames, int msFrameDuration, int nLoopCount, int nLoopFrame); +DLLExport32 BOOL WINAPI ExportNextFrame(CImageFilterMgr* pImgMgr, cSurface* psf, CImageFilter* pFilter, int msFrameDuration); +DLLExport32 void WINAPI EndAnimationExport(CImageFilterMgr* pImgMgr, CImageFilter* pFilter); DLLExport32 BOOL WINAPI ImportImageW(CImageFilterMgr* pImgMgr, LPCWSTR fileName, cSurface* psf, LPDWORD pDWFilterID, DWORD dwFlags); DLLExport32 BOOL WINAPI CanImportImageW(CImageFilterMgr* pImgMgr, LPCWSTR fileName); @@ -31,6 +29,7 @@ DLLExport32 BOOL WINAPI CanImportAnimationW(CImageFilterMgr* pImgMgr, LPCWSTR fi DLLExport32 BOOL WINAPI BeginAnimationImportW(CImageFilterMgr* pImgMgr, LPCWSTR pFileName, cSurface* psf, CImageFilter* pFilter, DWORD dwFlags); DLLExport32 BOOL WINAPI BeginAnimationExportW(CImageFilterMgr* pImgMgr, LPCWSTR pFileName, cSurface* psf, CImageFilter* pFilter, int nFrames, int msFrameDuration, int nLoopCount, int nLoopFrame); +#ifdef _UNICODE #define ImportImage ImportImageW #define CanImportImage CanImportImageW #define ImportPalette ImportPaletteW @@ -38,25 +37,14 @@ DLLExport32 BOOL WINAPI BeginAnimationExportW(CImageFilterMgr* pImgMgr, LPCWSTR #define CanImportAnimation CanImportAnimationW #define BeginAnimationImport BeginAnimationImportW #define BeginAnimationExport BeginAnimationExportW - #else - -DLLExport32 BOOL WINAPI ImportImage(CImageFilterMgr* pImgMgr, LPCSTR fileName, cSurface* psf, LPDWORD pDWFilterID, DWORD dwFlags); -DLLExport32 BOOL WINAPI CanImportImage(CImageFilterMgr* pImgMgr, LPCSTR fileName); -DLLExport32 BOOL WINAPI ImportPalette(CImageFilterMgr* pImgMgr, LPCSTR fileName, LPLOGPALETTE pPal); -DLLExport32 BOOL WINAPI ExportImage(CImageFilterMgr* pImgMgr, LPCSTR pFileName, cSurface* psf, DWORD dwFilterID); -DLLExport32 BOOL WINAPI CanImportAnimation(CImageFilterMgr* pImgMgr, LPCSTR fileName, BOOL* bNeedConversion); -DLLExport32 BOOL WINAPI BeginAnimationImport(CImageFilterMgr* pImgMgr, LPCSTR pFileName, cSurface* psf, CImageFilter* pFilter, DWORD dwFlags); -DLLExport32 BOOL WINAPI BeginAnimationExport(CImageFilterMgr* pImgMgr, LPCSTR pFileName, cSurface* psf, CImageFilter* pFilter, int nFrames, int msFrameDuration, int nLoopCount, int nLoopFrame); - -#define ImportImageA ImportImage -#define CanImportImageA CanImportImage -#define ImportPaletteA ImportPalette -#define ExportImageA ExportImage -#define CanImportAnimationA CanImportAnimation -#define BeginAnimationImportA BeginAnimationImport -#define BeginAnimationExportA BeginAnimationExport - +#define ImportImage ImportImageA +#define CanImportImage CanImportImageA +#define ImportPalette ImportPaletteA +#define ExportImage ExportImageA +#define CanImportAnimation CanImportAnimationA +#define BeginAnimationImport BeginAnimationImportA +#define BeginAnimationExport BeginAnimationExportA #endif // Picture selector diff --git a/Inc/MinGW.hpp b/Inc/MinGW.hpp new file mode 100644 index 0000000..b60c844 --- /dev/null +++ b/Inc/MinGW.hpp @@ -0,0 +1,238 @@ +#if !defined(MinGWSupport_HeaderPlusPlus) && defined(__MINGW32__) +#define MinGWSupport_HeaderPlusPlus + +#include +#include +#include +#include +#include +#include +#include + +inline int fopen_s(FILE **f, char const *filename, char const *mode) +{ + if(FILE *t = fopen(filename, mode)) + { + *f = t; + return 0; + } + return -1; +} +inline int _wfopen_s(FILE **f, wchar_t const *filename, wchar_t const *mode) +{ + //unfortunately is not yet supported in libstdc++ + //so we have to use WinAPI + int flags = WC_COMPOSITECHECK|WC_NO_BEST_FIT_CHARS; + int fnbs = WideCharToMultiByte(CP_UTF8, flags, filename, -1, 0, 0, 0, 0); + int mdbs = WideCharToMultiByte(CP_UTF8, flags, mode, -1, 0, 0, 0, 0); + + std::unique_ptr fn {new char[fnbs+1]}; + std::unique_ptr md {new char[mdbs+1]}; + + if(!WideCharToMultiByte(CP_UTF8, flags, filename, -1, fn.get(), fnbs+1, 0, 0) + || !WideCharToMultiByte(CP_UTF8, flags, mode, -1, md.get(), mdbs+1, 0, 0)) + { + return -1; + } + return fopen_s(f, fn.get(), md.get()); +} +#ifdef UNICODE + #define _tfopen_s _wfopen_s +#else + #define _tfopen_s fopen_s +#endif + +#define off64_t _off64_t +#define _near +#define _far +#define DLLExport32 +#define DLLExport + +inline char *_strdup(char const *str) +{ + return strcpy((char *)malloc(strlen(str)), str); +} +inline wchar_t *_wcsdup(wchar_t const *str) +{ + wchar_t *t = (wchar_t *)malloc((std::find(str, str-1, L'\0')-str)*sizeof(wchar_t)); + std::copy(str, std::find(str, str-1, L'\0')+1, t); + return t; +} +#ifdef UNICODE + #define _tcsdup _wcsdup +#else + #define _tcsdup _strdup +#endif + +inline int _stricmp(char const *s1, char const *s2) +{ + char const *s1e = s1+strlen(s1); + char const *s2e = s2+strlen(s2); + if(std::lexicographical_compare(s1, s1e, s2, s2e, [](char a, char b) -> bool + { + std::tolower(a) == std::tolower(b); + })) return 0; + if(std::lexicographical_compare(s1, s1e, s2, s2e, [](char a, char b) -> bool + { + std::tolower(a) < std::tolower(b); + })) return -1; + return 1; +} +inline int _strnicmp(char const *s1, char const *s2, std::size_t n) +{ + char const *s1e = s1+std::min(strlen(s1), n); + char const *s2e = s2+std::min(strlen(s2), n); + if(std::lexicographical_compare(s1, s1e, s2, s2e, [](char a, char b) -> bool + { + std::tolower(a) == std::tolower(b); + })) return 0; + if(std::lexicographical_compare(s1, s1e, s2, s2e, [](char a, char b) -> bool + { + std::tolower(a) < std::tolower(b); + })) return -1; + return 1; +} + +#define _MAX_PATH 260 +#define _MAX_DRIVE 3 +#define _MAX_DIR 256 +#define _MAX_FNAME 256 +#define _MAX_EXT 256 +inline void _splitpath(char const *path, char *drive, char *dir, char *fname, char *ext) +{ + char const *pend = path+strlen(path); + char const *pd = "\\/"; + if(drive) + { + char const *r = std::find(path, pend, ':'); + if(r == pend) drive[0] = '\0'; + else strncpy(drive, path, std::min((r+1)-path, _MAX_DRIVE)); + } + if(dir) + { + char const *r1 = std::find_first_of(path, pend, pd, pd+2); + if(r1 == pend) dir[0] = '\0'; + else + { + char const *r2 = std::find_first_of(std::reverse_iterator(pend), + std::reverse_iterator(path), + pd, pd+2).base(); + if(r2-r1+1 > _MAX_DIR) + { + r2 = r1 + _MAX_DIR; + } + std::copy(r1, r2+1, dir); + } + } + if(fname) + { + char const *r1 = std::find_first_of(std::reverse_iterator(pend), + std::reverse_iterator(path), + pd, pd+2).base(); + if(r1 == path-1) r1 = path; + char const *r2 = std::find(std::reverse_iterator(pend), + std::reverse_iterator(path), + '.').base(); + if(r2 == path-1) r2 = pend-1; + if(r2-r1+1 > _MAX_FNAME) + { + r2 = r1 + _MAX_FNAME; + } + std::copy(r1, r2+1, fname); + } + if(ext) + { + char const *r = std::find(std::reverse_iterator(pend), + std::reverse_iterator(path), + '.').base(); + if(r == path-1) ext[0] = '\0'; + else + { + char const *r2 = pend-1; + if(r2-r+1 > _MAX_EXT) + { + r2 = r + _MAX_EXT; + } + std::copy(r, r2+1, ext); + } + } +} +inline void _wsplitpath(wchar_t const *path, wchar_t *drive, wchar_t *dir, wchar_t *fname, wchar_t *ext) +{ + wchar_t const *pend = std::find(path, path-1, L'\0'); + wchar_t const *pd = L"\\/"; + if(drive) + { + wchar_t const *r = std::find(path, pend, L':'); + if(r == pend) drive[0] = L'\0'; + else + { + if(r-path+1 > _MAX_DRIVE) + { + r = path + _MAX_DRIVE; + } + std::copy(path, r+1, drive); + } + } + if(dir) + { + wchar_t const *r1 = std::find_first_of(path, pend, pd, pd+2); + if(r1 == pend) dir[0] = L'\0'; + else + { + wchar_t const *r2 = std::find_first_of(std::reverse_iterator(pend), + std::reverse_iterator(path), + pd, pd+2).base(); + if(r2-r1+1 > _MAX_DIR) + { + r2 = r1 + _MAX_DIR; + } + std::copy(r1, r2+1, dir); + } + } + if(fname) + { + wchar_t const *r1 = std::find_first_of(std::reverse_iterator(pend), + std::reverse_iterator(path), + pd, pd+2).base(); + if(r1 == path-1) r1 = path; + wchar_t const *r2 = std::find(std::reverse_iterator(pend), + std::reverse_iterator(path), + L'.').base(); + if(r2 == path-1) r2 = pend-1; + if(r2-r1+1 > _MAX_FNAME) + { + r2 = r1 + _MAX_FNAME; + } + std::copy(r1, r2+1, fname); + } + if(ext) + { + wchar_t const *r = std::find(std::reverse_iterator(pend), + std::reverse_iterator(path), + L'.').base(); + if(r == path-1) ext[0] = L'\0'; + else + { + wchar_t const *r2 = pend-1; + if(r2-r+1 > _MAX_EXT) + { + r2 = r + _MAX_EXT; + } + std::copy(r, r2+1, ext); + } + } +} + +template +int sprintf_s(char *buf, std::size_t bs, char const *f, Args... args) +{ + return snprintf(buf, bs, f, args...); +} +#ifdef UNICODE + #define _stprintf_s swprintf_s +#else + #define _stprintf_s sprintf_s +#endif + +#endif diff --git a/Inc/Mvt.h b/Inc/Mvt.h index 1685210..4348df8 100644 --- a/Inc/Mvt.h +++ b/Inc/Mvt.h @@ -128,6 +128,7 @@ typedef CMvt * LPMVT; // #define RUNMVT_VERSION_1 0x0001 +#define RUNMVT_VERSION_2 0x0002 // GetDir + Debugger functions /** * Movement Data at runtime. @@ -149,7 +150,7 @@ class CRunMvt { virtual void Delete(void) { delete this; } // Version - virtual int GetVersion() { return RUNMVT_VERSION_1; } + virtual int GetVersion() { return RUNMVT_VERSION_2; } virtual BOOL Move(LPHO pHo) { return FALSE; } virtual void SetPosition(LPHO pHo, int x, int y) {} @@ -175,6 +176,14 @@ class CRunMvt { virtual int GetDeceleration(LPHO hoPtr) {return 0;} virtual int GetGravity(LPHO hoPtr) {return 0;} + // Version 2 + virtual int GetDir(LPHO hoPtr) {return 0;} + + // Debugger + virtual LPWORD GetDebugTree() { return NULL; } + virtual void GetDebugItem(LPTSTR pBuffer, int id) {} + virtual void EditDebugItem(int id) {} + // End of public interface ////////////////////////// diff --git a/Inc/ObjectSelection.h b/Inc/ObjectSelection.h index f9d5714..9c572be 100644 --- a/Inc/ObjectSelection.h +++ b/Inc/ObjectSelection.h @@ -1,6 +1,5 @@ - // By Anders Riggelsen (Andos) -// http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Number=214148&gonew=1 +// http://community.clickteam.com/showthread.php?t=61672 // These files do not match up with the originals - modified for Edif (callbacks inside the extension class, etc..) @@ -16,11 +15,11 @@ namespace Riggs { - class ObjectSelection - { - public: + class ObjectSelection + { + public: - Extension * pExtension; + Extension * pExtension; ObjectSelection(LPRH rhPtr); diff --git a/Inc/Patch.h b/Inc/Patch.h index 6f8a2c2..57bfe6c 100644 --- a/Inc/Patch.h +++ b/Inc/Patch.h @@ -3,68 +3,68 @@ class MemoryLock { protected: - DWORD OldProtect; + DWORD OldProtect; - void * Address; - size_t Size; + void * Address; + size_t Size; public: - const char * Error; + const char * Error; - inline MemoryLock(void * Address, size_t Size) - { - Error = 0; + inline MemoryLock(void * Address, size_t Size) + { + Error = 0; - this->Address = Address; - this->Size = Size; + this->Address = Address; + this->Size = Size; - if(!VirtualProtectEx(GetCurrentProcess(), Address, Size, PAGE_EXECUTE_READWRITE, &OldProtect)) - { - Error = "Failed to change memory protection"; - return; - } - } + if(!VirtualProtectEx(GetCurrentProcess(), Address, Size, PAGE_EXECUTE_READWRITE, &OldProtect)) + { + Error = "Failed to change memory protection"; + return; + } + } - inline ~MemoryLock() - { - if(Error) - return; + inline ~MemoryLock() + { + if(Error) + return; - DWORD Unused; - VirtualProtectEx(GetCurrentProcess(), Address, Size, OldProtect, &Unused); - } + DWORD Unused; + VirtualProtectEx(GetCurrentProcess(), Address, Size, OldProtect, &Unused); + } - + }; class Patch { public: - const char * Error; + const char * Error; - inline Patch(void * Address, const char * Old, const char * New, size_t Size) - { - Error = 0; + inline Patch(void * Address, const char * Old, const char * New, size_t Size) + { + Error = 0; - { MemoryLock Lock(Address, Size); + { MemoryLock Lock(Address, Size); - if(Lock.Error) - { - Error = Lock.Error; - return; - } + if(Lock.Error) + { + Error = Lock.Error; + return; + } - if(memcmp(Address, Old, Size)) - { - Error = "Old memory isn't as expected - wrong version?"; - return; - } + if(memcmp(Address, Old, Size)) + { + Error = "Old memory isn't as expected - wrong version?"; + return; + } - memcpy(Address, New, Size); - } - } + memcpy(Address, New, Size); + } + } }; diff --git a/Inc/Props.h b/Inc/Props.h index 2c9750c..a40ccc5 100644 --- a/Inc/Props.h +++ b/Inc/Props.h @@ -10,8 +10,8 @@ typedef struct PropData { int dwID; // Identifier - UINT_PTR sName; // Name = ID of the property name in the resources, or LPCSTR - UINT_PTR sInfo; // Info = ID of the property description in the resources, or LPCSTR + UINT_PTR sName; // Name = ID of the property name in the resources, or LPCSTR / LPCTSTR + UINT_PTR sInfo; // Info = ID of the property description in the resources, or LPCSTR / LPCTSTR UINT_PTR lType; // Property type, or pointer to CPropItem (custom properties) DWORD dwOptions; // Options (check box, bold, etc) LPARAM lCreateParam; // Parameter @@ -293,16 +293,14 @@ class CPropAStringValue : public CPropValue m_pStr = _strdup(pStr); m_unused = 0; } - CPropAStringValue(LPCWSTR pWStr) { + CPropAStringValue(LPCWSTR pWStr, UINT codePage = CP_ACP) { if ( pWStr == NULL ) m_pStr = _strdup(""); else { - // m_pStr = _strdup(pStr); - int lg = wcslen(pWStr); - m_pStr = (LPSTR)calloc(lg+1, 1); // TODO : change that if we use something else than CP_ACP - WideCharToMultiByte(CP_ACP, 0, pWStr, lg, m_pStr, lg, NULL, NULL); - m_pStr[lg] = 0; + int lg = WideCharToMultiByte(codePage, 0, pWStr, -1, 0, 0, NULL, NULL); + m_pStr = (LPSTR)calloc(lg+1, 1); // +1 = security if lg = 0 for some reason + WideCharToMultiByte(codePage, 0, pWStr, -1, m_pStr, lg, NULL, NULL); } m_unused = 0; } @@ -349,16 +347,14 @@ class CPropWStringValue : public CPropValue m_pWStr = _wcsdup(pWStr); m_unused = 0; } - CPropWStringValue(LPCSTR pStr) { + CPropWStringValue(LPCSTR pStr, UINT codePage = CP_ACP) { if ( pStr == NULL ) m_pWStr = _wcsdup(L""); else { - // m_pStr = _strdup(pStr); - int lg = strlen(pStr); - m_pWStr = (LPWSTR)calloc(lg+1, sizeof(wchar_t)); - MultiByteToWideChar(CP_ACP, 0, pStr, lg, m_pWStr, lg); - m_pWStr[lg] = 0; + int lg = MultiByteToWideChar(codePage, 0, pStr, -1, 0, 0); + m_pWStr = (LPWSTR)calloc(lg+1, sizeof(wchar_t)); // +1 = security if lg = 0 for some reason + MultiByteToWideChar(codePage, 0, pStr, -1, m_pWStr, lg); } m_unused = 0; } @@ -480,35 +476,125 @@ typedef struct _NMPROPWND * List of property types. */ enum { - PROPTYPE_STATIC = 1, //! Simple static text - PROPTYPE_FOLDER, //! Folder - PROPTYPE_FOLDER_END, //! Folder End - PROPTYPE_EDITBUTTON, //! Edit button, param1 = button text, or NULL if Edit - PROPTYPE_EDIT_STRING, //! Edit box for strings, parameter = max length - PROPTYPE_EDIT_NUMBER, //! Edit box for numbers, parameters = min value, max value - PROPTYPE_COMBOBOX, //! Combo box, parameters = list of strings, options (sorted, etc) - PROPTYPE_SIZE, //! Size - PROPTYPE_COLOR, //! Color - PROPTYPE_LEFTCHECKBOX, //! Checkbox - PROPTYPE_SLIDEREDIT, //! Edit + Slider - PROPTYPE_SPINEDIT, //! Edit + Spin - PROPTYPE_DIRCTRL, //! Direction Selector - PROPTYPE_GROUP, //! Group - PROPTYPE_LISTBTN, //! Internal, do not use - PROPTYPE_FILENAME, //! Edit box + browse file button, parameter = FilenameCreateParam - PROPTYPE_FONT, //! Font dialog box - PROPTYPE_CUSTOM, //! Custom property - PROPTYPE_PICTUREFILENAME, //! Edit box + browse image file button - PROPTYPE_COMBOBOXBTN, //! Combo box, parameters = list of strings, options (sorted, etc) - PROPTYPE_EDIT_FLOAT, //! Edit box for floating point numbers, parameters = min value, max value, options (signed, float, spin) - PROPTYPE_EDIT_MULTILINE, //! Edit box for multiline texts, no parameter - PROPTYPE_IMAGELIST, //! Image list - PROPTYPE_ICONCOMBOBOX, //! Combo box with icons - PROPTYPE_URLBUTTON, //! URL button - PROPTYPE_DIRECTORYNAME, //! Directory pathname - PROPTYPE_SPINEDITFLOAT, //! Edit + Spin, value = floating point number + PROPTYPE_STATIC_A = 1, //! Simple static text + PROPTYPE_FOLDER_A, //! Folder + PROPTYPE_FOLDER_END_A, //! Folder End + PROPTYPE_EDITBUTTON_A, //! Edit button, param1 = button text, or NULL if Edit + PROPTYPE_EDIT_STRING_A, //! Edit box for strings, parameter = max length + PROPTYPE_EDIT_NUMBER_A, //! Edit box for numbers, parameters = min value, max value + PROPTYPE_COMBOBOX_A, //! Combo box, parameters = list of strings, options (sorted, etc) + PROPTYPE_SIZE_A, //! Size + PROPTYPE_COLOR_A, //! Color + PROPTYPE_LEFTCHECKBOX_A, //! Checkbox + PROPTYPE_SLIDEREDIT_A, //! Edit + Slider + PROPTYPE_SPINEDIT_A, //! Edit + Spin + PROPTYPE_DIRCTRL_A, //! Direction Selector + PROPTYPE_GROUP_A, //! Group + PROPTYPE_LISTBTN_A, //! Internal, do not use + PROPTYPE_FILENAME_A, //! Edit box + browse file button, parameter = FilenameCreateParam + PROPTYPE_FONT_A, //! Font dialog box + PROPTYPE_CUSTOM_A, //! Custom property + PROPTYPE_PICTUREFILENAME_A, //! Edit box + browse image file button + PROPTYPE_COMBOBOXBTN_A, //! Combo box, parameters = list of strings, options (sorted, etc) + PROPTYPE_EDIT_FLOAT_A, //! Edit box for floating point numbers, parameters = min value, max value, options (signed, float, spin) + PROPTYPE_EDIT_MULTILINE_A, //! Edit box for multiline texts, no parameter + PROPTYPE_IMAGELIST_A, //! Image list + PROPTYPE_ICONCOMBOBOX_A, //! Combo box with icons + PROPTYPE_URLBUTTON_A, //! URL button + PROPTYPE_DIRECTORYNAME_A, //! Directory pathname + PROPTYPE_SPINEDITFLOAT_A, //! Edit + Spin, value = floating point number + + PROPTYPE_STATIC_W = 1001, //! Simple static text + PROPTYPE_FOLDER_W, //! Folder + PROPTYPE_FOLDER_END_W, //! Folder End + PROPTYPE_EDITBUTTON_W, //! Edit button, param1 = button text, or NULL if Edit + PROPTYPE_EDIT_STRING_W, //! Edit box for strings, parameter = max length + PROPTYPE_EDIT_NUMBER_W, //! Edit box for numbers, parameters = min value, max value + PROPTYPE_COMBOBOX_W, //! Combo box, parameters = list of strings, options (sorted, etc) + PROPTYPE_SIZE_W, //! Size + PROPTYPE_COLOR_W, //! Color + PROPTYPE_LEFTCHECKBOX_W, //! Checkbox + PROPTYPE_SLIDEREDIT_W, //! Edit + Slider + PROPTYPE_SPINEDIT_W, //! Edit + Spin + PROPTYPE_DIRCTRL_W, //! Direction Selector + PROPTYPE_GROUP_W, //! Group + PROPTYPE_LISTBTN_W, //! Internal, do not use + PROPTYPE_FILENAME_W, //! Edit box + browse file button, parameter = FilenameCreateParam + PROPTYPE_FONT_W, //! Font dialog box + PROPTYPE_CUSTOM_W, //! Custom property + PROPTYPE_PICTUREFILENAME_W, //! Edit box + browse image file button + PROPTYPE_COMBOBOXBTN_W, //! Combo box, parameters = list of strings, options (sorted, etc) + PROPTYPE_EDIT_FLOAT_W, //! Edit box for floating point numbers, parameters = min value, max value, options (signed, float, spin) + PROPTYPE_EDIT_MULTILINE_W, //! Edit box for multiline texts, no parameter + PROPTYPE_IMAGELIST_W, //! Image list + PROPTYPE_ICONCOMBOBOX_W, //! Combo box with icons + PROPTYPE_URLBUTTON_W, //! URL button + PROPTYPE_DIRECTORYNAME_W, //! Directory pathname + PROPTYPE_SPINEDITFLOAT_W, //! Edit + Spin, value = floating point number }; +#ifdef _UNICODE + +#define PROPTYPE_STATIC PROPTYPE_STATIC_W +#define PROPTYPE_FOLDER PROPTYPE_FOLDER_W +#define PROPTYPE_FOLDER_END PROPTYPE_FOLDER_END_W +#define PROPTYPE_EDITBUTTON PROPTYPE_EDITBUTTON_W +#define PROPTYPE_EDIT_STRING PROPTYPE_EDIT_STRING_W +#define PROPTYPE_EDIT_NUMBER PROPTYPE_EDIT_NUMBER_W +#define PROPTYPE_COMBOBOX PROPTYPE_COMBOBOX_W +#define PROPTYPE_SIZE PROPTYPE_SIZE_W +#define PROPTYPE_COLOR PROPTYPE_COLOR_W +#define PROPTYPE_LEFTCHECKBOX PROPTYPE_LEFTCHECKBOX_W +#define PROPTYPE_SLIDEREDIT PROPTYPE_SLIDEREDIT_W +#define PROPTYPE_SPINEDIT PROPTYPE_SPINEDIT_W +#define PROPTYPE_DIRCTRL PROPTYPE_DIRCTRL_W +#define PROPTYPE_GROUP PROPTYPE_GROUP_W +#define PROPTYPE_LISTBTN PROPTYPE_LISTBTN_W +#define PROPTYPE_FILENAME PROPTYPE_FILENAME_W +#define PROPTYPE_FONT PROPTYPE_FONT_W +#define PROPTYPE_CUSTOM PROPTYPE_CUSTOM_W +#define PROPTYPE_PICTUREFILENAME PROPTYPE_PICTUREFILENAME_W +#define PROPTYPE_COMBOBOXBTN PROPTYPE_COMBOBOXBTN_W +#define PROPTYPE_EDIT_FLOAT PROPTYPE_EDIT_FLOAT_W +#define PROPTYPE_EDIT_MULTILINE PROPTYPE_EDIT_MULTILINE_W +#define PROPTYPE_IMAGELIST PROPTYPE_IMAGELIST_W +#define PROPTYPE_ICONCOMBOBOX PROPTYPE_ICONCOMBOBOX_W +#define PROPTYPE_URLBUTTON PROPTYPE_URLBUTTON_W +#define PROPTYPE_DIRECTORYNAME PROPTYPE_DIRECTORYNAME_W +#define PROPTYPE_SPINEDITFLOAT PROPTYPE_SPINEDITFLOAT_W + +#else + +#define PROPTYPE_STATIC PROPTYPE_STATIC_A +#define PROPTYPE_FOLDER PROPTYPE_FOLDER_A +#define PROPTYPE_FOLDER_END PROPTYPE_FOLDER_END_A +#define PROPTYPE_EDITBUTTON PROPTYPE_EDITBUTTON_A +#define PROPTYPE_EDIT_STRING PROPTYPE_EDIT_STRING_A +#define PROPTYPE_EDIT_NUMBER PROPTYPE_EDIT_NUMBER_A +#define PROPTYPE_COMBOBOX PROPTYPE_COMBOBOX_A +#define PROPTYPE_SIZE PROPTYPE_SIZE_A +#define PROPTYPE_COLOR PROPTYPE_COLOR_A +#define PROPTYPE_LEFTCHECKBOX PROPTYPE_LEFTCHECKBOX_A +#define PROPTYPE_SLIDEREDIT PROPTYPE_SLIDEREDIT_A +#define PROPTYPE_SPINEDIT PROPTYPE_SPINEDIT_A +#define PROPTYPE_DIRCTRL PROPTYPE_DIRCTRL_A +#define PROPTYPE_GROUP PROPTYPE_GROUP_A +#define PROPTYPE_LISTBTN PROPTYPE_LISTBTN_A +#define PROPTYPE_FILENAME PROPTYPE_FILENAME_A +#define PROPTYPE_FONT PROPTYPE_FONT_A +#define PROPTYPE_CUSTOM PROPTYPE_CUSTOM_A +#define PROPTYPE_PICTUREFILENAME PROPTYPE_PICTUREFILENAME_A +#define PROPTYPE_COMBOBOXBTN PROPTYPE_COMBOBOXBTN_A +#define PROPTYPE_EDIT_FLOAT PROPTYPE_EDIT_FLOAT_A +#define PROPTYPE_EDIT_MULTILINE PROPTYPE_EDIT_MULTILINE_A +#define PROPTYPE_IMAGELIST PROPTYPE_IMAGELIST_A +#define PROPTYPE_ICONCOMBOBOX PROPTYPE_ICONCOMBOBOX_A +#define PROPTYPE_URLBUTTON PROPTYPE_URLBUTTON_A +#define PROPTYPE_DIRECTORYNAME PROPTYPE_DIRECTORYNAME_A +#define PROPTYPE_SPINEDITFLOAT PROPTYPE_SPINEDITFLOAT_A + +#endif + /////////////////// // Property options /////////////////// @@ -528,6 +614,8 @@ enum { #define PROPOPT_EDIT_LOWERCASE 0x00020000 // For Edit String property #define PROPOPT_EDIT_UPPERCASE 0x00040000 // For Edit String property +#define PROPOPT_COMBO_SORT 0x00010000 // For Combo / Icon Combo properties + // Internal, not used by extensions #define PROPID_ROOT 0 @@ -535,82 +623,315 @@ enum { // Property definition macros ///////////////////////////// // -#define PropData_Folder(id,name,info) {id,name,info,PROPTYPE_FOLDER,PROPOPT_NIL,(LPARAM)NULL} -#define PropData_Folder_End() {-1,0,0,PROPTYPE_FOLDER_END,PROPOPT_NIL,(LPARAM)NULL} -#define PropData_Group(id,name,info) {id,name,info,PROPTYPE_GROUP,PROPOPT_NIL,(LPARAM)NULL} -#define PropData_StaticString(id,name,info) {id,name,info,PROPTYPE_STATIC,PROPOPT_NIL,(LPARAM)NULL} -#define PropData_StaticString_Opt(id,name,info,opt) {id,name,info,PROPTYPE_STATIC,opt,(LPARAM)NULL} -#define PropData_StaticString_List(id,name,info) {id,name,info,PROPTYPE_STATIC,PROPOPT_LIST,(LPARAM)NULL} -#define PropData_EditString(id,name,info) {id,name,info,PROPTYPE_EDIT_STRING,PROPOPT_NIL,(LPARAM)NULL} -#define PropData_EditString_Check(id,name,info) {id,name,info,PROPTYPE_EDIT_STRING,PROPOPT_CHECKBOX,(LPARAM)NULL} -#define PropData_EditString_Opt(id,name,info,opt) {id,name,info,PROPTYPE_EDIT_STRING,opt,(LPARAM)NULL} -#define PropData_EditNumber(id,name,info) {id,name,info,PROPTYPE_EDIT_NUMBER,PROPOPT_NIL,(LPARAM)NULL} -#define PropData_EditNumber_Check(id,name,info) {id,name,info,PROPTYPE_EDIT_NUMBER,PROPOPT_CHECKBOX,(LPARAM)NULL} -#define PropData_EditNumber_Opt(id,name,info,opt) {id,name,info,PROPTYPE_EDIT_NUMBER,opt,(LPARAM)NULL} -#define PropData_EditFloat(id,name,info) {id,name,info,PROPTYPE_EDIT_FLOAT,PROPOPT_NIL,(LPARAM)NULL} -#define PropData_EditFloat_Check(id,name,info) {id,name,info,PROPTYPE_EDIT_FLOAT,PROPOPT_CHECKBOX,(LPARAM)NULL} -#define PropData_EditFloat_Opt(id,name,info,opt) {id,name,info,PROPTYPE_EDIT_FLOAT,opt,(LPARAM)NULL} -#define PropData_EditMultiLine(id,name,info) {id,name,info,PROPTYPE_EDIT_MULTILINE,PROPOPT_NIL,(LPARAM)NULL} -#define PropData_EditMultiLine_Check(id,name,info) {id,name,info,PROPTYPE_EDIT_MULTILINE,PROPOPT_CHECKBOX,(LPARAM)NULL} -#define PropData_EditMultiLine_Opt(id,name,info,opt) {id,name,info,PROPTYPE_EDIT_MULTILINE,opt,(LPARAM)NULL} -#define PropData_SliderEdit(id,name,info,minmax) {id,name,info,PROPTYPE_SLIDEREDIT,PROPOPT_PARAMREQUIRED,(LPARAM)minmax} -#define PropData_SliderEdit_Check(id,name,info,minmax) {id,name,info,PROPTYPE_SLIDEREDIT,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)minmax} -#define PropData_SliderEdit_Opt(id,name,info,opt,minmax) {id,name,info,PROPTYPE_SLIDEREDIT,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)minmax} -#define PropData_SpinEdit(id,name,info,minmax) {id,name,info,PROPTYPE_SPINEDIT,PROPOPT_PARAMREQUIRED,(LPARAM)minmax} -#define PropData_SpinEdit_Check(id,name,info,minmax) {id,name,info,PROPTYPE_SPINEDIT,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)minmax} -#define PropData_SpinEdit_Opt(id,name,info,opt,minmax) {id,name,info,PROPTYPE_SPINEDIT,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)minmax} -#define PropData_Button(id,name,info,text) {id,name,info,PROPTYPE_EDITBUTTON,PROPOPT_NIL, (LPARAM)text} -#define PropData_Button_Check(id,name,info,text) {id,name,info,PROPTYPE_EDITBUTTON,PROPOPT_CHECKBOX,(LPARAM)text} -#define PropData_Button_Opt(id,name,info,opt,text) {id,name,info,PROPTYPE_EDITBUTTON,opt,(LPARAM)text} -#define PropData_EditButton(id,name,info) {id,name,info,PROPTYPE_EDITBUTTON,PROPOPT_NIL, (LPARAM)NULL} -#define PropData_EditButton_Check(id,name,info) {id,name,info,PROPTYPE_EDITBUTTON,PROPOPT_CHECKBOX,(LPARAM)NULL} -#define PropData_EditButton_Opt(id,name,info,opt) {id,name,info,PROPTYPE_EDITBUTTON,opt,(LPARAM)NULL} -#define PropData_Size(id,name,info,tab) {id,name,info,PROPTYPE_SIZE,PROPOPT_PARAMREQUIRED,(LPARAM)tab} -#define PropData_Size_Check(id,name,info,tab) {id,name,info,PROPTYPE_SIZE,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)tab} -#define PropData_Size_Opt(id,name,info,opt,tab) {id,name,info,PROPTYPE_SIZE,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)tab} -#define PropData_Color(id,name,info) {id,name,info,PROPTYPE_COLOR,PROPOPT_NIL,(LPARAM)NULL} -#define PropData_Color_Check(id,name,info) {id,name,info,PROPTYPE_COLOR,PROPOPT_CHECKBOX,(LPARAM)NULL} -#define PropData_Color_Opt(id,name,info,opt) {id,name,info,PROPTYPE_COLOR,opt,(LPARAM)NULL} -#define PropData_ComboBox(id,name,info,list) {id,name,info,PROPTYPE_COMBOBOX,PROPOPT_PARAMREQUIRED,(LPARAM)list} -#define PropData_ComboBox_Check(id,name,info,list) {id,name,info,PROPTYPE_COMBOBOX,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)list} -#define PropData_ComboBox_Opt(id,name,info,opt,list) {id,name,info,PROPTYPE_COMBOBOX,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)list} -#define PropData_CheckBox(id,name,info) {id,name,info,PROPTYPE_LEFTCHECKBOX,PROPOPT_CHECKBOX,(LPARAM)NULL} -#define PropData_CheckBox_Opt(id,name,info,opt) {id,name,info,PROPTYPE_LEFTCHECKBOX,(PROPOPT_CHECKBOX|opt),(LPARAM)NULL} -#define PropData_DirCtrl(id,name,info,param) {id,name,info,PROPTYPE_DIRCTRL,PROPOPT_PARAMREQUIRED,(LPARAM)param} -#define PropData_DirCtrl_Check(id,name,info,param) {id,name,info,PROPTYPE_DIRCTRL,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)param} -#define PropData_DirCtrl_Opt(id,name,info,opt,param) {id,name,info,PROPTYPE_DIRCTRL,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)param} -#define PropData_Filename(id,name,info,param) {id,name,info,PROPTYPE_FILENAME,PROPOPT_PARAMREQUIRED,(LPARAM)param} -#define PropData_Filename_Check(id,name,info,param) {id,name,info,PROPTYPE_FILENAME,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)param} -#define PropData_Filename_Opt(id,name,info,opt,param) {id,name,info,PROPTYPE_FILENAME,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)param} -#define PropData_PictureFilename(id,name,info,param) {id,name,info,PROPTYPE_PICTUREFILENAME,PROPOPT_PARAMREQUIRED,(LPARAM)param} -#define PropData_PictureFilename_Check(id,name,info,param) {id,name,info,PROPTYPE_PICTUREFILENAME,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)param} -#define PropData_PictureFilename_Opt(id,name,info,opt,param) {id,name,info,PROPTYPE_PICTUREFILENAME,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)param} -#define PropData_Font(id,name,info,param) {id,name,info,PROPTYPE_FONT,PROPOPT_PARAMREQUIRED,(LPARAM)param} -#define PropData_Font_Check(id,name,info,param) {id,name,info,PROPTYPE_FONT,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)param} -#define PropData_Font_Opt(id,name,info,opt,param) {id,name,info,PROPTYPE_FONT,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)param} -#define PropData_Custom(id,name,info,param) {id,name,info,PROPTYPE_CUSTOM,PROPOPT_PARAMREQUIRED,(LPARAM)param} -#define PropData_Custom_Check(id,name,info,param) {id,name,info,PROPTYPE_CUSTOM,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)param} -#define PropData_Custom_Opt(id,name,info,opt,param) {id,name,info,PROPTYPE_CUSTOM,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)param} -#define PropData_ComboBoxBtn(id,name,info,list) {id,name,info,PROPTYPE_COMBOBOXBTN,PROPOPT_PARAMREQUIRED,(LPARAM)list} -#define PropData_ComboBoxBtn_Check(id,name,info,list) {id,name,info,PROPTYPE_COMBOBOXBTN,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)list} -#define PropData_ComboBoxBtn_Opt(id,name,info,opt,list) {id,name,info,PROPTYPE_COMBOBOXBTN,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)list} -#define PropData_ImageList(id,name,info) {id,name,info,PROPTYPE_IMAGELIST,0,NULL} -#define PropData_ImageList_Check(id,name,info) {id,name,info,PROPTYPE_IMAGELIST,PROPOPT_CHECKBOX,NULL} -#define PropData_ImageList_Opt(id,name,info,opt) {id,name,info,PROPTYPE_IMAGELIST,opt,NULL} -#define PropData_IconComboBox(id,name,info,list) {id,name,info,PROPTYPE_ICONCOMBOBOX,PROPOPT_PARAMREQUIRED,(LPARAM)list} -#define PropData_IconComboBox_Check(id,name,info,list) {id,name,info,PROPTYPE_ICONCOMBOBOX,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)list} -#define PropData_IconComboBox_Opt(id,name,info,opt,list) {id,name,info,PROPTYPE_ICONCOMBOBOX,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)list} -#define PropData_URLButton(id,name,info,url) {id,name,info,PROPTYPE_URLBUTTON,PROPOPT_PARAMREQUIRED, (LPARAM)url} -#define PropData_URLButton_Check(id,name,info,url) {id,name,info,PROPTYPE_URLBUTTON,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)url} -#define PropData_URLButton_Opt(id,name,info,opt,url) {id,name,info,PROPTYPE_URLBUTTON,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)url} -#define PropData_DirectoryName(id,name,info,param) {id,name,info,PROPTYPE_DIRECTORYNAME,PROPOPT_PARAMREQUIRED,(LPARAM)param} -#define PropData_DirectoryName_Check(id,name,info,param) {id,name,info,PROPTYPE_DIRECTORYNAME,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)param} -#define PropData_DirectoryName_Opt(id,name,info,opt,param) {id,name,info,PROPTYPE_DIRECTORYNAME,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)param} -#define PropData_SpinEditFloat(id,name,info,minmax) {id,name,info,PROPTYPE_SPINEDITFLOAT,PROPOPT_PARAMREQUIRED,(LPARAM)minmaxdelta} -#define PropData_SpinEditFloat_Check(id,name,info,minmax) {id,name,info,PROPTYPE_SPINEDITFLOAT,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)minmaxdelta} -#define PropData_SpinEditFloat_Opt(id,name,info,opt,minmax) {id,name,info,PROPTYPE_SPINEDITFLOAT,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)minmaxdelta} #define PropData_End() {0} +#define PropData_Folder_A(id,name,info) {id,name,info,PROPTYPE_FOLDER_A,PROPOPT_NIL,(LPARAM)NULL} +#define PropData_Folder_End_A() {-1,0,0,PROPTYPE_FOLDER_END_A,PROPOPT_NIL,(LPARAM)NULL} +#define PropData_Group_A(id,name,info) {id,name,info,PROPTYPE_GROUP_A,PROPOPT_NIL,(LPARAM)NULL} +#define PropData_StaticString_A(id,name,info) {id,name,info,PROPTYPE_STATIC_A,PROPOPT_NIL,(LPARAM)NULL} +#define PropData_StaticString_Opt_A(id,name,info,opt) {id,name,info,PROPTYPE_STATIC_A,opt,(LPARAM)NULL} +#define PropData_StaticString_List_A(id,name,info) {id,name,info,PROPTYPE_STATIC_A,PROPOPT_LIST,(LPARAM)NULL} +#define PropData_EditString_A(id,name,info) {id,name,info,PROPTYPE_EDIT_STRING_A,PROPOPT_NIL,(LPARAM)NULL} +#define PropData_EditString_Check_A(id,name,info) {id,name,info,PROPTYPE_EDIT_STRING_A,PROPOPT_CHECKBOX,(LPARAM)NULL} +#define PropData_EditString_Opt_A(id,name,info,opt) {id,name,info,PROPTYPE_EDIT_STRING_A,opt,(LPARAM)NULL} +#define PropData_EditNumber_A(id,name,info) {id,name,info,PROPTYPE_EDIT_NUMBER_A,PROPOPT_NIL,(LPARAM)NULL} +#define PropData_EditNumber_Check_A(id,name,info) {id,name,info,PROPTYPE_EDIT_NUMBER_A,PROPOPT_CHECKBOX,(LPARAM)NULL} +#define PropData_EditNumber_Opt_A(id,name,info,opt) {id,name,info,PROPTYPE_EDIT_NUMBER_A,opt,(LPARAM)NULL} +#define PropData_EditFloat_A(id,name,info) {id,name,info,PROPTYPE_EDIT_FLOAT_A,PROPOPT_NIL,(LPARAM)NULL} +#define PropData_EditFloat_Check_A(id,name,info) {id,name,info,PROPTYPE_EDIT_FLOAT_A,PROPOPT_CHECKBOX,(LPARAM)NULL} +#define PropData_EditFloat_Opt_A(id,name,info,opt) {id,name,info,PROPTYPE_EDIT_FLOAT_A,opt,(LPARAM)NULL} +#define PropData_EditMultiLine_A(id,name,info) {id,name,info,PROPTYPE_EDIT_MULTILINE_A,PROPOPT_NIL,(LPARAM)NULL} +#define PropData_EditMultiLine_Check_A(id,name,info) {id,name,info,PROPTYPE_EDIT_MULTILINE_A,PROPOPT_CHECKBOX,(LPARAM)NULL} +#define PropData_EditMultiLine_Opt_A(id,name,info,opt) {id,name,info,PROPTYPE_EDIT_MULTILINE_A,opt,(LPARAM)NULL} +#define PropData_SliderEdit_A(id,name,info,minmax) {id,name,info,PROPTYPE_SLIDEREDIT_A,PROPOPT_PARAMREQUIRED,(LPARAM)minmax} +#define PropData_SliderEdit_Check_A(id,name,info,minmax) {id,name,info,PROPTYPE_SLIDEREDIT_A,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)minmax} +#define PropData_SliderEdit_Opt_A(id,name,info,opt,minmax) {id,name,info,PROPTYPE_SLIDEREDIT_A,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)minmax} +#define PropData_SpinEdit_A(id,name,info,minmax) {id,name,info,PROPTYPE_SPINEDIT_A,PROPOPT_PARAMREQUIRED,(LPARAM)minmax} +#define PropData_SpinEdit_Check_A(id,name,info,minmax) {id,name,info,PROPTYPE_SPINEDIT_A,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)minmax} +#define PropData_SpinEdit_Opt_A(id,name,info,opt,minmax) {id,name,info,PROPTYPE_SPINEDIT_A,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)minmax} +#define PropData_Button_A(id,name,info,text) {id,name,info,PROPTYPE_EDITBUTTON_A,PROPOPT_NIL, (LPARAM)text} +#define PropData_Button_Check_A(id,name,info,text) {id,name,info,PROPTYPE_EDITBUTTON_A,PROPOPT_CHECKBOX,(LPARAM)text} +#define PropData_Button_Opt_A(id,name,info,opt,text) {id,name,info,PROPTYPE_EDITBUTTON_A,opt,(LPARAM)text} +#define PropData_EditButton_A(id,name,info) {id,name,info,PROPTYPE_EDITBUTTON_A,PROPOPT_NIL, (LPARAM)NULL} +#define PropData_EditButton_Check_A(id,name,info) {id,name,info,PROPTYPE_EDITBUTTON_A,PROPOPT_CHECKBOX,(LPARAM)NULL} +#define PropData_EditButton_Opt_A(id,name,info,opt) {id,name,info,PROPTYPE_EDITBUTTON_A,opt,(LPARAM)NULL} +#define PropData_Size_A(id,name,info,tab) {id,name,info,PROPTYPE_SIZE_A,PROPOPT_PARAMREQUIRED,(LPARAM)tab} +#define PropData_Size_Check_A(id,name,info,tab) {id,name,info,PROPTYPE_SIZE_A,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)tab} +#define PropData_Size_Opt_A(id,name,info,opt,tab) {id,name,info,PROPTYPE_SIZE_A,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)tab} +#define PropData_Color_A(id,name,info) {id,name,info,PROPTYPE_COLOR_A,PROPOPT_NIL,(LPARAM)NULL} +#define PropData_Color_Check_A(id,name,info) {id,name,info,PROPTYPE_COLOR_A,PROPOPT_CHECKBOX,(LPARAM)NULL} +#define PropData_Color_Opt_A(id,name,info,opt) {id,name,info,PROPTYPE_COLOR_A,opt,(LPARAM)NULL} +#define PropData_ComboBox_A(id,name,info,list) {id,name,info,PROPTYPE_COMBOBOX_A,PROPOPT_PARAMREQUIRED,(LPARAM)list} +#define PropData_ComboBox_Check_A(id,name,info,list) {id,name,info,PROPTYPE_COMBOBOX_A,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)list} +#define PropData_ComboBox_Opt_A(id,name,info,opt,list) {id,name,info,PROPTYPE_COMBOBOX_A,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)list} +#define PropData_CheckBox_A(id,name,info) {id,name,info,PROPTYPE_LEFTCHECKBOX_A,PROPOPT_CHECKBOX,(LPARAM)NULL} +#define PropData_CheckBox_Opt_A(id,name,info,opt) {id,name,info,PROPTYPE_LEFTCHECKBOX_A,(PROPOPT_CHECKBOX|opt),(LPARAM)NULL} +#define PropData_DirCtrl_A(id,name,info,param) {id,name,info,PROPTYPE_DIRCTRL_A,PROPOPT_PARAMREQUIRED,(LPARAM)param} +#define PropData_DirCtrl_Check_A(id,name,info,param) {id,name,info,PROPTYPE_DIRCTRL_A,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)param} +#define PropData_DirCtrl_Opt_A(id,name,info,opt,param) {id,name,info,PROPTYPE_DIRCTRL_A,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)param} +#define PropData_Filename_A(id,name,info,param) {id,name,info,PROPTYPE_FILENAME_A,PROPOPT_PARAMREQUIRED,(LPARAM)param} +#define PropData_Filename_Check_A(id,name,info,param) {id,name,info,PROPTYPE_FILENAME_A,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)param} +#define PropData_Filename_Opt_A(id,name,info,opt,param) {id,name,info,PROPTYPE_FILENAME_A,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)param} +#define PropData_PictureFilename_A(id,name,info,param) {id,name,info,PROPTYPE_PICTUREFILENAME_A,PROPOPT_PARAMREQUIRED,(LPARAM)param} +#define PropData_PictureFilename_Check_A(id,name,info,param) {id,name,info,PROPTYPE_PICTUREFILENAME_A,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)param} +#define PropData_PictureFilename_Opt_A(id,name,info,opt,param) {id,name,info,PROPTYPE_PICTUREFILENAME_A,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)param} +#define PropData_Font_A(id,name,info,param) {id,name,info,PROPTYPE_FONT_A,PROPOPT_PARAMREQUIRED,(LPARAM)param} +#define PropData_Font_Check_A(id,name,info,param) {id,name,info,PROPTYPE_FONT_A,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)param} +#define PropData_Font_Opt_A(id,name,info,opt,param) {id,name,info,PROPTYPE_FONT_A,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)param} +#define PropData_Custom_A(id,name,info,param) {id,name,info,PROPTYPE_CUSTOM_A,PROPOPT_PARAMREQUIRED,(LPARAM)param} +#define PropData_Custom_Check_A(id,name,info,param) {id,name,info,PROPTYPE_CUSTOM_A,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)param} +#define PropData_Custom_Opt_A(id,name,info,opt,param) {id,name,info,PROPTYPE_CUSTOM_A,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)param} +#define PropData_ComboBoxBtn_A(id,name,info,list) {id,name,info,PROPTYPE_COMBOBOXBTN_A,PROPOPT_PARAMREQUIRED,(LPARAM)list} +#define PropData_ComboBoxBtn_Check_A(id,name,info,list) {id,name,info,PROPTYPE_COMBOBOXBTN_A,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)list} +#define PropData_ComboBoxBtn_Opt_A(id,name,info,opt,list) {id,name,info,PROPTYPE_COMBOBOXBTN_A,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)list} +#define PropData_ImageList_A(id,name,info) {id,name,info,PROPTYPE_IMAGELIST_A,0,NULL} +#define PropData_ImageList_Check_A(id,name,info) {id,name,info,PROPTYPE_IMAGELIST_A,PROPOPT_CHECKBOX,NULL} +#define PropData_ImageList_Opt_A(id,name,info,opt) {id,name,info,PROPTYPE_IMAGELIST_A,opt,NULL} +#define PropData_IconComboBox_A(id,name,info,list) {id,name,info,PROPTYPE_ICONCOMBOBOX_A,PROPOPT_PARAMREQUIRED,(LPARAM)list} +#define PropData_IconComboBox_Check_A(id,name,info,list) {id,name,info,PROPTYPE_ICONCOMBOBOX_A,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)list} +#define PropData_IconComboBox_Opt_A(id,name,info,opt,list) {id,name,info,PROPTYPE_ICONCOMBOBOX_A,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)list} +#define PropData_URLButton_A(id,name,info,url) {id,name,info,PROPTYPE_URLBUTTON_A,PROPOPT_PARAMREQUIRED, (LPARAM)url} +#define PropData_URLButton_Check_A(id,name,info,url) {id,name,info,PROPTYPE_URLBUTTON_A,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)url} +#define PropData_URLButton_Opt_A(id,name,info,opt,url) {id,name,info,PROPTYPE_URLBUTTON_A,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)url} +#define PropData_DirectoryName_A(id,name,info,param) {id,name,info,PROPTYPE_DIRECTORYNAME_A,PROPOPT_PARAMREQUIRED,(LPARAM)param} +#define PropData_DirectoryName_Check_A(id,name,info,param) {id,name,info,PROPTYPE_DIRECTORYNAME_A,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)param} +#define PropData_DirectoryName_Opt_A(id,name,info,opt,param) {id,name,info,PROPTYPE_DIRECTORYNAME_A,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)param} +#define PropData_SpinEditFloat_A(id,name,info,minmax) {id,name,info,PROPTYPE_SPINEDITFLOAT_A,PROPOPT_PARAMREQUIRED,(LPARAM)minmaxdelta} +#define PropData_SpinEditFloat_Check_A(id,name,info,minmax) {id,name,info,PROPTYPE_SPINEDITFLOAT_A,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)minmaxdelta} +#define PropData_SpinEditFloat_Opt_A(id,name,info,opt,minmax) {id,name,info,PROPTYPE_SPINEDITFLOAT_A,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)minmaxdelta} + + +#define PropData_Folder_W(id,name,info) {id,name,info,PROPTYPE_FOLDER_W,PROPOPT_NIL,(LPARAM)NULL} +#define PropData_Folder_End_W() {-1,0,0,PROPTYPE_FOLDER_END_W,PROPOPT_NIL,(LPARAM)NULL} +#define PropData_Group_W(id,name,info) {id,name,info,PROPTYPE_GROUP_W,PROPOPT_NIL,(LPARAM)NULL} +#define PropData_StaticString_W(id,name,info) {id,name,info,PROPTYPE_STATIC_W,PROPOPT_NIL,(LPARAM)NULL} +#define PropData_StaticString_Opt_W(id,name,info,opt) {id,name,info,PROPTYPE_STATIC_W,opt,(LPARAM)NULL} +#define PropData_StaticString_List_W(id,name,info) {id,name,info,PROPTYPE_STATIC_W,PROPOPT_LIST,(LPARAM)NULL} +#define PropData_EditString_W(id,name,info) {id,name,info,PROPTYPE_EDIT_STRING_W,PROPOPT_NIL,(LPARAM)NULL} +#define PropData_EditString_Check_W(id,name,info) {id,name,info,PROPTYPE_EDIT_STRING_W,PROPOPT_CHECKBOX,(LPARAM)NULL} +#define PropData_EditString_Opt_W(id,name,info,opt) {id,name,info,PROPTYPE_EDIT_STRING_W,opt,(LPARAM)NULL} +#define PropData_EditNumber_W(id,name,info) {id,name,info,PROPTYPE_EDIT_NUMBER_W,PROPOPT_NIL,(LPARAM)NULL} +#define PropData_EditNumber_Check_W(id,name,info) {id,name,info,PROPTYPE_EDIT_NUMBER_W,PROPOPT_CHECKBOX,(LPARAM)NULL} +#define PropData_EditNumber_Opt_W(id,name,info,opt) {id,name,info,PROPTYPE_EDIT_NUMBER_W,opt,(LPARAM)NULL} +#define PropData_EditFloat_W(id,name,info) {id,name,info,PROPTYPE_EDIT_FLOAT_W,PROPOPT_NIL,(LPARAM)NULL} +#define PropData_EditFloat_Check_W(id,name,info) {id,name,info,PROPTYPE_EDIT_FLOAT_W,PROPOPT_CHECKBOX,(LPARAM)NULL} +#define PropData_EditFloat_Opt_W(id,name,info,opt) {id,name,info,PROPTYPE_EDIT_FLOAT_W,opt,(LPARAM)NULL} +#define PropData_EditMultiLine_W(id,name,info) {id,name,info,PROPTYPE_EDIT_MULTILINE_W,PROPOPT_NIL,(LPARAM)NULL} +#define PropData_EditMultiLine_Check_W(id,name,info) {id,name,info,PROPTYPE_EDIT_MULTILINE_W,PROPOPT_CHECKBOX,(LPARAM)NULL} +#define PropData_EditMultiLine_Opt_W(id,name,info,opt) {id,name,info,PROPTYPE_EDIT_MULTILINE_W,opt,(LPARAM)NULL} +#define PropData_SliderEdit_W(id,name,info,minmax) {id,name,info,PROPTYPE_SLIDEREDIT_W,PROPOPT_PARAMREQUIRED,(LPARAM)minmax} +#define PropData_SliderEdit_Check_W(id,name,info,minmax) {id,name,info,PROPTYPE_SLIDEREDIT_W,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)minmax} +#define PropData_SliderEdit_Opt_W(id,name,info,opt,minmax) {id,name,info,PROPTYPE_SLIDEREDIT_W,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)minmax} +#define PropData_SpinEdit_W(id,name,info,minmax) {id,name,info,PROPTYPE_SPINEDIT_W,PROPOPT_PARAMREQUIRED,(LPARAM)minmax} +#define PropData_SpinEdit_Check_W(id,name,info,minmax) {id,name,info,PROPTYPE_SPINEDIT_W,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)minmax} +#define PropData_SpinEdit_Opt_W(id,name,info,opt,minmax) {id,name,info,PROPTYPE_SPINEDIT_W,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)minmax} +#define PropData_Button_W(id,name,info,text) {id,name,info,PROPTYPE_EDITBUTTON_W,PROPOPT_NIL, (LPARAM)text} +#define PropData_Button_Check_W(id,name,info,text) {id,name,info,PROPTYPE_EDITBUTTON_W,PROPOPT_CHECKBOX,(LPARAM)text} +#define PropData_Button_Opt_W(id,name,info,opt,text) {id,name,info,PROPTYPE_EDITBUTTON_W,opt,(LPARAM)text} +#define PropData_EditButton_W(id,name,info) {id,name,info,PROPTYPE_EDITBUTTON_W,PROPOPT_NIL, (LPARAM)NULL} +#define PropData_EditButton_Check_W(id,name,info) {id,name,info,PROPTYPE_EDITBUTTON_W,PROPOPT_CHECKBOX,(LPARAM)NULL} +#define PropData_EditButton_Opt_W(id,name,info,opt) {id,name,info,PROPTYPE_EDITBUTTON_W,opt,(LPARAM)NULL} +#define PropData_Size_W(id,name,info,tab) {id,name,info,PROPTYPE_SIZE_W,PROPOPT_PARAMREQUIRED,(LPARAM)tab} +#define PropData_Size_Check_W(id,name,info,tab) {id,name,info,PROPTYPE_SIZE_W,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)tab} +#define PropData_Size_Opt_W(id,name,info,opt,tab) {id,name,info,PROPTYPE_SIZE_W,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)tab} +#define PropData_Color_W(id,name,info) {id,name,info,PROPTYPE_COLOR_W,PROPOPT_NIL,(LPARAM)NULL} +#define PropData_Color_Check_W(id,name,info) {id,name,info,PROPTYPE_COLOR_W,PROPOPT_CHECKBOX,(LPARAM)NULL} +#define PropData_Color_Opt_W(id,name,info,opt) {id,name,info,PROPTYPE_COLOR_W,opt,(LPARAM)NULL} +#define PropData_ComboBox_W(id,name,info,list) {id,name,info,PROPTYPE_COMBOBOX_W,PROPOPT_PARAMREQUIRED,(LPARAM)list} +#define PropData_ComboBox_Check_W(id,name,info,list) {id,name,info,PROPTYPE_COMBOBOX_W,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)list} +#define PropData_ComboBox_Opt_W(id,name,info,opt,list) {id,name,info,PROPTYPE_COMBOBOX_W,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)list} +#define PropData_CheckBox_W(id,name,info) {id,name,info,PROPTYPE_LEFTCHECKBOX_W,PROPOPT_CHECKBOX,(LPARAM)NULL} +#define PropData_CheckBox_Opt_W(id,name,info,opt) {id,name,info,PROPTYPE_LEFTCHECKBOX_W,(PROPOPT_CHECKBOX|opt),(LPARAM)NULL} +#define PropData_DirCtrl_W(id,name,info,param) {id,name,info,PROPTYPE_DIRCTRL_W,PROPOPT_PARAMREQUIRED,(LPARAM)param} +#define PropData_DirCtrl_Check_W(id,name,info,param) {id,name,info,PROPTYPE_DIRCTRL_W,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)param} +#define PropData_DirCtrl_Opt_W(id,name,info,opt,param) {id,name,info,PROPTYPE_DIRCTRL_W,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)param} +#define PropData_Filename_W(id,name,info,param) {id,name,info,PROPTYPE_FILENAME_W,PROPOPT_PARAMREQUIRED,(LPARAM)param} +#define PropData_Filename_Check_W(id,name,info,param) {id,name,info,PROPTYPE_FILENAME_W,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)param} +#define PropData_Filename_Opt_W(id,name,info,opt,param) {id,name,info,PROPTYPE_FILENAME_W,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)param} +#define PropData_PictureFilename_W(id,name,info,param) {id,name,info,PROPTYPE_PICTUREFILENAME_W,PROPOPT_PARAMREQUIRED,(LPARAM)param} +#define PropData_PictureFilename_Check_W(id,name,info,param) {id,name,info,PROPTYPE_PICTUREFILENAME_W,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)param} +#define PropData_PictureFilename_Opt_W(id,name,info,opt,param) {id,name,info,PROPTYPE_PICTUREFILENAME_W,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)param} +#define PropData_Font_W(id,name,info,param) {id,name,info,PROPTYPE_FONT_W,PROPOPT_PARAMREQUIRED,(LPARAM)param} +#define PropData_Font_Check_W(id,name,info,param) {id,name,info,PROPTYPE_FONT_W,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)param} +#define PropData_Font_Opt_W(id,name,info,opt,param) {id,name,info,PROPTYPE_FONT_W,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)param} +#define PropData_Custom_W(id,name,info,param) {id,name,info,PROPTYPE_CUSTOM_W,PROPOPT_PARAMREQUIRED,(LPARAM)param} +#define PropData_Custom_Check_W(id,name,info,param) {id,name,info,PROPTYPE_CUSTOM_W,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)param} +#define PropData_Custom_Opt_W(id,name,info,opt,param) {id,name,info,PROPTYPE_CUSTOM_W,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)param} +#define PropData_ComboBoxBtn_W(id,name,info,list) {id,name,info,PROPTYPE_COMBOBOXBTN_W,PROPOPT_PARAMREQUIRED,(LPARAM)list} +#define PropData_ComboBoxBtn_Check_W(id,name,info,list) {id,name,info,PROPTYPE_COMBOBOXBTN_W,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)list} +#define PropData_ComboBoxBtn_Opt_W(id,name,info,opt,list) {id,name,info,PROPTYPE_COMBOBOXBTN_W,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)list} +#define PropData_ImageList_W(id,name,info) {id,name,info,PROPTYPE_IMAGELIST_W,0,NULL} +#define PropData_ImageList_Check_W(id,name,info) {id,name,info,PROPTYPE_IMAGELIST_W,PROPOPT_CHECKBOX,NULL} +#define PropData_ImageList_Opt_W(id,name,info,opt) {id,name,info,PROPTYPE_IMAGELIST_W,opt,NULL} +#define PropData_IconComboBox_W(id,name,info,list) {id,name,info,PROPTYPE_ICONCOMBOBOX_W,PROPOPT_PARAMREQUIRED,(LPARAM)list} +#define PropData_IconComboBox_Check_W(id,name,info,list) {id,name,info,PROPTYPE_ICONCOMBOBOX_W,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)list} +#define PropData_IconComboBox_Opt_W(id,name,info,opt,list) {id,name,info,PROPTYPE_ICONCOMBOBOX_W,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)list} +#define PropData_URLButton_W(id,name,info,url) {id,name,info,PROPTYPE_URLBUTTON_W,PROPOPT_PARAMREQUIRED, (LPARAM)url} +#define PropData_URLButton_Check_W(id,name,info,url) {id,name,info,PROPTYPE_URLBUTTON_W,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)url} +#define PropData_URLButton_Opt_W(id,name,info,opt,url) {id,name,info,PROPTYPE_URLBUTTON_W,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)url} +#define PropData_DirectoryName_W(id,name,info,param) {id,name,info,PROPTYPE_DIRECTORYNAME_W,PROPOPT_PARAMREQUIRED,(LPARAM)param} +#define PropData_DirectoryName_Check_W(id,name,info,param) {id,name,info,PROPTYPE_DIRECTORYNAME_W,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)param} +#define PropData_DirectoryName_Opt_W(id,name,info,opt,param) {id,name,info,PROPTYPE_DIRECTORYNAME_W,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)param} +#define PropData_SpinEditFloat_W(id,name,info,minmax) {id,name,info,PROPTYPE_SPINEDITFLOAT_W,PROPOPT_PARAMREQUIRED,(LPARAM)minmaxdelta} +#define PropData_SpinEditFloat_Check_W(id,name,info,minmax) {id,name,info,PROPTYPE_SPINEDITFLOAT_W,(PROPOPT_PARAMREQUIRED|PROPOPT_CHECKBOX),(LPARAM)minmaxdelta} +#define PropData_SpinEditFloat_Opt_W(id,name,info,opt,minmax) {id,name,info,PROPTYPE_SPINEDITFLOAT_W,(PROPOPT_PARAMREQUIRED|opt),(LPARAM)minmaxdelta} + +#ifdef _UNICODE + +#define PropData_Folder PropData_Folder_W +#define PropData_Folder_End PropData_Folder_End_W +#define PropData_Group PropData_Group_W +#define PropData_StaticString PropData_StaticString_W +#define PropData_StaticString_Opt PropData_StaticString_Opt_W +#define PropData_StaticString_List PropData_StaticString_List_W +#define PropData_EditString PropData_EditString_W +#define PropData_EditString_Check PropData_EditString_Check_W +#define PropData_EditString_Opt PropData_EditString_Opt_W +#define PropData_EditNumber PropData_EditNumber_W +#define PropData_EditNumber_Check PropData_EditNumber_Check_W +#define PropData_EditNumber_Opt PropData_EditNumber_Opt_W +#define PropData_EditFloat PropData_EditFloat_W +#define PropData_EditFloat_Check PropData_EditFloat_Check_W +#define PropData_EditFloat_Opt PropData_EditFloat_Opt_W +#define PropData_EditMultiLine PropData_EditMultiLine_W +#define PropData_EditMultiLine_Check PropData_EditMultiLine_Check_W +#define PropData_EditMultiLine_Opt PropData_EditMultiLine_Opt_W +#define PropData_SliderEdit PropData_SliderEdit_W +#define PropData_SliderEdit_Check PropData_SliderEdit_Check_W +#define PropData_SliderEdit_Opt PropData_SliderEdit_Opt_W +#define PropData_SpinEdit PropData_SpinEdit_W +#define PropData_SpinEdit_Check PropData_SpinEdit_Check_W +#define PropData_SpinEdit_Opt PropData_SpinEdit_Opt_W +#define PropData_Button PropData_Button_W +#define PropData_Button_Check PropData_Button_Check_W +#define PropData_Button_Opt PropData_Button_Opt_W +#define PropData_EditButton PropData_EditButton_W +#define PropData_EditButton_Check PropData_EditButton_Check_W +#define PropData_EditButton_Opt PropData_EditButton_Opt_W +#define PropData_Size PropData_Size_W +#define PropData_Size_Check PropData_Size_Check_W +#define PropData_Size_Opt PropData_Size_Opt_W +#define PropData_Color PropData_Color_W +#define PropData_Color_Check PropData_Color_Check_W +#define PropData_Color_Opt PropData_Color_Opt_W +#define PropData_ComboBox PropData_ComboBox_W +#define PropData_ComboBox_Check PropData_ComboBox_Check_W +#define PropData_ComboBox_Opt PropData_ComboBox_Opt_W +#define PropData_CheckBox PropData_CheckBox_W +#define PropData_CheckBox_Opt PropData_CheckBox_Opt_W +#define PropData_DirCtrl PropData_DirCtrl_W +#define PropData_DirCtrl_Check PropData_DirCtrl_Check_W +#define PropData_DirCtrl_Opt PropData_DirCtrl_Opt_W +#define PropData_Filename PropData_Filename_W +#define PropData_Filename_Check PropData_Filename_Check_W +#define PropData_Filename_Opt PropData_Filename_Opt_W +#define PropData_PictureFilename PropData_PictureFilename_W +#define PropData_PictureFilename_Check PropData_PictureFilename_Check_W +#define PropData_PictureFilename_Opt PropData_PictureFilename_Opt_W +#define PropData_Font PropData_Font_W +#define PropData_Font_Check PropData_Font_Check_W +#define PropData_Font_Opt PropData_Font_Opt_W +#define PropData_Custom PropData_Custom_W +#define PropData_Custom_Check PropData_Custom_Check_W +#define PropData_Custom_Opt PropData_Custom_Opt_W +#define PropData_ComboBoxBtn PropData_ComboBoxBtn_W +#define PropData_ComboBoxBtn_Check PropData_ComboBoxBtn_Check_W +#define PropData_ComboBoxBtn_Opt PropData_ComboBoxBtn_Opt_W +#define PropData_ImageList PropData_ImageList_W +#define PropData_ImageList_Check PropData_ImageList_Check_W +#define PropData_ImageList_Opt PropData_ImageList_Opt_W +#define PropData_IconComboBox PropData_IconComboBox_W +#define PropData_IconComboBox_Check PropData_IconComboBox_Check_W +#define PropData_IconComboBox_Opt PropData_IconComboBox_Opt_W +#define PropData_URLButton PropData_URLButton_W +#define PropData_URLButton_Check PropData_URLButton_Check_W +#define PropData_URLButton_Opt PropData_URLButton_Opt_W +#define PropData_DirectoryName PropData_DirectoryName_W +#define PropData_DirectoryName_Check PropData_DirectoryName_Check_W +#define PropData_DirectoryName_Opt PropData_DirectoryName_Opt_W +#define PropData_SpinEditFloat PropData_SpinEditFloat_W +#define PropData_SpinEditFloat_Check PropData_SpinEditFloat_Check_W +#define PropData_SpinEditFloat_Opt PropData_SpinEditFloat_Opt_W + +#else + +#define PropData_Folder PropData_Folder_A +#define PropData_Folder_End PropData_Folder_End_A +#define PropData_Group PropData_Group_A +#define PropData_StaticString PropData_StaticString_A +#define PropData_StaticString_Opt PropData_StaticString_Opt_A +#define PropData_StaticString_List PropData_StaticString_List_A +#define PropData_EditString PropData_EditString_A +#define PropData_EditString_Check PropData_EditString_Check_A +#define PropData_EditString_Opt PropData_EditString_Opt_A +#define PropData_EditNumber PropData_EditNumber_A +#define PropData_EditNumber_Check PropData_EditNumber_Check_A +#define PropData_EditNumber_Opt PropData_EditNumber_Opt_A +#define PropData_EditFloat PropData_EditFloat_A +#define PropData_EditFloat_Check PropData_EditFloat_Check_A +#define PropData_EditFloat_Opt PropData_EditFloat_Opt_A +#define PropData_EditMultiLine PropData_EditMultiLine_A +#define PropData_EditMultiLine_Check PropData_EditMultiLine_Check_A +#define PropData_EditMultiLine_Opt PropData_EditMultiLine_Opt_A +#define PropData_SliderEdit PropData_SliderEdit_A +#define PropData_SliderEdit_Check PropData_SliderEdit_Check_A +#define PropData_SliderEdit_Opt PropData_SliderEdit_Opt_A +#define PropData_SpinEdit PropData_SpinEdit_A +#define PropData_SpinEdit_Check PropData_SpinEdit_Check_A +#define PropData_SpinEdit_Opt PropData_SpinEdit_Opt_A +#define PropData_Button PropData_Button_A +#define PropData_Button_Check PropData_Button_Check_A +#define PropData_Button_Opt PropData_Button_Opt_A +#define PropData_EditButton PropData_EditButton_A +#define PropData_EditButton_Check PropData_EditButton_Check_A +#define PropData_EditButton_Opt PropData_EditButton_Opt_A +#define PropData_Size PropData_Size_A +#define PropData_Size_Check PropData_Size_Check_A +#define PropData_Size_Opt PropData_Size_Opt_A +#define PropData_Color PropData_Color_A +#define PropData_Color_Check PropData_Color_Check_A +#define PropData_Color_Opt PropData_Color_Opt_A +#define PropData_ComboBox PropData_ComboBox_A +#define PropData_ComboBox_Check PropData_ComboBox_Check_A +#define PropData_ComboBox_Opt PropData_ComboBox_Opt_A +#define PropData_CheckBox PropData_CheckBox_A +#define PropData_CheckBox_Opt PropData_CheckBox_Opt_A +#define PropData_DirCtrl PropData_DirCtrl_A +#define PropData_DirCtrl_Check PropData_DirCtrl_Check_A +#define PropData_DirCtrl_Opt PropData_DirCtrl_Opt_A +#define PropData_Filename PropData_Filename_A +#define PropData_Filename_Check PropData_Filename_Check_A +#define PropData_Filename_Opt PropData_Filename_Opt_A +#define PropData_PictureFilename PropData_PictureFilename_A +#define PropData_PictureFilename_Check PropData_PictureFilename_Check_A +#define PropData_PictureFilename_Opt PropData_PictureFilename_Opt_A +#define PropData_Font PropData_Font_A +#define PropData_Font_Check PropData_Font_Check_A +#define PropData_Font_Opt PropData_Font_Opt_A +#define PropData_Custom PropData_Custom_A +#define PropData_Custom_Check PropData_Custom_Check_A +#define PropData_Custom_Opt PropData_Custom_Opt_A +#define PropData_ComboBoxBtn PropData_ComboBoxBtn_A +#define PropData_ComboBoxBtn_Check PropData_ComboBoxBtn_Check_A +#define PropData_ComboBoxBtn_Opt PropData_ComboBoxBtn_Opt_A +#define PropData_ImageList PropData_ImageList_A +#define PropData_ImageList_Check PropData_ImageList_Check_A +#define PropData_ImageList_Opt PropData_ImageList_Opt_A +#define PropData_IconComboBox PropData_IconComboBox_A +#define PropData_IconComboBox_Check PropData_IconComboBox_Check_A +#define PropData_IconComboBox_Opt PropData_IconComboBox_Opt_A +#define PropData_URLButton PropData_URLButton_A +#define PropData_URLButton_Check PropData_URLButton_Check_A +#define PropData_URLButton_Opt PropData_URLButton_Opt_A +#define PropData_DirectoryName PropData_DirectoryName_A +#define PropData_DirectoryName_Check PropData_DirectoryName_Check_A +#define PropData_DirectoryName_Opt PropData_DirectoryName_Opt_A +#define PropData_SpinEditFloat PropData_SpinEditFloat_A +#define PropData_SpinEditFloat_Check PropData_SpinEditFloat_Check_A +#define PropData_SpinEditFloat_Opt PropData_SpinEditFloat_Opt_A + +#endif // _UNICODE + ///////////////////////////////// // Property definition parameters ///////////////////////////////// @@ -660,7 +981,18 @@ typedef struct { typedef struct { LPCSTR extFilter; // Filter string for GetOpenFilename dialog (for example "All Files (*.*)|*.*|") DWORD options; // Options for GetOpenFilename dialog (OFN_FILEMUSTEXIST, OFN_PATHMUSTEXIST, OFN_HIDEREADONLY, etc.) -} FilenameCreateParam; +} FilenameCreateParamA; + +typedef struct { + LPCWSTR extFilter; // Filter string for GetOpenFilename dialog (for example "All Files (*.*)|*.*|") + DWORD options; // Options for GetOpenFilename dialog (OFN_FILEMUSTEXIST, OFN_PATHMUSTEXIST, OFN_HIDEREADONLY, etc.) +} FilenameCreateParamW; + +#ifdef _UNICODE +#define FilenameCreateParam FilenameCreateParamW +#else +#define FilenameCreateParam FilenameCreateParamA +#endif //////////////////////////////////////////////// // @@ -687,9 +1019,11 @@ enum { PROPID_TAB_ANDROID, PROPID_TAB_XNA, PROPID_TAB_MAC, - PROPID_TAB_CUSTOM1 = 18, - PROPID_TAB_CUSTOM2, - PROPTAB_MAX // 20 + PROPID_TAB_HTML5, + PROPID_TAB_VITA, + PROPID_TAB_CUSTOM1 = 20, //TODO: keep updating this as Fusion updates + PROPID_TAB_CUSTOM2, //note: custom tabs are no longer supported in MMF2.0, only in CTF2.5 + PROPTAB_MAX }; /////////////// @@ -1009,14 +1343,14 @@ enum { PROPID_APP_IPHONEENABLEIAD, PROPID_APP_IPHONEIADBOTTOM, PROPID_APP_OPTIONAL_MODULES, - PROPID_APP_ANDROIDVERSION, + PROPID_APP_ANDROIDVERSION_MIN, PROPID_APP_IPHONEBUNDLEVERSION, PROPID_APP_IPHONETARGETDEVICE, PROPID_APP_IPHONEARCHITECTURE, PROPID_APP_IPHONEAPPICON_IPAD, PROPID_APP_IPHONELAUNCHIMAGE_IPAD, - PROPID_APP_XNAPROJECTPATH, - PROPID_APP_XNAPROJECTNAME, + PROPID_APP_PROJECTPATH, + PROPID_APP_PROJECTNAME, PROPID_APP_XNASTATUSLINE, PROPID_APP_XNAFONT_GROUP, PROPID_APP_XNAFONT_FIRSTCHAR, @@ -1033,6 +1367,74 @@ enum { PROPID_APP_BUILDWARNINGS, PROPID_APP_XNAADS, PROPID_APP_XNAPUBCENTERID, + PROPID_APP_XNAABOUT, + PROPID_APP_XNAAPPTITLE, + PROPID_APP_XNADESCRIPTION, + PROPID_APP_XNACOMPANY, + PROPID_APP_XNAPRODUCT, + PROPID_APP_XNACOPYRIGHT, + PROPID_APP_XNATRADEMARK, + PROPID_APP_XNAASSEMBLYVERSION, + PROPID_APP_XNAFILEVERSION, + PROPID_APP_XNAGAMETHUMBNAIL, + PROPID_APP_XNABACKGROUNDIMAGE, + PROPID_APP_ANDROIDKEYPASSWORD, + PROPID_APP_ANDROIDVERSIONING_GROUP, + PROPID_APP_ANDROIDVERSIONCODE, + PROPID_APP_ANDROIDVERSIONSTRING, + PROPID_APP_XNALANGUAGE, + PROPID_APP_ANDROIDKEYSTOREPASSWORD, + PROPID_APP_ANDROIDADMOB_GROUP, + PROPID_APP_ANDROIDENABLEAD, + PROPID_APP_ANDROIDADBOTTOM, + PROPID_APP_ANDROIDADMOBID, + PROPID_APP_ANDROIDTESTDEVICEID, + PROPID_APP_ANDROIDREQUIREGPU, + PROPID_APP_ANDROIDANTIALIAS, + PROPID_APP_ANDROIDLARGESOUNDDURATION, + PROPID_APP_HTML5USEMOSAIC, + PROPID_APP_HTML5KEEPRESOURCES, + PROPID_APP_VITAINPUT, + PROPID_APP_VITAACCELS, + PROPID_APP_VITATOUCHSCREEN, + PROPID_APP_VITAGAMEPAD, + PROPID_APP_VITAMEMORY, + PROPID_APP_VITARESHEAP, + PROPID_APP_VITAMNGHEAP, + PROPID_APP_XNAUSEMOSAIC, + PROPID_APP_ANDROIDGLMODE, + PROPID_APP_HTML5WEBGL, + PROPID_APP_ALLOWSCREENBORDERS, + PROPID_APP_IPHONEDISPLAY, + PROPID_APP_IPHONELAUNCHIMAGE_LANDSCAPE_IPAD, + PROPID_APP_HTML5_PRELOADER_GROUP, + PROPID_APP_HTML5_PRELOADER, + PROPID_APP_HTML5_PRELOADER_FILENAME, + PROPID_APP_HTML5_PRELOADER_PGB_X, + PROPID_APP_HTML5_PRELOADER_PGB_Y, + PROPID_APP_HTML5_PRELOADER_PGB_RADIUS, + PROPID_APP_HTML5_PRELOADER_PGB_THICKNESS, + PROPID_APP_HTML5_PRELOADER_PGB_COLOR, + PROPID_APP_HTML5_PRELOADER_BACK_COLOR, + PROPID_APP_HTML5_PRELOADERTYPE, + PROPID_APP_HTML5_PRELOADER_FRAMENUM, + PROPID_APP_IPHONELAUNCHIMAGE_IPHONE5, + PROPID_APP_ANDROIDDISPLAY, + PROPID_APP_ANDROIDSYSTEMFONT, + PROPID_APP_ANDROIDMENU, + PROPID_APP_ANDROIDVERSION_TARGET, + PROPID_APP_HTML5RUNEVENIFNOTFOCUS, + PROPID_APP_HTML5_GENERATEHTMLFILE, + PROPID_APP_HTML5_ALLOWOFFLINE, + PROPID_APP_HTML5_MEDIAFOLDER, + PROPID_APP_HTML5_SRCFOLDER, + PROPID_APP_ANDROIDKEYBOVERAPPWINDOW, + PROPID_APP_ANDROIDOUYA_GROUP, + PROPID_APP_ANDROIDOUYA_CATEGORY, + PROPID_APP_ANDROIDTESTING_GROUP, + PROPID_APP_ANDROIDRELEASE_GROUP, + PROPID_APP_ANDROIDDISPOPT, + PROPID_APP_HTML5_PRELOADER_ERASEBKD, PROPID_APP_LAST, PROPID_APP_ANDROID_PERM_FIRST = 90001, @@ -1089,6 +1491,22 @@ enum { PROPID_FRAME_DISABLEIDLETIMER, PROPID_FRAME_IPHONEIAD_GROUP, PROPID_FRAME_IPHONEIAD, + PROPID_FRAME_ANDROID_JOYSTICK_GROUP, + PROPID_FRAME_ANDROID_JOYSTICK_TYPE, + PROPID_FRAME_ANDROID_JOYSTICK_FIRE1, + PROPID_FRAME_ANDROID_JOYSTICK_FIRE2, + PROPID_FRAME_ANDROID_JOYSTICK_LEFTHAND, + PROPID_FRAME_ANDROIDAD_GROUP, + PROPID_FRAME_ANDROIDAD, + PROPID_FRAME_ANDROIDADBOTTOM, + PROPID_FRAME_ANDROIDADOVERFRAME, + PROPID_FRAME_VITA_JOYSTICK_TYPE, + PROPID_FRAME_HTML5_DISPLAYPRELOADER, + PROPID_FRAME_HTML5_JOYSTICK_GROUP, + PROPID_FRAME_HTML5_JOYSTICK_TYPE, + PROPID_FRAME_HTML5_JOYSTICK_FIRE1, + PROPID_FRAME_HTML5_JOYSTICK_FIRE2, + PROPID_FRAME_HTML5_JOYSTICK_LEFTHAND, PROPID_FRAME_LAST, }; diff --git a/Inc/Surface.h b/Inc/Surface.h index aa9cc05..066d680 100644 --- a/Inc/Surface.h +++ b/Inc/Surface.h @@ -27,23 +27,8 @@ typedef struct DisplayMode { typedef BOOL (CALLBACK * LPENUMSCREENMODESPROC)(DisplayMode*, LPVOID); -#ifdef HWABETA // Lost device callback function typedef void (CALLBACK * LOSTDEVICECALLBACKPROC)(cSurface*, LPARAM); -#endif - -// Direct3D surface information (Call cSurface::GetDriverInfo) -typedef struct D3DSURFINFO { - DWORD m_lSize; - int m_nD3DVersion; // 8 or 9 - LPVOID m_pD3D; // LPDIRECT3D8 or LPDIRECT3D9 - LPVOID m_pD3DDevice; // LPDIRECT3DDEVICE8 or LPDIRECT3DDEVICE9 - LPVOID m_pD3DTexture; // LPDIRECT3DTEXTURE8 or LPDIRECT3DTEXTURE9 - int m_dwPixelShaderVersion; - int m_dwVertexShaderVersion; // not used - int m_dwMaxTextureWidth; - int m_dwMaxTextureHeight; - } D3DSURFINFO; // System colors #ifndef COLOR_GRADIENTINACTIVECAPTION @@ -84,7 +69,7 @@ typedef enum { BOP_EFFECTEX, BOP_MAX, BOP_MASK = 0xFFF, - BOP_RGBAFILTER = 0x1000, // Same as RGB coefficient & Blend coefficient in MMF. BGRA format (highest byte is alpha) + BOP_RGBAFILTER = 0x1000, } BlitOp; #define ALPHATOSEMITRANSP(a) ((a==0) ? 128:(255-a)/2) @@ -120,11 +105,11 @@ enum ST_MEMORY, // Buffer only ST_MEMORYWITHDC, // Buffer + DC (i.e. DIBSection, DDRAW surface, etc... ST_MEMORYWITHPERMANENTDC, // Buffer + permanent DC (i.e. DIBDC) - ST_DDRAW_SYSTEMMEMORY, // Surface Direct Draw Surface in system memory + ST_DDRAW_SYSTEMMEMORY, // Surface Direct Draw en mémoire systeme ST_HWA_SCREEN, // Screen surface in HWA mode - ST_HWA_RTTEXTURE, // Render target texture in HWA mode. Fast writing, can be used as viewport surface - ST_HWA_ROUTEXTURE, // HWA texture created in video memory, unmanaged (lost when device is lost). Slow writing, should be treated read-only - ST_HWA_ROMTEXTURE, // HWA texture created in video memory, managed (automatically reloaded when the device is lost). Slow writing, should be treated read-only + ST_HWA_RTTEXTURE, // Render target texture in HWA mode + ST_HWA_ROUTEXTURE, // HWA texture created in video memory, unmanaged (lost when device is lost) + ST_HWA_ROMTEXTURE, // HWA texture created in video memory, managed (automatically reloaded when the device is lost) ST_MAX }; @@ -163,11 +148,9 @@ enum { // Blilt options enum { BLTF_ANTIA = 0x0001, // Anti-aliasing - BLTF_COPYALPHA = 0x0002, // Copy alpha channel to destination alpha channel instead of applying it (Note: Do not use in HWA mode) -#ifdef HWABETA + BLTF_COPYALPHA = 0x0002, // Copy alpha channel to destination alpha channel instead of applying it BLTF_SAFESRC = 0x0010, BLTF_TILE = 0x0020 -#endif }; // Stretch & BlitEx options @@ -175,10 +158,8 @@ enum { STRF_RESAMPLE = 0x0001, // Resample bitmap STRF_RESAMPLE_TRANSP = 0x0002, // Resample bitmap, but doesn't resample the transparent color STRF_COPYALPHA = 0x0004, // Copy (stretch) alpha channel to destination alpha channel instead of applying it -#ifdef HWABETA STRF_SAFESRC = 0x0010, STRF_TILE = 0x0020 -#endif }; @@ -229,9 +210,7 @@ class SURFACES_API cSurface // Init static void InitializeSurfaces(); static void FreeSurfaces(); -#ifdef HWABETA static void FreeExternalModules(); -#endif // Operators cSurface FAR & operator= (const cSurface FAR & source); @@ -303,12 +282,10 @@ class SURFACES_API cSurface int BeginRendering(BOOL bClear, RGBAREF dwRgba); int EndRendering(); BOOL UpdateScreen(); -#ifdef HWABETA cSurface* GetRenderTargetSurface(); void ReleaseRenderTargetSurface(cSurface* psf); void Flush(BOOL bMax); void SetZBuffer(float z2D); -#endif // ====================== // Device context for graphic operations @@ -383,6 +360,8 @@ class SURFACES_API cSurface // Blit surface to surface BOOL Blit(cSurface FAR & dest) const; + // New MMF 2.5 : HIBYTE(dwBlitFlags) = blend coefficient + BOOL Blit(cSurface FAR & dest, int destX, int destY, BlitMode bm = BMODE_OPAQUE, BlitOp bo = BOP_COPY, LPARAM param = 0, DWORD dwBlitFlags = 0) const; @@ -395,11 +374,10 @@ class SURFACES_API cSurface // Extended blit : can do stretch & rotate at the same time // Only implemented in 3D mode -#ifdef HWABETA BOOL BlitEx(cSurface FAR & dest, float dX, float dY, float fScaleX, float fScaleY, int sX, int sY, int sW, int sH, LPPOINT pCenter, float fAngle, BlitMode bm = BMODE_OPAQUE, BlitOp bo = BOP_COPY, LPARAM param = 0, DWORD dwFlags = 0) const; -#endif + // Scrolling BOOL Scroll (int xDest, int yDest, int xSrc, int ySrc, int width, int height); @@ -467,9 +445,7 @@ class SURFACES_API cSurface BOOL Fill(int x, int y, int w, int h, CFillData FAR * fd); BOOL Fill(int x, int y, int w, int h, int index); BOOL Fill(int x, int y, int w, int h, int R, int G, int B); -#ifdef HWABETA BOOL Fill(int x, int y, int w, int h, COLORREF* pColors, DWORD dwFlags); -#endif // ====================== // Geometric Primitives @@ -548,11 +524,7 @@ class SURFACES_API cSurface BOOL CreateRotatedSurface (cSurface FAR& ps, double a, BOOL bAA, COLORREF clrFill = 0L, BOOL bTransp=TRUE); BOOL CreateRotatedSurface (cSurface FAR& ps, int a, BOOL bAA, COLORREF clrFill = 0L, BOOL bTransp=TRUE); -#ifdef HWABETA static void GetSizeOfRotatedRect (int FAR *pWidth, int FAR *pHeight, float angle); -#else - static void GetSizeOfRotatedRect (int FAR *pWidth, int FAR *pHeight, int angle); -#endif // ====================== // Text @@ -623,9 +595,7 @@ class SURFACES_API cSurface void RestoreWindowedMode(HWND hWnd); void CopyScreenModeInfo(cSurface* pSrc); -#ifdef HWABETA BOOL SetAutoVSync(int nAutoVSync); -#endif BOOL WaitForVBlank(); // System colors @@ -636,6 +606,7 @@ class SURFACES_API cSurface void SetTransparentColor(COLORREF rgb); COLORREF GetTransparentColor(); int GetTransparentColorIndex(); +// void SetOpaque(BOOL bOpaque); // Alpha channel BOOL HasAlpha(); @@ -650,14 +621,12 @@ class SURFACES_API cSurface void ReleaseAlphaSurface(cSurface* pAlphaSf); // Transparent monochrome mask - DWORD CreateMask(LPSMASK pMask, UINT dwFlags); + DWORD CreateMask(LPSMASK pMask, UINT dwFlags); // Lost device callback -#ifdef HWABETA void OnLostDevice(); void AddLostDeviceCallBack(LOSTDEVICECALLBACKPROC pCallback, LPARAM lUserParam); void RemoveLostDeviceCallBack(LOSTDEVICECALLBACKPROC pCallback, LPARAM lUserParam); -#endif // Friend functions // ---------------- diff --git a/Inc/WinMacro.h b/Inc/WinMacro.h index 82c50d5..02aa31f 100644 --- a/Inc/WinMacro.h +++ b/Inc/WinMacro.h @@ -9,7 +9,7 @@ #ifdef WIN32 // Fonctions C -#ifndef _fmemcpy +#ifndef _fmalloc #define _fmemcpy(a, b, c) memcpy(a, b, c) #define _fmemccpy(a,b,c,d) _memccpy(a,b,c,d); #define _fmemmove(a, b, c) memmove(a, b, c) diff --git a/Inc/cncr.h b/Inc/cncr.h index d87c8a6..3c09e0c 100644 --- a/Inc/cncr.h +++ b/Inc/cncr.h @@ -14,6 +14,7 @@ class CRunApp; class CEffectEx; class CPList; #endif +class CPArray; #else #define cSurface void #define CTransition void @@ -22,6 +23,7 @@ class CPList; #define CEffectEx void #define CPList void #endif +#define CPArray void #endif ////////////////////////////////////////////////////////////////////////////// @@ -175,6 +177,10 @@ typedef struct RunFrameLayer LPARAM dwEffectParam; // CEffectEx si extended #endif // HWABETA + // LO index lists per zone + // /zone : offset 1st index, # indexes + CPArray* m_loZones; + // Backup for restart DWORD backUp_dwOptions; float backUp_xCoef; @@ -182,11 +188,6 @@ typedef struct RunFrameLayer DWORD backUp_nBkdLOs; DWORD backUp_nFirstLOIndex; -#ifdef HWABETA -// DWORD backUp_dwEffect; // A voir -// LPARAM backUp_dwEffectParam; -#endif // HWABETA - } RunFrameLayer; // Object transition data @@ -328,7 +329,7 @@ typedef struct CRunFrame { LPTSTR m_pTempString[MAX_TEMPSTRING]; // not used // Other - cSurface* m_pSaveSurface; + LPVOID m_pfree; // cSurface* m_pSaveSurface; int m_leEditWinWidth; int m_leEditWinHeight; DWORD m_dwColMaskBits; @@ -351,6 +352,18 @@ typedef struct CRunFrame { // List of sub-app surfaces to refresh at the end in D3D full screen mode CPList* m_pSurfacedSubApps; + + // Scale & angle + float m_xScale; + float m_yScale; + float m_scale; // not used for display + float m_angle; + + // Hotspot + POINT m_hotSpot; + + // Destination point + POINT m_destPoint; #endif #ifdef __cplusplus @@ -576,16 +589,14 @@ typedef struct CRunApp { BOOL m_bLoading; // Bluray - LPVOID m_pBROpt; + LPPLURAYAPPOPTIONS m_pBROpt; // Build info AppHeader2* m_pHdr2; // Code page -#ifdef _UNICODE DWORD m_dwCodePage; bool m_bUnicodeAppFile; -#endif // Effects #ifdef HWABETA @@ -596,6 +607,10 @@ typedef struct CRunApp { int m_nSubAppShowCount; // to show the child window otherwise it's not displayed... #endif // HWABETA + // Character encoding + DWORD m_charEncodingInput; + DWORD m_charEncodingOutput; + #ifdef __cplusplus }; #else diff --git a/Inc/json.h b/Inc/json.h index cbddc69..f6549ec 100644 --- a/Inc/json.h +++ b/Inc/json.h @@ -1,7 +1,7 @@ -/* vim: set et ts=3 sw=3 ft=c: +/* vim: set et ts=3 sw=3 sts=3 ft=c: * - * Copyright (C) 2012 James McLaughlin et al. All rights reserved. + * Copyright (C) 2012, 2013, 2014 James McLaughlin et al. All rights reserved. * https://github.com/udp/json-parser * * Redistribution and use in source and binary forms, with or without @@ -35,6 +35,17 @@ #define json_char char #endif +#ifndef json_int_t + #ifndef _MSC_VER + #include + #define json_int_t int64_t + #else + #define json_int_t __int64 + #endif +#endif + +#include + #ifdef __cplusplus #include @@ -49,9 +60,19 @@ typedef struct unsigned long max_memory; int settings; + /* Custom allocator support (leave null to use malloc/free) + */ + + void * (* mem_alloc) (size_t, int zero, void * user_data); + void (* mem_free) (void *, void * user_data); + + void * user_data; /* will be passed to mem_alloc and mem_free */ + + size_t value_extra; /* how much extra space to allocate for values? */ + } json_settings; -#define json_relaxed_commas 1 +#define json_enable_comments 0x01 typedef enum { @@ -67,6 +88,15 @@ typedef enum } json_type; extern const struct _json_value json_value_none; + +typedef struct _json_object_entry +{ + json_char * name; + unsigned int name_length; + + struct _json_value * value; + +} json_object_entry; typedef struct _json_value { @@ -77,7 +107,7 @@ typedef struct _json_value union { int boolean; - long integer; + json_int_t integer; double dbl; struct @@ -91,12 +121,16 @@ typedef struct _json_value { unsigned int length; - struct - { - json_char * name; - struct _json_value * value; + json_object_entry * values; - } * values; + #if defined(__cplusplus) && __cplusplus >= 201103L + decltype(values) begin () const + { return values; + } + decltype(values) end () const + { return values + length; + } + #endif } object; @@ -105,6 +139,15 @@ typedef struct _json_value unsigned int length; struct _json_value ** values; + #if defined(__cplusplus) && __cplusplus >= 201103L + decltype(values) begin () const + { return values; + } + decltype(values) end () const + { return values + length; + } + #endif + } array; } u; @@ -116,6 +159,14 @@ typedef struct _json_value } _reserved; + #ifdef JSON_TRACK_SOURCE + + /* Location of the value in the source JSON + */ + unsigned int line, col; + + #endif + /* Some C++ operator sugar */ @@ -162,27 +213,67 @@ typedef struct _json_value }; } - inline operator long () const - { return u.integer; + inline operator json_int_t () const + { + switch (type) + { + case json_integer: + return u.integer; + + case json_double: + return (json_int_t) u.dbl; + + default: + return 0; + }; } inline operator bool () const - { return u.boolean != 0; + { + if (type != json_boolean) + return false; + + return u.boolean != 0; + } + + inline operator double () const + { + switch (type) + { + case json_integer: + return (double) u.integer; + + case json_double: + return u.dbl; + + default: + return 0; + }; } #endif } json_value; + +json_value * json_parse (const json_char * json, + size_t length); -json_value * json_parse - (const json_char * json); - -json_value * json_parse_ex - (json_settings * settings, const json_char * json, char * error); +#define json_error_max 128 +json_value * json_parse_ex (json_settings * settings, + const json_char * json, + size_t length, + char * error); void json_value_free (json_value *); +/* Not usually necessary, unless you used a custom mem_alloc and now want to + * use a custom mem_free. + */ +void json_value_free_ex (json_settings * settings, + json_value *); + + #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/Lib/Edif.Edittime.cpp b/Lib/Edif.Edittime.cpp index 7f52dbf..fa9bd52 100644 --- a/Lib/Edif.Edittime.cpp +++ b/Lib/Edif.Edittime.cpp @@ -1,18 +1,18 @@ - #include "Common.h" +using namespace std; void WINAPI DLLExport GetObjInfos (mv _far *mV, void *, LPTSTR ObjName, LPTSTR ObjAuthor, - LPTSTR ObjCopyright, LPTSTR ObjComment, LPTSTR ObjHttp) + LPTSTR ObjCopyright, LPTSTR ObjComment, LPTSTR ObjHttp) { #ifndef RUN_ONLY - const json_value &Properties = SDK->json["About"]; + const json_value &Properties = SDK->json["About"]; - Edif::ConvertAndCopyString(ObjAuthor, Properties["Author"], MAX_PATH); - Edif::ConvertAndCopyString(ObjCopyright, Properties["Copyright"],MAX_PATH); - Edif::ConvertAndCopyString(ObjComment, Properties["Comment"], MAX_PATH); - Edif::ConvertAndCopyString(ObjHttp, Properties["URL"], MAX_PATH); - Edif::ConvertAndCopyString(ObjName, Properties["Name"], MAX_PATH); + Edif::ConvertAndCopyString(ObjAuthor, Properties["Author"], MAX_PATH); + Edif::ConvertAndCopyString(ObjCopyright,Properties["Copyright"],MAX_PATH); + Edif::ConvertAndCopyString(ObjComment, Properties["Comment"], MAX_PATH); + Edif::ConvertAndCopyString(ObjHttp, Properties["URL"], MAX_PATH); + Edif::ConvertAndCopyString(ObjName, Properties["Name"], MAX_PATH); #endif // !defined(RUN_ONLY) @@ -21,16 +21,13 @@ void WINAPI DLLExport GetObjInfos (mv _far *mV, void *, LPTSTR ObjName, LPTSTR O LPCTSTR WINAPI GetHelpFileName() { #ifndef RUN_ONLY - // Return a file without path if your help file can be loaded by the MMF help file. -// return "MyExt.chm"; - // Or return the path of your file, relatively to the MMF directory - // if your file is not loaded by the MMF help file. - static TCHAR TempString[MAX_PATH]; // used by GetHelpFileName() + static TCHAR TempString[MAX_PATH]; return Edif::ConvertAndCopyString(TempString, SDK->json["About"]["Help"], MAX_PATH); -#else - return NULL; + #endif // !defined(RUN_ONLY) + + return NULL; } void WINAPI DLLExport GetConditionTitle(mv _far *mV, short code, short param, LPTSTR strBuf, short maxLen) @@ -38,14 +35,14 @@ void WINAPI DLLExport GetConditionTitle(mv _far *mV, short code, short param, LP #ifndef RUN_ONLY if(!IS_COMPATIBLE(mV)) - return; + return; - const json_value &Parameter = SDK->json["Conditions"][code]["Parameters"][param]; + const json_value &Parameter = SDK->json["Conditions"][code]["Parameters"][param]; - if(Parameter.type == json_object) - Edif::ConvertAndCopyString(strBuf, Parameter["Title"], maxLen); - else - Edif::ConvertAndCopyString(strBuf, Parameter[1], maxLen); + if(Parameter.type == json_object) + Edif::ConvertAndCopyString(strBuf, Parameter["Title"], maxLen); + else + Edif::ConvertAndCopyString(strBuf, Parameter[1], maxLen); #endif // !defined(RUN_ONLY) } @@ -55,14 +52,14 @@ void WINAPI DLLExport GetActionTitle(mv _far *mV, short code, short param, LPTST #ifndef RUN_ONLY if(!IS_COMPATIBLE(mV)) - return; + return; - const json_value &Parameter = SDK->json["Actions"][code]["Parameters"][param]; + const json_value &Parameter = SDK->json["Actions"][code]["Parameters"][param]; - if(Parameter.type == json_object) - Edif::ConvertAndCopyString(strBuf, Parameter["Title"], maxLen); - else - Edif::ConvertAndCopyString(strBuf, Parameter[1], maxLen); + if(Parameter.type == json_object) + Edif::ConvertAndCopyString(strBuf, Parameter["Title"], maxLen); + else + Edif::ConvertAndCopyString(strBuf, Parameter[1], maxLen); #endif // !defined(RUN_ONLY) } @@ -73,14 +70,14 @@ void WINAPI DLLExport GetExpressionParam(mv _far *mV, short code, short param, L #ifndef RUN_ONLY if(!IS_COMPATIBLE(mV)) - return; + return; - const json_value &Parameter = SDK->json["Expressions"][code]["Parameters"][param]; + const json_value &Parameter = SDK->json["Expressions"][code]["Parameters"][param]; - if(Parameter.type == json_object) - Edif::ConvertAndCopyString(strBuf, Parameter["Title"], maxLen); - else - Edif::ConvertAndCopyString(strBuf, Parameter[1], maxLen); + if(Parameter.type == json_object) + Edif::ConvertAndCopyString(strBuf, Parameter["Title"], maxLen); + else + Edif::ConvertAndCopyString(strBuf, Parameter[1], maxLen); #endif // !defined(RUN_ONLY) @@ -92,9 +89,9 @@ void WINAPI DLLExport GetExpressionTitle(mv _far *mV, short code, LPTSTR strBuf, #ifndef RUN_ONLY if(!IS_COMPATIBLE(mV)) - return; + return; - Edif::ConvertAndCopyString(strBuf, SDK->json["Expressions"][code]["Title"], maxLen); + Edif::ConvertAndCopyString(strBuf, SDK->json["Expressions"][code]["Title"], maxLen); #endif // !defined(RUN_ONLY) } @@ -104,9 +101,9 @@ void WINAPI DLLExport GetConditionString(mv _far *mV, short code, LPTSTR strPtr, #ifndef RUN_ONLY if(!IS_COMPATIBLE(mV)) - return; + return; - Edif::ConvertAndCopyString(strPtr, SDK->json["Conditions"][code]["Title"], maxLen); + Edif::ConvertAndCopyString(strPtr, SDK->json["Conditions"][code]["Title"], maxLen); #endif // !defined(RUN_ONLY) } @@ -116,9 +113,9 @@ void WINAPI DLLExport GetActionString(mv _far *mV, short code, LPTSTR strPtr, sh #ifndef RUN_ONLY if(!IS_COMPATIBLE(mV)) - return; + return; - Edif::ConvertAndCopyString(strPtr, SDK->json["Actions"][code]["Title"], maxLen); + Edif::ConvertAndCopyString(strPtr, SDK->json["Actions"][code]["Title"], maxLen); #endif // !defined(RUN_ONLY) } @@ -128,9 +125,9 @@ void WINAPI DLLExport GetExpressionString(mv _far *mV, short code, LPTSTR strPtr #ifndef RUN_ONLY if(!IS_COMPATIBLE(mV)) - return; + return; - Edif::ConvertAndCopyString(strPtr, SDK->json["Expressions"][code]["Title"], maxLen); + Edif::ConvertAndCopyString(strPtr, SDK->json["Expressions"][code]["Title"], maxLen); #endif // !defined(RUN_ONLY) } @@ -168,11 +165,17 @@ LPINFOEVENTSV2 WINAPI DLLExport GetExpressionInfos(mv _far *mV, short code) return NULL; } +#ifndef RUN_ONLY +short InterceptActionSelection(mv *mV, short selectedId); +short InterceptConditionSelection(mv *mV, short selectedId); +short InterceptExpressionSelection(mv *mV, short selectedId); +#endif + short WINAPI DLLExport GetConditionCodeFromMenu(mv _far *mV, short menuId) { #ifndef RUN_ONLY - return menuId - Edif::ConditionID(0); + return InterceptConditionSelection(mV, menuId - Edif::ConditionID(0)); #endif // !defined(RUN_ONLY) return -1; @@ -182,7 +185,7 @@ short WINAPI DLLExport GetActionCodeFromMenu(mv _far *mV, short menuId) { #ifndef RUN_ONLY - return menuId - Edif::ActionID(0); + return InterceptActionSelection(mV, menuId - Edif::ActionID(0)); #endif // !defined(RUN_ONLY) return -1; @@ -192,7 +195,7 @@ short WINAPI DLLExport GetExpressionCodeFromMenu(mv _far *mV, short menuId) { #ifndef RUN_ONLY - return menuId - Edif::ExpressionID(0); + return InterceptExpressionSelection(mV, menuId - Edif::ExpressionID(0)); #endif // !defined(RUN_ONLY) return -1; @@ -233,11 +236,11 @@ HMENU WINAPI DLLExport GetConditionMenu(mv _far *mV, fpObjInfo oiPtr, LPEDATA ed #ifndef RUN_ONLY // Check compatibility if ( IS_COMPATIBLE(mV) ) - { - HMENU Menu = CreatePopupMenu(); - menucpy(Menu, Edif::ConditionMenu); + { + HMENU Menu = CreatePopupMenu(); + menucpy(Menu, Edif::ConditionMenu); return Menu; - } + } #endif // !defined(RUN_ONLY) return NULL; } @@ -247,11 +250,11 @@ HMENU WINAPI DLLExport GetActionMenu(mv _far *mV, fpObjInfo oiPtr, LPEDATA edPtr #ifndef RUN_ONLY // Check compatibility if ( IS_COMPATIBLE(mV) ) - { - HMENU Menu = CreatePopupMenu(); - menucpy(Menu, Edif::ActionMenu); - return Menu; - } + { + HMENU Menu = CreatePopupMenu(); + menucpy(Menu, Edif::ActionMenu); + return Menu; + } #endif // !defined(RUN_ONLY) return NULL; } @@ -261,11 +264,11 @@ HMENU WINAPI DLLExport GetExpressionMenu(mv _far *mV, fpObjInfo oiPtr, LPEDATA e #ifndef RUN_ONLY // Check compatibility if ( IS_COMPATIBLE(mV) ) - { - HMENU Menu = CreatePopupMenu(); - menucpy(Menu, Edif::ExpressionMenu); + { + HMENU Menu = CreatePopupMenu(); + menucpy(Menu, Edif::ExpressionMenu); return Menu; - } + } #endif // !defined(RUN_ONLY) return NULL; } @@ -276,7 +279,7 @@ HMENU WINAPI DLLExport GetExpressionMenu(mv _far *mV, fpObjInfo oiPtr, LPEDATA e #define _tstring string #endif -void AddDirectory(_tstring &From, _tstring &To) +void AddDirectory(_tstring const &From, _tstring const &To) { HANDLE FileHandle; WIN32_FIND_DATA Filejson; @@ -289,12 +292,12 @@ void AddDirectory(_tstring &From, _tstring &To) FileHandle = FindFirstFile(SearchString.c_str(), &Filejson); if(FileHandle == INVALID_HANDLE_VALUE) - return; + return; do { - if(*Filejson.cFileName == '.') - continue; + if(*Filejson.cFileName == '.') + continue; if((Filejson.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0) { @@ -313,7 +316,7 @@ void AddDirectory(_tstring &From, _tstring &To) CreateDirectory(NewPath.c_str(), 0); AddDirectory(OldPath, NewPath); - continue; + continue; } CopyFile((From + Filejson.cFileName).c_str(), (To + Filejson.cFileName).c_str(), FALSE); @@ -327,25 +330,25 @@ void WINAPI PrepareFlexBuild(LPMV pMV, LPEDATA edPtr, LPCWSTR wTempFolder) { #if !defined(RUN_ONLY) - TCHAR FlashFolderPath[MAX_PATH]; - Edif::GetSiblingPath(FlashFolderPath, _T("Flash")); + TCHAR FlashFolderPath[MAX_PATH]; + Edif::GetSiblingPath(FlashFolderPath, _T("Flash")); - if (!*FlashFolderPath) - return; + if (!*FlashFolderPath) + return; - LPTSTR TempFolder; + LPTSTR TempFolder; #ifdef _UNICODE TempFolder = (LPTSTR)wTempFolder; #else - { size_t Length = WideCharToMultiByte(CP_ACP, 0, wTempFolder, -1, 0, 0, 0, 0); - TempFolder = (LPSTR) alloca(Length + 1); + { size_t Length = WideCharToMultiByte(CP_ACP, 0, wTempFolder, -1, 0, 0, 0, 0); + TempFolder = (LPSTR) new char[Length + 1]; - WideCharToMultiByte(CP_ACP, 0, wTempFolder, -1, TempFolder, Length, 0, 0); - } + WideCharToMultiByte(CP_ACP, 0, wTempFolder, -1, TempFolder, Length, 0, 0); + } #endif - AddDirectory(((_tstring) FlashFolderPath + _T("\\")), (_tstring) TempFolder); + AddDirectory(((_tstring) FlashFolderPath + _T("\\")), (_tstring) TempFolder); #endif // !defined(RUN_ONLY) } diff --git a/Lib/Edif.General.cpp b/Lib/Edif.General.cpp index 7d49fb8..baf579e 100644 --- a/Lib/Edif.General.cpp +++ b/Lib/Edif.General.cpp @@ -5,47 +5,47 @@ LPCTSTR * Dependencies = 0; LPCTSTR * WINAPI DLLExport GetDependencies() { if(!Dependencies) - { - const json_value &DependenciesJSON = SDK->json["About"]["Dependencies"]; + { + const json_value &DependenciesJSON = SDK->json["About"]["Dependencies"]; - Dependencies = new LPCTSTR [DependenciesJSON.u.array.length + 2]; + Dependencies = new LPCTSTR [DependenciesJSON.u.array.length + 2]; - int Offset = 0; + int Offset = 0; - if (Edif::ExternalJSON) - { - TCHAR * JSONFilename = (TCHAR *)malloc(MAX_PATH * sizeof(TCHAR)); + if (Edif::ExternalJSON) + { + TCHAR JSONFilename [MAX_PATH * sizeof(TCHAR)]; - GetModuleFileName (hInstLib, JSONFilename, MAX_PATH); + GetModuleFileName (hInstLib, JSONFilename, MAX_PATH); - TCHAR * Iterator = JSONFilename + _tcslen(JSONFilename) - 1; + TCHAR * Iterator = JSONFilename + _tcslen(JSONFilename) - 1; - while(*Iterator != '.') - -- Iterator; + while(*Iterator != '.') + -- Iterator; - _tcscpy(++ Iterator, _T("json")); + _tcscpy(++ Iterator, _T("json")); - Iterator = JSONFilename + _tcslen(JSONFilename) - 1; + Iterator = JSONFilename + _tcslen(JSONFilename) - 1; - while(*Iterator != '\\' && *Iterator != '/') - -- Iterator; + while(*Iterator != '\\' && *Iterator != '/') + -- Iterator; - Dependencies [Offset ++] = ++ Iterator; - } + Dependencies [Offset ++] = ++ Iterator; + } - unsigned int i = 0; + unsigned int i = 0; - for(; i < DependenciesJSON.u.array.length; ++ i) + for(; i < DependenciesJSON.u.array.length; ++ i) { TCHAR* tstr = Edif::ConvertString(DependenciesJSON[i]); - Dependencies[Offset + i] = tstr; + Dependencies[Offset + i] = tstr; //Edif::FreeString(tstr); } - Dependencies[Offset + i] = 0; - } + Dependencies[Offset + i] = 0; + } - return Dependencies; + return Dependencies; } short WINAPI DLLExport GetRunObjectInfos(mv _far *mV, fpKpxRunInfos infoPtr) @@ -60,15 +60,29 @@ short WINAPI DLLExport GetRunObjectInfos(mv _far *mV, fpKpxRunInfos infoPtr) infoPtr->editDataSize = sizeof(EDITDATA); - infoPtr->windowProcPriority = Extension::WindowProcPriority; + infoPtr->windowProcPriority = Extension::WindowProcPriority; infoPtr->editFlags = Extension::OEFLAGS; infoPtr->editPrefs = Extension::OEPREFS; - memcpy(&infoPtr->identifier, SDK->json["About"]["Identifier"], 4); - - infoPtr->version = Extension::Version; - + json_value const &identifier = SDK->json["About"]["Identifier"]; + if(identifier.type == json_string) + { + memcpy(&infoPtr->identifier, identifier, 4); + } + else if(identifier.type == json_integer) + { + long id = static_cast(identifier.u.integer); + memcpy(&infoPtr->identifier, reinterpret_cast(&id), 4); + } + else + { + MessageBox(NULL, _T("Invalid Object Identifier!"), _T("EDIF Extension SDK"), MB_OK); + return FALSE; + } + + infoPtr->version = Extension::Version; + return TRUE; } @@ -80,33 +94,33 @@ extern "C" switch (info) { case KGI_VERSION: - return EXT_VERSION2; + return EXT_VERSION3; case KGI_PLUGIN: - return EXT_PLUGIN_VERSION1; + return EXT_PLUGIN_VERSION2; case KGI_PRODUCT: - #ifdef PROEXT - return PRODUCT_VERSION_DEV; - #endif + #ifdef PROEXT + return PRODUCT_VERSION_DEV; + #endif - #ifdef TGFEXT - return PRODUCT_VERSION_HOME; - #endif + #ifdef TGFEXT + return PRODUCT_VERSION_HOME; + #endif - return PRODUCT_VERSION_STANDARD; + return PRODUCT_VERSION_STANDARD; case KGI_BUILD: return Extension::MinimumBuild; - case KGI_UNICODE: + case KGI_UNICODE: - #ifdef _UNICODE - return TRUE; - #else - return FALSE; - #endif + #ifdef _UNICODE + return TRUE; + #else + return FALSE; + #endif default: return 0; @@ -154,14 +168,14 @@ short WINAPI DLLExport CreateRunObject(LPRDATA rdPtr, LPEDATA edPtr, fpcob cobPt short WINAPI DLLExport DestroyRunObject(LPRDATA rdPtr, long fast) { - delete rdPtr->pExtension; + delete rdPtr->pExtension; return 0; } short WINAPI DLLExport HandleRunObject(LPRDATA rdPtr) { - return rdPtr->pExtension->Handle(); + return rdPtr->pExtension->Handle(); } short WINAPI DLLExport DisplayRunObject(LPRDATA rdPtr) @@ -185,13 +199,13 @@ short WINAPI DLLExport ContinueRunObject(LPRDATA rdPtr) } BOOL WINAPI SaveRunObject(LPRDATA rdPtr, HANDLE hf) -{ - return rdPtr->pExtension->Save(hf) ? TRUE : FALSE; +{ + return rdPtr->pExtension->Save(hf) ? TRUE : FALSE; } BOOL WINAPI LoadRunObject(LPRDATA rdPtr, HANDLE hf) -{ - return rdPtr->pExtension->Load(hf) ? TRUE : FALSE; +{ + return rdPtr->pExtension->Load(hf) ? TRUE : FALSE; } LPEVENTINFOS2 GetEventInformations(LPEVENTINFOS2 eiPtr, short code) diff --git a/Lib/Edif.Runtime.cpp b/Lib/Edif.Runtime.cpp index 6b20f87..41c8947 100644 --- a/Lib/Edif.Runtime.cpp +++ b/Lib/Edif.Runtime.cpp @@ -1,277 +1,285 @@ -#include "Common.h" - -Edif::Runtime::Runtime(LPRDATA _rdPtr) : rdPtr(_rdPtr), ObjectSelection(_rdPtr->rHo.hoAdRunHeader) -{ -} - -Edif::Runtime::~Runtime() -{ -} - -void Edif::Runtime::Rehandle() -{ - callRunTimeFunction(rdPtr, RFUNCTION_REHANDLE, 0, 0); -} - -void Edif::Runtime::GenerateEvent(int EventID) -{ - callRunTimeFunction(rdPtr, RFUNCTION_GENERATEEVENT, EventID, 0); -} - -void Edif::Runtime::PushEvent(int EventID) -{ - callRunTimeFunction(rdPtr, RFUNCTION_PUSHEVENT, EventID, 0); -} - -void * Edif::Runtime::Allocate(size_t Size) -{ - return (void *) callRunTimeFunction(rdPtr, RFUNCTION_GETSTRINGSPACE_EX, 0, Size * sizeof(TCHAR)); -} - -TCHAR * Edif::Runtime::CopyString(const TCHAR * String) -{ - TCHAR * New = (TCHAR *) Allocate(_tcslen(String) + 1); - _tcscpy(New, String); - - return New; -} - -void Edif::Runtime::Pause() -{ - callRunTimeFunction(rdPtr, RFUNCTION_PAUSE, 0, 0); -} - -void Edif::Runtime::Resume() -{ - callRunTimeFunction(rdPtr, RFUNCTION_CONTINUE, 0, 0); -} - -void Edif::Runtime::Redisplay() -{ - callRunTimeFunction(rdPtr, RFUNCTION_REDISPLAY, 0, 0); -} - -void Edif::Runtime::GetApplicationDrive(TCHAR * Buffer) -{ - callRunTimeFunction(rdPtr, RFUNCTION_GETFILEINFOS, FILEINFO_DRIVE, (long) Buffer); -} - -void Edif::Runtime::GetApplicationDirectory(TCHAR * Buffer) -{ - callRunTimeFunction(rdPtr, RFUNCTION_GETFILEINFOS, FILEINFO_DIR, (long) Buffer); -} - -void Edif::Runtime::GetApplicationPath(TCHAR * Buffer) -{ - callRunTimeFunction(rdPtr, RFUNCTION_GETFILEINFOS, FILEINFO_PATH, (long) Buffer); -} - -void Edif::Runtime::GetApplicationName(TCHAR * Buffer) -{ - callRunTimeFunction(rdPtr, RFUNCTION_GETFILEINFOS, FILEINFO_APPNAME, (long) Buffer); -} - -void Edif::Runtime::GetApplicationTempPath(TCHAR * Buffer) -{ - callRunTimeFunction(rdPtr, RFUNCTION_GETFILEINFOS, FILEINFO_TEMPPATH, (long) Buffer); -} - -void Edif::Runtime::Redraw() -{ - callRunTimeFunction(rdPtr, RFUNCTION_REDRAW, 0, 0); -} - -void Edif::Runtime::Destroy() -{ - callRunTimeFunction(rdPtr, RFUNCTION_DESTROY, 0, 0); -} - -void Edif::Runtime::ExecuteProgram(prgParam * Program) -{ - callRunTimeFunction(rdPtr, RFUNCTION_EXECPROGRAM, 0, (long) Program); -} - -long Edif::Runtime::EditInteger(EditDebugInfo * EDI) -{ - return callRunTimeFunction(rdPtr, RFUNCTION_EDITINT, 0, (long) EDI); -} - -long Edif::Runtime::EditText(EditDebugInfo * EDI) -{ - return callRunTimeFunction(rdPtr, RFUNCTION_EDITTEXT, 0, (long) EDI); -} - -void Edif::Runtime::CallMovement(int ID, long Parameter) -{ - callRunTimeFunction(rdPtr, RFUNCTION_CALLMOVEMENT, ID, Parameter); -} - -void Edif::Runtime::SetPosition(int X, int Y) -{ - callRunTimeFunction(rdPtr, RFUNCTION_SETPOSITION, X, Y); -} - -CallTables* Edif::Runtime::GetCallTables() -{ - return (CallTables*)callRunTimeFunction(rdPtr, RFUNCTION_GETCALLTABLES, 0, 0); -} - -bool Edif::Runtime::IsHWA() -{ - return rdPtr->rHo.hoAdRunHeader->rh4.rh4Mv->mvCallFunction(NULL, 112, 0, 0, 0) == 1; -} - -bool Edif::Runtime::IsUnicode() -{ - return rdPtr->rHo.hoAdRunHeader->rh4.rh4Mv->mvCallFunction(NULL, 113, 0, 0, 0) == 1; -} - -event &Edif::Runtime::CurrentEvent() -{ - return *(event *) (((char *) param1) - CND_SIZE); -} - -LPRO Edif::Runtime::LPROFromFixed(int fixedvalue) -{ - LPOBL objList = rdPtr->rHo.hoAdRunHeader->rhObjectList; - int index = 0x0000FFFF & fixedvalue; - - if (index < 0 || index >= rdPtr->rHo.hoAdRunHeader->rhMaxObjects) - return NULL; - - LPRO theObject = (LPRO)objList[0x0000FFFF & fixedvalue].oblOffset; - - if (theObject == NULL) - return NULL; - else if (FixedFromLPRO(theObject) != fixedvalue) - return NULL; - - return theObject; -} - -int Edif::Runtime::FixedFromLPRO(LPRO object) -{ - if(object != NULL) - return (object->roHo.hoCreationId << 16) + object->roHo.hoNumber; - return 0; -} - -void Edif::Runtime::SetAngleOfObject(LPRO object, float acAngle) -{ - if(object == NULL) - return; - - if(IsHWA()) - memcpy(&object->roc.rcAngle, (int*)&acAngle, sizeof(int)); - else - object->roc.rcAngle = (int)acAngle; - -} - -extern HINSTANCE hInstLib; - -struct EdifGlobal -{ - TCHAR Name[256]; - void * Value; - - EdifGlobal * Next; -}; - -void Edif::Runtime::WriteGlobal(const TCHAR * Name, void * Value) -{ - LPRH rhPtr = rdPtr->rHo.hoAdRunHeader; - - while(rhPtr->rhApp->m_pParentApp) - rhPtr = rhPtr->rhApp->m_pParentApp->m_Frame->m_rhPtr; - - EdifGlobal * Global = (EdifGlobal *) rhPtr->rh4.rh4Mv->mvGetExtUserData(rhPtr->rhApp, hInstLib); - - if(!Global) - { - Global = new EdifGlobal; - - _tcscpy(Global->Name, Name); - Global->Value = Value; - - Global->Next = 0; - - rhPtr->rh4.rh4Mv->mvSetExtUserData(rhPtr->rhApp, hInstLib, Global); - - return; - } - - while(Global) - { - if(!_tcsicmp(Global->Name, Name)) - { - Global->Value = Value; - return; - } - - if(!Global->Next) - break; - - Global = Global->Next; - } - - Global->Next = new EdifGlobal; - Global = Global->Next; - - _tcscpy(Global->Name, Name); - - Global->Value = Value; - Global->Next = 0; -} - -void * Edif::Runtime::ReadGlobal(const TCHAR * Name) -{ - LPRH rhPtr = rdPtr->rHo.hoAdRunHeader; - - while(rhPtr->rhApp->m_pParentApp) - rhPtr = rhPtr->rhApp->m_pParentApp->m_Frame->m_rhPtr; - - EdifGlobal * Global = (EdifGlobal *) rhPtr->rh4.rh4Mv->mvGetExtUserData(rhPtr->rhApp, hInstLib); - - while(Global) - { - if(!_tcsicmp(Global->Name, Name)) - return Global->Value; - - Global = Global->Next; - } - - return 0; -} - -#ifdef EdifUseJS - - /* Breaking versions of Edif should change these so that newer extensions don't - try to work with an older JS context. */ - - const char * const ContextName = "JSContext-V1"; - - - JSContext * Edif::Runtime::GetJSContext() - { - JSContext * Context = ReadGlobal(ContextName); - - if(!Context) - { - Context = JS_NewContext(JS_NewRuntime(8 * 1024 * 1024), 8192); - - JS_SetOptions(Context, JSOPTION_VAROBJFIX | JSOPTION_JIT | JSOPTION_METHODJIT | JSOPTION_NO_SCRIPT_RVAL); - JS_SetVersion(Context, JSVERSION_LATEST); - - JSObject * Global = JS_NewGlobalObject(context, &GlobalClass); - - JS_SetGlobalObject (Context, Global); - JS_InitStandardClasses(Context, Global); - - WriteGlobal(ContextName, Context); - } - - return Context; - } - -#endif +#include "Common.h" + +Edif::Runtime::Runtime(LPRDATA _rdPtr) : rdPtr(_rdPtr), ObjectSelection(_rdPtr->rHo.hoAdRunHeader) +{ +} + +Edif::Runtime::~Runtime() +{ +} + +void Edif::Runtime::Rehandle() +{ + callRunTimeFunction(rdPtr, RFUNCTION_REHANDLE, 0, 0); +} + +void Edif::Runtime::GenerateEvent(int EventID) +{ + callRunTimeFunction(rdPtr, RFUNCTION_GENERATEEVENT, EventID, 0); +} + +void Edif::Runtime::PushEvent(int EventID) +{ + callRunTimeFunction(rdPtr, RFUNCTION_PUSHEVENT, EventID, 0); +} + +void * Edif::Runtime::Allocate(size_t Size) +{ + return (void *) callRunTimeFunction(rdPtr, RFUNCTION_GETSTRINGSPACE_EX, 0, Size * sizeof(TCHAR)); +} + +TCHAR * Edif::Runtime::CopyString(const TCHAR * String) +{ + TCHAR * New = (TCHAR *) Allocate(_tcslen(String) + 1); + _tcscpy(New, String); + + return New; +} + +void Edif::Runtime::Pause() +{ + callRunTimeFunction(rdPtr, RFUNCTION_PAUSE, 0, 0); +} + +void Edif::Runtime::Resume() +{ + callRunTimeFunction(rdPtr, RFUNCTION_CONTINUE, 0, 0); +} + +void Edif::Runtime::Redisplay() +{ + callRunTimeFunction(rdPtr, RFUNCTION_REDISPLAY, 0, 0); +} + +void Edif::Runtime::GetApplicationDrive(TCHAR * Buffer) +{ + callRunTimeFunction(rdPtr, RFUNCTION_GETFILEINFOS, FILEINFO_DRIVE, (long) Buffer); +} + +void Edif::Runtime::GetApplicationDirectory(TCHAR * Buffer) +{ + callRunTimeFunction(rdPtr, RFUNCTION_GETFILEINFOS, FILEINFO_DIR, (long) Buffer); +} + +void Edif::Runtime::GetApplicationPath(TCHAR * Buffer) +{ + callRunTimeFunction(rdPtr, RFUNCTION_GETFILEINFOS, FILEINFO_PATH, (long) Buffer); +} + +void Edif::Runtime::GetApplicationName(TCHAR * Buffer) +{ + callRunTimeFunction(rdPtr, RFUNCTION_GETFILEINFOS, FILEINFO_APPNAME, (long) Buffer); +} + +void Edif::Runtime::GetApplicationTempPath(TCHAR * Buffer) +{ + callRunTimeFunction(rdPtr, RFUNCTION_GETFILEINFOS, FILEINFO_TEMPPATH, (long) Buffer); +} + +void Edif::Runtime::Redraw() +{ + callRunTimeFunction(rdPtr, RFUNCTION_REDRAW, 0, 0); +} + +void Edif::Runtime::Destroy() +{ + callRunTimeFunction(rdPtr, RFUNCTION_DESTROY, 0, 0); +} + +void Edif::Runtime::ExecuteProgram(prgParam * Program) +{ + callRunTimeFunction(rdPtr, RFUNCTION_EXECPROGRAM, 0, (long) Program); +} + +long Edif::Runtime::EditInteger(EditDebugInfo * EDI) +{ + return callRunTimeFunction(rdPtr, RFUNCTION_EDITINT, 0, (long) EDI); +} + +long Edif::Runtime::EditText(EditDebugInfo * EDI) +{ + return callRunTimeFunction(rdPtr, RFUNCTION_EDITTEXT, 0, (long) EDI); +} + +void Edif::Runtime::CallMovement(int ID, long Parameter) +{ + callRunTimeFunction(rdPtr, RFUNCTION_CALLMOVEMENT, ID, Parameter); +} + +void Edif::Runtime::SetPosition(int X, int Y) +{ + callRunTimeFunction(rdPtr, RFUNCTION_SETPOSITION, X, Y); +} + +CallTables* Edif::Runtime::GetCallTables() +{ + return (CallTables*)callRunTimeFunction(rdPtr, RFUNCTION_GETCALLTABLES, 0, 0); +} + +bool Edif::Runtime::IsHWA() +{ + return rdPtr->rHo.hoAdRunHeader->rh4.rh4Mv->mvCallFunction(NULL, 112, 0, 0, 0) == 1; +} + +bool Edif::Runtime::IsUnicode() +{ + return rdPtr->rHo.hoAdRunHeader->rh4.rh4Mv->mvCallFunction(NULL, 113, 0, 0, 0) == 1; +} + +event &Edif::Runtime::CurrentEvent() +{ + return *(event *) (((char *) param1) - CND_SIZE); +} + +LPRO Edif::Runtime::LPROFromFixed(int fixedvalue) +{ + LPOBL objList = rdPtr->rHo.hoAdRunHeader->rhObjectList; + int index = 0x0000FFFF & fixedvalue; + + if (index < 0 || index >= rdPtr->rHo.hoAdRunHeader->rhMaxObjects) + return NULL; + + LPRO theObject = (LPRO)objList[0x0000FFFF & fixedvalue].oblOffset; + + if (theObject == NULL) + return NULL; + else if (FixedFromLPRO(theObject) != fixedvalue) + return NULL; + + return theObject; +} + +int Edif::Runtime::FixedFromLPRO(LPRO object) +{ + if(object != NULL) + return (object->roHo.hoCreationId << 16) + object->roHo.hoNumber; + return 0; +} + +void Edif::Runtime::SetAngleOfObject(LPRO object, float acAngle) +{ + if(object == NULL) + return; + + if(IsHWA()) + memcpy(&object->roc.rcAngle, (int*)&acAngle, sizeof(int)); + else + object->roc.rcAngle = (ANGLETYPE)acAngle; + +} + +struct EdifGlobal +{ + TCHAR Name[256]; + void * Value; + + EdifGlobal * Next; +}; + +void Edif::Runtime::WriteGlobal(mv * mV, CRunApp * App, const TCHAR * Name, void * Value) +{ + EdifGlobal * Global = (EdifGlobal *) mV->mvGetExtUserData(App, hInstLib); + + if(!Global) + { + Global = new EdifGlobal; + + _tcscpy(Global->Name, Name); + Global->Value = Value; + + Global->Next = 0; + + mV->mvSetExtUserData(App, hInstLib, Global); + + return; + } + + while(Global) + { + if(!_tcsicmp(Global->Name, Name)) + { + Global->Value = Value; + return; + } + + if(!Global->Next) + break; + + Global = Global->Next; + } + + Global->Next = new EdifGlobal; + Global = Global->Next; + + _tcscpy(Global->Name, Name); + + Global->Value = Value; + Global->Next = 0; +} + +void Edif::Runtime::WriteGlobal(const TCHAR * Name, void * Value) +{ + LPRH rhPtr = rdPtr->rHo.hoAdRunHeader; + + while(rhPtr->rhApp->m_pParentApp) + rhPtr = rhPtr->rhApp->m_pParentApp->m_Frame->m_rhPtr; + + WriteGlobal(rhPtr->rh4.rh4Mv, rhPtr->rhApp, Name, Value); +} + +void * Edif::Runtime::ReadGlobal(mv * mV, CRunApp * App, const TCHAR * Name) +{ + EdifGlobal * Global = (EdifGlobal *) mV->mvGetExtUserData(App, hInstLib); + + while(Global) + { + if(!_tcsicmp(Global->Name, Name)) + return Global->Value; + + Global = Global->Next; + } + + return 0; +} + +void * Edif::Runtime::ReadGlobal(const TCHAR * Name) +{ + LPRH rhPtr = rdPtr->rHo.hoAdRunHeader; + + while(rhPtr->rhApp->m_pParentApp) + rhPtr = rhPtr->rhApp->m_pParentApp->m_Frame->m_rhPtr; + + return ReadGlobal(rhPtr->rh4.rh4Mv, rhPtr->rhApp, Name); +} + +#ifdef EdifUseJS + + /* Breaking versions of Edif should change these so that newer extensions don't + try to work with an older JS context. */ + + const char * const ContextName = "JSContext-V1"; + + + JSContext * Edif::Runtime::GetJSContext() + { + JSContext * Context = ReadGlobal(ContextName); + + if(!Context) + { + Context = JS_NewContext(JS_NewRuntime(8 * 1024 * 1024), 8192); + + JS_SetOptions(Context, JSOPTION_VAROBJFIX | JSOPTION_JIT | JSOPTION_METHODJIT | JSOPTION_NO_SCRIPT_RVAL); + JS_SetVersion(Context, JSVERSION_LATEST); + + JSObject * Global = JS_NewGlobalObject(context, &GlobalClass); + + JS_SetGlobalObject (Context, Global); + JS_InitStandardClasses(Context, Global); + + WriteGlobal(ContextName, Context); + } + + return Context; + } + +#endif diff --git a/Lib/Edif.cpp b/Lib/Edif.cpp index a4a2bec..b163c1d 100644 --- a/Lib/Edif.cpp +++ b/Lib/Edif.cpp @@ -1,4 +1,5 @@ #include "Common.h" +using namespace std; Edif::SDK * SDK = 0; @@ -11,112 +12,71 @@ HMENU Edif::ActionMenu, Edif::ConditionMenu, Edif::ExpressionMenu; short ReadParameterType(const char * Text) { - if(!_stricmp(Text, "Text") || !_stricmp(Text, "String")) - return PARAM_EXPSTRING; - - if(!_stricmp(Text, "Filename") || !_stricmp(Text, "File")) - return PARAM_FILENAME; - - if(!_stricmp(Text, "Float")) - return PARAM_EXPRESSION; - - if(!_stricmp(Text, "Integer")) - return PARAM_EXPRESSION; - - if(!_stricmp(Text, "Object")) - return PARAM_OBJECT; - - if(!_stricmp(Text, "Position")) - return PARAM_POSITION; - - if(!_stricmp(Text, "Create")) - return PARAM_CREATE; - - if(!_stricmp(Text, "SysCreate")) - return PARAM_SYSCREATE; - - if(!_stricmp(Text, "Animation")) - return PARAM_ANIMATION; - - if(!_stricmp(Text, "Nop")) - return PARAM_NOP; - - if(!_stricmp(Text, "Player")) - return PARAM_PLAYER; - - if(!_stricmp(Text, "Every")) - return PARAM_EVERY; - - if(!_stricmp(Text, "Key")) - return PARAM_KEY; - - if(!_stricmp(Text, "Speed")) - return PARAM_SPEED; - - if(!_stricmp(Text, "JoyDirection")) - return PARAM_JOYDIRECTION; - - if(!_stricmp(Text, "Shoot")) - return PARAM_SHOOT; - - if(!_stricmp(Text, "Zone")) - return PARAM_ZONE; - - if(!_stricmp(Text, "Comparison")) - return PARAM_COMPARAISON; - - if(!_stricmp(Text, "StringComparison")) - return PARAM_CMPSTRING; - - if(!_stricmp(Text, "Colour") || !_stricmp(Text, "Color")) - return PARAM_COLOUR; - - if(!_stricmp(Text, "Frame")) - return PARAM_FRAME; - - if(!_stricmp(Text, "SampleLoop")) - return PARAM_SAMLOOP; - - if(!_stricmp(Text, "MusicLoop")) - return PARAM_MUSLOOP; - - if(!_stricmp(Text, "NewDirection")) - return PARAM_NEWDIRECTION; - - if(!_stricmp(Text, "TextNumber")) - return PARAM_TEXTNUMBER; - - if(!_stricmp(Text, "Click")) - return PARAM_CLICK; - - if(!_stricmp(Text, "Program")) - return PARAM_PROGRAM; - - if(!_strnicmp(Text, "Custom", 6)) - return PARAM_EXTBASE+atoi(Text+6); - - return 0; + if(!_stricmp(Text, "Text") || !_stricmp(Text, "String")) return PARAM_EXPSTRING; + if(!_stricmp(Text, "Filename") || !_stricmp(Text, "File")) return PARAM_FILENAME2; + if(!_stricmp(Text, "Float")) return PARAM_EXPRESSION; + if(!_stricmp(Text, "Integer")) return PARAM_EXPRESSION; + if(!_stricmp(Text, "Object")) return PARAM_OBJECT; + if(!_stricmp(Text, "Position")) return PARAM_POSITION; + if(!_stricmp(Text, "Create")) return PARAM_CREATE; + if(!_stricmp(Text, "SysCreate")) return PARAM_SYSCREATE; + if(!_stricmp(Text, "Animation")) return PARAM_ANIMATION; + if(!_stricmp(Text, "Nothing")) return PARAM_NOP; + if(!_stricmp(Text, "Player")) return PARAM_PLAYER; + if(!_stricmp(Text, "Every")) return PARAM_EVERY; + if(!_stricmp(Text, "Key")) return PARAM_KEY; + if(!_stricmp(Text, "Speed")) return PARAM_SPEED; + if(!_stricmp(Text, "JoyDirection")) return PARAM_JOYDIRECTION; + if(!_stricmp(Text, "Shoot")) return PARAM_SHOOT; + if(!_stricmp(Text, "Zone")) return PARAM_ZONE; + if(!_stricmp(Text, "Comparison")) return PARAM_COMPARAISON; + if(!_stricmp(Text, "StringComparison")) return PARAM_CMPSTRING; + if(!_stricmp(Text, "Colour") || !_stricmp(Text, "Color")) return PARAM_COLOUR; + if(!_stricmp(Text, "Frame")) return PARAM_FRAME; + if(!_stricmp(Text, "SampleLoop")) return PARAM_SAMLOOP; + if(!_stricmp(Text, "MusicLoop")) return PARAM_MUSLOOP; + if(!_stricmp(Text, "NewDirection")) return PARAM_NEWDIRECTION; + if(!_stricmp(Text, "TextNumber")) return PARAM_TEXTNUMBER; + if(!_stricmp(Text, "Click")) return PARAM_CLICK; + if(!_stricmp(Text, "Program")) return PARAM_PROGRAM; + if(!_strnicmp(Text, "Custom", 6)) return PARAM_EXTBASE+atoi(Text+6); + + return 0; } short ReadExpressionParameterType(const char * Text) { - if(!_stricmp(Text, "Text") || !_stricmp(Text, "String")) - return EXPPARAM_STRING; - - if(!_stricmp(Text, "Float")) - return EXPPARAM_LONG; + if(!_stricmp(Text, "Text") || !_stricmp(Text, "String")) return EXPPARAM_STRING; + if(!_stricmp(Text, "Float")) return EXPPARAM_LONG; + if(!_stricmp(Text, "Integer")) return EXPPARAM_LONG; - if(!_stricmp(Text, "Integer")) - return EXPPARAM_LONG; - - return 0; + return 0; } void Edif::Init(mv * _far mV, LPEDATA edPtr) -{ - IsEdittime = mV->mvHMainWin != 0; +{ + IsEdittime = mV->mvHMainWin != 0; - mvInvalidateObject(mV, edPtr); + mvInvalidateObject(mV, edPtr); + +#ifndef RUN_ONLY + TCHAR MFXPath[_MAX_PATH]; + GetModuleFileName(hInstLib, MFXPath, _MAX_PATH); + TCHAR MFXName[_MAX_FNAME]; + _tsplitpath(MFXPath, 0, 0, MFXName, 0); + if(_tcscmp(MFXName, _T("Template")) == 0) + { + TCHAR *extname; + MessageBox(0, _T("You forgot to change the MFX filename ") + _T("via the SDK Project name!\nChange the ") + _T("\"Template\" project name to whatever ") + _T("filename you want (letters/underscores") + _T(" only) The .mfx will be added for you."), + (_T("\"")+std::basic_string(extname = ConvertString(::SDK->json["About"]["Name"])) + +_T("\" named Template.mfx - EDIF")).c_str(), MB_OK); + FreeString(extname); + } +#endif } void Edif::Free(mv * _far mV) @@ -129,9 +89,9 @@ void Edif::Free(LPEDATA edPtr) int Edif::Init(mv _far * mV) { - _tcscpy (LanguageCode, _T ("EN")); + _tcscpy (LanguageCode, _T ("EN")); - // Get pathname of MMF2 + // Get pathname of Fusion LPTSTR mmfname = (LPTSTR)calloc(_MAX_PATH, sizeof(TCHAR)); if ( mmfname != NULL ) { @@ -161,13 +121,12 @@ int Edif::Init(mv _far * mV) } // Get JSON file - char * JSON; - size_t JSON_Size; + std::vector JSON; - int result = Edif::GetDependency (JSON, JSON_Size, _T("json"), IDR_EDIF_JSON); - - if (result == Edif::DependencyNotFound) - { + int result = Edif::GetDependency (JSON, _T("json"), IDR_EDIF_JSON); + + if (result == Edif::DependencyNotFound) + { TCHAR temp [MAX_PATH]; GetModuleFileName (hInstLib, temp, sizeof(temp)/sizeof(TCHAR)); LPTSTR filetitle = _tcsrchr(temp, _T('\\')); @@ -178,35 +137,29 @@ int Edif::Init(mv _far * mV) _tcscat(temp, _T(" - Error")); MessageBox(0, _T("JSON file not found on disk or in MFX resources"), temp, 0); - return -1; // error, init failed - } - - Edif::ExternalJSON = (result == Edif::DependencyWasFile); + return -1; // error, init failed + } - char * copy = (char *) malloc (JSON_Size + 1); - memcpy (copy, JSON, JSON_Size); - copy [JSON_Size] = 0; - if ( result != Edif::DependencyWasResource ) - free(JSON); + Edif::ExternalJSON = (result == Edif::DependencyWasFile); - char json_error [256]; - - json_settings settings; - memset (&settings, 0, sizeof (settings)); + char json_error [json_error_max+1]; + + json_settings settings; + memset (&settings, 0, sizeof (settings)); - // settings.settings = json_setting_permissive_commas; + settings.settings |= json_enable_comments; - json_value * json = json_parse_ex (&settings, copy, json_error); + json_value * json = json_parse_ex (&settings, JSON.data(), JSON.size(), json_error); - if (!json) - { - MessageBoxA(0, json_error, "Error parsing JSON", 0); - return -1; - } + if (!json) + { + MessageBoxA(0, json_error, "Error parsing JSON", 0); + return -1; + } static Edif::SDK gSDK (mV, *json); - ::SDK = &gSDK; - return 0; // no error + ::SDK = &gSDK; + return 0; // no error } Edif::SDK::SDK(mv * mV, json_value &_json) : json (_json) @@ -214,248 +167,254 @@ Edif::SDK::SDK(mv * mV, json_value &_json) : json (_json) this->mV = mV; #ifndef RUN_ONLY - Icon = new cSurface; - if(mV->mvImgFilterMgr) - { - char * IconData; - size_t IconSize; + Icon = new cSurface; + if(mV->mvImgFilterMgr) + { + std::vector IconData; - int result = Edif::GetDependency (IconData, IconSize, _T("png"), IDR_EDIF_ICON); + int result = Edif::GetDependency (IconData, _T("png"), IDR_EDIF_ICON); if (result != Edif::DependencyNotFound) - { - CInputMemFile * File = CInputMemFile::NewInstance (); - File->Create ((LPBYTE)IconData, IconSize); - - DWORD PNG = FILTERID_PNG; - ImportImageFromInputFile(mV->mvImgFilterMgr, File, Icon, &PNG, 0); - - File->Delete(); - - if(!Icon->HasAlpha()) - Icon->SetTransparentColor(RGB(255, 0, 255)); - if ( result != Edif::DependencyWasResource ) - free(IconData); - } - } + { + CInputMemFile * File = CInputMemFile::NewInstance (); + File->Create ((LPBYTE)IconData.data(), IconData.size()); + + DWORD PNG = FILTERID_PNG; + ImportImageFromInputFile(mV->mvImgFilterMgr, File, Icon, &PNG, 0); + + File->Delete(); + + if(!Icon->HasAlpha()) + Icon->SetTransparentColor(RGB(255, 0, 255)); + } + } #endif // RUN_ONLY - const json_value &Actions = json["Actions"]; - const json_value &Conditions = json["Conditions"]; - const json_value &Expressions = json["Expressions"]; + const json_value &Actions = json["Actions"]; + const json_value &Conditions = json["Conditions"]; + const json_value &Expressions = json["Expressions"]; - ActionJumps = new void * [Actions.u.array.length + 1]; - ConditionJumps = new void * [Conditions.u.array.length + 1]; - ExpressionJumps = new void * [Expressions.u.array.length + 1]; + ActionJumps = new void * [Actions.u.array.length + 1]; + ConditionJumps = new void * [Conditions.u.array.length + 1]; + ExpressionJumps = new void * [Expressions.u.array.length + 1]; - ActionJumps [Actions.u.array.length] = 0; - ConditionJumps [Conditions.u.array.length] = 0; - ExpressionJumps [Expressions.u.array.length] = 0; - - for(unsigned int i = 0; i < Actions.u.array.length; ++ i) - { - const json_value &Action = Actions[i]; + ActionJumps [Actions.u.array.length] = 0; + ConditionJumps [Conditions.u.array.length] = 0; + ExpressionJumps [Expressions.u.array.length] = 0; + + for(unsigned int i = 0; i < Actions.u.array.length; ++ i) + { + const json_value &Action = Actions[i]; - ActionJumps [i] = (void *) Edif::Action; + ActionJumps [i] = (void *) Edif::Action; - ActionFunctions.push_back(0); + ActionFunctions.push_back(0); - int ActionID = Edif::ActionID(i); + int ActionID = Edif::ActionID(i); - ActionInfos.push_back(ActionID); // Menu ID - ActionInfos.push_back(ActionID); // String ID - ActionInfos.push_back(i); // Code + ActionInfos.push_back(ActionID); // Menu ID + ActionInfos.push_back(ActionID); // String ID + ActionInfos.push_back(i); // Code - ActionInfos.push_back(0); // Flags + ActionInfos.push_back(0); // Flags - const json_value &Parameters = Action["Parameters"]; + const json_value &Parameters = Action["Parameters"]; - ActionInfos.push_back(Parameters.u.array.length); + ActionInfos.push_back(Parameters.u.array.length); - { short IsFloat = 0; + { short IsFloat = 0; - for(unsigned int i = 0; i < Parameters.u.array.length; ++ i) - { - const json_value &Parameter = Parameters[i]; + for(unsigned int i = 0; i < Parameters.u.array.length; ++ i) + { + const json_value &Parameter = Parameters[i]; - const char * Type; + const char * Type; - if(Parameter.type == json_object) - Type = Parameter["Type"]; - else - Type = Parameter[0]; + if(Parameter.type == json_object) + Type = Parameter["Type"]; + else + Type = Parameter[0]; - ActionInfos.push_back(ReadParameterType(Type)); - - if(!_stricmp(Type, "Float")) - IsFloat |= 1 << i; - } + ActionInfos.push_back(ReadParameterType(Type)); + + if(!_stricmp(Type, "Float")) + IsFloat |= 1 << i; + } - ActionFloatFlags.push_back(IsFloat); - } + ActionFloatFlags.push_back(IsFloat); + } - for(unsigned int i = 0; i < Parameters.u.array.length; ++ i) - ActionInfos.push_back(0); - } + for(unsigned int i = 0; i < Parameters.u.array.length; ++ i) + ActionInfos.push_back(0); + } - for(unsigned int i = 0; i < Conditions.u.array.length; ++ i) - { - const json_value &Condition = Conditions[i]; + for(unsigned int i = 0; i < Conditions.u.array.length; ++ i) + { + const json_value &Condition = Conditions[i]; - ConditionJumps [i] = (void *) Edif::Condition; + ConditionJumps [i] = (void *) Edif::Condition; - ConditionFunctions.push_back(0); + ConditionFunctions.push_back(0); - int ConditionID = Edif::ConditionID(i); + int ConditionID = Edif::ConditionID(i); - ConditionInfos.push_back(ConditionID); - ConditionInfos.push_back(ConditionID); - ConditionInfos.push_back(i); + ConditionInfos.push_back(ConditionID); + ConditionInfos.push_back(ConditionID); + ConditionInfos.push_back(i); - ConditionInfos.push_back(((bool) Condition["Triggered"]) ? 0 : (EVFLAGS_ALWAYS | EVFLAGS_NOTABLE)); + ConditionInfos.push_back(((bool) Condition["Triggered"]) ? (EVFLAGS_NOTABLE) : (EVFLAGS_ALWAYS | EVFLAGS_NOTABLE)); - const json_value &Parameters = Condition["Parameters"]; + const json_value &Parameters = Condition["Parameters"]; - ConditionInfos.push_back(Parameters.u.array.length); + ConditionInfos.push_back(Parameters.u.array.length); - { short IsFloat = 0; + { short IsFloat = 0; - for(unsigned int i = 0; i < Parameters.u.array.length; ++ i) - { - const json_value &Parameter = Parameters[i]; + for(unsigned int i = 0; i < Parameters.u.array.length; ++ i) + { + const json_value &Parameter = Parameters[i]; - const char * Type; + const char * Type; - if(Parameter.type == json_object) - Type = Parameter["Type"]; - else - Type = Parameter[0]; + if(Parameter.type == json_object) + Type = Parameter["Type"]; + else + Type = Parameter[0]; - ConditionInfos.push_back(ReadParameterType(Type)); - - if(!_stricmp(Type, "Float")) - IsFloat |= 1 << i; - } + ConditionInfos.push_back(ReadParameterType(Type)); + + if(!_stricmp(Type, "Float")) + IsFloat |= 1 << i; + } - ConditionFloatFlags.push_back(IsFloat); - } + ConditionFloatFlags.push_back(IsFloat); + } - for(unsigned int i = 0; i < Parameters.u.array.length; ++ i) - ConditionInfos.push_back(0); - } + for(unsigned int i = 0; i < Parameters.u.array.length; ++ i) + ConditionInfos.push_back(0); + } - for(unsigned int i = 0; i < Expressions.u.array.length; ++ i) - { - const json_value &Expression = Expressions[i]; + for(unsigned int i = 0; i < Expressions.u.array.length; ++ i) + { + const json_value &Expression = Expressions[i]; - ExpressionJumps [i] = (void *) Edif::Expression; + ExpressionJumps [i] = (void *) Edif::Expression; - ExpressionFunctions.push_back(0); + ExpressionFunctions.push_back(0); - if(!_stricmp(Expression["Returns"], "Integer")) - ExpressionTypes.push_back(0); - else if(!_stricmp(Expression["Returns"], "Float")) - ExpressionTypes.push_back(1); - else if(!_stricmp(Expression["Returns"], "Text") || !_stricmp(Expression["Returns"], "String")) - ExpressionTypes.push_back(2); - else - ExpressionTypes.push_back(0); + if(!_stricmp(Expression["Returns"], "Integer")) + ExpressionTypes.push_back(0); + else if(!_stricmp(Expression["Returns"], "Float")) + ExpressionTypes.push_back(1); + else if(!_stricmp(Expression["Returns"], "Text") || !_stricmp(Expression["Returns"], "String")) + ExpressionTypes.push_back(2); + else + ExpressionTypes.push_back(0); - int ExpressionID = Edif::ExpressionID(i); + int ExpressionID = Edif::ExpressionID(i); - ExpressionInfos.push_back(ExpressionID); - ExpressionInfos.push_back(ExpressionID); - ExpressionInfos.push_back(i); + ExpressionInfos.push_back(ExpressionID); + ExpressionInfos.push_back(ExpressionID); + ExpressionInfos.push_back(i); - { short FlagsValue = 0; + { short FlagsValue = 0; - if(ExpressionTypes.back() == 1) - FlagsValue |= EXPFLAG_DOUBLE; + if(ExpressionTypes.back() == 1) + FlagsValue |= EXPFLAG_DOUBLE; - if(ExpressionTypes.back() == 2) - FlagsValue |= EXPFLAG_STRING; + if(ExpressionTypes.back() == 2) + FlagsValue |= EXPFLAG_STRING; - ExpressionInfos.push_back(FlagsValue); - } + ExpressionInfos.push_back(FlagsValue); + } - const json_value &Parameters = Expression["Parameters"]; + const json_value &Parameters = Expression["Parameters"]; - ExpressionInfos.push_back(Parameters.u.array.length); + ExpressionInfos.push_back(Parameters.u.array.length); - { short IsFloat = 0; + { short IsFloat = 0; - for(unsigned int i = 0; i < Parameters.u.array.length; ++ i) - { - const json_value &Parameter = Parameters[i]; + for(unsigned int i = 0; i < Parameters.u.array.length; ++ i) + { + const json_value &Parameter = Parameters[i]; - const char * Type; + const char * Type; - if(Parameter.type == json_object) - Type = Parameter["Type"]; - else - Type = Parameter[0]; + if(Parameter.type == json_object) + Type = Parameter["Type"]; + else + Type = Parameter[0]; - ExpressionInfos.push_back(ReadExpressionParameterType(Type)); - - if(!_stricmp(Type, "Float")) - IsFloat |= 1 << i; - } + ExpressionInfos.push_back(ReadExpressionParameterType(Type)); + + if(!_stricmp(Type, "Float")) + IsFloat |= 1 << i; + } - ExpressionFloatFlags.push_back(IsFloat); - } + ExpressionFloatFlags.push_back(IsFloat); + } - for(unsigned int i = 0; i < Parameters.u.array.length; ++ i) - ExpressionInfos.push_back(0); - } + for(unsigned int i = 0; i < Parameters.u.array.length; ++ i) + ExpressionInfos.push_back(0); + } - ActionMenu = LoadMenuJSON(Edif::ActionID(0), json["ActionMenu"]); - ConditionMenu = LoadMenuJSON(Edif::ConditionID(0), json["ConditionMenu"]); - ExpressionMenu = LoadMenuJSON(Edif::ExpressionID(0), json["ExpressionMenu"]); + ActionMenu = LoadMenuJSON(Edif::ActionID(0), json["ActionMenu"]); + ConditionMenu = LoadMenuJSON(Edif::ConditionID(0), json["ConditionMenu"]); + ExpressionMenu = LoadMenuJSON(Edif::ExpressionID(0), json["ExpressionMenu"]); } Edif::SDK::~SDK() { - json_value_free (&json); + json_value_free (&json); - delete [] ActionJumps; - delete [] ConditionJumps; - delete [] ExpressionJumps; + delete [] ActionJumps; + delete [] ConditionJumps; + delete [] ExpressionJumps; #ifndef RUN_ONLY delete Icon; #endif } +#ifdef __MINGW32__ +template +std::int32_t CallExtMFP(Extension &ext, void *f, Args... args) +{ + std::int32_t (Extension::*mfp)(Args...) = *reinterpret_cast(&f); + return (ext.*mfp)(args...); +} +#endif + int ActionOrCondition(vector &FloatFlags, LPEVENTINFOS2 Info, void * Function, int ID, LPRDATA rdPtr, long param1, long param2) { - int * Parameters; - int ParameterCount; + int * Parameters; + int ParameterCount; bool Cast = true; - { Info = GetEventInformations(Info, ID); + { Info = GetEventInformations(Info, ID); - ParameterCount = Info->infos.nParams; - Parameters = (int *) alloca(sizeof(int) * ParameterCount); + ParameterCount = Info->infos.nParams; + Parameters = new int[ParameterCount]; - for(int i = 0; i < ParameterCount; ++ i) - { - switch(EVINFO2_PARAM(Info, i)) - { - case PARAM_EXPRESSION: + for(int i = 0; i < ParameterCount; ++ i) + { + switch(EVINFO2_PARAM(Info, i)) + { + case PARAM_EXPRESSION: - if((FloatFlags[ID] & (1 << i)) != 0) - { - Parameters[i] = CNC_GetFloatParameter(rdPtr); - break; - } + if((FloatFlags[ID] & (1 << i)) != 0) + { + Parameters[i] = CNC_GetFloatParameter(rdPtr); + break; + } - Parameters[i] = CNC_GetIntParameter(rdPtr); - break; + Parameters[i] = CNC_GetIntParameter(rdPtr); + break; - case PARAM_EXPSTRING: - case PARAM_FILENAME: + case PARAM_EXPSTRING: + case PARAM_FILENAME: - Parameters[i] = CNC_GetStringParameter(rdPtr); - break; + Parameters[i] = CNC_GetStringParameter(rdPtr); + break; case PARAM_COMPARAISON: //int must be returned case PARAM_CMPSTRING: //char * must be returned @@ -463,336 +422,416 @@ int ActionOrCondition(vector &FloatFlags, LPEVENTINFOS2 Info, void * Func Cast = false; break; - default: + default: - Parameters[i] = CNC_GetParameter(rdPtr); - break; - } - } - } + Parameters[i] = CNC_GetParameter(rdPtr); + break; + } + } + } - void * Extension = rdPtr->pExtension; + void * Extension = rdPtr->pExtension; - int Result; + int Result; - __asm - { - pushad +#ifndef __MINGW32__ + __asm + { + pushad - mov ecx, ParameterCount - - cmp ecx, 0 - je CallNow + mov ecx, ParameterCount + + cmp ecx, 0 + je CallNow - mov edx, Parameters + mov edx, Parameters - mov ebx, ecx - shl ebx, 2 + mov ebx, ecx + shl ebx, 2 - add edx, ebx - sub edx, 4 + add edx, ebx + sub edx, 4 - PushLoop: + PushLoop: - push [edx] - sub edx, 4 + push [edx] + sub edx, 4 - dec ecx + dec ecx - cmp ecx, 0 - jne PushLoop + cmp ecx, 0 + jne PushLoop - CallNow: + CallNow: - mov ecx, Extension - call Function - - mov Result, eax + mov ecx, Extension + call Function + + mov Result, eax - popad - } + popad + } +#else + int *P = Parameters; + switch(ParameterCount) + { + case 0: Result = CallExtMFP(*(rdPtr->pExtension), Function); + case 1: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0]); + case 2: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1]); + case 3: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2]); + case 4: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3]); + case 5: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4]); + case 6: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4], P[5]); + case 7: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4], P[5], P[6]); + case 8: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4], P[5], P[6], P[7]); + case 9: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4], P[5], P[6], P[7], P[8]); + case 10: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4], P[5], P[6], P[7], P[8], P[9]); + case 11: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4], P[5], P[6], P[7], P[8], P[9], P[10]); + case 12: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4], P[5], P[6], P[7], P[8], P[9], P[10], P[11]); + case 13: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4], P[5], P[6], P[7], P[8], P[9], P[10], P[11], P[12]); + case 14: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4], P[5], P[6], P[7], P[8], P[9], P[10], P[11], P[12], P[13]); + case 15: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4], P[5], P[6], P[7], P[8], P[9], P[10], P[11], P[12], P[13], P[14]); + case 16: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4], P[5], P[6], P[7], P[8], P[9], P[10], P[11], P[12], P[13], P[14], P[15]); + //Since Fusion doesn't fully support >16 parameters, they aren't supported here either + } +#endif - return Cast ? (char)Result : Result; + return Cast ? (char)Result : Result; } HMENU Edif::LoadMenuJSON(int BaseID, const json_value &Source, HMENU Parent) { - if(!Parent) - Parent = CreateMenu(); + if(!Parent) + Parent = CreateMenu(); - for(unsigned int i = 0; i < Source.u.array.length; ++ i) - { - const json_value &MenuItem = Source[i]; + for(unsigned int i = 0; i < Source.u.array.length; ++ i) + { + const json_value &MenuItem = Source[i]; - if(MenuItem.type == json_string) - { - if(!_stricmp(MenuItem, "Separator")) - { - AppendMenu(Parent, MF_BYPOSITION | MF_SEPARATOR, 0, 0); - continue; - } + if(MenuItem.type == json_string) + { + if(!_stricmp(MenuItem, "Separator")) + { + AppendMenu(Parent, MF_BYPOSITION | MF_SEPARATOR, 0, 0); + continue; + } - continue; - } + continue; + } - if(MenuItem[0].type == json_string && MenuItem[1].type == json_array) - { - HMENU SubMenu = CreatePopupMenu(); - LoadMenuJSON(BaseID, MenuItem, SubMenu); + if(MenuItem[0].type == json_string && MenuItem[1].type == json_array) + { + HMENU SubMenu = CreatePopupMenu(); + LoadMenuJSON(BaseID, MenuItem, SubMenu); TCHAR* str = ConvertString(MenuItem[0]); - AppendMenu(Parent, MF_BYPOSITION | MF_STRING | MF_POPUP, (UINT) SubMenu, str); + AppendMenu(Parent, MF_BYPOSITION | MF_STRING | MF_POPUP, (UINT) SubMenu, str); FreeString(str); - continue; - } + continue; + } - unsigned int ItemOffset = 0; + unsigned int ItemOffset = 0; - int ID = BaseID + (int) MenuItem[ItemOffset].u.integer; - TCHAR * Text = ConvertString(MenuItem[ItemOffset + 1]); - bool Disabled = MenuItem.u.array.length > (ItemOffset + 2) ? ((bool) MenuItem[ItemOffset + 2]) != 0 : false; + int ID = BaseID + (int) MenuItem[ItemOffset].u.integer; + TCHAR * Text = ConvertString(MenuItem[ItemOffset + 1]); + bool Disabled = MenuItem.u.array.length > (ItemOffset + 2) ? ((bool) MenuItem[ItemOffset + 2]) != 0 : false; - AppendMenu(Parent, Disabled ? MF_GRAYED | MF_UNCHECKED | MF_BYPOSITION | MF_STRING - : MF_BYPOSITION | MF_STRING, ID, Text); + AppendMenu(Parent, Disabled ? MF_GRAYED | MF_UNCHECKED | MF_BYPOSITION | MF_STRING + : MF_BYPOSITION | MF_STRING, ID, Text); FreeString(Text); - } + } - return Parent; + return Parent; } long __stdcall Edif::Condition(LPRDATA rdPtr, long param1, long param2) { - int ID = rdPtr->rHo.hoEventNumber; + int ID = rdPtr->rHo.hoEventNumber; - rdPtr->pExtension->Runtime.param1 = param1; - rdPtr->pExtension->Runtime.param2 = param2; + rdPtr->pExtension->Runtime.param1 = param1; + rdPtr->pExtension->Runtime.param2 = param2; - void * Function = ::SDK->ConditionFunctions[ID]; + void * Function = ::SDK->ConditionFunctions[ID]; - if(!Function) - return rdPtr->pExtension->Condition(ID, rdPtr, param1, param2); + if(!Function) + return rdPtr->pExtension->Condition(ID, rdPtr, param1, param2); - int Result = ActionOrCondition(::SDK->ConditionFloatFlags, (LPEVENTINFOS2) &::SDK->ConditionInfos[0], - Function, ID, rdPtr, param1, param2); + int Result = ActionOrCondition(::SDK->ConditionFloatFlags, (LPEVENTINFOS2) &::SDK->ConditionInfos[0], + Function, ID, rdPtr, param1, param2); - return *(char *) &Result; + return Result; } short __stdcall Edif::Action(LPRDATA rdPtr, long param1, long param2) { - /* int ID = rdPtr->rHo.hoAdRunHeader->rh4.rh4ActionStart->evtNum; */ - int ID = rdPtr->rHo.hoEventNumber; + /* int ID = rdPtr->rHo.hoAdRunHeader->rh4.rh4ActionStart->evtNum; */ + int ID = rdPtr->rHo.hoEventNumber; - rdPtr->pExtension->Runtime.param1 = param1; - rdPtr->pExtension->Runtime.param2 = param2; + rdPtr->pExtension->Runtime.param1 = param1; + rdPtr->pExtension->Runtime.param2 = param2; - void * Function = ::SDK->ActionFunctions[ID]; + void * Function = ::SDK->ActionFunctions[ID]; - if(!Function) - { - rdPtr->pExtension->Action(ID, rdPtr, param1, param2); - return 0; - } + if(!Function) + { + rdPtr->pExtension->Action(ID, rdPtr, param1, param2); + return 0; + } - ActionOrCondition(::SDK->ActionFloatFlags, (LPEVENTINFOS2) &::SDK->ActionInfos[0], - Function, ID, rdPtr, param1, param2); + ActionOrCondition(::SDK->ActionFloatFlags, (LPEVENTINFOS2) &::SDK->ActionInfos[0], + Function, ID, rdPtr, param1, param2); - return 0; + return 0; } long __stdcall Edif::Expression(LPRDATA rdPtr, long param) { - int ID = rdPtr->rHo.hoEventNumber; + int ID = rdPtr->rHo.hoEventNumber; - rdPtr->pExtension->Runtime.param1 = param; - rdPtr->pExtension->Runtime.param2 = 0; + rdPtr->pExtension->Runtime.param1 = param; + rdPtr->pExtension->Runtime.param2 = 0; - int * Parameters; - int ParameterCount; + int * Parameters; + int ParameterCount; - void * Function = ::SDK->ExpressionFunctions[ID]; + void * Function = ::SDK->ExpressionFunctions[ID]; - if(!Function) - return rdPtr->pExtension->Expression(ID, rdPtr, param); + if(!Function) + return rdPtr->pExtension->Expression(ID, rdPtr, param); - { LPEVENTINFOS2 Infos = GetEventInformations((LPEVENTINFOS2) &::SDK->ExpressionInfos[0], ID); + { LPEVENTINFOS2 Infos = GetEventInformations((LPEVENTINFOS2) &::SDK->ExpressionInfos[0], ID); - ParameterCount = Infos->infos.nParams; - Parameters = (int *) alloca(sizeof(int) * ParameterCount); + ParameterCount = Infos->infos.nParams; + Parameters = new int[ParameterCount]; - for(int i = 0; i < ParameterCount; ++ i) - { - switch(EVINFO2_PARAM(Infos, i)) - { - case EXPPARAM_STRING: + for(int i = 0; i < ParameterCount; ++ i) + { + switch(EVINFO2_PARAM(Infos, i)) + { + case EXPPARAM_STRING: - if(!i) - { - Parameters[i] = CNC_GetFirstExpressionParameter(rdPtr, param, TYPE_STRING); - break; - } + if(!i) + { + Parameters[i] = CNC_GetFirstExpressionParameter(rdPtr, param, TYPE_STRING); + break; + } - Parameters[i] = CNC_GetNextExpressionParameter(rdPtr, param, TYPE_STRING); - break; + Parameters[i] = CNC_GetNextExpressionParameter(rdPtr, param, TYPE_STRING); + break; - case EXPPARAM_LONG: + case EXPPARAM_LONG: - int Type = ((::SDK->ExpressionFloatFlags[ID] & (1 << i)) != 0) ? TYPE_FLOAT : TYPE_LONG; + int Type = ((::SDK->ExpressionFloatFlags[ID] & (1 << i)) != 0) ? TYPE_FLOAT : TYPE_LONG; - if(!i) - { - Parameters[i] = CNC_GetFirstExpressionParameter(rdPtr, param, Type); - break; - } + if(!i) + { + Parameters[i] = CNC_GetFirstExpressionParameter(rdPtr, param, Type); + break; + } - Parameters[i] = CNC_GetNextExpressionParameter(rdPtr, param, Type); - break; - } - } - } + Parameters[i] = CNC_GetNextExpressionParameter(rdPtr, param, Type); + break; + } + } + } - void * Extension = rdPtr->pExtension; + void * Extension = rdPtr->pExtension; - int Result; - int ExpressionType = ::SDK->ExpressionTypes[ID]; - - __asm - { - pushad + int Result; + int ExpressionType = ::SDK->ExpressionTypes[ID]; - mov ecx, ParameterCount - - cmp ecx, 0 - je CallNow +#ifndef __MINGW32__ + __asm + { + pushad - mov edx, Parameters + mov ecx, ParameterCount + + cmp ecx, 0 + je CallNow - mov ebx, ecx - shl ebx, 2 + mov edx, Parameters - add edx, ebx - sub edx, 4 + mov ebx, ecx + shl ebx, 2 - PushLoop: + add edx, ebx + sub edx, 4 - push [edx] - sub edx, 4 + PushLoop: - dec ecx + push [edx] + sub edx, 4 - cmp ecx, 0 - jne PushLoop + dec ecx - CallNow: + cmp ecx, 0 + jne PushLoop - mov ecx, Extension - call Function + CallNow: - mov ecx, ExpressionType; + mov ecx, Extension + call Function - cmp ecx, 1 - jne NotFloat + mov ecx, ExpressionType; - fstp Result - jmp End + cmp ecx, 1 + jne NotFloat - NotFloat: - - mov Result, eax - - End: + fstp Result + jmp End - popad - } - - switch(ExpressionType) - { - case 1: // Float - { - rdPtr->rHo.hoFlags |= HOF_FLOAT; - break; - } + NotFloat: + + mov Result, eax + + End: - case 2: // String - { - rdPtr->rHo.hoFlags |= HOF_STRING; - break; - } - }; - - return Result; + popad + } +#else + int *P = Parameters; + if(ExpressionType == 1) //float + { + switch(ParameterCount) + { + case 0: Result = CallExtMFP(*(rdPtr->pExtension), Function); + case 1: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0]); + case 2: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1]); + case 3: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2]); + case 4: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3]); + case 5: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4]); + case 6: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4], P[5]); + case 7: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4], P[5], P[6]); + case 8: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4], P[5], P[6], P[7]); + case 9: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4], P[5], P[6], P[7], P[8]); + case 10: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4], P[5], P[6], P[7], P[8], P[9]); + case 11: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4], P[5], P[6], P[7], P[8], P[9], P[10]); + case 12: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4], P[5], P[6], P[7], P[8], P[9], P[10], P[11]); + case 13: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4], P[5], P[6], P[7], P[8], P[9], P[10], P[11], P[12]); + case 14: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4], P[5], P[6], P[7], P[8], P[9], P[10], P[11], P[12], P[13]); + case 15: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4], P[5], P[6], P[7], P[8], P[9], P[10], P[11], P[12], P[13], P[14]); + case 16: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4], P[5], P[6], P[7], P[8], P[9], P[10], P[11], P[12], P[13], P[14], P[15]); + //Since Fusion doesn't fully support >16 parameters, they aren't supported here either + } + } + else + { + switch(ParameterCount) + { + case 0: Result = CallExtMFP(*(rdPtr->pExtension), Function); + case 1: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0]); + case 2: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1]); + case 3: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2]); + case 4: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3]); + case 5: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4]); + case 6: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4], P[5]); + case 7: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4], P[5], P[6]); + case 8: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4], P[5], P[6], P[7]); + case 9: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4], P[5], P[6], P[7], P[8]); + case 10: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4], P[5], P[6], P[7], P[8], P[9]); + case 11: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4], P[5], P[6], P[7], P[8], P[9], P[10]); + case 12: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4], P[5], P[6], P[7], P[8], P[9], P[10], P[11]); + case 13: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4], P[5], P[6], P[7], P[8], P[9], P[10], P[11], P[12]); + case 14: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4], P[5], P[6], P[7], P[8], P[9], P[10], P[11], P[12], P[13]); + case 15: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4], P[5], P[6], P[7], P[8], P[9], P[10], P[11], P[12], P[13], P[14]); + case 16: Result = CallExtMFP(*(rdPtr->pExtension), Function, P[0], P[1], P[2], P[3], P[4], P[5], P[6], P[7], P[8], P[9], P[10], P[11], P[12], P[13], P[14], P[15]); + //Since Fusion doesn't fully support >16 parameters, they aren't supported here either + } + } +#endif + + switch(ExpressionType) + { + case 1: // Float + { + rdPtr->rHo.hoFlags |= HOF_FLOAT; + break; + } + + case 2: // String + { + rdPtr->rHo.hoFlags |= HOF_STRING; + break; + } + }; + + return Result; } -int Edif::GetDependency (char *& Buffer, size_t &Size, const TCHAR * FileExtension, int Resource) +int Edif::GetDependency (std::vector &Buffer, const TCHAR * FileExtension, int Resource) { - TCHAR Filename [MAX_PATH]; - GetSiblingPath (Filename, FileExtension); + TCHAR Filename [MAX_PATH]; + GetSiblingPath (Filename, FileExtension); - Buffer = NULL; - if (*Filename) - { - FILE * File = NULL; + Buffer.clear(); + if (*Filename) + { + FILE * File = NULL; int error = _tfopen_s(&File, Filename, _T("rb")); - if (!File) - return DependencyNotFound; - - fseek (File, 0, SEEK_END); - Size = ftell (File); - fseek (File, 0, SEEK_SET); - - Buffer = (char *) malloc (Size + 1); - Buffer [Size] = 0; - - fread (Buffer, 1, Size, File); - - fclose (File); - - return DependencyWasFile; - } + if(File) + { + fseek(File, 0, SEEK_END); + Buffer.resize(ftell(File)); + fseek(File, 0, SEEK_SET); - if (!Resource) - return DependencyNotFound; + fread(Buffer.data(), 1, Buffer.size(), File); - HRSRC res = FindResource (hInstLib, MAKEINTRESOURCE (Resource), _T("EDIF")); + fclose(File); - if (!res) - return DependencyNotFound; + return DependencyWasFile; + } + } - Size = SizeofResource (hInstLib, res); - Buffer = (char *) LockResource (LoadResource (hInstLib, res)); + if(Resource) + { + if(HRSRC res_r = FindResource(hInstLib, MAKEINTRESOURCE(Resource), _T("EDIF"))) + { + if(HGLOBAL res_g = LoadResource(hInstLib, res_r)) + { + if(LPVOID res_p = LockResource(res_g)) + { + Buffer.resize(SizeofResource(hInstLib, res_r)); + memcpy(Buffer.data(), res_p, Buffer.size()); + + return DependencyWasResource; + } + } + } + } - return DependencyWasResource; + return DependencyNotFound; } static void GetSiblingPath (TCHAR * Buffer, const TCHAR * FileExtension) { - TCHAR temp [MAX_PATH]; + TCHAR temp [MAX_PATH]; - GetModuleFileName (hInstLib, temp, sizeof(temp)/sizeof(TCHAR)); + GetModuleFileName (hInstLib, temp, sizeof(temp)/sizeof(TCHAR)); - TCHAR * Filename = temp + _tcslen(temp) - 1; + TCHAR * Filename = temp + _tcslen(temp) - 1; - while(*Filename != '.') - -- Filename; + while(*Filename != '.') + -- Filename; - _tcscpy(++ Filename, FileExtension); + _tcscpy(++ Filename, FileExtension); - Filename = Filename + _tcslen(Filename) - 1; + Filename = Filename + _tcslen(Filename) - 1; - while(*Filename != '\\' && *Filename != '/') - -- Filename; + while(*Filename != '\\' && *Filename != '/') + -- Filename; - ++ Filename; + ++ Filename; // Is the file in the directory of the MFX? (if so, use this pathname) TCHAR FullFilename [MAX_PATH]; _tcscpy(FullFilename, temp); - if(GetFileAttributes(FullFilename) == 0xFFFFFFFF) - { + if(GetFileAttributes(FullFilename) == 0xFFFFFFFF) + { // No => editor TCHAR ExecutablePath [MAX_PATH]; GetModuleFileName (GetModuleHandle (0), ExecutablePath, sizeof(ExecutablePath)/sizeof(TCHAR)); @@ -809,39 +848,39 @@ static void GetSiblingPath (TCHAR * Buffer, const TCHAR * FileExtension) _stprintf_s(FullFilename, sizeof(ExecutablePath)/sizeof(TCHAR), _T("%s/%s"), ExecutablePath, Filename); if(GetFileAttributes(FullFilename) == 0xFFFFFFFF) { - // No => try Data/Runtime - _stprintf_s(FullFilename, sizeof(ExecutablePath)/sizeof(TCHAR), _T("%s/Data/Runtime/%s"), ExecutablePath, Filename); - if(GetFileAttributes(FullFilename) == 0xFFFFFFFF) - { - // No => try .. (maybe we're in the Unicode or HWA folder) - _stprintf_s(FullFilename, sizeof(ExecutablePath)/sizeof(TCHAR), _T("%s/../%s"), ExecutablePath, Filename); - if(GetFileAttributes(FullFilename) == 0xFFFFFFFF) - { - *Buffer = 0; - return; - } - } - } + // No => try Data/Runtime + _stprintf_s(FullFilename, sizeof(ExecutablePath)/sizeof(TCHAR), _T("%s/Data/Runtime/%s"), ExecutablePath, Filename); + if(GetFileAttributes(FullFilename) == 0xFFFFFFFF) + { + // No => try .. (maybe we're in the Unicode or HWA folder) + _stprintf_s(FullFilename, sizeof(ExecutablePath)/sizeof(TCHAR), _T("%s/../%s"), ExecutablePath, Filename); + if(GetFileAttributes(FullFilename) == 0xFFFFFFFF) + { + *Buffer = 0; + return; + } + } + } } - _tcscpy(Buffer, FullFilename); + _tcscpy(Buffer, FullFilename); } void Edif::GetSiblingPath (TCHAR * Buffer, const TCHAR * FileExtension) { - TCHAR * Extension = (TCHAR *) - alloca ((_tcslen (FileExtension) + _tcslen (LanguageCode) + 2) * sizeof(TCHAR)); + TCHAR * Extension = + new TCHAR[(_tcslen (FileExtension) + _tcslen (LanguageCode) + 2) * sizeof(TCHAR)]; - _tcscpy (Extension, LanguageCode); - _tcscat (Extension, _T (".")); - _tcscat (Extension, FileExtension); + _tcscpy (Extension, LanguageCode); + _tcscat (Extension, _T (".")); + _tcscat (Extension, FileExtension); - ::GetSiblingPath (Buffer, Extension); + ::GetSiblingPath (Buffer, Extension); - if (*Buffer) - return; + if (*Buffer) + return; - ::GetSiblingPath (Buffer, FileExtension); + ::GetSiblingPath (Buffer, FileExtension); } #ifdef _UNICODE diff --git a/Lib/ObjectSelection.cpp b/Lib/ObjectSelection.cpp index ab03514..bfebe9c 100644 --- a/Lib/ObjectSelection.cpp +++ b/Lib/ObjectSelection.cpp @@ -1,6 +1,6 @@ // By Anders Riggelsen (Andos) -// http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Number=214148&gonew=1 +// http://community.clickteam.com/showthread.php?t=61672 // These files do not match up with the originals - modified for Edif (callbacks inside the extension class, etc..) @@ -247,4 +247,4 @@ bool Riggs::ObjectSelection::FilterNonQualifierObjects(Extension* extension, sho pObjectInfo->oilNumOfSelected = count; return hasSelected; -} \ No newline at end of file +} diff --git a/Lib/json.c b/Lib/json.c index e37c83f..6012bad 100644 --- a/Lib/json.c +++ b/Lib/json.c @@ -1,7 +1,6 @@ - -/* vim: set et ts=3 sw=3 ft=c: +/* vim: set et ts=3 sw=3 sts=3 ft=c: * - * Copyright (C) 2012 James McLaughlin et al. All rights reserved. + * Copyright (C) 2012, 2013, 2014 James McLaughlin et al. All rights reserved. * https://github.com/udp/json-parser * * Redistribution and use in source and binary forms, with or without @@ -36,49 +35,58 @@ #endif #endif -#ifdef __cplusplus - const struct _json_value json_value_none; /* zero-d by ctor */ -#else - const struct _json_value json_value_none = { 0 }; -#endif +const struct _json_value json_value_none; -#include #include #include #include +#include -typedef unsigned short json_uchar; +typedef unsigned int json_uchar; static unsigned char hex_value (json_char c) { - if (c >= 'A' && c <= 'F') - return (c - 'A') + 10; - - if (c >= 'a' && c <= 'f') - return (c - 'a') + 10; - - if (c >= '0' && c <= '9') + if (isdigit(c)) return c - '0'; - return 0xFF; + switch (c) { + case 'a': case 'A': return 0x0A; + case 'b': case 'B': return 0x0B; + case 'c': case 'C': return 0x0C; + case 'd': case 'D': return 0x0D; + case 'e': case 'E': return 0x0E; + case 'f': case 'F': return 0x0F; + default: return 0xFF; + } } typedef struct { - json_settings settings; - int first_pass; - unsigned long used_memory; unsigned int uint_max; unsigned long ulong_max; + json_settings settings; + int first_pass; + + const json_char * ptr; + unsigned int cur_line, cur_col; + } json_state; -static void * json_alloc (json_state * state, unsigned long size, int zero) +static void * default_alloc (size_t size, int zero, void * user_data) +{ + return zero ? calloc (1, size) : malloc (size); +} + +static void default_free (void * ptr, void * user_data) { - void * mem; + free (ptr); +} +static void * json_alloc (json_state * state, unsigned long size, int zero) +{ if ((state->ulong_max - state->used_memory) < size) return 0; @@ -88,14 +96,12 @@ static void * json_alloc (json_state * state, unsigned long size, int zero) return 0; } - if (! (mem = zero ? calloc (size, 1) : malloc (size))) - return 0; - - return mem; + return state->settings.mem_alloc (size, zero, state->settings.user_data); } -static int new_value - (json_state * state, json_value ** top, json_value ** root, json_value ** alloc, json_type type) +static int new_value (json_state * state, + json_value ** top, json_value ** root, json_value ** alloc, + json_type type) { json_value * value; int values_size; @@ -112,19 +118,26 @@ static int new_value { case json_array: + if (value->u.array.length == 0) + break; + if (! (value->u.array.values = (json_value **) json_alloc (state, value->u.array.length * sizeof (json_value *), 0)) ) { return 0; } + value->u.array.length = 0; break; case json_object: + if (value->u.object.length == 0) + break; + values_size = sizeof (*value->u.object.values) * value->u.object.length; - if (! ((*(void **) &value->u.object.values) = json_alloc + if (! (value->u.object.values = (json_object_entry *) json_alloc (state, values_size + ((unsigned long) value->u.object.values), 0)) ) { return 0; @@ -132,6 +145,7 @@ static int new_value value->_reserved.object_mem = (*(char **) &value->u.object.values) + values_size; + value->u.object.length = 0; break; case json_string: @@ -142,21 +156,21 @@ static int new_value return 0; } + value->u.string.length = 0; break; default: break; }; - value->u.array.length = 0; - return 1; } - value = (json_value *) json_alloc (state, sizeof (json_value), 1); - - if (!value) + if (! (value = (json_value *) json_alloc + (state, sizeof (json_value) + state->settings.value_extra, 1))) + { return 0; + } if (!*root) *root = value; @@ -164,6 +178,11 @@ static int new_value value->type = type; value->parent = *top; + #ifdef JSON_TRACK_SOURCE + value->line = state->cur_line; + value->col = state->cur_col; + #endif + if (*alloc) (*alloc)->_reserved.next_alloc = value; @@ -172,35 +191,67 @@ static int new_value return 1; } -#define e_off \ - ((int) (i - cur_line_begin)) - #define whitespace \ - case '\n': ++ cur_line; cur_line_begin = i; \ + case '\n': ++ state.cur_line; state.cur_col = 0; \ case ' ': case '\t': case '\r' #define string_add(b) \ do { if (!state.first_pass) string [string_length] = b; ++ string_length; } while (0); -const static int - flag_next = 1, flag_reproc = 2, flag_need_comma = 4, flag_seek_value = 8, flag_exponent = 16, - flag_got_exponent_sign = 32, flag_escaped = 64, flag_string = 128, flag_need_colon = 256, - flag_done = 512; - -json_value * json_parse_ex (json_settings * settings, const json_char * json, char * error_buf) +#define line_and_col \ + state.cur_line, state.cur_col + +static const long + flag_next = 1 << 0, + flag_reproc = 1 << 1, + flag_need_comma = 1 << 2, + flag_seek_value = 1 << 3, + flag_escaped = 1 << 4, + flag_string = 1 << 5, + flag_need_colon = 1 << 6, + flag_done = 1 << 7, + flag_num_negative = 1 << 8, + flag_num_zero = 1 << 9, + flag_num_e = 1 << 10, + flag_num_e_got_sign = 1 << 11, + flag_num_e_negative = 1 << 12, + flag_line_comment = 1 << 13, + flag_block_comment = 1 << 14; + +json_value * json_parse_ex (json_settings * settings, + const json_char * json, + size_t length, + char * error_buf) { - json_char error [128]; - unsigned int cur_line; - const json_char * cur_line_begin, * i; + json_char error [json_error_max]; + const json_char * end; json_value * top, * root, * alloc = 0; - json_state state; - int flags; + json_state state = { 0 }; + long flags; + long num_digits = 0, num_e = 0; + json_int_t num_fraction = 0; + + /* Skip UTF-8 BOM + */ + if (length >= 3 && ((unsigned char) json [0]) == 0xEF + && ((unsigned char) json [1]) == 0xBB + && ((unsigned char) json [2]) == 0xBF) + { + json += 3; + length -= 3; + } error[0] = '\0'; + end = (json + length); - memset (&state, 0, sizeof (json_state)); memcpy (&state.settings, settings, sizeof (json_settings)); + if (!state.settings.mem_alloc) + state.settings.mem_alloc = default_alloc; + + if (!state.settings.mem_free) + state.settings.mem_free = default_free; + memset (&state.uint_max, 0xFF, sizeof (state.uint_max)); memset (&state.ulong_max, 0xFF, sizeof (state.ulong_max)); @@ -211,39 +262,22 @@ json_value * json_parse_ex (json_settings * settings, const json_char * json, ch { json_uchar uchar; unsigned char uc_b1, uc_b2, uc_b3, uc_b4; - json_char * string; - unsigned int string_length; + json_char * string = 0; + unsigned int string_length = 0; top = root = 0; flags = flag_seek_value; - cur_line = 1; - cur_line_begin = json; + state.cur_line = 1; - for (i = json ;; ++ i) + for (state.ptr = json ;; ++ state.ptr) { - json_char b = *i; - - if (flags & flag_done) - { - if (!b) - break; - - switch (b) - { - whitespace: - continue; - - default: - sprintf (error, "%d:%d: Trailing garbage: `%c`", cur_line, e_off, b); - goto e_failed; - }; - } - + json_char b = (state.ptr == end ? 0 : *state.ptr); + if (flags & flag_string) { if (!b) - { sprintf (error, "Unexpected EOF in string (at %d:%d)", cur_line, e_off); + { sprintf (error, "Unexpected EOF in string (at %d:%d)", line_and_col); goto e_failed; } @@ -263,19 +297,41 @@ json_value * json_parse_ex (json_settings * settings, const json_char * json, ch case 't': string_add ('\t'); break; case 'u': - if ((uc_b1 = hex_value (*++ i)) == 0xFF || (uc_b2 = hex_value (*++ i)) == 0xFF - || (uc_b3 = hex_value (*++ i)) == 0xFF || (uc_b4 = hex_value (*++ i)) == 0xFF) + if (end - state.ptr < 4 || + (uc_b1 = hex_value (*++ state.ptr)) == 0xFF || + (uc_b2 = hex_value (*++ state.ptr)) == 0xFF || + (uc_b3 = hex_value (*++ state.ptr)) == 0xFF || + (uc_b4 = hex_value (*++ state.ptr)) == 0xFF) { - sprintf (error, "Invalid character value `%c` (at %d:%d)", b, cur_line, e_off); + sprintf (error, "Invalid character value `%c` (at %d:%d)", b, line_and_col); goto e_failed; } - uc_b1 = uc_b1 * 16 + uc_b2; - uc_b2 = uc_b3 * 16 + uc_b4; + uc_b1 = (uc_b1 << 4) | uc_b2; + uc_b2 = (uc_b3 << 4) | uc_b4; + uchar = (uc_b1 << 8) | uc_b2; + + if ((uchar & 0xF800) == 0xD800) { + json_uchar uchar2; + + if (end - state.ptr < 6 || (*++ state.ptr) != '\\' || (*++ state.ptr) != 'u' || + (uc_b1 = hex_value (*++ state.ptr)) == 0xFF || + (uc_b2 = hex_value (*++ state.ptr)) == 0xFF || + (uc_b3 = hex_value (*++ state.ptr)) == 0xFF || + (uc_b4 = hex_value (*++ state.ptr)) == 0xFF) + { + sprintf (error, "Invalid character value `%c` (at %d:%d)", b, line_and_col); + goto e_failed; + } - uchar = ((json_char) uc_b1) * 256 + uc_b2; + uc_b1 = (uc_b1 << 4) | uc_b2; + uc_b2 = (uc_b3 << 4) | uc_b4; + uchar2 = (uc_b1 << 8) | uc_b2; + + uchar = 0x010000 | ((uchar & 0x3FF) << 10) | (uchar2 & 0x3FF); + } - if (sizeof (json_char) >= sizeof (json_uchar) || (uc_b1 == 0 && uc_b2 <= 0x7F)) + if (sizeof (json_char) >= sizeof (json_uchar) || (uchar <= 0x7F)) { string_add ((json_char) uchar); break; @@ -286,19 +342,32 @@ json_value * json_parse_ex (json_settings * settings, const json_char * json, ch if (state.first_pass) string_length += 2; else - { string [string_length ++] = 0xC0 | ((uc_b2 & 0xC0) >> 6) | ((uc_b1 & 0x3) << 3); - string [string_length ++] = 0x80 | (uc_b2 & 0x3F); + { string [string_length ++] = 0xC0 | (uchar >> 6); + string [string_length ++] = 0x80 | (uchar & 0x3F); } break; } + if (uchar <= 0xFFFF) { + if (state.first_pass) + string_length += 3; + else + { string [string_length ++] = 0xE0 | (uchar >> 12); + string [string_length ++] = 0x80 | ((uchar >> 6) & 0x3F); + string [string_length ++] = 0x80 | (uchar & 0x3F); + } + + break; + } + if (state.first_pass) - string_length += 3; + string_length += 4; else - { string [string_length ++] = 0xE0 | ((uc_b1 & 0xF0) >> 4); - string [string_length ++] = 0x80 | ((uc_b1 & 0xF) << 2) | ((uc_b2 & 0xC0) >> 6); - string [string_length ++] = 0x80 | (uc_b2 & 0x3F); + { string [string_length ++] = 0xF0 | (uchar >> 18); + string [string_length ++] = 0x80 | ((uchar >> 12) & 0x3F); + string [string_length ++] = 0x80 | ((uchar >> 6) & 0x3F); + string [string_length ++] = 0x80 | (uchar & 0x3F); } break; @@ -342,6 +411,9 @@ json_value * json_parse_ex (json_settings * settings, const json_char * json, ch top->u.object.values [top->u.object.length].name = (json_char *) top->_reserved.object_mem; + top->u.object.values [top->u.object.length].name_length + = string_length; + (*(json_char **) &top->_reserved.object_mem) += string_length + 1; } @@ -359,6 +431,85 @@ json_value * json_parse_ex (json_settings * settings, const json_char * json, ch } } + if (state.settings.settings & json_enable_comments) + { + if (flags & (flag_line_comment | flag_block_comment)) + { + if (flags & flag_line_comment) + { + if (b == '\r' || b == '\n' || !b) + { + flags &= ~ flag_line_comment; + -- state.ptr; /* so null can be reproc'd */ + } + + continue; + } + + if (flags & flag_block_comment) + { + if (!b) + { sprintf (error, "%d:%d: Unexpected EOF in block comment", line_and_col); + goto e_failed; + } + + if (b == '*' && state.ptr < (end - 1) && state.ptr [1] == '/') + { + flags &= ~ flag_block_comment; + ++ state.ptr; /* skip closing sequence */ + } + + continue; + } + } + else if (b == '/') + { + if (! (flags & (flag_seek_value | flag_done)) && top->type != json_object) + { sprintf (error, "%d:%d: Comment not allowed here", line_and_col); + goto e_failed; + } + + if (++ state.ptr == end) + { sprintf (error, "%d:%d: EOF unexpected", line_and_col); + goto e_failed; + } + + switch (b = *state.ptr) + { + case '/': + flags |= flag_line_comment; + continue; + + case '*': + flags |= flag_block_comment; + continue; + + default: + sprintf (error, "%d:%d: Unexpected `%c` in comment opening sequence", line_and_col, b); + goto e_failed; + }; + } + } + + if (flags & flag_done) + { + if (!b) + break; + + switch (b) + { + whitespace: + continue; + + default: + + sprintf (error, "%d:%d: Trailing garbage: `%c`", + state.cur_line, state.cur_col, b); + + goto e_failed; + }; + } + if (flags & flag_seek_value) { switch (b) @@ -368,10 +519,10 @@ json_value * json_parse_ex (json_settings * settings, const json_char * json, ch case ']': - if (top->type == json_array) + if (top && top->type == json_array) flags = (flags & ~ (flag_need_comma | flag_seek_value)) | flag_next; - else if (!state.settings.settings & json_relaxed_commas) - { sprintf (error, "%d:%d: Unexpected ]", cur_line, e_off); + else + { sprintf (error, "%d:%d: Unexpected ]", line_and_col); goto e_failed; } @@ -386,7 +537,10 @@ json_value * json_parse_ex (json_settings * settings, const json_char * json, ch continue; } else - { sprintf (error, "%d:%d: Expected , before %c", cur_line, e_off, b); + { + sprintf (error, "%d:%d: Expected , before %c", + state.cur_line, state.cur_col, b); + goto e_failed; } } @@ -398,7 +552,10 @@ json_value * json_parse_ex (json_settings * settings, const json_char * json, ch continue; } else - { sprintf (error, "%d:%d: Expected : before %c", cur_line, e_off, b); + { + sprintf (error, "%d:%d: Expected : before %c", + state.cur_line, state.cur_col, b); + goto e_failed; } } @@ -436,8 +593,11 @@ json_value * json_parse_ex (json_settings * settings, const json_char * json, ch case 't': - if (*(++ i) != 'r' || *(++ i) != 'u' || *(++ i) != 'e') + if ((end - state.ptr) < 3 || *(++ state.ptr) != 'r' || + *(++ state.ptr) != 'u' || *(++ state.ptr) != 'e') + { goto e_unknown_value; + } if (!new_value (&state, &top, &root, &alloc, json_boolean)) goto e_alloc_failure; @@ -449,8 +609,12 @@ json_value * json_parse_ex (json_settings * settings, const json_char * json, ch case 'f': - if (*(++ i) != 'a' || *(++ i) != 'l' || *(++ i) != 's' || *(++ i) != 'e') + if ((end - state.ptr) < 4 || *(++ state.ptr) != 'a' || + *(++ state.ptr) != 'l' || *(++ state.ptr) != 's' || + *(++ state.ptr) != 'e') + { goto e_unknown_value; + } if (!new_value (&state, &top, &root, &alloc, json_boolean)) goto e_alloc_failure; @@ -460,8 +624,11 @@ json_value * json_parse_ex (json_settings * settings, const json_char * json, ch case 'n': - if (*(++ i) != 'u' || *(++ i) != 'l' || *(++ i) != 'l') + if ((end - state.ptr) < 3 || *(++ state.ptr) != 'u' || + *(++ state.ptr) != 'l' || *(++ state.ptr) != 'l') + { goto e_unknown_value; + } if (!new_value (&state, &top, &root, &alloc, json_null)) goto e_alloc_failure; @@ -476,20 +643,43 @@ json_value * json_parse_ex (json_settings * settings, const json_char * json, ch if (!new_value (&state, &top, &root, &alloc, json_integer)) goto e_alloc_failure; - flags &= ~ (flag_exponent | flag_got_exponent_sign); - - if (state.first_pass) - continue; - - if (top->type == json_double) - top->u.dbl = strtod (i, (json_char **) &i); - else - top->u.integer = strtol (i, (json_char **) &i, 10); - - flags |= flag_next | flag_reproc; + if (!state.first_pass) + { + while (isdigit (b) || b == '+' || b == '-' + || b == 'e' || b == 'E' || b == '.') + { + if ( (++ state.ptr) == end) + { + b = 0; + break; + } + + b = *state.ptr; + } + + flags |= flag_next | flag_reproc; + break; + } + + flags &= ~ (flag_num_negative | flag_num_e | + flag_num_e_got_sign | flag_num_e_negative | + flag_num_zero); + + num_digits = 0; + num_fraction = 0; + num_e = 0; + + if (b != '-') + { + flags |= flag_reproc; + break; + } + + flags |= flag_num_negative; + continue; } else - { sprintf (error, "%d:%d: Unexpected %c when seeking value", cur_line, e_off, b); + { sprintf (error, "%d:%d: Unexpected %c when seeking value", line_and_col, b); goto e_failed; } }; @@ -508,9 +698,8 @@ json_value * json_parse_ex (json_settings * settings, const json_char * json, ch case '"': - if (flags & flag_need_comma && (!state.settings.settings & json_relaxed_commas)) - { - sprintf (error, "%d:%d: Expected , before \"", cur_line, e_off); + if (flags & flag_need_comma) + { sprintf (error, "%d:%d: Expected , before \"", line_and_col); goto e_failed; } @@ -535,8 +724,7 @@ json_value * json_parse_ex (json_settings * settings, const json_char * json, ch } default: - - sprintf (error, "%d:%d: Unexpected `%c` in object", cur_line, e_off, b); + sprintf (error, "%d:%d: Unexpected `%c` in object", line_and_col, b); goto e_failed; }; @@ -546,32 +734,109 @@ json_value * json_parse_ex (json_settings * settings, const json_char * json, ch case json_double: if (isdigit (b)) - continue; - - if (b == 'e' || b == 'E') { - if (!(flags & flag_exponent)) + ++ num_digits; + + if (top->type == json_integer || flags & flag_num_e) { - flags |= flag_exponent; - top->type = json_double; + if (! (flags & flag_num_e)) + { + if (flags & flag_num_zero) + { sprintf (error, "%d:%d: Unexpected `0` before `%c`", line_and_col, b); + goto e_failed; + } + if (num_digits == 1 && b == '0') + flags |= flag_num_zero; + } + else + { + flags |= flag_num_e_got_sign; + num_e = (num_e * 10) + (b - '0'); + continue; + } + + top->u.integer = (top->u.integer * 10) + (b - '0'); continue; } + + num_fraction = (num_fraction * 10) + (b - '0'); + continue; } - else if (b == '+' || b == '-') + + if (b == '+' || b == '-') { - if (flags & flag_exponent && !(flags & flag_got_exponent_sign)) + if ( (flags & flag_num_e) && !(flags & flag_num_e_got_sign)) { - flags |= flag_got_exponent_sign; + flags |= flag_num_e_got_sign; + + if (b == '-') + flags |= flag_num_e_negative; + continue; } } else if (b == '.' && top->type == json_integer) { + if (!num_digits) + { sprintf (error, "%d:%d: Expected digit before `.`", line_and_col); + goto e_failed; + } + top->type = json_double; + top->u.dbl = (double) top->u.integer; + + num_digits = 0; continue; } + if (! (flags & flag_num_e)) + { + if (top->type == json_double) + { + if (!num_digits) + { sprintf (error, "%d:%d: Expected digit after `.`", line_and_col); + goto e_failed; + } + + top->u.dbl += ((double) num_fraction) / (pow (10.0, (double) num_digits)); + } + + if (b == 'e' || b == 'E') + { + flags |= flag_num_e; + + if (top->type == json_integer) + { + top->type = json_double; + top->u.dbl = (double) top->u.integer; + } + + num_digits = 0; + flags &= ~ flag_num_zero; + + continue; + } + } + else + { + if (!num_digits) + { sprintf (error, "%d:%d: Expected digit after `e`", line_and_col); + goto e_failed; + } + + top->u.dbl *= pow (10.0, (double) + (flags & flag_num_e_negative ? - num_e : num_e)); + } + + if (flags & flag_num_negative) + { + if (top->type == json_integer) + top->u.integer = - top->u.integer; + else + top->u.dbl = - top->u.dbl; + } + flags |= flag_next | flag_reproc; break; @@ -583,7 +848,7 @@ json_value * json_parse_ex (json_settings * settings, const json_char * json, ch if (flags & flag_reproc) { flags &= ~ flag_reproc; - -- i; + -- state.ptr; } if (flags & flag_next) @@ -642,7 +907,7 @@ json_value * json_parse_ex (json_settings * settings, const json_char * json, ch e_unknown_value: - sprintf (error, "%d:%d: Unknown value", cur_line, e_off); + sprintf (error, "%d:%d: Unknown value", line_and_col); goto e_failed; e_alloc_failure: @@ -652,7 +917,7 @@ json_value * json_parse_ex (json_settings * settings, const json_char * json, ch e_overflow: - sprintf (error, "%d:%d: Too long (caught overflow)", cur_line, e_off); + sprintf (error, "%d:%d: Too long (caught overflow)", line_and_col); goto e_failed; e_failed: @@ -671,25 +936,23 @@ json_value * json_parse_ex (json_settings * settings, const json_char * json, ch while (alloc) { top = alloc->_reserved.next_alloc; - free (alloc); + state.settings.mem_free (alloc, state.settings.user_data); alloc = top; } if (!state.first_pass) - json_value_free (root); + json_value_free_ex (&state.settings, root); return 0; } -json_value * json_parse (const json_char * json) +json_value * json_parse (const json_char * json, size_t length) { - json_settings settings; - memset (&settings, 0, sizeof (json_settings)); - - return json_parse_ex (&settings, json, 0); + json_settings settings = { 0 }; + return json_parse_ex (&settings, json, length, 0); } -void json_value_free (json_value * value) +void json_value_free_ex (json_settings * settings, json_value * value) { json_value * cur_value; @@ -706,7 +969,7 @@ void json_value_free (json_value * value) if (!value->u.array.length) { - free (value->u.array.values); + settings->mem_free (value->u.array.values, settings->user_data); break; } @@ -717,7 +980,7 @@ void json_value_free (json_value * value) if (!value->u.object.length) { - free (value->u.object.values); + settings->mem_free (value->u.object.values, settings->user_data); break; } @@ -726,7 +989,7 @@ void json_value_free (json_value * value) case json_string: - free (value->u.string.ptr); + settings->mem_free (value->u.string.ptr, settings->user_data); break; default: @@ -735,8 +998,14 @@ void json_value_free (json_value * value) cur_value = value; value = value->parent; - free (cur_value); + settings->mem_free (cur_value, settings->user_data); } } +void json_value_free (json_value * value) +{ + json_settings settings = { 0 }; + settings.mem_free = default_free; + json_value_free_ex (&settings, value); +} diff --git a/Lib/mmfs2.lib b/Lib/mmfs2.0.lib similarity index 100% rename from Lib/mmfs2.lib rename to Lib/mmfs2.0.lib diff --git a/Lib/mmfs2hwa.lib b/Lib/mmfs2.0hwa.lib similarity index 100% rename from Lib/mmfs2hwa.lib rename to Lib/mmfs2.0hwa.lib diff --git a/Lib/mmfs2u.lib b/Lib/mmfs2.0u.lib similarity index 100% rename from Lib/mmfs2u.lib rename to Lib/mmfs2.0u.lib diff --git a/Lib/mmfs2.5.lib b/Lib/mmfs2.5.lib new file mode 100644 index 0000000..b5866fb Binary files /dev/null and b/Lib/mmfs2.5.lib differ diff --git a/README b/README deleted file mode 100644 index 8e7a9f3..0000000 --- a/README +++ /dev/null @@ -1,4 +0,0 @@ -Edif is an alternate extension development SDK for Multimedia Fusion 2, in which your extension -is a true C++ class, with a JSON file (optionally external) to describe it. - -TODO: Insert some helpful information here? \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..0553f82 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# Extension Development Is Fun +Edif is an alternate extension development SDK for Multimedia Fusion 2 and ClickTeam Fusion 2.5, in which your extension is a true C++ class, with a JSON file (optionally external) to describe it. We recommend that you [check out the wiki](https://github.com/ClickteamLLC/windows-edif/wiki/). If you're new to EDIF, read the [Getting started](https://github.com/ClickteamLLC/windows-edif/wiki/Getting-started) page. There are also some [Tutorials](https://github.com/ClickteamLLC/windows-edif/wiki/Tutorials).