mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-24 15:09:10 +00:00
Codechange: migrate all Window-related timers to the new framework
This means we also say goodbye to GUITimers.
This commit is contained in:
committed by
Patric Stout
parent
5e1bcee39b
commit
1ba4dcc924
@@ -18,6 +18,8 @@
|
||||
#include "../toolbar_gui.h"
|
||||
#include "../core/geometry_func.hpp"
|
||||
#include "../zoom_func.h"
|
||||
#include "../timer/timer.h"
|
||||
#include "../timer/timer_window.h"
|
||||
#include "network.h"
|
||||
#include "network_client.h"
|
||||
#include "network_base.h"
|
||||
@@ -170,9 +172,8 @@ void NetworkUndrawChatMessage()
|
||||
}
|
||||
}
|
||||
|
||||
/** Check if a message is expired. */
|
||||
void NetworkChatMessageLoop()
|
||||
{
|
||||
/** Check if a message is expired on a regular interval. */
|
||||
static IntervalTimer<TimerWindow> network_message_expired_interval(std::chrono::seconds(1), [](auto) {
|
||||
auto now = std::chrono::steady_clock::now();
|
||||
for (auto &cmsg : _chatmsg_list) {
|
||||
/* Message has expired, remove from the list */
|
||||
@@ -182,7 +183,7 @@ void NetworkChatMessageLoop()
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/** Draw the chat message-box */
|
||||
void NetworkDrawChatMessage()
|
||||
|
@@ -89,7 +89,6 @@ void NetworkInitChatMessage();
|
||||
void NetworkReInitChatBoxSize();
|
||||
void CDECL NetworkAddChatMessage(TextColour colour, uint duration, const std::string &message);
|
||||
void NetworkUndrawChatMessage();
|
||||
void NetworkChatMessageLoop();
|
||||
|
||||
void NetworkAfterNewGRFScan();
|
||||
|
||||
|
@@ -32,11 +32,12 @@
|
||||
#include "../core/geometry_func.hpp"
|
||||
#include "../genworld.h"
|
||||
#include "../map_type.h"
|
||||
#include "../guitimer_func.h"
|
||||
#include "../zoom_func.h"
|
||||
#include "../sprite.h"
|
||||
#include "../settings_internal.h"
|
||||
#include "../company_cmd.h"
|
||||
#include "../timer/timer.h"
|
||||
#include "../timer/timer_window.h"
|
||||
|
||||
#include "../widgets/network_widget.h"
|
||||
|
||||
@@ -55,8 +56,6 @@
|
||||
|
||||
static void ShowNetworkStartServerWindow();
|
||||
|
||||
static const int NETWORK_LIST_REFRESH_DELAY = 30; ///< Time, in seconds, between updates of the network list.
|
||||
|
||||
static ClientID _admin_client_id = INVALID_CLIENT_ID; ///< For what client a confirmation window is open.
|
||||
static CompanyID _admin_company_id = INVALID_COMPANY; ///< For what company a confirmation window is open.
|
||||
|
||||
@@ -229,7 +228,6 @@ protected:
|
||||
Scrollbar *vscroll; ///< Vertical scrollbar of the list of servers.
|
||||
QueryString name_editbox; ///< Client name editbox.
|
||||
QueryString filter_editbox; ///< Editbox for filter on servers.
|
||||
GUITimer requery_timer; ///< Timer for network requery.
|
||||
bool searched_internet = false; ///< Did we ever press "Search Internet" button?
|
||||
|
||||
int lock_offset; ///< Left offset for lock icon.
|
||||
@@ -499,8 +497,6 @@ public:
|
||||
this->last_joined = NetworkAddServer(_settings_client.network.last_joined, false);
|
||||
this->server = this->last_joined;
|
||||
|
||||
this->requery_timer.SetInterval(NETWORK_LIST_REFRESH_DELAY * 1000);
|
||||
|
||||
this->servers.SetListing(this->last_sorting);
|
||||
this->servers.SetSortFuncs(this->sorter_funcs);
|
||||
this->servers.SetFilterFuncs(this->filter_funcs);
|
||||
@@ -891,14 +887,12 @@ public:
|
||||
this->vscroll->SetCapacityFromWidget(this, WID_NG_MATRIX);
|
||||
}
|
||||
|
||||
void OnRealtimeTick(uint delta_ms) override
|
||||
{
|
||||
/** Refresh the online servers on a regular interval. */
|
||||
IntervalTimer<TimerWindow> refresh_interval = {std::chrono::seconds(30), [this](uint count) {
|
||||
if (!this->searched_internet) return;
|
||||
if (!this->requery_timer.Elapsed(delta_ms)) return;
|
||||
this->requery_timer.SetInterval(NETWORK_LIST_REFRESH_DELAY * 1000);
|
||||
|
||||
_network_coordinator_client.GetListing();
|
||||
}
|
||||
}};
|
||||
};
|
||||
|
||||
Listing NetworkGameWindow::last_sorting = {false, 5};
|
||||
|
Reference in New Issue
Block a user