When the background is changed, display it in the correct position as dictated by the server packets

Add a new "set pos" packet
Udpate the pos dropdown according to the current pos
This commit is contained in:
Crystalwarrior 2019-09-24 00:38:26 +03:00
parent 398f37794f
commit d8857aa2e4
3 changed files with 58 additions and 10 deletions

View File

@ -150,6 +150,9 @@ public:
//sets the current background to argument. also does some checks to see if it's a legacy bg
void set_background(QString p_background);
//sets the local character pos/side to use.
void set_side(QString p_side);
//sets the evidence list member variable to argument
void set_evidence_list(QVector<evi_type> &p_evi_list);
@ -412,6 +415,7 @@ private:
bool server_ooc = true;
QString current_background = "default";
QString current_side = "";
AOMusicPlayer *music_player;
AOSfxPlayer *sfx_player;

View File

@ -1005,15 +1005,44 @@ void Courtroom::set_background(QString p_background)
set_size_and_pos(ui_ic_chat_message, "ic_chat_message");
}
// ui_vp_speedlines->stop();
// ui_vp_player_char->stop();
// ui_vp_sideplayer_char->stop();
// ui_vp_effect->stop();
// ui_vp_message->hide();
// ui_vp_chatbox->hide();
// set_scene(ao_app->get_char_side(current_char), QString::number(ao_app->get_desk_mod(current_char, current_emote)));
ui_vp_speedlines->stop();
ui_vp_player_char->stop();
ui_vp_sideplayer_char->stop();
ui_vp_effect->stop();
ui_vp_message->hide();
ui_vp_chatbox->hide();
set_scene(QString::number(ao_app->get_desk_mod(current_char, current_emote)), current_side);
}
void Courtroom::set_side(QString p_side)
{
if (p_side == "")
current_side = ao_app->get_char_side(current_char);
else
current_side = p_side;
qDebug() << current_side;
for (int i = 0; i < ui_pos_dropdown->count(); ++i)
{
QString pos = ui_pos_dropdown->itemText(i);
if (pos == current_side)
{
//Block the signals to prevent setCurrentIndex from triggering a pos change
ui_pos_dropdown->blockSignals(true);
//Set the index on dropdown ui element to let you know what pos you're on right now
ui_pos_dropdown->setCurrentIndex(i);
//Unblock the signals so the element can be used for setting pos again
ui_pos_dropdown->blockSignals(false);
//alright we dun, jobs done here boyos
break;
}
}
}
void Courtroom::update_character(int p_cid)
{
bool newchar = m_cid != p_cid;
@ -1052,7 +1081,9 @@ void Courtroom::update_character(int p_cid)
set_sfx_dropdown();
set_effects_dropdown();
QString side = ao_app->get_char_side(f_char);
QString side = current_side;
if (side == "")
side = ao_app->get_char_side(current_char);
if (side == "jud")
{
@ -1320,7 +1351,9 @@ void Courtroom::on_chat_return_pressed()
QStringList packet_contents;
QString f_side = ao_app->get_char_side(current_char);
QString f_side = current_side;
if (f_side == "")
f_side = ao_app->get_char_side(current_char);
QString f_desk_mod = "chat";
@ -2946,7 +2979,6 @@ void Courtroom::handle_song(QStringList *p_contents)
crossfade = p_contents->at(5) == "1"; //let the music player handle it if it's bigger than the channel list
}
qDebug() << f_song << channel << p_contents->at(3) << looping;
music_player->set_looping(looping, channel);
music_player->play(f_song, channel, crossfade);
if (channel == 0)

View File

@ -594,8 +594,20 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
goto end;
if (courtroom_constructed)
{
if (f_contents.size() >= 2) //We have a pos included in the background packet!
w_courtroom->set_side(f_contents.at(1));
w_courtroom->set_background(f_contents.at(0));
}
}
else if (header == "SP")
{
if (f_contents.size() < 1)
goto end;
if (courtroom_constructed) //We were sent a "set position" packet
w_courtroom->set_side(f_contents.at(0));
}
//server accepting char request(CC) packet
else if (header == "PV")
{