Merge branch 'master' into pr/104

This commit is contained in:
sD 2020-03-15 13:12:52 +01:00
commit beb469cd80
8 changed files with 162 additions and 40 deletions

View File

@ -58,6 +58,8 @@ public:
void construct_courtroom(); void construct_courtroom();
void destruct_courtroom(); void destruct_courtroom();
bool is_music_track(QString trackname);
void ms_packet_received(AOPacket *p_packet); void ms_packet_received(AOPacket *p_packet);
void server_packet_received(AOPacket *p_packet); void server_packet_received(AOPacket *p_packet);

View File

@ -212,6 +212,9 @@ public:
void append_ms_chatmessage(QString f_name, QString f_message); void append_ms_chatmessage(QString f_name, QString f_message);
void append_server_chatmessage(QString p_name, QString p_message, QString p_colour); void append_server_chatmessage(QString p_name, QString p_message, QString p_colour);
//check whether or not current theme has images for buttons with fallback text
void detect_fallback_text();
//these functions handle chatmessages sequentially. //these functions handle chatmessages sequentially.
//The process itself is very convoluted and merits separate documentation //The process itself is very convoluted and merits separate documentation
//But the general idea is objection animation->pre animation->talking->idle //But the general idea is objection animation->pre animation->talking->idle
@ -415,6 +418,15 @@ private:
//is set to true if the bg folder contains defensedesk.png, prosecutiondesk.png and stand.png //is set to true if the bg folder contains defensedesk.png, prosecutiondesk.png and stand.png
bool is_ao2_bg = false; bool is_ao2_bg = false;
// whether or not to use text for buttons instead of images, true is text
bool change_char_fallback = true;
bool reload_theme_fallback = true;
bool settings_fallback = true;
bool call_mod_fallback = true;
bool casing_fallback = true;
bool amswap_fallback = true;
bool ooc_toggle_fallback = true;
//whether the ooc chat is server or master chat, true is server //whether the ooc chat is server or master chat, true is server
bool server_ooc = true; bool server_ooc = true;

View File

@ -70,7 +70,7 @@ void AOBlipPlayer::set_blips(QString p_sfx)
void AOBlipPlayer::blip_tick() void AOBlipPlayer::blip_tick()
{ {
int f_cycle = m_cycle++; m_cycle++;
if (m_cycle == 5) if (m_cycle == 5)
m_cycle = 0; m_cycle = 0;

View File

@ -208,7 +208,6 @@ void AOCharMovie::play_pre(QString p_char, QString p_emote, int duration)
m_movie->stop(); m_movie->stop();
m_movie->setFileName(gif_path); m_movie->setFileName(gif_path);
m_movie->jumpToFrame(0); m_movie->jumpToFrame(0);
int real_duration = 0;
play_once = true; play_once = true;
play(p_char, p_emote, ""); play(p_char, p_emote, "");
} }

View File

