ChesStrategy wrote:Hi Xela,
Thanks for the prompt response.
And honestly... you're writing decent code for what seems like a complicated game, LiveComposite is a poor, sad wrapper around a Fixed... you can create your own Fixed, prolly with better syntax, inside UDD if you wish and it may even end up working better and be better manageable.
Yes, worst case I can write my own, and based on what you said, it seems like I will have to do so. Obviously, where I can re-use code, that would reduce workload for me
, that the primary reason behind why I used LC.
Something along these lines:
Code: Select all
def MyCustomLiveComposite_1(size, **properties):
properties.setdefault('style', 'image_placement')
width, height = size
rv = Fixed(xmaximum=width, ymaximum=height, xminimum=width, yminimum=height, **properties)
rv.add(Transform(<some_child>, <supported_properties>))
# ... bla bla bla, moar transforms
rv.add(MyUDD(parent=rv)) # you can use the parent to get the proper size, or if size is a constant, just pass the size itself.
return rv
You can customize parameters as you see fit to make it as reusable as you like, I am just suggesting a general approach.
==================
This is the original (using ancient Position for whatever reason, I thought the idea was to kill Position off and use Transforms instead as a general rule in Ren'Py development...):
Code: Select all
def LiveComposite(size, *args, **properties):
"""
:doc: disp_imagelike
This creates a new displayable of `size`, by compositing other
displayables. `size` is a (width, height) tuple.
The remaining positional arguments are used to place images inside
the LiveComposite. The remaining positional arguments should come
in groups of two, with the first member of each group an (x, y)
tuple, and the second member of a group is a displayable that
is composited at that position.
Displayables are composited from back to front.
::
image eileen composite = LiveComposite(
(300, 600),
(0, 0), "body.png",
(0, 0), "clothes.png",
(50, 50), "expression.png")
"""
properties.setdefault('style', 'image_placement')
width, height = size
rv = Fixed(xmaximum=width, ymaximum=height, xminimum=width, yminimum=height, **properties)
if len(args) % 2 != 0:
raise Exception("LiveComposite requires an odd number of arguments.")
for pos, widget in zip(args[0::2], args[1::2]):
xpos, ypos = pos
rv.add(Position(widget, xpos=xpos, xanchor=0, ypos=ypos, yanchor=0))
return rv