aboutsummaryrefslogtreecommitdiff
path: root/src/courtroom.cpp
diff options
context:
space:
mode:
authorTrickyLeifa <date.epoch@gmail.com>2024-06-03 18:11:17 +0200
committerTrickyLeifa <date.epoch@gmail.com>2024-06-03 18:11:17 +0200
commita714bacd1aba3e54bf485580d112b42385788c50 (patch)
tree252ce858a688d2025fcdba92036bd6a935a5608f /src/courtroom.cpp
parent5af9dce21481e1d402df701b91593ccde4049c4b (diff)
Added screen slide timer
* Added screen slide timer * Added so that the animation becomes interruptible.
Diffstat (limited to 'src/courtroom.cpp')
-rw-r--r--src/courtroom.cpp27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/courtroom.cpp b/src/courtroom.cpp
index c9c22f18..c2c34219 100644
--- a/src/courtroom.cpp
+++ b/src/courtroom.cpp
@@ -111,6 +111,10 @@ Courtroom::Courtroom(AOApplication *p_ao_app)
ui_vp_objection->setAttribute(Qt::WA_TransparentForMouseEvents);
ui_vp_objection->setObjectName("ui_vp_objection");
+ m_screenshake_anim_group = new QParallelAnimationGroup(this);
+
+ m_screenslide_timer = new kal::ScreenSlideTimer(this);
+
ui_ic_chatlog = new QTextEdit(this);
ui_ic_chatlog->setReadOnly(true);
ui_ic_chatlog->setObjectName("ui_ic_chatlog");
@@ -514,7 +518,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app)
connect(ui_vp_evidence_display, &AOEvidenceDisplay::show_evidence_details, this, &Courtroom::show_evidence);
- connect(transition_animation_group, &QParallelAnimationGroup::finished, this, &Courtroom::finish_transition);
+ connect(m_screenslide_timer, &kal::ScreenSlideTimer::finished, this, &Courtroom::post_transition_cleanup);
set_widgets();
@@ -2502,6 +2506,7 @@ void Courtroom::unpack_chatmessage(QStringList p_contents)
anim_state = 0;
evidence_presented = false;
ui_vp_objection->stopPlayback();
+ m_screenslide_timer->stop();
chat_tick_timer->stop();
ui_vp_evidence_display->reset();
// This chat msg is not objection so we're not waiting on the objection animation to finish to display the character.
@@ -2947,8 +2952,8 @@ void Courtroom::do_screenshake()
// would return to its "final frame" properly. This properly resets all UI
// elements without having to bother keeping track of "origin" positions.
// Works great with the chat text being detached from the chat box!
- screenshake_animation_group->setCurrentTime(screenshake_animation_group->duration());
- screenshake_animation_group->clear();
+ m_screenshake_anim_group->setCurrentTime(m_screenshake_anim_group->duration());
+ m_screenshake_anim_group->clear();
const QList<QWidget *> &affected_list = {ui_vp_background, ui_vp_player_char, ui_vp_sideplayer_char, ui_vp_chatbox};
@@ -2975,10 +2980,10 @@ void Courtroom::do_screenshake()
}
screenshake_animation->setEndValue(pos_default);
screenshake_animation->setEasingCurve(QEasingCurve::Linear);
- screenshake_animation_group->addAnimation(screenshake_animation);
+ m_screenshake_anim_group->addAnimation(screenshake_animation);
}
- screenshake_animation_group->start();
+ m_screenshake_anim_group->start();
}
void Courtroom::do_transition(QString p_desk_mod, QString oldPosId, QString newPosId)
@@ -3020,7 +3025,7 @@ void Courtroom::do_transition(QString p_desk_mod, QString oldPosId, QString newP
ui_vp_dummy_char->setStyleSheet("background-color:rgba(255, 0, 0, 128);");
ui_vp_sidedummy_char->setStyleSheet("background-color:rgba(0, 255, 0, 128);");
- qDebug() << "STARTING TRANSITION, CURRENT TIME:" << transition_animation_group->currentTime();
+ qDebug() << "STARTING TRANSITION";
#endif
set_scene(p_desk_mod.toInt(), oldPosId);
@@ -3039,7 +3044,7 @@ void Courtroom::do_transition(QString p_desk_mod, QString oldPosId, QString newP
transition_animation->setEasingCurve(QEasingCurve::InOutCubic);
transition_animation->setStartValue(QPoint(-scaled_old_pos.x(), 0));
transition_animation->setEndValue(QPoint(-scaled_new_pos.x(), 0));
- transition_animation_group->addAnimation(transition_animation);
+ m_screenslide_timer->addAnimation(transition_animation);
}
auto calculate_offset_and_setup_layer = [&, this](kal::CharacterAnimationLayer *layer, QPoint newPos, QString rawOffset) {
@@ -3110,13 +3115,7 @@ void Courtroom::do_transition(QString p_desk_mod, QString oldPosId, QString newP
ui_vp_sideplayer_char->hide();
}
- QTimer::singleShot(TRANSITION_BOOKEND_DELAY, transition_animation_group, SLOT(start()));
-}
-
-void Courtroom::finish_transition()
-{
- transition_animation_group->clear();
- QTimer::singleShot(TRANSITION_BOOKEND_DELAY, this, SLOT(post_transition_cleanup()));
+ m_screenslide_timer->start();
}
void Courtroom::post_transition_cleanup()