OpenTTD Source: src/network/network_content_gui.h Source File

OpenTTD Source 15.3

network_content_gui.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#ifndef NETWORK_CONTENT_GUI_H
11#define NETWORK_CONTENT_GUI_H
12
13#include "network_content.h"
14#include "../window_gui.h"
15#include "../widgets/network_content_widget.h"
16
18 class BaseNetworkContentDownloadStatusWindow : public Window, ContentCallback {
19protected:
20 uint total_bytes = 0;
21 uint downloaded_bytes = 0;
22 uint total_files = 0;
23 uint downloaded_files = 0;
24
25 uint32_t cur_id = UINT32_MAX;
26 std::string name{};
27
28public:
33 BaseNetworkContentDownloadStatusWindow(WindowDesc &desc);
34
35 void Close([[maybe_unused]] int data = 0) override;
36 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override;
37 void DrawWidget(const Rect &r, WidgetID widget) const override;
38 void OnDownloadProgress(const ContentInfo &ci, int bytes) override;
39};
40
41void BuildContentTypeStringList();
42
43#endif /* NETWORK_CONTENT_GUI_H */
BaseNetworkContentDownloadStatusWindow
Base window for showing the download status of content.
Definition network_content_gui.h:18
BaseNetworkContentDownloadStatusWindow::cur_id
uint32_t cur_id
The current ID of the downloaded file.
Definition network_content_gui.h:25
BaseNetworkContentDownloadStatusWindow::downloaded_bytes
uint downloaded_bytes
Number of bytes downloaded.
Definition network_content_gui.h:21
BaseNetworkContentDownloadStatusWindow::total_files
uint total_files
Number of files to download.
Definition network_content_gui.h:22
BaseNetworkContentDownloadStatusWindow::DrawWidget
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
Definition network_content_gui.cpp:138
BaseNetworkContentDownloadStatusWindow::OnDownloadProgress
void OnDownloadProgress(const ContentInfo &ci, int bytes) override
We have progress in the download of a file.
Definition network_content_gui.cpp:166
BaseNetworkContentDownloadStatusWindow::Close
void Close(int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
Definition network_content_gui.cpp:114
BaseNetworkContentDownloadStatusWindow::name
std::string name
The current name of the downloaded file.
Definition network_content_gui.h:26
BaseNetworkContentDownloadStatusWindow::UpdateWidgetSize
void UpdateWidgetSize(WidgetID widget, Dimension &size, const Dimension &padding, Dimension &fill, Dimension &resize) override
Update size and resize step of a widget in the window.
Definition network_content_gui.cpp:120
BaseNetworkContentDownloadStatusWindow::downloaded_files
uint downloaded_files
Number of files downloaded.
Definition network_content_gui.h:23
BaseNetworkContentDownloadStatusWindow::total_bytes
uint total_bytes
Number of bytes to download.
Definition network_content_gui.h:20
network_content.h
Part of the network protocol handling content distribution.
BuildContentTypeStringList
void BuildContentTypeStringList()
Build array of all strings corresponding to the content types.
Definition network_content_gui.cpp:1020
ContentCallback
Callbacks for notifying others about incoming data.
Definition network_content.h:25
ContentInfo
Container for all important information about a piece of content.
Definition tcp_content_type.h:56
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition geometry_type.hpp:56
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition geometry_type.hpp:101
WindowDesc
High level window description.
Definition window_gui.h:168
Window
Data structure for an opened window.
Definition window_gui.h:274
Window::resize
ResizeInfo resize
Resize information.
Definition window_gui.h:315
WidgetID
int WidgetID
Widget ID.
Definition window_type.h:20