Skip to content

Commit

Permalink
Finished adding new mechanism for allowing parts of views to be hidden.
Browse files Browse the repository at this point in the history
Changed name of element to "collection" and initial visibility attribute
to "visible", and added them to documentation.  Also added them to
complay.py.

Fixed issue with collection inside group, and improved initial view
selection behaviour.

Updated some internal layouts to demonstrate new features, including
et3400, irrmaze, ltcasino, mekd3/mekd4, seawolf and vgmplay.

Removed all uses of cpanel, marquee and overlay from internal layouts
and removed them from complay.py to actively discourage use.  Also
cleaned up view names in layouts that were using them in place of
spaces, and removed some superfluous name attributes on elements that
won't do anything useful with an output value anyway.

Made vgmplay cycle visualiser modes when visualiser screen is clicked.

Fixed a copy/paste error in bus/rs232/hlemouse.cpp while I'm at it.
  • Loading branch information
cuavas committed Sep 6, 2020
1 parent 7fe5f18 commit 67ec5e5
Show file tree
Hide file tree
Showing 85 changed files with 1,557 additions and 1,436 deletions.
9 changes: 5 additions & 4 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys, os
import os.path
import sys

sys.path.insert(0, os.path.abspath('_ext'))
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), '_ext'))

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand All @@ -31,8 +32,8 @@
'sphinx.ext.autodoc',
'sphinx.ext.mathjax',
'sphinx.ext.viewcode',
'edit_on_github',
'sphinxcontrib.rsvgconverter'
'sphinxcontrib.rsvgconverter',
'edit_on_github'
]

edit_on_github_project = 'mamedev/mame'
Expand Down
45 changes: 45 additions & 0 deletions docs/source/techspecs/layout_files.rst
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,11 @@ screen
zero (0). If present, the ``tag`` attribute must be the tag path to the
screen relative to the device that causes the layout to be loaded. Screens
are drawn in the order they appear in the layout file, from front to back.
collection
Adds screens and/or items in a collection that can be shown or hidden by the
user (see :ref:`layout-parts-collections`). The name of the collection is
specified using the required ``name`` attribute.. There is a limit of 32
collections per view.
group
Adds the content of the group to the view (see :ref:`layout-parts-groups`).
The name of the group to add is specified using the required ``ref``
Expand Down Expand Up @@ -723,6 +728,46 @@ and only activates the frontmost element whose area includes the location of the
mouse pointer.


.. _layout-parts-collections:

Collections
~~~~~~~~~~~

Collections of screens and/or layout elements can be shown or hidden by the user
as desired. For example, a single view could include both displays and a
clickable keypad, and allow the user to hide the keypad leaving only the
displays visible. Collections are created using ``collection`` elements inside
``view``, ``group`` and other ``collection`` elements.

A collection element must have a ``name`` attribute providing the display name
for the collection. Collection names should be unique within a view. The
initial visibility of a collection may be specified by providing a ``visible``
attribute. Set the ``visible`` attribute to ``yes`` if the collection should be
initially visible, or ``no`` if it should be initially hidden. Collections are
initially visible by default.

Here is an example demonstrating the use of collections to allow parts of a view
to be hidden by the user::

<view name="LED Displays, CRT and Keypad">
<collection name="LED Displays">
<group ref="displays"><bounds x="240" y="0" width="320" height="47" /></group>
</collection>
<collection name="Keypad">
<group ref="keypad"><bounds x="650" y="57" width="148" height="140" /></group>
</collection>
<screen tag="screen"><bounds x="0" y="57" width="640" height="480" /></screen>
</view>


A collection creates a nested parameter scope. Any ``param`` elements inside
the collection element set parameters in the local scope for the collection.
See :ref:`layout-concepts-params` for more detail on parameters. (Note that the
collection’s name and default visibility are not part of its content, and any
parameter references in the ``name`` and ``visible`` attributes themselves will
be substituted using parameter values from the collection’s parent’s scope.)


.. _layout-parts-groups:

