Go to the documentation of this file.
12 #include "table/strings.h"
31 uint32 background_img;
38 ResizeWindow(
this, _screen.width - this->width, _screen.height - this->height);
42 void SetupHighScoreEndWindow()
45 if (this->
width != _screen.width || this->height != _screen.height)
ResizeWindow(
this, _screen.width - this->width, _screen.height - this->height);
54 for (uint i = 0; i < 10; i++) {
55 DrawSprite(this->background_img + i, PAL_NONE, pt.x, pt.y + (i * dim.height));
62 Point pt = {std::max(0, (_screen.width / 2) - (x / 2)), std::max(0, (_screen.height / 2) - (y / 2))};
102 this->background_img = SPR_TYCOON_IMG1_BEGIN;
107 this->background_img = SPR_TYCOON_IMG2_BEGIN;
135 this->SetupHighScoreEndWindow();
139 if (c ==
nullptr)
return;
143 if (this->background_img == SPR_TYCOON_IMG2_BEGIN) {
170 this->background_img = SPR_HIGHSCORE_CHART_BEGIN;
171 this->rank = ranking;
187 this->SetupHighScoreEndWindow();
198 if (hs[i].company[0] !=
'\0') {
199 TextColour colour = (this->rank == i) ? TC_RED : TC_BLACK;
211 static const NWidgetPart _nested_highscore_widgets[] = {
219 _nested_highscore_widgets,
lengthof(_nested_highscore_widgets)
226 _nested_highscore_widgets,
lengthof(_nested_highscore_widgets)
@ ES_HANDLED
The passed event is handled.
void HideVitalWindows()
Close all always on-top windows to get an empty screen.
static Titem * Get(size_t index)
Returns Titem with given index.
char32_t WChar
Type for wide characters, i.e.
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.
int8 SaveHighScoreValue(const Company *c)
Save the highscore for the company.
void Close() override
Hide the window and all its child windows, and mark them for a later deletion.
Tindex index
Index of this pool item.
@ SP_MULTIPLAYER
Special "multiplayer" highscore. Not saved, always specific to the current game.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
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.
GameCreationSettings game_creation
settings used during the creation of a game (map)
@ WC_HIGHSCORE
Highscore; Window numbers:
HighScore _highscore_table[SP_HIGHSCORE_END][5]
various difficulty-settings; top 5
High level window description.
void ShowVitalWindows()
Show the vital in-game windows.
int32 performance_history
Company score (scale 0-1000)
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
@ 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.
static int ScaleSpriteTrad(int value)
Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.
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.
bool _networking
are we in networking mode?
#define FONT_HEIGHT_LARGE
Height of characters in the large (FS_LARGE) font.
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.
Year ending_year
scoring end date
EventState OnKeyPress(WChar key, uint16 keycode) override
A key has been pressed.
void ShowEndGameChart()
Show the endgame victory screen in 2050.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
void Close() override
Hide the window and all its child windows, and mark them for a later deletion.
Point GetTopLeft(int x, int y)
Return the coordinate of the screen such that a window of 640x480 is centered at the screen.
bool IsQuitKey(uint16 keycode)
Does the given keycode match one of the keycodes bound to 'quit game'?
@ COMPANY_SPECTATOR
The client is spectating.
void CloseWindowByClass(WindowClass cls)
Close all windows of a given class.
void OnPaint() override
The window must be repainted.
@ PM_PAUSED_NORMAL
A game normally paused.
EventState
State of handling an event.
End game window shown at the end of the game.
@ WC_ENDSCREEN
Endscreen; Window numbers:
@ SA_CENTER
Center both horizontally and vertically.
#define lengthof(x)
Return the length of an fixed size array.
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)
int8 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.
void ShowHighscoreTable(int difficulty, int8 ranking)
Show the highscore table for a given difficulty.
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 SetDParamStr(uint n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
void ResizeWindow(Window *w, int delta_x, int delta_y, bool clamp_to_screen)
Resize the window.
virtual void Close()
Hide the window and all its child windows, and mark them for a later deletion.