12 #include "table/strings.h" 30 uint32 background_img;
37 ResizeWindow(
this, _screen.width - this->width, _screen.height - this->height);
41 void SetupHighScoreEndWindow()
44 if (this->
width != _screen.width || this->height != _screen.height)
ResizeWindow(
this, _screen.width - this->width, _screen.height - this->height);
53 for (uint i = 0; i < 10; i++) {
54 DrawSprite(this->background_img + i, PAL_NONE, pt.x, pt.y + (i * dim.height));
61 Point pt = {
max(0, (_screen.width / 2) - (x / 2)),
max(0, (_screen.height / 2) - (y / 2))};
101 this->background_img = SPR_TYCOON_IMG1_BEGIN;
106 this->background_img = SPR_TYCOON_IMG2_BEGIN;
133 this->SetupHighScoreEndWindow();
137 if (c ==
nullptr)
return;
141 if (this->background_img == SPR_TYCOON_IMG2_BEGIN) {
168 this->background_img = SPR_HIGHSCORE_CHART_BEGIN;
169 this->rank = ranking;
183 this->SetupHighScoreEndWindow();
194 if (hs[i].company[0] !=
'\0') {
195 TextColour colour = (this->rank == i) ? TC_RED : TC_BLACK;
207 static const NWidgetPart _nested_highscore_widgets[] = {
215 _nested_highscore_widgets,
lengthof(_nested_highscore_widgets)
222 _nested_highscore_widgets,
lengthof(_nested_highscore_widgets)
EventState
State of handling an event.
Functions related to OTTD's strings.
int8 SaveHighScoreValueNetwork()
Save the highscores in a network game when it has ended.
Definition of stuff that is very close to a company, like the company struct itself.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
bool _networking
are we in networking mode?
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
void OnPaint() override
The window must be repainted.
High level window description.
EventState OnKeyPress(WChar key, uint16 keycode) override
A key has been pressed.
WindowFlags flags
Window flags.
void DrawWidgets() const
Paint all widgets of a window.
static Titem * Get(size_t index)
Returns Titem with given index.
Hotkey related functions.
int32 performance_history
Company score (scale 0-1000)
The passed event is not handled.
static int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
HighScore _highscore_table[SP_HIGHSCORE_END][5]
various difficulty-settings; top 5
No profile, special "custom" highscore.
Tindex index
Index of this pool item.
#define CLRBITS(x, y)
Clears several bits in a variable.
static T max(const T a, const T b)
Returns the maximum of two values.
Functions, definitions and such used only by the GUI.
Special "multiplayer" highscore. Not saved, always specific to the current game.
bool _network_dedicated
are we a dedicated server?
Data structure for an opened window.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
void SetDParamStr(uint n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
void HideVitalWindows()
Delete all always on-top windows to get an empty screen.
The client is spectating.
Functions related to the gfx engine.
Definition of base types and functions in a cross-platform compatible way.
Center both horizontally and vertically.
A number of safeguards to prevent using unsafe methods.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
End game window shown at the end of the game.
void ShowEndGameChart()
Show the endgame victory screen in 2050.
Highscore; Window numbers:
bool game_paused_by_player
True if the game was paused by the player when the highscore window was opened.
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.
Basic functions/variables used all over the place.
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
#define FONT_HEIGHT_LARGE
Height of characters in the large (FS_LARGE) font.
Point GetTopLeft(int x, int y)
Return the coordinate of the screen such that a window of 640x480 is centered at the screen...
#define lengthof(x)
Return the length of an fixed size array.
PauseMode _pause_mode
The current pause mode.
void DeleteWindowByClass(WindowClass cls)
Delete all windows of a given class.
The max score that can be in the performance history.
No window, redirects to WC_MAIN_WINDOW.
Functions related to companies.
int8 SaveHighScoreValue(const Company *c)
Save the highscore for the company.
Declaration of functions and types defined in highscore.h and highscore_gui.h.
bool IsQuitKey(uint16 keycode)
Does the given keycode match one of the keycodes bound to 'quit game'?
Functions related to zooming.
CompanyEconomyEntry old_economy[MAX_HISTORY_QUARTERS]
Economic data of the company of the last MAX_HISTORY_QUARTERS quarters.
void OnPaint() override
The window must be repainted.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Functions related to commands.
Coordinates of a point in 2D.
void ShowHighscoreTable(int difficulty, int8 ranking)
Show the highscore table for a given difficulty.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Endscreen; Window numbers:
int width
width of the window (number of pixels to the right in x direction)
The passed event is handled.
WindowNumber window_number
Window number within the window class.
Window functions not directly related to making/drawing windows.
Manually align the window (so no automatic location finding)
uint32 WChar
Type for wide characters, i.e.
void ResizeWindow(Window *w, int delta_x, int delta_y, bool clamp_to_screen)
Resize the window.
Window white border counter bit mask.
void ShowVitalWindows()
Show the vital in-game windows.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Dimensions (a width and height) of a rectangle in 2D.
This file contains all sprite-related enums and defines.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
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.
static const Year ORIGINAL_END_YEAR
The original ending year.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.