Reusable groups
Expand Down
31 changes: 28 additions & 3 deletions scripts/build/complay.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class LayoutChecker(Minifyer):
VARPATTERN = re.compile('^.*~[0-9A-Za-z_]+~.*$')
FLOATCHARS = re.compile('^.*[.eE].*$')
SHAPES = frozenset(('disk', 'dotmatrix', 'dotmatrix5dot', 'dotmatrixdot', 'led14seg', 'led14segsc', 'led16seg', 'led16segsc', 'led7seg', 'led8seg_gts1', 'rect'))
OBJECTS = frozenset(('backdrop', 'bezel', 'cpanel', 'marquee', 'overlay'))
OBJECTS = frozenset(('backdrop', 'bezel'))
ORIENTATIONS = frozenset((0, 90, 180, 270))
YESNO = frozenset(('yes', 'no'))
BLENDMODES = frozenset(('none', 'alpha', 'multiply', 'add'))
Expand Down Expand Up @@ -471,7 +471,11 @@ def groupViewStartHandler(self, name, attrs):
inputmask = self.checkIntAttribute(name, attrs, 'inputmask', None)
if (inputmask is not None) and (0 == inputmask):
if (inputraw is None) or (0 == inputraw):
self.handleError('Element %s has attribute inputmask "%s" is zero' % (name, attrs['inputmask']))
self.handleError('Element %s attribute inputmask "%s" is zero' % (name, attrs['inputmask']))
if ('element' != name) and not self.has_legacy_object:
self.has_legacy_object = True
if self.has_collection:
self.handleError('Layout contains collection as well as legacy backdrop/bezel elements')
self.handlers.append((self.objectStartHandler, self.objectEndHandler))
self.have_bounds.append(False)
self.have_orientation.append(False)
Expand Down Expand Up @@ -507,21 +511,36 @@ def groupViewStartHandler(self, name, attrs):
self.handleError('Element repeat attribute count "%s" is negative' % (attrs['count'], ))
self.variable_scopes.append({ })
self.repeat_depth[-1] += 1
elif 'collection' == name:
if 'name' not in attrs:
self.handleError('Element collection missing attribute name')
if attrs.get('visible', 'yes') not in self.YESNO:
self.handleError('Element collection attribute visible "%s" is not "yes" or "no"' % (attrs['visible'], ))
if not self.has_collection:
self.has_collection = True
if self.has_legacy_object:
self.handleError('Layout contains collection as well as legacy backdrop/bezel elements')
self.variable_scopes.append({ })
self.collection_depth += 1
elif 'param' == name:
self.checkParameter(attrs)
self.ignored_depth = 1
elif 'bounds' == name:
self.checkBounds(attrs)
if self.repeat_depth[-1]:
self.handleError('Element bounds inside repeat')
elif self.collection_depth:
self.handleError('Element bounds inside collection')
self.ignored_depth = 1
else:
self.handleError('Encountered unexpected element %s' % (name, ))
self.ignored_depth = 1

def groupViewEndHandler(self, name):
self.variable_scopes.pop()
if self.repeat_depth[-1]:
if 'collection' == name:
self.collection_depth -= 1
elif self.repeat_depth[-1]:
self.repeat_depth[-1] -= 1
else:
self.repeat_depth.pop()
Expand Down Expand Up @@ -549,6 +568,9 @@ def startDocument(self):
self.ignored_depth = 0
self.variable_scopes = [ ]
self.repeat_depth = [ ]
self.collection_depth = 0
self.has_collection = False
self.has_legacy_object = False
self.have_bounds = [ ]
self.have_orientation = [ ]
self.have_color = [ ]
Expand All @@ -567,6 +589,9 @@ def endDocument(self):
del self.ignored_depth
del self.variable_scopes
del self.repeat_depth
del self.collection_depth
del self.has_collection
del self.has_legacy_object
del self.have_bounds
del self.have_orientation
del self.have_color
Expand Down
2 changes: 1 addition & 1 deletion src/devices/bus/rs232/hlemouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ WRITE_LINE_MEMBER(hle_msmouse_device_base::input_dtr)

WRITE_LINE_MEMBER(hle_msmouse_device_base::input_rts)
{
m_dtr = state ? 1U : 0U;
m_rts = state ? 1U : 0U;
check_enable();
}

