Codechange: replace char* with C++ style strings

This commit is contained in:
Rubidium
2025-04-29 22:34:20 +02:00
committed by rubidium42
parent 356b0159c7
commit 708e6a512d
20 changed files with 45 additions and 57 deletions

View File

@@ -590,7 +590,7 @@ static void FillGrfidMap(const GRFConfigList &lst, GrfIdMap &grfid_map)
}
static void NewGRFConfirmationCallback(Window *w, bool confirmed);
static void ShowSavePresetWindow(const char *initial_text);
static void ShowSavePresetWindow(std::string_view initial_text);
/**
* Window for showing NewGRF files
@@ -958,13 +958,13 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
}
case WID_NS_PRESET_SAVE:
ShowSavePresetWindow((this->preset == -1) ? nullptr : this->grf_presets[this->preset].c_str());
ShowSavePresetWindow((this->preset == -1) ? std::string_view{} : this->grf_presets[this->preset]);
break;
case WID_NS_PRESET_DELETE:
if (this->preset == -1) return;
DeleteGRFPresetFromConfig(this->grf_presets[this->preset].c_str());
DeleteGRFPresetFromConfig(this->grf_presets[this->preset]);
this->grf_presets = GetGRFPresetList();
this->preset = -1;
this->InvalidateData();
@@ -2020,12 +2020,12 @@ struct SavePresetWindow : public Window {
/**
* Constructor of the save preset window.
* @param initial_text Initial text to display in the edit box, or \c nullptr.
* @param initial_text Initial text to display in the edit box.
*/
SavePresetWindow(const char *initial_text) : Window(_save_preset_desc), presetname_editbox(32)
SavePresetWindow(std::string_view initial_text) : Window(_save_preset_desc), presetname_editbox(32)
{
this->presets = GetGRFPresetList();
if (initial_text != nullptr) {
if (!initial_text.empty()) {
for (uint i = 0; i < this->presets.size(); i++) {
if (this->presets[i] == initial_text) {
this->selected = i;
@@ -2044,7 +2044,7 @@ struct SavePresetWindow : public Window {
this->vscroll->SetCount(this->presets.size());
this->SetFocusedWidget(WID_SVP_EDITBOX);
if (initial_text != nullptr) this->presetname_editbox.text.Assign(initial_text);
this->presetname_editbox.text.Assign(initial_text);
}
~SavePresetWindow()
@@ -2132,7 +2132,7 @@ struct SavePresetWindow : public Window {
* Open the window for saving a preset.
* @param initial_text Initial text to display in the edit box, or \c nullptr.
*/
static void ShowSavePresetWindow(const char *initial_text)
static void ShowSavePresetWindow(std::string_view initial_text)
{
CloseWindowByClass(WC_SAVE_PRESET);
new SavePresetWindow(initial_text);