From edf3d463e990ff8573bb6655c793490e6b1ea82c Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Fri, 21 Aug 2020 17:17:49 +0300 Subject: add a new aoclocklabel class that is a QLabel with fancy DR-Style timing features WIP --- include/aoclocklabel.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 include/aoclocklabel.h (limited to 'include') diff --git a/include/aoclocklabel.h b/include/aoclocklabel.h new file mode 100644 index 0000000..518cae7 --- /dev/null +++ b/include/aoclocklabel.h @@ -0,0 +1,29 @@ +#ifndef AOCLOCKLABEL_H +#define AOCLOCKLABEL_H + +#include +#include +#include +#include + +class AOClockLabel : public QLabel { + Q_OBJECT + +public: + AOClockLabel(QWidget *parent); + void start(); + void start(QTime p_time); + void pause(); + void resume(); + void stop(); + +protected: + void timerEvent(QTimerEvent *event) override; + +private: + QBasicTimer timer; + QTime starting_time; + QTime target_time; +}; + +#endif // AOCLOCKLABEL_H -- cgit From f27f210efeb13a5ac29727fef271f8249e3e8c5d Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Fri, 21 Aug 2020 18:01:24 +0300 Subject: Proof of concept complete. The timer will now take int msecs to start, and will properly display the time remaining until target time in hh:mm:ss.zzz Clock can be defined in courtroom_config.ini and its font set in courtroom_fonts.ini Pause and resume functions will not work as expected atm. --- include/aoclocklabel.h | 4 ++-- include/courtroom.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/aoclocklabel.h b/include/aoclocklabel.h index 518cae7..806ed18 100644 --- a/include/aoclocklabel.h +++ b/include/aoclocklabel.h @@ -5,6 +5,7 @@ #include #include #include +#include class AOClockLabel : public QLabel { Q_OBJECT @@ -12,7 +13,7 @@ class AOClockLabel : public QLabel { public: AOClockLabel(QWidget *parent); void start(); - void start(QTime p_time); + void start(int msecs); void pause(); void resume(); void stop(); @@ -22,7 +23,6 @@ protected: private: QBasicTimer timer; - QTime starting_time; QTime target_time; }; diff --git a/include/courtroom.h b/include/courtroom.h index 5b5ff6c..1ff74f5 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -6,6 +6,7 @@ #include "aobutton.h" #include "aocharbutton.h" #include "aocharmovie.h" +#include "aoclocklabel.h" #include "aoemotebutton.h" #include "aoevidencebutton.h" #include "aoevidencedisplay.h" @@ -517,6 +518,8 @@ private: ScrollText *ui_music_name; AOMovie *ui_music_display; + AOClockLabel *ui_clock; + AOButton *ui_pair_button; QListWidget *ui_pair_list; QSpinBox *ui_pair_offset_spinbox; -- cgit From febfbeafc11ecad57d6e9a06575c28f1b13da8da Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Tue, 25 Aug 2020 12:18:49 +0300 Subject: Actually make use of the completely useless CHECK and CH keepalive timer and use them to determine the client's ping. Display ping in the application window title. keepalive timer now fires every second instead of every minute Remove meme clock starting on set_widgets() implement get_ping() on w_courtroom --- include/aoapplication.h | 3 +++ include/courtroom.h | 10 ++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/aoapplication.h b/include/aoapplication.h index 60d945e..3f5767c 100644 --- a/include/aoapplication.h +++ b/include/aoapplication.h @@ -61,6 +61,9 @@ public: void call_settings_menu(); void call_announce_menu(Courtroom *court); + qint64 last_ping; + QString window_title; + /////////////////server metadata////////////////// unsigned int s_decryptor = 5; diff --git a/include/courtroom.h b/include/courtroom.h index 1ff74f5..0daeb2b 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -57,7 +57,7 @@ #include #include #include -//#include +#include #include @@ -251,6 +251,8 @@ public: void check_connection_received(); + qint64 get_ping() { return ping_timer.elapsed(); } + ~Courtroom(); private: @@ -299,11 +301,15 @@ private: QVector ic_chatlog_history; - // triggers ping_server() every 60 seconds + // triggers ping_server() every 1 second QTimer *keepalive_timer; // determines how fast messages tick onto screen QTimer *chat_tick_timer; + + // count up timer to check how long it took for us to get a response from ping_server() + QElapsedTimer ping_timer; + // int chat_tick_interval = 60; // which tick position(character in chat message) we are at int tick_pos = 0; -- cgit From 7e9c5726e02a65023d9563f49e833525bf8f4bae Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Tue, 25 Aug 2020 12:21:10 +0300 Subject: Introduce the timer packet - "TI". This timer will start the clock accounting for latency! Cool, right? Remove useless qDebug() for music looping --- include/courtroom.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/courtroom.h b/include/courtroom.h index 0daeb2b..9346172 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -251,6 +251,10 @@ public: void check_connection_received(); + void start_clock(qint64 msecs); + + void stop_clock(); + qint64 get_ping() { return ping_timer.elapsed(); } ~Courtroom(); -- cgit From ee3bad44c72329d61a2cb0c4064c22512451372d Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Tue, 25 Aug 2020 12:48:09 +0300 Subject: Implement clock pausing Implement clock setting w/o starting or stopping Both of these should make it possible for the server to start/stop/pause/resume the clock with perfect synchronization to the true time. --- include/aoclocklabel.h | 2 +- include/courtroom.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/aoclocklabel.h b/include/aoclocklabel.h index 806ed18..b948330 100644 --- a/include/aoclocklabel.h +++ b/include/aoclocklabel.h @@ -14,8 +14,8 @@ public: AOClockLabel(QWidget *parent); void start(); void start(int msecs); + void set(int msecs, bool update_text=false); void pause(); - void resume(); void stop(); protected: diff --git a/include/courtroom.h b/include/courtroom.h index 9346172..15324a0 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -251,8 +251,11 @@ public: void check_connection_received(); + void start_clock(); void start_clock(qint64 msecs); + void set_clock(qint64 msecs); + void stop_clock(); qint64 get_ping() { return ping_timer.elapsed(); } -- cgit From 6c62980ffc9215a826ee05f9afb9874a96ce60ea Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Tue, 25 Aug 2020 12:58:48 +0300 Subject: forgot to ctrl+s header definitions fuck --- include/courtroom.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'include') diff --git a/include/courtroom.h b/include/courtroom.h index 15324a0..4835b0a 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -253,9 +253,8 @@ public: void start_clock(); void start_clock(qint64 msecs); - void set_clock(qint64 msecs); - + void pause_clock(); void stop_clock(); qint64 get_ping() { return ping_timer.elapsed(); } -- cgit From de3533fbf2615a40efc60c9ed2e96f1a3b5da3c1 Mon Sep 17 00:00:00 2001 From: oldmud0 Date: Sat, 9 Jan 2021 01:18:19 -0600 Subject: Rework timer and ping logic The timer's time as received by the server is clarified to be the actual numerical time, in milliseconds, to be shown on the clock. --- include/aoapplication.h | 3 ++- include/aoclocklabel.h | 2 +- include/courtroom.h | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/aoapplication.h b/include/aoapplication.h index 3f5767c..458a884 100644 --- a/include/aoapplication.h +++ b/include/aoapplication.h @@ -26,6 +26,7 @@ #include #include #include +#include class NetworkManager; class Lobby; @@ -61,7 +62,7 @@ public: void call_settings_menu(); void call_announce_menu(Courtroom *court); - qint64 last_ping; + qint64 latency = 0; QString window_title; /////////////////server metadata////////////////// diff --git a/include/aoclocklabel.h b/include/aoclocklabel.h index b948330..b5d0794 100644 --- a/include/aoclocklabel.h +++ b/include/aoclocklabel.h @@ -14,7 +14,7 @@ public: AOClockLabel(QWidget *parent); void start(); void start(int msecs); - void set(int msecs, bool update_text=false); + void set(int msecs, bool update_text = false); void pause(); void stop(); diff --git a/include/courtroom.h b/include/courtroom.h index 4835b0a..72b4989 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -256,11 +256,11 @@ public: void set_clock(qint64 msecs); void pause_clock(); void stop_clock(); + void set_clock_visibility(bool visible); - qint64 get_ping() { return ping_timer.elapsed(); } + qint64 pong(); ~Courtroom(); - private: AOApplication *ao_app; @@ -315,6 +315,7 @@ private: // count up timer to check how long it took for us to get a response from ping_server() QElapsedTimer ping_timer; + bool is_pinging = false; // int chat_tick_interval = 60; // which tick position(character in chat message) we are at -- cgit From 62532f0b643c5f7502f1f48781ec6ec338019275 Mon Sep 17 00:00:00 2001 From: oldmud0 Date: Sun, 10 Jan 2021 10:41:34 -0600 Subject: Trivial comment change --- include/courtroom.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/courtroom.h b/include/courtroom.h index e0db719..4924325 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -316,7 +316,7 @@ private: QVector ic_chatlog_history; - // triggers ping_server() every 1 second + // triggers ping_server() every 45 seconds QTimer *keepalive_timer; // determines how fast messages tick onto screen -- cgit From 45c78ea5caf58b6b8494decc6021540c755fabd7 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Mon, 11 Jan 2021 17:38:08 +0300 Subject: Add "id" variable to the clock functions and properly parse the ID Implement scalable maximum clock count, right now it's at 5 clocks a theme can have max Theme "clock_" starts from 1 instead of 0 since users don't know when stuff starts at index 0 TODO: testing lol --- include/courtroom.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/courtroom.h b/include/courtroom.h index 4924325..91606c3 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -255,12 +255,12 @@ public: void check_connection_received(); - void start_clock(); - void start_clock(qint64 msecs); - void set_clock(qint64 msecs); - void pause_clock(); - void stop_clock(); - void set_clock_visibility(bool visible); + void start_clock(int id); + void start_clock(int id, qint64 msecs); + void set_clock(int id, qint64 msecs); + void pause_clock(int id); + void stop_clock(int id); + void set_clock_visibility(int id, bool visible); qint64 pong(); // Truncates text so it fits within theme-specified boundaries and sets the tooltip to the full string @@ -563,7 +563,8 @@ private: ScrollText *ui_music_name; AOMovie *ui_music_display; - AOClockLabel *ui_clock; + static const int max_clocks = 5; + AOClockLabel *ui_clock[max_clocks]; AOButton *ui_pair_button; QListWidget *ui_pair_list; -- cgit From f96bd6cc3cb03a22d10ffdaa66d8b794faa3bf18 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Tue, 12 Jan 2021 11:59:07 +0300 Subject: Didn't notice I removed this from the mergening when I resolved merge conflicts, oops --- include/courtroom.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/courtroom.h b/include/courtroom.h index 4d4f173..d996715 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -358,6 +358,8 @@ private: QVector ic_chatlog_history; + QQueue chatmessage_queue; + // triggers ping_server() every 45 seconds QTimer *keepalive_timer; -- cgit