OpenTTD Source
12.0-beta2
|
Go to the documentation of this file.
14 #if defined(WITH_FREETYPE) || defined(WITH_UNISCRIBE) || defined(WITH_COCOA)
29 #include "table/strings.h"
163 _game_mode = GM_MENU;
215 if (this->button_size.width == 0) {
224 size->width = this->button_size.width * 2;
237 if (widget != 0)
return;
290 #if (defined(_WIN32) && defined(WITH_UNISCRIBE)) || (defined(WITH_FREETYPE) && (defined(WITH_FONTCONFIG) || defined(__APPLE__))) || defined(WITH_COCOA)
294 _game_mode = GM_BOOTSTRAP;
304 static const int offsets[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x80, 0, 0, 0, 0x04, 0x08 };
305 for (uint i = 0; i != 16; i++) {
306 for (
int j = 0; j < 8; j++) {
321 _exit_game = _game_mode == GM_BOOTSTRAP;
322 if (_exit_game)
return false;
328 _game_mode = GM_MENU;
334 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.
@ WD_FRAMERECT_TOP
Offset at top to draw the frame rectangular area.
Callbacks for notifying others about incoming data.
void CDECL usererror(const char *s,...)
Error handling for fatal user errors.
Dimensions (a width and height) of a rectangle in 2D.
static WindowDesc _bootstrap_errmsg_desc(WDP_CENTER, nullptr, 0, 0, WC_BOOTSTRAP, WC_NONE, WDF_MODAL, _nested_bootstrap_errmsg_widgets, lengthof(_nested_bootstrap_errmsg_widgets))
Window description for the error window.
void Close() override
Hide the window and all its child windows, and mark them for a later deletion.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
static WindowDesc _bootstrap_query_desc(WDP_CENTER, nullptr, 0, 0, WC_CONFIRM_POPUP_QUERY, WC_NONE, 0, _bootstrap_query_widgets, lengthof(_bootstrap_query_widgets))
The window description for the query.
@ FILLRECT_CHECKER
Draw only every second pixel, used for greying-out.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
@ WC_BOOTSTRAP
Bootstrap; Window numbers:
@ WD_FRAMETEXT_TOP
Top offset of the text of the frame.
Base window for showing the download status of content.
@ WD_FRAMETEXT_LEFT
Left offset of the text of the frame.
byte _colour_gradient[COLOUR_END][8]
All 16 colour gradients 8 colours per gradient from darkest (0) to lightest (7)
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
int DrawStringMultiLine(int left, int right, int top, int bottom, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
BootstrapAskForDownloadWindow()
Start listening to the content client events.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
BootstrapContentDownloadStatusWindow()
Simple call the constructor of the superclass.
High level window description.
void RequestContentList(ContentType type)
Request the content list for the given type.
@ WC_CONFIRM_POPUP_QUERY
Popup with confirm question; Window numbers:
static const NWidgetPart _nested_bootstrap_download_status_window_widgets[]
Nested widgets for the download window.
ResizeInfo resize
Resize information.
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.
void OnDownloadComplete(ContentID cid) override
We have finished downloading a file.
@ WF_WHITE_BORDER
Window white border counter bit mask.
static WindowDesc _background_desc(WDP_MANUAL, nullptr, 0, 0, WC_BOOTSTRAP, WC_NONE, 0, _background_widgets, lengthof(_background_widgets))
Window description for the background window to prevent smearing.
The window for the query.
The window for a failed bootstrap.
Container for all important information about a piece of content.
@ WD_FRAMERECT_BOTTOM
Offset at bottom to draw the frame rectangular area.
@ WD_FRAMETEXT_BOTTOM
Bottom offset of the text of the frame.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
static Blitter * GetCurrentBlitter()
Get the current active blitter (always set by calling SelectBlitter).
WindowFlags flags
Window flags.
@ WDF_MODAL
The window is a modal child of some other window, meaning the parent is 'inactive'.
Coordinates of a point in 2D.
@ WID_NCDS_BACKGROUND
Background of the window.
void RemoveCallback(ContentCallback *cb)
Remove a callback.
@ WD_FRAMETEXT_RIGHT
Right offset of the text of the frame.
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
static const NWidgetPart _bootstrap_query_widgets[]
The widgets for the query.
static const struct NWidgetPart _background_widgets[]
Widgets for the background window to prevent smearing.
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.
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
@ FILLRECT_OPAQUE
Fill rectangle with a single colour.
int GetStringHeight(const char *str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
ClientNetworkContentSocketHandler _network_content_client
The client we use to connect to the server.
@ 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 OnConnect(bool success) override
Callback for when the connection has finished.
void Close() override
Hide the window and all its child windows, and mark them for a later deletion.
static void InitializeUnicodeGlyphMap()
Initialize the glyph map.
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.
#define lengthof(x)
Return the length of an fixed size array.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
@ WDP_MANUAL
Manually align the window (so no automatic location finding)
virtual void MainLoop()=0
Perform the actual drawing.
void Close() override
Hide the window and all its child windows, and mark them for a later deletion.
Data structure for an opened window.
static WindowDesc _bootstrap_download_status_window_desc(WDP_CENTER, nullptr, 0, 0, WC_NETWORK_STATUS_WINDOW, WC_NONE, WDF_MODAL, _nested_bootstrap_download_status_window_widgets, lengthof(_nested_bootstrap_download_status_window_widgets))
Window description for the download window.
bool _network_available
is network mode available?
ContentID id
Unique (server side) ID for the content.
Specification of a rectangle with absolute coordinates of all edges.
void Close() override
Stop listening to the content client events.
#define CLRBITS(x, y)
Clears several bits in a variable.
@ WDP_CENTER
Center the window.
Window for showing the download status of content.
static const NWidgetPart _nested_bootstrap_errmsg_widgets[]
Nested widgets for the error window.
void OnReceiveContentInfo(const ContentInfo *ci) override
We received a content info.
void ResizeWindow(Window *w, int delta_x, int delta_y, bool clamp_to_screen)
Resize the window.
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
virtual void Close()
Hide the window and all its child windows, and mark them for a later deletion.