aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCrystalwarrior <varsash@gmail.com>2019-09-18 05:22:00 +0300
committerCrystalwarrior <varsash@gmail.com>2019-09-18 05:22:00 +0300
commitad057c6f7a71ffac53e8d5adbbd22ab17d3e0e98 (patch)
tree03c15313eb6a78146316dbbe723d4d6172aefab5
parent605e15bb8c0ad103fb0f75454d8912ba83ba7a17 (diff)
make icons for effects n shit
they're grabbed from the effects/icons/*same name as effects* gotta be .png or w/e i need my sleep
-rw-r--r--include/aoapplication.h2
-rw-r--r--src/courtroom.cpp41
-rw-r--r--src/text_file_functions.cpp44
3 files changed, 58 insertions, 29 deletions
diff --git a/include/aoapplication.h b/include/aoapplication.h
index f8ce2269..78de2b80 100644
--- a/include/aoapplication.h
+++ b/include/aoapplication.h
@@ -303,7 +303,7 @@ public:
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();
+ QStringList get_effects(QString p_char);
//t
QString get_effect(QString effect, QString p_char);
diff --git a/src/courtroom.cpp b/src/courtroom.cpp
index f26c6dc5..48aa637d 100644
--- a/src/courtroom.cpp
+++ b/src/courtroom.cpp
@@ -1439,7 +1439,8 @@ void Courtroom::on_chat_return_pressed()
{
QString fx_sound = ao_app->get_effect_sound(effect, current_char);
packet_contents.append(effect + "|" + fx_sound);
- qDebug() << effect << fx_sound;
+ ui_effects_dropdown->setCurrentIndex(0);
+ effect = "";
}
ao_app->send_server_packet(new AOPacket("MS", packet_contents));
@@ -1902,10 +1903,14 @@ void Courtroom::do_flash()
void Courtroom::do_effect(QString fx_name, QString fx_sound, QString p_char)
{
if(!ao_app->is_shake_flash_enabled())
- return;
+ return;
+
+ QString effect = ao_app->get_effect(fx_name, p_char);
+ if (effect == "")
+ 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
+ ui_vp_effect->play(effect); // 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));
}
@@ -3507,17 +3512,45 @@ void Courtroom::set_effects_dropdown()
ui_effects_dropdown->hide();
return;
}
- QStringList effectslist = ao_app->get_effects() << ao_app->get_char_effects(current_char);
+ QStringList effectslist = ao_app->get_effects(current_char);
if (effectslist.size() <= 0)
{
ui_effects_dropdown->hide();
return;
}
+
+
effectslist.prepend("None");
ui_effects_dropdown->show();
ui_effects_dropdown->addItems(effectslist);
+
+ //ICON-MAKING HELL
+ QString p_effect = ao_app->read_char_ini(current_char, "effects", "Options");
+ QString custom_path = ao_app->get_base_path() + "misc/" + p_effect + "/icons/";
+ QString theme_path = ao_app->get_theme_path("effects/icons/");
+ QString default_path = ao_app->get_default_theme_path("effects/icons/");
+ for (int i = 0; i < ui_effects_dropdown->count(); ++i)
+ {
+ QString entry = ui_effects_dropdown->itemText(i);
+ QString iconpath = ao_app->get_static_image_suffix(custom_path + entry);
+ qDebug() << iconpath << entry;
+ if (!file_exists(iconpath))
+ {
+ iconpath = ao_app->get_static_image_suffix(theme_path + entry);
+ qDebug() << iconpath << entry;
+ if (!file_exists(iconpath))
+ {
+ iconpath = ao_app->get_static_image_suffix(default_path + entry);
+ qDebug() << iconpath << entry;
+ if (!file_exists(iconpath))
+ continue;
+ }
+ }
+ ui_effects_dropdown->setItemIcon(i, QIcon(iconpath));
+ }
+
ui_effects_dropdown->setCurrentIndex(0);
}
diff --git a/src/text_file_functions.cpp b/src/text_file_functions.cpp
index d478582c..261b0ffd 100644
--- a/src/text_file_functions.cpp
+++ b/src/text_file_functions.cpp
@@ -820,42 +820,38 @@ int AOApplication::get_text_delay(QString p_char, QString p_emote)
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";
+ QString p_path = get_base_path() + "misc/" + p_effect + "/effects.ini";
- QDir directory(p_path);
- QStringList images = directory.entryList(filters, QDir::Files);
+ QStringList lines = read_file(p_path).split("\n");
QStringList effects;
- foreach (QString effect, images)
+ foreach (QString effect, lines)
{
- effect = effect.left(effect.lastIndexOf("."));
- if (!effects.contains(effect)) //Do that juicy priority meme
+ effect = effect.split("=")[0].trimmed();
+ qDebug() << effect;
+ if (effect != "" && !effects.contains(effect))
effects.append(effect);
}
-
return effects;
}
-QStringList AOApplication::get_effects()
+QStringList AOApplication::get_effects(QString p_char)
{
- 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";
+ QString p_path = get_theme_path("effects/effects.ini");
+ QString default_path = get_default_theme_path("effects/effects.ini");
- QDir directory(design_ini_path);
- QStringList images = directory.entryList(filters, QDir::Files);
- if (images.size() <= 0)
+ if (!file_exists(p_path))
{
- directory.cd(default_path);
- images = directory.entryList(filters, QDir::Files);
+ p_path = default_path;
}
+ QStringList lines = read_file(p_path).split("\n");
- QStringList effects;
- foreach (QString effect, images)
+ QStringList effects = get_char_effects(p_char);
+ foreach (QString effect, lines)
{
- effect = effect.left(effect.lastIndexOf("."));
- if (!effects.contains(effect)) //Do that juicy priority meme
+ effect = effect.split("=")[0].trimmed();
+ qDebug() << effect;
+ if (effect != "" && !effects.contains(effect))
effects.append(effect);
}
@@ -888,9 +884,9 @@ QString AOApplication::get_effect(QString effect, QString p_char)
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 p_path = get_base_path() + "misc/effects/" + p_effect + "/effects.ini";
+ QString design_ini_path = get_theme_path("effects/effects.ini");
+ QString default_path = get_default_theme_path("effects/effects.ini");
QString f_result = read_design_ini(fx_name, p_path);
if (f_result == "")