--- a/QTfrontend/game.cpp Tue Dec 18 20:48:37 2012 +0400
+++ b/QTfrontend/game.cpp Fri Jan 04 21:44:40 2013 +0400
@@ -22,13 +22,17 @@
#include <QColor>
#include <QStringListModel>
#include <QTextStream>
+#include <utility>
+#include "hwform.h"
+#include "ui/page/pageoptions.h"
#include "game.h"
#include "hwconsts.h"
#include "gameuiconfig.h"
#include "gamecfgwidget.h"
#include "teamselect.h"
#include "proto.h"
+#include "binds.h"
#include "campaign.h"
#include "ThemeModel.h"
#include "frontlibpoller.h"
@@ -55,6 +59,18 @@
flib_gameconn_destroy(m_conn);
}
+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;
@@ -72,6 +88,8 @@
}
HWProto::addStringToBuffer(buf, gt);
+ addKeyBindings(&buf);
+
buf += gamecfg->getFullConfig();
if (m_pTeamSelWidget)
@@ -84,10 +102,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);
}
@@ -103,7 +122,9 @@
HWProto::addStringToBuffer(traincfg, "eseed " + QUuid::createUuid().toString());
HWProto::addStringToBuffer(traincfg, "escript " + training);
- //RawSendIPC(traincfg);
+ addKeyBindings(&traincfg);
+
+ //RawSendIPC(traincfg);
}
void HWGame::SendCampaignConfig()
@@ -114,7 +135,9 @@
HWProto::addStringToBuffer(campaigncfg, "escript " + campaignScript);
- // RawSendIPC(campaigncfg);
+ addKeyBindings(&campaigncfg);
+
+ //RawSendIPC(campaigncfg);
}
void HWGame::SendNetConfig()
@@ -217,6 +240,16 @@
writeCampaignVar(msg.right(msg.size() - 3));
break;
}
+ case 'W':
+ {
+ // fetch new window resolution via IPC and save it in the settings
+ int size = msg.size();
+ QString newResolution = QString().append(msg.mid(2)).left(size - 4);
+ QStringList wh = newResolution.split('x');
+ config->Form->ui.pageOptions->windowWidthEdit->setText(wh[0]);
+ config->Form->ui.pageOptions->windowHeightEdit->setText(wh[1]);
+ break;
+ }
default:
{
if (gameType == gtNet && !netSuspend)
@@ -256,24 +289,48 @@
QStringList HWGame::getArguments()
{
QStringList arguments;
- QRect resolution = config->vid_Resolution();
- arguments << cfgdir->absolutePath();
- arguments << QString::number(resolution.width());
- arguments << QString::number(resolution.height());
- arguments << QString::number(config->bitDepth()); // bpp
+ std::pair<QRect, QRect> resolutions = config->vid_ResolutionPair();
+ QString nick = config->netNick().toUtf8().toBase64();
+
+ arguments << "--internal"; //Must be passed as first argument
+ arguments << "--port";
arguments << QString::number(flib_gameconn_getport(m_conn));
- arguments << (config->vid_Fullscreen() ? "1" : "0");
- arguments << (config->isSoundEnabled() ? "1" : "0");
- arguments << (config->isMusicEnabled() ? "1" : "0");
- arguments << QString::number(config->volume()); // sound volume
- arguments << QString::number(config->timerInterval());
+ arguments << "--prefix";
arguments << datadir->absolutePath();
- arguments << (config->isShowFPSEnabled() ? "1" : "0");
- arguments << (config->isAltDamageEnabled() ? "1" : "0");
- arguments << config->netNick().toUtf8().toBase64();
+ arguments << "--user-prefix";
+ arguments << cfgdir->absolutePath();
+ arguments << "--locale";
+ arguments << tr("en.txt");
+ arguments << "--frame-interval";
+ arguments << QString::number(config->timerInterval());
+ arguments << "--volume";
+ arguments << QString::number(config->volume());
+ arguments << "--fullscreen-width";
+ arguments << QString::number(resolutions.first.width());
+ arguments << "--fullscreen-height";
+ arguments << QString::number(resolutions.first.height());
+ arguments << "--width";
+ arguments << QString::number(resolutions.second.width());
+ arguments << "--height";
+ arguments << QString::number(resolutions.second.height());
+ arguments << "--raw-quality";
arguments << QString::number(config->translateQuality());
+ arguments << "--stereo";
arguments << QString::number(config->stereoMode());
- arguments << tr("en.txt");
+ if (config->vid_Fullscreen())
+ arguments << "--fullscreen";
+ if (config->isShowFPSEnabled())
+ arguments << "--showfps";
+ if (config->isAltDamageEnabled())
+ arguments << "--altdmg";
+ if (!config->isSoundEnabled())
+ arguments << "--nosound";
+ if (!config->isMusicEnabled())
+ arguments << "--nomusic";
+ if (!nick.isEmpty()) {
+ arguments << "--nick";
+ arguments << nick;
+ }
return arguments;
}