Fix music_display not stretching properly, reconsolidate ForegroundLayer into InterjectionLayer, rename InterjectionLayer to SplashLayer (#436)

* more intelligent separation

* separation 2 electric boogaloo

* rename InterjectionLayer to SplashLayer

* remove redundant layer type

* comments and cleanup

* fix incorrect use of continuous

* remove nonfunctional check

* fix additive not coloring correctly

Co-authored-by: Crystalwarrior <varsash@gmail.com>
This commit is contained in:
in1tiate 2021-01-29 11:41:53 -06:00 committed by GitHub
parent 4a9480afdc
commit 5cafb011f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 65 additions and 77 deletions

@ -1 +1 @@
Subproject commit 9090a63dec0384c63fc4bdc7fc68dccb961e05cf Subproject commit 15b0cc4aa1241a9b740fb1ce8a61c7f699a80de5

View File

@ -10,6 +10,27 @@
class AOApplication; class AOApplication;
// "Brief" explanation of what the hell this is:
//
// AOLayer handles all animations both inside and outside
// the viewport. It was originally devised as a layering
// system, but turned into a full refactor of the existing
// animation code.
//
// AOLayer has six subclasses, all of which differ mainly in
// how they handle path resolution.
//
// - BackgroundLayer: self-explanatory, handles files found in base/background
// - CharLayer: handles all the "wonderful" quirks of character path resolution
// - SplashLayer: handles elements that can either be provided by a misc/ directory
// or by the theme - speedlines, shouts, WT/CE, et cetera
// - EffectLayer: this is basically a dummy layer since effects do their own wonky
// path resolution in a different file
// - InterfaceLayer: handles UI elements like the chat arrow and the music display
// - StickerLayer: Crystalwarrior really wanted this. Handles "stickers," whatever those are.
//
// For questions comments or concerns, bother someone else
class AOLayer : public QLabel { class AOLayer : public QLabel {
Q_OBJECT Q_OBJECT
@ -24,6 +45,11 @@ public:
bool play_once = false; // Whether to loop this animation or not bool play_once = false; // Whether to loop this animation or not
bool cull_image = true; // if we're done playing this animation, should we bool cull_image = true; // if we're done playing this animation, should we
// hide it? also controls durational culling // hide it? also controls durational culling
// Are we loading this from the same frame we left off on?
bool continuous = false;
// Whether or not to forcibly bypass the simple check done by start_playback
// and use the existent value of continuous instead
bool force_continuous = false;
Qt::TransformationMode transform_mode = Qt::FastTransformation; // transformation mode to use for this image Qt::TransformationMode transform_mode = Qt::FastTransformation; // transformation mode to use for this image
bool stretch = false; // Should we stretch/squash this image to fill the screen? bool stretch = false; // Should we stretch/squash this image to fill the screen?
@ -72,7 +98,7 @@ protected:
QElapsedTimer actual_time; QElapsedTimer actual_time;
// Usually used to turn seconds into milliseconds such as for [Time] tag in // Usually used to turn seconds into milliseconds such as for [Time] tag in
// char.ini // char.ini (which is no longer used)
const int tick_ms = 60; const int tick_ms = 60;
// These are the X and Y values before they are fixed based on the sprite's // These are the X and Y values before they are fixed based on the sprite's
@ -91,12 +117,6 @@ protected:
int speed = 100; int speed = 100;
bool m_flipped = false; bool m_flipped = false;
// Are we loading this from the same frame we left off on? TODO: actually make
// this work
bool continuous = false;
// Whether or not to forcibly bypass the simple check done by start_playback
// and use the existent value of continuous instead
bool force_continuous = false;
int duration = 0; int duration = 0;
@ -129,14 +149,6 @@ public:
void load_image(QString p_filename); void load_image(QString p_filename);
}; };
class ForegroundLayer : public AOLayer {
Q_OBJECT
public:
ForegroundLayer(QWidget *p_parent, AOApplication *p_ao_app);
QString miscname; //'misc' folder to search. we fetch this based on p_charname below
void load_image(QString p_filename, QString p_charname);
};
class CharLayer : public AOLayer { class CharLayer : public AOLayer {
Q_OBJECT Q_OBJECT
public: public:
@ -191,10 +203,10 @@ signals:
void play_sfx(QString sfx); void play_sfx(QString sfx);
}; };
class InterjectionLayer : public AOLayer { class SplashLayer : public AOLayer {
Q_OBJECT Q_OBJECT
public: public:
InterjectionLayer(QWidget *p_parent, AOApplication *p_ao_app); SplashLayer(QWidget *p_parent, AOApplication *p_ao_app);
void load_image(QString p_filename, QString p_charname, QString p_miscname); void load_image(QString p_filename, QString p_charname, QString p_miscname);
}; };

View File

@ -605,7 +605,7 @@ private:
QWidget *ui_viewport; QWidget *ui_viewport;
BackgroundLayer *ui_vp_background; BackgroundLayer *ui_vp_background;
ForegroundLayer *ui_vp_speedlines; SplashLayer *ui_vp_speedlines;
CharLayer *ui_vp_player_char; CharLayer *ui_vp_player_char;
CharLayer *ui_vp_sideplayer_char; CharLayer *ui_vp_sideplayer_char;
BackgroundLayer *ui_vp_desk; BackgroundLayer *ui_vp_desk;
@ -614,10 +614,10 @@ private:
QLabel *ui_vp_showname; QLabel *ui_vp_showname;
InterfaceLayer *ui_vp_chat_arrow; InterfaceLayer *ui_vp_chat_arrow;
QTextEdit *ui_vp_message; QTextEdit *ui_vp_message;
InterfaceLayer *ui_vp_testimony; SplashLayer *ui_vp_testimony;
InterjectionLayer *ui_vp_wtce; SplashLayer *ui_vp_wtce;
EffectLayer *ui_vp_effect; EffectLayer *ui_vp_effect;
InterjectionLayer *ui_vp_objection; SplashLayer *ui_vp_objection;
QTextEdit *ui_ic_chatlog; QTextEdit *ui_ic_chatlog;

View File

@ -28,10 +28,6 @@ BackgroundLayer::BackgroundLayer(QWidget *p_parent, AOApplication *p_ao_app)
: AOLayer(p_parent, p_ao_app) : AOLayer(p_parent, p_ao_app)
{ {
} }
ForegroundLayer::ForegroundLayer(QWidget *p_parent, AOApplication *p_ao_app)
: AOLayer(p_parent, p_ao_app)
{
}
CharLayer::CharLayer(QWidget *p_parent, AOApplication *p_ao_app) CharLayer::CharLayer(QWidget *p_parent, AOApplication *p_ao_app)
: AOLayer(p_parent, p_ao_app) : AOLayer(p_parent, p_ao_app)
{ {
@ -40,7 +36,7 @@ EffectLayer::EffectLayer(QWidget *p_parent, AOApplication *p_ao_app)
: AOLayer(p_parent, p_ao_app) : AOLayer(p_parent, p_ao_app)
{ {
} }
InterjectionLayer::InterjectionLayer(QWidget *p_parent, AOApplication *p_ao_app) SplashLayer::SplashLayer(QWidget *p_parent, AOApplication *p_ao_app)
: AOLayer(p_parent, p_ao_app) : AOLayer(p_parent, p_ao_app)
{ {
} }
@ -48,7 +44,6 @@ InterfaceLayer::InterfaceLayer(QWidget *p_parent, AOApplication *p_ao_app)
: AOLayer(p_parent, p_ao_app) : AOLayer(p_parent, p_ao_app)
{ {
} }
StickerLayer::StickerLayer(QWidget *p_parent, AOApplication *p_ao_app) StickerLayer::StickerLayer(QWidget *p_parent, AOApplication *p_ao_app)
: AOLayer(p_parent, p_ao_app) : AOLayer(p_parent, p_ao_app)
{ {
@ -135,27 +130,6 @@ void BackgroundLayer::load_image(QString p_filename)
start_playback(ao_app->get_image_suffix(ao_app->get_background_path(p_filename))); start_playback(ao_app->get_image_suffix(ao_app->get_background_path(p_filename)));
} }
void ForegroundLayer::load_image(QString p_filename, QString p_charname)
{
play_once = false;
cull_image = false;
miscname = ao_app->get_char_shouts(p_charname);
qDebug() << "[ForegroundLayer] FG loaded: " << p_filename;
QList<QString> pathlist = {
ao_app->get_image_suffix(ao_app->get_character_path(
p_charname, p_filename)), // first check the character folder
ao_app->get_image_suffix(ao_app->get_theme_path(
"misc/" + miscname + "/" +
p_filename)), // then check our theme's misc directory
ao_app->get_image_suffix(ao_app->get_misc_path(
miscname, p_filename)), // then check our global misc folder
ao_app->get_image_suffix(
ao_app->get_theme_path(p_filename)), // then check the user's theme
ao_app->get_image_suffix(ao_app->get_default_theme_path(
p_filename))}; // and finally check the default theme
start_playback(find_image(pathlist));
}
void CharLayer::load_image(QString p_filename, QString p_charname, void CharLayer::load_image(QString p_filename, QString p_charname,
int p_duration, bool p_is_preanim) int p_duration, bool p_is_preanim)
{ {
@ -219,12 +193,9 @@ void CharLayer::load_image(QString p_filename, QString p_charname,
this->start_playback(find_image(pathlist)); this->start_playback(find_image(pathlist));
} }
void InterjectionLayer::load_image(QString p_filename, QString p_charname, void SplashLayer::load_image(QString p_filename, QString p_charname,
QString p_miscname) QString p_miscname)
{ {
continuous = false;
force_continuous = true;
play_once = true;
transform_mode = ao_app->get_misc_scaling(p_miscname); transform_mode = ao_app->get_misc_scaling(p_miscname);
QList<QString> pathlist = { QList<QString> pathlist = {
ao_app->get_image_suffix(ao_app->get_character_path( ao_app->get_image_suffix(ao_app->get_character_path(
@ -269,7 +240,7 @@ void EffectLayer::load_image(QString p_filename, bool p_looping)
void InterfaceLayer::load_image(QString p_filename, QString p_miscname) void InterfaceLayer::load_image(QString p_filename, QString p_miscname)
{ {
transform_mode = ao_app->get_misc_scaling(p_miscname); stretch = true;
QList<QString> pathlist = { QList<QString> pathlist = {
ao_app->get_image_suffix(ao_app->get_theme_path( ao_app->get_image_suffix(ao_app->get_theme_path(
"misc/" + p_miscname + "/" + "misc/" + p_miscname + "/" +
@ -371,12 +342,9 @@ void AOLayer::start_playback(QString p_image)
int l_delay = m_reader.nextImageDelay(); int l_delay = m_reader.nextImageDelay();
movie_frames.append(l_pixmap); movie_frames.append(l_pixmap);
movie_delays.append(l_delay); movie_delays.append(l_delay);
// qDebug() << "appending delay of " << l_delay;
} }
} }
last_path = p_image; last_path = p_image;
// qDebug() << "CONT: " << continuous << " MAX: " << max_frames
// << " LAST MAX: " << last_max_frames << " FRAME: " << frame;
QPixmap f_pixmap = this->get_pixmap(m_reader.read()); QPixmap f_pixmap = this->get_pixmap(m_reader.read());
int f_delay = m_reader.nextImageDelay(); int f_delay = m_reader.nextImageDelay();

View File

@ -44,7 +44,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_viewport = new QWidget(this); ui_viewport = new QWidget(this);
ui_vp_background = new BackgroundLayer(ui_viewport, ao_app); ui_vp_background = new BackgroundLayer(ui_viewport, ao_app);
ui_vp_speedlines = new ForegroundLayer(ui_viewport, ao_app); ui_vp_speedlines = new SplashLayer(ui_viewport, ao_app);
ui_vp_player_char = new CharLayer(ui_viewport, ao_app); ui_vp_player_char = new CharLayer(ui_viewport, ao_app);
ui_vp_sideplayer_char = new CharLayer(ui_viewport, ao_app); ui_vp_sideplayer_char = new CharLayer(ui_viewport, ao_app);
ui_vp_sideplayer_char->hide(); ui_vp_sideplayer_char->hide();
@ -67,13 +67,18 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_vp_message->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); ui_vp_message->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui_vp_message->setReadOnly(true); ui_vp_message->setReadOnly(true);
ui_vp_testimony = new InterfaceLayer(this, ao_app); ui_vp_testimony = new SplashLayer(this, ao_app);
ui_vp_testimony->set_play_once(false); ui_vp_testimony->set_play_once(false);
ui_vp_testimony->setAttribute(Qt::WA_TransparentForMouseEvents); ui_vp_testimony->setAttribute(Qt::WA_TransparentForMouseEvents);
ui_vp_wtce = new InterjectionLayer(this, ao_app); ui_vp_wtce = new SplashLayer(this, ao_app);
ui_vp_wtce->set_play_once(true); ui_vp_wtce->set_play_once(true);
ui_vp_wtce->continuous = false;
ui_vp_wtce->force_continuous = true;
ui_vp_wtce->setAttribute(Qt::WA_TransparentForMouseEvents); ui_vp_wtce->setAttribute(Qt::WA_TransparentForMouseEvents);
ui_vp_objection = new InterjectionLayer(this, ao_app); ui_vp_objection = new SplashLayer(this, ao_app);
ui_vp_objection->set_play_once(true);
ui_vp_objection->continuous = false;
ui_vp_objection->force_continuous = true;
ui_vp_objection->setAttribute(Qt::WA_TransparentForMouseEvents); ui_vp_objection->setAttribute(Qt::WA_TransparentForMouseEvents);
ui_ic_chatlog = new QTextEdit(this); ui_ic_chatlog = new QTextEdit(this);
@ -115,6 +120,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_music_display = new InterfaceLayer(this, ao_app); ui_music_display = new InterfaceLayer(this, ao_app);
ui_music_display->set_play_once(false); ui_music_display->set_play_once(false);
ui_music_display->transform_mode = Qt::SmoothTransformation;
ui_music_display->setAttribute(Qt::WA_TransparentForMouseEvents); ui_music_display->setAttribute(Qt::WA_TransparentForMouseEvents);
ui_music_name = new ScrollText(ui_music_display); ui_music_name = new ScrollText(ui_music_display);
@ -1998,6 +2004,7 @@ void Courtroom::chatmessage_dequeue()
QString f_char = m_chatmessage[CHAR_NAME]; QString f_char = m_chatmessage[CHAR_NAME];
f_custom_theme = ao_app->get_chat(f_char); f_custom_theme = ao_app->get_chat(f_char);
} }
ui_vp_chat_arrow->transform_mode = ao_app->get_misc_scaling(f_custom_theme);
ui_vp_chat_arrow->load_image("chat_arrow", f_custom_theme); ui_vp_chat_arrow->load_image("chat_arrow", f_custom_theme);
// Nothing to parse in the queue // Nothing to parse in the queue
@ -2592,18 +2599,16 @@ void Courtroom::initialize_chatbox()
// This should probably be called only if any change from the last chat // This should probably be called only if any change from the last chat
// arrow was actually detected. // arrow was actually detected.
if (current_misc != last_misc) { pos_size_type design_ini_result = ao_app->get_element_dimensions(
pos_size_type design_ini_result = ao_app->get_element_dimensions( "chat_arrow", "courtroom_design.ini", customchar);
"chat_arrow", "courtroom_design.ini", customchar); if (design_ini_result.width < 0 || design_ini_result.height < 0) {
if (design_ini_result.width < 0 || design_ini_result.height < 0) { qDebug() << "W: could not find \"chat_arrow\" in courtroom_design.ini";
qDebug() << "W: could not find \"chat_arrow\" in courtroom_design.ini"; ui_vp_chat_arrow->hide();
ui_vp_chat_arrow->hide(); }
} else {
else { ui_vp_chat_arrow->move(design_ini_result.x + ui_vp_chatbox->x(), design_ini_result.y + ui_vp_chatbox->y());
ui_vp_chat_arrow->move(design_ini_result.x + ui_vp_chatbox->x(), design_ini_result.y + ui_vp_chatbox->y()); ui_vp_chat_arrow->combo_resize(design_ini_result.width,
ui_vp_chat_arrow->combo_resize(design_ini_result.width, design_ini_result.height);
design_ini_result.height);
}
} }
pos_size_type default_width = ao_app->get_element_dimensions( pos_size_type default_width = ao_app->get_element_dimensions(
@ -2719,7 +2724,7 @@ void Courtroom::handle_ic_speaking()
filename = "prosecution_speedlines"; filename = "prosecution_speedlines";
else else
filename = "defense_speedlines"; filename = "defense_speedlines";
ui_vp_speedlines->load_image(filename, m_chatmessage[CHAR_NAME]); ui_vp_speedlines->load_image(filename, m_chatmessage[CHAR_NAME], ao_app->get_char_shouts(m_chatmessage[CHAR_NAME]));
} }
// Check if this is a talking color (white text, etc.) // Check if this is a talking color (white text, etc.)
@ -3308,12 +3313,14 @@ void Courtroom::chat_tick()
f_char = m_chatmessage[CHAR_NAME]; f_char = m_chatmessage[CHAR_NAME];
f_custom_theme = ao_app->get_chat(f_char); f_custom_theme = ao_app->get_chat(f_char);
} }
ui_vp_chat_arrow->load_image("chat_arrow",f_custom_theme); // Chat stopped being processed, indicate that. ui_vp_chat_arrow->transform_mode = ao_app->get_misc_scaling(f_custom_theme);
ui_vp_chat_arrow->load_image("chat_arrow", f_custom_theme); // Chat stopped being processed, indicate that.
additive_previous = additive_previous =
additive_previous + additive_previous +
filter_ic_text(f_message, true, -1, m_chatmessage[TEXT_COLOR].toInt()); filter_ic_text(f_message, true, -1, m_chatmessage[TEXT_COLOR].toInt());
QString f_message_filtered = filter_ic_text(f_message, true, -1, m_chatmessage[TEXT_COLOR].toInt()); QString f_message_filtered = filter_ic_text(f_message, true, -1, m_chatmessage[TEXT_COLOR].toInt());
for (int c = 0; c < max_colors; ++c) { for (int c = 0; c < max_colors; ++c) {
additive_previous = additive_previous.replace("$c" + QString::number(c), char_color_rgb_list.at(c).name(QColor::HexRgb));
f_message_filtered = f_message_filtered.replace("$c" + QString::number(c), char_color_rgb_list.at(c).name(QColor::HexRgb)); f_message_filtered = f_message_filtered.replace("$c" + QString::number(c), char_color_rgb_list.at(c).name(QColor::HexRgb));
} }
additive_previous = additive_previous + f_message_filtered; additive_previous = additive_previous + f_message_filtered;
@ -3448,6 +3455,7 @@ void Courtroom::chat_tick()
// Do the colors, gradual showing, etc. in here // Do the colors, gradual showing, etc. in here
QString f_message_filtered = filter_ic_text(f_message, true, tick_pos, m_chatmessage[TEXT_COLOR].toInt()); QString f_message_filtered = filter_ic_text(f_message, true, tick_pos, m_chatmessage[TEXT_COLOR].toInt());
for (int c = 0; c < max_colors; ++c) { for (int c = 0; c < max_colors; ++c) {
additive_previous = additive_previous.replace("$c" + QString::number(c), char_color_rgb_list.at(c).name(QColor::HexRgb));
f_message_filtered = f_message_filtered.replace("$c" + QString::number(c), char_color_rgb_list.at(c).name(QColor::HexRgb)); f_message_filtered = f_message_filtered.replace("$c" + QString::number(c), char_color_rgb_list.at(c).name(QColor::HexRgb));
} }
ui_vp_message->setHtml(additive_previous + f_message_filtered); ui_vp_message->setHtml(additive_previous + f_message_filtered);
@ -3772,6 +3780,7 @@ void Courtroom::handle_song(QStringList *p_contents)
void Courtroom::handle_wtce(QString p_wtce, int variant) void Courtroom::handle_wtce(QString p_wtce, int variant)
{ {
QString sfx_file = "courtroom_sounds.ini"; QString sfx_file = "courtroom_sounds.ini";
QString bg_misc = ao_app->read_design_ini("misc", ao_app->get_background_path("design.ini"));
QString sfx_name; QString sfx_name;
QString filename; QString filename;
ui_vp_wtce->set_static_duration(wtce_static_time); ui_vp_wtce->set_static_duration(wtce_static_time);
@ -3780,7 +3789,7 @@ void Courtroom::handle_wtce(QString p_wtce, int variant)
if (p_wtce == "testimony1") { if (p_wtce == "testimony1") {
sfx_name = "witness_testimony"; sfx_name = "witness_testimony";
filename = "witnesstestimony"; filename = "witnesstestimony";
ui_vp_testimony->load_image("testimony", ""); ui_vp_testimony->load_image("testimony", "", bg_misc);
} }
// cross examination // cross examination
else if (p_wtce == "testimony2") { else if (p_wtce == "testimony2") {
@ -3802,7 +3811,6 @@ void Courtroom::handle_wtce(QString p_wtce, int variant)
ui_vp_testimony->stop(); ui_vp_testimony->stop();
} }
} }
QString bg_misc = ao_app->read_design_ini("misc", ao_app->get_background_path("design.ini"));
sfx_player->play(ao_app->get_sfx(sfx_name, bg_misc)); sfx_player->play(ao_app->get_sfx(sfx_name, bg_misc));
ui_vp_wtce->load_image(filename, "", bg_misc); ui_vp_wtce->load_image(filename, "", bg_misc);
ui_vp_wtce->set_play_once(true); ui_vp_wtce->set_play_once(true);