184
|
1 |
/*
|
|
2 |
* Hedgewars, a worms-like game
|
|
3 |
* Copyright (c) 2006 Andrey Korotaev <unC0Rr@gmail.com>
|
|
4 |
*
|
|
5 |
* This program is free software; you can redistribute it and/or modify
|
|
6 |
* it under the terms of the GNU General Public License as published by
|
|
7 |
* the Free Software Foundation; version 2 of the License
|
|
8 |
*
|
|
9 |
* This program is distributed in the hope that it will be useful,
|
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
* GNU General Public License for more details.
|
|
13 |
*
|
|
14 |
* You should have received a copy of the GNU General Public License
|
|
15 |
* along with this program; if not, write to the Free Software
|
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
17 |
*/
|
|
18 |
|
|
19 |
#include <QMessageBox>
|
|
20 |
#include "gameuiconfig.h"
|
|
21 |
#include "hwform.h"
|
|
22 |
#include "pages.h"
|
|
23 |
#include "hwconsts.h"
|
297
|
24 |
#include "fpsedit.h"
|
184
|
25 |
|
301
|
26 |
GameUIConfig::GameUIConfig(HWForm * FormWidgets, const QString & fileName)
|
|
27 |
: QSettings(fileName, QSettings::IniFormat)
|
184
|
28 |
{
|
|
29 |
Form = FormWidgets;
|
|
30 |
|
301
|
31 |
Form->ui.pageOptions->CBResolution->setCurrentIndex(value("video/resolution").toUInt());
|
|
32 |
Form->ui.pageOptions->CBFullscreen->setChecked(value("video/fullscreen", false).toBool());
|
|
33 |
|
|
34 |
Form->ui.pageOptions->CBEnableSound->setChecked(value("audio/sound", true).toBool());
|
184
|
35 |
|
301
|
36 |
Form->ui.pageNet->editNetNick->setText(value("net/nick", QLineEdit::tr("unnamed")).toString());
|
|
37 |
Form->ui.pageNet->editIP->setText(value("net/ip", "").toString());
|
|
38 |
Form->ui.pageOptions->CBShowFPS->setChecked(value("fps/show", false).toBool());
|
|
39 |
Form->ui.pageOptions->fpsedit->setValue(value("fps/interval", 27).toUInt());
|
184
|
40 |
}
|
|
41 |
|
|
42 |
QStringList GameUIConfig::GetTeamsList()
|
|
43 |
{
|
|
44 |
QStringList teamslist = cfgdir->entryList(QStringList("*.cfg"));
|
|
45 |
QStringList cleanedList;
|
|
46 |
for (QStringList::Iterator it = teamslist.begin(); it != teamslist.end(); ++it ) {
|
|
47 |
QString tmpTeamStr=(*it).replace(QRegExp("^(.*).cfg$"), "\\1");
|
|
48 |
cleanedList.push_back(tmpTeamStr);
|
|
49 |
}
|
|
50 |
return cleanedList;
|
|
51 |
}
|
|
52 |
|
|
53 |
void GameUIConfig::SaveOptions()
|
|
54 |
{
|
301
|
55 |
setValue("video/resolution", vid_Resolution());
|
|
56 |
setValue("video/fullscreen", vid_Fullscreen());
|
|
57 |
|
|
58 |
setValue("audio/sound", isSoundEnabled());
|
|
59 |
|
|
60 |
setValue("net/nick", Form->ui.pageNet->editNetNick->text());
|
|
61 |
setValue("net/ip", Form->ui.pageNet->editIP->text());
|
|
62 |
|
|
63 |
setValue("fps/show", isShowFPSEnabled());
|
|
64 |
setValue("fps/interval", Form->ui.pageOptions->fpsedit->value());
|
184
|
65 |
}
|
|
66 |
|
|
67 |
int GameUIConfig::vid_Resolution()
|
|
68 |
{
|
|
69 |
return Form->ui.pageOptions->CBResolution->currentIndex();
|
|
70 |
}
|
|
71 |
|
|
72 |
bool GameUIConfig::vid_Fullscreen()
|
|
73 |
{
|
|
74 |
return Form->ui.pageOptions->CBFullscreen->isChecked();
|
|
75 |
}
|
|
76 |
|
|
77 |
bool GameUIConfig::isSoundEnabled()
|
|
78 |
{
|
|
79 |
return Form->ui.pageOptions->CBEnableSound->isChecked();
|
|
80 |
}
|
|
81 |
|
297
|
82 |
bool GameUIConfig::isShowFPSEnabled()
|
|
83 |
{
|
|
84 |
return Form->ui.pageOptions->CBShowFPS->isChecked();
|
|
85 |
}
|
|
86 |
|
|
87 |
quint8 GameUIConfig::timerInterval()
|
|
88 |
{
|
|
89 |
return 35 - Form->ui.pageOptions->fpsedit->value();
|
|
90 |
}
|