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.");
#define CLRBITS(x, y)
Clears several bits in a variable.
static constexpr NWidgetPart _background_widgets[]
Widgets for the background window to prevent smearing.
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.
static constexpr NWidgetPart _bootstrap_query_widgets[]
The widgets for the query.
static constexpr NWidgetPart _nested_bootstrap_errmsg_widgets[]
Nested widgets for the error window.
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.
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.
bool HandleBootstrap()
Handle all procedures for bootstrapping OpenTTD without a base graphics set.
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.
static constexpr NWidgetPart _nested_bootstrap_download_status_window_widgets[]
Nested widgets for the download window.
Base window for showing the download status of content.
static Blitter * GetCurrentBlitter()
Get the current active blitter (always set by calling SelectBlitter).
The window for the query.
Dimension button_size
The dimension of the button.
void Close([[maybe_unused]] int data=0) override
Stop listening to the content client events.
BootstrapAskForDownloadWindow()
Start listening to the content client events.
The background for the game.
The window for a failed bootstrap.
void DownloadSelectedContent(uint &files, uint &bytes, bool fallback=false)
Actually begin downloading the content we selected.
void RemoveCallback(ContentCallback *cb)
Remove a callback.
void Select(ContentID cid)
Select a specific content id.
void RequestContentList(ContentType type)
Request the content list for the given type.
void AddCallback(ContentCallback *cb)
Add a callback to this class.
void Connect()
Connect with the content server.
virtual void MainLoop()=0
Perform the actual drawing.
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
Functions related to errors.
Error reporting related functions.
Factory to 'query' all available blitters.
Functions to read fonts from files and cache them.
void InitializeUnicodeGlyphMap()
Initialize the glyph map.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
int GetStringHeight(std::string_view str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
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.
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.
Functions related to the gfx engine.
@ SA_CENTER
Center both horizontally and vertically.
@ FILLRECT_CHECKER
Draw only every second pixel, used for greying-out.
@ FILLRECT_OPAQUE
Fill rectangle with a single colour.
bool _network_available
is network mode available?
Basic functions/variables used all over the place.
ClientNetworkContentSocketHandler _network_content_client
The client we use to connect to the server.
Part of the network protocol handling content distribution.
User interface for downloading files.
@ WID_NCDS_PROGRESS_TEXT
Text explaining what is happening.
@ WID_NCDS_PROGRESS_BAR
Simple progress bar.
void SetColourGradient(Colours colour, ColourShade shade, uint8_t palette_index)
Set colour gradient palette index.
A number of safeguards to prevent using unsafe methods.
Definition of base types and functions in a cross-platform compatible way.
void CheckForMissingGlyphs(bool base_font, MissingGlyphSearcher *searcher)
Check whether the currently loaded language pack uses characters that the currently loaded font does ...
Functions related to OTTD's strings.
Window for showing the download status of content.
BootstrapContentDownloadStatusWindow()
Simple call the constructor of the superclass.
Callbacks for notifying others about incoming data.
virtual void OnConnect([[maybe_unused]] bool success)
Callback for when the connection has finished.
virtual void OnDownloadProgress([[maybe_unused]] const ContentInfo *ci, [[maybe_unused]] int bytes)
We have progress in the download of a file.
virtual void OnDownloadComplete([[maybe_unused]] ContentID cid)
We have finished downloading a file.
virtual void OnReceiveContentInfo([[maybe_unused]] const ContentInfo *ci)
We received a content info.
Container for all important information about a piece of content.
ContentID id
Unique (server side) ID for the content.
Dimensions (a width and height) of a rectangle in 2D.
Coordinates of a point in 2D.
constexpr uint Horizontal() const
Get total horizontal padding of RectPadding.
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
Specification of a rectangle with absolute coordinates of all edges.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
High level window description.
Data structure for an opened window.
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
ResizeInfo resize
Resize information.
Window(WindowDesc &desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
WindowFlags flags
Window flags.
@ CONTENT_TYPE_BASE_GRAPHICS
The content consists of base graphics.
ContentID
Unique identifier for the content.
Base of all video drivers.
void ResizeWindow(Window *w, int delta_x, int delta_y, bool clamp_to_screen, bool schedule_resize)
Resize the window.
Window functions not directly related to making/drawing windows.
@ WF_WHITE_BORDER
Window white border counter bit mask.
@ WDF_NO_CLOSE
This window can't be interactively closed.
@ WDF_MODAL
The window is a modal child of some other window, meaning the parent is 'inactive'.
@ WDP_CENTER
Center the window.
@ WDP_MANUAL
Manually align the window (so no automatic location finding)
@ WN_CONFIRM_POPUP_QUERY_BOOTSTRAP
Query popup confirm for bootstrap.
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
@ WC_CONFIRM_POPUP_QUERY
Popup with confirm question; Window numbers:
@ WC_BOOTSTRAP
Bootstrap; Window numbers:
@ WC_NETWORK_STATUS_WINDOW
Network status window; Window numbers: