QTfrontend/game.cpp
changeset 8346 3443e0de2c9d
parent 8325 ecd51650d5d8
child 8350 14b938faec69
--- a/QTfrontend/game.cpp	Fri Dec 28 23:54:42 2012 +0100
+++ b/QTfrontend/game.cpp	Sat Dec 29 22:50:10 2012 +0100
@@ -29,6 +29,7 @@
 #include "gamecfgwidget.h"
 #include "teamselect.h"
 #include "proto.h"
+#include "binds.h"
 #include "campaign.h"
 
 #include <QTextStream>
@@ -73,6 +74,18 @@
     SetGameState(gsStopped);
 }
 
+void HWGame::addKeyBindings(QByteArray * buf)
+{
+    for(int i = 0; i < BINDS_NUMBER; i++)
+    {
+        QString value = config->value(QString("Binds/%1").arg(cbinds[i].action), cbinds[i].strbind).toString();
+        if (value.isEmpty() || value == "default") continue;
+        
+        QString bind = QString("edbind " + value + " " + cbinds[i].action);
+        HWProto::addStringToBuffer(*buf, bind);
+    }
+}
+
 void HWGame::commonConfig()
 {
     QByteArray buf;
@@ -90,6 +103,8 @@
     }
     HWProto::addStringToBuffer(buf, gt);
 
+    addKeyBindings(&buf);
+
     buf += gamecfg->getFullConfig();
 
     if (m_pTeamSelWidget)
@@ -102,10 +117,11 @@
             HWProto::addStringToBuffer(buf, QString("eammreinf %1").arg(ammostr.mid(3 * cAmmoNumber, cAmmoNumber)));
             if(gamecfg->schemeData(15).toBool() || !gamecfg->schemeData(21).toBool()) HWProto::addStringToBuffer(buf, QString("eammstore"));
             HWProto::addStringListToBuffer(buf,
-                                           team.teamGameConfig(gamecfg->getInitHealth()));
+                                           team.teamGameConfig(gamecfg->getInitHealth(), config));
             ;
         }
     }
+    
     RawSendIPC(buf);
 }
 
@@ -119,6 +135,8 @@
     QByteArray teamscfg;
     ThemeModel * themeModel = DataManager::instance().themeModel();
 
+    addKeyBindings(&teamscfg);
+
     HWProto::addStringToBuffer(teamscfg, "TL");
     HWProto::addStringToBuffer(teamscfg, QString("etheme %1")
                                .arg((themeModel->rowCount() > 0) ? themeModel->index(rand() % themeModel->rowCount()).data().toString() : "steel"));
@@ -132,7 +150,7 @@
     team1.setNumHedgehogs(4);
     HWNamegen::teamRandomNames(team1,true);
     HWProto::addStringListToBuffer(teamscfg,
-                                   team1.teamGameConfig(100));
+                                   team1.teamGameConfig(100, config));
 
     HWTeam team2;
     team2.setDifficulty(4);
@@ -142,7 +160,7 @@
         HWNamegen::teamRandomNames(team2,true);
     while(!team2.name().compare(team1.name()) || !team2.hedgehog(0).Hat.compare(team1.hedgehog(0).Hat));
     HWProto::addStringListToBuffer(teamscfg,
-                                   team2.teamGameConfig(100));
+                                   team2.teamGameConfig(100, config));
 
     HWProto::addStringToBuffer(teamscfg, QString("eammloadt %1").arg(cDefaultAmmoStore->mid(0, cAmmoNumber)));
     HWProto::addStringToBuffer(teamscfg, QString("eammprob %1").arg(cDefaultAmmoStore->mid(cAmmoNumber, cAmmoNumber)));
@@ -150,6 +168,7 @@
     HWProto::addStringToBuffer(teamscfg, QString("eammreinf %1").arg(cDefaultAmmoStore->mid(3 * cAmmoNumber, cAmmoNumber)));
     HWProto::addStringToBuffer(teamscfg, QString("eammstore"));
     HWProto::addStringToBuffer(teamscfg, QString("eammstore"));
+    
     RawSendIPC(teamscfg);
 }
 
@@ -160,6 +179,8 @@
     HWProto::addStringToBuffer(traincfg, "eseed " + QUuid::createUuid().toString());
     HWProto::addStringToBuffer(traincfg, "escript " + training);
 
+    addKeyBindings(&traincfg);
+
     RawSendIPC(traincfg);
 }
 
@@ -171,6 +192,8 @@
 
     HWProto::addStringToBuffer(campaigncfg, "escript " + campaignScript);
 
+    addKeyBindings(&campaigncfg);
+
     RawSendIPC(campaigncfg);
 }