Better 'Load' page
authorunc0rr
Mon, 20 Aug 2007 18:47:24 +0000
changeset 581 909141b17f68
parent 580 d3ebf84e9fad
child 582 cbbf7646461e
Better 'Load' page
QTfrontend/hwform.cpp
QTfrontend/playrecordpage.cpp
QTfrontend/playrecordpage.h
--- a/QTfrontend/hwform.cpp	Mon Aug 20 18:11:43 2007 +0000
+++ b/QTfrontend/hwform.cpp	Mon Aug 20 18:47:24 2007 +0000
@@ -153,20 +153,14 @@
 
 void HWForm::GoToSaves()
 {
-	QDir tmpdir;
-	tmpdir.cd(cfgdir->absolutePath());
-	tmpdir.cd("Saves");
-	ui.pagePlayDemo->FillFromDir(tmpdir, "hws_" + *cProtoVer);
+	ui.pagePlayDemo->FillFromDir(PagePlayDemo::RT_Save);
 
 	GoToPage(ID_PAGE_DEMOS);
 }
 
 void HWForm::GoToDemos()
 {
-	QDir tmpdir;
-	tmpdir.cd(cfgdir->absolutePath());
-	tmpdir.cd("Demos");
-	ui.pagePlayDemo->FillFromDir(tmpdir, "hwd_" + *cProtoVer);
+	ui.pagePlayDemo->FillFromDir(PagePlayDemo::RT_Demo);
 
 	GoToPage(ID_PAGE_DEMOS);
 }
@@ -303,7 +297,7 @@
 	{
 		QMessageBox::critical(this,
 				tr("Error"),
-				tr("Please, select demo from the list above"),
+				tr("Please, select record from the list above"),
 				tr("OK"));
 		return ;
 	}
--- a/QTfrontend/playrecordpage.cpp	Mon Aug 20 18:11:43 2007 +0000
+++ b/QTfrontend/playrecordpage.cpp	Mon Aug 20 18:47:24 2007 +0000
@@ -48,8 +48,23 @@
 	pageLayout->addWidget(DemosList, 0, 1);
 }
 
-void PagePlayDemo::FillFromDir(QDir dir, const QString & extension)
+void PagePlayDemo::FillFromDir(RecordType rectype)
 {
+	QDir dir;
+	QString extension;
+
+	dir.cd(cfgdir->absolutePath());
+	if (rectype == RT_Demo)
+	{
+		dir.cd("Demos");
+		extension = "hwd_" + *cProtoVer;
+		BtnPlayDemo->setText(QPushButton::tr("Play demo"));
+	} else
+	{
+		dir.cd("Saves");
+		extension = "hws_" + *cProtoVer;
+		BtnPlayDemo->setText(QPushButton::tr("Load"));
+	}
 	dir.setFilter(QDir::Files);
 
 	QStringList sl = dir.entryList(QStringList(QString("*.%1").arg(extension)));
--- a/QTfrontend/playrecordpage.h	Mon Aug 20 18:11:43 2007 +0000
+++ b/QTfrontend/playrecordpage.h	Mon Aug 20 18:47:24 2007 +0000
@@ -30,9 +30,14 @@
 	Q_OBJECT
 
 public:
+	enum RecordType {
+		RT_Demo,
+		RT_Save
+	};
+
 	PagePlayDemo(QWidget* parent = 0);
 
-	void FillFromDir(QDir dir, const QString & extension);
+	void FillFromDir(RecordType rectype);
 
 	QPushButton *BtnBack;
 	QPushButton *BtnPlayDemo;