Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/mickelson/attract
Browse files Browse the repository at this point in the history
  • Loading branch information
mickelson committed Jul 12, 2018
2 parents 2ce5d1e + e53655f commit 04ed226
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 47 deletions.
15 changes: 9 additions & 6 deletions Layouts.md
Original file line number Diff line number Diff line change
Expand Up @@ -1466,6 +1466,9 @@ Properties:
`Transition.EndNavigation`. Default value is `Transition.ToNewSelection`.
* `smooth` - Get/set whether the image is to be smoothed. Default value can
be configured in attract.cfg
* `zorder` - Get/set the Image's order in the applicable draw list. Objects
with a lower zorder are drawn first, so that when objects overlap, the one
with the higher zorder is drawn on top. Default value is 0.
* `blend_mode` - Get/set the blend mode for this image. Can have one of the
following values:
- `BlendMode.Alpha`
Expand All @@ -1480,8 +1483,6 @@ Properties:
The default value is `false`. It's advised to force anisotropic filtering in
the display driver settings if the Image with auto generated mipmap is scaled
by the ratio that is not isotropic.
* `zorder` - Get/set the Image's order in the applicable draw list. When
objects overlap, the one with the higher zorder will be drawn on top.

Member Functions:

Expand Down Expand Up @@ -1657,8 +1658,9 @@ Properties:
Default value is `-1` which calcualtes the margin based on the .char_size.
* `shader` - Get/set the GLSL shader for this text. This can only be set to
an instance of the class `fe.Shader` (see: `fe.add_shader()`).
* `zorder` - Get/set the Text's order in the applicable draw list. When
objects overlap, the one with the higher zorder will be drawn on top.
* `zorder` - Get/set the Text's order in the applicable draw list. Objects
with a lower zorder are drawn first, so that when objects overlap, the one
with the higher zorder is drawn on top. Default value is 0.

Member Functions:

Expand Down Expand Up @@ -1762,8 +1764,9 @@ Properties:
behaviour as if set to "[Title]"). Default is an empty value.
* `shader` - Get/set the GLSL shader for this listbox. This can only be set
to an instance of the class `fe.Shader` (see: `fe.add_shader()`).
* `zorder` - Get/set the Listbox's order in the applicable draw list. When
objects overlap, the one with the higher zorder will be drawn on top.
* `zorder` - Get/set the Listbox's order in the applicable draw list. Objects
with a lower zorder are drawn first, so that when objects overlap, the one
with the higher zorder is drawn on top. Default value is 0.

Member Functions:

Expand Down
44 changes: 24 additions & 20 deletions config/loader/hyperspin.nut
Original file line number Diff line number Diff line change
Expand Up @@ -118,54 +118,65 @@ for ( local i=0; i< fe.displays.len(); i++ )
//
// - background
// - art1
// - (video_overlay if overlaybelow=true)
// - video
// - video_overlay
// - (art1 if below=true)
// - art2
// - art3
// - art4
// - (wheel)
// - (prompts)
// - override transitions
//
::hs_ent.background <- {
dir = "Images/Backgrounds/"
obj = fe.add_image( "" )
zorder = 0
zorder = -10
};

::hs_ent.artwork1 <- {
dir = "Images/Artwork1/"
obj = fe.add_image( "" )
zorder = 1
zorder = -9
};

// zorder -8 - hs_ent.video_overlay zorder goes here if overlaybelow=true

::hs_ent.video <- {
dir = "Video/"
obj = fe.add_image( "" )
zorder = 2
zorder = -7
};

::hs_ent.video_overlay <- {
dir = ""
obj = fe.add_image( "" )
zorder = 3
zorder = -6
};

// zorder -5 - hs_ent.artwork1 zorder goes here if below=true

::hs_ent.artwork2 <- {
dir = "Images/Artwork2/"
obj = fe.add_image( "" )
zorder = 4
zorder = -4
};

::hs_ent.artwork3 <- {
dir = "Images/Artwork3/"
obj = fe.add_image( "" )
zorder = 5
zorder = -3
};

