diff --git a/courtroom.cpp b/courtroom.cpp index e97fe3a..1fef052 100644 --- a/courtroom.cpp +++ b/courtroom.cpp @@ -31,6 +31,12 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() realization_timer = new QTimer(this); realization_timer->setSingleShot(true); + testimony_show_timer = new QTimer(this); + testimony_show_timer->setSingleShot(true); + + testimony_hide_timer = new QTimer(this); + testimony_hide_timer->setSingleShot(true); + char_button_mapper = new QSignalMapper(this); music_player = new AOMusicPlayer(this, ao_app); @@ -209,6 +215,8 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() connect(realization_timer, SIGNAL(timeout()), this, SLOT(realization_done())); + connect(testimony_show_timer, SIGNAL(timeout()), this, SLOT(hide_testimony())); + connect(testimony_hide_timer, SIGNAL(timeout()), this, SLOT(show_testimony())); //emote signals are set in emotes.cpp connect(ui_mute_list, SIGNAL(clicked(QModelIndex)), this, SLOT(on_mute_list_clicked(QModelIndex))); @@ -357,6 +365,8 @@ void Courtroom::set_widgets() ui_vp_testimony->move(0, 0); ui_vp_testimony->resize(ui_viewport->width(), ui_viewport->height()); + ui_vp_testimony->set_image("testimony.png"); + ui_vp_testimony->hide(); ui_vp_realization->move(0, 0); ui_vp_realization->resize(ui_viewport->width(), ui_viewport->height()); @@ -676,6 +686,8 @@ void Courtroom::enter_courtroom(int p_cid) ui_sfx_slider->setValue(50); ui_blip_slider->setValue(50); + testimony_in_progress = false; + ui_char_select_background->hide(); ui_ic_chat_message->setEnabled(true); @@ -1165,6 +1177,26 @@ void Courtroom::chat_tick() } } +void Courtroom::show_testimony() +{ + if (!testimony_in_progress || m_chatmessage[SIDE] != "wit") + return; + + ui_vp_testimony->show(); + + testimony_show_timer->start(testimony_show_time); +} + +void Courtroom::hide_testimony() +{ + ui_vp_testimony->hide(); + + if (!testimony_in_progress) + return; + + testimony_hide_timer->start(testimony_hide_time); +} + void Courtroom::play_sfx() { QString sfx_name = m_chatmessage[SFX_NAME]; @@ -1180,6 +1212,9 @@ void Courtroom::play_sfx() void Courtroom::set_scene() { + if (testimony_in_progress) + show_testimony(); + //witness is default if pos is invalid QString f_image = "witnessempty.png"; @@ -1336,12 +1371,15 @@ void Courtroom::handle_wtce(QString p_wtce) { sfx_player->play("sfx-testimony2.wav", ui_sfx_slider->value()); ui_vp_wtce->play("witnesstestimony"); + testimony_in_progress = true; + show_testimony(); } //cross examination else if (p_wtce == "testimony2") { sfx_player->play("sfx-testimony.wav", ui_sfx_slider->value()); ui_vp_wtce->play("crossexamination"); + testimony_in_progress = false; } } diff --git a/courtroom.h b/courtroom.h index 3ffbf54..d1a77d0 100644 --- a/courtroom.h +++ b/courtroom.h @@ -122,6 +122,9 @@ private: QTimer *realization_timer; + QTimer *testimony_show_timer; + QTimer *testimony_hide_timer; + //every time point in char.inis times this equals the final time const int time_mod = 40; @@ -131,6 +134,11 @@ private: QString previous_ic_message = ""; + bool testimony_in_progress = false; + + const int testimony_show_time = 1500; + const int testimony_hide_time = 500; + QMap mute_map; bool is_muted = false; @@ -278,6 +286,9 @@ public slots: void realization_done(); + void show_testimony(); + void hide_testimony(); + private slots: void start_chat_ticking(); void play_sfx();