mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-01-31 11:23:21 +00:00
Codechange: let FiosBrowseTo return a bool
This commit is contained in:
parent
c829930440
commit
f0a1ddd81c
@ -433,7 +433,7 @@ DEF_CONSOLE_CMD(ConLoad)
|
||||
if (GetAbstractFileType(item->type) == FT_SAVEGAME) {
|
||||
_switch_mode = SM_LOAD_GAME;
|
||||
_file_to_saveload.SetMode(item->type);
|
||||
_file_to_saveload.SetName(FiosBrowseTo(item));
|
||||
_file_to_saveload.SetName(item->name);
|
||||
_file_to_saveload.SetTitle(item->title);
|
||||
} else {
|
||||
IConsolePrint(CC_ERROR, "'{}' is not a savegame.", file);
|
||||
|
@ -145,9 +145,9 @@ StringID FiosGetDescText(const char **path, uint64 *total_free)
|
||||
/**
|
||||
* Browse to a new path based on the passed \a item, starting at #_fios_path.
|
||||
* @param *item Item telling us what to do.
|
||||
* @return A filename w/path if we reached a file, otherwise \c nullptr.
|
||||
* @return \c true when the path got changed.
|
||||
*/
|
||||
const char *FiosBrowseTo(const FiosItem *item)
|
||||
bool FiosBrowseTo(const FiosItem *item)
|
||||
{
|
||||
switch (item->type) {
|
||||
case FIOS_TYPE_DRIVE:
|
||||
@ -191,10 +191,10 @@ const char *FiosBrowseTo(const FiosItem *item)
|
||||
case FIOS_TYPE_OLD_SCENARIO:
|
||||
case FIOS_TYPE_PNG:
|
||||
case FIOS_TYPE_BMP:
|
||||
return item->name;
|
||||
return false;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -117,7 +117,7 @@ void FiosGetSavegameList(SaveLoadOperation fop, FileList &file_list);
|
||||
void FiosGetScenarioList(SaveLoadOperation fop, FileList &file_list);
|
||||
void FiosGetHeightmapList(SaveLoadOperation fop, FileList &file_list);
|
||||
|
||||
const char *FiosBrowseTo(const FiosItem *item);
|
||||
bool FiosBrowseTo(const FiosItem *item);
|
||||
|
||||
StringID FiosGetDescText(const char **path, uint64 *total_free);
|
||||
bool FiosDelete(const char *name);
|
||||
|
@ -634,9 +634,8 @@ public:
|
||||
case WID_SL_LOAD_BUTTON: {
|
||||
if (this->selected == nullptr || _load_check_data.HasErrors()) break;
|
||||
|
||||
const char *name = FiosBrowseTo(this->selected);
|
||||
_file_to_saveload.SetMode(this->selected->type);
|
||||
_file_to_saveload.SetName(name);
|
||||
_file_to_saveload.SetName(this->selected->name);
|
||||
_file_to_saveload.SetTitle(this->selected->title);
|
||||
|
||||
if (this->abstract_filetype == FT_HEIGHTMAP) {
|
||||
@ -676,8 +675,7 @@ public:
|
||||
}
|
||||
const FiosItem *file = &this->fios_items[y];
|
||||
|
||||
const char *name = FiosBrowseTo(file);
|
||||
if (name == nullptr) {
|
||||
if (FiosBrowseTo(file)) {
|
||||
/* Changed directory, need refresh. */
|
||||
this->InvalidateData(SLIWD_RESCAN_FILES);
|
||||
break;
|
||||
@ -708,7 +706,7 @@ public:
|
||||
} else {
|
||||
assert(this->abstract_filetype == FT_HEIGHTMAP);
|
||||
_file_to_saveload.SetMode(file->type);
|
||||
_file_to_saveload.SetName(name);
|
||||
_file_to_saveload.SetName(file->name);
|
||||
_file_to_saveload.SetTitle(file->title);
|
||||
|
||||
this->Close();
|
||||
|
Loading…
Reference in New Issue
Block a user