|
OpenTTD Source
14.0-beta3
|
Go to the documentation of this file.
12 #include "table/strings.h"
33 uint32_t background_img;
40 ResizeWindow(
this, _screen.width - this->width, _screen.height - this->height);
44 void SetupHighScoreEndWindow()
47 if (this->
width != _screen.width || this->height != _screen.height)
ResizeWindow(
this, _screen.width - this->width, _screen.height - this->height);
56 for (uint i = 0; i < 10; i++) {
57 DrawSprite(this->background_img + i, PAL_NONE, pt.x, pt.y + (i * dim.height));
64 Point pt = {std::max(0, (_screen.width / 2) - (x / 2)), std::max(0, (_screen.height / 2) - (y / 2))};
68 void OnClick([[maybe_unused]]
Point pt, [[maybe_unused]]
WidgetID widget, [[maybe_unused]]
int click_count)
override
73 EventState OnKeyPress([[maybe_unused]] char32_t key, uint16_t keycode)
override
104 this->background_img = SPR_TYCOON_IMG1_BEGIN;
109 this->background_img = SPR_TYCOON_IMG2_BEGIN;
128 void Close([[maybe_unused]]
int data = 0)
override
137 this->SetupHighScoreEndWindow();
141 if (c ==
nullptr)
return;
145 if (this->background_img == SPR_TYCOON_IMG2_BEGIN) {
172 this->background_img = SPR_HIGHSCORE_CHART_BEGIN;
173 this->rank = ranking;
176 void Close([[maybe_unused]]
int data = 0)
override
189 this->SetupHighScoreEndWindow();
196 for (uint8_t i = 0; i < ClampTo<uint8_t>(hs.size()); i++) {
200 if (!hs[i].name.empty()) {
201 TextColour colour = (this->rank == i) ? TC_RED : TC_BLACK;
213 static constexpr
NWidgetPart _nested_highscore_widgets[] = {
217 static WindowDesc _highscore_desc(__FILE__, __LINE__,
221 std::begin(_nested_highscore_widgets), std::end(_nested_highscore_widgets)
224 static WindowDesc _endgame_desc(__FILE__, __LINE__,
228 std::begin(_nested_highscore_widgets), std::end(_nested_highscore_widgets)
@ ES_HANDLED
The passed event is handled.
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
void HideVitalWindows()
Close all always on-top windows to get an empty screen.
static Titem * Get(size_t index)
Returns Titem with given index.
bool game_paused_by_player
True if the game was paused by the player when the highscore window was opened.
Dimensions (a width and height) of a rectangle in 2D.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
void OnClick([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget, [[maybe_unused]] int click_count) override
A click with the left mouse button has been made on the window.
void ShowHighscoreTable(int difficulty, int8_t ranking)
Show the highscore table for a given difficulty.
Tindex index
Index of this pool item.
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
@ SP_MULTIPLAYER
Special "multiplayer" highscore. Not saved, always specific to the current game.
@ FS_LARGE
Index of the large font in the font tables.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
GameCreationSettings game_creation
settings used during the creation of a game (map)
@ WC_HIGHSCORE
Highscore; Window numbers:
High level window description.
void ShowVitalWindows()
Show the vital in-game windows.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
HighScoresTable _highscore_table
Table with all the high scores.
@ WF_WHITE_BORDER
Window white border counter bit mask.
@ ES_NOT_HANDLED
The passed event is not handled.
@ SP_CUSTOM
No profile, special "custom" highscore.
PauseMode _pause_mode
The current pause mode.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
WindowFlags flags
Window flags.
TimerGameCalendar::Year ending_year
scoring end date
bool _networking
are we in networking mode?
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
Coordinates of a point in 2D.
bool _network_dedicated
are we a dedicated server?
WindowNumber window_number
Window number within the window class.
void OnPaint() override
The window must be repainted.
@ SCORE_MAX
The max score that can be in the performance history.
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
void ShowEndGameChart()
Show the endgame victory screen in 2050.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
bool IsQuitKey(uint16_t keycode)
Does the given keycode match one of the keycodes bound to 'quit game'?
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.
int32_t performance_history
Company score (scale 0-1000)
Point GetTopLeft(int x, int y)
Return the coordinate of the screen such that a window of 640x480 is centered at the screen.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
@ COMPANY_SPECTATOR
The client is spectating.
void OnPaint() override
The window must be repainted.
@ PM_PAUSED_NORMAL
A game normally paused.
int ScaleSpriteTrad(int value)
Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.
EventState
State of handling an event.
End game window shown at the end of the game.
void SetDParamStr(size_t n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
int8_t SaveHighScoreValue(const Company *c)
Save the highscore for the company.
@ WC_ENDSCREEN
Endscreen; Window numbers:
@ SA_CENTER
Center both horizontally and vertically.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
int width
width of the window (number of pixels to the right in x direction)
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
@ WDP_MANUAL
Manually align the window (so no automatic location finding)
int DrawString(int left, int right, int top, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
int8_t SaveHighScoreValueNetwork()
Save the highscores in a network game when it has ended.
Data structure for an opened window.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
void DrawWidgets() const
Paint all widgets of a window.
CompanyEconomyEntry old_economy[MAX_HISTORY_QUARTERS]
Economic data of the company of the last MAX_HISTORY_QUARTERS quarters.
#define CLRBITS(x, y)
Clears several bits in a variable.
void ResizeWindow(Window *w, int delta_x, int delta_y, bool clamp_to_screen)
Resize the window.
static Year year
Current year, starting at 0.