Okay so its been a couple of days since an update, bit off since ive been putting an update up here almost every day for the past week lol
What i am doing now:-
I think the most important thing at the moment is to be able to create modules inside the editor and to present the tools in a user-friendly way. Figuring out this loading and saving is becoming a bit of a challenge.
What is happening at the moment is every object added to the scene is put into its own simset, animations,sprites etc. Because the EditorToy is a module itself it looks for images in its own module. Loading another module inside the editortoy as far as i know is possible but at the moment because the objects are being created in one module and then added to a simset within that module, when it gets saved out and loaded back into the editor, the simset for the objects already exists and so it will not add them to it. Now i am working to fix this atm im almost certain its just a problem in my code.
But for exporting your projects and levels out i plan to do it the CS file route.
With the cs file route you can write out line by line the file that you want to put out. So for example if you have 10 sprites with a particular image asset, u you only have to have your constructor for that object in place once and have a create function in your reset script with different variables like so:
function MyToy::reset(%this)
{
%this.createBackground( static,10,10,1,1,1,31,"blue");
%this.createBackground( static,10,10,1,1,1,31,"red");
%this.createBackground( static,10,10,1,1,1,31,"green");
}
function MyToy::createBackground( %this, %bType, %posX, %posY, %sizeX, %sizeY,%pBool,%sLayer,%blndColor )
{
// Create the scroller.
%object = new Sprite();
// Set the sprite as "static" so it is not affected by gravity.
%object.setBodyType( %bType);
// Always try to configure a scene-object prior to adding it to a scene for best performance.
// Set the position.
%object.Position = %posX SPC %posY;
// Set the size.
%object.Size =%sizeX SPC %sizeY;
%object.PickingAllowed = %pBool;
// Set to the furthest background layer.
%object.SceneLayer = %sLayer;
// Set an image.
%object.Image = "ToyAssets:checkered";
// Set the blend color.
%object.BlendColor = %blndColor;
// Add the sprite to the scene.
SandboxScene.add( %object );
}
The above code is just an example for sprites using one imageasset. So if u have this sprite in your code 50 times it will create 50 create functions at the top to build the level. As far as i know this should be the best way to do it and it will mean an export with 20 lines of code for that 1 item instead of 1000 so if u do have to do any edits after export you wont have to delv through all that code to find the one object that isnt correct, you shouldn't have to do this anyway as long as you keep your modules save file, but for quick fixes sometimes we just like to jump into the script file and modify a single value while loading the module itself.
The old torque 2d (TGB) used to have different levels as different scenes and so this is the way i think i will do it with this editor too. Each level will be a different scene file that is loaded. This will in turn clear the previous scene removing it from memory and add another scene to the game that has function mentioned above added to it. Each scene will have its own settings too for camera size, gravity etc. each scene again will be saved as a taml file for the editor but exported as a cs file upon export for gameplay.
Each module will be saved for editing as a cs file, which will include a list of scenes which will in turn be linked to its respective objects taml files.