Implement effects system that reads your folder in theme/effects, or misc/<folder name>/<effects>
Add an effect packet Allow aomovie to be fed a direct path Add some really terrible helper functions that shouldn't exist, sorry.
This commit is contained in:
parent
e151964785
commit
605e15bb8c
@ -80,6 +80,7 @@ public:
|
||||
bool modcall_reason_enabled = false;
|
||||
bool looping_sfx_support_enabled = false;
|
||||
bool additive_enabled = false;
|
||||
bool effects_enabled = false;
|
||||
|
||||
///////////////loading info///////////////////
|
||||
|
||||
@ -298,6 +299,18 @@ public:
|
||||
//Not in use
|
||||
int get_text_delay(QString p_char, QString p_emote);
|
||||
|
||||
//Get the effects folder referenced by the char.ini, read it and return the list of filenames in a string
|
||||
QStringList get_char_effects(QString p_char);
|
||||
|
||||
//Get the theme's effects folder, read it and return the list of filenames in a string
|
||||
QStringList get_effects();
|
||||
|
||||
//t
|
||||
QString get_effect(QString effect, QString p_char);
|
||||
|
||||
//Return the effect sound associated with the fx_name in the misc/effects/<char-defined>/sounds.ini, or theme/effects/sounds.ini.
|
||||
QString get_effect_sound(QString fx_name, QString p_char);
|
||||
|
||||
// Returns the custom realisation used by the character.
|
||||
QString get_custom_realization(QString p_char);
|
||||
|
||||
|
@ -15,7 +15,7 @@ public:
|
||||
AOMovie(QWidget *p_parent, AOApplication *p_ao_app);
|
||||
|
||||
void set_play_once(bool p_play_once);
|
||||
void play(QString p_gif, QString p_char = "", QString p_custom_theme = "", int default_duration = 0);
|
||||
void play(QString p_image, QString p_char = "", QString p_custom_theme = "", int default_duration = 0);
|
||||
void combo_resize(int w, int h);
|
||||
void stop();
|
||||
|
||||
|
@ -345,7 +345,7 @@ private:
|
||||
//the amount of time non-animated witness testimony/cross-examination images stay onscreen for in ms
|
||||
const int wtce_stay_time = 1500;
|
||||
|
||||
static const int chatmessage_size = 29;
|
||||
static const int chatmessage_size = 30;
|
||||
QString m_chatmessage[chatmessage_size];
|
||||
bool chatmessage_is_empty = false;
|
||||
|
||||
@ -375,6 +375,8 @@ private:
|
||||
int text_color = 0;
|
||||
bool is_presenting_evidence = false;
|
||||
|
||||
QString effect = "";
|
||||
|
||||
int defense_bar_state = 0;
|
||||
int prosecution_bar_state = 0;
|
||||
|
||||
@ -429,7 +431,7 @@ private:
|
||||
QLabel *ui_vp_showname;
|
||||
AOMovie *ui_vp_chat_arrow;
|
||||
QTextEdit *ui_vp_message;
|
||||
AOMovie *ui_vp_realization;
|
||||
AOMovie *ui_vp_effect;
|
||||
AOMovie *ui_vp_testimony;
|
||||
AOMovie *ui_vp_wtce;
|
||||
AOMovie *ui_vp_objection;
|
||||
@ -470,6 +472,8 @@ private:
|
||||
QComboBox *ui_sfx_dropdown;
|
||||
AOButton *ui_sfx_remove;
|
||||
|
||||
QComboBox *ui_effects_dropdown;
|
||||
|
||||
AOImage *ui_defense_bar;
|
||||
AOImage *ui_prosecution_bar;
|
||||
|
||||
@ -579,6 +583,7 @@ public slots:
|
||||
void preanim_done();
|
||||
void do_screenshake();
|
||||
void do_flash();
|
||||
void do_effect(QString fx_path, QString fx_sound, QString p_char);
|
||||
void play_char_sfx(QString sfx_name);
|
||||
|
||||
void mod_called(QString p_ip);
|
||||
@ -620,6 +625,9 @@ private slots:
|
||||
void set_sfx_dropdown();
|
||||
void on_sfx_remove_clicked();
|
||||
|
||||
void set_effects_dropdown();
|
||||
void on_effects_dropdown_changed(int p_index);
|
||||
|
||||
QString get_char_sfx();
|
||||
int get_char_sfx_delay();
|
||||
|
||||
|
@ -106,7 +106,8 @@ enum CHAT_MESSAGE
|
||||
FRAME_SCREENSHAKE,
|
||||
FRAME_REALIZATION,
|
||||
FRAME_SFX,
|
||||
ADDITIVE
|
||||
ADDITIVE,
|
||||
EFFECTS
|
||||
};
|
||||
|
||||
enum COLOR
|
||||
|
@ -29,35 +29,41 @@ void AOMovie::play(QString p_image, QString p_char, QString p_custom_theme, int
|
||||
{
|
||||
m_movie->stop();
|
||||
|
||||
QString shout_path;
|
||||
QList<QString> pathlist;
|
||||
QString shout_path = p_image;
|
||||
if (!file_exists(p_image))
|
||||
{
|
||||
QList<QString> pathlist;
|
||||
|
||||
pathlist = {
|
||||
pathlist = {
|
||||
ao_app->get_image_suffix(ao_app->get_base_path() + "misc/" + p_custom_theme + "/" + p_image + "_bubble"), //Misc path
|
||||
ao_app->get_image_suffix(ao_app->get_custom_theme_path(p_custom_theme, p_image)), //Custom theme path
|
||||
ao_app->get_image_suffix(ao_app->get_theme_path(p_image)), //Theme path
|
||||
ao_app->get_image_suffix(ao_app->get_default_theme_path(p_image)), //Default theme path
|
||||
ao_app->get_image_suffix(ao_app->get_theme_path("placeholder")), //Placeholder path
|
||||
ao_app->get_image_suffix( ao_app->get_default_theme_path("placeholder")), //Default placeholder path
|
||||
};
|
||||
};
|
||||
|
||||
//Add this at the beginning of the list - order matters.
|
||||
if (p_image == "custom")
|
||||
pathlist.prepend(ao_app->get_image_suffix(ao_app->get_character_path(p_char, p_image)));
|
||||
else
|
||||
pathlist.prepend(ao_app->get_image_suffix(ao_app->get_character_path(p_char, p_image + "_bubble")));
|
||||
//Add this at the beginning of the list - order matters.
|
||||
if (p_image == "custom")
|
||||
pathlist.prepend(ao_app->get_image_suffix(ao_app->get_character_path(p_char, p_image)));
|
||||
else
|
||||
pathlist.prepend(ao_app->get_image_suffix(ao_app->get_character_path(p_char, p_image + "_bubble")));
|
||||
|
||||
for (QString path : pathlist)
|
||||
{
|
||||
for (QString path : pathlist)
|
||||
{
|
||||
if (file_exists(path))
|
||||
{
|
||||
shout_path = path;
|
||||
break;
|
||||
shout_path = path;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_movie->setFileName(shout_path);
|
||||
|
||||
if (m_movie->loopCount() == 0)
|
||||
play_once = true;
|
||||
|
||||
this->show();
|
||||
m_movie->start();
|
||||
if (m_movie->frameCount() == 0 && duration > 0)
|
||||
|
@ -98,7 +98,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
|
||||
|
||||
ui_vp_testimony = new AOMovie(this, ao_app);
|
||||
ui_vp_testimony->set_play_once(false);
|
||||
ui_vp_realization = new AOMovie(this, ao_app);
|
||||
ui_vp_effect = new AOMovie(this, ao_app);
|
||||
ui_vp_wtce = new AOMovie(this, ao_app);
|
||||
ui_vp_objection = new AOMovie(this, ao_app);
|
||||
|
||||
@ -169,6 +169,8 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
|
||||
ui_sfx_dropdown = new QComboBox(this);
|
||||
ui_sfx_remove = new AOButton(this, ao_app);
|
||||
|
||||
ui_effects_dropdown = new QComboBox(this);
|
||||
|
||||
ui_defense_bar = new AOImage(this, ao_app);
|
||||
ui_prosecution_bar = new AOImage(this, ao_app);
|
||||
|
||||
@ -294,6 +296,8 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
|
||||
connect(ui_sfx_dropdown, SIGNAL(activated(int)), this, SLOT(on_sfx_dropdown_changed(int)));
|
||||
connect(ui_sfx_remove, SIGNAL(clicked()), this, SLOT(on_sfx_remove_clicked()));
|
||||
|
||||
connect(ui_effects_dropdown, SIGNAL(activated(int)), this, SLOT(on_effects_dropdown_changed(int)));
|
||||
|
||||
connect(ui_mute_list, SIGNAL(clicked(QModelIndex)), this, SLOT(on_mute_list_clicked(QModelIndex)));
|
||||
|
||||
connect(ui_ic_chat_message, SIGNAL(returnPressed()), this, SLOT(on_chat_return_pressed()));
|
||||
@ -513,8 +517,8 @@ void Courtroom::set_widgets()
|
||||
ui_vp_testimony->move(ui_viewport->x(), ui_viewport->y());
|
||||
ui_vp_testimony->combo_resize(ui_viewport->width(), ui_viewport->height());
|
||||
|
||||
ui_vp_realization->move(ui_viewport->x(), ui_viewport->y());
|
||||
ui_vp_realization->combo_resize(ui_viewport->width(), ui_viewport->height());
|
||||
ui_vp_effect->move(ui_viewport->x(), ui_viewport->y());
|
||||
ui_vp_effect->combo_resize(ui_viewport->width(), ui_viewport->height());
|
||||
|
||||
ui_vp_wtce->move(ui_viewport->x(), ui_viewport->y());
|
||||
ui_vp_wtce->combo_resize(ui_viewport->width(), ui_viewport->height());
|
||||
@ -612,6 +616,12 @@ void Courtroom::set_widgets()
|
||||
ui_sfx_remove->set_image("evidencex");
|
||||
ui_sfx_remove->setToolTip(tr("Remove the currently selected iniswap from the list and return to the original character folder."));
|
||||
|
||||
set_size_and_pos(ui_effects_dropdown, "effects_dropdown");
|
||||
ui_effects_dropdown->setInsertPolicy(QComboBox::InsertAtBottom);
|
||||
ui_effects_dropdown->setToolTip(tr("Choose an effect to play on your next spoken message."));
|
||||
ui_effects_dropdown->setIconSize(QSize(16, 16)); //Todo: don't do hardcoding hell - make it part of courtroom_design.ini
|
||||
//Todo: actual list of effects
|
||||
|
||||
set_size_and_pos(ui_defense_bar, "defense_bar");
|
||||
ui_defense_bar->set_image("defensebar" + QString::number(defense_bar_state));
|
||||
|
||||
@ -1002,6 +1012,7 @@ void Courtroom::update_character(int p_cid)
|
||||
set_emote_dropdown();
|
||||
|
||||
set_sfx_dropdown();
|
||||
set_effects_dropdown();
|
||||
|
||||
QString side = ao_app->get_char_side(f_char);
|
||||
|
||||
@ -1424,6 +1435,12 @@ void Courtroom::on_chat_return_pressed()
|
||||
{
|
||||
packet_contents.append(ui_additive->isChecked() ? "1" : "0");
|
||||
}
|
||||
if (ao_app->effects_enabled)
|
||||
{
|
||||
QString fx_sound = ao_app->get_effect_sound(effect, current_char);
|
||||
packet_contents.append(effect + "|" + fx_sound);
|
||||
qDebug() << effect << fx_sound;
|
||||
}
|
||||
|
||||
ao_app->send_server_packet(new AOPacket("MS", packet_contents));
|
||||
}
|
||||
@ -1879,7 +1896,18 @@ void Courtroom::do_flash()
|
||||
if(!ao_app->is_shake_flash_enabled())
|
||||
return;
|
||||
|
||||
ui_vp_realization->play("realizationflash", "", "", 60);
|
||||
ui_vp_effect->play("realizationflash", "", "", 60);
|
||||
}
|
||||
|
||||
void Courtroom::do_effect(QString fx_name, QString fx_sound, QString p_char)
|
||||
{
|
||||
if(!ao_app->is_shake_flash_enabled())
|
||||
return;
|
||||
|
||||
ui_vp_effect->set_play_once(false); // The effects themselves dictate whether or not they're looping. Static effects will linger.
|
||||
ui_vp_effect->play(ao_app->get_effect(fx_name, p_char)); // It will set_play_once to true if the filepath provided is not designed to loop more than once
|
||||
if (fx_sound != "")
|
||||
sfx_player->play(ao_app->get_sfx_suffix(fx_sound));
|
||||
}
|
||||
|
||||
void Courtroom::play_char_sfx(QString sfx_name)
|
||||
@ -2288,7 +2316,18 @@ void Courtroom::start_chat_ticking()
|
||||
if (text_state != 0)
|
||||
return;
|
||||
|
||||
if (m_chatmessage[REALIZATION] == "1")
|
||||
if (m_chatmessage[EFFECTS] != "")
|
||||
{
|
||||
QStringList fx_list = m_chatmessage[EFFECTS].split("|");
|
||||
qDebug() << m_chatmessage[EFFECTS] << fx_list;
|
||||
QString fx = fx_list[0];
|
||||
QString fx_sound;
|
||||
if (fx_list.length() > 1)
|
||||
fx_sound = fx_list[1];
|
||||
|
||||
this->do_effect(fx, fx_sound, m_chatmessage[CHAR_NAME]);
|
||||
}
|
||||
else if (m_chatmessage[REALIZATION] == "1")
|
||||
{
|
||||
this->do_flash();
|
||||
sfx_player->play(ao_app->get_custom_realization(m_chatmessage[CHAR_NAME]));
|
||||
@ -3409,13 +3448,14 @@ void Courtroom::set_sfx_dropdown()
|
||||
}
|
||||
}
|
||||
|
||||
soundlist.prepend("Default");
|
||||
if (soundlist.size() <= 0)
|
||||
{
|
||||
ui_sfx_dropdown->hide();
|
||||
ui_sfx_remove->hide();
|
||||
return;
|
||||
}
|
||||
soundlist.prepend("Default");
|
||||
|
||||
ui_sfx_dropdown->show();
|
||||
ui_sfx_dropdown->addItems(soundlist);
|
||||
ui_sfx_dropdown->setCurrentIndex(0);
|
||||
@ -3459,6 +3499,34 @@ void Courtroom::on_sfx_remove_clicked()
|
||||
}
|
||||
}
|
||||
|
||||
void Courtroom::set_effects_dropdown()
|
||||
{
|
||||
ui_effects_dropdown->clear();
|
||||
if (m_cid == -1)
|
||||
{
|
||||
ui_effects_dropdown->hide();
|
||||
return;
|
||||
}
|
||||
QStringList effectslist = ao_app->get_effects() << ao_app->get_char_effects(current_char);
|
||||
|
||||
if (effectslist.size() <= 0)
|
||||
{
|
||||
ui_effects_dropdown->hide();
|
||||
return;
|
||||
}
|
||||
effectslist.prepend("None");
|
||||
|
||||
ui_effects_dropdown->show();
|
||||
ui_effects_dropdown->addItems(effectslist);
|
||||
ui_effects_dropdown->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
void Courtroom::on_effects_dropdown_changed(int p_index)
|
||||
{
|
||||
effect = ui_effects_dropdown->itemText(p_index);
|
||||
ui_ic_chat_message->setFocus();
|
||||
}
|
||||
|
||||
QString Courtroom::get_char_sfx()
|
||||
{
|
||||
QString sfx = ui_sfx_dropdown->itemText(ui_sfx_dropdown->currentIndex());
|
||||
|
@ -215,6 +215,8 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
|
||||
looping_sfx_support_enabled = true;
|
||||
if (f_packet.contains("additive",Qt::CaseInsensitive))
|
||||
additive_enabled = true;
|
||||
if (f_packet.contains("effects",Qt::CaseInsensitive))
|
||||
effects_enabled = true;
|
||||
}
|
||||
else if (header == "PN")
|
||||
{
|
||||
|
@ -817,6 +817,93 @@ int AOApplication::get_text_delay(QString p_char, QString p_emote)
|
||||
else return f_result.toInt();
|
||||
}
|
||||
|
||||
QStringList AOApplication::get_char_effects(QString p_char)
|
||||
{
|
||||
QString p_effect = read_char_ini(p_char, "effects", "Options");
|
||||
QString p_path = get_base_path() + "misc/" + p_effect + "/";
|
||||
QStringList filters = QStringList() << "*.gif" << "*.webp" << "*.apng" << "*.png" << "*.GIF" << "*.WEBP" << "*.APNG" << "*.PNG";
|
||||
|
||||
QDir directory(p_path);
|
||||
QStringList images = directory.entryList(filters, QDir::Files);
|
||||
|
||||
QStringList effects;
|
||||
foreach (QString effect, images)
|
||||
{
|
||||
effect = effect.left(effect.lastIndexOf("."));
|
||||
if (!effects.contains(effect)) //Do that juicy priority meme
|
||||
effects.append(effect);
|
||||
}
|
||||
|
||||
return effects;
|
||||
}
|
||||
|
||||
QStringList AOApplication::get_effects()
|
||||
{
|
||||
QString design_ini_path = get_theme_path("effects/");
|
||||
QString default_path = get_default_theme_path("effects/");
|
||||
QStringList filters = QStringList() << "*.gif" << "*.webp" << "*.apng" << "*.png" << "*.GIF" << "*.WEBP" << "*.APNG" << "*.PNG";
|
||||
|
||||
QDir directory(design_ini_path);
|
||||
QStringList images = directory.entryList(filters, QDir::Files);
|
||||
if (images.size() <= 0)
|
||||
{
|
||||
directory.cd(default_path);
|
||||
images = directory.entryList(filters, QDir::Files);
|
||||
}
|
||||
|
||||
QStringList effects;
|
||||
foreach (QString effect, images)
|
||||
{
|
||||
effect = effect.left(effect.lastIndexOf("."));
|
||||
if (!effects.contains(effect)) //Do that juicy priority meme
|
||||
effects.append(effect);
|
||||
}
|
||||
|
||||
return effects;
|
||||
}
|
||||
|
||||
QString AOApplication::get_effect(QString effect, QString p_char)
|
||||
{
|
||||
QString p_effect = read_char_ini(p_char, "effects", "Options");
|
||||
QString p_path = get_image_suffix(get_base_path() + "misc/" + p_effect + effect);
|
||||
QString design_ini_path = get_image_suffix(get_theme_path("effects/" + effect));
|
||||
QString default_path = get_image_suffix(get_default_theme_path("effects/" + effect));
|
||||
|
||||
if (!file_exists(p_path))
|
||||
{
|
||||
p_path = design_ini_path;
|
||||
if (!file_exists(p_path))
|
||||
{
|
||||
p_path = default_path;
|
||||
if (!file_exists(p_path))
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return p_path;
|
||||
}
|
||||
|
||||
QString AOApplication::get_effect_sound(QString fx_name, QString p_char)
|
||||
{
|
||||
QString p_effect = read_char_ini(p_char, "effects", "Options");
|
||||
QString p_path = get_base_path() + "misc/effects/" + p_effect + "/effect_sounds.ini";
|
||||
QString design_ini_path = get_theme_path("effects/effect_sounds.ini");
|
||||
QString default_path = get_default_theme_path("effects/effect_sounds.ini");
|
||||
|
||||
QString f_result = read_design_ini(fx_name, p_path);
|
||||
if (f_result == "")
|
||||
{
|
||||
f_result = read_design_ini(fx_name, design_ini_path);
|
||||
if (f_result == "")
|
||||
{
|
||||
f_result = read_design_ini(fx_name, default_path);
|
||||
}
|
||||
}
|
||||
return f_result;
|
||||
}
|
||||
|
||||
QString AOApplication::get_custom_realization(QString p_char)
|
||||
{
|
||||
QString f_result = read_char_ini(p_char, "realization", "Options");
|
||||
|
Loading…
Reference in New Issue
Block a user