diff --git a/include/aoapplication.h b/include/aoapplication.h index c69a0d3..3aa21a1 100644 --- a/include/aoapplication.h +++ b/include/aoapplication.h @@ -435,9 +435,6 @@ public: // Returns whether the given pos is a judge position bool get_pos_is_judge(const QString &p_pos); - // Returns the name of p_char - QString get_char_name(QString p_char); - // Returns the total amount of emotes of p_char int get_emote_number(QString p_char); diff --git a/include/courtroom.h b/include/courtroom.h index 479b105..d2d4107 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -213,7 +213,8 @@ public: QString get_current_background() { return current_background; } // updates character to p_cid and updates necessary ui elements - void update_character(int p_cid); + // Optional "char_name" is the iniswap we're using + void update_character(int p_cid, QString char_name = "", bool reset_emote = false); // properly sets up some varibles: resets user state void enter_courtroom(); diff --git a/src/courtroom.cpp b/src/courtroom.cpp index f14cc20..ab1ea8a 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1469,7 +1469,7 @@ void Courtroom::set_pos_dropdown(QStringList pos_dropdowns) set_side(current_side); } -void Courtroom::update_character(int p_cid) +void Courtroom::update_character(int p_cid, QString char_name, bool reset_emote) { bool newchar = m_cid != p_cid; @@ -1483,7 +1483,10 @@ void Courtroom::update_character(int p_cid) f_char = ""; } else { - f_char = ao_app->get_char_name(char_list.at(m_cid).name); + f_char = char_name; + if (char_name.isEmpty()) { + f_char = char_list.at(m_cid).name; + } if (ao_app->is_discord_enabled()) ao_app->discord->state_character(f_char.toStdString()); @@ -1494,8 +1497,11 @@ void Courtroom::update_character(int p_cid) set_text_color_dropdown(); - current_emote_page = 0; - current_emote = 0; + // If our cid changed or we're being told to reset + if (newchar || reset_emote) { + current_emote_page = 0; + current_emote = 0; + } if (m_cid == -1) ui_emotes->hide(); @@ -4476,9 +4482,6 @@ void Courtroom::set_iniswap_dropdown() ao_app->get_list_file(ao_app->get_character_path(char_list.at(m_cid).name, "iniswaps.ini")) + ao_app->get_list_file(VPath("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.prepend(char_list.at(m_cid).name); iniswaps.removeDuplicates(); if (iniswaps.size() <= 0) { @@ -4507,7 +4510,6 @@ void Courtroom::on_iniswap_dropdown_changed(int p_index) { ui_ic_chat_message->setFocus(); QString iniswap = ui_iniswap_dropdown->itemText(p_index); - ao_app->set_char_ini(char_list.at(m_cid).name, iniswap, "name", "Options"); QStringList swaplist; QStringList defswaplist = ao_app->get_list_file(ao_app->get_character_path(char_list.at(m_cid).name, "iniswaps.ini")); @@ -4524,7 +4526,7 @@ void Courtroom::on_iniswap_dropdown_changed(int p_index) ui_iniswap_dropdown->blockSignals(true); ui_iniswap_dropdown->setCurrentIndex(p_index); ui_iniswap_dropdown->blockSignals(false); - update_character(m_cid); + update_character(m_cid, iniswap, true); 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)); @@ -5407,7 +5409,7 @@ void Courtroom::on_reload_theme_clicked() set_courtroom_size(); set_widgets(); - update_character(m_cid); + update_character(m_cid, ui_iniswap_dropdown->itemText(ui_iniswap_dropdown->currentIndex())); enter_courtroom(); gen_char_rgb_list(ao_app->get_chat(current_char)); diff --git a/src/emotes.cpp b/src/emotes.cpp index 69d1185..2a1d506 100644 --- a/src/emotes.cpp +++ b/src/emotes.cpp @@ -173,6 +173,9 @@ void Courtroom::set_emote_dropdown() current_char, "emotions/button" + QString::number(n + 1) + "_off")); ui_emote_dropdown->setItemIcon(n, QIcon(icon_path)); } + if (current_emote > -1 && current_emote < ui_emote_dropdown->count()) { + ui_emote_dropdown->setCurrentIndex(current_emote); + } } void Courtroom::select_emote(int p_id) diff --git a/src/text_file_functions.cpp b/src/text_file_functions.cpp index bfb72f7..ed3b036 100644 --- a/src/text_file_functions.cpp +++ b/src/text_file_functions.cpp @@ -600,6 +600,7 @@ void AOApplication::set_char_ini(QString p_char, QString value, { QSettings settings(get_real_path(get_character_path(p_char, "char.ini")), QSettings::IniFormat); + settings.setIniCodec("UTF-8"); settings.beginGroup(target_tag); settings.setValue(p_search_line, value); settings.endGroup(); @@ -623,15 +624,6 @@ QStringList AOApplication::read_ini_tags(VPath p_path, QString target_tag) return r_values; } -QString AOApplication::get_char_name(QString p_char) -{ - QString f_result = read_char_ini(p_char, "name", "Options"); - - if (f_result == "") - return p_char; - return f_result; -} - QString AOApplication::get_showname(QString p_char) { QString f_result = read_char_ini(p_char, "showname", "Options");