14 #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 = {
max(0, (_screen.width / 2) - (x / 2)),
max(0, (_screen.height / 2) - (y / 2))};
102 this->background_img = SPR_TYCOON_IMG1_BEGIN;
107 this->background_img = SPR_TYCOON_IMG2_BEGIN;
134 this->SetupHighScoreEndWindow();
138 if (c == NULL)
return;
142 if (this->background_img == SPR_TYCOON_IMG2_BEGIN) {
146 DrawStringMultiLine(pt.x + 15, pt.x + 640 - 25, pt.y + 90, pt.y + 160, STR_HIGHSCORE_PRESIDENT_OF_COMPANY_ACHIEVES_STATUS, TC_FROMSTRING,
SA_CENTER);
169 this->background_img = SPR_HIGHSCORE_CHART_BEGIN;
170 this->rank = ranking;
184 this->SetupHighScoreEndWindow();
193 DrawString(pt.x + 40, pt.x + 600, pt.y + 140 + (i * 55), STR_HIGHSCORE_POSITION);
195 if (hs[i].company[0] !=
'\0') {
196 TextColour colour = (this->rank == i) ? TC_RED : TC_BLACK;
199 DrawString(pt.x + 71, pt.x + 569, pt.y + 140 + (i * 55), STR_JUST_BIG_RAW_STRING, colour);
208 static const NWidgetPart _nested_highscore_widgets[] = {
216 _nested_highscore_widgets,
lengthof(_nested_highscore_widgets)
223 _nested_highscore_widgets,
lengthof(_nested_highscore_widgets)
EventState
State of handling an event.
Functions related to OTTD's strings.
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
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...
High level window description.
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.
HighScore _highscore_table[SP_HIGHSCORE_END][5]
various difficulty-settings; top 5
No profile, special "custom" highscore.
Tindex index
Index of this pool item.
The client is spectating.
virtual void OnPaint()
The window must be repainted.
virtual EventState OnKeyPress(WChar key, uint16 keycode)
A key has been pressed.
#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?
CompanyByte _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
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.
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.
virtual void OnPaint()
The window must be repainted.
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.
PauseModeByte _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'?
CompanyEconomyEntry old_economy[MAX_HISTORY_QUARTERS]
Economic data of the company of the last MAX_HISTORY_QUARTERS quarters.
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-NULL) 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.
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.