-
An update from me...
Part 1 : Edif
First of all, I'd like to announce my new SDK for MMF2 extension development. It's called Edif - "Extension Development Is Fun".
Extension development has always been very much centred around tedious population of the info tables, resources, menus and jump tables, with a low proportion of the time actually spent on writing the code.
In 2007, Villy and I made an attempt to rectify this with a new, macro-based SDK for MMF2 based on some earlier work by Turboferret, called rSDK. Although rSDK sped up extension development a lot (nearly all of my extensions have been rSDK extensions, and that's around thirty now) it introduced a new set of problems of its own.
rSDK extensions didn't work with Visual Studio's intellisense due to heavily use (abuse, maybe) of macros. They were also impossible to translate since the strings weren't part of the resources (all official CT extensions are translated to French, so I haven't been able to use rSDK for, say, the Mochi extensions), and many bugs have been dug up over the years, such as crashes in nested expressions. rSDK also didn't solve the problem of the LPRDATA (rdPtr) structure not being allocated properly, so you still had to store everything as pointers, create them in CreateRunObject, and delete them in DestroyRunObject.
Another problem common to the normal SDK and rSDK is that code reuse is impossible, without writing your extension in a class and having the actions/conditions/expressions as simple wrappers (more tedious wrapping work). Actions/conditions/expressions can't call other actions/conditions/expressions, because the parameters aren't real C++ parameters - they're provided via special functions (CNC_GetParameter*, wrapper with Param() and ExParam() in rSDK).
Edif is my attempt to solve this situation. With Edif:
* Your extension is a simple C++ class. Actions, conditions and expressions are member functions, with real parameters and real return types. They can call each other (obviously) and you link them to be used as the actions/conditions/expressions by calling, for example, LinkExpression(0, MyExpression) in the constructor of your extension class, to link the member function MyExpression to expression ID 0.
If MyExpression took a float parameter and an integer parameter and returned a float of the two added together, it'd look like this:
Code:
float Extension::MyExpression(float MyFirstParameter, int MySecondParameter)
{
return MyFirstParameter + MySecondParameter;
}
All the GetParameter stuff, setting the flags, and giving the return value back to MMF, is handled by Edif. It uses assembler code to dynamically push the action arguments so that they arrive as real function arguments, and call the action function in the Extension class.
* Since your extension is a real C++ class, you simply add what you want to store at runtime (which would normally go in rdPtr) as class members. The constructors/destructors will be called properly, and you can access them without putting rdPtr-> everywhere in your actions, conditions and expressions.
* The Extension class (and the edittime stuff, which is the same in Edif as the normal SDK or rSDK) is the only thing inside the MFX file. Edif extensions also have an external JSON file (well, it's actually a slightly modified JSON syntax that doesn't require commas) which contains the object name, description, etc, and a description of each individual action/condition/expression and its parameters. It also contains the menu in a JSON-ified form.
All the strings in the JSON file can easily be specified in multiple languages using a special syntax, and Edif will automatically detect if the current version of MMF is English or French, and choose the appropriate string. UTF-8 support for the Unicode version of MMF is planned.
This leads on to...
Part 2 : AS Dynamics
If you're a user of Flash runtime, you've probably been following/waiting for my AS Dynamics object, the "custom ActionScript" object.
You'll probably be disappointed to hear that you're never going to see it. Here's why you shouldn't be.
Flash Player can not interpret AS 3.0 at runtime. This means that an object along the lines of the Lua objects but for ActionScript is completely impossible. Any AS 3.0 code must be written at edittime and compiled into the SWF.
To get around this and allow people to write custom AS code, I got Yves/Francois to add a special feature to build 250. The way the SWF exporter works is that it extracts the entire runtime source to a temporary directory, adds in all the extensions, and then invokes the Flex compiler to build it into a SWF. The new feature means that it's now possible for an extension to hook into this build process and modify the contents of that temp folder before the Flex compiler gets invoked.
The AS Dynamics object let you write an ActionScript file, and then call functions from it in a manner similar to the Lua objects (push argument, call function, etc) at runtime. It did this by modifying the AS Dynamics extension ActionScript at build time, to tell it to import this ActionScript file and how it was allowed to call it.
When this was nearly finished, I got assigned the task of writing the Newgrounds API object. After five or ten minutes with the standard SDK, I began to wonder whether it'd take much longer to write a new, quick to use SDK and implement the object in that. That's where Edif came from.
Edif deprecated AS Dynamics, before it was even released. Because all the information about the extension is external to the MFX file, if you don't mind your extension doing nothing in the C++ version, you can just copy-paste a precompiled Edif MFX, write new JSON to describe the extension and its actions/conditions/expressions, and then implement them in ActionScript only. You can make an extension for the Flash runtime without even having a C++ compiler installed, let alone touching a line of C++. Extension development is now open to anyone who can code ActionScript - at least, when some tutorials have been written, anyway.
Edif topic is over here
-
Re: An update from me...
So, technically it is now possible to port Box2D over to MMF2 with Edif?
-
Re: An update from me...
It was possible before, if you had the Flash SDK. But yeah, you can do it without the Flash SDK with Edif.
-
Re: An update from me...
However, you at least need a list of actions/conditions/expressions with their respective ID. I'm sure Werbad wouldn't mind giving it out, though.
-
Re: An update from me...
I get excited about C++ extension development, then disappointment about AS3 for a small amount of time until i realized that was just runtime (i think), then excited about AS3 development and a new SDK all over again... Epic! It's like drama in a post.
This is really great, i took a quick look at the new SDK and seems to have a great format/layout so i will have to test this as soon as i can. Looking forward to any tutorials and info also, this seems like it will be really cool. :D
-
Re: An update from me...
This post will change my life.
EDIT: Thank you, its a good change! I feel like I'll learn a lot more C++ with the new Edif!
-
Re: An update from me...
I'm not sure what this means, but I'm assuming that if it's built around classes, I can finally use classes without them falling miserably apart. Never the less I'm just glad theres a new SDK. Lets see those extensions lists expand.
-
Re: An update from me...
Along with MMF2 loadup times ;)
-
Re: An update from me...
That was a really great idea and it opens a lot of doors to MMF2 development.
Thank you for all your hard work, Jamie.
-
Re: An update from me...
awesome i gotta check this out, wish i saw it earlier
-
Re: An update from me...
Just when it will be Unicode compatible?
-
Hmm... I want write my first own extension with EDIF... but I can't figure howto do this, can you give me some resources from the forum which I must follow ?
Actually, what I made is:
1) Downloaded EDIF SDK Kit
2) Unzip to a folder and then Loaded the .vcproj into My Visual C++ 2010 Express
3) In VC++2010 It said I must convert the project to a newer recent version/structure of VC++ (accordling to VC++2010).
4) What I've made
5) Then opened the Template.vcprojx and then see the source code of EDIF/Extensions headers
So.. now, What I must to do?
I mean: How to read some docs, How to include some other libs to my extensions... I'm lost, please help with some docs or samples or If exists: a FULLY Readable EDIF Reference homepage! (or wiki)!
THANKS :)
-
For starting out, the only files you will want to have open will be Ext.json, Extension.h, Extension.cpp, Actions.cpp, Conditions.cpp, and Expressions.cpp. There is no reference or wiki or anything of that sort, so you'll just have to use the template as an example. Make sure you copy the template project to a new folder with a different name, you wouldn't want to have to redownload EDIF every time you want to make a new extension.
Extension.h is where you put your extension's local variables, and where you declare the Action functions, Condition functions, and Expression functions. You define the finctions in their corresponding .cpp files. Extension.cpp is the general extension-related area, where you define the constructor, destructor, and other things such as saving and loading frame positions.
-
Thanks LB, I will try some things tomorrow ! I'm was also thinking about create a new folder (before you've said that) for save my Extension source. But.. some questions come up:
1) Why there is no wiki or documentations?
2) When I import the project (Template.vcproj) to VC++2010, it ask for converting to VC++2010 file format/structure, so I made that (it's ok or not?)
3) When I build the solution, I get a folder called MFX, and within some files, included in a .mfx file (Template.mfx).. But when I try to move this file to my:
Extensions\
Data\Runtime
MMF2's folders, it simply not listed in my Extension list in MMF2, but was curiously listed as an .mfx in ExtensionView (by Jaffob).
So.. All I've must (for testing EDIF) is :
a) import the project in VC++, convert it to VC++2010 file format and then generating the solution (build Solution); It create a MFX folder and a mfx file.. But, unable to see It in my MMF2 (of course, even moved to the correct folder I've said..) What I do wrong?
Thanks for help, much appreciated ;) !
-
1. There just isn't.
2. Why can't you just open the .sln file?
3. There are five build configurations: Debug, Edittime, Runtime, Edittime Unicode, and Runtime Unicode. You should be concerned with the first three. Debug and Edittime create MFX files that go in to MMF2\Extensions\, whereas Runtime creates an MFX file that goes into MMF2\Data\Runtime\. MMF2 looks for extensions in (guess what) the Extensions folder; the ones on Data\Runtime\ are only used for building the EXE.
-
Ah... It seems (first time) I wanted to open the project by .sln file, there is not actions taken by system..
But, perhaps I mistakefully something
EDIT: ok I understand why it taked no action, it's because file was attempted to be loaded within VC# (not VC++), If I force the opening within VC++ it's ok, but convert always required!
REEDIT: Great, now I can see it listed in my extensions list within MMF2! SO Thanks LB !!! :)=