I am working on a project in MAME 0.285 and I've hit a wall regarding dynamic layouts and Lua.
1. The Project
I want to display character artwork (movelists) on the left (P1) and right (P2) of the game screen. I want to cycle through different characters for both players independently using LSHIFT (P1) and RSHIFT (P2). (f.e. 7 characters in Mortal Kombat, each with their own artwork containing their movelist)
2. What works right now
Currently, I have it working by swapping the entire view. When I press a key, Lua changes the target.view_index. This works, but it means P1 and P2 are not independent. To make them independent, I would need to pre-define 49 separate views ($7 \times 7$ combinations) in my .lay file.
Code: Select all
if p1_pressed and not last_p1 then
current_idx = (current_idx % 7) + 1
target.view_index = current_idx -- This refreshes the art, but swaps the whole layout
endI want to use one single view and update the state of the P1 and P2 elements independently. However, when I try to change the state via Lua, the console shows the value has changed, but the images on screen do not update
The goal is to use something like this (which currently doesn't refresh the screen):
The .lay setup:
Code: Select all
<element name="skins">
<image state="0" file="subzero.png" />
<image state="1" file="scorpion.png" />
.......
</element>
<view name="Main">
<screen index="0"><bounds x="240" y="0" width="1440" height="1080"/></screen>
<element ref="skins" name="p1_skin"><bounds x="40" y="60" width="181" height="960"/></element>
<element ref="skins" name="p2_skin"><bounds x="1690" y="60" width="181" height="960"/></element>
</view>Code: Select all
-- This changes the internal state, but the renderer doesn't 'see' it
local p1_item = target.current_view.items:at(2)
p1_item:set_state(new_skin_index)Is there a way to force a refresh of the current view/elements in MAME 0.285 so that set_state actually updates the images on screen without having to switch view_index? Or is defining dozens of views the only way to get independent P1/P2 artwork?