OpenTTD Source 20250524-master-gc366e6a48e
newgrf_badge_gui.h
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
7
10#ifndef NEWGRF_BADGE_GUI_H
11#define NEWGRF_BADGE_GUI_H
12
13#include "dropdown_type.h"
14#include "newgrf.h"
15#include "newgrf_badge_type.h"
17
19public:
20 struct Element {
22 uint8_t column_group;
23 bool visible;
26 std::string_view label;
27 };
28
29 GUIBadgeClasses() = default;
30 explicit GUIBadgeClasses(GrfSpecFeature feature);
31
32 inline std::span<const Element> GetClasses() const
33 {
34 return this->gui_classes;
35 }
36
37 inline std::span<const uint> GetColumnWidths() const
38 {
39 return this->column_widths;
40 }
41
42 uint GetTotalColumnsWidth() const;
43
44private:
45 std::vector<Element> gui_classes{};
46 std::vector<uint> column_widths{};
47};
48
49int DrawBadgeNameList(Rect r, std::span<const BadgeID> badges, GrfSpecFeature feature);
50void 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);
51
52std::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);
53std::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, std::string &&str, int value, bool masked = false, bool shaded = false);
54
55#endif /* NEWGRF_BADGE_GUI_H */
uint GetTotalColumnsWidth() const
Get total width of all columns.
Types related to the drop down widget.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition gfx_type.h:17
uint32_t PaletteID
The number of the palette.
Definition gfx_type.h:18
Base for the NewGRF implementation.
GrfSpecFeature
Definition newgrf.h:69
Types related to NewGRF badges.
Dimensions (a width and height) of a rectangle in 2D.
Dimension size
Maximal size of this element.
uint sort_order
Order of element.
std::string_view label
Class label (string owned by the class badge)
BadgeClassID class_index
Badge class index.
bool visible
Whether this element is visible.
uint8_t column_group
Column group in UI. 0 = left, 1 = centre, 2 = right.
Specification of a rectangle with absolute coordinates of all edges.
Definition of the game-calendar-timer.