H-uru / Plasma

Cyan Worlds's Plasma game engine
http://h-uru.github.io/Plasma/
GNU General Public License v3.0
205 stars 80 forks source link

`ptGUIControl` construction improvement. #1428

Closed Hoikas closed 1 year ago

Hoikas commented 1 year ago

This allows the scripter to avoid indirections through ptKey in their python code such that instead of writing something like:

ctrl = ptGUIControlButton(MyGUIAttr.dialog.getControlFromTag(kButtonTag))
ctrl.show()

The following can be used:

ctrl = MyGUIAttr.dialog.getControlModFromTag(kButtonTag))
ctrl.show()

This allows for more concise Python code and avoids constructing temporary pyKey objects in the engine. This API change is backwards incompatible, so I opted to make this a new method. I elected to not make ptGUIDialog a mapping type because controls can be fetched by both ID and tag, which are distinct values. It's better to be explicit in this case, IMO.

Further, I have applied the new methods to all Python code except for the KI (ki module and xOptionsMenu) because there are roughly 500 instances of the old junk in those files, and I'm getting tired.