QTfrontend/game.cpp
changeset 3760 d30f1ba768d7
parent 3709 c7849b74748d
child 3774 af0e68ca273e
equal deleted inserted replaced
3759:f352e9dcf516 3760:d30f1ba768d7
    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?
    33 QString training, campaign; // TODO: Cleaner solution?
    34 
    34 
    35 HWGame::HWGame(GameUIConfig * config, GameCFGWidget * gamecfg, QString ammo, TeamSelWidget* pTeamSelWidget) :
    35 HWGame::HWGame(GameUIConfig * config, GameCFGWidget * gamecfg, QString ammo, TeamSelWidget* pTeamSelWidget) :
    36   TCPBase(true),
    36   TCPBase(true),
    37   ammostr(ammo),
    37   ammostr(ammo),
    38   m_pTeamSelWidget(pTeamSelWidget)
    38   m_pTeamSelWidget(pTeamSelWidget)
   144 void HWGame::SendTrainingConfig()
   144 void HWGame::SendTrainingConfig()
   145 {
   145 {
   146     QByteArray traincfg;
   146     QByteArray traincfg;
   147     HWProto::addStringToBuffer(traincfg, "TL");
   147     HWProto::addStringToBuffer(traincfg, "TL");
   148 
   148 
   149     HWProto::addStringToBuffer(traincfg, "escript " + datadir->absolutePath() + "/Missions/Training/" + training + ".lua");
   149     HWProto::addStringToBuffer(traincfg, "escript " + training);
   150 
   150 
   151     RawSendIPC(traincfg);
   151     RawSendIPC(traincfg);
       
   152 }
       
   153 
       
   154 void HWGame::SendCampaignConfig()
       
   155 {
       
   156     QByteArray campaigncfg;
       
   157     HWProto::addStringToBuffer(campaigncfg, "TL");
       
   158 
       
   159     HWProto::addStringToBuffer(campaigncfg, "escript " + campaign);
       
   160 
       
   161     RawSendIPC(campaigncfg);
   152 }
   162 }
   153 
   163 
   154 void HWGame::SendNetConfig()
   164 void HWGame::SendNetConfig()
   155 {
   165 {
   156     commonConfig();
   166     commonConfig();
   178                     SendNetConfig();
   188                     SendNetConfig();
   179                     break;
   189                     break;
   180                 }
   190                 }
   181                 case gtTraining: {
   191                 case gtTraining: {
   182                     SendTrainingConfig();
   192                     SendTrainingConfig();
       
   193                     break;
       
   194                 }
       
   195                 case gtCampaign: {
       
   196                     SendCampaignConfig();
   183                     break;
   197                     break;
   184                 }
   198                 }
   185             }
   199             }
   186             break;
   200             break;
   187         }
   201         }
   341 }
   355 }
   342 
   356 
   343 void HWGame::StartTraining(const QString & file)
   357 void HWGame::StartTraining(const QString & file)
   344 {
   358 {
   345     gameType = gtTraining;
   359     gameType = gtTraining;
   346     training = file;
   360     training = datadir->absolutePath() + "/Missions/Tutorial/" + file + ".lua";
       
   361     demo.clear();
       
   362     Start();
       
   363     SetGameState(gsStarted);
       
   364 }
       
   365 
       
   366 void HWGame::StartCampaign(const QString & file)
       
   367 {
       
   368     gameType = gtCampaign;
       
   369     campaign = datadir->absolutePath() + "/Missions/Campaign/" + file + ".lua";
   347     demo.clear();
   370     demo.clear();
   348     Start();
   371     Start();
   349     SetGameState(gsStarted);
   372     SetGameState(gsStarted);
   350 }
   373 }
   351 
   374