# HG changeset patch # User unc0rr # Date 1190139842 0 # Node ID 38bdde6a54c1bd6f41ad8dc00f1ddaeb1b2848ae # Parent 5ee863f2f5688fd8b90e3c195425c7b009c2adc6 First step to store trainings in files diff -r 5ee863f2f568 -r 38bdde6a54c1 QTfrontend/game.cpp --- 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); } diff -r 5ee863f2f568 -r 38bdde6a54c1 QTfrontend/main.cpp.in --- 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 - * - * 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 -#include -#include -#include -#include -#include -#include -#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(); -} diff -r 5ee863f2f568 -r 38bdde6a54c1 share/hedgewars/Data/CMakeLists.txt --- 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 diff -r 5ee863f2f568 -r 38bdde6a54c1 share/hedgewars/Data/Trainings/001_Shotgun.txt --- /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 diff -r 5ee863f2f568 -r 38bdde6a54c1 share/hedgewars/Data/Trainings/CMakeLists.txt --- /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)