24 #include "table/strings.h" 46 if (!s->IsAwarded()) {
75 void HandleClick(
const Subsidy *s)
82 default: NOT_REACHED();
92 default: NOT_REACHED();
110 uint num_awarded = 0;
111 uint num_not_awarded = 0;
121 if (num_awarded == 0) num_awarded = 1;
122 if (num_not_awarded == 0) num_not_awarded = 1;
125 return 3 + num_awarded + num_not_awarded;
133 resize->height = d.height;
166 DrawString(x, right, y + pos * FONT_HEIGHT_NORMAL, STR_SUBSIDIES_OFFERED_FROM_TO);
174 if (
IsInsideMM(pos, 0, cap))
DrawString(x, right, y + pos * FONT_HEIGHT_NORMAL, STR_SUBSIDIES_NONE);
180 if (
IsInsideMM(pos, 0, cap))
DrawString(x, right, y + pos * FONT_HEIGHT_NORMAL, STR_SUBSIDIES_SUBSIDISED_TITLE);
192 DrawString(x, right, y + pos * FONT_HEIGHT_NORMAL, STR_SUBSIDIES_SUBSIDISED_FROM_TO);
200 if (
IsInsideMM(pos, 0, cap))
DrawString(x, right, y + pos * FONT_HEIGHT_NORMAL, STR_SUBSIDIES_NONE);
217 if (!gui_scope)
return;
222 static const NWidgetPart _nested_subsidies_list_widgets[] = {
240 WDP_AUTO,
"list_subsidies", 500, 127,
243 _nested_subsidies_list_widgets,
lengthof(_nested_subsidies_list_widgets)
247 void ShowSubsidiesList()
249 AllocateWindowDescFront<SubsidyListWindow>(&_subsidies_list_desc, 0);
Functions related to OTTD's strings.
Source/destination is a town.
Pair SetupSubsidyDecodeParam(const Subsidy *s, bool mode)
Setup the string parameters for printing the subsidy at the screen, and compute the news reference fo...
ResizeInfo resize
Resize information.
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
CompanyID awarded
Subsidy is awarded to this company; INVALID_COMPANY if it's not awarded to anyone.
High level window description.
SourceID src
Index of source. Either TownID or IndustryID.
bool IsAwarded() const
Tests whether this subsidy has been awarded to someone.
static Titem * Get(size_t index)
Returns Titem with given index.
Functions related to dates.
SourceType dst_type
Destination of subsidised path (ST_INDUSTRY or ST_TOWN)
Offset at top to draw the frame rectangular area.
SourceID dst
Index of destination. Either TownID or IndustryID.
uint CountLines()
Count the number of lines in this window.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
Functions, definitions and such used only by the GUI.
Functions related to (drawing on) viewports.
Data structure for an opened window.
bool _ctrl_pressed
Is Ctrl pressed?
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
static bool IsInsideMM(const T x, const size_t min, const size_t max)
Checks if a value is in an interval.
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Definition of base types and functions in a cross-platform compatible way.
Data structure to convert between Date and triplet (year, month, and day).
A number of safeguards to prevent using unsafe methods.
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
Subsidies list; Window numbers:
Offset at bottom to draw the frame rectangular area.
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.
#define lengthof(x)
Return the length of an fixed size array.
void ShowExtraViewPortWindow(TileIndex tile=INVALID_TILE)
Show a new Extra Viewport window.
Struct about subsidies, offered and awarded.
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
No window, redirects to WC_MAIN_WINDOW.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
uint32 TileIndex
The index/ID of a Tile.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
SourceType src_type
Source of subsidised path (ST_INDUSTRY or ST_TOWN)
bool ScrollMainWindowToTile(TileIndex tile, bool instant)
Scrolls the viewport of the main window to a given location.
Coordinates of a point in 2D.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Offset at right to draw the frame rectangular area.
int32 WindowNumber
Number to differentiate different windows of the same class.
Specification of a rectangle with absolute coordinates of all edges.
WindowNumber window_number
Window number within the window class.
byte remaining
Remaining months when this subsidy is valid.
Find a place automatically.
void OnResize() override
Called after the window got resized.
GUI functions that shouldn't be here.
Date _date
Current date in days (day counter)
void ConvertDateToYMD(Date date, YearMonthDay *ymd)
Converts a Date to a Year, Month & Day.
Dimensions (a width and height) of a rectangle in 2D.
Offset at left to draw the frame rectangular area.
Functions related to subsidies.
Source/destination is an industry.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.