Frontend:
authorsmxx
Wed, 03 Feb 2010 13:02:28 +0000
changeset 2742 21c0d2e69753
parent 2741 7a84ce33f52f
child 2743 39d097ac2276
Frontend: + Changed save and demo file extensions to ".<protocol>.hwd" and ".<protocol>.hws" to make file associations easier/constant + Added icons to savegame and demo file list (might require some redrawing/updating)
QTfrontend/hedgewars.qrc
QTfrontend/hwform.cpp
QTfrontend/playrecordpage.cpp
QTfrontend/res/file_demo.png
QTfrontend/res/file_save.png
--- a/QTfrontend/hedgewars.qrc	Wed Feb 03 04:18:28 2010 +0000
+++ b/QTfrontend/hedgewars.qrc	Wed Feb 03 13:02:28 2010 +0000
@@ -67,5 +67,7 @@
     <file>res/iconMine.png</file>
     <file>res/dice.png</file>
     <file>res/Star.png</file>
+	<file>res/file_save.png</file>
+	<file>res/file_demo.png</file>
 </qresource>
 </RCC>
--- a/QTfrontend/hwform.cpp	Wed Feb 03 04:18:28 2010 +0000
+++ b/QTfrontend/hwform.cpp	Wed Feb 03 13:02:28 2010 +0000
@@ -842,12 +842,12 @@
 		demo.replace(QByteArray("\x02TL"), QByteArray("\x02TD"));
 		demo.replace(QByteArray("\x02TN"), QByteArray("\x02TD"));
 		demo.replace(QByteArray("\x02TS"), QByteArray("\x02TD"));
-		filename = cfgdir->absolutePath() + "/Demos/" + recordFileName + ".hwd_" + *cProtoVer;
+		filename = cfgdir->absolutePath() + "/Demos/" + recordFileName + "." + *cProtoVer + ".hwd";
 	} else
 	{
 		demo.replace(QByteArray("\x02TL"), QByteArray("\x02TS"));
 		demo.replace(QByteArray("\x02TN"), QByteArray("\x02TS"));
-		filename = cfgdir->absolutePath() + "/Saves/" + recordFileName + ".hws_" + *cProtoVer;
+		filename = cfgdir->absolutePath() + "/Saves/" + recordFileName + "." + *cProtoVer + ".hws";
 	}
 
 
--- a/QTfrontend/playrecordpage.cpp	Wed Feb 03 04:18:28 2010 +0000
+++ b/QTfrontend/playrecordpage.cpp	Wed Feb 03 13:02:28 2010 +0000
@@ -71,25 +71,26 @@
 	if (rectype == RT_Demo)
 	{
 		dir.cd("Demos");
-		extension = "hwd_" + *cProtoVer;
+		extension = "hwd";
 		BtnPlayDemo->setText(QPushButton::tr("Play demo"));
 	} else
 	{
 		dir.cd("Saves");
-		extension = "hws_" + *cProtoVer;
+		extension = "hws";
 		BtnPlayDemo->setText(QPushButton::tr("Load"));
 	}
 	dir.setFilter(QDir::Files);
 
-	QStringList sl = dir.entryList(QStringList(QString("*.%1").arg(extension)));
-	sl.replaceInStrings(QRegExp(QString("^(.*)\\.%1$").arg(extension)), "\\1");
+	QStringList sl = dir.entryList(QStringList(QString("*.%2.%1").arg(extension, *cProtoVer)));
+	sl.replaceInStrings(QRegExp(QString("^(.*)\\.%2\\.%1$").arg(extension, *cProtoVer)), "\\1");
 
 	DemosList->clear();
 	DemosList->addItems(sl);
 
 	for (int i = 0; i < DemosList->count(); ++i)
 	{
-		DemosList->item(i)->setData(Qt::UserRole, dir.absoluteFilePath(QString("%1.%2").arg(sl[i], extension)));
+		DemosList->item(i)->setData(Qt::UserRole, dir.absoluteFilePath(QString("%1.%3.%2").arg(sl[i], extension, *cProtoVer)));
+		DemosList->item(i)->setIcon(recType == RT_Demo ? QIcon(":/res/file_demo.png") : QIcon(":/res/file_save.png"));
 	}
 }
 
@@ -110,13 +111,14 @@
 
 	bool ok;
 
-	QString newname = QInputDialog::getText(this, tr("Rename dialog"), tr("Enter new file name:"), QLineEdit::Normal, finfo.completeBaseName(), &ok);
+	QString newname = QInputDialog::getText(this, tr("Rename dialog"), tr("Enter new file name:"), QLineEdit::Normal, finfo.completeBaseName().replace("." + *cProtoVer, ""), &ok);
 
 	if(ok && newname.size())
 	{
-		QString newfullname = QString("%1/%2.%3")
+		QString newfullname = QString("%1/%2.%3.%4")
 		                              .arg(finfo.absolutePath())
 		                              .arg(newname)
+									  .arg(*cProtoVer)
 		                              .arg(finfo.suffix());
 
 		ok = rfile.rename(newfullname);
@@ -140,8 +142,6 @@
 	}
 	QFile rfile(curritem->data(Qt::UserRole).toString());
 
-	QFileInfo finfo(rfile);
-
 	bool ok;
 
 	ok = rfile.remove();
Binary file QTfrontend/res/file_demo.png has changed
Binary file QTfrontend/res/file_save.png has changed