Try to use map preview facilities: flibqtfrontend
authorunc0rr
Thu, 22 Nov 2012 01:19:16 +0400
branchflibqtfrontend
changeset 8092 08960209db8c
parent 8091 e0a76056a633
child 8094 6c5b4e69f03d
Try to use map preview facilities: - HWGame and HWRecorder are completely broken - HWMap should work, but doesn't
QTfrontend/CMakeLists.txt
QTfrontend/game.cpp
QTfrontend/game.h
QTfrontend/net/hwmap.cpp
QTfrontend/net/hwmap.h
QTfrontend/net/recorder.cpp
QTfrontend/net/recorder.h
QTfrontend/net/tcpBase.cpp
QTfrontend/net/tcpBase.h
QTfrontend/ui/widget/gamecfgwidget.cpp
QTfrontend/ui/widget/gamecfgwidget.h
QTfrontend/ui/widget/mapContainer.cpp
QTfrontend/ui/widget/mapContainer.h
QTfrontend/util/frontlibpoller.cpp
QTfrontend/util/frontlibpoller.h
project_files/hedgewars.pro
--- a/QTfrontend/CMakeLists.txt	Thu Nov 22 00:56:36 2012 +0400
+++ b/QTfrontend/CMakeLists.txt	Thu Nov 22 01:19:16 2012 +0400
@@ -123,6 +123,7 @@
     team.h
     util/DataManager.h
     util/LibavInteraction.h
+    util/frontlibpoller.h
     )
 
 set(hwfr_hdrs
--- a/QTfrontend/game.cpp	Thu Nov 22 00:56:36 2012 +0400
+++ b/QTfrontend/game.cpp	Thu Nov 22 01:19:16 2012 +0400
@@ -37,7 +37,7 @@
 QString training, campaign, campaignScript, campaignTeam; // TODO: Cleaner solution?
 
 HWGame::HWGame(GameUIConfig * config, GameCFGWidget * gamecfg, QString ammo, TeamSelWidget* pTeamSelWidget) :
-    TCPBase(true, 0),
+    TCPBase(0),
     ammostr(ammo),
     m_pTeamSelWidget(pTeamSelWidget)
 {
@@ -52,7 +52,7 @@
 }
 
 void HWGame::onClientDisconnect()
-{
+{/*
     switch (gameType)
     {
         case gtDemo:
@@ -69,7 +69,7 @@
                 emit HaveRecord(rtDemo, demo);
             else
                 emit HaveRecord(rtNeither, demo);
-    }
+    }*/
     SetGameState(gsStopped);
 }
 
@@ -106,7 +106,7 @@
             ;
         }
     }
-    RawSendIPC(buf);
+    //RawSendIPC(buf);
 }
 
 void HWGame::SendConfig()
@@ -150,7 +150,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);
+    //RawSendIPC(teamscfg);
 }
 
 void HWGame::SendTrainingConfig()
@@ -160,7 +160,7 @@
     HWProto::addStringToBuffer(traincfg, "eseed " + QUuid::createUuid().toString());
     HWProto::addStringToBuffer(traincfg, "escript " + training);
 
-    RawSendIPC(traincfg);
+   //RawSendIPC(traincfg);
 }
 
 void HWGame::SendCampaignConfig()
@@ -171,7 +171,7 @@
 
     HWProto::addStringToBuffer(campaigncfg, "escript " + campaignScript);
 
-    RawSendIPC(campaigncfg);
+   // RawSendIPC(campaigncfg);
 }
 
 void HWGame::SendNetConfig()
@@ -185,7 +185,7 @@
     {
         case '?':
         {
-            SendIPC("!");
+            //SendIPC("!");
             break;
         }
         case 'C':
@@ -256,7 +256,7 @@
             emit SendChat(msgbody);
             QByteArray buf;
             HWProto::addStringToBuffer(buf, "s" + HWProto::formatChatMsg(config->netNick(), msgbody) + "\x20\x20");
-            demo.append(buf);
+            //demo.append(buf);
             break;
         }
         case 'b':
@@ -280,25 +280,25 @@
             {
                 emit SendNet(msg);
             }
-            demo.append(msg);
+            //demo.append(msg);
         }
     }
 }
 
 void HWGame::FromNet(const QByteArray & msg)
 {
-    RawSendIPC(msg);
+    //RawSendIPC(msg);
 }
 
 void HWGame::FromNetChat(const QString & msg)
 {
     QByteArray buf;
     HWProto::addStringToBuffer(buf, 's' + msg + "\x20\x20");
-    RawSendIPC(buf);
+    //RawSendIPC(buf);
 }
 
 void HWGame::onClientRead()
-{
+{/*
     quint8 msglen;
     quint32 bufsize;
     while (!readbuffer.isEmpty() && ((bufsize = readbuffer.size()) > 0) &&
@@ -307,7 +307,7 @@
         QByteArray msg = readbuffer.left(msglen + 1);
         readbuffer.remove(0, msglen + 1);
         ParseMessage(msg);
-    }
+    }*/
 }
 
 QStringList HWGame::getArguments()
@@ -318,7 +318,7 @@
     arguments << QString::number(resolution.width());
     arguments << QString::number(resolution.height());
     arguments << QString::number(config->bitDepth()); // bpp
-    arguments << QString("%1").arg(ipc_port);
+    //arguments << QString("%1").arg(ipc_port);
     arguments << (config->vid_Fullscreen() ? "1" : "0");
     arguments << (config->isSoundEnabled() ? "1" : "0");
     arguments << (config->isMusicEnabled() ? "1" : "0");
@@ -346,35 +346,35 @@
     }
 
     // read demo
-    toSendBuf = demofile.readAll();
+    //toSendBuf = demofile.readAll();
 
     // run engine
-    demo.clear();
-    Start(false);
+    //demo.clear();
+    start(false);
     SetGameState(gsStarted);
 }
 
 void HWGame::StartNet()
 {
     gameType = gtNet;
-    demo.clear();
-    Start(false);
+    //demo.clear();
+    start(false);
     SetGameState(gsStarted);
 }
 
 void HWGame::StartLocal()
 {
     gameType = gtLocal;
-    demo.clear();
-    Start(false);
+    //demo.clear();
+    start(false);
     SetGameState(gsStarted);
 }
 
 void HWGame::StartQuick()
 {
     gameType = gtQLocal;
-    demo.clear();
-    Start(false);
+    //demo.clear();
+    start(false);
     SetGameState(gsStarted);
 }
 
@@ -382,8 +382,8 @@
 {
     gameType = gtTraining;
     training = "Missions/Training/" + file + ".lua";
-    demo.clear();
-    Start(false);
+    //demo.clear();
+    start(false);
     SetGameState(gsStarted);
 }
 
@@ -393,8 +393,8 @@
     campaign = camp;
     campaignScript = "Missions/Campaign/" + camp + "/" + campScript;
     campaignTeam = campTeam;
-    demo.clear();
-    Start(false);
+    //demo.clear();
+    start(false);
     SetGameState(gsStarted);
 }
 
@@ -412,7 +412,7 @@
 {
     QByteArray buf;
     HWProto::addStringToBuffer(buf, QString("efinish"));
-    RawSendIPC(buf);
+    //RawSendIPC(buf);
 }
 
 void HWGame::sendCampaignVar(const QByteArray &varToSend)
@@ -423,7 +423,7 @@
     QString varValue = teamfile.value("Campaign " + campaign + "/" + varToFind, "").toString();
     QByteArray command;
     HWProto::addStringToBuffer(command, "V." + varValue);
-    RawSendIPC(command);
+    //RawSendIPC(command);
 }
 
 void HWGame::writeCampaignVar(const QByteArray & varVal)
@@ -440,3 +440,7 @@
     teamfile.setValue("Campaign " + campaign + "/" + varToWrite, varValue);
 }
 
+void HWGame::onEngineStart()
+{
+
+}
--- a/QTfrontend/game.h	Thu Nov 22 00:56:36 2012 +0400
+++ b/QTfrontend/game.h	Thu Nov 22 01:19:16 2012 +0400
@@ -70,6 +70,7 @@
         virtual QStringList getArguments();
         virtual void onClientRead();
         virtual void onClientDisconnect();
+        void onEngineStart();
 
     signals:
         void SendNet(const QByteArray & msg);
@@ -96,7 +97,7 @@
             gtCampaign = 6,
             gtSave     = 7,
         };
-        char msgbuf[MAXMSGCHARS];
+        //char msgbuf[MAXMSGCHARS];
         QString ammostr;
         GameUIConfig * config;
         GameCFGWidget * gamecfg;
