mickelson / attract

A graphical front-end for command line emulators that hides the underlying operating system and is intended to be controlled with a joystick or gamepad.
http://attractmode.org
GNU General Public License v3.0
393 stars 115 forks source link

Fixed frame delay on nested surfaces #619

Closed oomek closed 4 years ago

oomek commented 4 years ago

Added surface sorting. This eliminates the delay in surface content update. For each surface nesting level there was one frame delay. This also works for clones.

oomek commented 4 years ago

Here is an example layout showing the problem that my PR is aiming to fix.

local flw = fe.layout.width
local flh = fe.layout.height
local n = 8 // Snaps count
local s = flw / n

local surf = []
local snap = []
local text = []

local background = fe.add_text( "", 0, 0, flw, flh )
background.set_bg_rgb( 0, 100, 150 )

// Snap on Fe
local snap_fe = fe.add_artwork( "snap", 0, 0, s, s )
snap_fe.video_flags = Vid.ImagesOnly
local txt_fe = fe.add_text( "Fe", 0, s, s, s/8 )

// Surface on Fe
surf.push( fe.add_surface( s*n, s+s/8 ))
surf[0].set_pos( s, 0 )
snap.push( surf[0].add_clone( snap_fe ))
snap[0].video_flags = Vid.ImagesOnly
text.push( surf[0].add_text( "Surface 0", 0, s, s, s/8 ))

// Nested Surfaces
for ( local i = 1; i < n; i++ )
{
    surf.push( surf[i-1].add_surface( s*(n-i), s+s/8 ))
    surf[i].set_pos( s, 0 )
    snap.push( surf[i].add_clone( snap_fe ))
    snap[i].video_flags = Vid.ImagesOnly
    text.push( surf[i].add_text( "Surface "+i, 0, s, s, s/8 ))
}