Skip to content

Commit ce59433

Browse files
SalantoTrickyLeifastonedDiscordoldmud0Crystalwarrior
committed
Cleanup lobby (#880)
* Remove config loading from AOApplications Removes most, but not all config functions from AOApplication and moves them into their own class. Not even remotely done here. but holy shit I'm tired. * First steps towards UI file * Fixed your UI layout issue * Leifa bullies me * Set all the setters Reminder : Figure out why username and ooc_name exist. Are they the same? Maybe. Maybe not. Gonna have to look at it and migrate the key. Todo : Cleanup key naming. Most of these are terrible, imprecise or I just don't like them. * Make layout appear proper * Minor option dialog update * Hookup AOOptionsdialogue to Options Getter/setter Not done yet, but parts of the options interactions work again. * More settings menu working * Mostly working settings dialogue Restore default and cancel still need work * Fix asset widget * Tooltips Also removes the commented out tooltip code * Finish Tooltips Move widget implementation to its own folder * Migrate callwords to config.ini Also correct sleep deprived code. * Fix widget translation * Language dropdown changes We might want to look into doing this a bit better. * Remove QSettings from AOApplication Try cleaning up stray references to said object anymore * Fix constructor order to prevent runtime crash * Slightly sort implementation file * Remove unused label declarations from header Fix some comments * Formatting * Fix buttons Also fixes restore settings when a restore to default is aborted. * Raise pair list after courtroom construction (#859) * Don't reset evidence selection (#860) They are defaulted in the header. This SHOULD not affect the client negatively. * Hitting the emergency exit (#861) Don't change the widget state when the ID exceeds the current widget list due to pages being changed while evidence is being edited. * add CI and license badge * add contributors * Handle config.temp after confirmation * Deletes config.temp when the user has confirmed they want to keep the current settings. * Make reset to default destructive Don't worry, we ask first! :) * Fix case of self_offset received without a y offset (#864) caused by typos in #701 it's possible for older clients to send x offsets without a y offset. if you think this case is annoying you can remove it in the next version and handle it server-side instead * Change default settings (#839) * Make default config enable features for most cases except for Continuous Playback due to it introducing performance issues according to tooltip and confirmed in testing * Increase log size to 1000 * Default disable animated themes Co-authored-by: Salanto <62221668+Salanto@users.noreply.github.com> Co-authored-by: stonedDiscord <Tukz@gmx.de> * Make it a singleton? Maybe? I dunno? Ask Longbyte * Commit suggestions * More suggestions Also try fixing a memory leak. Not going to well. * Return to dialog Otherwise we don't have Exec. * Cleanup * Deprecate ooc_name, implement username * Remove ooc_name key and copy its value to default_showname if its empty. * Consistent naming in AOOptionsDialog * Clang format * Don't write the username to the showname * Fix theme dropdown being incorrectly set * Bandaid callword playing every message * Remove unused or duplicate includes * More include removals Removes lobby and courtroom direct includes from the dialog source * Burn baby, burn! * Remove reload_theme function * Remove "Case Alert Supported Message" All servers I tested on master supported it. The text is redundant in operation. * Create preliminary lobby design Attempts to slightly modernize the aging lobby to a scheme more akin to modern server browsers. * Fix missing header, add necessary search lineedits * More UI changes * Start hooking up new UI elements * Hookup Serverbrowser to new UI frontend Still need to fix the favorites AND implement the NEW demolist * Fixup demo ui and make demoserver functional * More demoserver cleanup * Remove jarring ao_app pointer shenigans Still a bit to do before we can safely remove that pointer, but hey, its something. * *unholy screeches* Tried to untangle the tange of dependencies that is connection behaviour * Rip out loading screen Some servers are not even sending proper values anymore, like vanilla, so why keep it? * Optimise includes, format header Lobby should not even have to know what an AOPacket is, smh * Formatting fixes and turn settings menu opening into a signal * Why does netmanager never emit when the server is connected * Fixup final parts About as well implemented as I can do rn. Missing the load screen, but that was more flair than anything else * Correct start page * demo qol Co-authored-by: TrickyLeifa <date.epoch@gmail.com> Co-authored-by: stonedDiscord <Tukz@gmx.de> Co-authored-by: oldmud0 <oldmud0@users.noreply.github.com> Co-authored-by: Crystalwarrior <Varsash@Gmail.com>
1 parent 703c70b commit ce59433

File tree

13 files changed

+927
-604
lines changed

13 files changed

+927
-604
lines changed

include/aoapplication.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,19 @@ class AOApplication : public QApplication {
209209
*/
210210
QVector<server_type> read_legacy_favorite_servers();
211211

212+
/**
213+
* @brief Reads the clients log folder and locates potential demo files to populate the demoserver list.
214+
*
215+
* @return A seperated list of servernames and demo logfile filenames.
216+
*
217+
* @details This is to remove the need of delimiters or deal with potential
218+
* harmfully encoding or plattform differences. We always get a combo of servername and filename.
219+
*
220+
* Do note this function assumes all demo files have the .demo extension.
221+
*
222+
*/
223+
QMultiMap<QString, QString> load_demo_logs_list() const;
224+
212225
// Returns the value of p_identifier in the design.ini file in p_design_path
213226
QString read_design_ini(QString p_identifier, VPath p_design_path);
214227
QString read_design_ini(QString p_identifier, QString p_design_path);

include/demoserver.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ class DemoServer : public QObject
2222
int port = 27088;
2323
int max_wait = -1;
2424

25+
void set_demo_file(QString filepath);
26+
2527
private:
2628
void handle_packet(AOPacket *packet);
2729
void load_demo(QString filename);
@@ -39,6 +41,7 @@ class DemoServer : public QObject
3941
QString p_path;
4042
QTimer *timer;
4143
int elapsed_time = 0;
44+
QString filename;
4245

4346
private slots:
4447
void accept_connection();

include/lobby.h

Lines changed: 46 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
#ifndef LOBBY_H
22
#define LOBBY_H
33

4-
#include "aobutton.h"
5-
#include "aoimage.h"
6-
#include "aopacket.h"
7-
#include "aotextarea.h"
8-
4+
#include <QDebug>
95
#include <QLabel>
106
#include <QLineEdit>
11-
#include <QListWidget>
127
#include <QMainWindow>
13-
#include <QPlainTextEdit>
14-
#include <QProgressBar>
8+
#include <QPushButton>
159
#include <QTextBrowser>
1610
#include <QTreeWidget>
17-
#include <QDebug>
18-
#include <QScrollBar>
19-
#include <QHeaderView>
11+
12+
#include "networkmanager.h"
13+
2014
#ifdef ANDROID
2115
#include <QtAndroidExtras/QtAndroid>
2216
#endif
@@ -27,89 +21,74 @@ class Lobby : public QMainWindow {
2721
Q_OBJECT
2822

2923
public:
30-
Lobby(AOApplication *p_ao_app);
24+
Lobby(AOApplication *p_ao_app, NetworkManager *p_net_man = nullptr);
25+
~Lobby();
3126

32-
void set_widgets();
33-
void list_servers();
34-
void list_favorites();
35-
void get_motd();
36-
void check_for_updates();
37-
void append_chatmessage(QString f_name, QString f_message);
38-
void append_error(QString f_message);
3927
void set_player_count(int players_online, int max_players);
40-
void set_server_description(const QString& server_description);
41-
void set_stylesheet(QWidget *widget);
42-
void set_stylesheets();
43-
void set_fonts();
44-
void set_font(QWidget *widget, QString p_identifier);
45-
void set_loading_text(QString p_text);
46-
void show_loading_overlay() { ui_loading_background->show(); }
47-
void hide_loading_overlay() { ui_loading_background->hide(); }
48-
QString get_chatlog();
28+
void set_server_description(const QString &server_description);
29+
void list_servers();
4930
int get_selected_server();
50-
void enable_connect_button();
51-
void reset_selection();
52-
53-
void set_loading_value(int p_value);
5431

55-
bool public_servers_selected = true;
56-
bool doubleclicked = false;
32+
signals:
33+
void settings_requested();
5734

58-
~Lobby();
5935

6036
private:
6137
AOApplication *ao_app;
38+
NetworkManager *net_manager;
6239

63-
AOImage *ui_background;
40+
void list_favorites();
41+
void list_demos();
42+
void get_motd();
43+
void check_for_updates();
44+
void reset_selection();
6445

65-
AOButton *ui_public_servers;
66-
AOButton *ui_favorites;
46+
int last_index = -1;
6747

68-
AOButton *ui_refresh;
69-
AOButton *ui_add_to_fav;
70-
AOButton *ui_remove_from_fav;
71-
AOButton *ui_connect;
48+
enum TabPage { SERVER, FAVORITES, DEMOS };
7249

73-
QLabel *ui_version;
74-
AOButton *ui_about;
50+
// UI-file Lobby
7551

76-
AOButton *ui_settings;
52+
// Top Row
53+
QLabel *ui_game_version_lbl;
54+
QPushButton *ui_settings_button;
55+
QPushButton *ui_about_button;
7756

78-
QTreeWidget *ui_server_list;
79-
QLineEdit *ui_server_search;
57+
// Server, Favs and Demo lists
58+
QTabWidget *ui_connections_tabview;
8059

81-
QLabel *ui_player_count;
82-
AOTextArea *ui_description;
60+
QTreeWidget *ui_serverlist_tree;
61+
QLineEdit *ui_serverlist_search;
8362

84-
AOTextArea *ui_chatbox;
63+
QTreeWidget *ui_favorites_tree;
64+
QLineEdit *ui_favorites_search;
8565

86-
AOImage *ui_loading_background;
87-
QTextEdit *ui_loading_text;
88-
QProgressBar *ui_progress_bar;
89-
AOButton *ui_cancel;
66+
QTreeWidget *ui_demo_tree;
67+
QLineEdit *ui_demo_search;
9068

91-
int last_index = -1;
69+
QPushButton *ui_add_to_favorite_button;
70+
QPushButton *ui_remove_from_favorites_button;
71+
QPushButton *ui_refresh_button;
9272

93-
void set_size_and_pos(QWidget *p_widget, QString p_identifier);
73+
// Serverinfo / MOTD Horizontal Row
74+
QTextBrowser *ui_motd_text;
9475

95-
private slots:
96-
void on_public_servers_clicked();
97-
void on_favorites_clicked();
76+
QLabel *ui_server_player_count_lbl;
77+
QTextBrowser *ui_server_description_text;
78+
QPushButton *ui_connect_button;
9879

99-
void on_refresh_pressed();
80+
private slots:
81+
void on_tab_changed(int index);
10082
void on_refresh_released();
101-
void on_add_to_fav_pressed();
10283
void on_add_to_fav_released();
103-
void on_remove_from_fav_pressed();
10484
void on_remove_from_fav_released();
105-
void on_connect_pressed();
106-
void on_connect_released();
10785
void on_about_clicked();
108-
void on_settings_clicked();
10986
void on_server_list_clicked(QTreeWidgetItem *p_item, int column);
110-
void on_server_list_doubleclicked(QTreeWidgetItem *p_item, int column);
111-
void on_server_list_context_menu_requested(const QPoint &point);
87+
void on_list_doubleclicked(QTreeWidgetItem *p_item, int column);
88+
void on_favorite_list_context_menu_requested(const QPoint &point);
89+
void on_favorite_tree_clicked(QTreeWidgetItem *p_item, int column);
11290
void on_server_search_edited(QString p_text);
91+
void on_demo_clicked(QTreeWidgetItem *item, int column);
11392
};
11493

11594
#endif // LOBBY_H

include/networkmanager.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,13 @@ class NetworkManager : public QObject {
5151
void connect_to_server(server_type p_server);
5252
void disconnect_from_server();
5353

54+
signals:
55+
void server_connected(bool state);
56+
5457
public slots:
5558
void get_server_list(const std::function<void()> &cb);
5659
void ship_server_packet(QString p_packet);
60+
void join_to_server();
5761
void handle_server_packet(const QString& p_data);
5862

5963
void request_document(MSDocumentType document_type,

0 commit comments

Comments
 (0)