@ -244,7 +244,6 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
ui_audio_device_combobox = new QComboBox(ui_audio_widget); ui_audio_device_combobox = new QComboBox(ui_audio_widget);
// Let's fill out the combobox with the available audio devices. Or don't if there is no audio // Let's fill out the combobox with the available audio devices. Or don't if there is no audio
int a = 0;
if (needs_default_audiodev()) if (needs_default_audiodev())
{ {
@ -253,6 +252,7 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
} }
#ifdef BASSAUDIO #ifdef BASSAUDIO
BASS_DEVICEINFO info; BASS_DEVICEINFO info;
int a = 0;
for (a = 0; BASS_GetDeviceInfo(a, &info); a++) for (a = 0; BASS_GetDeviceInfo(a, &info); a++)
{ {
ui_audio_device_combobox->addItem(info.name); ui_audio_device_combobox->addItem(info.name);

View File

@ -150,6 +150,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_ooc_chat_message = new QLineEdit(this); ui_ooc_chat_message = new QLineEdit(this);
ui_ooc_chat_message->setFrame(false); ui_ooc_chat_message->setFrame(false);
ui_ooc_chat_message->setPlaceholderText(tr("OOC Message"));
ui_ooc_chat_name = new QLineEdit(this); ui_ooc_chat_name = new QLineEdit(this);
ui_ooc_chat_name->setFrame(false); ui_ooc_chat_name->setFrame(false);
@ -367,6 +368,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
set_widgets(); set_widgets();
set_char_select(); set_char_select();
detect_fallback_text();
} }
void Courtroom::set_mute_list() void Courtroom::set_mute_list()
@ -609,7 +611,15 @@ void Courtroom::set_widgets()
ui_take_that->set_image("takethat.png"); ui_take_that->set_image("takethat.png");
set_size_and_pos(ui_ooc_toggle, "ooc_toggle"); set_size_and_pos(ui_ooc_toggle, "ooc_toggle");
if (ooc_toggle_fallback)
{
ui_ooc_toggle->setText(tr("Server")); ui_ooc_toggle->setText(tr("Server"));
}
else
{
ui_ooc_toggle->set_image("ooc_toggle_server.png");
ui_ooc_toggle->setText(tr(""));
}
set_size_and_pos(ui_witness_testimony, "witness_testimony"); set_size_and_pos(ui_witness_testimony, "witness_testimony");
ui_witness_testimony->set_image("witnesstestimony.png"); ui_witness_testimony->set_image("witnesstestimony.png");
@ -622,22 +632,70 @@ void Courtroom::set_widgets()
ui_not_guilty->set_image("notguilty.png"); ui_not_guilty->set_image("notguilty.png");
set_size_and_pos(ui_change_character, "change_character"); set_size_and_pos(ui_change_character, "change_character");
if (change_char_fallback)
{
ui_change_character->setText(tr("Change character")); ui_change_character->setText(tr("Change character"));
}
else
{
ui_change_character->set_image("change_character.png");
ui_change_character->setText(tr("")); // set text to empty otherwise it just sits there
}
set_size_and_pos(ui_reload_theme, "reload_theme"); set_size_and_pos(ui_reload_theme, "reload_theme");
if (reload_theme_fallback)
{
ui_reload_theme->setText(tr("Reload theme")); ui_reload_theme->setText(tr("Reload theme"));
}
else
{
ui_reload_theme->set_image("reload_theme.png");
ui_reload_theme->setText(tr(""));
}
set_size_and_pos(ui_call_mod, "call_mod"); set_size_and_pos(ui_call_mod, "call_mod");
if (call_mod_fallback)
{
ui_call_mod->setText(tr("Call mod")); ui_call_mod->setText(tr("Call mod"));
}
else
{
ui_call_mod->set_image("call_mod.png");
ui_call_mod->setText(tr(""));
}
set_size_and_pos(ui_settings, "settings"); set_size_and_pos(ui_settings, "settings");
if (settings_fallback)
{
ui_settings->setText(tr("Settings")); ui_settings->setText(tr("Settings"));
}
else
{
ui_settings->set_image("settings.png");
ui_settings->setText(tr(""));
}
set_size_and_pos(ui_announce_casing, "casing_button"); set_size_and_pos(ui_announce_casing, "casing_button");
if (casing_fallback)
{
ui_announce_casing->setText(tr("Casing")); ui_announce_casing->setText(tr("Casing"));
}
else
{
ui_announce_casing->set_image("casing.png");
ui_announce_casing->setText(tr(""));
}
set_size_and_pos(ui_switch_area_music, "switch_area_music"); set_size_and_pos(ui_switch_area_music, "switch_area_music");
if (amswap_fallback)
{
ui_switch_area_music->setText(tr("A/M")); ui_switch_area_music->setText(tr("A/M"));
}
else
{
ui_switch_area_music->set_image("amswap.png");
ui_switch_area_music->setText(tr(""));
}
set_size_and_pos(ui_pre, "pre"); set_size_and_pos(ui_pre, "pre");
ui_pre->setText(tr("Preanim")); ui_pre->setText(tr("Preanim"));
@ -1131,6 +1189,32 @@ void Courtroom::append_server_chatmessage(QString p_name, QString p_message, QSt
ui_server_chatlog->append_chatmessage(p_name, p_message, colour); ui_server_chatlog->append_chatmessage(p_name, p_message, colour);
} }
void Courtroom::detect_fallback_text()
{
QString change_char_path = ao_app->get_theme_path("change_character.png");
QString reload_theme_path = ao_app->get_theme_path("reload_theme.png");
QString settings_path = ao_app->get_theme_path("settings.png");
QString call_mod_path = ao_app->get_theme_path("call_mod.png");
QString casing_path = ao_app->get_theme_path("casing.png");
QString amswap_path = ao_app->get_theme_path("amswap.png");
QString ooc_toggle_path = ao_app->get_theme_path("ooc_toggle_ms.png");
if (file_exists(change_char_path)) {change_char_fallback = false;}
else {change_char_fallback = true;}
if (file_exists(reload_theme_path)) {reload_theme_fallback = false;}
else {reload_theme_fallback = true;}
if (file_exists(settings_path)) {settings_fallback = false;}
else {settings_fallback = true;}
if (file_exists(call_mod_path)) {call_mod_fallback = false;}
else {call_mod_fallback = true;}
if (file_exists(casing_path)) {casing_fallback = false;}
else {casing_fallback = true;}
if (file_exists(amswap_path)) {amswap_fallback = false;}
else {amswap_fallback = true;}
if (file_exists(ooc_toggle_path)) {ooc_toggle_fallback = false;}
else {ooc_toggle_fallback = true;}
}
class AOFrameThreadingPre : public QRunnable class AOFrameThreadingPre : public QRunnable
{ {
public: public:
@ -1655,7 +1739,21 @@ void Courtroom::handle_chatmessage_2()
ui_vp_chatbox->set_image("chatmed.png"); ui_vp_chatbox->set_image("chatmed.png");
else else
{ {
QString chatbox_path = ao_app->get_base_path() + "misc/" + chatbox + "/chatbox.png"; QString chatbox_path;
QString misc_path = ao_app->get_base_path() + "misc/" + chatbox + "/chatbox.png";
// support for 2.4 legacy chatboxes
QString legacy_path = ao_app->get_base_path() + "misc/" + chatbox + ".png";
if (file_exists(misc_path))
{
chatbox_path = misc_path;
}
else if (file_exists(legacy_path))
chatbox_path = legacy_path;
else
{
QString default_chatbox_path = ao_app->get_theme_path("chatmed.png");
chatbox_path = default_chatbox_path;
}
ui_vp_chatbox->set_image_from_path(chatbox_path); ui_vp_chatbox->set_image_from_path(chatbox_path);
} }
@ -3300,16 +3398,24 @@ void Courtroom::on_ooc_toggle_clicked()
{ {
ui_ms_chatlog->show(); ui_ms_chatlog->show();
ui_server_chatlog->hide(); ui_server_chatlog->hide();
ui_ooc_toggle->setText(tr(""));
ui_ooc_toggle->set_image("ooc_toggle_ms.png");
if (ooc_toggle_fallback)
{
ui_ooc_toggle->setText(tr("Master")); ui_ooc_toggle->setText(tr("Master"));
}
server_ooc = false; server_ooc = false;
} }
else else
{ {
ui_ms_chatlog->hide(); ui_ms_chatlog->hide();
ui_server_chatlog->show(); ui_server_chatlog->show();
ui_ooc_toggle->setText(tr(""));
ui_ooc_toggle->set_image("ooc_toggle_server.png");
if (ooc_toggle_fallback)
{
ui_ooc_toggle->setText(tr("Server")); ui_ooc_toggle->setText(tr("Server"));
}
server_ooc = true; server_ooc = true;
} }
} }
@ -3750,6 +3856,8 @@ void Courtroom::on_reload_theme_clicked()
//to update status on the background //to update status on the background
set_background(current_background); set_background(current_background);
//to update fallback text bools
detect_fallback_text();
enter_courtroom(m_cid); enter_courtroom(m_cid);
anim_state = 4; anim_state = 4;

