QTfrontend/hwform.cpp
changeset 2821 67815ee123d7
parent 2820 389e8b286afe
child 2822 0533562bc3a4
equal deleted inserted replaced
2820:389e8b286afe 2821:67815ee123d7
    52 #include "chatwidget.h"
    52 #include "chatwidget.h"
    53 #include "playrecordpage.h"
    53 #include "playrecordpage.h"
    54 #include "input_ip.h"
    54 #include "input_ip.h"
    55 #include "ammoSchemeModel.h"
    55 #include "ammoSchemeModel.h"
    56 #include "bgwidget.h"
    56 #include "bgwidget.h"
       
    57 #include "xfire.h"
    57 
    58 
    58 #ifdef __APPLE__
    59 #ifdef __APPLE__
    59 #include "CocoaInitializer.h"
    60 #include "CocoaInitializer.h"
    60 #include "M3Panel.h"
    61 #include "M3Panel.h"
    61 #ifdef SPARKLE_ENABLED
    62 #ifdef SPARKLE_ENABLED
    69 bool frontendEffects = true;
    70 bool frontendEffects = true;
    70 
    71 
    71 HWForm::HWForm(QWidget *parent)
    72 HWForm::HWForm(QWidget *parent)
    72   : QMainWindow(parent), pnetserver(0), pRegisterServer(0), editedTeam(0), hwnet(0)
    73   : QMainWindow(parent), pnetserver(0), pRegisterServer(0), editedTeam(0), hwnet(0)
    73 {
    74 {
       
    75 	xfire_init();
    74     gameSettings = new QSettings(cfgdir->absolutePath() + "/hedgewars.ini", QSettings::IniFormat);
    76     gameSettings = new QSettings(cfgdir->absolutePath() + "/hedgewars.ini", QSettings::IniFormat);
    75     frontendEffects = gameSettings->value("video/frontendeffects", true).toBool();
    77     frontendEffects = gameSettings->value("video/frontendeffects", true).toBool();
    76 
    78 
    77 	ui.setupUi(this);
    79 	ui.setupUi(this);
    78 
    80 
   203 
   205 
   204 	PagesStack.push(ID_PAGE_MAIN);
   206 	PagesStack.push(ID_PAGE_MAIN);
   205 	GoBack();
   207 	GoBack();
   206 }
   208 }
   207 
   209 
       
   210 void HWForm::updateXfire(void)
       
   211 {
       
   212 //	xfire_setvalue(XFIRE_ROOM, "None");
       
   213 //	xfire_setvalue(XFIRE_GAMEMODE, "Multiplayer");
       
   214 //	xfire_setvalue(XFIRE_NICKNAME, ui.pageOptions->editNetNick->text().toAscii());
       
   215 //	if(!host.compare("netserver.hedgewars.org"))
       
   216 //		xfire_setvalue(XFIRE_SERVER, "Official server");
       
   217 //	else
       
   218 //		xfire_setvalue(XFIRE_SERVER, "Custom or local LAN server");
       
   219 	if(hwnet)
       
   220 	{
       
   221 		xfire_setvalue(XFIRE_SERVER, !hwnet->getHost().compare("netserver.hedgewars.org:46631") ? "Official server" : hwnet->getHost().toAscii());
       
   222 		switch(hwnet->getClientState())
       
   223 		{
       
   224 			case 1: // Connecting
       
   225 			xfire_setvalue(XFIRE_STATUS, "Connecting");
       
   226 			xfire_setvalue(XFIRE_NICKNAME, "-");
       
   227 			xfire_setvalue(XFIRE_ROOM, "-");
       
   228 			case 2: // In lobby
       
   229 			xfire_setvalue(XFIRE_STATUS, "Online");
       
   230 			xfire_setvalue(XFIRE_NICKNAME, hwnet->getNick().toAscii());
       
   231 			xfire_setvalue(XFIRE_ROOM, "In game lobby");
       
   232 			break;
       
   233 			case 3: // In room
       
   234 			xfire_setvalue(XFIRE_STATUS, "Online");
       
   235 			xfire_setvalue(XFIRE_NICKNAME, hwnet->getNick().toAscii());
       
   236 			xfire_setvalue(XFIRE_ROOM, (hwnet->getRoom() + " (waiting for players)").toAscii());
       
   237 			break;
       
   238 			case 5: // In game
       
   239 			xfire_setvalue(XFIRE_STATUS, "Online");
       
   240 			xfire_setvalue(XFIRE_NICKNAME, hwnet->getNick().toAscii());
       
   241 			xfire_setvalue(XFIRE_ROOM, (hwnet->getRoom() + " (playing or spectating)").toAscii());
       
   242 			break;
       
   243 			default:
       
   244 			break;
       
   245 		}
       
   246 	}
       
   247 	else
       
   248 	{
       
   249 		xfire_setvalue(XFIRE_STATUS, "Offline");
       
   250 		xfire_setvalue(XFIRE_NICKNAME, "-");
       
   251 		xfire_setvalue(XFIRE_ROOM, "-");
       
   252 		xfire_setvalue(XFIRE_SERVER, "-");
       
   253 	}
       
   254 	xfire_update();
       
   255 }
       
   256 
   208 void HWForm::onFrontendFullscreen(bool value)
   257 void HWForm::onFrontendFullscreen(bool value)
   209 {
   258 {
   210   if (value)
   259   if (value)
   211     setWindowState(windowState() | Qt::WindowFullScreen);
   260     setWindowState(windowState() | Qt::WindowFullScreen);
   212   else {
   261   else {
   357 	GoToPage(ID_PAGE_ADMIN);
   406 	GoToPage(ID_PAGE_ADMIN);
   358 }
   407 }
   359 
   408 
   360 void HWForm::OnPageShown(quint8 id, quint8 lastid)
   409 void HWForm::OnPageShown(quint8 id, quint8 lastid)
   361 {
   410 {
       
   411 	updateXfire();
   362 	if (id == ID_PAGE_MULTIPLAYER || id == ID_PAGE_NETGAME) {
   412 	if (id == ID_PAGE_MULTIPLAYER || id == ID_PAGE_NETGAME) {
   363 		QStringList tmNames = config->GetTeamsList();
   413 		QStringList tmNames = config->GetTeamsList();
   364 		TeamSelWidget* curTeamSelWidget;
   414 		TeamSelWidget* curTeamSelWidget;
   365 
   415 
   366 		if(id == ID_PAGE_MULTIPLAYER) {
   416 		if(id == ID_PAGE_MULTIPLAYER) {
   889 	game->StartNet();
   939 	game->StartNet();
   890 }
   940 }
   891 
   941 
   892 void HWForm::closeEvent(QCloseEvent *event)
   942 void HWForm::closeEvent(QCloseEvent *event)
   893 {
   943 {
       
   944 	xfire_free();
   894 	config->SaveOptions();
   945 	config->SaveOptions();
   895 	event->accept();
   946 	event->accept();
   896 }
   947 }
   897 
   948 
   898 void HWForm::Music(bool checked)
   949 void HWForm::Music(bool checked)