@@ -60,6 +60,7 @@ namespace RTE {
60
60
m_SaveGameName = dynamic_cast <GUITextBox *>(m_GUIControlManager->GetControl (" SaveGameName" ));
61
61
m_LoadButton = dynamic_cast <GUIButton *>(m_GUIControlManager->GetControl (" ButtonLoad" ));
62
62
m_CreateButton = dynamic_cast <GUIButton *>(m_GUIControlManager->GetControl (" ButtonCreate" ));
63
+ m_OverwriteButton = dynamic_cast <GUIButton *>(m_GUIControlManager->GetControl (" ButtonOverwrite" ));
63
64
m_DeleteButton = dynamic_cast <GUIButton *>(m_GUIControlManager->GetControl (" ButtonDelete" ));
64
65
m_ActivityCannotBeSavedLabel = dynamic_cast <GUILabel *>(m_GUIControlManager->GetControl (" ActivityCannotBeSavedWarning" ));
65
66
@@ -210,13 +211,31 @@ namespace RTE {
210
211
211
212
void SaveLoadMenuGUI::UpdateButtonEnabledStates () {
212
213
bool allowSave = g_ActivityMan.GetActivityAllowsSaving () && m_SaveGameName->GetText () != " " ;
213
- bool allowLoad = m_SaveGamesListBox->GetSelectedIndex () > -1 && m_SaveGameName->GetText () != " " && m_SaveGameName->GetText () == m_SaveGames[m_SaveGamesListBox->GetSelected ()->m_ExtraIndex ].SavePath .stem ().string ();
214
- bool allowDelete = allowLoad;
215
214
216
- m_CreateButton->SetVisible (allowSave);
217
- m_CreateButton->SetEnabled (allowSave);
218
- m_LoadButton->SetEnabled (allowLoad);
219
- m_DeleteButton->SetEnabled (allowDelete);
215
+ int existingSaveItemIndex = -1 ;
216
+ for (int i = 0 ; i < m_SaveGamesListBox->GetItemList ()->size (); ++i) {
217
+ SaveRecord& save = m_SaveGames[m_SaveGamesListBox->GetItem (i)->m_ExtraIndex ];
218
+ if (save.SavePath .stem ().string () == m_SaveGameName->GetText ()) {
219
+ existingSaveItemIndex = i;
220
+ break ;
221
+ }
222
+ }
223
+
224
+ // Select the item in the list - selecting -1 unselects all
225
+ m_SaveGamesListBox->SetSelectedIndex (existingSaveItemIndex);
226
+
227
+ bool saveExists = existingSaveItemIndex != -1 ;
228
+
229
+ bool allowCreate = allowSave && !saveExists;
230
+ m_CreateButton->SetVisible (allowCreate);
231
+ m_CreateButton->SetEnabled (allowCreate);
232
+
233
+ bool allowOverwrite = allowSave && saveExists;
234
+ m_OverwriteButton->SetVisible (allowOverwrite);
235
+ m_OverwriteButton->SetEnabled (allowOverwrite);
236
+
237
+ m_LoadButton->SetEnabled (saveExists);
238
+ m_DeleteButton->SetEnabled (saveExists);
220
239
221
240
m_ActivityCannotBeSavedLabel->SetVisible (g_ActivityMan.GetActivity () && !g_ActivityMan.GetActivityAllowsSaving ());
222
241
}
@@ -244,7 +263,7 @@ namespace RTE {
244
263
}
245
264
return true ;
246
265
}
247
- } else if (guiEvent.GetControl () == m_CreateButton) {
266
+ } else if (guiEvent.GetControl () == m_CreateButton || guiEvent. GetControl () == m_OverwriteButton ) {
248
267
CreateSave ();
249
268
} else if (guiEvent.GetControl () == m_DeleteButton) {
250
269
DeleteSave ();
0 commit comments