summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fios.cpp1
-rw-r--r--src/fios.h1
-rw-r--r--src/fios_gui.cpp38
3 files changed, 19 insertions, 21 deletions
diff --git a/src/fios.cpp b/src/fios.cpp
index c670ee339..af89ef049 100644
--- a/src/fios.cpp
+++ b/src/fios.cpp
@@ -29,7 +29,6 @@
#include "safeguards.h"
/* Variables to display file lists */
-FileList _fios_items;
static char *_fios_path;
static const char *_fios_path_last;
SortingBits _savegame_sort_order = SORT_BY_DATE | SORT_DESCENDING;
diff --git a/src/fios.h b/src/fios.h
index c1da5720f..37d562ca1 100644
--- a/src/fios.h
+++ b/src/fios.h
@@ -215,7 +215,6 @@ enum SortingBits {
DECLARE_ENUM_AS_BIT_SET(SortingBits)
/* Variables to display file lists */
-extern FileList _fios_items;
extern SaveLoadDialogMode _saveload_mode;
extern SortingBits _savegame_sort_order;
diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp
index 179a397ef..c9d612f4c 100644
--- a/src/fios_gui.cpp
+++ b/src/fios_gui.cpp
@@ -193,7 +193,11 @@ const TextColour _fios_colours[] = {
TC_ORANGE, TC_LIGHT_BROWN, TC_ORANGE, TC_ORANGE, TC_YELLOW
};
-static void MakeSortedSaveGameList()
+/**
+ * Sort the collected list save games prior to displaying it in the save/load gui.
+ * @param [inout] file_list List of save game files found in the directory.
+ */
+static void SortSaveGameList(FileList &file_list)
{
uint sort_start = 0;
uint sort_end = 0;
@@ -202,7 +206,7 @@ static void MakeSortedSaveGameList()
* Drives (A:\ (windows only) are always under the files (FIOS_TYPE_DRIVE)
* Only sort savegames/scenarios, not directories
*/
- for (const FiosItem *item = _fios_items.Begin(); item != _fios_items.End(); item++) {
+ for (const FiosItem *item = file_list.Begin(); item != file_list.End(); item++) {
switch (item->type) {
case FIOS_TYPE_DIR: sort_start++; break;
case FIOS_TYPE_PARENT: sort_start++; break;
@@ -211,15 +215,16 @@ static void MakeSortedSaveGameList()
}
}
- uint s_amount = _fios_items.Length() - sort_start - sort_end;
- QSortT(_fios_items.Get(sort_start), s_amount, CompareFiosItems);
+ uint s_amount = file_list.Length() - sort_start - sort_end;
+ QSortT(file_list.Get(sort_start), s_amount, CompareFiosItems);
}
struct SaveLoadWindow : public Window {
private:
QueryString filename_editbox; ///< Filename editbox.
+ FileList fios_items; ///< Save game list.
FiosItem o_dir;
- const FiosItem *selected;
+ const FiosItem *selected; ///< Selected game in #fios_items, or \c NULL.
Scrollbar *vscroll;
public:
@@ -307,7 +312,6 @@ public:
if (!_networking && _game_mode != GM_EDITOR && _game_mode != GM_MENU) {
DoCommandP(0, PM_PAUSED_SAVELOAD, 0, CMD_PAUSE);
}
- _fios_items.Clear();
}
virtual void DrawWidget(const Rect &r, int widget) const
@@ -340,8 +344,8 @@ public:
GfxFillRect(r.left + 1, r.top + 1, r.right, r.bottom, PC_BLACK);
uint y = r.top + WD_FRAMERECT_TOP;
- for (uint pos = this->vscroll->GetPosition(); pos < _fios_items.Length(); pos++) {
- const FiosItem *item = _fios_items.Get(pos);
+ for (uint pos = this->vscroll->GetPosition(); pos < this->fios_items.Length(); pos++) {
+ const FiosItem *item = this->fios_items.Get(pos);
if (item == this->selected) {
GfxFillRect(r.left + 1, y, r.right, y + this->resize.step_height, PC_DARK_BLUE);
@@ -475,10 +479,10 @@ public:
{
if (_savegame_sort_dirty) {
_savegame_sort_dirty = false;
- MakeSortedSaveGameList();
+ SortSaveGameList(this->fios_items);
}
- this->vscroll->SetCount(_fios_items.Length());
+ this->vscroll->SetCount(this->fios_items.Length());
this->DrawWidgets();
}
@@ -543,7 +547,7 @@ public:
int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SL_DRIVES_DIRECTORIES_LIST, WD_FRAMERECT_TOP);
if (y == INT_MAX) return;
- const FiosItem *file = _fios_items.Get(y);
+ const FiosItem *file = this->fios_items.Get(y);
const char *name = FiosBrowseTo(file);
if (name != NULL) {
@@ -665,8 +669,10 @@ public:
if (!gui_scope) break;
_fios_path_changed = true;
- _fios_items.BuildFileList(_saveload_mode);
- InvalidateWindowData(WC_SAVELOAD, 0, 2, true);
+ this->fios_items.BuildFileList(_saveload_mode);
+ this->vscroll->SetCount(this->fios_items.Length());
+ this->selected = NULL;
+ _load_check_data.Clear();
/* FALL THROUGH */
case 1:
/* Selection changes */
@@ -683,12 +689,6 @@ public:
!_load_check_data.HasNewGrfs() || _load_check_data.grf_compatibility == GLC_ALL_GOOD);
}
break;
- case 2:
- /* _fios_items changed */
- this->vscroll->SetCount(_fios_items.Length());
- this->selected = NULL;
- _load_check_data.Clear();
- break;
}
}
};