First step to store trainings in files
authorunc0rr
Tue, 18 Sep 2007 18:24:02 +0000
changeset 596 38bdde6a54c1
parent 595 5ee863f2f568
child 597 ec5f057ab268
First step to store trainings in files
QTfrontend/game.cpp
QTfrontend/main.cpp.in
share/hedgewars/Data/CMakeLists.txt
share/hedgewars/Data/Trainings/001_Shotgun.txt
share/hedgewars/Data/Trainings/CMakeLists.txt
--- a/QTfrontend/game.cpp	Sat Sep 15 13:01:44 2007 +0000
+++ b/QTfrontend/game.cpp	Tue Sep 18 18:24:02 2007 +0000
@@ -139,11 +139,18 @@
 	HWProto::addStringListToBuffer(teamscfg,
 			team2.TeamGameConfig(100));
 
-//	HWProto::addStringToBuffer(teamscfg, "eaddtrig 2147483649");
-	HWProto::addStringToBuffer(teamscfg, "eaddtrig s2147483649 1 1 33 1100 -100 1");
-	HWProto::addStringToBuffer(teamscfg, "eaddtrig s1 1 1 33 1200 -100 2");
-	HWProto::addStringToBuffer(teamscfg, "eaddtrig s2 1 1 33 1300 -100 3");
-	HWProto::addStringToBuffer(teamscfg, "eaddtrig s3 1 1 33 1400 -100 0");
+	QFile file(datadir->absolutePath() + "/Trainings/001_Shotgun.txt");
+	if(!file.open(QFile::ReadOnly))
+	{
+		emit ErrorMessage(tr("Error reading training config file"));
+		return;
+	}
+	
+	QTextStream stream(&file);
+	while(!stream.atEnd())
+	{
+		HWProto::addStringToBuffer(teamscfg, stream.readLine());
+	}
 
 	RawSendIPC(teamscfg);
 }
--- a/QTfrontend/main.cpp.in	Sat Sep 15 13:01:44 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,104 +0,0 @@
-/*
- * Hedgewars, a worms-like game
- * Copyright (c) 2005-2007 Andrey Korotaev <unC0Rr@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include <QApplication>
-#include <QTranslator>
-#include <QLocale>
-#include <QMessageBox>
-#include <QFileInfo>
-#include <QDateTime>
-#include <QTextStream>
-#include "hwform.h"
-#include "hwconsts.h"
-
-QDir * bindir;
-QDir * cfgdir;
-QDir * datadir;
-QStringList * Themes;
-
-bool checkForDir(const QString & dir)
-{
-	QDir tmpdir;
-	if (!tmpdir.exists(dir))
-		if (!tmpdir.mkdir(dir))
-		{
-			QMessageBox::critical(0,
-					QObject::tr("Error"),
-					QObject::tr("Cannot create directory %1").arg(dir),
-					QObject::tr("OK"));
-			return false;
-		}
-	return true;
-}
-
-int main(int argc, char *argv[])
-{
-	QApplication app(argc, argv);
-
-	QDateTime now = QDateTime::currentDateTime();
-	QDateTime zero;
-	srand(now.secsTo(zero));
-
-	Q_INIT_RESOURCE(hedgewars);
-
-	QDir mydir("${HEDGEWARS_BINDIR}");
-	mydir.cd("bin");
-
-	bindir = new QDir(mydir);
-	cfgdir = new QDir();
-
-	cfgdir->setPath(cfgdir->homePath());
-	if (checkForDir(cfgdir->absolutePath() + "/.hedgewars"))
-	{
-		checkForDir(cfgdir->absolutePath() + "/.hedgewars/Demos");
-		checkForDir(cfgdir->absolutePath() + "/.hedgewars/Saves");
-	}
-	cfgdir->cd(".hedgewars");
-
-	datadir = new QDir(mydir);
-	datadir->cd("${HEDGEWARS_DATADIR}");
-	if(!datadir->cd("hedgewars/Data")) {
-		QMessageBox::critical(0, QMessageBox::tr("Error"), 
-			QMessageBox::tr("Failed to open data directory:\n%1\n"
-					"Please check your installation").
-					arg(datadir->absolutePath()+"/hedgewars/Data"));
-		return 1;
-	}
-
-	QTranslator Translator;
-	Translator.load(datadir->absolutePath() + "/Locale/hedgewars_" + QLocale::system().name());
-	app.installTranslator(&Translator);
-
-	Themes = new QStringList();
-	QFile themesfile(datadir->absolutePath() + "/Themes/themes.cfg");
-	if (themesfile.open(QIODevice::ReadOnly)) {
-		QTextStream stream(&themesfile);
-		QString str;
-		while (!stream.atEnd())
-		{
-			Themes->append(stream.readLine());
-		}
-		themesfile.close();
-	} else {
-		QMessageBox::critical(0, "Error", "Cannot access themes.cfg", "OK");
-	}
-
-	HWForm *Form = new HWForm();
-	Form->show();
-	return app.exec();
-}
--- a/share/hedgewars/Data/CMakeLists.txt	Sat Sep 15 13:01:44 2007 +0000
+++ b/share/hedgewars/Data/CMakeLists.txt	Tue Sep 18 18:24:02 2007 +0000
@@ -1,3 +1,3 @@
-foreach(dir "Fonts" "Forts" "Graphics" "Locale" "Maps" "Music" "Sounds" "Themes")
+foreach(dir "Fonts" "Forts" "Graphics" "Locale" "Maps" "Music" "Sounds" "Themes" "Trainings")
   add_subdirectory(${dir})
 endforeach(dir)
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/share/hedgewars/Data/Trainings/001_Shotgun.txt	Tue Sep 18 18:24:02 2007 +0000
@@ -0,0 +1,4 @@
+eaddtrig s2147483649 1 1 33 1100 -100 1
+eaddtrig s1 1 1 33 1200 -100 2
+eaddtrig s2 1 1 33 1300 -100 3
+eaddtrig s3 1 1 33 1400 -100 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/share/hedgewars/Data/Trainings/CMakeLists.txt	Tue Sep 18 18:24:02 2007 +0000
@@ -0,0 +1,5 @@
+file(GLOB Trainings 0*.txt)
+
+install(FILES
+	${Trainings}
+	DESTINATION ${SHAREPATH}Data/Trainings)