From 0e2bd0b110fe44f485871d20b5e614a214470f12 Mon Sep 17 00:00:00 2001 From: Alex Noir Date: Fri, 18 Feb 2022 22:02:18 +0300 Subject: [PATCH] Add icons for iniswaps and emotes in the dropdown Fix iniswap list not recognizing a name that's different from a character folder when switching to that character --- src/courtroom.cpp | 14 +++++++++++--- src/emotes.cpp | 10 +++++----- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 3fb691e..8596ee7 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -4322,6 +4322,10 @@ void Courtroom::set_iniswap_dropdown() QStringList iniswaps = ao_app->get_list_file(ao_app->get_character_path(char_list.at(m_cid).name, "iniswaps.ini")) + ao_app->get_list_file(ao_app->get_base_path() + "iniswaps.ini"); + + if (ao_app->get_char_name(char_list.at(m_cid).name) != char_list.at(m_cid).name) + iniswaps.append(ao_app->get_char_name(char_list.at(m_cid).name)); + iniswaps.removeDuplicates(); iniswaps.prepend(char_list.at(m_cid).name); if (iniswaps.size() <= 0) { @@ -4330,16 +4334,17 @@ void Courtroom::set_iniswap_dropdown() return; } ui_iniswap_dropdown->show(); - ui_iniswap_dropdown->addItems(iniswaps); - for (int i = 0; i < iniswaps.size(); ++i) { + ui_iniswap_dropdown->addItem(iniswaps.at(i)); + QString icon_path = ao_app->get_image_suffix(ao_app->get_character_path( + iniswaps.at(i), "char_icon")); + ui_iniswap_dropdown->setItemIcon(i, QIcon(icon_path)); if (iniswaps.at(i) == current_char) { ui_iniswap_dropdown->setCurrentIndex(i); if (i != 0) ui_iniswap_remove->show(); else ui_iniswap_remove->hide(); - break; } } ui_iniswap_dropdown->blockSignals(false); @@ -4365,6 +4370,9 @@ void Courtroom::on_iniswap_dropdown_changed(int p_index) ui_iniswap_dropdown->setCurrentIndex(p_index); ui_iniswap_dropdown->blockSignals(false); update_character(m_cid); + QString icon_path = ao_app->get_image_suffix(ao_app->get_character_path( + iniswap, "char_icon")); + ui_iniswap_dropdown->setItemIcon(p_index, QIcon(icon_path)); if (p_index != 0) ui_iniswap_remove->show(); else diff --git a/src/emotes.cpp b/src/emotes.cpp index 53f2b06..547dc0e 100644 --- a/src/emotes.cpp +++ b/src/emotes.cpp @@ -141,14 +141,14 @@ void Courtroom::set_emote_dropdown() ui_emote_dropdown->clear(); int total_emotes = ao_app->get_emote_number(current_char); - QStringList emote_list; for (int n = 0; n < total_emotes; ++n) { - emote_list.append(QString::number(n + 1) + ": " + - ao_app->get_emote_comment(current_char, n)); + ui_emote_dropdown->addItem(QString::number(n + 1) + ": " + + ao_app->get_emote_comment(current_char, n)); + QString icon_path = ao_app->get_image_suffix(ao_app->get_character_path( + current_char, "emotions/button" + QString::number(n + 1) + "_off")); + ui_emote_dropdown->setItemIcon(n, QIcon(icon_path)); } - - ui_emote_dropdown->addItems(emote_list); } void Courtroom::select_emote(int p_id)