1313#include < QBrush>
1414#include < QTextCharFormat>
1515#include < QFont>
16+ #include < QPropertyAnimation>
1617
1718Courtroom::Courtroom (AOApplication *p_ao_app) : QMainWindow()
1819{
@@ -66,6 +67,16 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
6667 ui_vp_desk = new AOScene (ui_viewport, ao_app);
6768 ui_vp_legacy_desk = new AOScene (ui_viewport, ao_app);
6869
70+ ui_vp_music_display_a = new AOImage (this , ao_app);
71+ ui_vp_music_display_b = new AOImage (this , ao_app);
72+ ui_vp_music_area = new QWidget (ui_vp_music_display_a);
73+ ui_vp_music_name = new QTextEdit (ui_vp_music_area);
74+ ui_vp_music_name->setText (" hewwo OwO" );
75+ ui_vp_music_name->setFrameStyle (QFrame::NoFrame);
76+ ui_vp_music_name->setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
77+ ui_vp_music_name->setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
78+ ui_vp_music_name->setReadOnly (true );
79+
6980 ui_vp_evidence_display = new AOEvidenceDisplay (this , ao_app);
7081
7182 ui_vp_chatbox = new AOImage (this , ao_app);
@@ -391,6 +402,18 @@ void Courtroom::set_widgets()
391402 set_size_and_pos (ui_vp_chatbox, " chatbox" );
392403 }
393404
405+ set_size_and_pos (ui_vp_music_area, " music_area" );
406+ ui_vp_music_area->show ();
407+ set_size_and_pos (ui_vp_music_name, " music_name" );
408+
409+ set_size_and_pos (ui_vp_music_display_a, " music_display_a" );
410+ ui_vp_music_display_a->set_image (" music_display_a.png" );
411+ ui_vp_music_display_a->show ();
412+
413+ set_size_and_pos (ui_vp_music_display_b, " music_display_b" );
414+ ui_vp_music_display_b->set_image (" music_display_b.png" );
415+ ui_vp_music_display_b->show ();
416+
394417 ui_ic_chat_message->setStyleSheet (" QLineEdit{background-color: rgba(100, 100, 100, 255);}" );
395418
396419 ui_vp_chatbox->set_image (" chatmed.png" );
@@ -541,6 +564,8 @@ void Courtroom::set_widgets()
541564 ui_char_select_right->set_image (" arrow_right.png" );
542565
543566 set_size_and_pos (ui_spectator, " spectator" );
567+
568+ handle_music_anim (ui_vp_music_name, " music_name" , " music_area" );
544569}
545570
546571void Courtroom::set_fonts ()
@@ -551,6 +576,7 @@ void Courtroom::set_fonts()
551576 set_font (ui_ms_chatlog, " ms_chatlog" );
552577 set_font (ui_server_chatlog, " server_chatlog" );
553578 set_font (ui_music_list, " music_list" );
579+ set_font (ui_vp_music_name, " music_name" );
554580}
555581
556582void Courtroom::set_font (QWidget *widget, QString p_identifier)
@@ -559,19 +585,47 @@ void Courtroom::set_font(QWidget *widget, QString p_identifier)
559585 int f_weight = ao_app->get_font_size (p_identifier, design_file);
560586 QString class_name = widget->metaObject ()->className ();
561587
562- widget->setFont (QFont (" Sans" , f_weight));
588+ QString font_name = ao_app->get_font_name (" font_" + p_identifier, design_file);
589+
590+ widget->setFont (QFont (font_name, f_weight));
563591
564592 QColor f_color = ao_app->get_color (p_identifier + " _color" , design_file);
565593
594+ int bold = ao_app->get_font_size (p_identifier + " _bold" , design_file); // is the font bold or not?
595+
596+ QString is_bold = " " ;
597+ if (bold == 1 ) is_bold = " bold" ;
598+
566599 QString style_sheet_string = class_name + " { background-color: rgba(0, 0, 0, 0);\n " +
567600 " color: rgba(" +
568601 QString::number (f_color.red ()) + " , " +
569602 QString::number (f_color.green ()) + " , " +
570- QString::number (f_color.blue ()) + " , 255); }" ;
603+ QString::number (f_color.blue ()) + " , 255);\n "
604+ " font: " + is_bold + " ; }" ;
571605
572606 widget->setStyleSheet (style_sheet_string);
573607}
574608
609+ void Courtroom::handle_music_anim (QWidget *p_widget, QString p_identifier_a, QString p_identifier_b)
610+ {
611+ QString file_a = " courtroom_design.ini" ;
612+ QString file_b = " courtroom_fonts.ini" ;
613+ pos_size_type res_a = ao_app->get_element_dimensions (p_identifier_a, file_a);
614+ pos_size_type res_b = ao_app->get_element_dimensions (p_identifier_b, file_a);
615+ int speed = ao_app->get_font_size (p_identifier_a + " _speed" , file_b);
616+ int nchar = ui_vp_music_name->toPlainText ().size ();
617+
618+ int time = nchar/speed*1000 ;
619+
620+ QPropertyAnimation *animation = new QPropertyAnimation (p_widget, " geometry" );
621+ animation->setLoopCount (-1 );
622+ animation->setDuration (time);
623+ animation->setStartValue (QRect (-res_a.width + res_a.x , res_a.y , res_a.width , res_a.height ));
624+ animation->setEndValue (QRect (res_b.width + res_a.x , res_a.y , res_a.width , res_a.height ));
625+
626+ animation->start ();
627+ }
628+
575629void Courtroom::set_window_title (QString p_title)
576630{
577631 this ->setWindowTitle (p_title);
@@ -923,6 +977,7 @@ void Courtroom::handle_chatmessage(QStringList *p_contents)
923977 for (int n_string = 0 ; n_string < chatmessage_size ; ++n_string)
924978 {
925979 m_chatmessage[n_string] = p_contents->at (n_string);
980+ // qDebug() << "m_chatmessage[" << n_string << "] = " << m_chatmessage[n_string];
926981 }
927982
928983 int f_char_id = m_chatmessage[CHAR_ID].toInt ();
@@ -1156,7 +1211,7 @@ void Courtroom::append_ic_text(QString p_text, QString p_name)
11561211 normal.setFontWeight (QFont::Normal);
11571212 const QTextCursor old_cursor = ui_ic_chatlog->textCursor ();
11581213 const int old_scrollbar_value = ui_ic_chatlog->verticalScrollBar ()->value ();
1159- const bool is_scrolled_up = old_scrollbar_value == ui_ic_chatlog->verticalScrollBar ()->minimum ();
1214+ const bool is_scrolled_up = old_scrollbar_value == ui_ic_chatlog->verticalScrollBar ()->maximum ();
11601215
11611216 ui_ic_chatlog->moveCursor (QTextCursor::Start);
11621217
@@ -1173,7 +1228,7 @@ void Courtroom::append_ic_text(QString p_text, QString p_name)
11731228 {
11741229 // The user hasn't selected any text and the scrollbar is at the top: scroll to the top.
11751230 ui_ic_chatlog->moveCursor (QTextCursor::Start);
1176- ui_ic_chatlog->verticalScrollBar ()->setValue (ui_ic_chatlog->verticalScrollBar ()->minimum ());
1231+ ui_ic_chatlog->verticalScrollBar ()->setValue (ui_ic_chatlog->verticalScrollBar ()->maximum ());
11771232 }
11781233}
11791234
@@ -1535,6 +1590,11 @@ void Courtroom::handle_song(QStringList *p_contents)
15351590 music_player->play (f_song);
15361591 }
15371592 }
1593+
1594+ int pos = f_song.lastIndexOf (QChar (' .' ));
1595+ QString r_song = f_song.left (pos);
1596+
1597+ ui_vp_music_name->setText (r_song);
15381598}
15391599
15401600void Courtroom::handle_wtce (QString p_wtce)
0 commit comments