--- a/QTfrontend/net/hwmap.cpp	Thu Nov 22 00:56:36 2012 +0400
+++ b/QTfrontend/net/hwmap.cpp	Thu Nov 22 01:19:16 2012 +0400
@@ -19,14 +19,21 @@
 
 #include "hwconsts.h"
 #include "hwmap.h"
+#include "frontlibpoller.h"
 
 HWMap::HWMap(QObject * parent) :
-    TCPBase(false, parent)
+    TCPBase(parent)
 {
+    m_conn = NULL;
+    m_map = NULL;
 }
 
 HWMap::~HWMap()
 {
+    if(m_conn)
+        flib_mapconn_destroy(m_conn);
+    if(m_map)
+        flib_map_destroy(m_map);
 }
 
 bool HWMap::couldBeRemoved()
@@ -34,18 +41,43 @@
     return !m_hasStarted;
 }
 
-void HWMap::getImage(const QString & seed, int filter, MapGenerator mapgen, int maze_size, const QByteArray & drawMapData)
+void HWMap::getImage(const QString & seed, int filter, int mapgen, int maze_size, const QByteArray & drawMapData)
 {
-    m_seed = seed;
-    templateFilter = filter;
-    m_mapgen = mapgen;
-    m_maze_size = maze_size;
-    if(mapgen == MAPGEN_DRAWN) m_drawMapData = drawMapData;
-    Start(true);
+    switch(mapgen)
+    {
+        case MAPGEN_REGULAR: m_map =
+                flib_map_create_regular(
+                    seed.toUtf8().constData()
+                    , "" // theme? here?
+                    , filter);
+                break;
+        case MAPGEN_MAZE: m_map =
+                flib_map_create_maze(
+                    seed.toUtf8().constData()
+                    , ""
+                    , maze_size);
+                break;
+        case MAPGEN_DRAWN: m_map =
+                flib_map_create_drawn(
+                    seed.toUtf8().constData()
+                    , ""
+                    , (const uint8_t*)drawMapData.constData()
+                    , drawMapData.size()
+                    );
+                break;
+        default:
+            Q_ASSERT_X(false, "HWMap::getImage", "Unknown generator");
+    }
+
+    start(true);
 }
 
 QStringList HWMap::getArguments()
 {
+    Q_ASSERT(m_conn);
+
+    int ipc_port = flib_mapconn_getport(m_conn);
+
     QStringList arguments;
     arguments << cfgdir->absolutePath();
     arguments << QString("%1").arg(ipc_port);
@@ -53,45 +85,33 @@
     return arguments;
 }
 
-void HWMap::onClientDisconnect()
+void HWMap::onSuccess(void *context, const uint8_t *bitmap, int numHedgehogs)
 {
-    if (readbuffer.size() == 128 * 32 + 1)
-    {
-        quint8 *buf = (quint8*) readbuffer.constData();
-        QImage im(buf, 256, 128, QImage::Format_Mono);
-        im.setNumColors(2);
-        emit HHLimitReceived(buf[128 * 32]);
-        emit ImageReceived(im);
-    }
+    qDebug("HWMap::onSuccess");
+    HWMap * hwMap = (HWMap *)context;
+
+    QImage im(bitmap, MAPIMAGE_WIDTH, MAPIMAGE_HEIGHT, QImage::Format_Mono);
+    im.setNumColors(2);
+    emit hwMap->HHLimitReceived(numHedgehogs);
+    emit hwMap->ImageReceived(im);
+
+    hwMap->clientDisconnected();
 }
 
-void HWMap::SendToClientFirst()
+void HWMap::onFailure(void *context, const char *errormessage)
 {
-    SendIPC(QString("eseed %1").arg(m_seed).toUtf8());
-    SendIPC(QString("e$template_filter %1").arg(templateFilter).toUtf8());
-    SendIPC(QString("e$mapgen %1").arg(m_mapgen).toUtf8());
+    qDebug("HWMap::onFailure");
+    HWMap * hwMap = (HWMap *)context;
 
-    switch (m_mapgen)
-    {
-        case MAPGEN_MAZE:
-            SendIPC(QString("e$maze_size %1").arg(m_maze_size).toUtf8());
-            break;
+    hwMap->clientDisconnected();
+}
 
-        case MAPGEN_DRAWN:
-        {
-            QByteArray data = m_drawMapData;
-            while(data.size() > 0)
-            {
-                QByteArray tmp = data;
-                tmp.truncate(200);
-                SendIPC("edraw " + tmp);
-                data.remove(0, 200);
-            }
-            break;
-        }
-        default:
-            ;
-    }
+void HWMap::onEngineStart()
+{
+    qDebug("HWMap::onEngineStart");
+    m_conn = flib_mapconn_create(m_map);
+    flib_mapconn_onSuccess(m_conn, onSuccess, this);
+    flib_mapconn_onFailure(m_conn, onFailure, this);
 
-    SendIPC("!");
+    new FrontLibPoller((void (*)(void *))flib_mapconn_tick, m_conn, this);
 }
--- a/QTfrontend/net/hwmap.h	Thu Nov 22 00:56:36 2012 +0400
+++ b/QTfrontend/net/hwmap.h	Thu Nov 22 01:19:16 2012 +0400
@@ -23,16 +23,10 @@
 #include <QByteArray>
 #include <QString>
 #include <QImage>
+#include <QTimer>
 
 #include "tcpBase.h"
-
-enum MapGenerator
-{
-    MAPGEN_REGULAR,
-    MAPGEN_MAZE,
-    MAPGEN_DRAWN,
-    MAPGEN_MAP
-};
+#include "frontlib.h"
 
 class HWMap : public TCPBase
 {
@@ -41,13 +35,12 @@
     public:
         HWMap(QObject *parent = 0);
         virtual ~HWMap();
-        void getImage(const QString & seed, int templateFilter, MapGenerator mapgen, int maze_size, const QByteArray & drawMapData);
+        void getImage(const QString & seed, int templateFilter, int mapgen, int maze_size, const QByteArray & drawMapData);
         bool couldBeRemoved();
 
     protected:
-        virtual QStringList getArguments();
-        virtual void onClientDisconnect();
-        virtual void SendToClientFirst();
+        QStringList getArguments();
+        void onEngineStart();
 
     signals:
         void ImageReceived(const QImage newImage);
@@ -55,11 +48,12 @@
 
     private:
         QString m_seed;
-        int templateFilter;
-        MapGenerator m_mapgen;
-        int m_maze_size;
-        QByteArray m_drawMapData;
 
+        flib_mapconn * m_conn;
+        flib_map * m_map;
+
+        static void onSuccess(void *context, const uint8_t *bitmap, int numHedgehogs);
+        static void onFailure(void *context, const char *errormessage);
     private slots:
 };
 
--- a/QTfrontend/net/recorder.cpp	Thu Nov 22 00:56:36 2012 +0400
+++ b/QTfrontend/net/recorder.cpp	Thu Nov 22 01:19:16 2012 +0400
@@ -47,16 +47,21 @@
     if (queue.empty())
         numRecorders--;
     else
-        queue.takeFirst()->Start(false);
+        queue.takeFirst()->start(false);
 }
 
 void HWRecorder::onClientDisconnect()
 {
 }
 
+void HWRecorder::onEngineStart()
+{
+
+}
+
 void HWRecorder::onClientRead()
 {
-    quint8 msglen;
+/*    quint8 msglen;
     quint32 bufsize;
     while (!readbuffer.isEmpty() && ((bufsize = readbuffer.size()) > 0) &&
             ((msglen = readbuffer.data()[0]) < bufsize))
@@ -75,12 +80,12 @@
             finished = true;
             break;
         }
-    }
+    }*/
 }
 
 void HWRecorder::EncodeVideo(const QByteArray & record)
 {
-    toSendBuf = record;
+    /*toSendBuf = record;
     toSendBuf.replace(QByteArray("\x02TD"), QByteArray("\x02TV"));
     toSendBuf.replace(QByteArray("\x02TL"), QByteArray("\x02TV"));
     toSendBuf.replace(QByteArray("\x02TN"), QByteArray("\x02TV"));
@@ -92,7 +97,7 @@
         Start(false); // run engine
     }
     else
-        queue.push_back(this);
+        queue.push_back(this);*/
 }
 
 QStringList HWRecorder::getArguments()
@@ -103,7 +108,7 @@
     arguments << QString::number(resolution.width());
     arguments << QString::number(resolution.height());
     arguments << "32"; // bpp
