Skip to content

Commit

Permalink
Issue #566 - fix filter info update when display changes
Browse files Browse the repository at this point in the history
- When navigating displays that have the same layout, the filter information
  between each display was not being updated correctly
- We now reload the filter array in squirrel whenever the display changes
  • Loading branch information
mickelson committed Sep 22, 2019
1 parent fd55246 commit 7dc5c88
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/fe_present.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1086,9 +1086,9 @@ void FePresent::load_layout( bool initial_load )
update_to_new_list( FromToNoValue, true );
}

void FePresent::update_to_new_list( int var, bool new_layout )
void FePresent::update_to_new_list( int var, bool reset_display )
{
update( true, new_layout );
update( true, reset_display );
on_transition( ToNewList, var );
}

Expand Down Expand Up @@ -1289,7 +1289,7 @@ void FePresent::set_transforms()

float adjust_x = std::fabs( m_layoutSize.y * m_layoutScale.x - m_mon[0].size.x ) / 2;
float adjust_y = std::fabs( m_layoutSize.x * m_layoutScale.y - m_mon[0].size.y ) / 2;

if ( actualRotation == FeSettings::RotateRight )
{
m_transform.translate( m_mon[0].size.x - adjust_x, adjust_y );
Expand Down
2 changes: 1 addition & 1 deletion src/fe_present.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class FePresent
void load_screensaver();
void load_layout( bool initial_load=false );

void update_to_new_list( int var=0, bool new_layout=false );
virtual void update_to_new_list( int var=0, bool reset_display=false ); // NOTE virtual function!
void on_end_navigation();
void redraw_surfaces();

Expand Down
39 changes: 28 additions & 11 deletions src/fe_vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,31 @@ void FeVM::vm_init()
Sqrat::DefaultVM::Set( vm );
}

void FeVM::update_to_new_list( int var, bool reset_display )
{
if ( reset_display )
{
//
// Populate script arrays that may change from display to display (currently just fe.filters)
//
Sqrat::Table fe( Sqrat::RootTable().GetSlot( _SC("fe") ) );

Sqrat::Table ftab; // hack Table to Array because creating the Array straight up doesn't work
fe.Bind( _SC("filters"), ftab );
Sqrat::Array farray( ftab.GetObject() );

farray.Resize( 0 );

FeDisplayInfo *di = m_feSettings->get_display( m_feSettings->get_current_display_index() );
if ( di )
{
for ( int i=0; i < di->get_filter_count(); i++ )
farray.SetInstance( farray.GetSize(), di->get_filter( i ) );
}
}

FePresent::update_to_new_list( var, reset_display );
}

bool FeVM::on_new_layout()
{
Expand Down Expand Up @@ -938,20 +963,12 @@ bool FeVM::on_new_layout()
m_feSettings->get_display( i ) );

//
// fe.filters
// Note the fe.filters array gets populated in call to FeVM::update_to_new_list(), since it
// gets reset even when the layout itself isn't necessarily reloaded (i.e. when navigating between
// displays that use the same layout)
//
FeDisplayInfo *di = m_feSettings->get_display( m_feSettings->get_current_display_index() );


Table ftab; // hack Table to Array because creating the Array straight up doesn't work
fe.Bind( _SC("filters"), ftab );
Array farray( ftab.GetObject() );

if ( di )
{
for ( int i=0; i < di->get_filter_count(); i++ )
farray.SetInstance( farray.GetSize(), di->get_filter( i ) );
}

//
// fe.monitors
Expand Down
2 changes: 2 additions & 0 deletions src/fe_vm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ class FeVM : public FePresent
bool poll_command( FeInputMap::Command &c, sf::Event &ev, bool &from_ui );
void clear(); // override of base class clear()

void update_to_new_list( int var=0, bool reset_display=false ); // NOTE: override virtual function from FePresent

// runs .attract/emulators/template/setup.nut to generate default emulator
// configs and detect emulators. Prompts user to automaticallly import emulators
//
Expand Down

2 comments on commit 7dc5c88

@oomek
Copy link
Collaborator

@oomek oomek commented on 7dc5c88 Nov 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit caused fe.filters.len() returning 0 when called inside the main layout body

@oomek
Copy link
Collaborator

@oomek oomek commented on 7dc5c88 Nov 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The filters array is not even populated before Transition.StartLayout, The first transition that has the filter array non 0 is Transition.ToNewList

Please sign in to comment.