Changeset - r27194:98f2b221171c
[Not reviewed]
master
0 4 0
Rubidium - 14 months ago 2023-04-16 19:27:01
rubidium@openttd.org
Codechange: let FiosBrowseTo return a bool
4 files changed with 9 insertions and 11 deletions:
0 comments (0 inline, 0 general)
src/console_cmds.cpp
Show inline comments
 
@@ -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);
src/fios.cpp
Show inline comments
 
@@ -145,9 +145,9 @@ StringID FiosGetDescText(const char **pa
 
/**
 
 * 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 
 
		case FIOS_TYPE_OLD_SCENARIO:
 
		case FIOS_TYPE_PNG:
 
		case FIOS_TYPE_BMP:
 
			return item->name;
 
			return false;
 
	}
 

	
 
	return nullptr;
 
	return true;
 
}
 

	
 
/**
src/fios.h
Show inline comments
 
@@ -117,7 +117,7 @@ void FiosGetSavegameList(SaveLoadOperati
 
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);
src/fios_gui.cpp
Show inline comments
 
@@ -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();
0 comments (0 inline, 0 general)