aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCrystalwarrior <Varsash@Gmail.com>2022-07-31 21:05:09 +0300
committerGitHub <noreply@github.com>2022-07-31 13:05:09 -0500
commitb9aa2039d3eccf00985b1ffb91465f571006b896 (patch)
treed4fc6fff45242611144988c246034fcfc023179b
parentdd8eee7eede02b71b86864b533eed4102f0c584e (diff)
Add "edit" and "open folder" actions for dropdowns (#776)
* Add "edit" and "open folder" actions for dropdowns: - CharSelect char button with "edit char.ini," "open this char folder" - pos dropdown with "open this background" - text color dropdown with "open chat_config.ini" - evidence button with "open evidence folder" - sound list with "open sounds folder" - music list with "open music folder" - theme list with "open themes folder" * Implement "Play <sfx_name>" for the Play action, and only show it if the sfx is not "0" or "1" or "-" Co-authored-by: stonedDiscord <Tukz@gmx.de> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: oldmud0 <oldmud0@users.noreply.github.com>
-rw-r--r--include/aooptionsdialog.h1
-rw-r--r--include/courtroom.h4
-rw-r--r--src/aooptionsdialog.cpp17
-rw-r--r--src/charselect.cpp37
-rw-r--r--src/courtroom.cpp113
5 files changed, 164 insertions, 8 deletions
diff --git a/include/aooptionsdialog.h b/include/aooptionsdialog.h
index daf1b354..be305d21 100644
--- a/include/aooptionsdialog.h
+++ b/include/aooptionsdialog.h
@@ -51,6 +51,7 @@ private:
QLabel *ui_subtheme_label;
QComboBox *ui_subtheme_combobox;
QPushButton *ui_theme_reload_button;
+ QPushButton *ui_theme_folder_button;
QLabel *ui_evidence_double_click_lbl;
QCheckBox *ui_evidence_double_click_cb;
QLabel *ui_animated_theme_lbl;
diff --git a/include/courtroom.h b/include/courtroom.h
index e8c4e004..45c040fb 100644
--- a/include/courtroom.h
+++ b/include/courtroom.h
@@ -824,6 +824,7 @@ private:
void set_char_select();
void set_char_select_page();
void char_clicked(int n_char);
+ void on_char_button_context_menu_requested(const QPoint &pos);
void put_button_in_place(int starting, int chars_on_this_page);
void filter_character_list();
@@ -893,6 +894,7 @@ private slots:
void on_emote_dropdown_changed(int p_index);
void on_pos_dropdown_changed(int p_index);
void on_pos_dropdown_changed(QString p_text);
+ void on_pos_dropdown_context_menu_requested(const QPoint &pos);
void on_pos_remove_clicked();
void on_iniswap_dropdown_changed(int p_index);
@@ -952,6 +954,7 @@ private slots:
void on_prosecution_plus_clicked();
void on_text_color_changed(int p_color);
+ void on_text_color_context_menu_requested(const QPoint &pos);
void set_text_color_dropdown();
void on_music_slider_moved(int p_value);
@@ -982,6 +985,7 @@ private slots:
void on_showname_enable_clicked();
void on_evidence_button_clicked();
+ void on_evidence_context_menu_requested(const QPoint &pos);
void on_evidence_delete_clicked();
bool on_evidence_x_clicked();
diff --git a/src/aooptionsdialog.cpp b/src/aooptionsdialog.cpp
index 679a674d..e25b4653 100644
--- a/src/aooptionsdialog.cpp
+++ b/src/aooptionsdialog.cpp
@@ -120,7 +120,6 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app)
ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_subtheme_combobox);
row += 1;
-
ui_theme_reload_button = new QPushButton(ui_form_layout_widget);
ui_theme_reload_button->setText(tr("Reload Theme"));
ui_theme_reload_button->setToolTip(
@@ -130,6 +129,22 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app)
&AOOptionsDialog::on_reload_theme_clicked);
row += 1;
+ ui_theme_folder_button = new QPushButton(ui_form_layout_widget);
+ ui_theme_folder_button->setText(tr("Open Theme Folder"));
+ ui_theme_folder_button->setToolTip(
+ tr("Open the theme folder of the currently selected theme."));
+ ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_theme_folder_button);
+ connect(ui_theme_folder_button, &QPushButton::clicked, this,
+ [=] {
+ QString p_path = ao_app->get_real_path(ao_app->get_theme_path("", ui_theme_combobox->itemText(ui_theme_combobox->currentIndex())));
+ if (!dir_exists(p_path)) {
+ return;
+ }
+ QDesktopServices::openUrl(QUrl::fromLocalFile(p_path));
+ }
+ );
+
+ row += 1;
ui_animated_theme_lbl = new QLabel(ui_form_layout_widget);
ui_animated_theme_lbl->setText(tr("Animated Theme:"));
ui_animated_theme_lbl->setToolTip(
diff --git a/src/charselect.cpp b/src/charselect.cpp
index fb25ccef..a9770048 100644
--- a/src/charselect.cpp
+++ b/src/charselect.cpp
@@ -190,6 +190,41 @@ void Courtroom::char_clicked(int n_char)
}
}
+void Courtroom::on_char_button_context_menu_requested(const QPoint &pos)
+{
+ AOCharButton* button = qobject_cast<AOCharButton*>(sender());
+ int n_char = ui_char_button_list.indexOf(button);
+ if (n_char == -1)
+ {
+ return;
+ }
+
+ QString char_name = char_list.at(n_char).name;
+ QString char_ini_path = ao_app->get_real_path(
+ ao_app->get_character_path(char_name, "char.ini"));
+
+ if (!file_exists(char_ini_path)) {
+ call_error(tr("Could not find character (char.ini) for %1").arg(char_name));
+ return;
+ }
+
+ QMenu *menu = new QMenu(this);
+ menu->addAction(QString("Edit " + char_name + "/char.ini"), this,
+ [=] { QDesktopServices::openUrl(QUrl::fromLocalFile(char_ini_path)); }
+ );
+ menu->addSeparator();
+ menu->addAction(QString("Open character folder " + char_name), this,
+ [=] {
+ QString p_path = ao_app->get_real_path(VPath("characters/" + char_name + "/"));
+ if (!dir_exists(p_path)) {
+ return;
+ }
+ QDesktopServices::openUrl(QUrl::fromLocalFile(p_path));
+ }
+ );
+ menu->popup(button->mapToGlobal(pos));
+}
+
void Courtroom::put_button_in_place(int starting, int chars_on_this_page)
{
if (ui_char_button_list_filtered.size() == 0)
@@ -249,6 +284,7 @@ void Courtroom::character_loading_finished()
for (int n = 0; n < char_list.size(); n++) {
AOCharButton *char_button =
new AOCharButton(ui_char_buttons, ao_app, 0, 0, char_list.at(n).taken);
+ char_button->setContextMenuPolicy(Qt::CustomContextMenu);
char_button->reset();
char_button->hide();
char_button->set_image(char_list.at(n).name);
@@ -282,6 +318,7 @@ void Courtroom::character_loading_finished()
connect(char_button, &AOCharButton::clicked,
[this, n]() { this->char_clicked(n); });
+ connect(char_button, &AOCharButton::customContextMenuRequested, this, &Courtroom::on_char_button_context_menu_requested);
// This part here serves as a way of showing to the player that the game is
// still running, it is just loading the pictures of the characters.
diff --git a/src/courtroom.cpp b/src/courtroom.cpp
index e54c1ae6..efea86d5 100644
--- a/src/courtroom.cpp
+++ b/src/courtroom.cpp
@@ -211,6 +211,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_music_search->setObjectName("ui_music_search");
ui_pos_dropdown = new QComboBox(this);
+ ui_pos_dropdown->setContextMenuPolicy(Qt::CustomContextMenu);
ui_pos_dropdown->view()->setTextElideMode(Qt::ElideLeft);
ui_pos_dropdown->setObjectName("ui_pos_dropdown");
@@ -359,6 +360,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_prosecution_minus->setObjectName("ui_prosecution_minus");
ui_text_color = new QComboBox(this);
+ ui_text_color->setContextMenuPolicy(Qt::CustomContextMenu);
ui_text_color->setObjectName("ui_text_color");
ui_music_slider = new QSlider(Qt::Horizontal, this);
@@ -401,6 +403,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_pair_button->setObjectName("ui_pair_button");
ui_evidence_button = new AOButton(this, ao_app);
+ ui_evidence_button->setContextMenuPolicy(Qt::CustomContextMenu);
ui_evidence_button->setObjectName("ui_evidence_button");
initialize_emotes();
@@ -431,6 +434,8 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
QOverload<int>::of(&Courtroom::on_pos_dropdown_changed));
connect(ui_pos_dropdown, &QComboBox::editTextChanged, this,
QOverload<QString>::of(&Courtroom::on_pos_dropdown_changed));
+ connect(ui_pos_dropdown, &QComboBox::customContextMenuRequested, this,
+ &Courtroom::on_pos_dropdown_context_menu_requested);
connect(ui_pos_remove, &AOButton::clicked, this, &Courtroom::on_pos_remove_clicked);
connect(ui_iniswap_dropdown, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
@@ -500,6 +505,8 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
connect(ui_text_color, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&Courtroom::on_text_color_changed);
+ connect(ui_text_color, &QComboBox::customContextMenuRequested, this,
+ &Courtroom::on_text_color_context_menu_requested);
connect(ui_music_slider, &QSlider::valueChanged, this,
&Courtroom::on_music_slider_moved);
@@ -554,6 +561,8 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
connect(ui_evidence_button, &AOButton::clicked, this,
&Courtroom::on_evidence_button_clicked);
+ connect(ui_evidence_button, &QComboBox::customContextMenuRequested, this,
+ &Courtroom::on_evidence_context_menu_requested);
connect(qApp, QOverload<Qt::ApplicationState>::of(&QApplication::applicationStateChanged), this,
&Courtroom::on_application_state_changed);
@@ -4532,6 +4541,25 @@ void Courtroom::on_pos_dropdown_changed(QString p_text)
set_side(p_text);
}
+void Courtroom::on_pos_dropdown_context_menu_requested(const QPoint &pos)
+{
+ QMenu *menu = ui_iniswap_dropdown->lineEdit()->createStandardContextMenu();
+
+ menu->setAttribute(Qt::WA_DeleteOnClose);
+ menu->addSeparator();
+
+ menu->addAction(QString("Open background " + current_background), this,
+ [=] {
+ QString p_path = ao_app->get_real_path(VPath("background/" + current_background + "/"));
+ if (!dir_exists(p_path)) {
+ return;
+ }
+ QDesktopServices::openUrl(QUrl::fromLocalFile(p_path));
+ }
+ );
+ menu->popup(ui_iniswap_dropdown->mapToGlobal(pos));
+}
+
void Courtroom::on_pos_remove_clicked()
{
ui_pos_dropdown->blockSignals(true);
@@ -4633,18 +4661,32 @@ void Courtroom::on_iniswap_context_menu_requested(const QPoint &pos)
if (file_exists(ao_app->get_real_path(
ao_app->get_character_path(current_char, "char.ini"))))
menu->addAction(QString("Edit " + current_char + "/char.ini"), this,
- SLOT(on_iniswap_edit_requested()));
+ &Courtroom::on_iniswap_edit_requested);
if (ui_iniswap_dropdown->itemText(ui_iniswap_dropdown->currentIndex()) !=
char_list.at(m_cid).name)
menu->addAction(QString("Remove " + current_char), this,
- SLOT(on_iniswap_remove_clicked()));
+ &Courtroom::on_iniswap_remove_clicked);
+
+ menu->addSeparator();
+ menu->addAction(QString("Open character folder " + current_char), this,
+ [=] {
+ QString p_path = ao_app->get_real_path(VPath("characters/" + current_char + "/"));
+ if (!dir_exists(p_path)) {
+ return;
+ }
+
+ QDesktopServices::openUrl(QUrl::fromLocalFile(p_path));
+ }
+ );
menu->popup(ui_iniswap_dropdown->mapToGlobal(pos));
}
+
void Courtroom::on_iniswap_edit_requested()
{
QString p_path = ao_app->get_real_path(ao_app->get_character_path(current_char, "char.ini"));
- if (!file_exists(p_path))
+ if (!file_exists(p_path)) {
return;
+ }
QDesktopServices::openUrl(QUrl::fromLocalFile(p_path));
}
@@ -4690,8 +4732,9 @@ void Courtroom::set_sfx_dropdown()
for (const QString &sound : qAsConst(sound_list)) {
QStringList unpacked = sound.split("=");
QString display = unpacked[0].trimmed();
- if (unpacked.size() > 1)
+ if (unpacked.size() > 1) {
display = unpacked[1].trimmed();
+ }
display_sounds.append(display);
}
@@ -4726,7 +4769,11 @@ void Courtroom::on_sfx_context_menu_requested(const QPoint &pos)
menu->setAttribute(Qt::WA_DeleteOnClose);
menu->addSeparator();
- menu->addAction(QString("Play"), this, &Courtroom::on_sfx_play_clicked);
+ // SFX is not "Nothing" or "Default"?
+ if (get_char_sfx() != "0" && get_char_sfx() != "1" && get_char_sfx() != "-") {
+ // Add an option to play the SFX
+ menu->addAction(QString("Play " + get_char_sfx()), this, &Courtroom::on_sfx_play_clicked);;
+ }
if (file_exists(ao_app->get_real_path(
ao_app->get_character_path(current_char, "soundlist.ini"))))
menu->addAction(QString("Edit " + current_char + "/soundlist.ini"), this,
@@ -4736,6 +4783,16 @@ void Courtroom::on_sfx_context_menu_requested(const QPoint &pos)
&Courtroom::on_sfx_edit_requested);
if (!custom_sfx.isEmpty())
menu->addAction(QString("Clear Edit Text"), this, &Courtroom::on_sfx_remove_clicked);
+ menu->addSeparator();
+ menu->addAction(QString("Open base sounds folder"), this,
+ [=] {
+ QString p_path = ao_app->get_base_path() + "sounds/general/";
+ if (!dir_exists(p_path)) {
+ return;
+ }
+ QDesktopServices::openUrl(QUrl::fromLocalFile(p_path));
+ }
+ );
menu->popup(ui_sfx_dropdown->mapToGlobal(pos));
}
@@ -4809,9 +4866,9 @@ void Courtroom::on_effects_context_menu_requested(const QPoint &pos)
QString("Open misc/" +
ao_app->read_char_ini(current_char, "effects", "Options") +
" folder"),
- this, SLOT(on_character_effects_edit_requested()));
+ this, &Courtroom::on_character_effects_edit_requested);
menu->addAction(QString("Open theme's effects folder"), this,
- SLOT(on_effects_edit_requested()));
+ &Courtroom::on_effects_edit_requested);
menu->popup(ui_effects_dropdown->mapToGlobal(pos));
}
void Courtroom::on_effects_edit_requested()
@@ -5001,6 +5058,17 @@ void Courtroom::on_music_list_context_menu_requested(const QPoint &pos)
connect(menu->actions().back(), &QAction::toggled, this,
&Courtroom::music_synchronize);
+ menu->addSeparator();
+ menu->addAction(QString("Open base music folder"), this,
+ [=] {
+ QString p_path = ao_app->get_base_path() + "sounds/music/";
+ if (!dir_exists(p_path)) {
+ return;
+ }
+ QDesktopServices::openUrl(QUrl::fromLocalFile(p_path));
+ }
+ );
+
menu->popup(ui_music_list->mapToGlobal(pos));
}
@@ -5313,6 +5381,22 @@ void Courtroom::on_prosecution_plus_clicked()
new AOPacket("HP", {"2", QString::number(f_state)}));
}
+void Courtroom::on_text_color_context_menu_requested(const QPoint &pos)
+{
+ QMenu *menu = new QMenu(this);
+
+ menu->addAction(QString("Open currently used chat_config.ini"), this,
+ [=] {
+ QString p_path = ao_app->get_asset("chat_config.ini", ao_app->current_theme, ao_app->get_subtheme(), ao_app->default_theme, ao_app->get_chat(current_char));
+ if (!file_exists(p_path)) {
+ return;
+ }
+ QDesktopServices::openUrl(QUrl::fromLocalFile(p_path));
+ }
+ );
+ menu->popup(ui_text_color->mapToGlobal(pos));
+}
+
void Courtroom::set_text_color_dropdown()
{
// Clear the lists
@@ -5617,6 +5701,21 @@ void Courtroom::on_evidence_button_clicked()
}
}
+void Courtroom::on_evidence_context_menu_requested(const QPoint &pos)
+{
+ QMenu *menu = new QMenu(this);
+ menu->addAction(QString("Open base evidence folder"), this,
+ [=] {
+ QString p_path = ao_app->get_base_path() + "evidence/";
+ if (!dir_exists(p_path)) {
+ return;
+ }
+ QDesktopServices::openUrl(QUrl::fromLocalFile(p_path));
+ }
+ );
+ menu->popup(ui_evidence_button->mapToGlobal(pos));
+}
+
void Courtroom::on_switch_area_music_clicked()
{
if (ui_area_list->isHidden()) {