1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-16 00:42:45 +01:00

Codechange: Use std::variant to store string parameter data.

This avoids storing two separate values and makes the test for which type is held clearer.

This replaces use of unique_ptr for conditionally storing a string, and is also used in place of StringParameterBackup.
This commit is contained in:
Peter Nelson
2024-07-29 17:58:32 +01:00
committed by Peter Nelson
parent b449839538
commit 3d8d0e0d26
10 changed files with 39 additions and 92 deletions

View File

@@ -668,7 +668,7 @@ static WindowDesc _tool_tips_desc(
struct TooltipsWindow : public Window
{
StringID string_id; ///< String to display as tooltip.
std::vector<StringParameterBackup> params; ///< The string parameters.
std::vector<StringParameterData> params; ///< The string parameters.
TooltipCloseCondition close_cond; ///< Condition for closing the window.
TooltipsWindow(Window *parent, StringID str, uint paramcount, TooltipCloseCondition close_tooltip) : Window(_tool_tips_desc)
@@ -1089,7 +1089,7 @@ void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *paren
*/
struct QueryWindow : public Window {
QueryCallbackProc *proc; ///< callback function executed on closing of popup. Window* points to parent, bool is true if 'yes' clicked, false otherwise
std::vector<StringParameterBackup> params; ///< local copy of #_global_string_params
std::vector<StringParameterData> params; ///< local copy of #_global_string_params
StringID message; ///< message shown for query window
QueryWindow(WindowDesc &desc, StringID caption, StringID message, Window *parent, QueryCallbackProc *callback) : Window(desc)