Codechange: let FiosGetDiskFreeSpace only return disk space and split FiosGetCurrentPath off

This commit is contained in:
Rubidium
2023-05-30 22:38:55 +02:00
committed by rubidium42
parent f2e704b9a7
commit 324c43eeb2
7 changed files with 27 additions and 50 deletions

View File

@@ -420,19 +420,19 @@ public:
break;
case WID_SL_BACKGROUND: {
static const char *path = nullptr;
static StringID str = STR_ERROR_UNABLE_TO_READ_DRIVE;
static uint64 tot = 0;
static std::string path;
static std::optional<uint64_t> free_space = std::nullopt;
if (_fios_path_changed) {
str = FiosGetDescText(&path, &tot);
path = FiosGetCurrentPath();
free_space = FiosGetDiskFreeSpace(path);
_fios_path_changed = false;
}
Rect ir = r.Shrink(WidgetDimensions::scaled.framerect);
if (str != STR_ERROR_UNABLE_TO_READ_DRIVE) SetDParam(0, tot);
DrawString(ir.left, ir.right, ir.top + FONT_HEIGHT_NORMAL, str);
if (free_space.has_value()) SetDParam(0, free_space.value());
DrawString(ir.left, ir.right, ir.top + FONT_HEIGHT_NORMAL, free_space.has_value() ? STR_SAVELOAD_BYTES_FREE : STR_ERROR_UNABLE_TO_READ_DRIVE);
DrawString(ir.left, ir.right, ir.top, path, TC_BLACK);
break;
}