QTfrontend/game.cpp
changeset 2468 0b62498c201a
parent 2443 fececcbc2189
child 2584 cc049fbb65ef
equal deleted inserted replaced
2467:be6690c337fb 2468:0b62498c201a
    28 #include "KB.h"
    28 #include "KB.h"
    29 #include "proto.h"
    29 #include "proto.h"
    30 
    30 
    31 #include <QTextStream>
    31 #include <QTextStream>
    32 
    32 
       
    33 QString training; // TODO: Cleaner solution?
       
    34 
    33 HWGame::HWGame(GameUIConfig * config, GameCFGWidget * gamecfg, QString ammo, TeamSelWidget* pTeamSelWidget) :
    35 HWGame::HWGame(GameUIConfig * config, GameCFGWidget * gamecfg, QString ammo, TeamSelWidget* pTeamSelWidget) :
    34   TCPBase(true),
    36   TCPBase(true),
    35   ammostr(ammo),
    37   ammostr(ammo),
    36   m_pTeamSelWidget(pTeamSelWidget)
    38   m_pTeamSelWidget(pTeamSelWidget)
    37 {
    39 {
   139 	team1.teamColor = *color1;
   141 	team1.teamColor = *color1;
   140 	team1.numHedgehogs = 1;
   142 	team1.numHedgehogs = 1;
   141 	HWProto::addStringListToBuffer(traincfg,
   143 	HWProto::addStringListToBuffer(traincfg,
   142 			team1.TeamGameConfig(100));
   144 			team1.TeamGameConfig(100));
   143 
   145 
   144 	QFile file(datadir->absolutePath() + "/Trainings/003_RCPlane.txt");
   146 	QFile file(datadir->absolutePath() + "/Trainings/" + training + ".txt");
   145 	if(!file.open(QFile::ReadOnly))
   147 	if(!file.open(QFile::ReadOnly))
   146 	{
   148 	{
   147 		emit ErrorMessage(tr("Error reading training config file"));
   149 		emit ErrorMessage(tr("Error reading training config file"));
   148 		return;
   150 		return;
   149 	}
   151 	}
   348 	demo.clear();
   350 	demo.clear();
   349 	Start();
   351 	Start();
   350 	SetGameState(gsStarted);
   352 	SetGameState(gsStarted);
   351 }
   353 }
   352 
   354 
   353 void HWGame::StartTraining()
   355 void HWGame::StartTraining(const QString & file)
   354 {
   356 {
   355 	gameType = gtTraining;
   357 	gameType = gtTraining;
       
   358 	training = file;
   356 	demo.clear();
   359 	demo.clear();
   357 	Start();
   360 	Start();
   358 	SetGameState(gsStarted);
   361 	SetGameState(gsStarted);
   359 }
   362 }
   360 
   363