Engine Wishlist/Coordination

Started by monkey0506, Fri 29/04/2011 12:06:07

Previous topic - Next topic

monkey0506

#20
You don't necessarily need functions like that in order to implement this in an OO-compliant way. That's what properties and indexers are for (which the MSDN defines as being functions! :P).

So maybe even:

readonly static Room* Game.Rooms[int roomNumber]

Returns the Room identified by ROOMNUMBER. Uses actual room numbers; you can use Game.RoomID to get the room number of a given room sequentially.

Then we could do:

Code: ags
Room *room = Game.Rooms[roomNumber];
Object *obj1 = Game.Rooms[roomNumber].Objects[objectID];
Object *obj2 = room.Objects[objectID];


I know that internally it would be working out the same anyway, but it just looks and feels nicer to me. Of course this (at least as shown for obj1) would also be dependent on getting the compiler error fixed that prevents access of non-static members of static members.

As an interesting side-note, aside from the fact that I'm proposing linking these items into the Game structure statically, this (meaning the static properties and indexers) would even be feasible from the standpoint of a module, so presumably it would be rather easy to implement.

redspark

Perhaps looking at the core for portability might be a good way to go.  I don't know how much effort it would be to recompile to OSX but it would be nice to have a Mac engine again.  The lack of an OSX engine is the only reason I have shied away from using AGS.  Otherwise, IMHO, AGS is the best game development kit available. :)

monkey0506

I've been working on developing the demo of my Playlist module, in the style of a fashionable media player :=, and I've come across a couple points that I would like to see about having implemented in the engine if possible.

Currently there is no generic way of accessing the game audio. I would very much like to be able to do this so that I could allow the user to save playlist data to an external file. Since there's no generics for AudioClips though, I can't really do that. So, I'm proposing the following:




readonly static AudioClip* Game.AudioClips[int index]

Returns the AudioClip* indicated by the specified index. Useful if you need to loop through the audio in the game for some reason, such as via a module.

readonly int AudioClip.ID

Returns an integer ID associated with this AudioClip, for use with the Game.AudioClips array.




This would allow me to save the AudioClip.ID to the external file, and when reading it back in, use Game.AudioClips to get an AudioClip* again. Currently I could create a custom ID based on the clips that have been added to a playlist, but I would have no way to read it back as an AudioClip*.

Also, I would find it useful for my purposes if audio files could be loaded dynamically. The basic structure would be very similar to the existing AudioClip structure, with the following additional functions (including the ID property I suggested above):




static DynamicAudio* DynamicAudio.CreateFromFile(String filename, AudioType)

Loads an external audio file FILENAME into memory, and gives it the specified AudioType. AudioFileType is automatically determined by the file type of the loaded file.

IMPORTANT: This command loads an extra audio clip into memory which is not controlled by the normal AGS audio cache and will not be automatically disposed of. Therefore, when you are finished with the image you MUST call Delete on it to free its memory.

IMPORTANT: If the DynamicAudio instance is released from memory (ie. there is no longer a DynamicAudio* variable pointing to it), then the clip will also be removed from memory. Make sure that you keep a global variable pointer to the clip until you are finished with it, and at that point call Delete.

void DynamicAudio.Delete()

Deletes the specified dynamic audio clip from memory. Use this when you are no longer using the clip and it can be safely disposed of.

You do not normally need to audio clips, since the AGS Audio Cache manages loading and deleting audio clips automatically.

However, when an extra audio clip has been loaded into the game, via CreateFromFile, then AGS does not delete it automatically, and you must call this command instead.

NOTE: This command will set the IsAvailable property for the clip to false. You can use this property to make sure that the clip has not been deleted before playing it.




I might actually consider seeing what I could do to offer some of the same functionality via a plugin since I don't have access to the engine source at the moment...anyway, feel free to comment on the suggestions. :=

Calin Leafshade

None of that is possible really since the plugin API has been neglected for quite a while (because it's rarely used i imagine)

The plugin API doesnt expose any of the new audio system (or any of the D3D functions either much to my chagrin)

Yeppoh

On the topic of D3D, I'm in the project of reworking/optimising the D3D rendering engine of AGS so I can put a post-processing feature (meaning setting a Backbuffer in D3D mode). Put so far I'm trying to understand all the settings and what calls what.
On an interesting side, implementing Overlays' Transparency was extremely easy, since it was already there, but unused.

monkey0506

I was going to try and do something ridiculous and script some native AGScript functions and register them as a header, but I can't get the C# plugin API to work at all. Even the example code is producing a run-time explosion for me in the engine.

Even if it isn't possible via an engine plugin, this was originally an engine suggestion anyway. :P

However, I came across PlayMP3File which was apparently replaced by AudioClip.Play. That seems like a regression in the capabilities of the engine. The DynamicAudio type I suggested would be a better replacement for the function than AudioClip.Play since the latter can't load external files at run-time.

SMF spam blocked by CleanTalk