OpenTTD Source 20250220-master-gf89924a727
|
Functions related to NewGRF badges. More...
#include "dropdown_type.h"
#include "newgrf.h"
#include "newgrf_badge_type.h"
#include "newgrf_commons.h"
#include "strings_type.h"
#include "timer/timer_game_calendar.h"
Go to the source code of this file.
Data Structures | |
class | Badge |
class | GUIBadgeClasses |
struct | GUIBadgeClasses::Element |
class | BadgeTextFilter |
Functions | |
void | ResetBadges () |
Reset badges to the default state. | |
Badge & | GetOrCreateBadge (std::string_view label) |
Register a badge label and return its global index. | |
void | MarkBadgeSeen (BadgeID index, GrfSpecFeature feature) |
Mark a badge a seen (used) by a feature. | |
void | AppendCopyableBadgeList (std::vector< BadgeID > &dst, std::span< const BadgeID > src, GrfSpecFeature feature) |
Append copyable badges from a list onto another. | |
void | ApplyBadgeFeaturesToClassBadges () |
Apply features from all badges to their badge classes. | |
Badge * | GetBadge (BadgeID index) |
Get a badge if it exists. | |
Badge * | GetBadgeByLabel (std::string_view label) |
Get a badge by label if it exists. | |
Badge * | GetClassBadge (BadgeClassID class_index) |
Get the badge class of a badge label. | |
int | DrawBadgeNameList (Rect r, std::span< const BadgeID > badges, GrfSpecFeature feature) |
Draw names for a list of badge labels. | |
void | DrawBadgeColumn (Rect r, int column_group, const GUIBadgeClasses &badge_classes, std::span< const BadgeID > badges, GrfSpecFeature feature, std::optional< TimerGameCalendar::Date > introduction_date, PaletteID remap) |
Draw a badge column group. | |
uint32_t | GetBadgeVariableResult (const struct GRFFile &grffile, std::span< const BadgeID > badges, uint32_t parameter) |
std::unique_ptr< DropDownListItem > | MakeDropDownListBadgeItem (const std::shared_ptr< GUIBadgeClasses > &gui_classes, std::span< const BadgeID > badges, GrfSpecFeature feature, std::optional< TimerGameCalendar::Date > introduction_date, StringID str, int value, bool masked=false, bool shaded=false) |
std::unique_ptr< DropDownListItem > | MakeDropDownListBadgeIconItem (const std::shared_ptr< GUIBadgeClasses > &gui_classes, std::span< const BadgeID > badges, GrfSpecFeature feature, std::optional< TimerGameCalendar::Date > introduction_date, const Dimension &dim, SpriteID sprite, PaletteID palette, StringID str, int value, bool masked=false, bool shaded=false) |
Functions related to NewGRF badges.
Definition in file newgrf_badge.h.
void AppendCopyableBadgeList | ( | std::vector< BadgeID > & | dst, |
std::span< const BadgeID > | src, | ||
GrfSpecFeature | feature | ||
) |
Append copyable badges from a list onto another.
Badges must exist and be marked with the Copy flag.
dst | Destination badge list. |
src | Source badge list. |
feature | Feature of list. |
Definition at line 237 of file newgrf_badge.cpp.
References Copy, Badge::features, Badge::flags, GetBadge(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().
Referenced by FinaliseEngineArray().
void ApplyBadgeFeaturesToClassBadges | ( | ) |
Apply features from all badges to their badge classes.
Definition at line 254 of file newgrf_badge.cpp.
References _badges, Badge::features, GetClassBadge(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), and Badges::specs.
Referenced by FinaliseBadges().
void DrawBadgeColumn | ( | Rect | r, |
int | column_group, | ||
const GUIBadgeClasses & | badge_classes, | ||
std::span< const BadgeID > | badges, | ||
GrfSpecFeature | feature, | ||
std::optional< TimerGameCalendar::Date > | introduction_date, | ||
PaletteID | remap | ||
) |
Draw a badge column group.
r | rect to draw within. |
column_group | column to draw. |
badge_classes | badge classes. |
badges | badges to draw. |
feature | feature being used. |
introduction_date | introduction date of item. |
remap | palette remap to for company-coloured badges. |
Definition at line 482 of file newgrf_badge.cpp.
References _current_text_dir, Badge::class_index, GetBadge(), GetBadgeSprite(), Rect::Indent(), PalSpriteID::pal, SA_CENTER, WidgetDimensions::scaled, ScaleGUITrad(), PalSpriteID::sprite, TD_RTL, and Rect::WithWidth().
Referenced by BuildIndustryWindow::DrawWidget(), and PickerWindow::DrawWidget().
int DrawBadgeNameList | ( | Rect | r, |
std::span< const BadgeID > | badges, | ||
GrfSpecFeature | feature | ||
) |
Draw names for a list of badge labels.
r | Rect to draw in. |
badges | List of badges. |
feature | GRF feature being used. |
Definition at line 436 of file newgrf_badge.cpp.
References AppendStringInPlace(), Badge::class_index, DrawStringMultiLine(), Badge::flags, GetBadge(), GetClassBadge(), GetListSeparator(), Badge::name, NameListFirstOnly, NameListStop, SetDParam(), SetDParamStr(), and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().
Referenced by DrawVehiclePurchaseInfo(), BuildIndustryWindow::DrawWidget(), BuildObjectWindow::DrawWidget(), BuildAirportWindow::OnPaint(), BuildRailStationWindow::OnPaint(), and BuildRoadStationWindow::OnPaint().
Get a badge if it exists.
index | Index of badge. |
Definition at line 99 of file newgrf_badge.cpp.
References _badges, and Badges::specs.
Referenced by AppendCopyableBadgeList(), DrawBadgeColumn(), DrawBadgeNameList(), NewGRFInspectWindow::DrawMainPanelWidget(), GetClassBadge(), MarkBadgeSeen(), and UsedBadgeClasses::UsedBadgeClasses().
Badge * GetBadgeByLabel | ( | std::string_view | label | ) |
Get a badge by label if it exists.
label | Label of badge. |
Definition at line 110 of file newgrf_badge.cpp.
References _badges, Badge::label, and Badges::specs.
Referenced by FinaliseBadges().
Badge * GetClassBadge | ( | BadgeClassID | class_index | ) |
Get the badge class of a badge label.
label | Label to get class of. |
Definition at line 123 of file newgrf_badge.cpp.
References _badges, Badges::classes, and GetBadge().
Referenced by ApplyBadgeFeaturesToClassBadges(), DrawBadgeNameList(), GUIBadgeClasses::GUIBadgeClasses(), and UsedBadgeClasses::UsedBadgeClasses().
Badge & GetOrCreateBadge | ( | std::string_view | label | ) |
Register a badge label and return its global index.
label | Badge label to register. |
Definition at line 68 of file newgrf_badge.cpp.
References _badges, BADGE_CLASS_SEPARATOR, Badge::class_index, GetOrCreateBadge(), GetOrCreateBadgeClass(), Badge::label, and Badges::specs.
Referenced by GetOrCreateBadge().
std::unique_ptr< DropDownListItem > MakeDropDownListBadgeIconItem | ( | const std::shared_ptr< GUIBadgeClasses > & | gui_classes, |
std::span< const BadgeID > | badges, | ||
GrfSpecFeature | feature, | ||
std::optional< TimerGameCalendar::Date > | introduction_date, | ||
const Dimension & | dim, | ||
SpriteID | sprite, | ||
PaletteID | palette, | ||
StringID | str, | ||
int | value, | ||
bool | masked = false , |
||
bool | shaded = false |
||
) |
Definition at line 551 of file newgrf_badge.cpp.
std::unique_ptr< DropDownListItem > MakeDropDownListBadgeItem | ( | const std::shared_ptr< GUIBadgeClasses > & | gui_classes, |
std::span< const BadgeID > | badges, | ||
GrfSpecFeature | feature, | ||
std::optional< TimerGameCalendar::Date > | introduction_date, | ||
StringID | str, | ||
int | value, | ||
bool | masked = false , |
||
bool | shaded = false |
||
) |
Definition at line 546 of file newgrf_badge.cpp.
void MarkBadgeSeen | ( | BadgeID | index, |
GrfSpecFeature | feature | ||
) |
Mark a badge a seen (used) by a feature.
Definition at line 223 of file newgrf_badge.cpp.
References Badge::features, GetBadge(), and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set().
Referenced by ReadBadgeList().
void ResetBadges | ( | ) |
Reset badges to the default state.
Definition at line 58 of file newgrf_badge.cpp.
References _badges.
Referenced by ResetNewGRFData().