QTfrontend/hwform.cpp
changeset 85 44d9045b26ff
parent 84 0f6669da2fcb
child 86 664b536a1c27
equal deleted inserted replaced
84:0f6669da2fcb 85:44d9045b26ff
     1 /*
     1 /*
     2  * Hedgewars, a worms-like game
     2  * Hedgewars, a worms-like game
     3  * Copyright (c) 2005 Andrey Korotaev <unC0Rr@gmail.com>
     3  * Copyright (c) 2005, 2006 Andrey Korotaev <unC0Rr@gmail.com>
     4  *
     4  *
     5  * Distributed under the terms of the BSD-modified licence:
     5  * Distributed under the terms of the BSD-modified licence:
     6  *
     6  *
     7  * Permission is hereby granted, free of charge, to any person obtaining a copy
     7  * Permission is hereby granted, free of charge, to any person obtaining a copy
     8  * of this software and associated documentation files (the "Software"), to deal
     8  * of this software and associated documentation files (the "Software"), to deal
    42 #include <QTextStream>
    42 #include <QTextStream>
    43 
    43 
    44 #include "hwform.h"
    44 #include "hwform.h"
    45 #include "sdlkeys.h"
    45 #include "sdlkeys.h"
    46 #include "hwconsts.h"
    46 #include "hwconsts.h"
    47 #include "gameconfig.h"
    47 #include "gameuiconfig.h"
    48 
    48 
    49 HWForm::HWForm(QWidget *parent)
    49 HWForm::HWForm(QWidget *parent)
    50 	: QMainWindow(parent)
    50 	: QMainWindow(parent)
    51 {
    51 {
    52 	ui.setupUi(this);
    52 	ui.setupUi(this);
    98 	for (QStringList::Iterator it = list.begin(); it != list.end(); ++it )
    98 	for (QStringList::Iterator it = list.begin(); it != list.end(); ++it )
    99 	{
    99 	{
   100 		ui.CBGrave->addItem((*it).replace(QRegExp("^(.*).png"), "\\1"));
   100 		ui.CBGrave->addItem((*it).replace(QRegExp("^(.*).png"), "\\1"));
   101 	}
   101 	}
   102 
   102 
   103 	config = new GameConfig(this);
   103 	config = new GameUIConfig(this);
   104 
   104 
   105 	QStringList teamslist = config->GetTeamsList();
   105 	QStringList teamslist = config->GetTeamsList();
   106 
   106 
   107 	if(teamslist.empty()) {
   107 	if(teamslist.empty()) {
   108 	  HWTeam defaultTeam("DefaultTeam");
   108 	  HWTeam defaultTeam("DefaultTeam");
   109 	  defaultTeam.SetCfgDir(config->cfgdir.absolutePath());
   109 	  defaultTeam.SetCfgDir(config->cfgdir.absolutePath());
   110 	  defaultTeam.SaveToFile();
   110 	  defaultTeam.SaveToFile();
   111 	  teamslist.push_back("DefaultTeam");
   111 	  teamslist.push_back("DefaultTeam");
   112 	}
   112 	}
   113 
   113 
   114 	pts=new TeamSelWidget(ui.Pages->widget(ID_PAGE_SINGLEPLAYER));
       
   115 
       
   116 	for (QStringList::Iterator it = teamslist.begin(); it != teamslist.end(); ++it )
   114 	for (QStringList::Iterator it = teamslist.begin(); it != teamslist.end(); ++it )
   117 	{
   115 	{
   118 	  QString tmpTeamStr=(*it).replace(QRegExp("^(.*).cfg$"), "\\1");
   116 	  QString tmpTeamStr=(*it).replace(QRegExp("^(.*).cfg$"), "\\1");
   119 	  pts->addTeam(tmpTeamStr);
   117 	  ui.PageLGTeamsSelect->addTeam(tmpTeamStr);
   120 	  ui.CBTeamName->addItem(tmpTeamStr);
   118 	  ui.CBTeamName->addItem(tmpTeamStr);
   121 	}
   119 	}
   122 
   120 
   123 	connect(ui.BtnSPBack,	SIGNAL(clicked()),	this, SLOT(GoToMain()));
   121 	connect(ui.BtnSPBack,	SIGNAL(clicked()),	this, SLOT(GoToMain()));
   124 	connect(ui.BtnDemosBack,	SIGNAL(clicked()),	this, SLOT(GoToMain()));
   122 	connect(ui.BtnDemosBack,	SIGNAL(clicked()),	this, SLOT(GoToMain()));
   155 }
   153 }
   156 
   154 
   157 void HWForm::GoToSinglePlayer()
   155 void HWForm::GoToSinglePlayer()
   158 {
   156 {
   159 	ui.Pages->setCurrentIndex(ID_PAGE_SINGLEPLAYER);
   157 	ui.Pages->setCurrentIndex(ID_PAGE_SINGLEPLAYER);
   160 
       
   161 	pts->resize(500, 350);
       
   162 	pts->show();
       
   163 }
   158 }
   164 
   159 
   165 void HWForm::GoToSetup()
   160 void HWForm::GoToSetup()
   166 {
   161 {
   167 	ui.Pages->setCurrentIndex(ID_PAGE_SETUP);
   162 	ui.Pages->setCurrentIndex(ID_PAGE_SETUP);
   223 	ui.Pages->setCurrentIndex(ID_PAGE_SETUP);
   218 	ui.Pages->setCurrentIndex(ID_PAGE_SETUP);
   224 }
   219 }
   225 
   220 
   226 void HWForm::SimpleGame()
   221 void HWForm::SimpleGame()
   227 {
   222 {
   228 	game = new HWGame(config);
   223 	game = new HWGame(config, ui.pageLGGameCFG);
   229 	game->AddTeam("DefaultTeam");
   224 	game->AddTeam("DefaultTeam");
   230 	game->AddTeam("DefaultTeam");
   225 	game->AddTeam("DefaultTeam");
   231 	game->StartLocal();
   226 	game->StartLocal();
   232 }
   227 }
   233 
   228 
   252 				tr("Error"),
   247 				tr("Error"),
   253 				tr("Please, select demo from the list above"),
   248 				tr("Please, select demo from the list above"),
   254 				tr("OK"));
   249 				tr("OK"));
   255 		return ;
   250 		return ;
   256 	}
   251 	}
   257 	game = new HWGame(config);
   252 	game = new HWGame(config, 0);
   258 	game->PlayDemo(QString(DATA_PATH) + "/Demos/" + curritem->text() + ".hwd_1");
   253 	game->PlayDemo(QString(DATA_PATH) + "/Demos/" + curritem->text() + ".hwd_1");
   259 }
   254 }
   260 
   255 
   261 void HWForm::NetConnect()
   256 void HWForm::NetConnect()
   262 {
   257 {