Control Panel Layout images
-
Hey all! I've been following this thread:
Control Panel Layout before game starts
(thanks, @TheRealSmilebit .. exactly what I want to do)
I'm trying to create my own cpanel images for each of my roms. @Texacate has some great code to generate button layout (thank you!), but I want to also display controls like joystick, spinner, etc. (I know, I'm being greedy always wanting more ;). Looking at info from @markwkidd , the controls.xml file from the MAME 2003-Plus project has all the details I need. The question I have for the hive mind is, how do I parse (in bash, using XMLStarlet) for each game, select rom name and each configured control name, with label, so I can then use imagemagick to generate the image (I've got this part working, thanks again to @Texacate ).Here's a snippet of the control.xml file:
<game romname="roundup" gamename="Round-Up" numPlayers="2" alternating="1" mirrored="1" usesService="0" tilt="0" cocktail="1"> <miscDetails> The original panel has the same button either side of the joystick so can be played with either hand </miscDetails> <player number="1" numButtons="1"> <controls> <control name="4-way Joystick"> <constant name="joy4way"/> </control> </controls> <labels> <label name="P1_BUTTON1" value="Cube Color Select"/> <label name="P1_JOYSTICK_UP" value="Up"/> <label name="P1_JOYSTICK_DOWN" value="Down"/> <label name="P1_JOYSTICK_LEFT" value="Left"/> <label name="P1_JOYSTICK_RIGHT" value="Right"/> </labels> </player> </game>
The last phase will be to display the image at game startup (I've seen a few posts on this already; will work on this once I get the images generated).
Thanks for any help!
-Ron
-
xmlstarlet sel -t \ -m '//game[@romname="roundup"]/player' -v "concat('Player ',@number)" \ -n -v 'concat("* control: ", controls/control/@name, " (", controls/control/constant/@name, ")")' \ -n -m 'labels/label' -v 'concat("* button : ", @name," = ", @value)' \ -n control.xml
-
@mitu Awesome, thanks! Of course, one good deed.. inspires more questions ;)
In bash scripting, how do I get iterative values? (load 'em into arrays?)
And when it comes to single elements (miscDetails) vs. multiple (button labels), would I need individual XMLStarlet calls? (it's a nice, and compact language, but I'm having a hard time wrapping my head around how best to code it).Thanks again!
-
@ronbo85 said in Control Panel Layout images:
In bash scripting, how do I get iterative values? (load 'em into arrays?)
Yes, you can use arrrays.
And when it comes to single elements (miscDetails) vs. multiple (button labels), would I need individual XMLStarlet calls? (it's a nice, and compact language, but I'm having a hard time wrapping my head around how best to code it).
My example shows everything in one call, but you can run separate commands if you want to get different values without parsing the output.
For instance, to get the contents of themiscDetails
node:xmlstarlet sel -t -m '//game[@romname="roundup"]/miscDetails' -v "text()" control.xml
If you want to get the how many buttons player1 has :
xmlstarlet sel -t -m '//game[@romname="roundup"]/player[@number="1"]' -v "@numButtons" -n control.xml
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.