OpenTTD Source: src/newgrf_badge_config.cpp File Reference

OpenTTD Source 15.3

Data Structures | Functions | Variables
newgrf_badge_config.cpp File Reference

Functionality for NewGRF badge configuration. More...

`#include "stdafx.h"`
`#include "core/string_consumer.hpp"`
`#include "ini_type.h"`
`#include "newgrf.h"`
`#include "newgrf_badge.h"`
`#include "newgrf_badge_config.h"`
`#include "newgrf_badge_type.h"`
`#include "table/strings.h"`
`#include "safeguards.h"`

Go to the source code of this file.

## Data Structures
class | BadgeClassConfig
| Global state for badge class configuration. More...

## Functions
std::span< BadgeClassConfigItem > | GetBadgeClassConfiguration (GrfSpecFeature feature)
| Get the badge user configuration for a feature.
void | AddBadgeClassesToConfiguration ()
| Add current badge classes to user configuration.
void | ResetBadgeClassConfiguration (GrfSpecFeature feature)
| Reset badge class configuration for a feature.
std::pair< const BadgeClassConfigItem &, int > | GetBadgeClassConfigItem (GrfSpecFeature feature, std::string_view label)
| Get configuration for a badge class.
static void | BadgeClassLoadConfigFeature (const IniFile &ini, GrfSpecFeature feature)
| Load badge column preferences.
void | BadgeClassLoadConfig (const IniFile &ini)
| Load badge column preferences.
static void | BadgeClassSaveConfigFeature (IniFile &ini, GrfSpecFeature feature)
| Save badge column preferences.
void | BadgeClassSaveConfig (IniFile &ini)
| Save badge column preferences.

## Variables
static BadgeClassConfig | _badge_config
| Static instance of badge class configuration state.

## Detailed Description

Functionality for NewGRF badge configuration.

Definition in file newgrf_badge_config.cpp.

## Function Documentation

## ◆ AddBadgeClassesToConfiguration()

void AddBadgeClassesToConfiguration | ( |  | ) |

Add current badge classes to user configuration.

Definition at line 76 of file newgrf_badge_config.cpp.

References _badge_config, Badge::features, GetBadge(), GetClassBadges(), Badge::label, BadgeClassConfigItem::label, Badge::name, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

Referenced by FinaliseBadges().

## ◆ BadgeClassLoadConfig()

void BadgeClassLoadConfig | ( | const IniFile & | ini | ) |

Load badge column preferences.

Parameters

  ini | IniFile to load to.

Definition at line 169 of file newgrf_badge_config.cpp.

References BadgeClassLoadConfigFeature().

Referenced by LoadFromConfig().

## ◆ BadgeClassLoadConfigFeature()

static void BadgeClassLoadConfigFeature | ( | const IniFile & | ini,
|  | GrfSpecFeature | feature
| ) |  |
| static

Load badge column preferences.

Parameters

  ini | IniFile to load to.
  feature | Feature to load.

Definition at line 138 of file newgrf_badge_config.cpp.

References _badge_config, IniLoadFile::GetGroup(), IniGroup::items, StringConsumer::ReadCharIf(), and StringConsumer::TryReadIntegerBase().

Referenced by BadgeClassLoadConfig().

## ◆ BadgeClassSaveConfig()

void BadgeClassSaveConfig | ( | IniFile & | ini | ) |

Save badge column preferences.

Parameters

  ini | IniFile to save to.

Definition at line 198 of file newgrf_badge_config.cpp.

References BadgeClassSaveConfigFeature().

Referenced by SaveToConfig().

## ◆ BadgeClassSaveConfigFeature()

static void BadgeClassSaveConfigFeature | ( | IniFile & | ini,
|  | GrfSpecFeature | feature
| ) |  |
| static

Save badge column preferences.

Parameters

  ini | IniFile to save to.
  feature | Feature to save.

Definition at line 181 of file newgrf_badge_config.cpp.

References _badge_config, IniGroup::Clear(), IniGroup::CreateItem(), IniLoadFile::GetOrCreateGroup(), IniItem::SetValue(), and to_underlying().

Referenced by BadgeClassSaveConfig().

## ◆ GetBadgeClassConfigItem()

std::pair< const BadgeClassConfigItem &, int > GetBadgeClassConfigItem | ( | GrfSpecFeature | feature,
|  | std::string_view | label
| ) |  |

Get configuration for a badge class.

Parameters

  feature | Feature being used.
  label | Badge class label.

Returns
  badge class configuration item.

Definition at line 119 of file newgrf_badge_config.cpp.

References GetBadgeClassConfiguration(), and BadgeClassConfigItem::label.

Referenced by AddBadgeDropdownFilters(), and GUIBadgeClasses::GUIBadgeClasses().

## ◆ GetBadgeClassConfiguration()

std::span< BadgeClassConfigItem > GetBadgeClassConfiguration | ( | GrfSpecFeature | feature | ) |

Get the badge user configuration for a feature.

Returns
  badge configuration for the given feature.

Definition at line 66 of file newgrf_badge_config.cpp.

References _badge_config, and to_underlying().

Referenced by GetBadgeClassConfigItem().

## ◆ ResetBadgeClassConfiguration()

void ResetBadgeClassConfiguration | ( | GrfSpecFeature | feature | ) |

Reset badge class configuration for a feature.

Parameters

  feature | Feature to reset.

Definition at line 99 of file newgrf_badge_config.cpp.

References _badge_config, GetBadge(), GetClassBadges(), Badge::label, and Badge::name.

Referenced by HandleBadgeConfigurationDropDownClick().

## Variable Documentation

## ◆ _badge_config

BadgeClassConfig _badge_config
| static

Static instance of badge class configuration state.

Definition at line 60 of file newgrf_badge_config.cpp.

Referenced by AddBadgeClassesToConfiguration(), BadgeClassLoadConfigFeature(), BadgeClassSaveConfigFeature(), GetBadgeClassConfiguration(), and ResetBadgeClassConfiguration().