mirror of https://github.com/OpenTTD/OpenTTD.git
Change: De-template BaseSetTextfileWindow. (#12536)
The BaseSet type is not needed after the window is constructed, only the filename and name are required, which can be passed as parameters from `ShowBaseSetTextfileWindow()` instead. This avoids compiling three instances of `BaseSetTextfileWindow`.
This commit is contained in:
parent
e441033d68
commit
2114888485
|
@ -92,24 +92,21 @@ static uint GetCurrentResolutionIndex()
|
||||||
static void ShowCustCurrency();
|
static void ShowCustCurrency();
|
||||||
|
|
||||||
/** Window for displaying the textfile of a BaseSet. */
|
/** Window for displaying the textfile of a BaseSet. */
|
||||||
template <class TBaseSet>
|
|
||||||
struct BaseSetTextfileWindow : public TextfileWindow {
|
struct BaseSetTextfileWindow : public TextfileWindow {
|
||||||
const TBaseSet *baseset; ///< View the textfile of this BaseSet.
|
const std::string name; ///< Name of the content.
|
||||||
StringID content_type; ///< STR_CONTENT_TYPE_xxx for title.
|
const StringID content_type; ///< STR_CONTENT_TYPE_xxx for title.
|
||||||
|
|
||||||
BaseSetTextfileWindow(TextfileType file_type, const TBaseSet *baseset, StringID content_type) : TextfileWindow(file_type), baseset(baseset), content_type(content_type)
|
BaseSetTextfileWindow(TextfileType file_type, const std::string &name, const std::string &textfile, StringID content_type) : TextfileWindow(file_type), name(name), content_type(content_type)
|
||||||
{
|
{
|
||||||
this->ConstructWindow();
|
this->ConstructWindow();
|
||||||
|
this->LoadTextfile(textfile, BASESET_DIR);
|
||||||
auto textfile = this->baseset->GetTextfile(file_type);
|
|
||||||
this->LoadTextfile(textfile.value(), BASESET_DIR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetStringParameters(WidgetID widget) const override
|
void SetStringParameters(WidgetID widget) const override
|
||||||
{
|
{
|
||||||
if (widget == WID_TF_CAPTION) {
|
if (widget == WID_TF_CAPTION) {
|
||||||
SetDParam(0, content_type);
|
SetDParam(0, content_type);
|
||||||
SetDParamStr(1, this->baseset->name);
|
SetDParamStr(1, this->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -124,7 +121,7 @@ template <class TBaseSet>
|
||||||
void ShowBaseSetTextfileWindow(TextfileType file_type, const TBaseSet *baseset, StringID content_type)
|
void ShowBaseSetTextfileWindow(TextfileType file_type, const TBaseSet *baseset, StringID content_type)
|
||||||
{
|
{
|
||||||
CloseWindowById(WC_TEXTFILE, file_type);
|
CloseWindowById(WC_TEXTFILE, file_type);
|
||||||
new BaseSetTextfileWindow<TBaseSet>(file_type, baseset, content_type);
|
new BaseSetTextfileWindow(file_type, baseset->name, *baseset->GetTextfile(file_type), content_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
|
|
Loading…
Reference in New Issue