-    arguments << QString("%1").arg(ipc_port);
+    //arguments << QString("%1").arg(ipc_port);
     arguments << "0"; // fullscreen
     arguments << "0"; // sound
     arguments << "0"; // music
--- a/QTfrontend/net/recorder.h	Thu Nov 22 00:56:36 2012 +0400
+++ b/QTfrontend/net/recorder.h	Thu Nov 22 01:19:16 2012 +0400
@@ -45,6 +45,7 @@
         virtual QStringList getArguments();
         virtual void onClientRead();
         virtual void onClientDisconnect();
+        void onEngineStart();
 
     signals:
         void onProgress(float progress); // 0 < progress < 1
--- a/QTfrontend/net/tcpBase.cpp	Thu Nov 22 00:56:36 2012 +0400
+++ b/QTfrontend/net/tcpBase.cpp	Thu Nov 22 01:19:16 2012 +0400
@@ -57,74 +57,32 @@
 #endif
 
 QList<TCPBase*> srvsList;
-QPointer<QTcpServer> TCPBase::IPCServer(0);
 
 TCPBase::~TCPBase()
 {
     // make sure this object is not in the server list anymore
     srvsList.removeOne(this);
-
-    if (IPCSocket)
-        IPCSocket->deleteLater();
 }
 
-TCPBase::TCPBase(bool demoMode, QObject *parent) :
+TCPBase::TCPBase(QObject *parent) :
     QObject(parent),
-    m_hasStarted(false),
-    m_isDemoMode(demoMode),
-    IPCSocket(0)
+    m_hasStarted(false)
 {
-    if(!IPCServer)
-    {
-        IPCServer = new QTcpServer(0);
-        IPCServer->setMaxPendingConnections(1);
-        if (!IPCServer->listen(QHostAddress::LocalHost))
-        {
-            QMessageBox deniedMsg(QApplication::activeWindow());
-            deniedMsg.setIcon(QMessageBox::Critical);
-            deniedMsg.setWindowTitle(QMessageBox::tr("TCP - Error"));
-            deniedMsg.setText(QMessageBox::tr("Unable to start the server: %1.").arg(IPCServer->errorString()));
-            deniedMsg.setWindowModality(Qt::WindowModal);
-            deniedMsg.exec();
 
-            exit(0); // FIXME - should be graceful exit here (lower Critical -> Warning above when implemented)
-        }
-    }
-#ifdef HWLIBRARY
-    ipc_port=65000; //HACK
-#else
-    ipc_port=IPCServer->serverPort();
-#endif
-}
-
-void TCPBase::NewConnection()
-{
-    if(IPCSocket)
-    {
-        // connection should be already finished
-        return;
-    }
-    disconnect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection()));
-    IPCSocket = IPCServer->nextPendingConnection();
-    if(!IPCSocket) return;
-    connect(IPCSocket, SIGNAL(disconnected()), this, SLOT(ClientDisconnect()));
-    connect(IPCSocket, SIGNAL(readyRead()), this, SLOT(ClientRead()));
-    SendToClientFirst();
 }
 
 void TCPBase::RealStart()
 {
-    connect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection()));
-    IPCSocket = 0;
+    onEngineStart();
 
 #ifdef HWLIBRARY
     EngineThread engineThread;// = new EngineThread(this);
     engineThread.start();
 #else
     QProcess * process;
+
     process = new QProcess();
-    connect(process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(StartProcessError(QProcess::ProcessError)));
-    QStringList arguments=getArguments();
+    QStringList arguments = getArguments();
 
     // redirect everything written on stdout/stderr
     if(isDevBuild)
@@ -135,50 +93,26 @@
     m_hasStarted = true;
 }
 
-void TCPBase::ClientDisconnect()
+void TCPBase::clientDisconnected()
 {
-    disconnect(IPCSocket, SIGNAL(readyRead()), this, SLOT(ClientRead()));
-    onClientDisconnect();
-
-    emit isReadyNow();
-    IPCSocket->deleteLater();
+    emit nextPlease();
 
     deleteLater();
 }
 
-void TCPBase::ClientRead()
-{
-    QByteArray readed=IPCSocket->readAll();
-    if(readed.isEmpty()) return;
-    readbuffer.append(readed);
-    onClientRead();
-}
-
-void TCPBase::StartProcessError(QProcess::ProcessError error)
+void TCPBase::iStart()
 {
-    QMessageBox deniedMsg(QApplication::activeWindow());
-    deniedMsg.setIcon(QMessageBox::Critical);
-    deniedMsg.setWindowTitle(QMessageBox::tr("TCP - Error"));
-    deniedMsg.setText(QMessageBox::tr("Unable to run engine at ") + bindir->absolutePath() + "/hwengine\n" +
-                      QMessageBox::tr("Error code: %1").arg(error));
-    deniedMsg.setWindowModality(Qt::WindowModal);
-    deniedMsg.exec();
-
-    ClientDisconnect();
-}
-
-void TCPBase::tcpServerReady()
-{
-    disconnect(srvsList.first(), SIGNAL(isReadyNow()), this, SLOT(tcpServerReady()));
+    disconnect(srvsList.first(), SIGNAL(nextPlease()), this, SLOT(iStart()));
 
     RealStart();
 }
 
-void TCPBase::Start(bool couldCancelPreviousRequest)
+void TCPBase::start(bool couldCancelPreviousRequest)
 {
     if(srvsList.isEmpty())
     {
         srvsList.push_back(this);
+
         RealStart();
     }
     else
@@ -190,56 +124,15 @@
         {
             srvsList.removeLast();
             last->deleteLater();
-            Start(couldCancelPreviousRequest);
+            start(couldCancelPreviousRequest);
         } else
         {
-            connect(srvsList.last(), SIGNAL(isReadyNow()), this, SLOT(tcpServerReady()));
+            connect(srvsList.last(), SIGNAL(nextPlease()), this, SLOT(iStart()));
             srvsList.push_back(this);
         }
     }
 }
 
-void TCPBase::onClientRead()
-{
-}
-
-void TCPBase::onClientDisconnect()
-{
-}
-
-void TCPBase::SendToClientFirst()
-{
-}
-
-void TCPBase::SendIPC(const QByteArray & buf)
-{
-    if (buf.size() > MAXMSGCHARS) return;
-    quint8 len = buf.size();
-    RawSendIPC(QByteArray::fromRawData((char *)&len, 1) + buf);
-}
-
-void TCPBase::RawSendIPC(const QByteArray & buf)
-{
-    if (!IPCSocket)
-    {
-        toSendBuf += buf;
-    }
-    else
-    {
-        if (toSendBuf.size() > 0)
-        {
-            IPCSocket->write(toSendBuf);
-            if(m_isDemoMode) demo.append(toSendBuf);
-            toSendBuf.clear();
-        }
-        if(!buf.isEmpty())
-        {
-            IPCSocket->write(buf);
-            if(m_isDemoMode) demo.append(buf);
-        }
-    }
-}
-
 bool TCPBase::couldBeRemoved()
 {
     return false;
--- a/QTfrontend/net/tcpBase.h	Thu Nov 22 00:56:36 2012 +0400
+++ b/QTfrontend/net/tcpBase.h	Thu Nov 22 01:19:16 2012 +0400
@@ -21,64 +21,37 @@
 #define _TCPBASE_INCLUDED
 
 #include <QObject>
-#include <QTcpServer>
-#include <QTcpSocket>
-#include <QByteArray>
-#include <QString>
-#include <QDir>
 #include <QProcess>
-#include <QPointer>
-
-#include <QImage>
-
-#define MAXMSGCHARS 255
 
 class TCPBase : public QObject
 {
         Q_OBJECT
 
     public:
-        TCPBase(bool demoMode, QObject * parent = 0);
+        TCPBase(QObject * parent = 0);
         virtual ~TCPBase();
 
         virtual bool couldBeRemoved();
 
     signals:
-        void isReadyNow();
+        void nextPlease();
 
     protected:
         bool m_hasStarted;
-        quint16 ipc_port;
+        int m_port;
 
-        void Start(bool couldCancelPreviousRequest);
-
-        QByteArray readbuffer;
+        void start(bool couldCancelPreviousRequest);
 
-        QByteArray toSendBuf;
-        QByteArray demo;
+        virtual QStringList getArguments() = 0;
+        virtual void onEngineStart() = 0;
 
-        void SendIPC(const QByteArray & buf);
-        void RawSendIPC(const QByteArray & buf);
-
-        virtual QStringList getArguments()=0;
-        virtual void onClientRead();
-        virtual void onClientDisconnect();
-        virtual void SendToClientFirst();
+        void clientDisconnected();
 
     private:
-        static QPointer<QTcpServer> IPCServer;
-
-        bool m_isDemoMode;
         void RealStart();
-        QPointer<QTcpSocket> IPCSocket;
 
     private slots:
-        void NewConnection();
-        void ClientDisconnect();
-        void ClientRead();
-        void StartProcessError(QProcess::ProcessError error);
-
-        void tcpServerReady();
+        void iStart();
 };
 
 #endif // _TCPBASE_INCLUDED
--- a/QTfrontend/ui/widget/gamecfgwidget.cpp	Thu Nov 22 00:56:36 2012 +0400
+++ b/QTfrontend/ui/widget/gamecfgwidget.cpp	Thu Nov 22 01:19:16 2012 +0400
@@ -108,7 +108,7 @@
 
     connect(pMapContainer, SIGNAL(seedChanged(const QString &)), this, SLOT(seedChanged(const QString &)));
     connect(pMapContainer, SIGNAL(mapChanged(const QString &)), this, SLOT(mapChanged(const QString &)));
-    connect(pMapContainer, SIGNAL(mapgenChanged(MapGenerator)), this, SLOT(mapgenChanged(MapGenerator)));
+    connect(pMapContainer, SIGNAL(mapgenChanged(int)), this, SLOT(mapgenChanged(int)));
     connect(pMapContainer, SIGNAL(mazeSizeChanged(int)), this, SLOT(maze_sizeChanged(int)));
     connect(pMapContainer, SIGNAL(themeChanged(const QString &)), this, SLOT(themeChanged(const QString &)));
     connect(pMapContainer, SIGNAL(newTemplateFilter(int)), this, SLOT(templateFilterChanged(int)));
@@ -343,7 +343,7 @@
         }
         if (param == "MAPGEN")
         {
-            pMapContainer->setMapgen((MapGenerator)value.toUInt());
+            pMapContainer->setMapgen(value.toInt());
             return;
         }
         if (param == "MAZE_SIZE")
