From 70747f938d97ad1115f652eecd3dc5e11edbf4b1 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 2 Jun 2024 18:00:47 +0200 Subject: [PATCH] load scores before showing custom modes --- menus.cpp | 6 ++++-- scores.cpp | 22 +++++++++++++++------- yendor.cpp | 2 -- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/menus.cpp b/menus.cpp index 78214bbf..9f1ee6a6 100644 --- a/menus.cpp +++ b/menus.cpp @@ -816,7 +816,7 @@ EX void showChangeMode() { dialog::addItem(XLAT("highlights & achievements"), 'h'); dialog::add_action_push(mode_higlights); dialog::addItem(XLAT("custom mode manager"), 'm'); - dialog::add_action_push(show_custom); + dialog::add_action([] { scores::load_only(); pushScreen(show_custom); }); dialog::addBack(); dialog::display(); @@ -1262,7 +1262,9 @@ int read_menu_args() { PHASEFROM(2); launch_dialog(showChangeMode); } else if(argis("-d:custom")) { - PHASEFROM(2); launch_dialog(show_custom); + PHASEFROM(3); + scores::load_only(); + launch_dialog(show_custom); } else if(argis("-d:history")) { PHASEFROM(2); launch_dialog(history::history_menu); diff --git a/scores.cpp b/scores.cpp index e71b8163..b3af3f85 100644 --- a/scores.cpp +++ b/scores.cpp @@ -315,7 +315,7 @@ void show() { }; } -void load() { +void load_only() { if(scorefile == "") return; scores.clear(); FILE *f = fopen(scorefile.c_str(), "rt"); @@ -368,15 +368,27 @@ void load() { } } + fclose(f); + + qty_scores_for.clear(); + for(auto s: scores::scores) { + int modeid = s.box[scores::MODECODE_BOX]; + qty_scores_for[get_identify(modeid)]++; + } + } + +void load() { + load_only(); + + saved_modecode = modecode(); saveBox(); - score sc; + score sc; for(int i=0; i qty_scores_for; -EX void count_scores() { - qty_scores_for.clear(); - for(auto s: scores::scores) qty_scores_for[scores::MODECODE_BOX]++; - } } #endif diff --git a/yendor.cpp b/yendor.cpp index 5ef8a1a6..b74253c3 100644 --- a/yendor.cpp +++ b/yendor.cpp @@ -1485,8 +1485,6 @@ EX string mode_to_search; EX void list_saved_custom_modes() { dialog::start_list(2000, 2000, 'a'); - count_scores(); - auto current_mc = modecode(); int unidentified = 0;