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
This commit is contained in:
Alex Noir 2022-02-18 22:02:18 +03:00
parent e6f06d8959
commit 0e2bd0b110
2 changed files with 16 additions and 8 deletions

View File

@ -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

View File

@ -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)