Backov
06-13-2007, 05:29 PM
This is pretty esoteric, but I figured someone might have some good insights here.
I'm (re)implementing my track editor in my Ogre engine. One of the features of that editor is that objects on the track have "properties", which are as simple as position, width, height and then additional properties like "speed boosted %", "refuel per second", etc..
Essentially they're all int or float properties at this point.
Anyway, in my old system I had a properties system that wasn't the greatest I don't think, but it worked pretty well. When you'd click on an item, the game would ask the selected object for its properties.. The object would return its base objects properties as well as its own in a dictionary of properties, all object instances inherited from AbstractProperty, like FloatProperty, IntProperty, etc.. Once it got the whole dictionary, it would create a list of editor GUI controls, like a text box, increment/decrement boxes, etc, and hook their methods up to each of the properties.. When the properties were changed, they'd alert the actual track objects, so you could instantly see the change on the track display. It worked pretty well.
Anyway, something about it seems kludgey. It worked, but I think there's probably a nicer way to do it. Anyone know of a good pattern for this? Something to do with templates?
I'm (re)implementing my track editor in my Ogre engine. One of the features of that editor is that objects on the track have "properties", which are as simple as position, width, height and then additional properties like "speed boosted %", "refuel per second", etc..
Essentially they're all int or float properties at this point.
Anyway, in my old system I had a properties system that wasn't the greatest I don't think, but it worked pretty well. When you'd click on an item, the game would ask the selected object for its properties.. The object would return its base objects properties as well as its own in a dictionary of properties, all object instances inherited from AbstractProperty, like FloatProperty, IntProperty, etc.. Once it got the whole dictionary, it would create a list of editor GUI controls, like a text box, increment/decrement boxes, etc, and hook their methods up to each of the properties.. When the properties were changed, they'd alert the actual track objects, so you could instantly see the change on the track display. It worked pretty well.
Anyway, something about it seems kludgey. It worked, but I think there's probably a nicer way to do it. Anyone know of a good pattern for this? Something to do with templates?