Skip to content

Commit

Permalink
Don't reload the game twice when loading a game from the terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
OFFTKP committed Aug 13, 2024
1 parent ecc7308 commit a7aba8b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6170,7 +6170,10 @@ void se_draw_menu_panel(){
&gui_state.settings.draw_leaderboard_trackers,
&gui_state.settings.draw_challenge_indicators,
};
retro_achievements_draw_settings(checkboxes);
bool login_pressed = retro_achievements_draw_settings(checkboxes);
if(login_pressed){
gui_state.settings.ra_needs_reload = true;
}
#endif
{
se_bios_info_t * info = &gui_state.bios_info;
Expand Down
8 changes: 5 additions & 3 deletions src/retro_achievements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,6 @@ namespace
path += "ra_token.txt";

sb_save_file_data(path.c_str(), (const uint8_t*)data.data(), data.size());
retro_achievements_load_game();
se_emscripten_flush_fs();
ra_state->error_message.store(nullptr);
} else {
Expand Down Expand Up @@ -1083,7 +1082,7 @@ bool retro_achievements_load_game()

const rc_client_user_t* user = rc_client_get_user_info(ra_state->rc_client);
if (!user)
return true; // not logged in or login in progress, in which case the game will be loaded
return false; // not logged in or login in progress, in which case the game will be loaded
// when the login is done

if (ra_state->game_state && ra_state->game_state->outstanding_requests.load() != 0)
Expand Down Expand Up @@ -1234,8 +1233,9 @@ bool retro_achievements_has_game_loaded(){
return rc_client_get_game_info(ra_state->rc_client)!=NULL;
}

void retro_achievements_draw_settings(uint32_t* draw_checkboxes[5])
bool retro_achievements_draw_settings(uint32_t* draw_checkboxes[5])
{
bool login_pressed = false;
int win_w = igGetWindowContentRegionWidth();
const rc_client_user_t* user = rc_client_get_user_info(ra_state->rc_client);
igPushIDStr("RetroAchievements");
Expand Down Expand Up @@ -1268,6 +1268,7 @@ void retro_achievements_draw_settings(uint32_t* draw_checkboxes[5])
if (se_button(ICON_FK_SIGN_IN " Login", ImVec2{0, 0}) || enter)
{
retro_achievements_login(username, password);
login_pressed = true;
}
if (pending_login)
se_pop_disabled();
Expand Down Expand Up @@ -1319,6 +1320,7 @@ void retro_achievements_draw_settings(uint32_t* draw_checkboxes[5])
for (int i = 0; i < 5; i++)*draw_checkboxes[i] = draw_checkboxes_bool[i];
}
igPopID();
return login_pressed;
}
void retro_achievements_draw_panel()
{
Expand Down
2 changes: 1 addition & 1 deletion src/retro_achievements.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void retro_achievements_frame();

void retro_achievements_draw_panel();

void retro_achievements_draw_settings(uint32_t* draw_checkboxes[5]);
bool retro_achievements_draw_settings(uint32_t* draw_checkboxes[5]);

void retro_achievements_update_atlases();

Expand Down

0 comments on commit a7aba8b

Please sign in to comment.