New GameCFGWidget. Now it's possible to set forts mode from ui
--- a/QTfrontend/CMakeLists.txt Mon Jul 24 22:37:34 2006 +0000
+++ b/QTfrontend/CMakeLists.txt Tue Jul 25 13:32:11 2006 +0000
@@ -14,8 +14,9 @@
teamselhelper.cpp
frameTeam.cpp
vertScrollArea.cpp
- gameconfig.cpp
- ui_hwform.cpp)
+ gameuiconfig.cpp
+ ui_hwform.cpp
+ gamecfgwidget.cpp)
if (WIN32)
set(hwfr_src ${hwfr_src} res/hedgewars.rc)
@@ -29,8 +30,9 @@
teamselhelper.h
frameTeam.h
vertScrollArea.h
- gameconfig.h
- ui_hwform.h)
+ gameuiconfig.h
+ ui_hwform.h
+ gamecfgwidget.h)
set(hwfr_rez
--- a/QTfrontend/game.cpp Mon Jul 24 22:37:34 2006 +0000
+++ b/QTfrontend/game.cpp Tue Jul 25 13:32:11 2006 +0000
@@ -40,11 +40,12 @@
#include <QFile>
#include "game.h"
#include "hwconsts.h"
-#include "gameconfig.h"
+#include "gameuiconfig.h"
-HWGame::HWGame(GameConfig * config)
+HWGame::HWGame(GameUIConfig * config, GameCFGWidget * gamecfg)
{
this->config = config;
+ this->gamecfg = gamecfg;
TeamCount = 0;
seed = "";
}
@@ -86,7 +87,7 @@
SendIPC(QString("etheme %1").arg(GetThemeBySeed()));
//SENDIPC("emap test");
SENDIPC("TL");
- SENDIPC("e$gmflags 0");
+ SendIPC(QString("e$gmflags %1").arg(gamecfg->getGameFlags()));
SENDIPC("eaddteam");
SendTeamConfig(0);
SENDIPC("ecolor 65535");
--- a/QTfrontend/game.h Mon Jul 24 22:37:34 2006 +0000
+++ b/QTfrontend/game.h Tue Jul 25 13:32:11 2006 +0000
@@ -47,13 +47,14 @@
#define MAXMSGCHARS 255
#define SENDIPC(a) SendIPC(a, sizeof(a) - 1)
-class GameConfig;
+class GameUIConfig;
+class GameCFGWidget;
class HWGame : public QObject
{
Q_OBJECT
public:
- HWGame(GameConfig * config);
+ HWGame(GameUIConfig * config, GameCFGWidget * gamecfg);
void AddTeam(const QString & team);
void PlayDemo(const QString & demofilename);
void StartLocal();
@@ -82,7 +83,8 @@
RNDStr seedgen;
QByteArray * demo;
QByteArray toSendBuf;
- GameConfig * config;
+ GameUIConfig * config;
+ GameCFGWidget * gamecfg;
GameType gameType;
void Start();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/gamecfgwidget.cpp Tue Jul 25 13:32:11 2006 +0000
@@ -0,0 +1,57 @@
+/*
+ * Hedgewars, a worms-like game
+ * Copyright (c) 2006 Andrey Korotaev <unC0Rr@gmail.com>
+ *
+ * Distributed under the terms of the BSD-modified licence:
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * with the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+ * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <QResizeEvent>
+#include "gamecfgwidget.h"
+
+GameCFGWidget::GameCFGWidget(QWidget* parent) : QWidget(parent)
+{
+ QPalette newPalette = palette();
+ newPalette.setColor(QPalette::Background, QColor(0, 128, 0));
+ setPalette(newPalette);
+ CB_mode_Forts = new QCheckBox(this);
+ CB_mode_Forts->setText("Forts mode");
+}
+
+void GameCFGWidget::resizeEvent(QResizeEvent * event)
+{
+ resize(event->size());
+}
+
+quint32 GameCFGWidget::getGameFlags()
+{
+ quint32 result = 0;
+ if (CB_mode_Forts->isChecked())
+ result |= 1;
+ return result;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/gamecfgwidget.h Tue Jul 25 13:32:11 2006 +0000
@@ -0,0 +1,58 @@
+/*
+ * Hedgewars, a worms-like game
+ * Copyright (c) 2006 Andrey Korotaev <unC0Rr@gmail.com>
+ *
+ * Distributed under the terms of the BSD-modified licence:
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * with the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+ * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef GAMECONFIGWIDGET_H
+#define GAMECONFIGWIDGET_H
+
+#include <QWidget>
+#include <QCheckBox>
+
+
+class GameCFGWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ GameCFGWidget(QWidget* parent=0);
+ quint32 getGameFlags();
+
+private slots:
+
+private:
+ QCheckBox * CB_mode_Forts;
+
+protected:
+ void resizeEvent(QResizeEvent * event);
+};
+
+#endif // GAMECONFIGWIDGET_H
--- a/QTfrontend/gameconfig.cpp Mon Jul 24 22:37:34 2006 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,128 +0,0 @@
-/*
- * Hedgewars, a worms-like game
- * Copyright (c) 2006 Andrey Korotaev <unC0Rr@gmail.com>
- *
- * Distributed under the terms of the BSD-modified licence:
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * with the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <QMessageBox>
-#include <QTextStream>
-#include "gameconfig.h"
-
-GameConfig::GameConfig(HWForm * FormWidgets)
- : QObject()
-{
- Form = FormWidgets;
-
- cfgdir.setPath(cfgdir.homePath());
- if (!cfgdir.exists(".hedgewars"))
- {
- if (!cfgdir.mkdir(".hedgewars"))
- {
- QMessageBox::critical(0,
- tr("Error"),
- tr("Cannot create directory %1").arg("/.hedgewars"),
- tr("Quit"));
- return ;
- }
- }
- cfgdir.cd(".hedgewars");
-
- QFile settings(cfgdir.absolutePath() + "/options");
- if (settings.open(QIODevice::ReadOnly))
- {
- QTextStream stream(&settings);
- stream.setCodec("UTF-8");
- QString str;
-
- while (!stream.atEnd())
- {
- str = stream.readLine();
- if (str.startsWith(";")) continue;
- if (str.startsWith("resolution "))
- {
- Form->ui.CBResolution->setCurrentIndex(str.mid(11).toLong());
- } else
- if (str.startsWith("fullscreen "))
- {
- Form->ui.CBFullscreen->setChecked(str.mid(11).toLong());
- } else
- if (str.startsWith("sound "))
- {
- Form->ui.CBEnableSound->setChecked(str.mid(6).toLong());
- } else
- if (str.startsWith("nick "))
- {
- Form->ui.editNetNick->setText(str.mid(5));
- }
- }
- settings.close();
- }
-}
-
-QStringList GameConfig::GetTeamsList()
-{
- return cfgdir.entryList(QStringList("*.cfg"));
-}
-
-void GameConfig::SaveOptions()
-{
- QFile settings(cfgdir.absolutePath() + "/options");
- if (!settings.open(QIODevice::WriteOnly))
- {
- QMessageBox::critical(0,
- tr("Error"),
- tr("Cannot save options to file %1").arg(settings.fileName()),
- tr("Quit"));
- return ;
- }
- QTextStream stream(&settings);
- stream.setCodec("UTF-8");
- stream << "; Generated by Hedgewars, do not modify" << endl;
- stream << "resolution " << Form->ui.CBResolution->currentIndex() << endl;
- stream << "fullscreen " << Form->ui.CBFullscreen->isChecked() << endl;
- stream << "sound " << Form->ui.CBEnableSound->isChecked() << endl;
- stream << "nick " << Form->ui.editNetNick->text() << endl;
- settings.close();
-}
-
-int GameConfig::vid_Resolution()
-{
- return Form->ui.CBResolution->currentIndex();
-}
-
-bool GameConfig::vid_Fullscreen()
-{
- return Form->ui.CBFullscreen->isChecked();
-}
-
-bool GameConfig::isSoundEnabled()
-{
- return Form->ui.CBEnableSound->isChecked();
-}
--- a/QTfrontend/gameconfig.h Mon Jul 24 22:37:34 2006 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-/*
- * Hedgewars, a worms-like game
- * Copyright (c) 2006 Andrey Korotaev <unC0Rr@gmail.com>
- *
- * Distributed under the terms of the BSD-modified licence:
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * with the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GAMECONFIG_H
-#define GAMECONFIG_H
-
-#include <QObject>
-#include <QDir>
-#include <QStringList>
-#include "hwform.h"
-
-class GameConfig : public QObject
-{
- Q_OBJECT
-
-public:
- GameConfig(HWForm * FormWidgets);
- QStringList GetTeamsList();
- QDir cfgdir;
- int vid_Resolution();
- bool vid_Fullscreen();
- bool isSoundEnabled();
-
-private slots:
-
-public slots:
- void SaveOptions();
-
-private:
- HWForm * Form;
-};
-
-#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/gameuiconfig.cpp Tue Jul 25 13:32:11 2006 +0000
@@ -0,0 +1,128 @@
+/*
+ * Hedgewars, a worms-like game
+ * Copyright (c) 2006 Andrey Korotaev <unC0Rr@gmail.com>
+ *
+ * Distributed under the terms of the BSD-modified licence:
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * with the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+ * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <QMessageBox>
+#include <QTextStream>
+#include "gameuiconfig.h"
+
+GameUIConfig::GameUIConfig(HWForm * FormWidgets)
+ : QObject()
+{
+ Form = FormWidgets;
+
+ cfgdir.setPath(cfgdir.homePath());
+ if (!cfgdir.exists(".hedgewars"))
+ {
+ if (!cfgdir.mkdir(".hedgewars"))
+ {
+ QMessageBox::critical(0,
+ tr("Error"),
+ tr("Cannot create directory %1").arg("/.hedgewars"),
+ tr("Quit"));
+ return ;
+ }
+ }
+ cfgdir.cd(".hedgewars");
+
+ QFile settings(cfgdir.absolutePath() + "/options");
+ if (settings.open(QIODevice::ReadOnly))
+ {
+ QTextStream stream(&settings);
+ stream.setCodec("UTF-8");
+ QString str;
+
+ while (!stream.atEnd())
+ {
+ str = stream.readLine();
+ if (str.startsWith(";")) continue;
+ if (str.startsWith("resolution "))
+ {
+ Form->ui.CBResolution->setCurrentIndex(str.mid(11).toLong());
+ } else
+ if (str.startsWith("fullscreen "))
+ {
+ Form->ui.CBFullscreen->setChecked(str.mid(11).toLong());
+ } else
+ if (str.startsWith("sound "))
+ {
+ Form->ui.CBEnableSound->setChecked(str.mid(6).toLong());
+ } else
+ if (str.startsWith("nick "))
+ {
+ Form->ui.editNetNick->setText(str.mid(5));
+ }
+ }
+ settings.close();
+ }
+}
+
+QStringList GameUIConfig::GetTeamsList()
+{
+ return cfgdir.entryList(QStringList("*.cfg"));
+}
+
+void GameUIConfig::SaveOptions()
+{
+ QFile settings(cfgdir.absolutePath() + "/options");
+ if (!settings.open(QIODevice::WriteOnly))
+ {
+ QMessageBox::critical(0,
+ tr("Error"),
+ tr("Cannot save options to file %1").arg(settings.fileName()),
+ tr("Quit"));
+ return ;
+ }
+ QTextStream stream(&settings);
+ stream.setCodec("UTF-8");
+ stream << "; Generated by Hedgewars, do not modify" << endl;
+ stream << "resolution " << Form->ui.CBResolution->currentIndex() << endl;
+ stream << "fullscreen " << Form->ui.CBFullscreen->isChecked() << endl;
+ stream << "sound " << Form->ui.CBEnableSound->isChecked() << endl;
+ stream << "nick " << Form->ui.editNetNick->text() << endl;
+ settings.close();
+}
+
+int GameUIConfig::vid_Resolution()
+{
+ return Form->ui.CBResolution->currentIndex();
+}
+
+bool GameUIConfig::vid_Fullscreen()
+{
+ return Form->ui.CBFullscreen->isChecked();
+}
+
+bool GameUIConfig::isSoundEnabled()
+{
+ return Form->ui.CBEnableSound->isChecked();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/gameuiconfig.h Tue Jul 25 13:32:11 2006 +0000
@@ -0,0 +1,63 @@
+/*
+ * Hedgewars, a worms-like game
+ * Copyright (c) 2006 Andrey Korotaev <unC0Rr@gmail.com>
+ *
+ * Distributed under the terms of the BSD-modified licence:
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * with the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+ * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef GAMECONFIG_H
+#define GAMECONFIG_H
+
+#include <QObject>
+#include <QDir>
+#include <QStringList>
+#include "hwform.h"
+
+class GameUIConfig : public QObject
+{
+ Q_OBJECT
+
+public:
+ GameUIConfig(HWForm * FormWidgets);
+ QStringList GetTeamsList();
+ QDir cfgdir;
+ int vid_Resolution();
+ bool vid_Fullscreen();
+ bool isSoundEnabled();
+
+private slots:
+
+public slots:
+ void SaveOptions();
+
+private:
+ HWForm * Form;
+};
+
+#endif
--- a/QTfrontend/hedgewars.pro Mon Jul 24 22:37:34 2006 +0000
+++ b/QTfrontend/hedgewars.pro Tue Jul 25 13:32:11 2006 +0000
@@ -22,8 +22,9 @@
teamselhelper.h \
frameTeam.h \
vertScrollArea.h \
- gameconfig.h \
- ui_hwform.h
+ gameuiconfig.h \
+ ui_hwform.h \
+ gamecfgwidget.h
SOURCES += game.cpp \
main.cpp \
@@ -36,8 +37,9 @@
teamselhelper.cpp \
frameTeam.cpp \
vertScrollArea.cpp \
- gameconfig.cpp \
- ui_hwform.cpp
+ gameuiconfig.cpp \
+ ui_hwform.cpp \
+ gamecfgwidget.cpp
TRANSLATIONS += translations/hedgewars_ru.ts
--- a/QTfrontend/hwform.cpp Mon Jul 24 22:37:34 2006 +0000
+++ b/QTfrontend/hwform.cpp Tue Jul 25 13:32:11 2006 +0000
@@ -1,6 +1,6 @@
/*
* Hedgewars, a worms-like game
- * Copyright (c) 2005 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2005, 2006 Andrey Korotaev <unC0Rr@gmail.com>
*
* Distributed under the terms of the BSD-modified licence:
*
@@ -44,7 +44,7 @@
#include "hwform.h"
#include "sdlkeys.h"
#include "hwconsts.h"
-#include "gameconfig.h"
+#include "gameuiconfig.h"
HWForm::HWForm(QWidget *parent)
: QMainWindow(parent)
@@ -100,7 +100,7 @@
ui.CBGrave->addItem((*it).replace(QRegExp("^(.*).png"), "\\1"));
}
- config = new GameConfig(this);
+ config = new GameUIConfig(this);
QStringList teamslist = config->GetTeamsList();
@@ -111,12 +111,10 @@
teamslist.push_back("DefaultTeam");
}
- pts=new TeamSelWidget(ui.Pages->widget(ID_PAGE_SINGLEPLAYER));
-
for (QStringList::Iterator it = teamslist.begin(); it != teamslist.end(); ++it )
{
QString tmpTeamStr=(*it).replace(QRegExp("^(.*).cfg$"), "\\1");
- pts->addTeam(tmpTeamStr);
+ ui.PageLGTeamsSelect->addTeam(tmpTeamStr);
ui.CBTeamName->addItem(tmpTeamStr);
}
@@ -157,9 +155,6 @@
void HWForm::GoToSinglePlayer()
{
ui.Pages->setCurrentIndex(ID_PAGE_SINGLEPLAYER);
-
- pts->resize(500, 350);
- pts->show();
}
void HWForm::GoToSetup()
@@ -225,7 +220,7 @@
void HWForm::SimpleGame()
{
- game = new HWGame(config);
+ game = new HWGame(config, ui.pageLGGameCFG);
game->AddTeam("DefaultTeam");
game->AddTeam("DefaultTeam");
game->StartLocal();
@@ -254,7 +249,7 @@
tr("OK"));
return ;
}
- game = new HWGame(config);
+ game = new HWGame(config, 0);
game->PlayDemo(QString(DATA_PATH) + "/Demos/" + curritem->text() + ".hwd_1");
}
--- a/QTfrontend/hwform.h Mon Jul 24 22:37:34 2006 +0000
+++ b/QTfrontend/hwform.h Tue Jul 25 13:32:11 2006 +0000
@@ -45,7 +45,7 @@
#include "netclient.h"
#include "teamselect.h"
-class GameConfig;
+class GameUIConfig;
class HWForm : public QMainWindow
{
@@ -91,9 +91,7 @@
HWGame * game;
HWTeam * tmpTeam;
HWNet * hwnet;
- GameConfig * config;
-
- TeamSelWidget* pts;
+ GameUIConfig * config;
};
#define ID_PAGE_SINGLEPLAYER 0
--- a/QTfrontend/netclient.cpp Mon Jul 24 22:37:34 2006 +0000
+++ b/QTfrontend/netclient.cpp Tue Jul 25 13:32:11 2006 +0000
@@ -35,7 +35,7 @@
#include "netclient.h"
#include "game.h"
-HWNet::HWNet(GameConfig * config)
+HWNet::HWNet(GameUIConfig * config)
: QObject()
{
this->config = config;
@@ -492,7 +492,7 @@
void HWNet::RunGame(const QString & seed)
{
- HWGame * game = new HWGame(config);
+ HWGame * game = new HWGame(config, 0);
connect(game, SIGNAL(SendNet(const QByteArray &)), this, SLOT(SendNet(const QByteArray &)));
connect(this, SIGNAL(FromNet(const QByteArray &)), game, SLOT(FromNet(const QByteArray &)));
connect(this, SIGNAL(LocalCFG(const QString &)), game, SLOT(LocalCFG(const QString &)));
--- a/QTfrontend/netclient.h Mon Jul 24 22:37:34 2006 +0000
+++ b/QTfrontend/netclient.h Tue Jul 25 13:32:11 2006 +0000
@@ -50,14 +50,14 @@
QStringList hhs;
};
-class GameConfig;
+class GameUIConfig;
class HWNet : public QObject
{
Q_OBJECT
public:
- HWNet(GameConfig * config);
+ HWNet(GameUIConfig * config);
void Connect(const QString & hostName, quint16 port, const QString & nick);
void Disconnect();
void JoinGame(const QString & game);
@@ -106,7 +106,7 @@
int configasks;
QByteArray NetBuffer;
QTimer * TimerFlusher;
- GameConfig * config;
+ GameUIConfig * config;
void RawSendNet(const QString & buf);
void RawSendNet(const QByteArray & buf);
--- a/QTfrontend/teamselect.cpp Mon Jul 24 22:37:34 2006 +0000
+++ b/QTfrontend/teamselect.cpp Tue Jul 25 13:32:11 2006 +0000
@@ -3,8 +3,6 @@
#include <QPushButton>
#include <QFrame>
-#include <algorithm>
-
#include <vertScrollArea.h>
#include "teamselect.h"
#include "teamselhelper.h"
--- a/QTfrontend/ui_hwform.cpp Mon Jul 24 22:37:34 2006 +0000
+++ b/QTfrontend/ui_hwform.cpp Tue Jul 25 13:32:11 2006 +0000
@@ -7,7 +7,7 @@
SetupFonts();
HWForm->setObjectName(QString::fromUtf8("HWForm"));
- HWForm->resize(QSize(640, 450).expandedTo(HWForm->minimumSizeHint()));
+ HWForm->resize(QSize(620, 430).expandedTo(HWForm->minimumSizeHint()));
HWForm->setMinimumSize(QSize(620, 430));
centralWidget = new QWidget(HWForm);
@@ -83,17 +83,17 @@
void Ui_HWForm::SetupPageLocalGame(QWidget *Parent)
{
- BtnSimpleGame = new QPushButton(Parent);
- BtnSimpleGame->setGeometry(QRect(330, 380, 161, 41));
- BtnSimpleGame->setFont(*font14);
- BtnSimpleGame->setCheckable(false);
- BtnSimpleGame->setChecked(false);
+ QGridLayout * PageLGLayout = new QGridLayout(Parent);
BtnSPBack = new QPushButton(Parent);
- BtnSPBack->setGeometry(QRect(120, 380, 161, 41));
BtnSPBack->setFont(*font14);
- BtnSPBack->setCheckable(false);
- BtnSPBack->setChecked(false);
-
+ PageLGLayout->addWidget(BtnSPBack, 1, 0);
+ BtnSimpleGame = new QPushButton(Parent);
+ BtnSimpleGame->setFont(*font14);
+ PageLGLayout->addWidget(BtnSimpleGame, 1, 3);
+ pageLGGameCFG = new GameCFGWidget(Parent);
+ PageLGLayout->addWidget(pageLGGameCFG, 0, 0, 1, 2);
+ PageLGTeamsSelect = new TeamSelWidget(Parent);
+ PageLGLayout->addWidget(PageLGTeamsSelect, 0, 2, 1, 2);
}
void Ui_HWForm::SetupPageEditTeam(QWidget *Parent)
@@ -271,25 +271,39 @@
void Ui_HWForm::SetupPageMain(QWidget *Parent)
{
QGridLayout * PageMainLayout = new QGridLayout(Parent);
- PageMainLayout->setMargin(15);
+ PageMainLayout->setMargin(25);
+ PageMainLayout->setColumnStretch(0, 1);
+ PageMainLayout->setColumnStretch(1, 2);
+ PageMainLayout->setColumnStretch(2, 1);
BtnSinglePlayer = new QPushButton(Parent);
+ BtnSinglePlayer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
BtnSinglePlayer->setFont(*font14);
- PageMainLayout->addWidget(BtnSinglePlayer, 0, 0);
+ PageMainLayout->addWidget(BtnSinglePlayer, 1, 1);
+
BtnMultiplayer = new QPushButton(Parent);
+ BtnMultiplayer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
BtnMultiplayer->setFont(*font14);
- PageMainLayout->addWidget(BtnMultiplayer, 0, 1);
+ PageMainLayout->addWidget(BtnMultiplayer, 2, 1);
+
BtnNet = new QPushButton(Parent);
+ BtnNet->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
BtnNet->setFont(*font14);
- PageMainLayout->addWidget(BtnNet, 1, 0);
- BtnSetup = new QPushButton(Parent);
- BtnSetup->setFont(*font14);
- PageMainLayout->addWidget(BtnSetup, 1, 1);
+ PageMainLayout->addWidget(BtnNet, 3, 1);
+
BtnDemos = new QPushButton(Parent);
+ BtnDemos->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
BtnDemos->setFont(*font14);
- PageMainLayout->addWidget(BtnDemos, 2, 0);
+ PageMainLayout->addWidget(BtnDemos, 4, 1);
+
+ BtnSetup = new QPushButton(Parent);
+ BtnSetup->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ BtnSetup->setFont(*font14);
+ PageMainLayout->addWidget(BtnSetup, 5, 1);
+
BtnExit = new QPushButton(Parent);
+ BtnExit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
BtnExit->setFont(*font14);
- PageMainLayout->addWidget(BtnExit, 2, 1);
+ PageMainLayout->addWidget(BtnExit, 6, 1);
}
void Ui_HWForm::retranslateUi(QMainWindow *HWForm)
--- a/QTfrontend/ui_hwform.h Mon Jul 24 22:37:34 2006 +0000
+++ b/QTfrontend/ui_hwform.h Tue Jul 25 13:32:11 2006 +0000
@@ -17,6 +17,8 @@
#include <QtGui/QToolBox>
#include <QtGui/QWidget>
#include <QStackedLayout>
+#include "teamselect.h"
+#include "gamecfgwidget.h"
class Ui_HWForm
{
@@ -84,6 +86,8 @@
QStackedLayout *Pages;
QFont *font14;
+ TeamSelWidget *PageLGTeamsSelect;
+ GameCFGWidget *pageLGGameCFG;
void setupUi(QMainWindow *HWForm);
void SetupFonts();
--- a/QTfrontend/vertScrollArea.cpp Mon Jul 24 22:37:34 2006 +0000
+++ b/QTfrontend/vertScrollArea.cpp Tue Jul 25 13:32:11 2006 +0000
@@ -1,16 +1,16 @@
-#include "vertScrollArea.h"
-
-#include <QResizeEvent>
-
-VertScrArea::VertScrArea(QColor frameColor, QWidget * parent) :
- QScrollArea(parent)
-{
- QPalette newPalette = palette();
- newPalette.setColor(QPalette::Background, frameColor);
- setPalette(newPalette);
-}
-
-void VertScrArea::resizeEvent(QResizeEvent * event)
-{
- widget()->resize(event->size().width(), widget()->sizeHint().height());
-}
+#include "vertScrollArea.h"
+
+#include <QResizeEvent>
+
+VertScrArea::VertScrArea(QColor frameColor, QWidget * parent) :
+ QScrollArea(parent)
+{
+ QPalette newPalette = palette();
+ newPalette.setColor(QPalette::Background, frameColor);
+ setPalette(newPalette);
+}
+
+void VertScrArea::resizeEvent(QResizeEvent * event)
+{
+ widget()->resize(event->size().width(), widget()->sizeHint().height());
+}
--- a/QTfrontend/vertScrollArea.h Mon Jul 24 22:37:34 2006 +0000
+++ b/QTfrontend/vertScrollArea.h Tue Jul 25 13:32:11 2006 +0000
@@ -1,17 +1,17 @@
-#ifndef _VERT_SCROLL_AREA_INCLUDED
-#define _VERT_SCROLL_AREA_INCLUDED
-
-#include <QScrollArea>
-
-class VertScrArea : public QScrollArea
-{
- Q_OBJECT
-
- public:
- VertScrArea(QColor frameColor, QWidget * parent = 0);
-
- protected:
- virtual void resizeEvent(QResizeEvent * event);
-};
-
-#endif // _VERT_SCROLL_AREA_INCLUDED
+#ifndef _VERT_SCROLL_AREA_INCLUDED
+#define _VERT_SCROLL_AREA_INCLUDED
+
+#include <QScrollArea>
+
+class VertScrArea : public QScrollArea
+{
+ Q_OBJECT
+
+public:
+ VertScrArea(QColor frameColor, QWidget * parent = 0);
+
+protected:
+ virtual void resizeEvent(QResizeEvent * event);
+};
+
+#endif // _VERT_SCROLL_AREA_INCLUDED