@@ -382,7 +382,7 @@
 
             pMapContainer->setAllMapParameters(
                 slValue[0],
-                (MapGenerator)slValue[1].toUInt(),
+                slValue[1].toInt(),
                 slValue[2].toUInt(),
                 seed,
                 slValue[4].toUInt()
@@ -553,7 +553,7 @@
     emit paramChanged("SCRIPT", QStringList(name));
 }
 
-void GameCFGWidget::mapgenChanged(MapGenerator m)
+void GameCFGWidget::mapgenChanged(int m)
 {
     emit paramChanged("MAPGEN", QStringList(QString::number(m)));
 }
--- a/QTfrontend/ui/widget/gamecfgwidget.h	Thu Nov 22 00:56:36 2012 +0400
+++ b/QTfrontend/ui/widget/gamecfgwidget.h	Thu Nov 22 01:19:16 2012 +0400
@@ -69,7 +69,7 @@
         void scriptChanged(int);
         void jumpToSchemes();
         void jumpToWeapons();
-        void mapgenChanged(MapGenerator m);
+        void mapgenChanged(int m);
         void maze_sizeChanged(int s);
         void onDrawnMapChanged(const QByteArray & data);
         void updateModelViews();
--- a/QTfrontend/ui/widget/mapContainer.cpp	Thu Nov 22 00:56:36 2012 +0400
+++ b/QTfrontend/ui/widget/mapContainer.cpp	Thu Nov 22 01:19:16 2012 +0400
@@ -254,7 +254,7 @@
             cbMazeSize->hide();
             break;
         default:
-            mapgen = MAPGEN_MAP;
+            mapgen = MAPGEN_NAMED;
             gbThemes->hide();
             lblFilter->hide();
             cbTemplateFilter->hide();
@@ -339,7 +339,7 @@
 
 QString HWMapContainer::getCurrentMap() const
 {
-    if(chooseMap->currentIndex() < MAPGEN_MAP) return QString();
+    if(chooseMap->currentIndex() < MAPGEN_NAMED) return QString();
     return(m_curMap);
 }
 
@@ -468,7 +468,7 @@
         updatePreview();
 }
 
-MapGenerator HWMapContainer::get_mapgen(void) const
+int HWMapContainer::get_mapgen(void) const
 {
     return mapgen;
 }
@@ -491,7 +491,7 @@
         updatePreview();
 }
 
-void HWMapContainer::intSetMapgen(MapGenerator m)
+void HWMapContainer::intSetMapgen(int m)
 {
     if (mapgen != m)
     {
@@ -508,7 +508,7 @@
             case MAPGEN_DRAWN:
                 m_mapInfo.type = MapModel::HandDrawnMap;
                 break;
-            case MAPGEN_MAP:
+            case MAPGEN_NAMED:
                 switch (m_mapInfo.type)
                 {
                     case MapModel::GeneratedMap:
@@ -521,17 +521,17 @@
                 break;
         }
 
-        if(m != MAPGEN_MAP)
+        if(m != MAPGEN_NAMED)
             chooseMap->setCurrentIndex(m);
 
         emit mapgenChanged(m);
     }
 }
 
-void HWMapContainer::setMapgen(MapGenerator m)
+void HWMapContainer::setMapgen(int m)
 {
     intSetMapgen(m);
-    if(m != MAPGEN_MAP)
+    if(m != MAPGEN_NAMED)
         updatePreview();
 }
 
@@ -619,7 +619,7 @@
     }
 }
 
