qmlFrontend/hwengine.cpp
branchqmlfrontend
changeset 11423 e045dc60c37e
parent 11422 c6c6a4b32cea
child 11424 86c13e5662f1
equal deleted inserted replaced
11422:c6c6a4b32cea 11423:e045dc60c37e
    35     changeTeamColor_t * flibChangeTeamColor;
    35     changeTeamColor_t * flibChangeTeamColor;
    36 
    36 
    37     connectOfficialServer_t * flibConnectOfficialServer;
    37     connectOfficialServer_t * flibConnectOfficialServer;
    38     passNetData_t * flibPassNetData;
    38     passNetData_t * flibPassNetData;
    39     sendChatLine_t * flibSendChatLine;
    39     sendChatLine_t * flibSendChatLine;
       
    40     joinRoom_t * flibJoinRoom;
    40 }
    41 }
    41 
    42 
    42 Q_DECLARE_METATYPE(MessageType);
    43 Q_DECLARE_METATYPE(MessageType);
    43 
    44 
    44 HWEngine::HWEngine(QQmlEngine *engine, QObject *parent) :
    45 HWEngine::HWEngine(QQmlEngine *engine, QObject *parent) :
    82     flibChangeTeamColor = (changeTeamColor_t*) hwlib.resolve("changeTeamColor");
    83     flibChangeTeamColor = (changeTeamColor_t*) hwlib.resolve("changeTeamColor");
    83 
    84 
    84     flibConnectOfficialServer = (connectOfficialServer_t*) hwlib.resolve("connectOfficialServer");
    85     flibConnectOfficialServer = (connectOfficialServer_t*) hwlib.resolve("connectOfficialServer");
    85     flibPassNetData = (passNetData_t*) hwlib.resolve("passNetData");
    86     flibPassNetData = (passNetData_t*) hwlib.resolve("passNetData");
    86     flibSendChatLine = (sendChatLine_t*) hwlib.resolve("sendChatLine");
    87     flibSendChatLine = (sendChatLine_t*) hwlib.resolve("sendChatLine");
       
    88     flibJoinRoom = (joinRoom_t*) hwlib.resolve("joinRoom");
    87 
    89 
    88     flibInit("/usr/home/unC0Rr/Sources/Hedgewars/Hedgewars-GC/share/hedgewars/Data", "/usr/home/unC0Rr/.hedgewars");
    90     flibInit("/usr/home/unC0Rr/Sources/Hedgewars/Hedgewars-GC/share/hedgewars/Data", "/usr/home/unC0Rr/.hedgewars");
    89     flibRegisterUIMessagesCallback(this, &guiMessagesCallback);
    91     flibRegisterUIMessagesCallback(this, &guiMessagesCallback);
    90 
    92 
    91     ThemeIconProvider * themeIcon = (ThemeIconProvider *)m_engine->imageProvider(QLatin1String("theme"));
    93     ThemeIconProvider * themeIcon = (ThemeIconProvider *)m_engine->imageProvider(QLatin1String("theme"));
   189     case MSG_ADDLOBBYCLIENT: {
   191     case MSG_ADDLOBBYCLIENT: {
   190         emit lobbyClientAdded(QString::fromUtf8(msg));
   192         emit lobbyClientAdded(QString::fromUtf8(msg));
   191         break;
   193         break;
   192     }
   194     }
   193     case MSG_REMOVELOBBYCLIENT: {
   195     case MSG_REMOVELOBBYCLIENT: {
   194         emit lobbyClientRemoved(QString::fromUtf8(msg));
   196         QStringList l = QString::fromUtf8(msg).split('\n');
       
   197         emit lobbyClientRemoved(l[0], l[1]);
   195         break;
   198         break;
   196     }
   199     }
   197     case MSG_LOBBYCHATLINE: {
   200     case MSG_LOBBYCHATLINE: {
   198         QStringList l = QString::fromUtf8(msg).split('\n');
   201         QStringList l = QString::fromUtf8(msg).split('\n');
   199         emit lobbyChatLine(l[0], l[1]);
   202         emit lobbyChatLine(l[0], l[1]);
   209         emit roomUpdated(l[0], 0, l[2], l[3].toInt(), l[4].toInt(), l[5], l[6], l[7], l[8], l[9]);
   212         emit roomUpdated(l[0], 0, l[2], l[3].toInt(), l[4].toInt(), l[5], l[6], l[7], l[8], l[9]);
   210         break;
   213         break;
   211     }
   214     }
   212     case MSG_REMOVEROOM: {
   215     case MSG_REMOVEROOM: {
   213         emit roomRemoved(QString::fromUtf8(msg));
   216         emit roomRemoved(QString::fromUtf8(msg));
       
   217         break;
       
   218     }
       
   219     case MSG_ERROR: {
       
   220         emit errorMessage(QString::fromUtf8(msg));
       
   221         break;
       
   222     }
       
   223     case MSG_WARNING: {
       
   224         emit warningMessage(QString::fromUtf8(msg));
   214         break;
   225         break;
   215     }
   226     }
   216     }
   227     }
   217 }
   228 }
   218 
   229 
   292 void HWEngine::sendChatMessage(const QString &msg)
   303 void HWEngine::sendChatMessage(const QString &msg)
   293 {
   304 {
   294     flibSendChatLine(msg.toUtf8().constData());
   305     flibSendChatLine(msg.toUtf8().constData());
   295 }
   306 }
   296 
   307 
       
   308 void HWEngine::joinRoom(const QString &roomName)
       
   309 {
       
   310     flibJoinRoom(roomName.toUtf8().constData());
       
   311 }
       
   312 
   297 void HWEngine::setTheme(const QString &theme)
   313 void HWEngine::setTheme(const QString &theme)
   298 {
   314 {
   299     flibSetTheme(theme.toUtf8().constData());
   315     flibSetTheme(theme.toUtf8().constData());
   300 }
   316 }
   301 
   317