QTfrontend/hwform.cpp
changeset 11851 5edd66c2d422
parent 11830 6078cf0e4944
child 11852 d7227dc3b397
equal deleted inserted replaced
11850:0025eb20d6f9 11851:5edd66c2d422
    88 #include "chatwidget.h"
    88 #include "chatwidget.h"
    89 #include "input_ip.h"
    89 #include "input_ip.h"
    90 #include "input_password.h"
    90 #include "input_password.h"
    91 #include "ammoSchemeModel.h"
    91 #include "ammoSchemeModel.h"
    92 #include "bgwidget.h"
    92 #include "bgwidget.h"
    93 #include "xfire.h"
       
    94 #include "drawmapwidget.h"
    93 #include "drawmapwidget.h"
    95 #include "mouseoverfilter.h"
    94 #include "mouseoverfilter.h"
    96 #include "roomslistmodel.h"
    95 #include "roomslistmodel.h"
    97 #include "recorder.h"
    96 #include "recorder.h"
    98 #include "playerslistmodel.h"
    97 #include "playerslistmodel.h"
   140     , hwnet(0)
   139     , hwnet(0)
   141 {
   140 {
   142     // set music track
   141     // set music track
   143     SDLInteraction::instance().setMusicTrack("/Music/main_theme.ogg");
   142     SDLInteraction::instance().setMusicTrack("/Music/main_theme.ogg");
   144 
   143 
   145 #ifdef USE_XFIRE
       
   146     xfire_init();
       
   147 #endif
       
   148     this->setStyleSheet(styleSheet);
   144     this->setStyleSheet(styleSheet);
   149     ui.setupUi(this);
   145     ui.setupUi(this);
   150     setMinimumSize(760, 580);
   146     setMinimumSize(760, 580);
   151     //setFocusPolicy(Qt::StrongFocus);
   147     //setFocusPolicy(Qt::StrongFocus);
   152     CustomizePalettes();
   148     CustomizePalettes();
   356     ui.Pages->setCurrentIndex(ID_PAGE_INFO);
   352     ui.Pages->setCurrentIndex(ID_PAGE_INFO);
   357     PagesStack.push(ID_PAGE_MAIN);
   353     PagesStack.push(ID_PAGE_MAIN);
   358     ((AbstractPage*)ui.Pages->widget(ID_PAGE_MAIN))->triggerPageEnter();
   354     ((AbstractPage*)ui.Pages->widget(ID_PAGE_MAIN))->triggerPageEnter();
   359     GoBack();
   355     GoBack();
   360 }
   356 }
   361 
       
   362 #ifdef USE_XFIRE
       
   363 void HWForm::updateXfire(void)
       
   364 {
       
   365     if(hwnet && (hwnet->clientState() != HWNewNet::Disconnected))
       
   366     {
       
   367         xfire_setvalue(XFIRE_SERVER, !hwnet->getHost().compare(QString("%1:%2").arg(NETGAME_DEFAULT_SERVER).arg(NETGAME_DEFAULT_PORT)) ? "Official server" : hwnet->getHost().toAscii());
       
   368         switch(hwnet->clientState())
       
   369         {
       
   370             case HWNewNet::Connecting: // Connecting
       
   371             case HWNewNet::Connected:
       
   372                 xfire_setvalue(XFIRE_STATUS, "Connecting");
       
   373                 xfire_setvalue(XFIRE_NICKNAME, "-");
       
   374                 xfire_setvalue(XFIRE_ROOM, "-");
       
   375             case HWNewNet::InLobby: // In lobby
       
   376                 xfire_setvalue(XFIRE_STATUS, "Online");
       
   377                 xfire_setvalue(XFIRE_NICKNAME, hwnet->getNick().toAscii());
       
   378                 xfire_setvalue(XFIRE_ROOM, "In game lobby");
       
   379                 break;
       
   380             case HWNewNet::InRoom: // In room
       
   381                 xfire_setvalue(XFIRE_STATUS, "Online");
       
   382                 xfire_setvalue(XFIRE_NICKNAME, hwnet->getNick().toAscii());
       
   383                 xfire_setvalue(XFIRE_ROOM, (hwnet->getRoom() + " (waiting for players)").toAscii());
       
   384                 break;
       
   385             case HWNewNet::InGame: // In game
       
   386                 xfire_setvalue(XFIRE_STATUS, "Online");
       
   387                 xfire_setvalue(XFIRE_NICKNAME, hwnet->getNick().toAscii());
       
   388                 xfire_setvalue(XFIRE_ROOM, (hwnet->getRoom() + " (playing or spectating)").toAscii());
       
   389                 break;
       
   390             default:
       
   391                 break;
       
   392         }
       
   393     }
       
   394     else
       
   395     {
       
   396         xfire_setvalue(XFIRE_STATUS, "Offline");
       
   397         xfire_setvalue(XFIRE_NICKNAME, "-");
       
   398         xfire_setvalue(XFIRE_ROOM, "-");
       
   399         xfire_setvalue(XFIRE_SERVER, "-");
       
   400     }
       
   401     xfire_update();
       
   402 }
       
   403 #endif
       
   404 
   357 
   405 void HWForm::onFrontendFullscreen(bool value)
   358 void HWForm::onFrontendFullscreen(bool value)
   406 {
   359 {
   407     if (value)
   360     if (value)
   408         setWindowState(windowState() | Qt::WindowFullScreen);
   361         setWindowState(windowState() | Qt::WindowFullScreen);
   592     return pageName;
   545     return pageName;
   593 }
   546 }
   594 
   547 
   595 void HWForm::OnPageShown(quint8 id, quint8 lastid)
   548 void HWForm::OnPageShown(quint8 id, quint8 lastid)
   596 {
   549 {
   597 #ifdef USE_XFIRE
       
   598     updateXfire();
       
   599 #endif
       
   600 
       
   601 #ifdef QT_DEBUG
   550 #ifdef QT_DEBUG
   602     qDebug("Leaving %s, entering %s", qPrintable(stringifyPageId(lastid)), qPrintable(stringifyPageId(id)));
   551     qDebug("Leaving %s, entering %s", qPrintable(stringifyPageId(lastid)), qPrintable(stringifyPageId(id)));
   603 #endif
   552 #endif
   604     if (lastid == ID_PAGE_MAIN)
   553     if (lastid == ID_PAGE_MAIN)
   605     {
   554     {
  1760     game->StartNet();
  1709     game->StartNet();
  1761 }
  1710 }
  1762 
  1711 
  1763 void HWForm::closeEvent(QCloseEvent *event)
  1712 void HWForm::closeEvent(QCloseEvent *event)
  1764 {
  1713 {
  1765 #ifdef USE_XFIRE
       
  1766     xfire_free();
       
  1767 #endif
       
  1768     config->SaveOptions();
  1714     config->SaveOptions();
  1769 #if VIDEOREC
  1715 if VIDEOREC
  1770     config->SaveVideosOptions();
  1716     config->SaveVideosOptions();
  1771 #endif
  1717 #endif
  1772     event->accept();
  1718     event->accept();
  1773 }
  1719 }
  1774 
  1720