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