Codechange: use std::string for text file name resolution

This commit is contained in:
Rubidium
2023-05-05 00:04:52 +02:00
committed by rubidium42
parent 0b72297d57
commit 877349c13d
15 changed files with 56 additions and 58 deletions

View File

@@ -545,8 +545,8 @@ struct NewGRFTextfileWindow : public TextfileWindow {
NewGRFTextfileWindow(TextfileType file_type, const GRFConfig *c) : TextfileWindow(file_type), grf_config(c)
{
const char *textfile = this->grf_config->GetTextfile(file_type);
this->LoadTextfile(textfile, NEWGRF_DIR);
auto textfile = this->grf_config->GetTextfile(file_type);
this->LoadTextfile(textfile.value(), NEWGRF_DIR);
}
void SetStringParameters(int widget) const override
@@ -1285,7 +1285,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
const GRFConfig *selected_config = (this->avail_sel == nullptr) ? this->active_sel : this->avail_sel;
for (TextfileType tft = TFT_BEGIN; tft < TFT_END; tft++) {
this->SetWidgetDisabledState(WID_NS_NEWGRF_TEXTFILE + tft, selected_config == nullptr || selected_config->GetTextfile(tft) == nullptr);
this->SetWidgetDisabledState(WID_NS_NEWGRF_TEXTFILE + tft, selected_config == nullptr || !selected_config->GetTextfile(tft).has_value());
}
this->SetWidgetDisabledState(WID_NS_OPEN_URL, selected_config == nullptr || StrEmpty(selected_config->GetURL()));