184
|
1 |
/*
|
|
2 |
* Hedgewars, a worms-like game
|
486
|
3 |
* Copyright (c) 2006, 2007 Andrey Korotaev <unC0Rr@gmail.com>
|
184
|
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>
|
471
|
20 |
#include <QCheckBox>
|
|
21 |
#include <QLineEdit>
|
|
22 |
|
184
|
23 |
#include "gameuiconfig.h"
|
|
24 |
#include "hwform.h"
|
|
25 |
#include "pages.h"
|
|
26 |
#include "hwconsts.h"
|
297
|
27 |
#include "fpsedit.h"
|
184
|
28 |
|
301
|
29 |
GameUIConfig::GameUIConfig(HWForm * FormWidgets, const QString & fileName)
|
|
30 |
: QSettings(fileName, QSettings::IniFormat)
|
184
|
31 |
{
|
|
32 |
Form = FormWidgets;
|
|
33 |
|
301
|
34 |
Form->ui.pageOptions->CBResolution->setCurrentIndex(value("video/resolution").toUInt());
|
|
35 |
Form->ui.pageOptions->CBFullscreen->setChecked(value("video/fullscreen", false).toBool());
|
|
36 |
|
|
37 |
Form->ui.pageOptions->CBEnableSound->setChecked(value("audio/sound", true).toBool());
|
184
|
38 |
|
301
|
39 |
Form->ui.pageNet->editNetNick->setText(value("net/nick", QLineEdit::tr("unnamed")).toString());
|
|
40 |
Form->ui.pageNet->editIP->setText(value("net/ip", "").toString());
|
|
41 |
Form->ui.pageOptions->CBShowFPS->setChecked(value("fps/show", false).toBool());
|
|
42 |
Form->ui.pageOptions->fpsedit->setValue(value("fps/interval", 27).toUInt());
|
184
|
43 |
}
|
|
44 |
|
|
45 |
QStringList GameUIConfig::GetTeamsList()
|
|
46 |
{
|
|
47 |
QStringList teamslist = cfgdir->entryList(QStringList("*.cfg"));
|
|
48 |
QStringList cleanedList;
|
|
49 |
for (QStringList::Iterator it = teamslist.begin(); it != teamslist.end(); ++it ) {
|
|
50 |
QString tmpTeamStr=(*it).replace(QRegExp("^(.*).cfg$"), "\\1");
|
|
51 |
cleanedList.push_back(tmpTeamStr);
|
|
52 |
}
|
|
53 |
return cleanedList;
|
|
54 |
}
|
|
55 |
|
|
56 |
void GameUIConfig::SaveOptions()
|
|
57 |
{
|
301
|
58 |
setValue("video/resolution", vid_Resolution());
|
|
59 |
setValue("video/fullscreen", vid_Fullscreen());
|
|
60 |
|
|
61 |
setValue("audio/sound", isSoundEnabled());
|
|
62 |
|
|
63 |
setValue("net/nick", Form->ui.pageNet->editNetNick->text());
|
|
64 |
setValue("net/ip", Form->ui.pageNet->editIP->text());
|
|
65 |
|
|
66 |
setValue("fps/show", isShowFPSEnabled());
|
|
67 |
setValue("fps/interval", Form->ui.pageOptions->fpsedit->value());
|
184
|
68 |
}
|
|
69 |
|
|
70 |
int GameUIConfig::vid_Resolution()
|
|
71 |
{
|
|
72 |
return Form->ui.pageOptions->CBResolution->currentIndex();
|
|
73 |
}
|
|
74 |
|
|
75 |
bool GameUIConfig::vid_Fullscreen()
|
|
76 |
{
|
|
77 |
return Form->ui.pageOptions->CBFullscreen->isChecked();
|
|
78 |
}
|
|
79 |
|
|
80 |
bool GameUIConfig::isSoundEnabled()
|
|
81 |
{
|
|
82 |
return Form->ui.pageOptions->CBEnableSound->isChecked();
|
|
83 |
}
|
|
84 |
|
297
|
85 |
bool GameUIConfig::isShowFPSEnabled()
|
|
86 |
{
|
|
87 |
return Form->ui.pageOptions->CBShowFPS->isChecked();
|
|
88 |
}
|
|
89 |
|
|
90 |
quint8 GameUIConfig::timerInterval()
|
|
91 |
{
|
|
92 |
return 35 - Form->ui.pageOptions->fpsedit->value();
|
|
93 |
}
|