QTfrontend/hwform.cpp
changeset 579 94db15de0392
parent 541 bc7be7f6d3e8
child 580 d3ebf84e9fad
equal deleted inserted replaced
578:6b0af3860192 579:94db15de0392
    41 #include "newnetclient.h"
    41 #include "newnetclient.h"
    42 #include "gamecfgwidget.h"
    42 #include "gamecfgwidget.h"
    43 #include "netudpserver.h"
    43 #include "netudpserver.h"
    44 #include "netudpwidget.h"
    44 #include "netudpwidget.h"
    45 #include "chatwidget.h"
    45 #include "chatwidget.h"
       
    46 #include "playrecordpage.h"
    46 
    47 
    47 HWForm::HWForm(QWidget *parent)
    48 HWForm::HWForm(QWidget *parent)
    48   : QMainWindow(parent), pnetserver(0), pUdpServer(0), editedTeam(0)
    49   : QMainWindow(parent), pnetserver(0), pUdpServer(0), editedTeam(0)
    49 {
    50 {
    50 	ui.setupUi(this);
    51 	ui.setupUi(this);
    54 	UpdateTeamsLists();
    55 	UpdateTeamsLists();
    55 
    56 
    56 	connect(ui.pageMain->BtnSinglePlayer,	SIGNAL(clicked()),	this, SLOT(GoToSinglePlayer()));
    57 	connect(ui.pageMain->BtnSinglePlayer,	SIGNAL(clicked()),	this, SLOT(GoToSinglePlayer()));
    57 	connect(ui.pageMain->BtnSetup,	SIGNAL(clicked()),	this, SLOT(GoToSetup()));
    58 	connect(ui.pageMain->BtnSetup,	SIGNAL(clicked()),	this, SLOT(GoToSetup()));
    58 	connect(ui.pageMain->BtnMultiplayer,	SIGNAL(clicked()),	this, SLOT(GoToMultiplayer()));
    59 	connect(ui.pageMain->BtnMultiplayer,	SIGNAL(clicked()),	this, SLOT(GoToMultiplayer()));
       
    60 	connect(ui.pageMain->BtnLoad,	SIGNAL(clicked()),	this, SLOT(GoToSaves()));
    59 	connect(ui.pageMain->BtnDemos,	SIGNAL(clicked()),	this, SLOT(GoToDemos()));
    61 	connect(ui.pageMain->BtnDemos,	SIGNAL(clicked()),	this, SLOT(GoToDemos()));
    60 	connect(ui.pageMain->BtnNet,	SIGNAL(clicked()),	this, SLOT(GoToNet()));
    62 	connect(ui.pageMain->BtnNet,	SIGNAL(clicked()),	this, SLOT(GoToNet()));
    61 	connect(ui.pageMain->BtnInfo,	SIGNAL(clicked()),	this, SLOT(GoToInfo()));
    63 	connect(ui.pageMain->BtnInfo,	SIGNAL(clicked()),	this, SLOT(GoToInfo()));
    62 	connect(ui.pageMain->BtnExit, SIGNAL(pressed()), this, SLOT(btnExitPressed()));
    64 	connect(ui.pageMain->BtnExit, SIGNAL(pressed()), this, SLOT(btnExitPressed()));
    63 	connect(ui.pageMain->BtnExit, SIGNAL(clicked()), this, SLOT(btnExitClicked()));
    65 	connect(ui.pageMain->BtnExit, SIGNAL(clicked()), this, SLOT(btnExitClicked()));
   147 void HWForm::GoToMultiplayer()
   149 void HWForm::GoToMultiplayer()
   148 {
   150 {
   149 	GoToPage(ID_PAGE_MULTIPLAYER);
   151 	GoToPage(ID_PAGE_MULTIPLAYER);
   150 }
   152 }
   151 
   153 
       
   154 void HWForm::GoToSaves()
       
   155 {
       
   156 	QDir tmpdir;
       
   157 	tmpdir.cd(cfgdir->absolutePath());
       
   158 	tmpdir.cd("Saves");
       
   159 	ui.pagePlayDemo->FillFromDir(tmpdir);
       
   160 
       
   161 	GoToPage(ID_PAGE_DEMOS);
       
   162 }
       
   163 
   152 void HWForm::GoToDemos()
   164 void HWForm::GoToDemos()
   153 {
   165 {
   154 	QDir tmpdir;
   166 	QDir tmpdir;
   155 	tmpdir.cd(cfgdir->absolutePath());
   167 	tmpdir.cd(cfgdir->absolutePath());
   156 	tmpdir.cd("Demos");
   168 	tmpdir.cd("Demos");
   157 	tmpdir.setFilter(QDir::Files);
   169 	ui.pagePlayDemo->FillFromDir(tmpdir);
   158 	ui.pagePlayDemo->DemosList->clear();
   170 
   159 	ui.pagePlayDemo->DemosList->addItems(tmpdir.entryList(QStringList("*.hwd_" + cProtoVer))
       
   160 			.replaceInStrings(QRegExp("^(.*).hwd_" + cProtoVer), "\\1"));
       
   161 	GoToPage(ID_PAGE_DEMOS);
   171 	GoToPage(ID_PAGE_DEMOS);
   162 }
   172 }
   163 
   173 
   164 void HWForm::GoToNet()
   174 void HWForm::GoToNet()
   165 {
   175 {
   296 				tr("Please, select demo from the list above"),
   306 				tr("Please, select demo from the list above"),
   297 				tr("OK"));
   307 				tr("OK"));
   298 		return ;
   308 		return ;
   299 	}
   309 	}
   300 	CreateGame(0, 0);
   310 	CreateGame(0, 0);
   301 	game->PlayDemo(cfgdir->absolutePath() + "/Demos/" + curritem->text() + ".hwd_" + cProtoVer);
   311 	game->PlayDemo(cfgdir->absolutePath() + "/Demos/" + curritem->text() + ".hwd_" + *cProtoVer);
   302 }
   312 }
   303 
   313 
   304 void HWForm::NetConnectServer()
   314 void HWForm::NetConnectServer()
   305 {
   315 {
   306   QListWidgetItem * curritem = ui.pageNet->pUdpClient->serversList->currentItem();
   316   QListWidgetItem * curritem = ui.pageNet->pUdpClient->serversList->currentItem();
   498 	QByteArray demo = record;
   508 	QByteArray demo = record;
   499 	if (isDemo)
   509 	if (isDemo)
   500 	{
   510 	{
   501 		demo.replace(QByteArray("\x02TL"), QByteArray("\x02TD"));
   511 		demo.replace(QByteArray("\x02TL"), QByteArray("\x02TD"));
   502 		demo.replace(QByteArray("\x02TN"), QByteArray("\x02TD"));
   512 		demo.replace(QByteArray("\x02TN"), QByteArray("\x02TD"));
   503 		filename = cfgdir->absolutePath() + "/Demos/LastRound.hwd_" + cProtoVer;
   513 		filename = cfgdir->absolutePath() + "/Demos/LastRound.hwd_" + *cProtoVer;
   504 	} else
   514 	} else
   505 	{
   515 	{
   506 		demo.replace(QByteArray("\x02TL"), QByteArray("\x02TS"));
   516 		demo.replace(QByteArray("\x02TL"), QByteArray("\x02TS"));
   507 		demo.replace(QByteArray("\x02TN"), QByteArray("\x02TS"));
   517 		demo.replace(QByteArray("\x02TN"), QByteArray("\x02TS"));
   508 		filename = cfgdir->absolutePath() + "/Saves/LastRound.hws_" + cProtoVer;
   518 		filename = cfgdir->absolutePath() + "/Saves/LastRound.hws_" + *cProtoVer;
   509 	}
   519 	}
   510 
   520 
   511 
   521 
   512 	QFile demofile(filename);
   522 	QFile demofile(filename);
   513 	if (!demofile.open(QIODevice::WriteOnly))
   523 	if (!demofile.open(QIODevice::WriteOnly))