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[] = {
221 _nested_highscore_widgets
228 _nested_highscore_widgets
#define CLRBITS(x, y)
Clears several bits in a variable.
static Year year
Current year, starting at 0.
Functions related to commands.
Definition of stuff that is very close to a company, like the company struct itself.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Functions related to companies.
@ COMPANY_SPECTATOR
The client is spectating.
@ SCORE_MAX
The max score that can be in the performance history.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
PauseMode _pause_mode
The current pause mode.
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.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
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.
@ 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...
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
int8_t SaveHighScoreValueNetwork()
Save the highscores in a network game when it has ended.
HighScoresTable _highscore_table
Table with all the high scores.
int8_t SaveHighScoreValue(const Company *c)
Save the highscore for the company.
Declaration of functions and types defined in highscore.h and highscore_gui.h.
void ShowHighscoreTable(int difficulty, int8_t ranking)
Show the highscore table for a given difficulty.
void ShowEndGameChart()
Show the endgame victory screen in 2050.
Hotkey related functions.
bool IsQuitKey(uint16_t keycode)
Does the given keycode match one of the keycodes bound to 'quit game'?
void ShowVitalWindows()
Show the vital in-game windows.
Miscellaneous command definitions.
bool _networking
are we in networking mode?
bool _network_dedicated
are we a dedicated server?
Basic functions/variables used all over the place.
@ PM_PAUSED_NORMAL
A game normally paused.
A number of safeguards to prevent using unsafe methods.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
@ SP_CUSTOM
No profile, special "custom" highscore.
@ SP_MULTIPLAYER
Special "multiplayer" highscore. Not saved, always specific to the current game.
This file contains all sprite-related enums and defines.
Definition of base types and functions in a cross-platform compatible way.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
void SetDParamStr(size_t n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
Functions related to OTTD's strings.
int32_t performance_history
Company score (scale 0-1000)
CompanyEconomyEntry old_economy[MAX_HISTORY_QUARTERS]
Economic data of the company of the last MAX_HISTORY_QUARTERS quarters.
Dimensions (a width and height) of a rectangle in 2D.
Point GetTopLeft(int x, int y)
Return the coordinate of the screen such that a window of 640x480 is centered at the screen.
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.
End game window shown at the end of the game.
void OnPaint() override
The window must be repainted.
TimerGameCalendar::Year ending_year
scoring end date
GameCreationSettings game_creation
settings used during the creation of a game (map)
void OnPaint() override
The window must be repainted.
bool game_paused_by_player
True if the game was paused by the player when the highscore window was opened.
Coordinates of a point in 2D.
Tindex index
Index of this pool item.
static Titem * Get(size_t index)
Returns Titem with given index.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
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.
void DrawWidgets() const
Paint all widgets of a window.
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.
int width
width of the window (number of pixels to the right in x direction)
WindowNumber window_number
Window number within the window class.
Definition of Interval and OneShot timers.
Definition of the game-calendar-timer.
void ResizeWindow(Window *w, int delta_x, int delta_y, bool clamp_to_screen, bool schedule_resize)
Resize the window.
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.
Window functions not directly related to making/drawing windows.
Functions, definitions and such used only by the GUI.
@ WF_WHITE_BORDER
Window white border counter bit mask.
@ WDP_MANUAL
Manually align the window (so no automatic location finding)
EventState
State of handling an event.
@ ES_HANDLED
The passed event is handled.
@ ES_NOT_HANDLED
The passed event is not handled.
@ WC_HIGHSCORE
Highscore; Window numbers:
@ WC_ENDSCREEN
Endscreen; Window numbers:
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Functions related to zooming.
int ScaleSpriteTrad(int value)
Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.