diff --git a/src/dropdown.cpp b/src/dropdown.cpp index 3fde9ef74f..38d50ff1b5 100644 --- a/src/dropdown.cpp +++ b/src/dropdown.cpp @@ -47,9 +47,9 @@ std::unique_ptr MakeDropDownListIconItem(const Dimension &dim, return std::make_unique(dim, sprite, palette, str, value, masked, shaded); } -std::unique_ptr MakeDropDownListCheckedItem(bool checked, StringID str, int value, bool masked, bool shaded) +std::unique_ptr MakeDropDownListCheckedItem(bool checked, StringID str, int value, bool masked, bool shaded, uint indent) { - return std::make_unique(checked, str, value, masked, shaded); + return std::make_unique(indent, checked, str, value, masked, shaded); } static constexpr NWidgetPart _nested_dropdown_menu_widgets[] = { diff --git a/src/dropdown_common_type.h b/src/dropdown_common_type.h index a851c216ec..71becf9fa1 100644 --- a/src/dropdown_common_type.h +++ b/src/dropdown_common_type.h @@ -169,10 +169,31 @@ public: } }; +/** + * Drop down indent component. + * @tparam TBase Base component. + * @tparam TEnd Position checkmark at end if true, or start if false. + */ +template +class DropDownIndent : public TBase { + uint indent; +public: + template + explicit DropDownIndent(uint indent, Args&&... args) : TBase(std::forward(args)...), indent(indent) {} + + uint Width() const override { return this->indent * WidgetDimensions::scaled.hsep_indent + this->TBase::Width(); } + + void Draw(const Rect &full, const Rect &r, bool sel, Colours bg_colour) const override + { + bool rtl = TEnd ^ (_current_text_dir == TD_RTL); + this->TBase::Draw(full, r.Indent(this->indent * WidgetDimensions::scaled.hsep_indent, rtl), sel, bg_colour); + } +}; + /* Commonly used drop down list items. */ using DropDownListDividerItem = DropDownDivider; using DropDownListStringItem = DropDownString; using DropDownListIconItem = DropDownIcon>; -using DropDownListCheckedItem = DropDownCheck>; +using DropDownListCheckedItem = DropDownIndent>>; #endif /* DROPDOWN_COMMON_TYPE_H */ diff --git a/src/dropdown_func.h b/src/dropdown_func.h index 6aee0066f7..7e520c21ce 100644 --- a/src/dropdown_func.h +++ b/src/dropdown_func.h @@ -21,6 +21,6 @@ std::unique_ptr MakeDropDownListStringItem(StringID str, int v std::unique_ptr MakeDropDownListStringItem(const std::string &str, int value, bool masked = false, bool shaded = false); std::unique_ptr MakeDropDownListIconItem(SpriteID sprite, PaletteID palette, StringID str, int value, bool masked = false, bool shaded = false); std::unique_ptr MakeDropDownListIconItem(const Dimension &dim, SpriteID sprite, PaletteID palette, StringID str, int value, bool masked = false, bool shaded = false); -std::unique_ptr MakeDropDownListCheckedItem(bool checked, StringID str, int value, bool masked = false, bool shaded = false); +std::unique_ptr MakeDropDownListCheckedItem(bool checked, StringID str, int value, bool masked = false, bool shaded = false, uint indent = 0); #endif /* DROPDOWN_FUNC_H */ diff --git a/src/lang/english.txt b/src/lang/english.txt index 4244c77792..5c1e1c60ca 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -443,7 +443,6 @@ STR_SCENEDIT_TOWN_MENU_BUILD_TOWN :Generate towns STR_SCENEDIT_TOWN_MENU_PACE_HOUSE :Place houses # Settings menu -###length 16 STR_SETTINGS_MENU_GAME_OPTIONS :Game options STR_SETTINGS_MENU_CONFIG_SETTINGS_TREE :Settings STR_SETTINGS_MENU_AI_SETTINGS :AI settings @@ -453,6 +452,11 @@ STR_SETTINGS_MENU_SANDBOX_OPTIONS :Sandbox options STR_SETTINGS_MENU_TRANSPARENCY_OPTIONS :Transparency options STR_SETTINGS_MENU_TOWN_NAMES_DISPLAYED :Town names displayed STR_SETTINGS_MENU_STATION_NAMES_DISPLAYED :Station names displayed +STR_SETTINGS_MENU_STATION_NAMES_TRAIN :{TRAIN} Train stations +STR_SETTINGS_MENU_STATION_NAMES_LORRY :{LORRY} Lorry stops +STR_SETTINGS_MENU_STATION_NAMES_BUS :{BUS} Bus stops +STR_SETTINGS_MENU_STATION_NAMES_SHIP :{SHIP} Docks +STR_SETTINGS_MENU_STATION_NAMES_PLANE :{PLANE} Airports STR_SETTINGS_MENU_WAYPOINTS_DISPLAYED :Waypoint names displayed STR_SETTINGS_MENU_SIGNS_DISPLAYED :Signs displayed STR_SETTINGS_MENU_SHOW_COMPETITOR_SIGNS :Competitor signs and names displayed diff --git a/src/table/settings/misc_settings.ini b/src/table/settings/misc_settings.ini index 45051908e0..7c95c28ccb 100644 --- a/src/table/settings/misc_settings.ini +++ b/src/table/settings/misc_settings.ini @@ -12,6 +12,7 @@ extern std::string _config_language_file; static constexpr std::initializer_list _support8bppmodes{"no", "system", "hardware"}; static constexpr std::initializer_list _display_opt_modes{"SHOW_TOWN_NAMES", "SHOW_STATION_NAMES", "SHOW_SIGNS", "FULL_ANIMATION", "", "FULL_DETAIL", "WAYPOINTS", "SHOW_COMPETITOR_SIGNS"}; +static constexpr std::initializer_list _facility_display_opt_modes{"TRAIN", "TRUCK_STOP", "BUS_STOP", "AIRPORT", "DOCK"}; #ifdef WITH_COCOA extern bool _allow_hidpi_window; @@ -64,6 +65,13 @@ var = _display_opt def = (1 << DO_SHOW_TOWN_NAMES | 1 << DO_SHOW_STATION_NAMES | 1 << DO_SHOW_SIGNS | 1 << DO_FULL_ANIMATION | 1 << DO_FULL_DETAIL | 1 << DO_SHOW_WAYPOINT_NAMES | 1 << DO_SHOW_COMPETITOR_SIGNS) full = _display_opt_modes +[SDTG_MMANY] +name = ""facility_display_opt"" +type = SLE_UINT8 +var = _facility_display_opt +def = (1 << FACIL_TRAIN | 1 << FACIL_TRUCK_STOP | 1 << FACIL_BUS_STOP | 1 << FACIL_AIRPORT | 1 << FACIL_DOCK) +full = _facility_display_opt_modes + [SDTG_BOOL] name = ""fullscreen"" var = _fullscreen diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 51ad8849c3..fe8a32eb6b 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -236,6 +236,11 @@ enum OptionMenuEntries { OME_TRANSPARENCIES, OME_SHOW_TOWNNAMES, OME_SHOW_STATIONNAMES, + OME_SHOW_STATIONNAMES_TRAIN, + OME_SHOW_STATIONNAMES_LORRY, + OME_SHOW_STATIONNAMES_BUS, + OME_SHOW_STATIONNAMES_SHIP, + OME_SHOW_STATIONNAMES_PLANE, OME_SHOW_WAYPOINTNAMES, OME_SHOW_SIGNS, OME_SHOW_COMPETITOR_SIGNS, @@ -271,6 +276,11 @@ static CallBackFunction ToolbarOptionsClick(Window *w) list.push_back(MakeDropDownListDividerItem()); list.push_back(MakeDropDownListCheckedItem(HasBit(_display_opt, DO_SHOW_TOWN_NAMES), STR_SETTINGS_MENU_TOWN_NAMES_DISPLAYED, OME_SHOW_TOWNNAMES)); list.push_back(MakeDropDownListCheckedItem(HasBit(_display_opt, DO_SHOW_STATION_NAMES), STR_SETTINGS_MENU_STATION_NAMES_DISPLAYED, OME_SHOW_STATIONNAMES)); + list.push_back(MakeDropDownListCheckedItem((_facility_display_opt & FACIL_TRAIN) != 0, STR_SETTINGS_MENU_STATION_NAMES_TRAIN, OME_SHOW_STATIONNAMES_TRAIN, false, false, 1)); + list.push_back(MakeDropDownListCheckedItem((_facility_display_opt & FACIL_TRUCK_STOP) != 0, STR_SETTINGS_MENU_STATION_NAMES_LORRY, OME_SHOW_STATIONNAMES_LORRY, false, false, 1)); + list.push_back(MakeDropDownListCheckedItem((_facility_display_opt & FACIL_BUS_STOP) != 0, STR_SETTINGS_MENU_STATION_NAMES_BUS, OME_SHOW_STATIONNAMES_BUS, false, false, 1)); + list.push_back(MakeDropDownListCheckedItem((_facility_display_opt & FACIL_DOCK) != 0, STR_SETTINGS_MENU_STATION_NAMES_SHIP, OME_SHOW_STATIONNAMES_SHIP, false, false, 1)); + list.push_back(MakeDropDownListCheckedItem((_facility_display_opt & FACIL_AIRPORT) != 0, STR_SETTINGS_MENU_STATION_NAMES_PLANE, OME_SHOW_STATIONNAMES_PLANE, false, false, 1)); list.push_back(MakeDropDownListCheckedItem(HasBit(_display_opt, DO_SHOW_WAYPOINT_NAMES), STR_SETTINGS_MENU_WAYPOINTS_DISPLAYED, OME_SHOW_WAYPOINTNAMES)); list.push_back(MakeDropDownListCheckedItem(HasBit(_display_opt, DO_SHOW_SIGNS), STR_SETTINGS_MENU_SIGNS_DISPLAYED, OME_SHOW_SIGNS)); list.push_back(MakeDropDownListCheckedItem(HasBit(_display_opt, DO_SHOW_COMPETITOR_SIGNS), STR_SETTINGS_MENU_SHOW_COMPETITOR_SIGNS, OME_SHOW_COMPETITOR_SIGNS)); @@ -284,6 +294,19 @@ static CallBackFunction ToolbarOptionsClick(Window *w) return CBF_NONE; } +/** + * Toggle display station names for a facility. + * @param facility Facility to toggle. + */ +static void ToggleFacilityDisplay(const uint8_t facility) +{ + if ((_facility_display_opt & facility) == 0) { + SETBITS(_facility_display_opt, facility); + } else { + CLRBITS(_facility_display_opt, facility); + } +} + /** * Handle click on one of the entries in the Options button menu. * @@ -303,6 +326,11 @@ static CallBackFunction MenuClickSettings(int index) case OME_SHOW_TOWNNAMES: ToggleBit(_display_opt, DO_SHOW_TOWN_NAMES); break; case OME_SHOW_STATIONNAMES: ToggleBit(_display_opt, DO_SHOW_STATION_NAMES); break; + case OME_SHOW_STATIONNAMES_TRAIN: ToggleFacilityDisplay(FACIL_TRAIN); break; + case OME_SHOW_STATIONNAMES_LORRY: ToggleFacilityDisplay(FACIL_TRUCK_STOP); break; + case OME_SHOW_STATIONNAMES_BUS: ToggleFacilityDisplay(FACIL_BUS_STOP); break; + case OME_SHOW_STATIONNAMES_SHIP: ToggleFacilityDisplay(FACIL_DOCK); break; + case OME_SHOW_STATIONNAMES_PLANE: ToggleFacilityDisplay(FACIL_AIRPORT); break; case OME_SHOW_WAYPOINTNAMES: ToggleBit(_display_opt, DO_SHOW_WAYPOINT_NAMES); break; case OME_SHOW_SIGNS: ToggleBit(_display_opt, DO_SHOW_SIGNS); break; case OME_SHOW_COMPETITOR_SIGNS: diff --git a/src/transparency.h b/src/transparency.h index 782c009f22..9274fd4d45 100644 --- a/src/transparency.h +++ b/src/transparency.h @@ -38,6 +38,7 @@ extern TransparencyOptionBits _transparency_opt; extern TransparencyOptionBits _transparency_lock; extern TransparencyOptionBits _invisibility_opt; extern uint8_t _display_opt; +extern uint8_t _facility_display_opt; /** * Check if the transparency option bit is set diff --git a/src/transparency_gui.cpp b/src/transparency_gui.cpp index d10c6c12d0..256a4e7e1a 100644 --- a/src/transparency_gui.cpp +++ b/src/transparency_gui.cpp @@ -24,6 +24,7 @@ TransparencyOptionBits _transparency_opt; ///< The bits that should be transpar TransparencyOptionBits _transparency_lock; ///< Prevent these bits from flipping with X. TransparencyOptionBits _invisibility_opt; ///< The bits that should be invisible. uint8_t _display_opt; ///< What do we want to draw/do? +uint8_t _facility_display_opt; ///< What station facilities to draw. class TransparenciesWindow : public Window { diff --git a/src/viewport.cpp b/src/viewport.cpp index 341845bee7..c12b05f0a3 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -1448,6 +1448,7 @@ static void ViewportAddKdtreeSigns(DrawPixelInfo *dpi) case ViewportSignKdtreeItem::VKI_STATION: { if (!show_stations) break; const BaseStation *st = BaseStation::Get(item.id.station); + if ((_facility_display_opt & st->facilities) == 0) break; /* Don't draw if station is owned by another company and competitor station names are hidden. Stations owned by none are never ignored. */ if (!show_competitors && _local_company != st->owner && st->owner != OWNER_NONE) break;