# HG changeset patch # User unc0rr # Date 1165777025 0 # Node ID 279e10ec31b4494f2fbd44dbc24f11688082812b # Parent 607912ccc5af44f919bb885bf8c849cebaef9635 'Show FPS' and 'FPS limit' options diff -r 607912ccc5af -r 279e10ec31b4 QTfrontend/CMakeLists.txt --- a/QTfrontend/CMakeLists.txt Sun Dec 10 18:13:10 2006 +0000 +++ b/QTfrontend/CMakeLists.txt Sun Dec 10 18:57:05 2006 +0000 @@ -41,7 +41,8 @@ mapContainer.cpp tcpBase.cpp about.cpp - proto.cpp) + proto.cpp + fpsedit.cpp) if (WIN32) set(hwfr_src ${hwfr_src} res/hedgewars.rc) @@ -68,7 +69,8 @@ tcpBase.h about.h KB.h - proto.h) + proto.h + fpsedit.h) set(hwfr_rez diff -r 607912ccc5af -r 279e10ec31b4 QTfrontend/fpsedit.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/fpsedit.cpp Sun Dec 10 18:57:05 2006 +0000 @@ -0,0 +1,31 @@ +/* + * Hedgewars, a worms-like game + * Copyright (c) 2006 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include "fpsedit.h" + +FPSEdit::FPSEdit(QWidget * parent) : + QSpinBox(parent) +{ + setRange(1, 34); + setValue(27); +} + +QString FPSEdit::textFromValue(int value) const +{ + return QString::number(1000 / (35 - value)); +} diff -r 607912ccc5af -r 279e10ec31b4 QTfrontend/fpsedit.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/fpsedit.h Sun Dec 10 18:57:05 2006 +0000 @@ -0,0 +1,35 @@ +/* + * Hedgewars, a worms-like game + * Copyright (c) 2006 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#ifndef _FPSEDIT_H +#define _FPSEDIT_H + +#include + +class FPSEdit : public QSpinBox +{ + Q_OBJECT + +public: + FPSEdit(QWidget * parent = 0); + +protected: + QString textFromValue (int value) const; +}; + +#endif // _FPSEDIT_H diff -r 607912ccc5af -r 279e10ec31b4 QTfrontend/game.cpp --- a/QTfrontend/game.cpp Sun Dec 10 18:13:10 2006 +0000 +++ b/QTfrontend/game.cpp Sun Dec 10 18:57:05 2006 +0000 @@ -194,9 +194,9 @@ arguments << (config->isSoundEnabled() ? "1" : "0"); arguments << tr("en.txt"); arguments << "128"; // sound volume - arguments << "1024"; // max fps + arguments << QString::number(config->timerInterval()); arguments << datadir->absolutePath(); - arguments << "1"; // show fps + arguments << (config->isShowFPSEnabled() ? "1" : "0"); return arguments; } diff -r 607912ccc5af -r 279e10ec31b4 QTfrontend/gameuiconfig.cpp --- a/QTfrontend/gameuiconfig.cpp Sun Dec 10 18:13:10 2006 +0000 +++ b/QTfrontend/gameuiconfig.cpp Sun Dec 10 18:57:05 2006 +0000 @@ -22,6 +22,7 @@ #include "hwform.h" #include "pages.h" #include "hwconsts.h" +#include "fpsedit.h" GameUIConfig::GameUIConfig(HWForm * FormWidgets) : QObject() @@ -58,6 +59,14 @@ if (str.startsWith("ip ")) { Form->ui.pageNet->editIP->setText(str.mid(3)); + } else + if (str.startsWith("showfps ")) + { + Form->ui.pageOptions->CBShowFPS->setChecked(str.mid(8).toLong()); + } else + if (str.startsWith("interval ")) + { + Form->ui.pageOptions->fpsedit->setValue(str.mid(9).toUInt()); } } settings.close(); @@ -102,11 +111,13 @@ QTextStream stream(&settings); stream.setCodec("UTF-8"); stream << "; Generated by Hedgewars, do not modify" << endl; - stream << "resolution " << Form->ui.pageOptions->CBResolution->currentIndex() << endl; - stream << "fullscreen " << Form->ui.pageOptions->CBFullscreen->isChecked() << endl; - stream << "sound " << Form->ui.pageOptions->CBEnableSound->isChecked() << endl; + stream << "resolution " << vid_Resolution() << endl; + stream << "fullscreen " << vid_Fullscreen() << endl; + stream << "sound " << isSoundEnabled() << endl; stream << "nick " << Form->ui.pageNet->editNetNick->text() << endl; stream << "ip " << Form->ui.pageNet->editIP->text() << endl; + stream << "showfps " << isShowFPSEnabled() << endl; + stream << "interval " << Form->ui.pageOptions->fpsedit->value() << endl; settings.close(); } @@ -125,6 +136,16 @@ return Form->ui.pageOptions->CBEnableSound->isChecked(); } +bool GameUIConfig::isShowFPSEnabled() +{ + return Form->ui.pageOptions->CBShowFPS->isChecked(); +} + +quint8 GameUIConfig::timerInterval() +{ + return 35 - Form->ui.pageOptions->fpsedit->value(); +} + QString GameUIConfig::GetRandomTheme() { return (Themes.size() > 0) ? Themes[rand() % Themes.size()] : QString("steel"); diff -r 607912ccc5af -r 279e10ec31b4 QTfrontend/gameuiconfig.h --- a/QTfrontend/gameuiconfig.h Sun Dec 10 18:13:10 2006 +0000 +++ b/QTfrontend/gameuiconfig.h Sun Dec 10 18:57:05 2006 +0000 @@ -35,6 +35,8 @@ int vid_Resolution(); bool vid_Fullscreen(); bool isSoundEnabled(); + bool isShowFPSEnabled(); + quint8 timerInterval(); QString GetRandomTheme(); private slots: diff -r 607912ccc5af -r 279e10ec31b4 QTfrontend/hedgewars.pro --- a/QTfrontend/hedgewars.pro Sun Dec 10 18:13:10 2006 +0000 +++ b/QTfrontend/hedgewars.pro Sun Dec 10 18:57:05 2006 +0000 @@ -32,7 +32,9 @@ tcpBase.h \ about.h \ KB.h \ - proto.h + proto.h \ + fpsedit.h + SOURCES += game.cpp \ main.cpp \ @@ -53,7 +55,8 @@ mapContainer.cpp \ tcpBase.cpp \ about.cpp \ - proto.cpp + proto.cpp \ + fpsedit.cpp TRANSLATIONS += translations/hedgewars_ru.ts diff -r 607912ccc5af -r 279e10ec31b4 QTfrontend/pages.cpp --- a/QTfrontend/pages.cpp Sun Dec 10 18:13:10 2006 +0000 +++ b/QTfrontend/pages.cpp Sun Dec 10 18:57:05 2006 +0000 @@ -37,6 +37,7 @@ #include "SquareLabel.h" #include "mapContainer.h" #include "about.h" +#include "fpsedit.h" PageMain::PageMain(QWidget* parent) : QWidget(parent) { @@ -345,6 +346,13 @@ CBEnableSound->setText(QCheckBox::tr("Enable sound")); GBAlayout->addWidget(CBEnableSound, 0, 2); + CBShowFPS = new QCheckBox(AGGroupBox); + CBShowFPS->setText(QCheckBox::tr("Show FPS")); + GBAlayout->addWidget(CBShowFPS, 0, 3); + + fpsedit = new FPSEdit(AGGroupBox); + GBAlayout->addWidget(fpsedit, 0, 4); + pageLayout->addWidget(new QWidget(), 3, 0, 1, 3); BtnSaveOptions = new QPushButton(this); diff -r 607912ccc5af -r 279e10ec31b4 QTfrontend/pages.h --- a/QTfrontend/pages.h Sun Dec 10 18:13:10 2006 +0000 +++ b/QTfrontend/pages.h Sun Dec 10 18:57:05 2006 +0000 @@ -37,6 +37,7 @@ class SquareLabel; class About; class QSpinBox; +class FPSEdit; class PageMain : public QWidget { @@ -142,6 +143,8 @@ QComboBox *CBResolution; QCheckBox *CBEnableSound; QCheckBox *CBFullscreen; + QCheckBox *CBShowFPS; + FPSEdit *fpsedit; QPushButton *BtnSaveOptions; }; diff -r 607912ccc5af -r 279e10ec31b4 hedgewars/hwengine.dpr --- a/hedgewars/hwengine.dpr Sun Dec 10 18:13:10 2006 +0000 +++ b/hedgewars/hwengine.dpr Sun Dec 10 18:57:05 2006 +0000 @@ -173,7 +173,6 @@ cLocaleFName:= ParamStr(7); val(ParamStr(8), cInitVolume, c); val(ParamStr(9), cTimerInterval, c); - cTimerInterval:= 1024 div cTimerInterval; PathPrefix:= ParamStr(10); cShowFPS:= ParamStr(11) = '1'; for p:= Succ(Low(TPathType)) to High(TPathType) do