|
OpenTTD Source 20260108-master-g8ba1860eaa
|
GUI functionalities for NewGRF badges. More...
#include "stdafx.h"#include "core/flatset_type.hpp"#include "dropdown_type.h"#include "dropdown_func.h"#include "newgrf.h"#include "newgrf_badge.h"#include "newgrf_badge_config.h"#include "newgrf_badge_gui.h"#include "newgrf_badge_type.h"#include "settings_gui.h"#include "strings_func.h"#include "timer/timer_game_calendar.h"#include "window_gui.h"#include "window_type.h"#include "zoom_func.h"#include "table/strings.h"#include "dropdown_common_type.h"#include "safeguards.h"Go to the source code of this file.
Data Structures | |
| class | DropDownBadges< TBase, TEnd, TFs > |
| Drop down element that draws a list of badges. More... | |
| class | DropDownMover< TBase, TEnd, TFs > |
| Drop down component that shows extra buttons to indicate that the item can be moved up or down. More... | |
Typedefs | |
| using | DropDownListBadgeItem = DropDownBadges< DropDownString< DropDownSpacer< DropDownListStringItem, true >, FS_SMALL, true > > |
| using | DropDownListBadgeIconItem = DropDownBadges< DropDownString< DropDownSpacer< DropDownListIconItem, true >, FS_SMALL, true > > |
| using | DropDownListToggleMoverItem = DropDownMover< DropDownToggle< DropDownString< DropDownListItem > > > |
| using | DropDownListToggleItem = DropDownToggle< DropDownString< DropDownListItem > > |
Enumerations | |
| enum | BadgeClick : int { BADGE_CLICK_NONE , BADGE_CLICK_MOVE_UP , BADGE_CLICK_MOVE_DOWN , BADGE_CLICK_TOGGLE_ICON , BADGE_CLICK_TOGGLE_FILTER } |
Functions | |
| static Dimension | GetBadgeMaximalDimension (BadgeClassID class_index, GrfSpecFeature feature) |
| Get the largest badge size (within limits) for a badge class. | |
| static bool | operator< (const GUIBadgeClasses::Element &a, const GUIBadgeClasses::Element &b) |
| int | DrawBadgeNameList (Rect r, std::span< const BadgeID > badges, GrfSpecFeature) |
| 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, bool shaded) |
| 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, bool shaded) |
| 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, bool shaded) |
| DropDownList | BuildBadgeClassConfigurationList (const GUIBadgeClasses &gui_classes, uint columns, std::span< const StringID > column_separators, Colours bg_colour) |
| static void | BadgeClassToggleVisibility (GrfSpecFeature feature, Badge &class_badge, int click_result, BadgeFilterChoices &choices) |
| Toggle badge class visibility. | |
| static void | BadgeClassMovePrevious (GrfSpecFeature feature, Badge &class_badge) |
| Move the badge class to the previous position. | |
| static void | BadgeClassMoveNext (GrfSpecFeature feature, Badge &class_badge, uint columns) |
| Move the badge class to the next position. | |
| 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. | |
Variables | |
| static constexpr uint | MAX_BADGE_HEIGHT = 12 |
| Maximal height of a badge sprite. | |
| static constexpr uint | MAX_BADGE_WIDTH = MAX_BADGE_HEIGHT * 2 |
| Maximal width. | |
GUI functionalities for NewGRF badges.
Definition in file newgrf_badge_gui.cpp.
| using DropDownListBadgeIconItem = DropDownBadges<DropDownString<DropDownSpacer<DropDownListIconItem, true>, FS_SMALL, true> > |
Definition at line 249 of file newgrf_badge_gui.cpp.
| using DropDownListBadgeItem = DropDownBadges<DropDownString<DropDownSpacer<DropDownListStringItem, true>, FS_SMALL, true> > |
Definition at line 248 of file newgrf_badge_gui.cpp.
Definition at line 324 of file newgrf_badge_gui.cpp.
| using DropDownListToggleMoverItem = DropDownMover<DropDownToggle<DropDownString<DropDownListItem> >> |
Definition at line 323 of file newgrf_badge_gui.cpp.
| enum BadgeClick : int |
Definition at line 326 of file newgrf_badge_gui.cpp.
| std::pair< WidgetID, WidgetID > AddBadgeDropdownFilters | ( | Window * | window, |
| WidgetID | container_id, | ||
| WidgetID | widget, | ||
| Colours | colour, | ||
| GrfSpecFeature | feature | ||
| ) |
Add badge drop down filter widgets.
| 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. |
Definition at line 561 of file newgrf_badge_gui.cpp.
References NWidgetContainer::Clear(), GetBadgeClassConfigItem(), GetClassBadge(), and Window::GetWidget().
Referenced by BuildVehicleWindow::OnInit(), and PickerWindow::OnInit().
|
static |
Move the badge class to the next position.
| feature | Feature being used. |
| class_badge | Class badge. |
| columns | Maximum column number permitted. |
Definition at line 433 of file newgrf_badge_gui.cpp.
References Badge::class_index, GUIBadgeClasses::Element::class_index, GetBadgeClassConfiguration(), Badge::label, and BadgeClassConfigItem::label.
Referenced by HandleBadgeConfigurationDropDownClick().
|
static |
Move the badge class to the previous position.
| feature | Feature being used. |
| class_badge | Class badge. |
Definition at line 403 of file newgrf_badge_gui.cpp.
References Badge::class_index, GUIBadgeClasses::Element::class_index, GetBadgeClassConfiguration(), Badge::label, and BadgeClassConfigItem::label.
Referenced by HandleBadgeConfigurationDropDownClick().
|
static |
Toggle badge class visibility.
| feature | Feature being used. |
| class_badge | Class badge. |
| click | Dropdown click result. |
Definition at line 385 of file newgrf_badge_gui.cpp.
References Badge::class_index, GetBadgeClassConfiguration(), Badge::label, BadgeClassConfigItem::label, and ResetBadgeFilter().
Referenced by HandleBadgeConfigurationDropDownClick().
| DropDownList BuildBadgeClassConfigurationList | ( | const GUIBadgeClasses & | gui_classes, |
| uint | columns, | ||
| std::span< const StringID > | column_separators, | ||
| Colours | bg_colour | ||
| ) |
Definition at line 334 of file newgrf_badge_gui.cpp.
| 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.
| 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().
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 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().
Referenced by DrawVehiclePurchaseInfo(), BuildIndustryWindow::DrawWidget(), BuildObjectWindow::DrawWidget(), BuildAirportWindow::OnPaint(), BuildRailStationWindow::OnPaint(), and BuildRoadStationWindow::OnPaint().
|
static |
Get the largest badge size (within limits) for a badge class.
| class_index | Badge class. |
| feature | Feature being used. |
Definition at line 42 of file newgrf_badge_gui.cpp.
References GetBadges(), GetBadgeSprite(), GetSpriteSize(), MAX_BADGE_HEIGHT, MAX_BADGE_WIDTH, Normal, and PalSpriteID::sprite.
Referenced by NWidgetBadgeFilter::GetDropDownList(), and GUIBadgeClasses::GUIBadgeClasses().
| bool HandleBadgeConfigurationDropDownClick | ( | GrfSpecFeature | feature, |
| uint | columns, | ||
| int | result, | ||
| int | click_result, | ||
| BadgeFilterChoices & | choices | ||
| ) |
Handle the badge configuration drop down selection.
| feature | Feature being used. |
| columns | Maximum column number permitted. |
| result | Selected dropdown item value. |
| click_result | Dropdown click result. |
Definition at line 465 of file newgrf_badge_gui.cpp.
References BadgeClassMoveNext(), BadgeClassMovePrevious(), BadgeClassToggleVisibility(), GetClassBadge(), and ResetBadgeClassConfiguration().
Referenced by BuildVehicleWindow::OnDropdownSelect(), and PickerWindow::OnDropdownSelect().
| 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, | ||
| bool | shaded | ||
| ) |
Definition at line 261 of file newgrf_badge_gui.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, | ||
| Money | cost, | ||
| std::string && | str, | ||
| int | value, | ||
| bool | masked, | ||
| bool | shaded | ||
| ) |
Definition at line 256 of file newgrf_badge_gui.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, | ||
| std::string && | str, | ||
| int | value, | ||
| bool | masked, | ||
| bool | shaded | ||
| ) |
Definition at line 251 of file newgrf_badge_gui.cpp.
|
static |
Definition at line 60 of file newgrf_badge_gui.cpp.
| void ResetBadgeFilter | ( | BadgeFilterChoices & | choices, |
| BadgeClassID | badge_class_index | ||
| ) |
Reset badge filter choice for a class.
Definition at line 586 of file newgrf_badge_gui.cpp.
Referenced by BadgeClassToggleVisibility(), BuildVehicleWindow::OnDropdownSelect(), and PickerWindow::OnDropdownSelect().
| void SetBadgeFilter | ( | BadgeFilterChoices & | choices, |
| BadgeID | badge_index | ||
| ) |
Set badge filter choice for a class.
| choices | Badge filter choices. |
| badge_index | Badge to set. The badge class is inferred from the badge. |
Definition at line 597 of file newgrf_badge_gui.cpp.
References Badge::class_index, and GetBadge().
Referenced by BuildVehicleWindow::OnDropdownSelect(), and PickerWindow::OnDropdownSelect().
|
staticconstexpr |
Maximal height of a badge sprite.
Definition at line 33 of file newgrf_badge_gui.cpp.
Referenced by GetBadgeMaximalDimension().
|
staticconstexpr |
Maximal width.
Definition at line 34 of file newgrf_badge_gui.cpp.
Referenced by GetBadgeMaximalDimension().