|
OpenTTD Source
14.0-beta3
|
Go to the documentation of this file.
24 #include "table/strings.h"
39 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
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;
141 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
164 SetDParam(7, STR_SUBSIDIES_OFFERED_EXPIRY_TIME);
167 SetDParam(7, STR_SUBSIDIES_OFFERED_EXPIRY_DATE);
196 SetDParam(8, STR_SUBSIDIES_SUBSIDISED_EXPIRY_TIME);
200 SetDParam(8, STR_SUBSIDIES_SUBSIDISED_EXPIRY_DATE);
228 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
230 if (!gui_scope)
return;
235 static constexpr
NWidgetPart _nested_subsidies_list_widgets[] = {
252 static WindowDesc _subsidies_list_desc(__FILE__, __LINE__,
253 WDP_AUTO,
"list_subsidies", 500, 127,
256 std::begin(_nested_subsidies_list_widgets), std::end(_nested_subsidies_list_widgets)
260 void ShowSubsidiesList()
262 AllocateWindowDescFront<SubsidyListWindow>(&_subsidies_list_desc, 0);
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:
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.
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...
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.
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.
SourceID dst
Index of destination. Either TownID or IndustryID.
@ Gui
Subsidies listed in the Subsidy GUI.
Coordinates of a point in 2D.
@ Industry
Source/destination is an industry.
static YearMonthDay ConvertDateToYMD(Date date)
Converts a Date to a Year, Month & Day.
WindowNumber window_number
Window number within the window class.
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
@ Town
Source/destination is a town.
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.
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
static Date date
Current date in days (day counter).