OpenTTD Source
20240917-master-g9ab0a47812
|
Go to the documentation of this file.
15 #if defined(WITH_FREETYPE) || defined(WITH_UNISCRIBE) || defined(WITH_COCOA)
30 #include "table/strings.h"
94 void Close([[maybe_unused]]
int data = 0)
override
109 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
116 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
152 void Close([[maybe_unused]]
int data = 0)
override
158 this->BaseNetworkContentDownloadStatusWindow::Close();
161 void OnDownloadComplete(
ContentID)
override
167 _game_mode = GM_MENU;
208 void Close([[maybe_unused]]
int data = 0)
override
217 if (this->button_size.width == 0) {
226 size.width = this->button_size.width * 2;
237 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
244 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
261 void OnConnect(
bool success)
override
264 UserError(
"Failed to connect to content server. Please acquire a graphics set for OpenTTD. See section 1.4 of README.md.");
275 void OnReceiveContentInfo(
const ContentInfo *ci)
override
286 #if defined(__EMSCRIPTEN__)
287 # include <emscripten.h>
294 bool downloading =
false;
295 uint total_files = 0;
296 uint total_bytes = 0;
297 uint downloaded_bytes = 0;
300 BootstrapEmscripten()
306 ~BootstrapEmscripten()
314 EM_ASM({
if (window[
"openttd_bootstrap_failed"]) openttd_bootstrap_failed(); });
324 if (this->downloading)
return;
329 this->downloading =
true;
331 EM_ASM({
if (window[
"openttd_bootstrap"]) openttd_bootstrap($0, $1); }, this->downloaded_bytes, this->total_bytes);
338 this->downloaded_bytes = 0;
340 this->downloaded_bytes += bytes;
343 EM_ASM({
if (window[
"openttd_bootstrap"]) openttd_bootstrap($0, $1); }, this->downloaded_bytes, this->total_bytes);
370 #if defined(__EMSCRIPTEN__) || (defined(_WIN32) && defined(WITH_UNISCRIBE)) || (defined(WITH_FREETYPE) && (defined(WITH_FONTCONFIG) || defined(__APPLE__))) || defined(WITH_COCOA)
374 _game_mode = GM_BOOTSTRAP;
376 #if defined(__EMSCRIPTEN__)
377 new BootstrapEmscripten();
387 static const int offsets[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x80, 0, 0, 0, 0x04, 0x08 };
388 for (Colours i = COLOUR_BEGIN; i != COLOUR_END; i++) {
389 for (ColourShade j = SHADE_BEGIN; j < SHADE_END; j++) {
405 _exit_game = _game_mode == GM_BOOTSTRAP;
406 if (_exit_game)
return false;
412 _game_mode = GM_MENU;
418 UserError(
"Failed to find a graphics set. Please acquire a graphics set for OpenTTD. See section 1.4 of README.md.");
bool HandleBootstrap()
Handle all procedures for bootstrapping OpenTTD without a base graphics set.
virtual void OnDownloadProgress([[maybe_unused]] const ContentInfo *ci, [[maybe_unused]] int bytes)
We have progress in the download of a file.
Callbacks for notifying others about incoming data.
virtual void OnReceiveContentInfo([[maybe_unused]] const ContentInfo *ci)
We received a content info.
virtual void OnConnect([[maybe_unused]] bool success)
Callback for when the connection has finished.
Dimensions (a width and height) of a rectangle in 2D.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
static constexpr NWidgetPart _background_widgets[]
Widgets for the background window to prevent smearing.
void InitializeUnicodeGlyphMap()
Initialize the glyph map.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
@ FILLRECT_CHECKER
Draw only every second pixel, used for greying-out.
@ WC_BOOTSTRAP
Bootstrap; Window numbers:
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
Base window for showing the download status of content.
void SetColourGradient(Colours colour, ColourShade shade, uint8_t palette_index)
Set colour gradient palette index.
@ WID_NCDS_PROGRESS_TEXT
Text explaining what is happening.
void ResizeWindow(Window *w, int delta_x, int delta_y, bool clamp_to_screen, bool schedule_resize)
Resize the window.
BootstrapAskForDownloadWindow()
Start listening to the content client events.
BootstrapContentDownloadStatusWindow()
Simple call the constructor of the superclass.
High level window description.
constexpr uint Horizontal() const
Get total horizontal padding of RectPadding.
void RequestContentList(ContentType type)
Request the content list for the given type.
@ WC_CONFIRM_POPUP_QUERY
Popup with confirm question; Window numbers:
ResizeInfo resize
Resize information.
static WindowDesc _background_desc(WDP_MANUAL, nullptr, 0, 0, WC_BOOTSTRAP, WC_NONE, WDF_NO_CLOSE, _background_widgets)
Window description for the background window to prevent smearing.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Dimension button_size
The dimension of the button.
@ WF_WHITE_BORDER
Window white border counter bit mask.
The window for the query.
static constexpr NWidgetPart _bootstrap_query_widgets[]
The widgets for the query.
The window for a failed bootstrap.
Container for all important information about a piece of content.
static Blitter * GetCurrentBlitter()
Get the current active blitter (always set by calling SelectBlitter).
virtual void OnDownloadComplete([[maybe_unused]] ContentID cid)
We have finished downloading a file.
WindowFlags flags
Window flags.
int GetStringHeight(std::string_view str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
Window(WindowDesc &desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
@ WDF_MODAL
The window is a modal child of some other window, meaning the parent is 'inactive'.
Coordinates of a point in 2D.
@ WDF_NO_CLOSE
This window can't be interactively closed.
void RemoveCallback(ContentCallback *cb)
Remove a callback.
void DownloadSelectedContent(uint &files, uint &bytes, bool fallback=false)
Actually begin downloading the content we selected.
static WindowDesc _bootstrap_errmsg_desc(WDP_CENTER, nullptr, 0, 0, WC_BOOTSTRAP, WC_NONE, WDF_MODAL|WDF_NO_CLOSE, _nested_bootstrap_errmsg_widgets)
Window description for the error window.
void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen.
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
static constexpr NWidgetPart _nested_bootstrap_errmsg_widgets[]
Nested widgets for the error window.
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
@ FILLRECT_OPAQUE
Fill rectangle with a single colour.
static constexpr NWidgetPart _nested_bootstrap_download_status_window_widgets[]
Nested widgets for the download window.
ClientNetworkContentSocketHandler _network_content_client
The client we use to connect to the server.
int DrawStringMultiLine(int left, int right, int top, int bottom, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
@ CONTENT_TYPE_BASE_GRAPHICS
The content consists of base graphics.
The background for the game.
@ WN_CONFIRM_POPUP_QUERY_BOOTSTRAP
Query popup confirm for bootstrap.
void Connect()
Connect with the content server.
@ WC_NETWORK_STATUS_WINDOW
Network status window; Window numbers:
ContentID
Unique identifier for the content.
void Select(ContentID cid)
Select a specific content id.
void AddCallback(ContentCallback *cb)
Add a callback to this class.
void CheckForMissingGlyphs(bool base_font, MissingGlyphSearcher *searcher)
Check whether the currently loaded language pack uses characters that the currently loaded font does ...
@ SA_CENTER
Center both horizontally and vertically.
@ WDP_MANUAL
Manually align the window (so no automatic location finding)
virtual void MainLoop()=0
Perform the actual drawing.
void Close([[maybe_unused]] int data=0) override
Stop listening to the content client events.
Data structure for an opened window.
bool _network_available
is network mode available?
ContentID id
Unique (server side) ID for the content.
static WindowDesc _bootstrap_download_status_window_desc(WDP_CENTER, nullptr, 0, 0, WC_NETWORK_STATUS_WINDOW, WC_NONE, WDF_MODAL|WDF_NO_CLOSE, _nested_bootstrap_download_status_window_widgets)
Window description for the download window.
Specification of a rectangle with absolute coordinates of all edges.
#define CLRBITS(x, y)
Clears several bits in a variable.
@ WDP_CENTER
Center the window.
Window for showing the download status of content.
@ WID_NCDS_PROGRESS_BAR
Simple progress bar.
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
static WindowDesc _bootstrap_query_desc(WDP_CENTER, nullptr, 0, 0, WC_CONFIRM_POPUP_QUERY, WC_NONE, WDF_NO_CLOSE, _bootstrap_query_widgets)
The window description for the query.