::hs_ent.artwork4 <- {
dir = "Images/Artwork4/"
obj = fe.add_image( "" )
zorder = 6
zorder = -2
};

// wheel and prompts zorder is at 0

::hs_ent.override_transition <- {
dir = "Video/Override Transitions/"
obj = fe.add_image( "", 0, 0, fe.layout.width, fe.layout.height )
Expand Down Expand Up @@ -519,7 +530,7 @@ function load( ttype, match_map, hs_sys_dir )
local d=0.0;
local type = "";
local start = "";
local vid_below=false;
local overlay_below=false;
local overlayoffsetx = 0;
local overlayoffsety = 0;

Expand All @@ -544,7 +555,7 @@ function load( ttype, match_map, hs_sys_dir )
break;
case "overlaybelow":
if ( v == "true" )
vid_below = true;
overlay_below = true;
break;
case "forceaspect":
if (( c.tag == "video" ) && ( v == "both" ))
Expand Down Expand Up @@ -601,8 +612,8 @@ function load( ttype, match_map, hs_sys_dir )
obj2.height = obj2.texture_height;
obj2.rotation = obj.rotation;

if ( vid_below )
obj2.zorder = obj.zorder-1;
if ( overlay_below )
obj2.zorder = ::hs_ent["video"].zorder-1;
}

if ( r != 0 )
Expand Down Expand Up @@ -776,15 +787,8 @@ function load( ttype, match_map, hs_sys_dir )

//below seems to swap zorder of video + overlay with artwork 1
//
if ( below )
{
if ( found_tags["artwork1"] )
// we only need to update artwork1 zorder to "3" zorder of
// the artworks with lower zorder seem to change
// automatically, verified with print statements
//
::hs_ent["artwork1"].obj.zorder = 3;
}
if ( below && found_tags["artwork1"] )
::hs_ent["artwork1"].obj.zorder = ::hs_ent["video_overlay"].zorder + 1;

return call_into_transition;
}
Expand Down
36 changes: 15 additions & 21 deletions src/fe_presentable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
FeBasePresentable::FeBasePresentable( FePresentableParent &p )
: m_parent( p ),
m_shader( NULL ),
m_visible( true )
m_visible( true ),
m_zorder( 0 )
{
}

Expand Down Expand Up @@ -192,33 +193,26 @@ void FeBasePresentable::script_set_shader( FeShader *sh )

int FeBasePresentable::get_zorder()
{
for ( size_t i=0; i< m_parent.elements.size(); i++ )
return m_zorder;
}

namespace
{
bool zcompare( FeBasePresentable *one, FeBasePresentable *two )
{
if ( this == m_parent.elements[i] )
return i;
return ( one->get_zorder() < two->get_zorder() );
}

return -1;
}
};

void FeBasePresentable::set_zorder( int pos )
{
if ( pos >= (int)m_parent.elements.size() )
pos = m_parent.elements.size()-1;
if ( pos < 0 )
pos = 0;
if ( pos == m_zorder )
return;

int old = get_zorder();
if (( old >= 0 ) && ( old != pos ))
{
FeBasePresentable *temp = m_parent.elements[old];
m_parent.elements.erase( m_parent.elements.begin() + old );

m_parent.elements.insert( m_parent.elements.begin() + pos,
temp );
m_zorder = pos;

FePresent::script_flag_redraw();
}
std::stable_sort( m_parent.elements.begin(), m_parent.elements.end(), zcompare );
FePresent::script_flag_redraw();
}

FeImage *FePresentableParent::add_image(const char *n, int x, int y, int w, int h)
Expand Down
1 change: 1 addition & 0 deletions src/fe_presentable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class FeBasePresentable
FePresentableParent &m_parent;
FeShader *m_shader;
bool m_visible;
int m_zorder;

public:
FeBasePresentable( FePresentableParent &p );
Expand Down

0 comments on commit 04ed226

Please sign in to comment.