Expand Down
49 changes: 21 additions & 28 deletions src/emu/render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@ unsigned render_target::configured_view(const char *viewname, int targetindex, i
if (strcmp(viewname, "auto") != 0)
{
// scan for a matching view name
size_t viewlen = strlen(viewname);
size_t const viewlen = strlen(viewname);
for (unsigned i = 0; !view && (m_views.size() > i); ++i)
if (!core_strnicmp(m_views[i].first.get().name().c_str(), viewname, viewlen))
view = &m_views[i].first.get();
Expand All @@ -1082,21 +1082,22 @@ unsigned render_target::configured_view(const char *viewname, int targetindex, i
// if we have enough targets to be one per screen, assign in order
if (numtargets >= screens.size())
{
int const ourindex = index() % screens.size();
screen_device &screen = screens[ourindex];

// find the first view with this screen and this screen only
unsigned viewindex;
for (view = view_by_index(viewindex = 0); view != nullptr; view = view_by_index(++viewindex))
screen_device const &screen = screens[index() % screens.size()];
for (unsigned i = 0; !view && (m_views.size() > i); ++i)
{
auto const &viewscreens = view->screens();
if (viewscreens.empty())
for (screen_device const &viewscreen : m_views[i].first.get().screens())
{
view = nullptr;
break;
if (&viewscreen == &screen)
{
view = &m_views[i].first.get();
}
else
{
view = nullptr;
break;
}
}
else if (std::find_if(viewscreens.begin(), viewscreens.end(), [&screen] (auto const &scr) { return &scr.get() != &screen; }) == viewscreens.end())
break;
}
}

Expand All @@ -1105,18 +1106,10 @@ unsigned render_target::configured_view(const char *viewname, int targetindex, i
{
for (unsigned i = 0; !view && (m_views.size() > i); ++i)
{
view = &m_views[i].first.get();
if (view->screen_count() >= screens.size())
{
for (screen_device &screen : screens)
{
if (!view->has_screen(screen))
{
view = nullptr;
break;
}
}
}
layout_view &curview = m_views[i].first;
if (curview.screen_count() >= screens.size())
if (std::find_if(screens.begin(), screens.end(), [&curview] (screen_device &screen) { return !curview.has_screen(screen); }) == screens.end())
view = &curview;
}
}
}
Expand Down Expand Up @@ -2631,7 +2624,7 @@ void render_target::config_load(util::xml::data_node const &targetnode)
if (m_views.end() == view)
continue;

for (util::xml::data_node const *vistogglenode = viewnode->get_child("vistoggle"); vistogglenode; vistogglenode = vistogglenode->get_next_sibling("vistoggle"))
for (util::xml::data_node const *vistogglenode = viewnode->get_child("collection"); vistogglenode; vistogglenode = vistogglenode->get_next_sibling("collection"))
{
char const *const vistogglename = vistogglenode->get_attribute_string("name", nullptr);
if (!vistogglename)
Expand All @@ -2642,7 +2635,7 @@ void render_target::config_load(util::xml::data_node const &targetnode)
if (vistoggles.end() == vistoggle)
continue;

int const enable = vistogglenode->get_attribute_int("enabled", -1);
int const enable = vistogglenode->get_attribute_int("visible", -1);
if (0 <= enable)
{
if (enable)
Expand Down Expand Up @@ -2716,9 +2709,9 @@ bool render_target::config_save(util::xml::data_node &targetnode)
viewnode = targetnode.add_child("view", nullptr);
viewnode->set_attribute("name", view.first.get().name().c_str());
}
util::xml::data_node *const vistogglenode = viewnode->add_child("vistoggle", nullptr);
util::xml::data_node *const vistogglenode = viewnode->add_child("collection", nullptr);
vistogglenode->set_attribute("name", toggle.name().c_str());
vistogglenode->set_attribute_int("enabled", BIT(view.second, i));
vistogglenode->set_attribute_int("visible", BIT(view.second, i));
changed = true;
}
++i;
Expand Down
1 change: 1 addition & 0 deletions src/emu/render.h
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,7 @@ class layout_group
group_map &groupmap,
std::vector<layout_group const *> &seen,
bool empty,
bool collection,
bool repeat,
bool init);

Expand Down
19 changes: 10 additions & 9 deletions src/emu/rendlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,7 @@ void layout_group::resolve_bounds(environment &env, group_map &groupmap, std::ve
{
set_render_bounds_xy(m_bounds, 0.0F, 0.0F, 1.0F, 1.0F);
environment local(env);
resolve_bounds(local, m_groupnode, groupmap, seen, true, false, true);
resolve_bounds(local, m_groupnode, groupmap, seen, true, false, false, true);
}
seen.pop_back();
}
Expand All @@ -1127,6 +1127,7 @@ void layout_group::resolve_bounds(
group_map &groupmap,
std::vector<layout_group const *> &seen,
bool empty,
bool collection,
bool repeat,
bool init)
{
Expand Down Expand Up @@ -1216,16 +1217,16 @@ void layout_group::resolve_bounds(
environment local(env);
for (int i = 0; !m_bounds_resolved && (count > i); ++i)
{
resolve_bounds(local, *itemnode, groupmap, seen, empty, true, !i);
resolve_bounds(local, *itemnode, groupmap, seen, empty, false, true, !i);
local.increment_parameters();
}
}
else if (!strcmp(itemnode->get_name(), "vistoggle"))
else if (!strcmp(itemnode->get_name(), "collection"))
{
if (!env.get_attribute_string(*itemnode, "name", nullptr))
throw layout_syntax_error("vistoggle must have name attribute");
throw layout_syntax_error("collection must have name attribute");
environment local(env);
resolve_bounds(local, *itemnode, groupmap, seen, empty, false, true);
resolve_bounds(local, *itemnode, groupmap, seen, empty, true, false, true);
}
else
{
Expand All @@ -1241,7 +1242,7 @@ void layout_group::resolve_bounds(
m_bounds_resolved = resolved;
}

if (!repeat)
if (!collection && !repeat)
m_bounds_resolved = true;
}

Expand Down Expand Up @@ -3364,12 +3365,12 @@ void layout_view::add_items(
local.increment_parameters();
}
}
else if (!strcmp(itemnode->get_name(), "vistoggle"))
else if (!strcmp(itemnode->get_name(), "collection"))
{
char const *name(env.get_attribute_string(*itemnode, "name", nullptr));
if (!name)
throw layout_syntax_error("vistoggle must have name attribute");
m_defvismask |= u32(env.get_attribute_bool(*itemnode, "enabled", true) ? 1 : 0) << m_vistoggles.size(); // TODO: make this less hacky
throw layout_syntax_error("collection must have name attribute");
m_defvismask |= u32(env.get_attribute_bool(*itemnode, "visible", true) ? 1 : 0) << m_vistoggles.size(); // TODO: make this less hacky
view_environment local(env, true);
m_vistoggles.emplace_back(name, local.visibility_mask());
add_items(layers, local, *itemnode, elemmap, groupmap, orientation, trans, color, false, false, true);
Expand Down
22 changes: 13 additions & 9 deletions src/mame/drivers/mekd4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,28 +239,32 @@ FS 0 to F
******************************************************************************/

#include "emu.h"

#include "bus/rs232/rs232.h"
#include "cpu/m6809/m6809.h"
#include "machine/input_merger.h"
#include "machine/bankdev.h"
#include "imagedev/cassette.h"
#include "imagedev/snapquik.h"
#include "machine/6821pia.h"
#include "machine/6850acia.h"
#include "machine/mc14411.h"
#include "machine/bankdev.h"
#include "machine/clock.h"
#include "machine/input_merger.h"
#include "machine/mc14411.h"
#include "machine/timer.h"
#include "sound/wave.h"
#include "speaker.h"
#include "bus/rs232/rs232.h"
#include "mekd4.lh"
#include "imagedev/cassette.h"
#include "imagedev/snapquik.h"
#include "video/pwm.h"

// MEK68R2
#include "machine/terminal.h"
#include "video/mc6845.h"

#include "emupal.h"
#include "screen.h"
#include "render.h"
#include "screen.h"
#include "speaker.h"

#include "mekd4.lh"


class mekd4_state : public driver_device
{
Expand Down
2 changes: 0 additions & 2 deletions src/mame/drivers/psikyo4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,8 +617,6 @@ void psikyo4_state::ps4big(machine_config &config)
PALETTE(config, m_palette[0]).set_entries((0x2000/4) + 1); /* palette + clear colour */
PALETTE(config, m_palette[1]).set_entries((0x2000/4) + 1);

config.set_default_layout(layout_dualhsxs);

SCREEN(config, m_lscreen, SCREEN_TYPE_RASTER);
m_lscreen->set_refresh_hz(60);
m_lscreen->set_vblank_time(ATTOSECONDS_IN_USEC(0));
Expand Down
Loading

0 comments on commit 67ec5e5

Please sign in to comment.