diff options
| author | Crystalwarrior <Varsash@Gmail.com> | 2022-07-18 15:45:47 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-18 15:45:47 +0300 |
| commit | c8914c930294266729fdb1b90cab5b8f5d5bd6c3 (patch) | |
| tree | 7d6178f07dcb74b56cccd01ff091abe40395ea73 /src/text_file_functions.cpp | |
| parent | 9849ce261024dfce474538418fba5e68c75c988c (diff) | |
Add effect layering under the character, flippable effects and more (#701)
* Fix effect offsets only applying after the effect already plays
Add "_layer" property which can be "behind", "character" or default "chat". This deprecates the "under_chatbox" property
* Add a "sticky" effect property which is the same as "stickyeffects" setting being enabled but just for that 1 effect
* Clang is tidy, clang is caring
* make character layer actually stack over the character but under the desk
add new "over" layer which is over everything in the viewport but under the chat box
* Switch "ignore_offset" to "respect_offset" so effects only respect character offsets if explicitly told to
* Appease clang tidy... mostly. I don't understand the last thing it's talking about.
* Appease clang tidy further
* Remove "effect_done" due to it overwriting the AOLayers behavior
Add "loop" effect property so you set up in the ini if the effect should loop rather than it using the file's loop settings
Add "max_duration" effect property
Add "cull" effect property which decides whether to clear the effect or not when it's done (if loop is false)
* Fix effects not allowed to have underscores (_) in them without breaking
* Change the way effects.ini looks and is parsed to be more sane and doable.
However, since order may or may not matter, you can optionally include index:name and it orders it properly.
* Appeal to clang
* Fix a dumb way I created QSettings in get_effects
* Fix effect properties being broken due to optional index
* Fix get_effect_property not getting the current theme properties if a misc theme exists
* If sound list has a sound effect selected, if pre is not checked, don't play effect sound and prefer the sfx we chose instead.
* Fix \f not using the theme's realization effect
* Add missing curly bracket
* Yolo
Co-authored-by: Salanto <62221668+Salanto@users.noreply.github.com>
Co-authored-by: stonedDiscord <Tukz@gmx.de>
Diffstat (limited to 'src/text_file_functions.cpp')
| -rw-r--r-- | src/text_file_functions.cpp | 57 |
1 files changed, 36 insertions, 21 deletions
diff --git a/src/text_file_functions.cpp b/src/text_file_functions.cpp index 28478e9f..be162b22 100644 --- a/src/text_file_functions.cpp +++ b/src/text_file_functions.cpp @@ -877,19 +877,18 @@ QStringList AOApplication::get_effects(QString p_char) QString p_misc = read_char_ini(p_char, "effects", "Options"); QString p_path = get_asset("effects/effects.ini", current_theme, get_subtheme(), default_theme, ""); QString p_misc_path = get_asset("effects.ini", current_theme, get_subtheme(), default_theme, p_misc); - QStringList effects; - - QStringList lines = read_file(p_path).split("\n"); - // Misc path different from default path, stack the new miscs on top of the defaults - if (p_misc_path != p_path) { - lines << read_file(p_misc_path).split("\n"); - } - foreach (QString effect, lines) { - effect = effect.split("=")[0].trimmed().split("_")[0]; - if (!effect.isEmpty() && !effects.contains(effect)) - effects.append(effect); + QSettings effects_config(p_path, QSettings::IniFormat); + effects_config.setIniCodec("UTF-8"); + QStringList effects = effects_config.childGroups(); + std::sort(effects.begin(), effects.end(), [] (const QString &a, const QString &b) {return a.split(":")[0].toInt() < b.split(":")[0].toInt();}); + if (p_path != p_misc_path) { + // If misc path is different from default path, stack the new miscs on top of the defaults + QSettings effects_config_misc(p_misc_path, QSettings::IniFormat); + effects_config_misc.setIniCodec("UTF-8"); + QStringList misc_effects = effects_config_misc.childGroups(); + std::sort(misc_effects.begin(), misc_effects.end(), [] (const QString &a, const QString &b) {return a.split(":")[0].toInt() < b.split(":")[0].toInt();}); + effects += misc_effects; } - return effects; } @@ -913,15 +912,31 @@ QString AOApplication::get_effect(QString effect, QString p_char, QString AOApplication::get_effect_property(QString fx_name, QString p_char, QString p_property) { - QString f_property; - if (p_property == "sound") - f_property = fx_name; - else - f_property = fx_name + "_" + p_property; - - QString f_result = get_config_value(f_property, "effects.ini", current_theme, get_subtheme(), default_theme, read_char_ini(p_char, "effects", "Options")); - if (f_result == "") - f_result = get_config_value(f_property, "effects/effects.ini", current_theme, get_subtheme(), default_theme, ""); + const auto paths = get_asset_paths("effects/effects.ini", current_theme, get_subtheme(), default_theme, ""); + const auto misc_paths = get_asset_paths("effects.ini", current_theme, get_subtheme(), default_theme, read_char_ini(p_char, "effects", "Options")); + QString path; + QString f_result; + for (const VPath &p : paths + misc_paths) { + path = get_real_path(p); + if (!path.isEmpty()) { + QSettings settings(path, QSettings::IniFormat); + settings.setIniCodec("UTF-8"); + QStringList char_effects = settings.childGroups(); + for (int i = 0; i < char_effects.size(); ++i) { + QString effect = char_effects[i]; + if (effect.contains(":")) { + effect = effect.section(':', 1); + } + if (effect.toLower() == fx_name.toLower()) { + f_result = settings.value(char_effects[i] + "/" + p_property).toString(); + if (!f_result.isEmpty()) { + // Only break the loop if we get a non-empty result, continue the search otherwise + break; + } + } + } + } + } if (fx_name == "realization" && p_property == "sound") { f_result = get_custom_realization(p_char); } |
