13
13
#include " GUIButton.h"
14
14
#include " GUIListBox.h"
15
15
#include " GUITextBox.h"
16
+ #include " GUIComboBox.h"
16
17
17
18
namespace RTE {
18
19
@@ -32,6 +33,12 @@ namespace RTE {
32
33
saveGameMenuBox->CenterInParent (true , true );
33
34
saveGameMenuBox->SetPositionAbs (saveGameMenuBox->GetXPos (), (rootBox->GetHeight () < 540 ) ? saveGameMenuBox->GetYPos () - 15 : 140 );
34
35
36
+ m_OrderByComboBox = dynamic_cast <GUIComboBox*>(m_GUIControlManager->GetControl (" ComboOrderBy" ));
37
+ m_OrderByComboBox->AddItem (" Name" );
38
+ m_OrderByComboBox->AddItem (" Date" );
39
+ m_OrderByComboBox->AddItem (" Activity" );
40
+ m_OrderByComboBox->SetSelectedIndex (1 ); // order by Date by default
41
+
35
42
m_BackToMainButton = dynamic_cast <GUIButton *>(m_GUIControlManager->GetControl (" ButtonBackToMainMenu" ));
36
43
37
44
if (createForPauseMenu) {
@@ -107,7 +114,14 @@ namespace RTE {
107
114
108
115
void SaveLoadMenuGUI::UpdateSaveGamesGUIList ()
109
116
{
110
- std::sort (m_SaveGames.begin (), m_SaveGames.end ());
117
+ const std::string& currentOrder = m_OrderByComboBox->GetSelectedItem ()->m_Name ;
118
+ if (currentOrder == " Name" ) {
119
+ std::stable_sort (m_SaveGames.begin (), m_SaveGames.end (), [](const SaveRecord& lhs, const SaveRecord& rhs) { return lhs.SavePath .stem ().string () < rhs.SavePath .stem ().string (); });
120
+ } else if (currentOrder == " Date" ) {
121
+ std::stable_sort (m_SaveGames.begin (), m_SaveGames.end (), [](const SaveRecord& lhs, const SaveRecord& rhs) { return lhs.SaveDate > rhs.SaveDate ; });
122
+ } else if (currentOrder == " Activity" ) {
123
+ std::stable_sort (m_SaveGames.begin (), m_SaveGames.end (), [](const SaveRecord& lhs, const SaveRecord& rhs) { return lhs.Activity < rhs.Activity ; });
124
+ }
111
125
112
126
m_SaveGamesListBox->ClearList ();
113
127
for (int i = 0 ; i < m_SaveGames.size (); i++) {
@@ -181,6 +195,10 @@ namespace RTE {
181
195
// m_DescriptionLabel->SetText(record.GetDisplayString());
182
196
m_SaveGameName->SetText (record.SavePath .stem ().string ());
183
197
}
198
+
199
+ if (guiEvent.GetControl () == m_OrderByComboBox && guiEvent.GetMsg () == GUIComboBox::Closed) {
200
+ UpdateSaveGamesGUIList ();
201
+ }
184
202
}
185
203
}
186
204
return false ;
0 commit comments