Skip to content

Commit

Permalink
Async Loader WIP
Browse files Browse the repository at this point in the history
- Decouple m_current_display and m_current_search_index
- Add m_current_display_index instead
- Move ShowDisplaysMenu handling from main.cpp to fe_settings.cpp
  • Loading branch information
oomek committed Feb 24, 2024
1 parent 0260e23 commit 66723d6
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 20 deletions.
5 changes: 2 additions & 3 deletions src/fe_present.cpp
Expand Up @@ -1061,7 +1061,7 @@ void FePresent::process_transitions_v3()
break;

case EndNavigation:
on_end_navigation(); //replace with
on_end_navigation(); //TODO: replace with
// updates from on_end_navigation()
// on_transition( EndNavigation, 0 );
m_transition_queue.pop_front();
Expand Down Expand Up @@ -1302,7 +1302,6 @@ void FePresent::load_screensaver()
update( true, true );
}

// suppress_transition usage eliminated
void FePresent::load_layout( bool initial_load )
{
m_layout_loaded = false;
Expand Down Expand Up @@ -1357,7 +1356,7 @@ void FePresent::update_to_new_list( int var, bool reset_display )
on_transition( ToNewList, var );
}

// Only called wnen menu is up
// Only called when Configure Menu is up
bool FePresent::tick()
{
bool ret_val = false;
Expand Down
29 changes: 20 additions & 9 deletions src/fe_settings.cpp
Expand Up @@ -274,6 +274,7 @@ FeSettings::FeSettings( const std::string &config_path )
m_joy_thresh( 75 ),
m_mouse_thresh( 10 ),
m_current_search_index( 0 ),
m_current_display_index( 0 ),
m_displays_menu_exit( true ),
m_hide_brackets( false ),
m_group_clones( false ),
Expand Down Expand Up @@ -386,6 +387,11 @@ void FeSettings::load()
FeRomListSorter::init_title_rex( rex_str );

load_state();

m_current_display_index = m_current_display;
if ( get_startup_mode() == ShowDisplaysMenu )
m_current_display = -1;

init_display();

// Make sure we have some keyboard mappings
Expand Down Expand Up @@ -712,7 +718,7 @@ void FeSettings::save_state()
display_idx = m_display_stack.front();

if ( display_idx < 0 )
display_idx = m_current_search_index;
display_idx = m_current_display_index;

m_rl.save_state();

Expand Down Expand Up @@ -946,7 +952,7 @@ int FeSettings::get_rom_index( int filter_index, int offset ) const
int retval, rl_size;
if ( m_current_display < 0 )
{
retval = m_current_search_index;
retval = m_current_display_index;
rl_size = m_rl.filter_size( filter_index );
}
else if ( !m_current_search.empty()
Expand Down Expand Up @@ -1433,10 +1439,10 @@ int FeSettings::display_menu_get_current_selection_as_absolute_display_index()
{
ASSERT( m_current_display < 0 );

if (( m_current_search_index < 0 ) || ( m_current_search_index >= (int)m_display_menu.size() ))
if (( m_current_display_index < 0 ) || ( m_current_display_index >= (int)m_display_menu.size() ))
return -1;

return m_display_menu[ m_current_search_index ];
return m_display_menu[ m_current_display_index ];
}

bool FeSettings::set_display( int index, bool stack_previous )
Expand All @@ -1456,16 +1462,19 @@ bool FeSettings::set_display( int index, bool stack_previous )
m_display_stack.pop_back();
}
else
index = m_current_display;
index = m_current_display_index;
}
else if (( m_current_display != index ) && ( m_current_display >= 0 ))
{
m_current_display_index = m_current_display;
m_display_stack.push_back( m_current_display );
}

}
else
{
if ( index < 0 )
m_current_search_index = find_idx_in_vec( m_current_display, m_display_menu );
m_current_display_index = find_idx_in_vec( m_current_display, m_display_menu );

// If not stacking, clear the existing back stack (if any)
m_display_stack.clear();
Expand Down Expand Up @@ -1571,9 +1580,11 @@ void FeSettings::set_current_selection( int filter_index, int rom_index )
{
// handle situation where we are currently showing a search result or clone group
//
if (( m_current_display < 0 )
|| ( !m_current_search.empty()
&& ( get_current_filter_index() == filter_index )))
if ( m_current_display < 0 )
{
m_current_display_index = rom_index;
}
else if (( !m_current_search.empty() && ( get_current_filter_index() == filter_index )))
{
m_current_search_index = rom_index;
}
Expand Down
2 changes: 2 additions & 0 deletions src/fe_settings.hpp
Expand Up @@ -216,6 +216,7 @@ class FeSettings : public FeBaseConfigurable
int m_joy_thresh; // [1..100], 100=least sensitive
int m_mouse_thresh; // [1..100], 100=least sensitive
int m_current_search_index; // used when custom searching *AND* when showing 'Displays Menu' w/ custom layout
int m_current_display_index;
bool m_displays_menu_exit;
bool m_hide_brackets;
bool m_group_clones;
Expand Down Expand Up @@ -582,6 +583,7 @@ class FeSettings : public FeBaseConfigurable
std::vector<int> &indices,
int &current_idx ) const;

// Used only when Edit Game is pressed in Displays Menu
int display_menu_get_current_selection_as_absolute_display_index();

FeDisplayInfo *get_display( int index );
Expand Down
10 changes: 2 additions & 8 deletions src/main.cpp
Expand Up @@ -198,10 +198,7 @@ int main(int argc, char *argv[])
break;

case FeSettings::ShowDisplaysMenu:
// we do a double load of the layout on startup if there is custom display menu
// so we suppress the extra transition signals that get triggered here
feSettings.set_display(-1);
FeVM::cb_signal( "displays_menu" );
// TODO: check if this switch statement is still necessary
break;

default:
Expand Down Expand Up @@ -561,10 +558,7 @@ int main(int argc, char *argv[])
break;

case FeSettings::ShowDisplaysMenu:
// we do a double load of the layout on startup if there is custom display menu
// so we suppress the extra transition signals that get triggered here
if ( feSettings.get_current_display_index() != -1 )
feSettings.set_display(-1);
// TODO: check if this switch statement is still necessary
feVM.load_layout( true );
break;

Expand Down

0 comments on commit 66723d6

Please sign in to comment.