mirror of
https://github.com/holub/mame
synced 2025-07-02 00:29:37 +03:00
Allow layouts to specify screen tags rather than indices - makes order of instantiation irrelevant in Model 1 etc.
This commit is contained in:
parent
dfb09f2c17
commit
82c6d7dbc5
@ -92,6 +92,7 @@ class XmlError(Exception):
|
|||||||
|
|
||||||
|
|
||||||
class LayoutChecker(Minifyer):
|
class LayoutChecker(Minifyer):
|
||||||
|
BADTAGPATTERN = re.compile('[^abcdefghijklmnopqrstuvwxyz0123456789_.:^$]')
|
||||||
VARPATTERN = re.compile('^~scr(0|[1-9][0-9]*)(native[xy]aspect|width|height)~$')
|
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'))
|
SHAPES = frozenset(('disk', 'led14seg', 'led14segsc', 'led16seg', 'led16segsc', 'led7seg', 'led8seg_gts1', 'rect'))
|
||||||
OBJECTS = frozenset(('backdrop', 'bezel', 'cpanel', 'marquee', 'overlay'))
|
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'], ))
|
self.handleError('Element screen attribute index "%s" is negative' % (attrs['index'], ))
|
||||||
except:
|
except:
|
||||||
self.handleError('Element screen attribute index "%s" is not an integer' % (attrs['index'], ))
|
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.in_object = True
|
||||||
self.have_bounds.append(False)
|
self.have_bounds.append(False)
|
||||||
elif 'group' == name:
|
elif 'group' == name:
|
||||||
|
@ -2676,7 +2676,10 @@ layout_view::item::item(
|
|||||||
// sanity checks
|
// sanity checks
|
||||||
if (strcmp(itemnode.get_name(), "screen") == 0)
|
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));
|
throw layout_reference_error(util::string_format("invalid screen index %d", index));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -18,10 +18,10 @@
|
|||||||
</element>
|
</element>
|
||||||
|
|
||||||
<view name="Default">
|
<view name="Default">
|
||||||
<screen index="0">
|
<screen tag="ioboard:screen">
|
||||||
<bounds left="0" top="0" right="1" bottom="1" />
|
<bounds left="0" top="0" right="1" bottom="1" />
|
||||||
</screen>
|
</screen>
|
||||||
<screen index="1">
|
<screen tag="screen">
|
||||||
<bounds left="0" top="0" right="4" bottom="3" />
|
<bounds left="0" top="0" right="4" bottom="3" />
|
||||||
</screen>
|
</screen>
|
||||||
</view>
|
</view>
|
||||||
@ -30,10 +30,10 @@
|
|||||||
<backdrop element="background">
|
<backdrop element="background">
|
||||||
<bounds x="0" y="0" width="496" height="419" />
|
<bounds x="0" y="0" width="496" height="419" />
|
||||||
</backdrop>
|
</backdrop>
|
||||||
<screen index="1">
|
<screen tag="screen">
|
||||||
<bounds left="0" top="0" right="496" bottom="384" />
|
<bounds left="0" top="0" right="496" bottom="384" />
|
||||||
</screen>
|
</screen>
|
||||||
<screen index="0">
|
<screen tag="ioboard:screen">
|
||||||
<bounds left="8" top="392" right="129" bottom="411" />
|
<bounds left="8" top="392" right="129" bottom="411" />
|
||||||
</screen>
|
</screen>
|
||||||
<cpanel name="led_comm_err" element="led_red">
|
<cpanel name="led_comm_err" element="led_red">
|
||||||
|
@ -1,70 +1,70 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<mamelayout version="2">
|
<mamelayout version="2">
|
||||||
<view name="Main Screen Standard (4:3)">
|
<view name="Main Screen Standard (4:3)">
|
||||||
<screen index="0">
|
<screen tag="screen">
|
||||||
<bounds left="0" top="0" right="4" bottom="3" />
|
<bounds left="0" top="0" right="4" bottom="3" />
|
||||||
</screen>
|
</screen>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view name="LCD0 Standard (15:3)">
|
<view name="LCD0 Standard (15:3)">
|
||||||
<screen index="1">
|
<screen tag="lcd0">
|
||||||
<bounds left="0" top="0" right="15" bottom="3" />
|
<bounds left="0" top="0" right="15" bottom="3" />
|
||||||
</screen>
|
</screen>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view name="LCD1 Standard (15:3)">
|
<view name="LCD1 Standard (15:3)">
|
||||||
<screen index="2">
|
<screen tag="lcd1">
|
||||||
<bounds left="0" top="0" right="15" bottom="3" />
|
<bounds left="0" top="0" right="15" bottom="3" />
|
||||||
</screen>
|
</screen>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view name="Main Screen Pixel Aspect (~scr0nativexaspect~:~scr0nativeyaspect~)">
|
<view name="Main Screen Pixel Aspect (~scr0nativexaspect~:~scr0nativeyaspect~)">
|
||||||
<screen index="0">
|
<screen tag="screen">
|
||||||
<bounds left="0" top="0" right="~scr0width~" bottom="~scr0height~" />
|
<bounds left="0" top="0" right="~scr0width~" bottom="~scr0height~" />
|
||||||
</screen>
|
</screen>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view name="LCD0 Pixel Aspect (~scr1nativexaspect~:~scr1nativeyaspect~)">
|
<view name="LCD0 Pixel Aspect (~scr1nativexaspect~:~scr1nativeyaspect~)">
|
||||||
<screen index="1">
|
<screen tag="lcd0">
|
||||||
<bounds left="0" top="0" right="~scr1width~" bottom="~scr1height~" />
|
<bounds left="0" top="0" right="~scr1width~" bottom="~scr1height~" />
|
||||||
</screen>
|
</screen>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view name="LCD1 Pixel Aspect (~scr2nativexaspect~:~scr2nativeyaspect~)">
|
<view name="LCD1 Pixel Aspect (~scr2nativexaspect~:~scr2nativeyaspect~)">
|
||||||
<screen index="2">
|
<screen tag="lcd1">
|
||||||
<bounds left="0" top="0" right="~scr2width~" bottom="~scr2height~" />
|
<bounds left="0" top="0" right="~scr2width~" bottom="~scr2height~" />
|
||||||
</screen>
|
</screen>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view name="Triple">
|
<view name="Triple">
|
||||||
<screen index="0">
|
<screen tag="screen">
|
||||||
<bounds x="0" y="3" width="15" height="11.25" />
|
<bounds x="0" y="3" width="15" height="11.25" />
|
||||||
</screen>
|
</screen>
|
||||||
<screen index="1">
|
<screen tag="lcd0">
|
||||||
<bounds x="0" y="14.25" width="15" height="3" />
|
<bounds x="0" y="14.25" width="15" height="3" />
|
||||||
<orientation rotate="180" />
|
<orientation rotate="180" />
|
||||||
</screen>
|
</screen>
|
||||||
<screen index="2">
|
<screen tag="lcd1">
|
||||||
<bounds x="0" y="0" width="15" height="3" />
|
<bounds x="0" y="0" width="15" height="3" />
|
||||||
</screen>
|
</screen>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view name="Player 1">
|
<view name="Player 1">
|
||||||
<screen index="0">
|
<screen tag="screen">
|
||||||
<bounds x="0" y="3" width="15" height="11.25" />
|
<bounds x="0" y="3" width="15" height="11.25" />
|
||||||
</screen>
|
</screen>
|
||||||
<screen index="1">
|
<screen tag="lcd0">
|
||||||
<bounds x="0" y="14.25" width="15" height="3" />
|
<bounds x="0" y="14.25" width="15" height="3" />
|
||||||
<orientation rotate="180" />
|
<orientation rotate="180" />
|
||||||
</screen>
|
</screen>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view name="Player 2">
|
<view name="Player 2">
|
||||||
<screen index="0">
|
<screen tag="screen">
|
||||||
<bounds x="0" y="3" width="15" height="11.25" />
|
<bounds x="0" y="3" width="15" height="11.25" />
|
||||||
<orientation rotate="180" />
|
<orientation rotate="180" />
|
||||||
</screen>
|
</screen>
|
||||||
<screen index="2">
|
<screen tag="lcd1">
|
||||||
<bounds x="0" y="14.25" width="15" height="3" />
|
<bounds x="0" y="14.25" width="15" height="3" />
|
||||||
<orientation rotate="180" />
|
<orientation rotate="180" />
|
||||||
</screen>
|
</screen>
|
||||||
|
Loading…
Reference in New Issue
Block a user