From 7dc5c88ca15d756f53ff28e427f8b6be019a1db7 Mon Sep 17 00:00:00 2001 From: Andrew Mickelson Date: Sun, 22 Sep 2019 12:18:05 -0700 Subject: [PATCH] Issue #566 - fix filter info update when display changes - 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 --- src/fe_present.cpp | 6 +++--- src/fe_present.hpp | 2 +- src/fe_vm.cpp | 39 ++++++++++++++++++++++++++++----------- src/fe_vm.hpp | 2 ++ 4 files changed, 34 insertions(+), 15 deletions(-) diff --git a/src/fe_present.cpp b/src/fe_present.cpp index c2dcd19a7..cfd346e81 100644 --- a/src/fe_present.cpp +++ b/src/fe_present.cpp @@ -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 ); } @@ -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 ); diff --git a/src/fe_present.hpp b/src/fe_present.hpp index d1b24c55d..e27f186d3 100644 --- a/src/fe_present.hpp +++ b/src/fe_present.hpp @@ -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(); diff --git a/src/fe_vm.cpp b/src/fe_vm.cpp index 2bd1f04d1..085627a99 100644 --- a/src/fe_vm.cpp +++ b/src/fe_vm.cpp @@ -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() { @@ -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 diff --git a/src/fe_vm.hpp b/src/fe_vm.hpp index cb1a43ee6..25890b547 100644 --- a/src/fe_vm.hpp +++ b/src/fe_vm.hpp @@ -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 //