changeset 2022:25255b395baf

Bugfix: character preview file (.png) deleted together with character.
author thegusty999
date Tue, 01 Nov 2011 08:31:32 +0000
parents c1de43168f5d
children 542b726ef834
files src/gui/savegamelist.cpp
diffstat 1 files changed, 24 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/gui/savegamelist.cpp	Mon Oct 31 22:47:55 2011 +0000
+++ b/src/gui/savegamelist.cpp	Tue Nov 01 08:31:32 2011 +0000
@@ -279,14 +279,37 @@
 
 bool SavegameList::onDeleteCharConfirmClicked(const CEGUI::EventArgs& evt)
 {
+	// Get the save file to remove.
+	std::string saveFile =  m_document->getSaveFile ();
+	if (saveFile.length () <= 0)
+	{
+		return false;
+	}
+
 	CEGUI::WindowManager& win_mgr = CEGUI::WindowManager::getSingleton();
 	CEGUI::FrameWindow* message = (CEGUI::FrameWindow*) win_mgr.getWindow("DeleteChar");
 	
 	message->setVisible(false);
 	message->setModalState(false);
 	
-	remove(m_document->getSaveFile().c_str());
+	// Get rid of the save file
+	remove (saveFile.c_str ());
 
+	// Also get rif od the preview image.
+	// The preview image should have the same name as the save file, but with a different extension.
+	// Using the standard 3 char extension (4 if the "." is included).
+	if (saveFile.length () > 4)
+	{
+		// Parse the name.
+		std::string previewPicture (saveFile);
+		previewPicture.erase (saveFile.length () - 4, saveFile.length());
+		previewPicture.append (".png");
+
+		// Get rid of the file
+		remove (previewPicture.c_str ());
+	}
+
+	// Clear the selection in the menu.
 	if(m_currentSelected != 0)
 	{
 		CEGUI::WindowManager::getSingleton().destroyWindow(m_currentSelected);