From 4f7768ec6e76e9af32bed1961025b994466c9b8c Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 14 Nov 2011 15:54:17 +0100 Subject: KYRA: Cleanup _saveSlots array sorting. --- engines/kyra/gui.cpp | 4 ++++ engines/kyra/gui.h | 2 ++ engines/kyra/gui_lol.cpp | 6 ++++-- engines/kyra/gui_lol.h | 2 ++ 4 files changed, 12 insertions(+), 2 deletions(-) (limited to 'engines/kyra') diff --git a/engines/kyra/gui.cpp b/engines/kyra/gui.cpp index 7fd9880dce..27f09b645e 100644 --- a/engines/kyra/gui.cpp +++ b/engines/kyra/gui.cpp @@ -388,6 +388,10 @@ void GUI::updateSaveList(bool excludeQuickSaves) { if (_saveSlots.begin() == _saveSlots.end()) return; + sortSaveSlots(); +} + +void GUI::sortSaveSlots() { Common::sort(_saveSlots.begin(), _saveSlots.end(), Common::Less()); if (_saveSlots.size() > 2) Common::sort(_saveSlots.begin()+1, _saveSlots.end(), Common::Greater()); diff --git a/engines/kyra/gui.h b/engines/kyra/gui.h index c04892636b..6e9606f1de 100644 --- a/engines/kyra/gui.h +++ b/engines/kyra/gui.h @@ -207,6 +207,8 @@ protected: void updateSaveList(bool excludeQuickSaves = false); int getNextSavegameSlot(); + virtual void sortSaveSlots(); + uint32 _lastScreenUpdate; Common::KeyState _keyPressed; void checkTextfieldInput(); diff --git a/engines/kyra/gui_lol.cpp b/engines/kyra/gui_lol.cpp index 2017a6e6ba..fefcaf762f 100644 --- a/engines/kyra/gui_lol.cpp +++ b/engines/kyra/gui_lol.cpp @@ -2618,8 +2618,6 @@ void GUI_LoL::updateSavegameList() { _savegameListSize = _saveSlots.size(); if (_savegameListSize) { - Common::sort(_saveSlots.begin(), _saveSlots.end(), Common::Greater()); - LoLEngine::SaveHeader header; Common::InSaveFile *in; @@ -2642,6 +2640,10 @@ void GUI_LoL::updateSavegameList() { } } +void GUI_LoL::sortSaveSlots() { + Common::sort(_saveSlots.begin(), _saveSlots.end(), Common::Greater()); +} + void GUI_LoL::printMenuText(const char *str, int x, int y, uint8 c0, uint8 c1, uint8 flags) { _screen->fprintString("%s", x, y, c0, c1, _vm->gameFlags().use16ColorMode ? (flags & 3) : flags , str); } diff --git a/engines/kyra/gui_lol.h b/engines/kyra/gui_lol.h index 0686926534..af487402f6 100644 --- a/engines/kyra/gui_lol.h +++ b/engines/kyra/gui_lol.h @@ -175,6 +175,8 @@ private: char **_savegameList; int _savegameListSize; bool _savegameListUpdateNeeded; + + virtual void sortSaveSlots(); }; } // End of namespace Kyra -- cgit v1.2.3