ENIGMA Forums

Sharing is caring => Ideas and Design => Topic started by: luiscubal on January 22, 2011, 05:34:42 PM

Title: Extension API
Post by: luiscubal on January 22, 2011, 05:34:42 PM
I propose an extension API for ENIGMA based on the following concepts:

1. Each extension will typically have a Java/LGM part and an "execution" part(C++/ENIGMA or whatever the backend is)
3. Each execution component has a part of it that describes its function. This might be in Java, XML or any other cross-platform language that LGM can understand.

-------------------------------------

Core Extension API

Code: [Select]
LGM.requestRestart(String msg); //If the extension requires a restart
LGM.installExtension(String path, Object params); //Install "with args"
LGM.installExtension(String path); //Same as installExtension(path, null)
LGM.uninstallExtension(Extension extension);

Code: [Select]
class Extension
public String getName()
public String getDescription()
public String[] getAuthors()
public java.awt.Image getIcon()
public boolean getEnabled()
public void setEnabled(boolean enabled);
public ExtensionContent load();

Code: [Select]
interface or class ExtensionContent
public void install();
public void load(); //Extension code and resources were loaded, now handle the load logic
public void enable(); //Enable the extension

This is the barebones, now the interesting part:

Code: [Select]
void LGM.registerResourceType(ResourceType resource);
void LGM.unregisterResourceType(ResourceType resource);
GameFolder LGM.createGameFolder(String folderName, ResourceType resource, boolean canRename);
void LGM.renameGameFolder(GameFolder folder);
void LGM.deleteGameFolder(GameFolder folder);

Code: [Select]
class or interface ResourceType
public String getName();
public Image getIcon();
public Designer createDesigner(Object resource);
//Missing is the serialization API for loading/saving. I don't think I can properly design this without also designing a file format, which is not within the scope of this topic, so someone else will have to do this part.

Code: [Select]
class Designer extends JPanel
//Stuff like designer window title, etc.

Now for the "execution" part:
Code: [Select]
LGM.registerExecutionPlugin(ExecutionPlugin plugin);

Code: [Select]
class or interface BackendInfo
public String getName(); //return "enigma";
public String getLanguage(); //return "cpp";
public boolean isDebugMode();
public String getFullInfo(); //something like "enigma/cpp debug windows+opengl+openal"
//Possibly more functions

Code: [Select]
class or interface ExecutionPlugin
public String getName();
public boolean acceptsBackend(BackendInfo info); //Whether the execution plugin was made for this backend
public Script[] getScripts(); //Creates GML scripts for the plugin, useful for pure GML plugins
//The rest would be backend-specific. For instance, ENIGMA could provide a EnigmaExecutionPlugin.
//Do note that even if a plugin was not EnigmaExecutionPlugin, ENIGMA would accept it based ONLY on the acceptsBackend function, in order to allow pure GML extensions.

I am not sure how to allow pure GML scripts to handle custom resources, though.

This is just a proposal. Feel free to use, modify and/or ignore it. I release this proposal under the WTFPL.
Title: Re: Extension API
Post by: RetroX on January 22, 2011, 08:41:23 PM
I think that we should have a separate resource type entirely for C++ scripts.  It would act like definitions, although, all concatenated.  This would allow people to sort their sources rather than dumping them all into one pile.

I think that an entire extensions system is kind of overkill.

Maybe we could allow LGM to import GML or C++ scripts from an archive?
Title: Re: Extension API
Post by: luiscubal on January 22, 2011, 09:58:26 PM
Not enough. We're talking about entire resource types.
Josh mentioned a while back that he would like paths and alarms to be entirely extensions. What you describe can not possibly implement this properly.
Title: Re: Extension API
Post by: Fede-lasse on January 23, 2011, 07:04:08 AM
Will the extensions be compiled or protected in some proper manner? They would be really useful if so.
Title: Re: Extension API
Post by: luiscubal on January 23, 2011, 11:39:54 AM
That would be up to Josh. I am, however, guessing that for C++ extensions at least the header files will be unprotected.
Title: Re: Extension API
Post by: Josh @ Dreamland on January 23, 2011, 06:22:24 PM
He's proposing a solution to an issue from another thread, being allowing adding resources to LGM. Simple extensions or static parts of extensions could potentially be released as object files on a per-platform basis. That said, this system would be for users who are wise enough to stay open source. Hence, I doubt that this will be requested, but I don't mind allowing for it.

I can see how this would allow adding resources, but not how it would allow modifying existing ones. I'd like Ism's opinion on it.
Title: Re: Extension API
Post by: IsmAvatar on January 23, 2011, 11:57:24 PM
As I said in the other thread, I do like the idea, and was expecting it to come sooner or later. This is especially helpful for LGM, as it's very bundled currently, making it hard to modify/extend, so this is a welcome change. I'm not a fan of luis's proposal, but it kinda gives us an idea of where to start.

We could provide official extensions which will maintain the ENIGMA license so that users don't have to worry about "boohoo, all the good stuff forces me to go open source."

This seems already pretty much compatible with LGM's existing plugin system for the most part, which is another part of my concern with Luis's suggestion - it's not revolutionary enough to change the internals of LGM yet, which is what I'd really like to do. I'm sure as it evolves that will become more readily available.

Also, luis should consider joining the IRC from time to time.
Title: Re: Extension API
Post by: Fede-lasse on January 24, 2011, 10:30:15 AM
I was hoping I could give out functions to users without allowing them to see the source, kinda like a DLL, without being a DLL. This isn't possible or will not happen? And will these extensions be compatible with GM? *guesses no to both*
Title: Re: Extension API
Post by: Josh @ Dreamland on January 24, 2011, 09:33:31 PM
Making it easy for users to distribute compiled extensions on a per-platform basis is easily in our power and will probably be implemented. It will not be compatible with GM. It's also not relevant to this topic. This thread is basically dead; I'm considering closing it in favor of the other topic, but I'm generally opposed to closing things, so.
Title: Re: Extension API
Post by: MrGriggs on March 30, 2011, 05:37:04 AM
Similar to what MultiMedia Fusion has?

I remember their MOO extension, lol.