From 23cae09135683c6b97ea0691d5dd6e69d41d7cfb Mon Sep 17 00:00:00 2001 From: in1tiate <32779090+in1tiate@users.noreply.github.com> Date: Tue, 14 Jan 2025 03:36:35 -0600 Subject: [PATCH 1/3] Reworked legacy position population - Changed data structure to a static list of pairs to avoid unnecessary deep copies - Fixed oversight which caused iteration over the value and not the key of the previous QMap --- src/courtroom.cpp | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index cf321c352..43e12092b 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1394,26 +1394,17 @@ void Courtroom::set_background(QString p_background, bool display) ui_vp_testimony->stopPlayback(); current_background = p_background; - // welcome to hardcode central may I take your order of regularly scheduled - // CBT - QMap default_pos; - default_pos["defenseempty"] = "def"; - default_pos["helperstand"] = "hld"; - default_pos["prosecutorempty"] = "pro"; - default_pos["prohelperstand"] = "hlp"; - default_pos["witnessempty"] = "wit"; - default_pos["judgestand"] = "jud"; - default_pos["jurystand"] = "jur"; - default_pos["seancestand"] = "sea"; + // Legacy positions paired to their modern counterparts for use in dropdown population + static QList> legacy_positions = {{"def", "defenseempty"}, {"hld", "helperstand"}, {"pro", "prosecutorempty"}, {"hlp", "prohelperstand"}, {"wit", "witnessempty"}, {"jud", "judgestand"}, {"jur", "jurystand"}, {"sea", "seancestand"}}; // Populate the dropdown list with all pos that exist on this bg QStringList pos_list = {}; - for (const QString &key : std::as_const(default_pos)) + for (const QPair &pos_pair : std::as_const(legacy_positions)) { - if (file_exists(ao_app->get_image_suffix(ao_app->get_background_path(default_pos[key]))) || // if we have 2.8-style positions, e.g. def.png, wit.webp, hld.apng - file_exists(ao_app->get_image_suffix(ao_app->get_background_path(key)))) + if (file_exists(ao_app->get_image_suffix(ao_app->get_background_path(pos_pair.first))) || // if we have 2.8-style positions, e.g. def.png, wit.webp, hld.apng + file_exists(ao_app->get_image_suffix(ao_app->get_background_path(pos_pair.second)))) { // if we have pre-2.8-style positions, e.g. defenseempty.png - pos_list.append(default_pos[key]); + pos_list.append(pos_pair.first); // the dropdown always uses the new style } } if (file_exists(ao_app->get_image_suffix(ao_app->get_background_path("court")))) From ee4bbc9c3552a1444e36a9da4184909900aef59f Mon Sep 17 00:00:00 2001 From: in1tiate <32779090+in1tiate@users.noreply.github.com> Date: Tue, 14 Jan 2025 03:40:57 -0600 Subject: [PATCH 2/3] clang-format pass :rolling_eyes: --- src/courtroom.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 43e12092b..337b064e8 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1402,8 +1402,8 @@ void Courtroom::set_background(QString p_background, bool display) for (const QPair &pos_pair : std::as_const(legacy_positions)) { if (file_exists(ao_app->get_image_suffix(ao_app->get_background_path(pos_pair.first))) || // if we have 2.8-style positions, e.g. def.png, wit.webp, hld.apng - file_exists(ao_app->get_image_suffix(ao_app->get_background_path(pos_pair.second)))) - { // if we have pre-2.8-style positions, e.g. defenseempty.png + file_exists(ao_app->get_image_suffix(ao_app->get_background_path(pos_pair.second)))) // if we have pre-2.8-style positions, e.g. defenseempty.png + { pos_list.append(pos_pair.first); // the dropdown always uses the new style } } From 7ce2d732fbabc856c757c84a321c602b69cf501e Mon Sep 17 00:00:00 2001 From: in1tiate <32779090+in1tiate@users.noreply.github.com> Date: Tue, 14 Jan 2025 04:12:47 -0600 Subject: [PATCH 3/3] disambiguate pair order further --- src/courtroom.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 337b064e8..372432ac7 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1394,7 +1394,8 @@ void Courtroom::set_background(QString p_background, bool display) ui_vp_testimony->stopPlayback(); current_background = p_background; - // Legacy positions paired to their modern counterparts for use in dropdown population + // Modern positions paired to their legacy counterparts for use in dropdown population + // {"new", "old"} static QList> legacy_positions = {{"def", "defenseempty"}, {"hld", "helperstand"}, {"pro", "prosecutorempty"}, {"hlp", "prohelperstand"}, {"wit", "witnessempty"}, {"jud", "judgestand"}, {"jur", "jurystand"}, {"sea", "seancestand"}}; // Populate the dropdown list with all pos that exist on this bg