QTfrontend/hwform.cpp
changeset 31 99888245a4e8
parent 28 59f7db859b8a
child 32 78bff13b11c0
equal deleted inserted replaced
30:794e98e11b66 31:99888245a4e8
   132 		{
   132 		{
   133 			str = stream.readLine();
   133 			str = stream.readLine();
   134 			if (str.startsWith(";")) continue;
   134 			if (str.startsWith(";")) continue;
   135 			if (str.startsWith("resolution "))
   135 			if (str.startsWith("resolution "))
   136 			{
   136 			{
   137 				str.remove(0, 11);
   137 				ui.CBResolution->setCurrentIndex(str.mid(11).toLong());
   138 				ui.CBResolution->setCurrentIndex(str.toLong());
       
   139 			} else
   138 			} else
   140 			if (str.startsWith("fullscreen "))
   139 			if (str.startsWith("fullscreen "))
   141 			{
   140 			{
   142 				str.remove(0, 11);
   141 				ui.CBFullscreen->setChecked(str.mid(11).toLong());
   143 				ui.CBFullscreen->setChecked(str.toLong());
   142 			} else
       
   143 			if (str.startsWith("nick "))
       
   144 			{
       
   145 				ui.editNetNick->setText(str.mid(5));
   144 			}
   146 			}
   145 		}
   147 		}
   146 		settings.close();
   148 		settings.close();
   147 	}
   149 	}
   148 
   150 
   154 	connect(ui.BtnSinglePlayer,	SIGNAL(clicked()),	this, SLOT(GoToSinglePlayer()));
   156 	connect(ui.BtnSinglePlayer,	SIGNAL(clicked()),	this, SLOT(GoToSinglePlayer()));
   155 	connect(ui.BtnSetup,	SIGNAL(clicked()),	this, SLOT(GoToSetup()));
   157 	connect(ui.BtnSetup,	SIGNAL(clicked()),	this, SLOT(GoToSetup()));
   156 	connect(ui.BtnMultiplayer,	SIGNAL(clicked()),	this, SLOT(GoToMultiplayer()));
   158 	connect(ui.BtnMultiplayer,	SIGNAL(clicked()),	this, SLOT(GoToMultiplayer()));
   157 	connect(ui.BtnDemos,	SIGNAL(clicked()),	this, SLOT(GoToDemos()));
   159 	connect(ui.BtnDemos,	SIGNAL(clicked()),	this, SLOT(GoToDemos()));
   158 	connect(ui.BtnNet,	SIGNAL(clicked()),	this, SLOT(GoToNet()));
   160 	connect(ui.BtnNet,	SIGNAL(clicked()),	this, SLOT(GoToNet()));
       
   161 	connect(ui.BtnNetCFGBack,	SIGNAL(clicked()),	this, SLOT(GoToNetChat()));
   159 	connect(ui.BtnNewTeam,	SIGNAL(clicked()),	this, SLOT(NewTeam()));
   162 	connect(ui.BtnNewTeam,	SIGNAL(clicked()),	this, SLOT(NewTeam()));
   160 	connect(ui.BtnEditTeam,	SIGNAL(clicked()),	this, SLOT(EditTeam()));
   163 	connect(ui.BtnEditTeam,	SIGNAL(clicked()),	this, SLOT(EditTeam()));
   161 	connect(ui.BtnTeamSave,	SIGNAL(clicked()),	this, SLOT(TeamSave()));
   164 	connect(ui.BtnTeamSave,	SIGNAL(clicked()),	this, SLOT(TeamSave()));
   162 	connect(ui.BtnTeamDiscard,	SIGNAL(clicked()),	this, SLOT(TeamDiscard()));
   165 	connect(ui.BtnTeamDiscard,	SIGNAL(clicked()),	this, SLOT(TeamDiscard()));
   163 	connect(ui.BtnSimpleGame,	SIGNAL(clicked()),	this, SLOT(SimpleGame()));
   166 	connect(ui.BtnSimpleGame,	SIGNAL(clicked()),	this, SLOT(SimpleGame()));
   164 	connect(ui.BtnSaveOptions,	SIGNAL(clicked()),	this, SLOT(SaveOptions()));
   167 	connect(ui.BtnSaveOptions,	SIGNAL(clicked()),	this, SLOT(SaveOptions()));
   165 	connect(ui.BtnPlayDemo,	SIGNAL(clicked()),	this, SLOT(PlayDemo()));
   168 	connect(ui.BtnPlayDemo,	SIGNAL(clicked()),	this, SLOT(PlayDemo()));
   166 	connect(ui.BtnNetConnect,	SIGNAL(clicked()),	this, SLOT(NetConnect()));
   169 	connect(ui.BtnNetConnect,	SIGNAL(clicked()),	this, SLOT(NetConnect()));
   167 	connect(ui.BtnNetChatDisconnect, SIGNAL(clicked()), this, SLOT(NetDisconnect()));
   170 	connect(ui.BtnNetChatDisconnect, SIGNAL(clicked()), this, SLOT(NetDisconnect()));
       
   171 	connect(ui.BtnNetChatJoin,	SIGNAL(clicked()),	this, SLOT(NetJoin()));
       
   172 	connect(ui.BtnNetChatCreate,	SIGNAL(clicked()),	this, SLOT(NetCreate()));
       
   173 	connect(ui.BtnNetCFGAddTeam,	SIGNAL(clicked()),	this, SLOT(NetAddTeam()));
       
   174 	connect(ui.BtnNetCFGGo,	SIGNAL(clicked()),	this, SLOT(NetStartGame()));
   168 	connect(ui.CBGrave,	SIGNAL(activated(const QString &)),	this, SLOT(CBGrave_activated(const QString &)));
   175 	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 &)));
   176 	connect(ui.CBFort,	SIGNAL(activated(const QString &)),	this, SLOT(CBFort_activated(const QString &)));
   170 	ui.Pages->setCurrentIndex(ID_PAGE_MAIN);
   177 	ui.Pages->setCurrentIndex(ID_PAGE_MAIN);
   171 }
   178 }
   172 
   179 
   242 }
   249 }
   243 
   250 
   244 void HWForm::SimpleGame()
   251 void HWForm::SimpleGame()
   245 {
   252 {
   246 	game = new HWGame(ui.CBResolution->currentIndex(), ui.CBFullscreen->isChecked());
   253 	game = new HWGame(ui.CBResolution->currentIndex(), ui.CBFullscreen->isChecked());
   247 	game->AddTeam(cfgdir.absolutePath() + "/team.cfg");
   254 	game->AddTeam("team.cfg");
   248 	game->AddTeam(cfgdir.absolutePath() + "/team.cfg");
   255 	game->AddTeam("team.cfg");
   249 	game->Start();
   256 	game->StartLocal();
   250 }
   257 }
   251 
   258 
   252 void HWForm::CBGrave_activated(const QString & gravename)
   259 void HWForm::CBGrave_activated(const QString & gravename)
   253 {
   260 {
   254 	QPixmap pix(QString(DATA_PATH) + "/Graphics/Graves/" + gravename + ".png");
   261 	QPixmap pix(QString(DATA_PATH) + "/Graphics/Graves/" + gravename + ".png");
   275 	QTextStream stream(&settings);
   282 	QTextStream stream(&settings);
   276 	stream.setCodec("UTF-8");
   283 	stream.setCodec("UTF-8");
   277 	stream << "; Generated by Hedgewars, do not modify" << endl;
   284 	stream << "; Generated by Hedgewars, do not modify" << endl;
   278 	stream << "resolution " << ui.CBResolution->currentIndex() << endl;
   285 	stream << "resolution " << ui.CBResolution->currentIndex() << endl;
   279 	stream << "fullscreen " << ui.CBFullscreen->isChecked() << endl;
   286 	stream << "fullscreen " << ui.CBFullscreen->isChecked() << endl;
       
   287 	stream << "nick " << ui.editNetNick->text() << endl;
   280 	settings.close();
   288 	settings.close();
   281 }
   289 }
   282 
   290 
   283 void HWForm::PlayDemo()
   291 void HWForm::PlayDemo()
   284 {
   292 {
   295 	game->PlayDemo(QString(DATA_PATH) + "/Demos/" + curritem->text() + ".hwd_1");
   303 	game->PlayDemo(QString(DATA_PATH) + "/Demos/" + curritem->text() + ".hwd_1");
   296 }
   304 }
   297 
   305 
   298 void HWForm::NetConnect()
   306 void HWForm::NetConnect()
   299 {
   307 {
   300 	hwnet = new HWNet();
   308 	hwnet = new HWNet(ui.CBResolution->currentIndex(), ui.CBFullscreen->isChecked());
   301 	hwnet->Connect("localhost", 6667);
   309 	hwnet->Connect("172.19.5.168", 6667, ui.editNetNick->text());
   302 	connect(hwnet, SIGNAL(Connected()), this, SLOT(GoToNetChat()));
   310 	connect(hwnet, SIGNAL(Connected()), this, SLOT(GoToNetChat()));
   303 	connect(hwnet, SIGNAL(AddGame(const QString &)), this, SLOT(AddGame(const QString &)));
   311 	connect(hwnet, SIGNAL(AddGame(const QString &)), this, SLOT(AddGame(const QString &)));
       
   312 	connect(hwnet, SIGNAL(EnteredGame()), this, SLOT(NetGameEnter()));
   304 }
   313 }
   305 
   314 
   306 void HWForm::NetDisconnect()
   315 void HWForm::NetDisconnect()
   307 {
   316 {
   308 	hwnet->Disconnect();
   317 	hwnet->Disconnect();
   311 
   320 
   312 void HWForm::AddGame(const QString & chan)
   321 void HWForm::AddGame(const QString & chan)
   313 {
   322 {
   314 	ui.ChannelsList->addItem(chan);
   323 	ui.ChannelsList->addItem(chan);
   315 }
   324 }
       
   325 
       
   326 void HWForm::NetGameEnter()
       
   327 {
       
   328 	ui.Pages->setCurrentIndex(ID_PAGE_NETCFG);
       
   329 }
       
   330 
       
   331 void HWForm::NetJoin()
       
   332 {
       
   333 	hwnet->JoinGame("#hw");
       
   334 }
       
   335 
       
   336 void HWForm::NetCreate()
       
   337 {
       
   338 	hwnet->JoinGame("#hw");
       
   339 }
       
   340 
       
   341 void HWForm::NetAddTeam()
       
   342 {
       
   343 	HWTeam team("team");
       
   344 	team.SetCfgDir(cfgdir.absolutePath());
       
   345 	team.LoadFromFile();
       
   346 	hwnet->AddTeam(team);
       
   347 }
       
   348 
       
   349 void HWForm::NetStartGame()
       
   350 {
       
   351 	hwnet->StartGame();
       
   352 }