10
src/fios.cpp
10
src/fios.cpp
@@ -230,16 +230,6 @@ std::string FiosMakeHeightmapName(std::string_view name)
|
|||||||
return FiosMakeFilename(_fios_path, name, fmt::format(".{}", GetCurrentScreenshotExtension()));
|
return FiosMakeFilename(_fios_path, name, fmt::format(".{}", GetCurrentScreenshotExtension()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete a file.
|
|
||||||
* @param name Filename to delete.
|
|
||||||
* @return Whether the file deletion was successful.
|
|
||||||
*/
|
|
||||||
bool FiosDelete(std::string_view name)
|
|
||||||
{
|
|
||||||
return FioRemove(FiosMakeSavegameName(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef std::tuple<FiosType, std::string> FiosGetTypeAndNameProc(SaveLoadOperation fop, std::string_view filename, std::string_view ext);
|
typedef std::tuple<FiosType, std::string> FiosGetTypeAndNameProc(SaveLoadOperation fop, std::string_view filename, std::string_view ext);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -112,7 +112,6 @@ bool FiosBrowseTo(const FiosItem *item);
|
|||||||
|
|
||||||
std::string FiosGetCurrentPath();
|
std::string FiosGetCurrentPath();
|
||||||
std::optional<uint64_t> FiosGetDiskFreeSpace(const std::string &path);
|
std::optional<uint64_t> FiosGetDiskFreeSpace(const std::string &path);
|
||||||
bool FiosDelete(std::string_view name);
|
|
||||||
std::string FiosMakeHeightmapName(std::string_view name);
|
std::string FiosMakeHeightmapName(std::string_view name);
|
||||||
std::string FiosMakeSavegameName(std::string_view name);
|
std::string FiosMakeSavegameName(std::string_view name);
|
||||||
|
|
||||||
|
|||||||
@@ -327,13 +327,13 @@ private:
|
|||||||
QueryString filename_editbox; ///< Filename editbox.
|
QueryString filename_editbox; ///< Filename editbox.
|
||||||
AbstractFileType abstract_filetype{}; /// Type of file to select.
|
AbstractFileType abstract_filetype{}; /// Type of file to select.
|
||||||
SaveLoadOperation fop{}; ///< File operation to perform.
|
SaveLoadOperation fop{}; ///< File operation to perform.
|
||||||
FileList fios_items{}; ///< Save game list.
|
FileList fios_items{}; ///< Item list.
|
||||||
FiosItem o_dir{}; ///< Original dir (home dir for this browser)
|
FiosItem o_dir{}; ///< Original dir (home dir for this browser)
|
||||||
const FiosItem *selected = nullptr; ///< Selected game in #fios_items, or \c nullptr.
|
const FiosItem *selected = nullptr; ///< Selected item in #fios_items, or \c nullptr.
|
||||||
const FiosItem *highlighted = nullptr; ///< Item in fios_items highlighted by mouse pointer, or \c nullptr.
|
const FiosItem *highlighted = nullptr; ///< Item in fios_items highlighted by mouse pointer, or \c nullptr.
|
||||||
Scrollbar *vscroll = nullptr;
|
Scrollbar *vscroll = nullptr;
|
||||||
|
|
||||||
StringFilter string_filter{}; ///< Filter for available games.
|
StringFilter string_filter{}; ///< Filter for available items.
|
||||||
QueryString filter_editbox; ///< Filter editbox;
|
QueryString filter_editbox; ///< Filter editbox;
|
||||||
std::vector<FiosItem *> display_list{}; ///< Filtered display list
|
std::vector<FiosItem *> display_list{}; ///< Filtered display list
|
||||||
|
|
||||||
@@ -353,8 +353,10 @@ private:
|
|||||||
{
|
{
|
||||||
auto *save_load_window = static_cast<SaveLoadWindow*>(window);
|
auto *save_load_window = static_cast<SaveLoadWindow*>(window);
|
||||||
|
|
||||||
|
assert(save_load_window->selected != nullptr);
|
||||||
|
|
||||||
if (confirmed) {
|
if (confirmed) {
|
||||||
if (!FiosDelete(save_load_window->filename_editbox.text.GetText())) {
|
if (!FioRemove(save_load_window->selected->name)) {
|
||||||
ShowErrorMessage(GetEncodedString(STR_ERROR_UNABLE_TO_DELETE_FILE), {}, WL_ERROR);
|
ShowErrorMessage(GetEncodedString(STR_ERROR_UNABLE_TO_DELETE_FILE), {}, WL_ERROR);
|
||||||
} else {
|
} else {
|
||||||
save_load_window->InvalidateData(SLIWD_RESCAN_FILES);
|
save_load_window->InvalidateData(SLIWD_RESCAN_FILES);
|
||||||
@@ -909,6 +911,8 @@ public:
|
|||||||
/* Selection changes */
|
/* Selection changes */
|
||||||
if (!gui_scope) break;
|
if (!gui_scope) break;
|
||||||
|
|
||||||
|
if (this->fop == SLO_SAVE) this->SetWidgetDisabledState(WID_SL_DELETE_SELECTION, this->selected == nullptr);
|
||||||
|
|
||||||
if (this->fop != SLO_LOAD) break;
|
if (this->fop != SLO_LOAD) break;
|
||||||
|
|
||||||
switch (this->abstract_filetype) {
|
switch (this->abstract_filetype) {
|
||||||
@@ -947,6 +951,11 @@ public:
|
|||||||
this->string_filter.SetFilterTerm(this->filter_editbox.text.GetText());
|
this->string_filter.SetFilterTerm(this->filter_editbox.text.GetText());
|
||||||
this->InvalidateData(SLIWD_FILTER_CHANGES);
|
this->InvalidateData(SLIWD_FILTER_CHANGES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (wid == WID_SL_SAVE_OSK_TITLE) {
|
||||||
|
this->selected = nullptr;
|
||||||
|
this->InvalidateData(SLIWD_SELECTION_CHANGES);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user