Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add effect layering under the character, flippable effects and more #701

Merged
merged 22 commits into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
01e80dd
Fix effect offsets only applying after the effect already plays
Crystalwarrior Mar 25, 2022
e5516cf
Add a "sticky" effect property which is the same as "stickyeffects" s…
Crystalwarrior Mar 25, 2022
cfe3b1f
Clang is tidy, clang is caring
Crystalwarrior Mar 25, 2022
d34835a
make character layer actually stack over the character but under the …
Crystalwarrior Mar 25, 2022
f7cc329
Switch "ignore_offset" to "respect_offset" so effects only respect ch…
Crystalwarrior Mar 27, 2022
6cf7efc
Appease clang tidy... mostly. I don't understand the last thing it's …
Crystalwarrior Mar 27, 2022
e996315
Appease clang tidy further
Crystalwarrior Mar 27, 2022
9261283
Remove "effect_done" due to it overwriting the AOLayers behavior
Crystalwarrior Mar 27, 2022
0d9fb00
Fix effects not allowed to have underscores (_) in them without breaking
Crystalwarrior Mar 27, 2022
c36c02b
Change the way effects.ini looks and is parsed to be more sane and do…
Crystalwarrior Mar 27, 2022
978413a
Appeal to clang
Crystalwarrior Mar 27, 2022
c539525
Fix a dumb way I created QSettings in get_effects
Crystalwarrior Mar 27, 2022
c276462
Fix effect properties being broken due to optional index
Crystalwarrior Mar 27, 2022
f036f31
Fix get_effect_property not getting the current theme properties if a…
Crystalwarrior Mar 27, 2022
4f1ebe6
If sound list has a sound effect selected, if pre is not checked, don…
Crystalwarrior Mar 28, 2022
4812940
Merge commit '18412cc9303b1c11c8e35818d57b39aee72a5ec2' into effect-l…
Crystalwarrior Mar 28, 2022
dab16a6
Fix \f not using the theme's realization effect
Crystalwarrior Mar 29, 2022
f7c87b5
Merge branch 'master' into effect-layers
Salanto Jun 2, 2022
a6896a6
Merge branch 'master' into effect-layers
stonedDiscord Jun 6, 2022
12d105d
Add missing curly bracket
Salanto Jun 19, 2022
4097881
Merge branch 'master' into effect-layers
stonedDiscord Jun 19, 2022
5d1132f
Yolo
Salanto Jun 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions include/courtroom.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,7 @@ class Courtroom : public QMainWindow {
void set_scene(QString f_desk_mod, QString f_side);

// sets ui_vp_player_char according to SELF_OFFSET, only a function bc it's used with desk_mod 4 and 5
// sets ui_effects_layer according to the SELF_OFFSET, unless it is overwritten by effects.ini
stonedDiscord marked this conversation as resolved.
Show resolved Hide resolved
void set_self_offset(QString p_list, QString p_effect);
void set_self_offset(const QString& p_list);

// takes in serverD-formatted IP list as prints a converted version to server
// OOC admittedly poorly named
Expand Down Expand Up @@ -807,12 +806,11 @@ class Courtroom : public QMainWindow {
void regenerate_ic_chatlog();
public slots:
void objection_done();
void effect_done();
void preanim_done();
void do_screenshake();
void do_flash();
void do_effect(QString fx_path, QString fx_sound, QString p_char,
QString p_folder);
void do_effect(QString& fx_path, QString& fx_sound, QString& p_char,
Crystalwarrior marked this conversation as resolved.
Show resolved Hide resolved
QString& p_folder);
void play_char_sfx(QString sfx_name);

void mod_called(QString p_ip);
Expand Down
142 changes: 92 additions & 50 deletions src/courtroom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,6 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
connect(keepalive_timer, &QTimer::timeout, this, &Courtroom::ping_server);

connect(ui_vp_objection, &SplashLayer::done, this, &Courtroom::objection_done);
connect(ui_vp_effect, &EffectLayer::done, this, &Courtroom::effect_done);
connect(ui_vp_wtce, &SplashLayer::done, this, &Courtroom::effect_done);
connect(ui_vp_player_char, &CharLayer::done, this, &Courtroom::preanim_done);
connect(ui_vp_player_char, &CharLayer::shake, this, &Courtroom::do_screenshake);
connect(ui_vp_player_char, &CharLayer::flash, this, &Courtroom::do_flash);
Expand Down Expand Up @@ -2073,7 +2071,7 @@ void Courtroom::on_chat_return_pressed()
QString p_effect =
ao_app->read_char_ini(current_char, "effects", "Options");
packet_contents.append(effect + "|" + p_effect + "|" + fx_sound);
if (!ao_app->is_stickyeffects_enabled()) {
if (!ao_app->is_stickyeffects_enabled() && !ao_app->get_effect_property(effect, current_char, "sticky").startsWith("true")) {
ui_effects_dropdown->blockSignals(true);
ui_effects_dropdown->setCurrentIndex(0);
ui_effects_dropdown->blockSignals(false);
Expand Down Expand Up @@ -2413,12 +2411,6 @@ bool Courtroom::handle_objection()
return false;
}

void Courtroom::effect_done()
{
ui_vp_effect->stop();
ui_vp_wtce->stop();
}

void Courtroom::display_character()
{
// Stop all previously playing animations, effects etc.
Expand Down Expand Up @@ -2447,13 +2439,10 @@ void Courtroom::display_character()
else
ui_vp_player_char->network_strings.clear();

// Determine if we should flip the character or not (what servers don't support flipping at this point?)
if (ao_app->flipping_enabled && m_chatmessage[FLIP].toInt() == 1)
ui_vp_player_char->set_flipped(true);
else
ui_vp_player_char->set_flipped(false);
// Determine if we should flip the character or not
ui_vp_player_char->set_flipped(m_chatmessage[FLIP].toInt() == 1);
// Move the character on the viewport according to the offsets
set_self_offset(m_chatmessage[SELF_OFFSET], m_chatmessage[EFFECTS]);
set_self_offset(m_chatmessage[SELF_OFFSET]);
stonedDiscord marked this conversation as resolved.
Show resolved Hide resolved
stonedDiscord marked this conversation as resolved.
Show resolved Hide resolved
}

void Courtroom::display_pair_character(QString other_charid, QString other_offset)
Expand Down Expand Up @@ -2659,44 +2648,107 @@ void Courtroom::do_flash()
QString f_char = m_chatmessage[CHAR_NAME];
QString f_custom_theme = ao_app->get_chat(f_char);
ui_vp_effect->stretch = true;
ui_vp_effect->setParent(this);
Crystalwarrior marked this conversation as resolved.
Show resolved Hide resolved
Crystalwarrior marked this conversation as resolved.
Show resolved Hide resolved
ui_vp_effect->stackUnder(ui_vp_objection); // go above the chatbox
Crystalwarrior marked this conversation as resolved.
Show resolved Hide resolved
ui_vp_effect->move(ui_viewport->x(), ui_viewport->y());

ui_vp_effect->set_static_duration(60);
ui_vp_effect->set_max_duration(60);
Crystalwarrior marked this conversation as resolved.
Show resolved Hide resolved
ui_vp_player_char->stackUnder(ui_vp_objection); // go above the chatbox
ui_vp_effect->load_image(
ao_app->get_effect("realization", f_char, f_custom_theme), false);
}
stonedDiscord marked this conversation as resolved.
Show resolved Hide resolved

void Courtroom::do_effect(QString fx_name, QString fx_sound, QString p_char,
QString p_folder)
void Courtroom::do_effect(QString& fx_path, QString& fx_sound, QString& p_char,
QString& p_folder)
{
if (fx_name == "")
if (fx_path == "") {
return;
stonedDiscord marked this conversation as resolved.
Show resolved Hide resolved
QString effect = ao_app->get_effect(fx_name, p_char, p_folder);
if (effect == "")
}
QString effect = ao_app->get_effect(fx_path, p_char, p_folder);
if (effect == "") {
stonedDiscord marked this conversation as resolved.
Show resolved Hide resolved
return;
}

if (fx_sound != "")
if (fx_sound != "") {
sfx_player->play(fx_sound);
}

// Only check if effects are disabled after playing the sound if it exists
if (!ao_app->is_effects_enabled())
if (!ao_app->is_effects_enabled()) {
return;
}
ui_vp_effect->transform_mode = ao_app->get_scaling(
ao_app->get_effect_property(fx_name, p_char, "scaling"));
ao_app->get_effect_property(fx_path, p_char, "scaling"));
ui_vp_effect->stretch =
ao_app->get_effect_property(fx_name, p_char, "stretch")
ao_app->get_effect_property(fx_path, p_char, "stretch")
.startsWith("true");
bool under_chatbox = ao_app->get_effect_property(fx_name, p_char, "under_chatbox").startsWith("true");
if (under_chatbox)
ui_vp_effect->stackUnder(ui_vp_chatbox);
else
ui_vp_effect->stackUnder(ui_vp_objection);
ui_vp_effect->set_flipped(ao_app->get_effect_property(fx_path, p_char, "respect_flip").startsWith("true") && m_chatmessage[FLIP].toInt() == 1);
ui_vp_effect->set_play_once(
false); // The effects themselves dictate whether or not they're looping.
// Static effects will linger.
ui_vp_effect->set_static_duration(0);
ui_vp_effect->set_max_duration(0);
ui_vp_effect->load_image(effect, true);

bool looping =
ao_app->get_effect_property(fx_path, p_char, "loop")
.startsWith("true");

int max_duration =
ao_app->get_effect_property(fx_path, p_char, "max_duration")
.toInt();

bool cull =
ao_app->get_effect_property(fx_path, p_char, "cull")
.startsWith("true");

// Possible values: "chat", "character", "behind"
QString layer = ao_app->get_effect_property(fx_path, p_char, "layer").toLower();
if (layer == "behind"){
ui_vp_effect->setParent(ui_viewport);
ui_vp_effect->stackUnder(ui_vp_player_char);
}
else if (layer == "character") {
ui_vp_effect->setParent(ui_viewport);
ui_vp_effect->stackUnder(ui_vp_desk);
}
else if (layer == "over") {
ui_vp_effect->setParent(ui_viewport);
ui_vp_effect->raise();
}
else { // if (layer == "chat") {
ui_vp_effect->setParent(this);
ui_vp_effect->stackUnder(ui_vp_objection);
}

int effect_x = 0;
int effect_y = 0;
// The effect is not parented to viewport, meaning we're overlaying ui elements
if (ui_vp_effect->parentWidget() != ui_viewport) {
//We need to add the viewport as an offset as effects are not bound to it.
Crystalwarrior marked this conversation as resolved.
Show resolved Hide resolved
effect_x = ui_viewport->x();
effect_y = ui_viewport->y();
Crystalwarrior marked this conversation as resolved.
Show resolved Hide resolved
}
// This effect respects the character offset settings
if (ao_app->get_effect_property(fx_path, p_char, "respect_offset") == "true") {
QStringList self_offsets = m_chatmessage[SELF_OFFSET].split("&");
Crystalwarrior marked this conversation as resolved.
Show resolved Hide resolved
int self_offset = self_offsets[0].toInt();
Crystalwarrior marked this conversation as resolved.
Show resolved Hide resolved
int self_offset_v;
if (self_offsets.length() <= 1) {
self_offset_v = 0;
Crystalwarrior marked this conversation as resolved.
Show resolved Hide resolved
}
else {
self_offset_v = self_offsets[1].toInt();
Crystalwarrior marked this conversation as resolved.
Show resolved Hide resolved
}

// Move the effects layer to match the position of our character
const int percent = 100;
effect_x += ui_viewport->width() * self_offset / percent;
effect_y += ui_viewport->height() * self_offset_v / percent;
}
Crystalwarrior marked this conversation as resolved.
Show resolved Hide resolved
Crystalwarrior marked this conversation as resolved.
Show resolved Hide resolved
ui_vp_effect->move(effect_x, effect_y);
Crystalwarrior marked this conversation as resolved.
Show resolved Hide resolved
stonedDiscord marked this conversation as resolved.
Show resolved Hide resolved

ui_vp_effect->set_static_duration(max_duration);
ui_vp_effect->set_max_duration(max_duration);
Crystalwarrior marked this conversation as resolved.
Show resolved Hide resolved
Crystalwarrior marked this conversation as resolved.
Show resolved Hide resolved
ui_vp_effect->load_image(effect, looping);
ui_vp_effect->set_cull_image(cull);
}

void Courtroom::play_char_sfx(QString sfx_name)
Expand Down Expand Up @@ -3378,7 +3430,7 @@ void Courtroom::start_chat_ticking()
// handle expanded desk mods
switch(m_chatmessage[DESK_MOD].toInt()) {
case 4:
set_self_offset(m_chatmessage[SELF_OFFSET], QString("||"));
set_self_offset(m_chatmessage[SELF_OFFSET]);
[[fallthrough]];
case 2:
set_scene("1", m_chatmessage[SIDE]);
Expand Down Expand Up @@ -3834,28 +3886,18 @@ void Courtroom::set_scene(QString f_desk_mod, QString f_side)
}
}

