Go to the documentation of this file.
24 #include "table/strings.h"
45 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
52 if (!s->IsAwarded()) {
81 void HandleClick(
const Subsidy *s)
88 default: NOT_REACHED();
98 default: NOT_REACHED();
116 uint num_awarded = 0;
117 uint num_not_awarded = 0;
127 if (num_awarded == 0) num_awarded = 1;
128 if (num_not_awarded == 0) num_not_awarded = 1;
131 return 3 + num_awarded + num_not_awarded;
147 void DrawCargoIcon(
const Rect &r,
int y_offset,
CargoID cid)
const
156 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
180 SetDParam(7, STR_SUBSIDIES_OFFERED_EXPIRY_TIME);
183 SetDParam(7, STR_SUBSIDIES_OFFERED_EXPIRY_DATE);
213 SetDParam(8, STR_SUBSIDIES_SUBSIDISED_EXPIRY_TIME);
217 SetDParam(8, STR_SUBSIDIES_SUBSIDISED_EXPIRY_DATE);
246 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
248 if (!gui_scope)
return;
253 static constexpr
NWidgetPart _nested_subsidies_list_widgets[] = {
270 static WindowDesc _subsidies_list_desc(__FILE__, __LINE__,
271 WDP_AUTO,
"list_subsidies", 500, 127,
274 std::begin(_nested_subsidies_list_widgets), std::end(_nested_subsidies_list_widgets)
278 void ShowSubsidiesList()
280 AllocateWindowDescFront<SubsidyListWindow>(&_subsidies_list_desc, 0);
void OnInit() override
Notification that the nested widget tree gets initialized.
uint CountLines()
Count the number of lines in this window.
static Titem * Get(size_t index)
Returns Titem with given index.
bool ScrollMainWindowToTile(TileIndex tile, bool instant)
Scrolls the viewport of the main window to a given location.
uint16_t remaining
Remaining months when this subsidy is valid.
void ShowExtraViewportWindow(TileIndex tile=INVALID_TILE)
Show a new Extra Viewport window.
Dimensions (a width and height) of a rectangle in 2D.
constexpr bool IsInsideMM(const T x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
@ WC_SUBSIDIES_LIST
Subsidies list; Window numbers:
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
bool _ctrl_pressed
Is Ctrl pressed?
bool IsAwarded() const
Tests whether this subsidy has been awarded to someone.
static bool UsingWallclockUnits(bool newgame=false)
Check if we are using wallclock units.
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
SpriteID GetCargoIcon() const
Get sprite for showing cargo of this type.
const Scrollbar * GetScrollbar(WidgetID widnum) const
Return the Scrollbar to a widget index.
std::pair< NewsReferenceType, NewsReferenceType > SetupSubsidyDecodeParam(const Subsidy *s, SubsidyDecodeParamType mode, uint parameter_offset)
Setup the string parameters for printing the subsidy at the screen, and compute the news reference fo...
Rect WithHeight(int height, bool end=false) const
Copy Rect and set its height.
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
High level window description.
constexpr uint Horizontal() const
Get total horizontal padding of RectPadding.
CargoID cargo_type
Cargo type involved in this subsidy, INVALID_CARGO for invalid subsidy.
Struct about subsidies, offered and awarded.
@ WDP_AUTO
Find a place automatically.
ResizeInfo resize
Resize information.
int32_t WindowNumber
Number to differentiate different windows of the same class.
@ FS_NORMAL
Index of the normal font in the font tables.
SourceID src
Index of source. Either TownID or IndustryID.
Rect Indent(int indent, bool end) const
Copy Rect and indent it from its position.
SourceID dst
Index of destination. Either TownID or IndustryID.
@ Gui
Subsidies listed in the Subsidy GUI.
Rect WithWidth(int width, bool end) const
Copy Rect and set its width.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
byte CargoID
Cargo slots to indicate a cargo type within a game.
Coordinates of a point in 2D.
@ Industry
Source/destination is an industry.
int CenterBounds(int min, int max, int size)
Determine where to draw a centred object inside a widget.
static YearMonthDay ConvertDateToYMD(Date date)
Converts a Date to a Year, Month & Day.
WindowNumber window_number
Window number within the window class.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
@ Town
Source/destination is a town.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
SourceType dst_type
Destination of subsidised path (SourceType::Industry or SourceType::Town)
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
void OnResize() override
Called after the window got resized.
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
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.
Data structure for an opened window.
SourceType src_type
Source of subsidised path (SourceType::Industry or SourceType::Town)
Specification of a rectangle with absolute coordinates of all edges.
CompanyID awarded
Subsidy is awarded to this company; INVALID_COMPANY if it's not awarded to anyone.
@ TD_RTL
Text is written right-to-left by default.
TextDirection _current_text_dir
Text direction of the currently selected language.
Dimension GetLargestCargoIconSize()
Get dimensions of largest cargo icon.
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
static Date date
Current date in days (day counter).