From 7301e62c737f17da55be71b9e93e96ef38f7a1ba Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Fri, 29 Jul 2022 04:29:32 +0300 Subject: [PATCH] Fix iniswaps.ini and soundlist.ini not using vpath (#714) Fixes #670 Co-authored-by: stonedDiscord Co-authored-by: oldmud0 --- src/courtroom.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index f39ec82..7a65391 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -4468,7 +4468,7 @@ 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"); + 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)); @@ -4510,9 +4510,11 @@ void Courtroom::on_iniswap_dropdown_changed(int p_index) if (!swaplist.contains(entry) && entry != char_list.at(m_cid).name && !defswaplist.contains(entry)) swaplist.append(entry); } - ao_app->write_to_file( - swaplist.join("\n"), - ao_app->get_base_path() + "iniswaps.ini"); + QString p_path = ao_app->get_real_path(VPath("iniswaps.ini")); + if (!file_exists(p_path)) { + p_path = ao_app->get_base_path() + "iniswaps.ini"; + } + ao_app->write_to_file(swaplist.join("\n"), p_path); ui_iniswap_dropdown->blockSignals(true); ui_iniswap_dropdown->setCurrentIndex(p_index); ui_iniswap_dropdown->blockSignals(false); @@ -4586,8 +4588,7 @@ void Courtroom::set_sfx_dropdown() } // Append default sound list after the character sound list. - sound_list += ao_app->get_list_file( - ao_app->get_base_path() + "soundlist.ini"); + sound_list += ao_app->get_list_file(VPath("soundlist.ini")); QStringList display_sounds; for (const QString &sound : qAsConst(sound_list)) { @@ -4635,7 +4636,7 @@ void Courtroom::on_sfx_context_menu_requested(const QPoint &pos) menu->addAction(QString("Edit " + current_char + "/soundlist.ini"), this, &Courtroom::on_sfx_edit_requested); else - menu->addAction(QString("Edit global soundlist.ini"), this, + menu->addAction(QString("Edit base soundlist.ini"), this, &Courtroom::on_sfx_edit_requested); if (!custom_sfx.isEmpty()) menu->addAction(QString("Clear Edit Text"), this, &Courtroom::on_sfx_remove_clicked); @@ -4654,6 +4655,10 @@ void Courtroom::on_sfx_edit_requested() p_path = ao_app->get_real_path(ao_app->get_character_path(current_char, "sounds.ini")); } + if (!file_exists(p_path)) { + p_path = ao_app->get_real_path(VPath("soundlist.ini")); + } + if (!file_exists(p_path)) { p_path = ao_app->get_base_path() + "soundlist.ini"; }