diff --git a/src/dialogxml/dialogs/strchoice.cpp b/src/dialogxml/dialogs/strchoice.cpp index 3cbb7d029..24f6392ae 100644 --- a/src/dialogxml/dialogs/strchoice.cpp +++ b/src/dialogxml/dialogs/strchoice.cpp @@ -14,6 +14,8 @@ #include #include +#include + #include "dialogxml/widgets/field.hpp" #include "dialogxml/dialogs/strdlog.hpp" #include "fileio/resmgr/res_dialog.hpp" @@ -23,14 +25,20 @@ const sf::Color HILITE_COLOUR = Colours::LIGHT_GREEN; -cStringChoice::cStringChoice(cDialog* parent, bool editable) +cStringChoice::cStringChoice(cDialog* parent, bool editable, bool force_single_column) : editable(editable) - , per_page(editable ? 20 : 40) + , per_page((editable || force_single_column) ? 20 : 40) , dlg(*ResMgr::dialogs.get(editable ? "choose-edit-string" : "choose-string"), parent) -{} +{ + if(force_single_column){ + for(int i = per_page + 1; i <= per_page * 2; ++i){ + dlg[fmt::format("led{}", i)].hide(); + } + } +} -cStringChoice::cStringChoice(const std::vector& strs, std::string title, cDialog* parent, bool editable) - : cStringChoice(parent, editable) +cStringChoice::cStringChoice(const std::vector& strs, std::string title, cDialog* parent, bool editable, bool force_single_column) + : cStringChoice(parent, editable, force_single_column) { setTitle(title); strings = strs; diff --git a/src/dialogxml/dialogs/strchoice.hpp b/src/dialogxml/dialogs/strchoice.hpp index f76d77697..ddc5abf73 100644 --- a/src/dialogxml/dialogs/strchoice.hpp +++ b/src/dialogxml/dialogs/strchoice.hpp @@ -41,13 +41,13 @@ class cStringChoice { bool search_open = false; cLedGroup* leds; std::function select_handler; - cStringChoice(cDialog* parent, bool editable = false); + cStringChoice(cDialog* parent, bool editable = false, bool force_single_column = false); public: /// Initializes a dialog from a list of strings. /// @param strs A list of all strings in the dialog. /// @param title The title to show in the dialog. /// @param parent Optionally, a parent dialog. - explicit cStringChoice(const std::vector& strs, std::string title, cDialog* parent = nullptr, bool editable = false); + explicit cStringChoice(const std::vector& strs, std::string title, cDialog* parent = nullptr, bool editable = false, bool force_single_column = false); /// Initializes a dialog from an iterator pair. /// @param begin An iterator to the first string in the dialog. /// @param end An iterator to one past the last string in the dialog.