Allow layouts to specify screen tags rather than indices - makes order of instantiation irrelevant in Model 1 etc.

This commit is contained in:
Vas Crabb 2018-07-10 04:26:57 +10:00
parent dfb09f2c17
commit 82c6d7dbc5
4 changed files with 37 additions and 18 deletions

View File

@ -92,6 +92,7 @@ class XmlError(Exception):
class LayoutChecker(Minifyer):
BADTAGPATTERN = re.compile('[^abcdefghijklmnopqrstuvwxyz0123456789_.:^$]')
VARPATTERN = re.compile('^~scr(0|[1-9][0-9]*)(native[xy]aspect|width|height)~$')
SHAPES = frozenset(('disk', 'led14seg', 'led14segsc', 'led16seg', 'led16segsc', 'led7seg', 'led8seg_gts1', 'rect'))
OBJECTS = frozenset(('backdrop', 'bezel', 'cpanel', 'marquee', 'overlay'))
@ -181,6 +182,21 @@ class LayoutChecker(Minifyer):
self.handleError('Element screen attribute index "%s" is negative' % (attrs['index'], ))
except:
self.handleError('Element screen attribute index "%s" is not an integer' % (attrs['index'], ))
if 'tag' in attrs:
self.handleError('Element screen has both index and tag attributes');
if 'tag' in attrs:
tag = attrs['tag']
if '' == tag:
self.handleError('Element screen attribute tag is empty')
else:
if self.BADTAGPATTERN.search(tag):
self.handleError('Element screen attribute tag "%s" contains invalid characters' % (tag, ));
if tag.find('^') >= 0:
self.handleError('Element screen attribute tag "%s" contains parent device reference' % (tag, ));
if ':' == tag[-1]:
self.handleError('Element screen attribute tag "%s" ends with separator' % (tag, ));
if tag.find('::') >= 0:
self.handleError('Element screen attribute tag "%s" contains double separator' % (tag, ));
self.in_object = True
self.have_bounds.append(False)
elif 'group' == name:

View File

@ -2676,7 +2676,10 @@ layout_view::item::item(
// sanity checks
if (strcmp(itemnode.get_name(), "screen") == 0)
{
if (m_screen == nullptr)
char const *const tag(itemnode.get_attribute_string("tag", nullptr));
if (tag)
m_screen = dynamic_cast<screen_device *>(machine.root_device().subdevice(tag));
if (!m_screen)
throw layout_reference_error(util::string_format("invalid screen index %d", index));
}
else

View File

@ -18,10 +18,10 @@
</element>
<view name="Default">
<screen index="0">
<screen tag="ioboard:screen">
<bounds left="0" top="0" right="1" bottom="1" />
</screen>
<screen index="1">
<screen tag="screen">
<bounds left="0" top="0" right="4" bottom="3" />
</screen>
</view>
@ -30,10 +30,10 @@
<backdrop element="background">
<bounds x="0" y="0" width="496" height="419" />
</backdrop>
<screen index="1">
<screen tag="screen">
<bounds left="0" top="0" right="496" bottom="384" />
</screen>
<screen index="0">
<screen tag="ioboard:screen">
<bounds left="8" top="392" right="129" bottom="411" />
</screen>
<cpanel name="led_comm_err" element="led_red">

View File

@ -1,70 +1,70 @@
<?xml version="1.0"?>
<mamelayout version="2">
<view name="Main Screen Standard (4:3)">
<screen index="0">
<screen tag="screen">
<bounds left="0" top="0" right="4" bottom="3" />
</screen>
</view>
<view name="LCD0 Standard (15:3)">
<screen index="1">
<screen tag="lcd0">
<bounds left="0" top="0" right="15" bottom="3" />
</screen>
</view>
<view name="LCD1 Standard (15:3)">
<screen index="2">
<screen tag="lcd1">
<bounds left="0" top="0" right="15" bottom="3" />
</screen>
</view>
<view name="Main Screen Pixel Aspect (~scr0nativexaspect~:~scr0nativeyaspect~)">
<screen index="0">
<screen tag="screen">
<bounds left="0" top="0" right="~scr0width~" bottom="~scr0height~" />
</screen>
</view>
<view name="LCD0 Pixel Aspect (~scr1nativexaspect~:~scr1nativeyaspect~)">
<screen index="1">
<screen tag="lcd0">
<bounds left="0" top="0" right="~scr1width~" bottom="~scr1height~" />
</screen>
</view>
<view name="LCD1 Pixel Aspect (~scr2nativexaspect~:~scr2nativeyaspect~)">
<screen index="2">
<screen tag="lcd1">
<bounds left="0" top="0" right="~scr2width~" bottom="~scr2height~" />
</screen>
</view>
<view name="Triple">
<screen index="0">
<screen tag="screen">
<bounds x="0" y="3" width="15" height="11.25" />
</screen>
<screen index="1">
<screen tag="lcd0">
<bounds x="0" y="14.25" width="15" height="3" />
<orientation rotate="180" />
</screen>
<screen index="2">
<screen tag="lcd1">
<bounds x="0" y="0" width="15" height="3" />
</screen>
</view>
<view name="Player 1">
<screen index="0">
<screen tag="screen">
<bounds x="0" y="3" width="15" height="11.25" />
</screen>
<screen index="1">
<screen tag="lcd0">
<bounds x="0" y="14.25" width="15" height="3" />
<orientation rotate="180" />
</screen>
</view>
<view name="Player 2">
<screen index="0">
<screen tag="screen">
<bounds x="0" y="3" width="15" height="11.25" />
<orientation rotate="180" />
</screen>
<screen index="2">
<screen tag="lcd1">
<bounds x="0" y="14.25" width="15" height="3" />
<orientation rotate="180" />
</screen>