QTfrontend/hwform.cpp
changeset 28 59f7db859b8a
parent 26 e32fa14529f8
child 31 99888245a4e8
equal deleted inserted replaced
27:c374fe590272 28:59f7db859b8a
   144 			}
   144 			}
   145 		}
   145 		}
   146 		settings.close();
   146 		settings.close();
   147 	}
   147 	}
   148 
   148 
   149 	connect(ui.BtnSPBack, SIGNAL(clicked()), this, SLOT(GoToMain()));
   149 	connect(ui.BtnSPBack,	SIGNAL(clicked()),	this, SLOT(GoToMain()));
   150 	connect(ui.BtnDemosBack, SIGNAL(clicked()), this, SLOT(GoToMain()));
   150 	connect(ui.BtnDemosBack,	SIGNAL(clicked()),	this, SLOT(GoToMain()));
   151 	connect(ui.BtnSetupBack, SIGNAL(clicked()), this, SLOT(GoToMain()));
   151 	connect(ui.BtnSetupBack,	SIGNAL(clicked()),	this, SLOT(GoToMain()));
   152 	connect(ui.BtnMPBack, SIGNAL(clicked()), this, SLOT(GoToMain()));
   152 	connect(ui.BtnMPBack,	SIGNAL(clicked()),	this, SLOT(GoToMain()));
   153 	connect(ui.BtnSinglePlayer, SIGNAL(clicked()), this, SLOT(GoToSinglePlayer()));
   153 	connect(ui.BtnNetBack,	SIGNAL(clicked()),	this, SLOT(GoToMain()));
   154 	connect(ui.BtnSetup, SIGNAL(clicked()), this, SLOT(GoToSetup()));
   154 	connect(ui.BtnSinglePlayer,	SIGNAL(clicked()),	this, SLOT(GoToSinglePlayer()));
   155 	connect(ui.BtnMultiplayer, SIGNAL(clicked()), this, SLOT(GoToMultiplayer()));
   155 	connect(ui.BtnSetup,	SIGNAL(clicked()),	this, SLOT(GoToSetup()));
   156 	connect(ui.BtnDemos, SIGNAL(clicked()), this, SLOT(GoToDemos()));
   156 	connect(ui.BtnMultiplayer,	SIGNAL(clicked()),	this, SLOT(GoToMultiplayer()));
   157 	connect(ui.BtnNewTeam, SIGNAL(clicked()), this, SLOT(NewTeam()));
   157 	connect(ui.BtnDemos,	SIGNAL(clicked()),	this, SLOT(GoToDemos()));
   158 	connect(ui.BtnEditTeam, SIGNAL(clicked()), this, SLOT(EditTeam()));
   158 	connect(ui.BtnNet,	SIGNAL(clicked()),	this, SLOT(GoToNet()));
   159 	connect(ui.BtnTeamSave, SIGNAL(clicked()), this, SLOT(TeamSave()));
   159 	connect(ui.BtnNewTeam,	SIGNAL(clicked()),	this, SLOT(NewTeam()));
   160 	connect(ui.BtnTeamDiscard, SIGNAL(clicked()), this, SLOT(TeamDiscard()));
   160 	connect(ui.BtnEditTeam,	SIGNAL(clicked()),	this, SLOT(EditTeam()));
   161 	connect(ui.BtnSimpleGame, SIGNAL(clicked()), this, SLOT(SimpleGame()));
   161 	connect(ui.BtnTeamSave,	SIGNAL(clicked()),	this, SLOT(TeamSave()));
   162 	connect(ui.BtnSaveOptions, SIGNAL(clicked()), this, SLOT(SaveOptions()));
   162 	connect(ui.BtnTeamDiscard,	SIGNAL(clicked()),	this, SLOT(TeamDiscard()));
   163 	connect(ui.BtnPlayDemo, SIGNAL(clicked()), this, SLOT(PlayDemo()));
   163 	connect(ui.BtnSimpleGame,	SIGNAL(clicked()),	this, SLOT(SimpleGame()));
   164 	connect(ui.CBGrave, SIGNAL(activated(const QString &)), this, SLOT(CBGrave_activated(const QString &)));
   164 	connect(ui.BtnSaveOptions,	SIGNAL(clicked()),	this, SLOT(SaveOptions()));
   165 	connect(ui.CBFort, SIGNAL(activated(const QString &)), this, SLOT(CBFort_activated(const QString &)));
   165 	connect(ui.BtnPlayDemo,	SIGNAL(clicked()),	this, SLOT(PlayDemo()));
       
   166 	connect(ui.BtnNetConnect,	SIGNAL(clicked()),	this, SLOT(NetConnect()));
       
   167 	connect(ui.BtnNetChatDisconnect, SIGNAL(clicked()), this, SLOT(NetDisconnect()));
       
   168 	connect(ui.CBGrave,	SIGNAL(activated(const QString &)),	this, SLOT(CBGrave_activated(const QString &)));
       
   169 	connect(ui.CBFort,	SIGNAL(activated(const QString &)),	this, SLOT(CBFort_activated(const QString &)));
   166 	ui.Pages->setCurrentIndex(ID_PAGE_MAIN);
   170 	ui.Pages->setCurrentIndex(ID_PAGE_MAIN);
   167 }
   171 }
   168 
   172 
   169 void HWForm::GoToMain()
   173 void HWForm::GoToMain()
   170 {
   174 {
   190 {
   194 {
   191 	QDir tmpdir;
   195 	QDir tmpdir;
   192 	tmpdir.cd(DATA_PATH);
   196 	tmpdir.cd(DATA_PATH);
   193 	tmpdir.cd("Demos");
   197 	tmpdir.cd("Demos");
   194 	tmpdir.setFilter(QDir::Files);
   198 	tmpdir.setFilter(QDir::Files);
       
   199 	ui.DemosList->clear();
   195 	ui.DemosList->addItems(tmpdir.entryList(QStringList("*.hwd_1")).replaceInStrings(QRegExp("^(.*).hwd_1"), "\\1"));
   200 	ui.DemosList->addItems(tmpdir.entryList(QStringList("*.hwd_1")).replaceInStrings(QRegExp("^(.*).hwd_1"), "\\1"));
   196 	ui.Pages->setCurrentIndex(ID_PAGE_DEMOS);
   201 	ui.Pages->setCurrentIndex(ID_PAGE_DEMOS);
       
   202 }
       
   203 
       
   204 void HWForm::GoToNet()
       
   205 {
       
   206 	ui.Pages->setCurrentIndex(ID_PAGE_NET);
       
   207 }
       
   208 
       
   209 void HWForm::GoToNetChat()
       
   210 {
       
   211 	ui.Pages->setCurrentIndex(ID_PAGE_NETCHAT);
   197 }
   212 }
   198 
   213 
   199 void HWForm::NewTeam()
   214 void HWForm::NewTeam()
   200 {
   215 {
   201 	tmpTeam = new HWTeam("unnamed");
   216 	tmpTeam = new HWTeam("unnamed");
   278 	}
   293 	}
   279 	game = new HWGame(ui.CBResolution->currentIndex(), ui.CBFullscreen->isChecked());
   294 	game = new HWGame(ui.CBResolution->currentIndex(), ui.CBFullscreen->isChecked());
   280 	game->PlayDemo(QString(DATA_PATH) + "/Demos/" + curritem->text() + ".hwd_1");
   295 	game->PlayDemo(QString(DATA_PATH) + "/Demos/" + curritem->text() + ".hwd_1");
   281 }
   296 }
   282 
   297 
   283 
   298 void HWForm::NetConnect()
       
   299 {
       
   300 	hwnet = new HWNet();
       
   301 	hwnet->Connect("localhost", 6667);
       
   302 	connect(hwnet, SIGNAL(Connected()), this, SLOT(GoToNetChat()));
       
   303 	connect(hwnet, SIGNAL(AddGame(const QString &)), this, SLOT(AddGame(const QString &)));
       
   304 }
       
   305 
       
   306 void HWForm::NetDisconnect()
       
   307 {
       
   308 	hwnet->Disconnect();
       
   309 	GoToNet();
       
   310 }
       
   311 
       
   312 void HWForm::AddGame(const QString & chan)
       
   313 {
       
   314 	ui.ChannelsList->addItem(chan);
       
   315 }