diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/aoapplication.cpp | 14 | ||||
| -rw-r--r-- | src/aoevidencebutton.cpp | 2 | ||||
| -rw-r--r-- | src/charselect.cpp | 28 | ||||
| -rw-r--r-- | src/courtroom.cpp | 112 | ||||
| -rw-r--r-- | src/discord_rich_presence.cpp | 4 | ||||
| -rw-r--r-- | src/evidence.cpp | 10 | ||||
| -rw-r--r-- | src/hardware_functions.cpp | 7 | ||||
| -rw-r--r-- | src/networkmanager.cpp | 16 | ||||
| -rw-r--r-- | src/packet_distribution.cpp | 10 |
9 files changed, 140 insertions, 63 deletions
diff --git a/src/aoapplication.cpp b/src/aoapplication.cpp index d7c3e662..4ef1edd3 100644 --- a/src/aoapplication.cpp +++ b/src/aoapplication.cpp @@ -37,9 +37,9 @@ void AOApplication::construct_lobby() w_lobby = new Lobby(this); lobby_constructed = true; - QRect screenGeometry = QApplication::desktop()->screenGeometry(); - int x = (screenGeometry.width()-w_lobby->width()) / 2; - int y = (screenGeometry.height()-w_lobby->height()) / 2; + QRect geometry = QGuiApplication::primaryScreen()->geometry(); + int x = (geometry.width()-w_lobby->width()) / 2; + int y = (geometry.height()-w_lobby->height()) / 2; w_lobby->move(x, y); if (is_discord_enabled()) @@ -72,9 +72,9 @@ void AOApplication::construct_courtroom() w_courtroom = new Courtroom(this); courtroom_constructed = true; - QRect screenGeometry = QApplication::desktop()->screenGeometry(); - int x = (screenGeometry.width()-w_courtroom->width()) / 2; - int y = (screenGeometry.height()-w_courtroom->height()) / 2; + QRect geometry = QGuiApplication::primaryScreen()->geometry(); + int x = (geometry.width()-w_courtroom->width()) / 2; + int y = (geometry.height()-w_courtroom->height()) / 2; w_courtroom->move(x, y); } @@ -161,7 +161,7 @@ void AOApplication::ms_connect_finished(bool connected, bool will_retry) { if (lobby_constructed) w_lobby->append_error("Error connecting to master server. Will try again in " - + QString::number(net_manager->ms_reconnect_delay_ms / 1000.f) + " seconds."); + + QString::number(net_manager->ms_reconnect_delay) + " seconds."); } else { diff --git a/src/aoevidencebutton.cpp b/src/aoevidencebutton.cpp index 924aeb88..15b598fc 100644 --- a/src/aoevidencebutton.cpp +++ b/src/aoevidencebutton.cpp @@ -86,6 +86,7 @@ void AOEvidenceButton::mouseDoubleClickEvent(QMouseEvent *e) evidence_double_clicked(m_id); } +/* void AOEvidenceButton::dragLeaveEvent(QMouseEvent *e) { //QWidget::dragLeaveEvent(e); @@ -99,6 +100,7 @@ void AOEvidenceButton::dragEnterEvent(QMouseEvent *e) qDebug() << "drag enter event"; } +*/ void AOEvidenceButton::enterEvent(QEvent * e) { diff --git a/src/charselect.cpp b/src/charselect.cpp index 8e1b9122..4987cf57 100644 --- a/src/charselect.cpp +++ b/src/charselect.cpp @@ -44,7 +44,6 @@ void Courtroom::construct_char_select() set_size_and_pos(ui_char_buttons, "char_buttons"); - connect (char_button_mapper, SIGNAL(mapped(int)), this, SLOT(char_clicked(int))); connect(ui_back_to_lobby, SIGNAL(clicked()), this, SLOT(on_back_to_lobby_clicked())); connect(ui_char_select_left, SIGNAL(clicked()), this, SLOT(on_char_select_left_clicked())); @@ -52,9 +51,9 @@ void Courtroom::construct_char_select() connect(ui_spectator, SIGNAL(clicked()), this, SLOT(on_spectator_clicked())); - connect(ui_char_search, SIGNAL(textEdited(const QString&)), this, SLOT(on_char_search_changed(const QString&))); - connect(ui_char_passworded, SIGNAL(stateChanged(int)), this, SLOT(on_char_passworded_clicked(int))); - connect(ui_char_taken, SIGNAL(stateChanged(int)), this, SLOT(on_char_taken_clicked(int))); + connect(ui_char_search, SIGNAL(textEdited(const QString&)), this, SLOT(on_char_search_changed())); + connect(ui_char_passworded, SIGNAL(stateChanged(int)), this, SLOT(on_char_passworded_clicked())); + connect(ui_char_taken, SIGNAL(stateChanged(int)), this, SLOT(on_char_taken_clicked())); } void Courtroom::set_char_select() @@ -197,14 +196,15 @@ void Courtroom::character_loading_finished() // Later on, we'll be revealing buttons as we need them. for (int n = 0; n < char_list.size(); n++) { - AOCharButton* character = new AOCharButton(ui_char_buttons, ao_app, 0, 0, char_list.at(n).taken); - character->reset(); - character->hide(); - character->set_image(char_list.at(n).name); - ui_char_button_list.append(character); + AOCharButton* char_button = new AOCharButton(ui_char_buttons, ao_app, 0, 0, char_list.at(n).taken); + char_button->reset(); + char_button->hide(); + char_button->set_image(char_list.at(n).name); + ui_char_button_list.append(char_button); - connect(character, SIGNAL(clicked()), char_button_mapper, SLOT(map())); - char_button_mapper->setMapping(character, ui_char_button_list.size() - 1); + connect(char_button, &AOCharButton::clicked, [this, n](){ + this->char_clicked(n); + }); // This part here serves as a way of showing to the player that the game is still running, it is // just loading the pictures of the characters. @@ -252,17 +252,17 @@ void Courtroom::filter_character_list() set_char_select_page(); } -void Courtroom::on_char_search_changed(const QString& newtext) +void Courtroom::on_char_search_changed() { filter_character_list(); } -void Courtroom::on_char_passworded_clicked(int newstate) +void Courtroom::on_char_passworded_clicked() { filter_character_list(); } -void Courtroom::on_char_taken_clicked(int newstate) +void Courtroom::on_char_taken_clicked() { filter_character_list(); } diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 6a5379aa..dd6aedcb 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -6,7 +6,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() #ifdef BASSAUDIO // Change the default audio output device to be the one the user has given // in his config.ini file for now. - int a = 0; + unsigned int a = 0; BASS_DEVICEINFO info; if (ao_app->get_audio_output_device() == "default") @@ -21,7 +21,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() if (ao_app->get_audio_output_device() == info.name) { BASS_SetDevice(a); - BASS_Init(a, 48000, BASS_DEVICE_LATENCY, nullptr, nullptr); + BASS_Init(static_cast<int>(a), 48000, BASS_DEVICE_LATENCY, nullptr, nullptr); load_bass_opus_plugin(); qDebug() << info.name << "was set as the default audio output device."; break; @@ -50,8 +50,6 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() testimony_hide_timer = new QTimer(this); testimony_hide_timer->setSingleShot(true); - char_button_mapper = new QSignalMapper(this); - music_player = new AOMusicPlayer(this, ao_app); music_player->set_volume(0); sfx_player = new AOSfxPlayer(this, ao_app); @@ -2025,6 +2023,7 @@ void Courtroom::chat_tick() //do not perform heavy operations here QString f_message = m_chatmessage[MESSAGE]; + f_message.remove(0, tick_pos); // Due to our new text speed system, we always need to stop the timer now. chat_tick_timer->stop(); @@ -2039,7 +2038,7 @@ void Courtroom::chat_tick() f_message.remove(0,2); } - if (tick_pos >= f_message.size()) + if (f_message.size() == 0) { text_state = 2; if (anim_state != 4) @@ -2051,9 +2050,21 @@ void Courtroom::chat_tick() else { - QString f_character = f_message.at(tick_pos); + QTextBoundaryFinder tbf(QTextBoundaryFinder::Grapheme, f_message); + QString f_character; + int f_char_length; + + tbf.toNextBoundary(); + + if (tbf.position() == -1) + f_character = f_message; + else + f_character = f_message.left(tbf.position()); + + f_char_length = f_character.length(); f_character = f_character.toHtmlEscaped(); + if (f_character == " ") ui_vp_message->insertPlainText(" "); @@ -2146,7 +2157,7 @@ void Courtroom::chat_tick() else { next_character_is_not_special = true; - tick_pos--; + tick_pos -= f_char_length; } } @@ -2167,7 +2178,7 @@ void Courtroom::chat_tick() else { next_character_is_not_special = true; - tick_pos--; + tick_pos -= f_char_length; } } @@ -2211,11 +2222,7 @@ void Courtroom::chat_tick() case INLINE_GREY: ui_vp_message->insertHtml("<font color=\""+ get_text_color("_inline_grey").name() +"\">" + f_character + "</font>"); break; - default: - ui_vp_message->insertHtml(f_character); - break; } - } else { @@ -2266,7 +2273,7 @@ void Courtroom::chat_tick() if(blank_blip) qDebug() << "blank_blip found true"; - if (f_message.at(tick_pos) != ' ' || blank_blip) + if (f_character != ' ' || blank_blip) { if (blip_pos % blip_rate == 0 && !formatting_char) @@ -2278,7 +2285,7 @@ void Courtroom::chat_tick() ++blip_pos; } - ++tick_pos; + tick_pos += f_char_length; // Restart the timer, but according to the newly set speeds, if there were any. // Keep the speed at bay. @@ -2305,6 +2312,7 @@ void Courtroom::chat_tick() } } + void Courtroom::show_testimony() { if (!testimony_in_progress || m_chatmessage[SIDE] != "wit") @@ -2697,6 +2705,7 @@ void Courtroom::on_ooc_return_pressed() } else { + other_charid = -1; append_server_chatmessage("CLIENT", "You are no longer paired with anyone.", "1"); } } @@ -2853,6 +2862,60 @@ void Courtroom::on_ooc_return_pressed() ui_ooc_chat_message->clear(); return; } + else if(ooc_message.startsWith("/save_case")) + { + QStringList command = ooc_message.split(" ", QString::SkipEmptyParts); + + QDir casefolder("base/cases"); + if (!casefolder.exists()) + { + QDir::current().mkdir("base/" + casefolder.dirName()); + append_server_chatmessage("CLIENT", "You don't have a `base/cases/` folder! It was just made for you, but seeing as it WAS just made for you, it's likely that you somehow deleted it.", "1"); + ui_ooc_chat_message->clear(); + return; + } + QStringList caseslist = casefolder.entryList(); + caseslist.removeOne("."); + caseslist.removeOne(".."); + caseslist.replaceInStrings(".ini",""); + + if (command.size() < 3) + { + append_server_chatmessage("CLIENT", "You need to give a filename to save (extension not needed) and the courtroom status!", "1"); + ui_ooc_chat_message->clear(); + return; + } + + + if (command.size() > 3) + { + append_server_chatmessage("CLIENT", "Too many arguments to save a case! You only need a filename without extension and the courtroom status!", "1"); + ui_ooc_chat_message->clear(); + return; + } + QSettings casefile("base/cases/" + command[1] + ".ini", QSettings::IniFormat); + casefile.setValue("author",ui_ooc_chat_name->text()); + casefile.setValue("cmdoc",""); + casefile.setValue("doc", ""); + casefile.setValue("status",command[2]); + casefile.sync(); + for(int i = local_evidence_list.size() - 1; i >= 0; i--) + { + QString clean_evidence_dsc = local_evidence_list[i].description.replace(QRegularExpression("<owner = ...>..."), ""); + clean_evidence_dsc = clean_evidence_dsc.replace(clean_evidence_dsc.lastIndexOf(">"), 1, ""); + casefile.beginGroup(QString::number(i)); + casefile.sync(); + casefile.setValue("name",local_evidence_list[i].name); + casefile.setValue("description",local_evidence_list[i].description); + casefile.setValue("image",local_evidence_list[i].image); + casefile.endGroup(); + } + casefile.sync(); + append_server_chatmessage("CLIENT", "Succesfully saved, edit doc and cmdoc link on the ini!", "1"); + ui_ooc_chat_message->clear(); + return; + + } QStringList packet_contents; packet_contents.append(ui_ooc_chat_name->text()); @@ -2982,6 +3045,7 @@ void Courtroom::on_pair_list_clicked(QModelIndex p_index) QListWidgetItem *f_item = ui_pair_list->item(p_index.row()); QString f_char = f_item->text(); QString real_char; + int f_cid = -1; if (f_char.endsWith(" [x]")) { @@ -2989,17 +3053,19 @@ void Courtroom::on_pair_list_clicked(QModelIndex p_index) f_item->setText(real_char); } else - real_char = f_char; - - int f_cid = -1; - - for (int n_char = 0 ; n_char < char_list.size() ; n_char++) { + real_char = f_char; + for (int n_char = 0 ; n_char < char_list.size() ; n_char++) + { if (char_list.at(n_char).name == real_char) f_cid = n_char; + } } - if (f_cid < 0 || f_cid >= char_list.size()) + + + + if (f_cid < -2 || f_cid >= char_list.size()) { qDebug() << "W: " << real_char << " not present in char_list"; return; @@ -3018,8 +3084,10 @@ void Courtroom::on_pair_list_clicked(QModelIndex p_index) for (int i = 0; i < ui_pair_list->count(); i++) { ui_pair_list->item(i)->setText(sorted_pair_list.at(i)); } - - f_item->setText(real_char + " [x]"); + if(other_charid != -1) + { + f_item->setText(real_char + " [x]"); + } } void Courtroom::on_music_list_double_clicked(QModelIndex p_model) diff --git a/src/discord_rich_presence.cpp b/src/discord_rich_presence.cpp index a310a684..95a824a1 100644 --- a/src/discord_rich_presence.cpp +++ b/src/discord_rich_presence.cpp @@ -12,10 +12,10 @@ Discord::Discord() qInfo() << "Discord RPC ready"; }; handlers.disconnected = [](int errorCode, const char* message) { - qInfo() << "Discord RPC disconnected! " << message; + qInfo() << "Discord RPC disconnected! " << message << errorCode; }; handlers.errored = [](int errorCode, const char* message) { - qWarning() << "Discord RPC errored out! " << message; + qWarning() << "Discord RPC errored out! " << message << errorCode; }; qInfo() << "Initializing Discord RPC"; Discord_Initialize(APPLICATION_ID, &handlers, 1, nullptr); diff --git a/src/evidence.cpp b/src/evidence.cpp index 4e796642..ebef7490 100644 --- a/src/evidence.cpp +++ b/src/evidence.cpp @@ -188,11 +188,12 @@ void Courtroom::on_evidence_image_name_edited() void Courtroom::on_evidence_image_button_clicked() { + QDir dir(ao_app->get_base_path() + "evidence"); QFileDialog dialog(this); dialog.setFileMode(QFileDialog::ExistingFile); dialog.setNameFilter(tr("Images (*.png)")); dialog.setViewMode(QFileDialog::List); - dialog.setDirectory(ao_app->get_base_path() + "evidence"); + dialog.setDirectory(dir); QStringList filenames; @@ -203,13 +204,8 @@ void Courtroom::on_evidence_image_button_clicked() return; QString filename = filenames.at(0); - - QStringList split_filename = filename.split("/"); - - filename = split_filename.at(split_filename.size() - 1); - + filename = dir.relativeFilePath(filename); ui_evidence_image_name->setText(filename); - on_evidence_image_name_edited(); } diff --git a/src/hardware_functions.cpp b/src/hardware_functions.cpp index ebba6ab7..5d6b6ffa 100644 --- a/src/hardware_functions.cpp +++ b/src/hardware_functions.cpp @@ -5,12 +5,12 @@ #if (defined (_WIN32) || defined (_WIN64)) #include <windows.h> -DWORD dwVolSerial; -BOOL bIsRetrieved; +static DWORD dwVolSerial; +static BOOL bIsRetrieved; QString get_hdid() { - bIsRetrieved = GetVolumeInformation(TEXT("C:\\"), NULL, NULL, &dwVolSerial, NULL, NULL, NULL, NULL); + bIsRetrieved = GetVolumeInformation(TEXT("C:\\"), nullptr, 0, &dwVolSerial, nullptr, nullptr, nullptr, 0); if (bIsRetrieved) return QString::number(dwVolSerial, 16); @@ -18,7 +18,6 @@ QString get_hdid() //a totally random string //what could possibly go wrong return "gxsps32sa9fnwic92mfbs0"; - } #elif (defined (LINUX) || defined (__linux__)) diff --git a/src/networkmanager.cpp b/src/networkmanager.cpp index 288a9007..5b16db40 100644 --- a/src/networkmanager.cpp +++ b/src/networkmanager.cpp @@ -78,9 +78,9 @@ void NetworkManager::ship_server_packet(QString p_packet) void NetworkManager::handle_ms_packet() { - char buffer[buffer_max_size]; - std::memset(buffer, 0, buffer_max_size); - ms_socket->read(buffer, buffer_max_size); + char buffer[BUFFER_MAX_SIZE]; + std::memset(buffer, 0, BUFFER_MAX_SIZE); + ms_socket->read(buffer, BUFFER_MAX_SIZE); QString in_data = buffer; @@ -137,7 +137,9 @@ void NetworkManager::on_srv_lookup() for (const QDnsServiceRecord &record : srv_records) { +#ifdef DEBUG_NETWORK qDebug() << "Connecting to " << record.target() << ":" << record.port(); +#endif ms_socket->connectToHost(record.target(), record.port()); QTime timer; timer.start(); @@ -206,7 +208,7 @@ void NetworkManager::on_ms_socket_error(QAbstractSocket::SocketError error) emit ms_connect_finished(false, true); - ms_reconnect_timer->start(ms_reconnect_delay_ms); + ms_reconnect_timer->start(ms_reconnect_delay * 1000); } void NetworkManager::retry_ms_connect() @@ -217,9 +219,9 @@ void NetworkManager::retry_ms_connect() void NetworkManager::handle_server_packet() { - char buffer[buffer_max_size]; - std::memset(buffer, 0, buffer_max_size); - server_socket->read(buffer, buffer_max_size); + char buffer[BUFFER_MAX_SIZE]; + std::memset(buffer, 0, BUFFER_MAX_SIZE); + server_socket->read(buffer, BUFFER_MAX_SIZE); QString in_data = buffer; diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index 68d2fb9b..942c275d 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -14,8 +14,10 @@ void AOApplication::ms_packet_received(AOPacket *p_packet) QString header = p_packet->get_header(); QStringList f_contents = p_packet->get_contents(); +#ifdef DEBUG_NETWORK if (header != "CHECK") qDebug() << "R(ms):" << p_packet->to_string(); +#endif if (header == "ALL") { @@ -127,8 +129,10 @@ void AOApplication::server_packet_received(AOPacket *p_packet) QStringList f_contents = p_packet->get_contents(); QString f_packet = p_packet->to_string(); +#ifdef DEBUG_NETWORK if (header != "checkconnection") qDebug() << "R:" << f_packet; +#endif if (header == "decryptor") { @@ -677,7 +681,9 @@ void AOApplication::send_ms_packet(AOPacket *p_packet) net_manager->ship_ms_packet(f_packet); +#ifdef DEBUG_NETWORK qDebug() << "S(ms):" << f_packet; +#endif delete p_packet; } @@ -691,14 +697,18 @@ void AOApplication::send_server_packet(AOPacket *p_packet, bool encoded) if (encryption_needed) { +#ifdef DEBUG_NETWORK qDebug() << "S(e):" << f_packet; +#endif p_packet->encrypt_header(s_decryptor); f_packet = p_packet->to_string(); } else { +#ifdef DEBUG_NETWORK qDebug() << "S:" << f_packet; +#endif } net_manager->ship_server_packet(f_packet); |
