OpenTTD Source: src/newgrf_badge_gui.h File Reference

OpenTTD Source 15.0-RC2

Data Structures | Functions
newgrf_badge_gui.h File Reference

GUI functions related to NewGRF badges. More...

`#include "dropdown_type.h"`
`#include "newgrf.h"`
`#include "newgrf_badge.h"`
`#include "newgrf_badge_type.h"`
`#include "timer/timer_game_calendar.h"`

Go to the source code of this file.

## Data Structures
class | GUIBadgeClasses
struct | GUIBadgeClasses::Element
class | NWidgetBadgeFilter

## Functions
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 &gui_classes, std::span< const BadgeID > badges, GrfSpecFeature feature, std::optional< TimerGameCalendar::Date > introduction_date, PaletteID remap)
| Draw a badge column group.
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, std::string &&str, int value, bool masked=false, bool shaded=false)
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, Money cost, std::string &&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, Money cost, const Dimension &dim, SpriteID sprite, PaletteID palette, std::string &&str, int value, bool masked=false, bool shaded=false)
DropDownList | BuildBadgeClassConfigurationList (const class GUIBadgeClasses &badge_class, uint columns, std::span< const StringID > column_separators, Colours bg_colour)
bool | HandleBadgeConfigurationDropDownClick (GrfSpecFeature feature, uint columns, int result, int click_result, BadgeFilterChoices &choices)
| Handle the badge configuration drop down selection.
std::pair< WidgetID, WidgetID > | AddBadgeDropdownFilters (Window *window, WidgetID container_id, WidgetID widget, Colours colour, GrfSpecFeature feature)
| Add badge drop down filter widgets.
void | ResetBadgeFilter (BadgeFilterChoices &choices, BadgeClassID badge_class_index)
| Reset badge filter choice for a class.
void | SetBadgeFilter (BadgeFilterChoices &choices, BadgeID badge_index)
| Set badge filter choice for a class.

## Detailed Description

GUI functions related to NewGRF badges.

Definition in file newgrf_badge_gui.h.

## Function Documentation

## ◆ AddBadgeDropdownFilters()

std::pair< WidgetID, WidgetID > AddBadgeDropdownFilters | ( | Window * | window,
|  | WidgetID | container_id,
|  | WidgetID | widget,
|  | Colours | colour,
|  | GrfSpecFeature | feature
| ) |  |

Add badge drop down filter widgets.

Parameters

  window | Window that holds the container.
  container | Container widget index to hold filter widgets.
  widget | Widget index to apply to first filter.
  colour | Background colour of widgets.
  feature | GRF feature for filters.

Returns
  First and last widget indexes of filter widgets.

Definition at line 561 of file newgrf_badge_gui.cpp.

References NWidgetContainer::Clear(), GetBadgeClassConfigItem(), GetClassBadge(), and Window::GetWidget().

## ◆ DrawBadgeColumn()

void DrawBadgeColumn | ( | Rect | r,
|  | int | column_group,
|  | const GUIBadgeClasses & | gui_classes,
|  | std::span< const BadgeID > | badges,
|  | GrfSpecFeature | feature,
|  | std::optional< TimerGameCalendar::Date > | introduction_date,
|  | PaletteID | remap
| ) |  |

Draw a badge column group.

Parameters

  r | rect to draw within.
  column_group | column to draw.
  gui_classes | gui 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 165 of file newgrf_badge_gui.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().

## ◆ DrawBadgeNameList()

int DrawBadgeNameList | ( | Rect | r,
|  | std::span< const BadgeID > | badges,
|  | GrfSpecFeature | feature
| ) |  |

Draw names for a list of badge labels.

Parameters

  r | Rect to draw in.
  badges | List of badges.
  feature | GRF feature being used.

Returns
  Vertical position after drawing is complete.

Definition at line 120 of file newgrf_badge_gui.cpp.

References AppendStringInPlace(), Badge::class_index, DrawStringMultiLine(), Badge::flags, GetBadge(), GetClassBadge(), GetListSeparator(), GetString(), FlatSet< Tkey, Tcompare >::insert(), Badge::name, NameListFirstOnly, NameListSkip, NameListStop, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

## ◆ HandleBadgeConfigurationDropDownClick()

bool HandleBadgeConfigurationDropDownClick | ( | GrfSpecFeature | feature,
|  | uint | columns,
|  | int | result,
|  | int | click_result,
|  | BadgeFilterChoices & | choices
| ) |  |

Handle the badge configuration drop down selection.

Parameters

  feature | Feature being used.
  columns | Maximum column number permitted.
  result | Selected dropdown item value.
  click_result | Dropdown click result.

Returns
  true iff the caller should reinitialise their widgets.

Definition at line 465 of file newgrf_badge_gui.cpp.

References GetClassBadge(), and ResetBadgeClassConfiguration().

## ◆ MakeDropDownListBadgeIconItem()

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,
|  | Money | cost,
|  | const Dimension & | dim,
|  | SpriteID | sprite,
|  | PaletteID | palette,
|  | std::string && | str,
|  | int | value,
|  | bool | masked = `false`,
|  | bool | shaded = `false`
| ) |  |

Definition at line 261 of file newgrf_badge_gui.cpp.

## ◆ MakeDropDownListBadgeItem() [1/2]

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,
|  | Money | cost,
|  | std::string && | str,
|  | int | value,
|  | bool | masked = `false`,
|  | bool | shaded = `false`
| ) |  |

Definition at line 256 of file newgrf_badge_gui.cpp.

## ◆ MakeDropDownListBadgeItem() [2/2]

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,
|  | std::string && | str,
|  | int | value,
|  | bool | masked = `false`,
|  | bool | shaded = `false`
| ) |  |

Definition at line 251 of file newgrf_badge_gui.cpp.

## ◆ ResetBadgeFilter()

void ResetBadgeFilter | ( | BadgeFilterChoices & | choices,
|  | BadgeClassID | badge_class_index
| ) |  |

Reset badge filter choice for a class.

Parameters

  choices | Badge filter choices.
  badge_class_index | Badge class to reset.

Definition at line 586 of file newgrf_badge_gui.cpp.

## ◆ SetBadgeFilter()

void SetBadgeFilter | ( | BadgeFilterChoices & | choices,
|  | BadgeID | badge_index
| ) |  |

Set badge filter choice for a class.

Parameters

  choices | Badge filter choices.
  badge_index | Badge to set. The badge class is inferred from the badge.

Note
  if the badge_index is invalid, the filter will be reset instead.

Definition at line 597 of file newgrf_badge_gui.cpp.

References Badge::class_index, and GetBadge().