ogre icon indicating copy to clipboard operation
ogre copied to clipboard

Make Overlays part of the Resource System

Open paroj opened this issue 6 years ago • 3 comments

for proper unloading/ reloading

paroj avatar Nov 17 '19 13:11 paroj

I'd like to help with this. Is there anything special I need to know? I already had some contact with the Resource system, I think I can make out the rest from the code and docs.

I want to use overlays as base for user-made animated HUDs in Rigs of Rods. I already wrote a prototype, but I bumped into the reload-hack. I want the overlay scripts to be un/loaded ad hoc as part of user-made content, so they must behave as Resources.

ohlidalp avatar Apr 19 '21 12:04 ohlidalp

I dont recall why I did not port things right-away (maybe I wanted to get 1.12 out of the door).

One thing to consider is that OverlayManager, separates its elements into "templates" and "instances". The templates are an early form of script inheritance via OverlayElement::copyFromTemplate.

I am not sure how this affects resource reloading. On the other hand there is also Material::copyDetailsTo.

paroj avatar Apr 19 '21 16:04 paroj

took a closer look

  • deriving OverlayElement from Resource requires additional constructor info (notably resource handle) so all custom ElementFactories will break
  • the custom inheritance renames inherited children to avoid name conflicts as children are elements themselves (in contrast to Material -> Technique)
  • the typical use of OverlayElement is via createOverlayElementFromTemplate. These elements wont get updated, even if we manage to reload the template

I did some refactoring in #2136, but I will leave it at this for 1.13 and give it some more thought.

paroj avatar Jul 27 '21 01:07 paroj