QTfrontend/hwform.cpp
changeset 26 e32fa14529f8
parent 25 27aa8030322b
child 28 59f7db859b8a
equal deleted inserted replaced
25:27aa8030322b 26:e32fa14529f8
    64 	for(int i = 0; strlen(sdlkeys[i][1]) > 0; i++)
    64 	for(int i = 0; strlen(sdlkeys[i][1]) > 0; i++)
    65 	{
    65 	{
    66 		binds << sdlkeys[i][1];
    66 		binds << sdlkeys[i][1];
    67 	}
    67 	}
    68 
    68 
    69 	for(int i = 0; i < BINDS_NUMBER; i++)
    69 	quint16 widind = 0, top = 0;
    70 	{
    70 	for(quint8 i = 0; i < BINDS_NUMBER; i++)
    71 		LBind[i] = new QLabel(ui.GBoxBinds);
    71 	{
    72 		LBind[i]->setGeometry(QRect(10, 23 + i * 30, 60, 20));
    72 		LBind[i] = new QLabel(ui.BindsBox->widget(widind));
       
    73 		LBind[i]->setGeometry(QRect(10, top + 3, 60, 20));
    73 		LBind[i]->setText(cbinds[i].name);
    74 		LBind[i]->setText(cbinds[i].name);
    74 		LBind[i]->setAlignment(Qt::AlignRight);
    75 		LBind[i]->setAlignment(Qt::AlignRight);
    75 		CBBind[i] = new QComboBox(ui.GBoxBinds);
    76 		CBBind[i] = new QComboBox(ui.BindsBox->widget(widind));
    76 		CBBind[i]->setGeometry(QRect(80, 20 + i * 30, 80, 20));
    77 		CBBind[i]->setGeometry(QRect(80, top, 80, 20));
    77 		CBBind[i]->addItems(binds);
    78 		CBBind[i]->addItems(binds);
       
    79 		if (cbinds[i].chwidget)
       
    80 		{
       
    81 			top = 0;
       
    82 			widind++;
       
    83 		} else
       
    84 		{
       
    85 			top += 30;
       
    86 		}
    78 	}
    87 	}
    79 
    88 
    80 	QDir tmpdir;
    89 	QDir tmpdir;
    81 	tmpdir.cd(DATA_PATH);
    90 	tmpdir.cd(DATA_PATH);
    82 	tmpdir.cd("Forts");
    91 	tmpdir.cd("Forts");
   134 				ui.CBFullscreen->setChecked(str.toLong());
   143 				ui.CBFullscreen->setChecked(str.toLong());
   135 			}
   144 			}
   136 		}
   145 		}
   137 		settings.close();
   146 		settings.close();
   138 	}
   147 	}
       
   148 
   139 	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()));
   140 	connect(ui.BtnSetupBack, SIGNAL(clicked()), this, SLOT(GoToMain()));
   151 	connect(ui.BtnSetupBack, SIGNAL(clicked()), this, SLOT(GoToMain()));
   141 	connect(ui.BtnMPBack, SIGNAL(clicked()), this, SLOT(GoToMain()));
   152 	connect(ui.BtnMPBack, SIGNAL(clicked()), this, SLOT(GoToMain()));
   142 	connect(ui.BtnSinglePlayer, SIGNAL(clicked()), this, SLOT(GoToSinglePlayer()));
   153 	connect(ui.BtnSinglePlayer, SIGNAL(clicked()), this, SLOT(GoToSinglePlayer()));
   143 	connect(ui.BtnSetup, SIGNAL(clicked()), this, SLOT(GoToSetup()));
   154 	connect(ui.BtnSetup, SIGNAL(clicked()), this, SLOT(GoToSetup()));
   144 	connect(ui.BtnMultiplayer, SIGNAL(clicked()), this, SLOT(GoToMultiplayer()));
   155 	connect(ui.BtnMultiplayer, SIGNAL(clicked()), this, SLOT(GoToMultiplayer()));
       
   156 	connect(ui.BtnDemos, SIGNAL(clicked()), this, SLOT(GoToDemos()));
   145 	connect(ui.BtnNewTeam, SIGNAL(clicked()), this, SLOT(NewTeam()));
   157 	connect(ui.BtnNewTeam, SIGNAL(clicked()), this, SLOT(NewTeam()));
   146 	connect(ui.BtnEditTeam, SIGNAL(clicked()), this, SLOT(EditTeam()));
   158 	connect(ui.BtnEditTeam, SIGNAL(clicked()), this, SLOT(EditTeam()));
   147 	connect(ui.BtnTeamSave, SIGNAL(clicked()), this, SLOT(TeamSave()));
   159 	connect(ui.BtnTeamSave, SIGNAL(clicked()), this, SLOT(TeamSave()));
   148 	connect(ui.BtnTeamDiscard, SIGNAL(clicked()), this, SLOT(TeamDiscard()));
   160 	connect(ui.BtnTeamDiscard, SIGNAL(clicked()), this, SLOT(TeamDiscard()));
   149 	connect(ui.BtnSimpleGame, SIGNAL(clicked()), this, SLOT(SimpleGame()));
   161 	connect(ui.BtnSimpleGame, SIGNAL(clicked()), this, SLOT(SimpleGame()));
   150 	connect(ui.BtnSaveOptions, SIGNAL(clicked()), this, SLOT(SaveOptions()));
   162 	connect(ui.BtnSaveOptions, SIGNAL(clicked()), this, SLOT(SaveOptions()));
       
   163 	connect(ui.BtnPlayDemo, SIGNAL(clicked()), this, SLOT(PlayDemo()));
   151 	connect(ui.CBGrave, SIGNAL(activated(const QString &)), this, SLOT(CBGrave_activated(const QString &)));
   164 	connect(ui.CBGrave, SIGNAL(activated(const QString &)), this, SLOT(CBGrave_activated(const QString &)));
   152 	connect(ui.CBFort, SIGNAL(activated(const QString &)), this, SLOT(CBFort_activated(const QString &)));
   165 	connect(ui.CBFort, SIGNAL(activated(const QString &)), this, SLOT(CBFort_activated(const QString &)));
   153 	ui.Pages->setCurrentIndex(ID_PAGE_MAIN);
   166 	ui.Pages->setCurrentIndex(ID_PAGE_MAIN);
   154 }
   167 }
   155 
   168 
   170 
   183 
   171 void HWForm::GoToMultiplayer()
   184 void HWForm::GoToMultiplayer()
   172 {
   185 {
   173 	ui.Pages->setCurrentIndex(ID_PAGE_MULTIPLAYER);
   186 	ui.Pages->setCurrentIndex(ID_PAGE_MULTIPLAYER);
   174 }
   187 }
       
   188 
       
   189 void HWForm::GoToDemos()
       
   190 {
       
   191 	QDir tmpdir;
       
   192 	tmpdir.cd(DATA_PATH);
       
   193 	tmpdir.cd("Demos");
       
   194 	tmpdir.setFilter(QDir::Files);
       
   195 	ui.DemosList->addItems(tmpdir.entryList(QStringList("*.hwd_1")).replaceInStrings(QRegExp("^(.*).hwd_1"), "\\1"));
       
   196 	ui.Pages->setCurrentIndex(ID_PAGE_DEMOS);
       
   197 }
       
   198 
   175 void HWForm::NewTeam()
   199 void HWForm::NewTeam()
   176 {
   200 {
   177 	tmpTeam = new HWTeam("unnamed");
   201 	tmpTeam = new HWTeam("unnamed");
   178 	tmpTeam->SetCfgDir(cfgdir.absolutePath());
   202 	tmpTeam->SetCfgDir(cfgdir.absolutePath());
   179 	tmpTeam->SetToPage(this);
   203 	tmpTeam->SetToPage(this);
   202 	ui.Pages->setCurrentIndex(ID_PAGE_SETUP);
   226 	ui.Pages->setCurrentIndex(ID_PAGE_SETUP);
   203 }
   227 }
   204 
   228 
   205 void HWForm::SimpleGame()
   229 void HWForm::SimpleGame()
   206 {
   230 {
   207 	game = new HWGame();
   231 	game = new HWGame(ui.CBResolution->currentIndex(), ui.CBFullscreen->isChecked());
   208 	game->AddTeam(cfgdir.absolutePath() + "/team.cfg");
   232 	game->AddTeam(cfgdir.absolutePath() + "/team.cfg");
   209 	game->AddTeam(cfgdir.absolutePath() + "/team.cfg");
   233 	game->AddTeam(cfgdir.absolutePath() + "/team.cfg");
   210 	game->Start(ui.CBResolution->currentIndex(), ui.CBFullscreen->isChecked());
   234 	game->Start();
   211 }
   235 }
   212 
   236 
   213 void HWForm::CBGrave_activated(const QString & gravename)
   237 void HWForm::CBGrave_activated(const QString & gravename)
   214 {
   238 {
   215 	QPixmap pix(QString(DATA_PATH) + "/Graphics/Graves/" + gravename + ".png");
   239 	QPixmap pix(QString(DATA_PATH) + "/Graphics/Graves/" + gravename + ".png");
   238 	stream << "; Generated by Hedgewars, do not modify" << endl;
   262 	stream << "; Generated by Hedgewars, do not modify" << endl;
   239 	stream << "resolution " << ui.CBResolution->currentIndex() << endl;
   263 	stream << "resolution " << ui.CBResolution->currentIndex() << endl;
   240 	stream << "fullscreen " << ui.CBFullscreen->isChecked() << endl;
   264 	stream << "fullscreen " << ui.CBFullscreen->isChecked() << endl;
   241 	settings.close();
   265 	settings.close();
   242 }
   266 }
       
   267 
       
   268 void HWForm::PlayDemo()
       
   269 {
       
   270 	QListWidgetItem * curritem = ui.DemosList->currentItem();
       
   271 	if (!curritem)
       
   272 	{
       
   273 		QMessageBox::critical(this,
       
   274 				tr("Error"),
       
   275 				tr("Please, select demo from the list above"),
       
   276 				tr("OK"));
       
   277 		return ;
       
   278 	}
       
   279 	game = new HWGame(ui.CBResolution->currentIndex(), ui.CBFullscreen->isChecked());
       
   280 	game->PlayDemo(QString(DATA_PATH) + "/Demos/" + curritem->text() + ".hwd_1");
       
   281 }
       
   282 
       
   283