aboutsummaryrefslogtreecommitdiff
path: root/src/lobby.cpp
diff options
context:
space:
mode:
authoroldmud0 <oldmud0@users.noreply.github.com>2021-06-13 22:16:41 -0500
committeroldmud0 <oldmud0@users.noreply.github.com>2021-06-13 22:16:41 -0500
commitb682d69e494acdbf5fc97a81109faa667ad1918f (patch)
treee294c53b113b96438d52ec5e153e5efeb1445643 /src/lobby.cpp
parentfbce4937efdd01791dca7c8a40c14b43ef487365 (diff)
Use new HTTP-based master server client
Diffstat (limited to 'src/lobby.cpp')
-rw-r--r--src/lobby.cpp45
1 files changed, 40 insertions, 5 deletions
diff --git a/src/lobby.cpp b/src/lobby.cpp
index 5cdb94a3..feb922ca 100644
--- a/src/lobby.cpp
+++ b/src/lobby.cpp
@@ -101,6 +101,8 @@ Lobby::Lobby(AOApplication *p_ao_app) : QMainWindow()
ui_connect->setEnabled(false);
list_servers();
+ get_motd();
+ check_for_updates();
set_widgets();
}
@@ -324,9 +326,13 @@ void Lobby::on_refresh_released()
{
ui_refresh->set_image("refresh");
- AOPacket *f_packet = new AOPacket("ALL#%");
-
- ao_app->send_ms_packet(f_packet);
+ if (public_servers_selected) {
+ ao_app->net_manager->get_server_list(std::bind(&Lobby::list_servers, this));
+ get_motd();
+ } else {
+ ao_app->set_favorite_list();
+ list_favorites();
+ }
}
void Lobby::on_add_to_fav_pressed()
@@ -492,9 +498,10 @@ void Lobby::on_chatfield_return_pressed()
QString f_header = "CT";
QStringList f_contents{ui_chatname->text(), ui_chatmessage->text()};
- AOPacket *f_packet = new AOPacket(f_header, f_contents);
+ append_chatmessage("", "Stubbed lmao");
- ao_app->send_ms_packet(f_packet);
+// AOPacket *f_packet = new AOPacket(f_header, f_contents);
+// ao_app->send_ms_packet(f_packet);
ui_chatmessage->clear();
}
@@ -537,6 +544,34 @@ void Lobby::list_favorites()
ui_server_list->setSortingEnabled(true);
}
+void Lobby::get_motd()
+{
+ ao_app->net_manager->request_document(MSDocumentType::Motd,
+ [this](QString document) {
+ if (document.isEmpty())
+ document = tr("Couldn't get the message of the day.");
+ bool isHtml = document.startsWith("<!DOCTYPE", Qt::CaseInsensitive)
+ || document.startsWith("<html>", Qt::CaseInsensitive);
+ if (isHtml) {
+ ui_chatbox->setHtml(document);
+ } else {
+ ui_chatbox->setMarkdown(document);
+ }
+ });
+}
+
+void Lobby::check_for_updates()
+{
+ ao_app->net_manager->request_document(MSDocumentType::ClientVersion,
+ [this](QString version) {
+ const QString current_version = ao_app->get_version_string();
+ if (!version.isEmpty() && version != current_version) {
+ ui_version->setText(tr("Version: %1 (!)").arg(current_version));
+ ui_version->setToolTip(tr("New version available: %1").arg(version));
+ }
+ });
+}
+
void Lobby::append_chatmessage(QString f_name, QString f_message)
{
ui_chatbox->append_chatmessage(