SonyWWS / LevelEditor

The ATF LevelEditor is a powerful tool for constructing and assembling game levels. It provides a WYSIWYG interface and allows you to place objects, edit properties, edit terrain, and build game levels.
Apache License 2.0
1.32k stars 230 forks source link

ResourceListener - managed usage? #32

Open jethac opened 8 years ago

jethac commented 8 years ago

Hello! As per topic - I find myself in need of a resource-loaded listener in managed land, and for the life of me I can't seem to find one. The use case is, loading a game object definition file that contains game object component definitions, and then resolving and instantiating components for those definitions once the file has been loaded.

If the functionality doesn't exist yet I'll take a swing at it, but I figured I'd ask just in case.

jethac commented 8 years ago

Well, I feel dumb. Coming back to it with fresh eyes, IResourceService has a ResourceLoaded event... I'll just let myself out here. Sorry to make you worry!

jethac commented 8 years ago

...sadly, that didn't help very much at all. The triggering order seems to be:

[C#] IResourceService.OnResourceLoaded [C#] IResourceConverter.Convert [C++] ResourceFactory.LoadResource

...and I'm after something that can tell me when LoadResource succeeds. If anything, IResourceService might be better named OnResourceRequested - it implies that the resource is ready at that point, when it's not guaranteed to be in fact.

Any notes re: resource lifecycle would be appreciated!

abeckus commented 8 years ago

In C++ side there is an event called when resource is loaded. look at class MyResourceListener : public ResourceListener {} located in LvEdRenderingEngine.cpp. OnResourceLoaded(Resource* r); is called when resource is loaded. The current implementation of OnResourceLoaded invokes InvalidateViewsCallbackType call back. I suggest to rename InvalidateViewsCallbackType to resource loaded call back and do the same in C# side. Also rename C# side too.

jethac commented 8 years ago

Cheers Alan - that does look like what I'm after in terms of the lifecycle. Will take a stab at it now! :+1: