26 #include "table/strings.h" 48 FOR_ALL_SUBSIDIES(s) {
67 FOR_ALL_SUBSIDIES(s) {
78 void HandleClick(
const Subsidy *s)
85 default: NOT_REACHED();
95 default: NOT_REACHED();
113 uint num_awarded = 0;
114 uint num_not_awarded = 0;
116 FOR_ALL_SUBSIDIES(s) {
125 if (num_awarded == 0) num_awarded = 1;
126 if (num_not_awarded == 0) num_not_awarded = 1;
129 return 3 + num_awarded + num_not_awarded;
137 resize->height = d.height;
165 FOR_ALL_SUBSIDIES(s) {
171 DrawString(x, right, y + pos * FONT_HEIGHT_NORMAL, STR_SUBSIDIES_OFFERED_FROM_TO);
179 if (
IsInsideMM(pos, 0, cap))
DrawString(x, right, y + pos * FONT_HEIGHT_NORMAL, STR_SUBSIDIES_NONE);
185 if (
IsInsideMM(pos, 0, cap))
DrawString(x, right, y + pos * FONT_HEIGHT_NORMAL, STR_SUBSIDIES_SUBSIDISED_TITLE);
189 FOR_ALL_SUBSIDIES(s) {
197 DrawString(x, right, y + pos * FONT_HEIGHT_NORMAL, STR_SUBSIDIES_SUBSIDISED_FROM_TO);
205 if (
IsInsideMM(pos, 0, cap))
DrawString(x, right, y + pos * FONT_HEIGHT_NORMAL, STR_SUBSIDIES_NONE);
222 if (!gui_scope)
return;
227 static const NWidgetPart _nested_subsidies_list_widgets[] = {
245 WDP_AUTO,
"list_subsidies", 500, 127,
248 _nested_subsidies_list_widgets,
lengthof(_nested_subsidies_list_widgets)
252 void ShowSubsidiesList()
254 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...
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.
static bool IsInsideMM(const T x, const uint min, const uint max)
Checks if a value is in an interval.
Offset at top to draw the frame rectangular area.
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
SourceID dst
Index of destination. Either TownID or IndustryID.
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
uint CountLines()
Count the number of lines in this window.
SourceTypeByte src_type
Source of subsidised path (ST_INDUSTRY or ST_TOWN)
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.
#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.
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
CompanyByte awarded
Subsidy is awarded to this company; INVALID_COMPANY if it's not awarded to anyone.
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.
virtual void OnResize()
Called after the window got resized.
uint32 TileIndex
The index/ID of a Tile.
SourceTypeByte dst_type
Destination of subsidised path (ST_INDUSTRY or ST_TOWN)
Source/destination is an industry.
bool ScrollMainWindowToTile(TileIndex tile, bool instant)
Scrolls the viewport of the main window to a given location.
Coordinates of a point in 2D.
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.
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.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.