QTfrontend/gameuiconfig.cpp
changeset 555 0376fdcc6322
parent 529 812682c1ab62
child 578 6b0af3860192
equal deleted inserted replaced
554:4f83b3de17c7 555:0376fdcc6322
    29 GameUIConfig::GameUIConfig(HWForm * FormWidgets, const QString & fileName)
    29 GameUIConfig::GameUIConfig(HWForm * FormWidgets, const QString & fileName)
    30 	: QSettings(fileName, QSettings::IniFormat)
    30 	: QSettings(fileName, QSettings::IniFormat)
    31 {
    31 {
    32 	Form = FormWidgets;
    32 	Form = FormWidgets;
    33 
    33 
    34 	Form->ui.pageOptions->CBResolution->setCurrentIndex(value("video/resolution").toUInt());
    34 	int t = Form->ui.pageOptions->CBResolution->findText(value("video/resolution").toString());
       
    35 	Form->ui.pageOptions->CBResolution->setCurrentIndex((t < 0) ? 0 : t);
    35 	Form->ui.pageOptions->CBFullscreen->setChecked(value("video/fullscreen", false).toBool());
    36 	Form->ui.pageOptions->CBFullscreen->setChecked(value("video/fullscreen", false).toBool());
    36 
    37 
    37 	Form->ui.pageOptions->CBEnableSound->setChecked(value("audio/sound", true).toBool());
    38 	Form->ui.pageOptions->CBEnableSound->setChecked(value("audio/sound", true).toBool());
    38 
    39 
    39 	Form->ui.pageNet->editNetNick->setText(value("net/nick", QLineEdit::tr("unnamed")).toString());
    40 	Form->ui.pageNet->editNetNick->setText(value("net/nick", QLineEdit::tr("unnamed")).toString());
    56 	return cleanedList;
    57 	return cleanedList;
    57 }
    58 }
    58 
    59 
    59 void GameUIConfig::SaveOptions()
    60 void GameUIConfig::SaveOptions()
    60 {
    61 {
    61 	setValue("video/resolution", vid_Resolution());
    62 	setValue("video/resolution", Form->ui.pageOptions->CBResolution->currentText());
    62 	setValue("video/fullscreen", vid_Fullscreen());
    63 	setValue("video/fullscreen", vid_Fullscreen());
    63 
    64 
    64 	setValue("audio/sound", isSoundEnabled());
    65 	setValue("audio/sound", isSoundEnabled());
    65 
    66 
    66 	setValue("net/nick", Form->ui.pageNet->editNetNick->text());
    67 	setValue("net/nick", Form->ui.pageNet->editNetNick->text());
    70 	setValue("fps/interval", Form->ui.pageOptions->fpsedit->value());
    71 	setValue("fps/interval", Form->ui.pageOptions->fpsedit->value());
    71 
    72 
    72 	setValue("misc/altdamage", isAltDamageEnabled());
    73 	setValue("misc/altdamage", isAltDamageEnabled());
    73 }
    74 }
    74 
    75 
    75 int GameUIConfig::vid_Resolution()
    76 QRect GameUIConfig::vid_Resolution()
    76 {
    77 {
    77 	return Form->ui.pageOptions->CBResolution->currentIndex();
    78 	QRect result(0, 0, 640, 480);
       
    79 	QStringList wh = Form->ui.pageOptions->CBResolution->currentText().split('x');
       
    80 	if (wh.size() == 2)
       
    81 	{
       
    82 		result.setWidth(wh[0].toInt());
       
    83 		result.setHeight(wh[1].toInt());
       
    84 	}
       
    85 	return result;
    78 }
    86 }
    79 
    87 
    80 bool GameUIConfig::vid_Fullscreen()
    88 bool GameUIConfig::vid_Fullscreen()
    81 {
    89 {
    82 	return Form->ui.pageOptions->CBFullscreen->isChecked();
    90 	return Form->ui.pageOptions->CBFullscreen->isChecked();