View File

@ -151,6 +151,16 @@ void AOApplication::ms_packet_received(AOPacket *p_packet)
delete p_packet; delete p_packet;
} }
bool AOApplication::is_music_track(QString trackname)
{
return (trackname.startsWith("==") ||
trackname.endsWith(".wav") ||
trackname.endsWith(".mp3") ||
trackname.endsWith(".mp4") ||
trackname.endsWith(".ogg") ||
trackname.endsWith(".opus"));
}
void AOApplication::server_packet_received(AOPacket *p_packet) void AOApplication::server_packet_received(AOPacket *p_packet)
{ {
p_packet->net_decode(); p_packet->net_decode();
@ -411,7 +421,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
if (!courtroom_constructed) if (!courtroom_constructed)
goto end; goto end;
bool musics_time = false; bool musiclist_start = false;
int areas = 0; int areas = 0;
for (int n_element = 0 ; n_element < f_contents.size() ; n_element += 2) for (int n_element = 0 ; n_element < f_contents.size() ; n_element += 2)
@ -428,19 +438,15 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
w_lobby->set_loading_text(tr("Loading music:\n%1/%2").arg(QString::number(loaded_music)).arg(QString::number(music_list_size))); w_lobby->set_loading_text(tr("Loading music:\n%1/%2").arg(QString::number(loaded_music)).arg(QString::number(music_list_size)));
if (musics_time) if (musiclist_start)
{ {
w_courtroom->append_music(f_music); w_courtroom->append_music(f_music);
} }
else else
{ {
if (f_music.endsWith(".wav") || if (is_music_track(f_music))
f_music.endsWith(".mp3") ||
f_music.endsWith(".mp4") ||
f_music.endsWith(".ogg") ||
f_music.endsWith(".opus"))
{ {
musics_time = true; musiclist_start = true;
areas--; areas--;
//w_courtroom->fix_last_area(); //w_courtroom->fix_last_area();
w_courtroom->append_music(f_music); w_courtroom->append_music(f_music);
@ -514,22 +520,17 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
if (!courtroom_constructed) if (!courtroom_constructed)
goto end; goto end;
bool musics_time = false; bool musiclist_start = false;
area_count = 0; area_count = 0;
for (int n_element = 0 ; n_element < f_contents.size() ; ++n_element) for (int n_element = 0 ; n_element < f_contents.size() ; ++n_element)
{ {
if (!musics_time && (f_contents.at(n_element).startsWith("==") || if (!musiclist_start && is_music_track(f_contents.at(n_element)))
f_contents.at(n_element).endsWith(".wav") ||
f_contents.at(n_element).endsWith(".mp3") ||
f_contents.at(n_element).endsWith(".mp4") ||
f_contents.at(n_element).endsWith(".ogg") ||
f_contents.at(n_element).endsWith(".opus")))
{ {
musics_time = true; musiclist_start = true;
continue; continue;
} }
AOPacketLoadMusicThreading *music_load = new AOPacketLoadMusicThreading(this, f_contents.at(n_element), musics_time); AOPacketLoadMusicThreading *music_load = new AOPacketLoadMusicThreading(this, f_contents.at(n_element), musiclist_start);
QThreadPool::globalInstance()->start(music_load); QThreadPool::globalInstance()->start(music_load);
++loaded_music; ++loaded_music;
int total_loading_size = char_list_size * 2 + evidence_list_size + music_list_size; int total_loading_size = char_list_size * 2 + evidence_list_size + music_list_size;