-void HWMapContainer::setAllMapParameters(const QString &map, MapGenerator m, int mazesize, const QString &seed, int tmpl)
+void HWMapContainer::setAllMapParameters(const QString &map, int m, int mazesize, const QString &seed, int tmpl)
 {
     intSetMapgen(m);
     intSetMazeSize(mazesize);
--- a/QTfrontend/ui/widget/mapContainer.h	Thu Nov 22 00:56:36 2012 +0400
+++ b/QTfrontend/ui/widget/mapContainer.h	Thu Nov 22 01:19:16 2012 +0400
@@ -55,7 +55,7 @@
         QString getCurrentScheme() const;
         QString getCurrentWeapons() const;
         quint32 getTemplateFilter() const;
-        MapGenerator get_mapgen(void) const;
+        int get_mapgen(void) const;
         int getMazeSize(void) const;
         bool getCurrentIsMission() const;
         QByteArray getDrawnMapData();
@@ -69,10 +69,10 @@
         void setMap(const QString & map);
         void setTheme(const QString & theme);
         void setTemplateFilter(int);
-        void setMapgen(MapGenerator m);
+        void setMapgen(int m);
         void setMazeSize(int size);
         void setDrawnMapData(const QByteArray & ar);
-        void setAllMapParameters(const QString & map, MapGenerator m, int mazesize, const QString & seed, int tmpl);
+        void setAllMapParameters(const QString & map, int m, int mazesize, const QString & seed, int tmpl);
         void updateModelViews();
         void onPreviewMapDestroyed(QObject * map);
 
@@ -81,7 +81,7 @@
         void mapChanged(const QString & map);
         void themeChanged(const QString & theme);
         void newTemplateFilter(int filter);
-        void mapgenChanged(MapGenerator m);
+        void mapgenChanged(int m);
         void mazeSizeChanged(int s);
         void drawMapRequested();
         void drawnMapChanged(const QByteArray & data);
@@ -119,12 +119,12 @@
         QComboBox* cbTemplateFilter;
         QLabel *maze_size_label;
         QComboBox *cbMazeSize;
-        MapGenerator mapgen;
+        int mapgen;
         DrawMapScene drawMapScene;
 
         void intSetSeed(const QString & seed);
         void intSetMap(const QString & map);
-        void intSetMapgen(MapGenerator m);
+        void intSetMapgen(int m);
         void intSetTemplateFilter(int);
         void intSetMazeSize(int size);
         void updatePreview();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/util/frontlibpoller.cpp	Thu Nov 22 01:19:16 2012 +0400
@@ -0,0 +1,20 @@
+#include <QTimerEvent>
+
+#include "frontlibpoller.h"
+
+FrontLibPoller::FrontLibPoller(void (*poll)(void * data), void *data, QObject *parent) :
+    QObject(parent)
+{
+    m_poll = poll;
+    m_data = data;
+
+    m_timer.start(50, this);
+}
+
+void FrontLibPoller::timerEvent(QTimerEvent *event)
+{
+    if(event->timerId() == m_timer.timerId())
+        m_poll(m_data);
+    else
+        QObject::timerEvent(event);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/util/frontlibpoller.h	Thu Nov 22 01:19:16 2012 +0400
@@ -0,0 +1,22 @@
+#ifndef FRONTLIBPOLLER_H
+#define FRONTLIBPOLLER_H
+
+#include <QObject>
+#include <QBasicTimer>
+
+class FrontLibPoller : public QObject
+{
+    Q_OBJECT
+public:
+    explicit FrontLibPoller(void (*poll)(void *), void * data, QObject *parent = 0);
+
+private:
+    QBasicTimer m_timer;
+
+    void (*m_poll)(void *);
+    void * m_data;
+
+    void timerEvent(QTimerEvent *event);
+};
+
+#endif // FRONTLIBPOLLER_H
--- a/project_files/hedgewars.pro	Thu Nov 22 00:56:36 2012 +0400
+++ b/project_files/hedgewars.pro	Thu Nov 22 01:19:16 2012 +0400
@@ -1,271 +1,273 @@
-TEMPLATE = app
-TARGET = hedgewars
-DEPENDPATH += ../QTfrontend/
-INCLUDEPATH += ../QTfrontend
-INCLUDEPATH += ../QTfrontend/model
-INCLUDEPATH += ../QTfrontend/ui
-INCLUDEPATH += ../QTfrontend/ui/widget
-INCLUDEPATH += ../QTfrontend/ui/page
-INCLUDEPATH += ../QTfrontend/ui/dialog
-INCLUDEPATH += ../QTfrontend/net
-INCLUDEPATH += ../QTfrontend/util
-INCLUDEPATH += ../misc/physfs/src
-INCLUDEPATH += ../misc/physfs/extras
-INCLUDEPATH += ../project_files/frontlib
-
-DESTDIR = ../bin
-
-QT += network
-QT += webkit
-
-HEADERS += ../QTfrontend/model/ThemeModel.h \
-    ../QTfrontend/model/MapModel.h \
-    ../QTfrontend/model/ammoSchemeModel.h \
-    ../QTfrontend/model/netserverslist.h \
-    ../QTfrontend/ui/page/pagedrawmap.h \
-    ../QTfrontend/ui/page/pagedata.h \
-    ../QTfrontend/ui/page/pagetraining.h \
-    ../QTfrontend/ui/page/pageselectweapon.h \
-    ../QTfrontend/ui/page/pagesingleplayer.h \
-    ../QTfrontend/ui/page/pagenettype.h \
-    ../QTfrontend/ui/page/pageingame.h \
-    ../QTfrontend/ui/page/pageadmin.h \
-    ../QTfrontend/ui/page/pagescheme.h \
-    ../QTfrontend/ui/page/pagemultiplayer.h \
-    ../QTfrontend/ui/page/pageplayrecord.h \
-    ../QTfrontend/ui/page/pagemain.h \
-    ../QTfrontend/ui/page/pageoptions.h \
-    ../QTfrontend/ui/page/pagenetgame.h \
-    ../QTfrontend/ui/page/pageeditteam.h \
-    ../QTfrontend/ui/page/pageconnecting.h \
-    ../QTfrontend/ui/page/pageroomslist.h \
-    ../QTfrontend/ui/page/pagenet.h \
-    ../QTfrontend/ui/page/pagecampaign.h \
-    ../QTfrontend/ui/page/pageinfo.h \
-    ../QTfrontend/ui/page/pagenetserver.h \
-    ../QTfrontend/ui/page/pagegamestats.h \
-    ../QTfrontend/ui/dialog/input_ip.h \
-    ../QTfrontend/ui/qaspectratiolayout.h \
-    ../QTfrontend/ui/widget/bgwidget.h \
-    ../QTfrontend/ui/widget/fpsedit.h \
-    ../QTfrontend/ui/widget/FreqSpinBox.h \
-    ../QTfrontend/ui/widget/igbox.h \
-    ../QTfrontend/ui/widget/chatwidget.h \
-    ../QTfrontend/ui/widget/togglebutton.h \
-    ../QTfrontend/ui/widget/SquareLabel.h \
-    ../QTfrontend/ui/widget/itemNum.h \
-    ../QTfrontend/ui/widget/frameTeam.h \
-    ../QTfrontend/ui/widget/teamselect.h \
-    ../QTfrontend/ui/widget/vertScrollArea.h \
-    ../QTfrontend/ui/widget/about.h \
-    ../QTfrontend/ui/widget/teamselhelper.h \
-    ../QTfrontend/ui/widget/drawmapwidget.h \
-    ../QTfrontend/ui/widget/databrowser.h \
-    ../QTfrontend/ui/widget/hedgehogerWidget.h \
-    ../QTfrontend/ui/widget/selectWeapon.h \
-    ../QTfrontend/ui/widget/weaponItem.h \
-    ../QTfrontend/ui/widget/gamecfgwidget.h \
-    ../QTfrontend/ui/widget/mapContainer.h \
-    ../QTfrontend/ui/widget/HistoryLineEdit.h \
-    ../QTfrontend/ui/widget/SmartLineEdit.h \
-    ../QTfrontend/util/DataManager.h \
-    ../QTfrontend/net/netregister.h \
-    ../QTfrontend/net/netserver.h \
-    ../QTfrontend/net/netudpwidget.h \
-    ../QTfrontend/net/tcpBase.h \
-    ../QTfrontend/net/proto.h \
-    ../QTfrontend/net/newnetclient.h \
-    ../QTfrontend/net/netudpserver.h \
-    ../QTfrontend/net/hwmap.h \
-    ../QTfrontend/util/namegen.h \
-    ../QTfrontend/ui/page/AbstractPage.h \
-    ../QTfrontend/drawmapscene.h \
-    ../QTfrontend/game.h \
-    ../QTfrontend/gameuiconfig.h \
-    ../QTfrontend/HWApplication.h \
-    ../QTfrontend/hwform.h \
-    ../QTfrontend/util/SDLInteraction.h \
-    ../QTfrontend/team.h \
-    ../QTfrontend/achievements.h \
-    ../QTfrontend/binds.h \
-    ../QTfrontend/ui_hwform.h \
-    ../QTfrontend/KB.h \
-    ../QTfrontend/hwconsts.h \
-    ../QTfrontend/sdlkeys.h \
-    ../QTfrontend/ui/mouseoverfilter.h \
-    ../QTfrontend/ui/qpushbuttonwithsound.h \
-    ../QTfrontend/ui/widget/qpushbuttonwithsound.h \
-    ../QTfrontend/ui/page/pagefeedback.h \
-    ../QTfrontend/model/roomslistmodel.h \
-    ../QTfrontend/ui/dialog/input_password.h \
-    ../QTfrontend/ui/widget/colorwidget.h \
-    ../QTfrontend/model/HatModel.h \
-    ../QTfrontend/model/GameStyleModel.h \
-    ../QTfrontend/ui/page/pagevideos.h \
-    ../QTfrontend/net/recorder.h \
-    ../QTfrontend/ui/dialog/ask_quit.h \
-    ../QTfrontend/ui/dialog/upload_video.h \
-    ../QTfrontend/campaign.h \
-    ../QTfrontend/model/playerslistmodel.h \
-    ../QTfrontend/util/LibavInteraction.h \
-    ../QTfrontend/util/FileEngine.h
-
-
-SOURCES += ../QTfrontend/model/ammoSchemeModel.cpp \
-    ../QTfrontend/model/MapModel.cpp \
-    ../QTfrontend/model/ThemeModel.cpp \
-    ../QTfrontend/model/netserverslist.cpp \
-    ../QTfrontend/ui/qaspectratiolayout.cpp \
-    ../QTfrontend/ui/page/pagemain.cpp \
-    ../QTfrontend/ui/page/pagetraining.cpp \
-    ../QTfrontend/ui/page/pageroomslist.cpp \
-    ../QTfrontend/ui/page/pagemultiplayer.cpp \
-    ../QTfrontend/ui/page/pagegamestats.cpp \
-    ../QTfrontend/ui/page/pagenettype.cpp \
-    ../QTfrontend/ui/page/pageeditteam.cpp \
-    ../QTfrontend/ui/page/pagenetgame.cpp \
-    ../QTfrontend/ui/page/pagedata.cpp \
-    ../QTfrontend/ui/page/pagedrawmap.cpp \
-    ../QTfrontend/ui/page/pageplayrecord.cpp \
-    ../QTfrontend/ui/page/pageselectweapon.cpp \
-    ../QTfrontend/ui/page/pageingame.cpp \
-    ../QTfrontend/ui/page/pagenetserver.cpp \
-    ../QTfrontend/ui/page/pagecampaign.cpp \
-    ../QTfrontend/ui/page/pageadmin.cpp \
-    ../QTfrontend/ui/page/pageinfo.cpp \
-    ../QTfrontend/ui/page/pageconnecting.cpp \
-    ../QTfrontend/ui/page/pagesingleplayer.cpp \
-    ../QTfrontend/ui/page/pagenet.cpp \
-    ../QTfrontend/ui/page/pagescheme.cpp \
-    ../QTfrontend/ui/page/pageoptions.cpp \
-    ../QTfrontend/ui/dialog/input_ip.cpp \
-    ../QTfrontend/ui/widget/igbox.cpp \
-    ../QTfrontend/ui/widget/selectWeapon.cpp \
-    ../QTfrontend/ui/widget/FreqSpinBox.cpp \
-    ../QTfrontend/ui/widget/SquareLabel.cpp \
-    ../QTfrontend/ui/widget/frameTeam.cpp \
-    ../QTfrontend/ui/widget/fpsedit.cpp \
-    ../QTfrontend/ui/widget/databrowser.cpp \
-    ../QTfrontend/ui/widget/teamselect.cpp \
-    ../QTfrontend/ui/widget/gamecfgwidget.cpp \
-    ../QTfrontend/ui/widget/chatwidget.cpp \
-    ../QTfrontend/ui/widget/itemNum.cpp \
-    ../QTfrontend/ui/widget/bgwidget.cpp \
-    ../QTfrontend/ui/widget/about.cpp \
-    ../QTfrontend/ui/widget/togglebutton.cpp \
-    ../QTfrontend/ui/widget/vertScrollArea.cpp \
-    ../QTfrontend/ui/widget/hedgehogerWidget.cpp \
-    ../QTfrontend/ui/widget/teamselhelper.cpp \
-    ../QTfrontend/ui/widget/drawmapwidget.cpp \
-    ../QTfrontend/ui/widget/weaponItem.cpp \
-    ../QTfrontend/ui/widget/mapContainer.cpp \
-    ../QTfrontend/ui/widget/HistoryLineEdit.cpp \
-    ../QTfrontend/ui/widget/SmartLineEdit.cpp \
-    ../QTfrontend/util/DataManager.cpp \
-    ../QTfrontend/net/tcpBase.cpp \
-    ../QTfrontend/net/netregister.cpp \
-    ../QTfrontend/net/proto.cpp \
-    ../QTfrontend/net/hwmap.cpp \
-    ../QTfrontend/net/netudpserver.cpp \
-    ../QTfrontend/net/newnetclient.cpp \
-    ../QTfrontend/net/netudpwidget.cpp \
-    ../QTfrontend/net/netserver.cpp \
-    ../QTfrontend/util/namegen.cpp \
-    ../QTfrontend/ui/page/AbstractPage.cpp \
-    ../QTfrontend/achievements.cpp \
-    ../QTfrontend/binds.cpp \
-    ../QTfrontend/drawmapscene.cpp \
-    ../QTfrontend/game.cpp \
-    ../QTfrontend/gameuiconfig.cpp \
-    ../QTfrontend/HWApplication.cpp \
-    ../QTfrontend/hwform.cpp \
-    ../QTfrontend/main.cpp \
-    ../QTfrontend/util/SDLInteraction.cpp \
-    ../QTfrontend/team.cpp \
-    ../QTfrontend/ui_hwform.cpp \
-    ../QTfrontend/hwconsts.cpp \
-    ../QTfrontend/ui/mouseoverfilter.cpp \
-    ../QTfrontend/ui/widget/qpushbuttonwithsound.cpp \
-    ../QTfrontend/ui/page/pagefeedback.cpp \
-    ../QTfrontend/model/roomslistmodel.cpp \
-    ../QTfrontend/ui/dialog/input_password.cpp \
-    ../QTfrontend/ui/widget/colorwidget.cpp \
-    ../QTfrontend/model/HatModel.cpp \
-    ../QTfrontend/model/GameStyleModel.cpp \
-    ../QTfrontend/ui/page/pagevideos.cpp \
-    ../QTfrontend/net/recorder.cpp \
-    ../QTfrontend/ui/dialog/ask_quit.cpp \
-    ../QTfrontend/ui/dialog/upload_video.cpp \
-    ../QTfrontend/campaign.cpp \
-    ../QTfrontend/model/playerslistmodel.cpp \
-    ../QTfrontend/util/LibavInteraction.cpp \
-    ../QTfrontend/util/FileEngine.cpp
-
-
-TRANSLATIONS += ../share/hedgewars/Data/Locale/hedgewars_ar.ts \
-    ../share/hedgewars/Data/Locale/hedgewars_bg.ts \
-    ../share/hedgewars/Data/Locale/hedgewars_cs.ts \
-    ../share/hedgewars/Data/Locale/hedgewars_da.ts \
-    ../share/hedgewars/Data/Locale/hedgewars_de.ts \ 
-    ../share/hedgewars/Data/Locale/hedgewars_el.ts \
-    ../share/hedgewars/Data/Locale/hedgewars_en.ts \ 
-    ../share/hedgewars/Data/Locale/hedgewars_es.ts \
-    ../share/hedgewars/Data/Locale/hedgewars_fi.ts \
-    ../share/hedgewars/Data/Locale/hedgewars_fr.ts \ 
-    ../share/hedgewars/Data/Locale/hedgewars_gl.ts \
-    ../share/hedgewars/Data/Locale/hedgewars_hu.ts \ 
-    ../share/hedgewars/Data/Locale/hedgewars_it.ts \ 
-    ../share/hedgewars/Data/Locale/hedgewars_ja.ts \ 
-    ../share/hedgewars/Data/Locale/hedgewars_ko.ts \ 
-    ../share/hedgewars/Data/Locale/hedgewars_lt.ts \
-    ../share/hedgewars/Data/Locale/hedgewars_ms.ts \
-    ../share/hedgewars/Data/Locale/hedgewars_nl.ts \ 
-    ../share/hedgewars/Data/Locale/hedgewars_pl.ts \ 
-    ../share/hedgewars/Data/Locale/hedgewars_pt_BR.ts \
-    ../share/hedgewars/Data/Locale/hedgewars_pt_PT.ts \
-    ../share/hedgewars/Data/Locale/hedgewars_ro.ts \
-    ../share/hedgewars/Data/Locale/hedgewars_ru.ts \
-    ../share/hedgewars/Data/Locale/hedgewars_sk.ts \
-    ../share/hedgewars/Data/Locale/hedgewars_sv.ts \
-    ../share/hedgewars/Data/Locale/hedgewars_tr_TR.ts \
-    ../share/hedgewars/Data/Locale/hedgewars_uk.ts \
-    ../share/hedgewars/Data/Locale/hedgewars_zh_CN.ts \
-    ../share/hedgewars/Data/Locale/hedgewars_zh_TW.ts
-
-RESOURCES += ../QTfrontend/hedgewars.qrc
-
-LIBS += -L../bin -lphysfs -lfrontlib
-
-macx {
-    QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6
-    QMAKE_MAC_SDK=/Developer/SDKs/MacOSX10.6.sdk
-
-    OBJECTIVE_SOURCES += ../QTfrontend/*.m ../QTfrontend/*.mm
-    SOURCES += ../QTfrontend/AutoUpdater.cpp ../QTfrontend/InstallController.cpp \
-               ../../build/QTfrontend/hwconsts.cpp
-    HEADERS += ../QTfrontend/M3InstallController.h ../QTfrontend/M3Panel.h \
-               ../QTfrontend/NSWorkspace_RBAdditions.h ../QTfrontend/AutoUpdater.h \
-               ../QTfrontend/CocoaInitializer.h ../QTfrontend/InstallController.h \
-               ../QTfrontend/SparkleAutoUpdater.h
-
-    LIBS += -lobjc -framework AppKit -framework IOKit -framework Foundation -framework SDL -framework SDL_Mixer -framework Sparkle -DSPARKLE_ENABLED
-    INCLUDEPATH += /Library/Frameworks/SDL.framework/Headers /Library/Frameworks/SDL_Mixer.framework/Headers
-    CONFIG += warn_on x86
-    #CONFIG += x86 ppc x86_64 ppc64
-}
-
-win32 {
-    RC_FILE = ../QTfrontend/hedgewars.rc
-    SOURCES += ../QTfrontend/xfire.cpp
-    INCLUDEPATH += ../misc/winutils/include
-    LIBS += -L../misc/winutils/lib
-}
-
-!macx {
-    LIBS += -lSDL -lSDL_mixer -lSDL_net
-    !win32 {
-        INCLUDEPATH += /usr/local/include/SDL /usr/include/SDL
-    }
-}
-
-FORMS +=
+TEMPLATE = app
+TARGET = hedgewars
+DEPENDPATH += ../QTfrontend/
+INCLUDEPATH += ../QTfrontend
+INCLUDEPATH += ../QTfrontend/model
+INCLUDEPATH += ../QTfrontend/ui
+INCLUDEPATH += ../QTfrontend/ui/widget
+INCLUDEPATH += ../QTfrontend/ui/page
+INCLUDEPATH += ../QTfrontend/ui/dialog
+INCLUDEPATH += ../QTfrontend/net
+INCLUDEPATH += ../QTfrontend/util
+INCLUDEPATH += ../misc/physfs/src
+INCLUDEPATH += ../misc/physfs/extras
+INCLUDEPATH += ../project_files/frontlib
+
+DESTDIR = ../bin
+
+QT += network
+QT += webkit
+
+HEADERS += ../QTfrontend/model/ThemeModel.h \
+    ../QTfrontend/model/MapModel.h \
+    ../QTfrontend/model/ammoSchemeModel.h \
+    ../QTfrontend/model/netserverslist.h \
+    ../QTfrontend/ui/page/pagedrawmap.h \
+    ../QTfrontend/ui/page/pagedata.h \
+    ../QTfrontend/ui/page/pagetraining.h \
+    ../QTfrontend/ui/page/pageselectweapon.h \
+    ../QTfrontend/ui/page/pagesingleplayer.h \
+    ../QTfrontend/ui/page/pagenettype.h \
+    ../QTfrontend/ui/page/pageingame.h \
+    ../QTfrontend/ui/page/pageadmin.h \
+    ../QTfrontend/ui/page/pagescheme.h \
+    ../QTfrontend/ui/page/pagemultiplayer.h \
+    ../QTfrontend/ui/page/pageplayrecord.h \
+    ../QTfrontend/ui/page/pagemain.h \
+    ../QTfrontend/ui/page/pageoptions.h \
+    ../QTfrontend/ui/page/pagenetgame.h \
+    ../QTfrontend/ui/page/pageeditteam.h \
+    ../QTfrontend/ui/page/pageconnecting.h \
+    ../QTfrontend/ui/page/pageroomslist.h \
+    ../QTfrontend/ui/page/pagenet.h \
+    ../QTfrontend/ui/page/pagecampaign.h \
+    ../QTfrontend/ui/page/pageinfo.h \
+    ../QTfrontend/ui/page/pagenetserver.h \
+    ../QTfrontend/ui/page/pagegamestats.h \
+    ../QTfrontend/ui/dialog/input_ip.h \
+    ../QTfrontend/ui/qaspectratiolayout.h \
+    ../QTfrontend/ui/widget/bgwidget.h \
+    ../QTfrontend/ui/widget/fpsedit.h \
+    ../QTfrontend/ui/widget/FreqSpinBox.h \
+    ../QTfrontend/ui/widget/igbox.h \
+    ../QTfrontend/ui/widget/chatwidget.h \
+    ../QTfrontend/ui/widget/togglebutton.h \
+    ../QTfrontend/ui/widget/SquareLabel.h \
+    ../QTfrontend/ui/widget/itemNum.h \
+    ../QTfrontend/ui/widget/frameTeam.h \
+    ../QTfrontend/ui/widget/teamselect.h \
+    ../QTfrontend/ui/widget/vertScrollArea.h \
+    ../QTfrontend/ui/widget/about.h \
+    ../QTfrontend/ui/widget/teamselhelper.h \
+    ../QTfrontend/ui/widget/drawmapwidget.h \
+    ../QTfrontend/ui/widget/databrowser.h \
+    ../QTfrontend/ui/widget/hedgehogerWidget.h \
+    ../QTfrontend/ui/widget/selectWeapon.h \
+    ../QTfrontend/ui/widget/weaponItem.h \
+    ../QTfrontend/ui/widget/gamecfgwidget.h \
+    ../QTfrontend/ui/widget/mapContainer.h \
+    ../QTfrontend/ui/widget/HistoryLineEdit.h \
+    ../QTfrontend/ui/widget/SmartLineEdit.h \
+    ../QTfrontend/util/DataManager.h \
+    ../QTfrontend/net/netregister.h \
+    ../QTfrontend/net/netserver.h \
+    ../QTfrontend/net/netudpwidget.h \
+    ../QTfrontend/net/tcpBase.h \
+    ../QTfrontend/net/proto.h \
+    ../QTfrontend/net/newnetclient.h \
+    ../QTfrontend/net/netudpserver.h \
+    ../QTfrontend/net/hwmap.h \
+    ../QTfrontend/util/namegen.h \
+    ../QTfrontend/ui/page/AbstractPage.h \
+    ../QTfrontend/drawmapscene.h \
+    ../QTfrontend/game.h \
+    ../QTfrontend/gameuiconfig.h \
+    ../QTfrontend/HWApplication.h \
+    ../QTfrontend/hwform.h \
+    ../QTfrontend/util/SDLInteraction.h \
+    ../QTfrontend/team.h \
+    ../QTfrontend/achievements.h \
+    ../QTfrontend/binds.h \
+    ../QTfrontend/ui_hwform.h \
+    ../QTfrontend/KB.h \
+    ../QTfrontend/hwconsts.h \
+    ../QTfrontend/sdlkeys.h \
+    ../QTfrontend/ui/mouseoverfilter.h \
+    ../QTfrontend/ui/qpushbuttonwithsound.h \
+    ../QTfrontend/ui/widget/qpushbuttonwithsound.h \
+    ../QTfrontend/ui/page/pagefeedback.h \
+    ../QTfrontend/model/roomslistmodel.h \
+    ../QTfrontend/ui/dialog/input_password.h \
+    ../QTfrontend/ui/widget/colorwidget.h \
+    ../QTfrontend/model/HatModel.h \
+    ../QTfrontend/model/GameStyleModel.h \
+    ../QTfrontend/ui/page/pagevideos.h \
+    ../QTfrontend/net/recorder.h \
+    ../QTfrontend/ui/dialog/ask_quit.h \
+    ../QTfrontend/ui/dialog/upload_video.h \
+    ../QTfrontend/campaign.h \
+    ../QTfrontend/model/playerslistmodel.h \
+    ../QTfrontend/util/LibavInteraction.h \
+    ../QTfrontend/util/FileEngine.h \
+    ../QTfrontend/util/frontlibpoller.h
+
+
+SOURCES += ../QTfrontend/model/ammoSchemeModel.cpp \
+    ../QTfrontend/model/MapModel.cpp \
+    ../QTfrontend/model/ThemeModel.cpp \
+    ../QTfrontend/model/netserverslist.cpp \
+    ../QTfrontend/ui/qaspectratiolayout.cpp \
+    ../QTfrontend/ui/page/pagemain.cpp \
+    ../QTfrontend/ui/page/pagetraining.cpp \
+    ../QTfrontend/ui/page/pageroomslist.cpp \
+    ../QTfrontend/ui/page/pagemultiplayer.cpp \
+    ../QTfrontend/ui/page/pagegamestats.cpp \
+    ../QTfrontend/ui/page/pagenettype.cpp \
+    ../QTfrontend/ui/page/pageeditteam.cpp \
+    ../QTfrontend/ui/page/pagenetgame.cpp \
+    ../QTfrontend/ui/page/pagedata.cpp \
+    ../QTfrontend/ui/page/pagedrawmap.cpp \
+    ../QTfrontend/ui/page/pageplayrecord.cpp \
+    ../QTfrontend/ui/page/pageselectweapon.cpp \
+    ../QTfrontend/ui/page/pageingame.cpp \
+    ../QTfrontend/ui/page/pagenetserver.cpp \
+    ../QTfrontend/ui/page/pagecampaign.cpp \
+    ../QTfrontend/ui/page/pageadmin.cpp \
+    ../QTfrontend/ui/page/pageinfo.cpp \
+    ../QTfrontend/ui/page/pageconnecting.cpp \
+    ../QTfrontend/ui/page/pagesingleplayer.cpp \
+    ../QTfrontend/ui/page/pagenet.cpp \
+    ../QTfrontend/ui/page/pagescheme.cpp \
+    ../QTfrontend/ui/page/pageoptions.cpp \
+    ../QTfrontend/ui/dialog/input_ip.cpp \
+    ../QTfrontend/ui/widget/igbox.cpp \
+    ../QTfrontend/ui/widget/selectWeapon.cpp \
+    ../QTfrontend/ui/widget/FreqSpinBox.cpp \
+    ../QTfrontend/ui/widget/SquareLabel.cpp \
+    ../QTfrontend/ui/widget/frameTeam.cpp \
+    ../QTfrontend/ui/widget/fpsedit.cpp \
+    ../QTfrontend/ui/widget/databrowser.cpp \
+    ../QTfrontend/ui/widget/teamselect.cpp \
+    ../QTfrontend/ui/widget/gamecfgwidget.cpp \
+    ../QTfrontend/ui/widget/chatwidget.cpp \
+    ../QTfrontend/ui/widget/itemNum.cpp \
+    ../QTfrontend/ui/widget/bgwidget.cpp \
+    ../QTfrontend/ui/widget/about.cpp \
+    ../QTfrontend/ui/widget/togglebutton.cpp \
+    ../QTfrontend/ui/widget/vertScrollArea.cpp \
+    ../QTfrontend/ui/widget/hedgehogerWidget.cpp \
+    ../QTfrontend/ui/widget/teamselhelper.cpp \
+    ../QTfrontend/ui/widget/drawmapwidget.cpp \
+    ../QTfrontend/ui/widget/weaponItem.cpp \
+    ../QTfrontend/ui/widget/mapContainer.cpp \
+    ../QTfrontend/ui/widget/HistoryLineEdit.cpp \
+    ../QTfrontend/ui/widget/SmartLineEdit.cpp \
+    ../QTfrontend/util/DataManager.cpp \
+    ../QTfrontend/net/tcpBase.cpp \
+    ../QTfrontend/net/netregister.cpp \
+    ../QTfrontend/net/proto.cpp \
+    ../QTfrontend/net/hwmap.cpp \
+    ../QTfrontend/net/netudpserver.cpp \
+    ../QTfrontend/net/newnetclient.cpp \
+    ../QTfrontend/net/netudpwidget.cpp \
+    ../QTfrontend/net/netserver.cpp \
+    ../QTfrontend/util/namegen.cpp \
+    ../QTfrontend/ui/page/AbstractPage.cpp \
+    ../QTfrontend/achievements.cpp \
+    ../QTfrontend/binds.cpp \
+    ../QTfrontend/drawmapscene.cpp \
+    ../QTfrontend/game.cpp \
+    ../QTfrontend/gameuiconfig.cpp \
+    ../QTfrontend/HWApplication.cpp \
+    ../QTfrontend/hwform.cpp \
+    ../QTfrontend/main.cpp \
+    ../QTfrontend/util/SDLInteraction.cpp \
+    ../QTfrontend/team.cpp \
+    ../QTfrontend/ui_hwform.cpp \
+    ../QTfrontend/hwconsts.cpp \
+    ../QTfrontend/ui/mouseoverfilter.cpp \
+    ../QTfrontend/ui/widget/qpushbuttonwithsound.cpp \
+    ../QTfrontend/ui/page/pagefeedback.cpp \
+    ../QTfrontend/model/roomslistmodel.cpp \
+    ../QTfrontend/ui/dialog/input_password.cpp \
+    ../QTfrontend/ui/widget/colorwidget.cpp \
+    ../QTfrontend/model/HatModel.cpp \
+    ../QTfrontend/model/GameStyleModel.cpp \
+    ../QTfrontend/ui/page/pagevideos.cpp \
+    ../QTfrontend/net/recorder.cpp \
+    ../QTfrontend/ui/dialog/ask_quit.cpp \
+    ../QTfrontend/ui/dialog/upload_video.cpp \
+    ../QTfrontend/campaign.cpp \
+    ../QTfrontend/model/playerslistmodel.cpp \
+    ../QTfrontend/util/LibavInteraction.cpp \
+    ../QTfrontend/util/FileEngine.cpp \
+    ../QTfrontend/util/frontlibpoller.cpp
+
+
+TRANSLATIONS += ../share/hedgewars/Data/Locale/hedgewars_ar.ts \
+    ../share/hedgewars/Data/Locale/hedgewars_bg.ts \
+    ../share/hedgewars/Data/Locale/hedgewars_cs.ts \
+    ../share/hedgewars/Data/Locale/hedgewars_da.ts \
+    ../share/hedgewars/Data/Locale/hedgewars_de.ts \ 
+    ../share/hedgewars/Data/Locale/hedgewars_el.ts \
+    ../share/hedgewars/Data/Locale/hedgewars_en.ts \ 
+    ../share/hedgewars/Data/Locale/hedgewars_es.ts \
+    ../share/hedgewars/Data/Locale/hedgewars_fi.ts \
+    ../share/hedgewars/Data/Locale/hedgewars_fr.ts \ 
+    ../share/hedgewars/Data/Locale/hedgewars_gl.ts \
+    ../share/hedgewars/Data/Locale/hedgewars_hu.ts \ 
+    ../share/hedgewars/Data/Locale/hedgewars_it.ts \ 
+    ../share/hedgewars/Data/Locale/hedgewars_ja.ts \ 
+    ../share/hedgewars/Data/Locale/hedgewars_ko.ts \ 
+    ../share/hedgewars/Data/Locale/hedgewars_lt.ts \
+    ../share/hedgewars/Data/Locale/hedgewars_ms.ts \
+    ../share/hedgewars/Data/Locale/hedgewars_nl.ts \ 
+    ../share/hedgewars/Data/Locale/hedgewars_pl.ts \ 
+    ../share/hedgewars/Data/Locale/hedgewars_pt_BR.ts \
+    ../share/hedgewars/Data/Locale/hedgewars_pt_PT.ts \
+    ../share/hedgewars/Data/Locale/hedgewars_ro.ts \
+    ../share/hedgewars/Data/Locale/hedgewars_ru.ts \
+    ../share/hedgewars/Data/Locale/hedgewars_sk.ts \
+    ../share/hedgewars/Data/Locale/hedgewars_sv.ts \
+    ../share/hedgewars/Data/Locale/hedgewars_tr_TR.ts \
+    ../share/hedgewars/Data/Locale/hedgewars_uk.ts \
+    ../share/hedgewars/Data/Locale/hedgewars_zh_CN.ts \
+    ../share/hedgewars/Data/Locale/hedgewars_zh_TW.ts
+
+RESOURCES += ../QTfrontend/hedgewars.qrc
+
+LIBS += -L../bin -lphysfs -lfrontlib
+
+macx {
+    QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6
+    QMAKE_MAC_SDK=/Developer/SDKs/MacOSX10.6.sdk
+
+    OBJECTIVE_SOURCES += ../QTfrontend/*.m ../QTfrontend/*.mm
+    SOURCES += ../QTfrontend/AutoUpdater.cpp ../QTfrontend/InstallController.cpp \
+               ../../build/QTfrontend/hwconsts.cpp
+    HEADERS += ../QTfrontend/M3InstallController.h ../QTfrontend/M3Panel.h \
+               ../QTfrontend/NSWorkspace_RBAdditions.h ../QTfrontend/AutoUpdater.h \
+               ../QTfrontend/CocoaInitializer.h ../QTfrontend/InstallController.h \
+               ../QTfrontend/SparkleAutoUpdater.h
+
+    LIBS += -lobjc -framework AppKit -framework IOKit -framework Foundation -framework SDL -framework SDL_Mixer -framework Sparkle -DSPARKLE_ENABLED
+    INCLUDEPATH += /Library/Frameworks/SDL.framework/Headers /Library/Frameworks/SDL_Mixer.framework/Headers
+    CONFIG += warn_on x86
+    #CONFIG += x86 ppc x86_64 ppc64
+}
+
+win32 {
+    RC_FILE = ../QTfrontend/hedgewars.rc
+    SOURCES += ../QTfrontend/xfire.cpp
+    INCLUDEPATH += ../misc/winutils/include
+    LIBS += -L../misc/winutils/lib
+}
+
+!macx {
+    LIBS += -lSDL -lSDL_mixer -lSDL_net
+    !win32 {
+        INCLUDEPATH += /usr/local/include/SDL /usr/include/SDL
+    }
+}
+
+FORMS +=