void Courtroom::set_self_offset(QString p_list, QString p_effect) {
void Courtroom::set_self_offset(const QString& p_list) {
QStringList self_offsets = p_list.split("&");
QStringList play_effect = p_effect.split("|");
int self_offset = self_offsets[0].toInt();
int self_offset_v;
if (self_offsets.length() <= 1)
if (self_offsets.length() <= 1) {
self_offset_v = 0;
else
}
else {
self_offset_v = self_offsets[1].toInt();
ui_vp_player_char->move(ui_viewport->width() * self_offset / 100, ui_viewport->height() * self_offset_v / 100);

//If an effect is ignoring the users offset, we force it to the default position of the viewport.
if (ao_app->get_effect_property(play_effect[0], current_char, "ignore_offset") == "true") {
ui_vp_effect->move(ui_viewport->x(), ui_viewport->y());
return;
}

//Offset is not disabled, we move the effects layer to match the position of our character
//We need to add the viewport as an offset as effects are not bound to it.
int effect_x = (ui_viewport->width() * self_offset / 100) + ui_viewport->x();
int effect_y = (ui_viewport->height() * self_offset_v / 100) + ui_viewport->y();
ui_vp_effect->move(effect_x, effect_y);
const int percent = 100;
ui_vp_player_char->move(ui_viewport->width() * self_offset / percent, ui_viewport->height() * self_offset_v / percent);
}

void Courtroom::set_ip_list(QString p_list)
Expand Down