--- a/QTfrontend/binds.h Tue Dec 06 19:46:40 2005 +0000
+++ b/QTfrontend/binds.h Wed Dec 07 20:36:55 2005 +0000
@@ -1,61 +1,71 @@
-/*
- * Hedgewars, a worms-like game
- * Copyright (c) 2005 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 BINDS_H
-#define BINDS_H
-
-#include <QtGlobal>
-
-#define BINDS_NUMBER 9
-
-struct BindAction
-{
- QString action;
- QString strbind;
- QString name;
-};
-
-const BindAction cbinds[BINDS_NUMBER] =
-{
- {"+up", "up", QT_TR_NOOP("up")},
- {"+left", "left", QT_TR_NOOP("left")},
- {"+right", "right", QT_TR_NOOP("right")},
- {"+down", "down", QT_TR_NOOP("down")},
- {"ljump", "return", QT_TR_NOOP("jump")},
- {"hjump", "backspace", QT_TR_NOOP("jump")},
- {"+attack", "space", QT_TR_NOOP("attack")},
- {"switch", "tab", QT_TR_NOOP("switch")},
- {"quit", "F10", QT_TR_NOOP("quit")}
-};
-
-#endif // BINDS_H
+/*
+ * Hedgewars, a worms-like game
+ * Copyright (c) 2005 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 BINDS_H
+#define BINDS_H
+
+#include <QtGlobal>
+
+#define BINDS_NUMBER 18
+
+struct BindAction
+{
+ QString action;
+ QString strbind;
+ QString name;
+ bool chwidget;
+};
+
+const BindAction cbinds[BINDS_NUMBER] =
+{
+ {"+up", "up", QT_TR_NOOP("up"), false},
+ {"+left", "left", QT_TR_NOOP("left"), false},
+ {"+right", "right", QT_TR_NOOP("right"), false},
+ {"+down", "down", QT_TR_NOOP("down"), false},
+ {"ljump", "return", QT_TR_NOOP("jump"), false},
+ {"hjump", "backspace", QT_TR_NOOP("jump"), false},
+ {"+attack", "space", QT_TR_NOOP("attack"), false},
+ {"switch", "tab", QT_TR_NOOP("switch"), true},
+ {"slot 1", "f1", QT_TR_NOOP("slot 1"), false},
+ {"slot 2", "f2", QT_TR_NOOP("slot 2"), false},
+ {"slot 3", "f3", QT_TR_NOOP("slot 3"), false},
+ {"slot 4", "f4", QT_TR_NOOP("slot 4"), false},
+ {"slot 5", "f5", QT_TR_NOOP("slot 5"), false},
+ {"slot 6", "f6", QT_TR_NOOP("slot 6"), false},
+ {"slot 7", "f7", QT_TR_NOOP("slot 7"), false},
+ {"slot 8", "f8", QT_TR_NOOP("slot 8"), true},
+ {"capture", "f11", QT_TR_NOOP("capture"), false},
+ {"quit", "f10", QT_TR_NOOP("quit"), false}
+};
+
+#endif // BINDS_H
--- a/QTfrontend/game.cpp Tue Dec 06 19:46:40 2005 +0000
+++ b/QTfrontend/game.cpp Wed Dec 07 20:36:55 2005 +0000
@@ -41,8 +41,10 @@
#include "game.h"
#include "hwconsts.h"
-HWGame::HWGame()
+HWGame::HWGame(int Resolution, bool Fullscreen)
{
+ vid_Resolution = Resolution;
+ vid_Fullscreen = Fullscreen;
IPCServer = new QTcpServer(this);
IPCServer->setMaxPendingConnections(1);
if (!IPCServer->listen(QHostAddress("127.0.0.1"), IPC_PORT))
@@ -54,7 +56,7 @@
connect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection()));
IPCSocket = 0;
TeamCount = 0;
- seed = "seed";
+ seed = "";
}
void HWGame::NewConnection()
@@ -103,6 +105,13 @@
void HWGame::SendConfig()
{
+ if (gameType == gtDemo)
+ {
+ SENDIPC("TD");
+ SendIPCRaw(toSendBuf->constData(), toSendBuf->size());
+ delete toSendBuf;
+ return ;
+ }
SENDIPC("TL");
SENDIPC("e$gmflags 0");
SENDIPC("eaddteam");
@@ -168,6 +177,12 @@
demo->append(buf);
}
+void HWGame::SendIPCRaw(const char * msg, quint32 len)
+{
+ IPCSocket->write(msg, len);
+ demo->append(QByteArray::fromRawData(msg, len));
+}
+
void HWGame::ClientRead()
{
qint64 readbytes = 1;
@@ -190,19 +205,20 @@
}
}
-void HWGame::Start(int Resolution, bool Fullscreen)
+void HWGame::Start()
{
+ gameType = gtLocal;
if (TeamCount < 2) return;
QProcess * process;
QStringList arguments;
seedgen.GenRNDStr(seed, 10);
process = new QProcess;
- arguments << resolutions[0][Resolution];
- arguments << resolutions[1][Resolution];
+ arguments << resolutions[0][vid_Resolution];
+ arguments << resolutions[1][vid_Resolution];
arguments << GetThemeBySeed();
arguments << "46631";
arguments << seed;
- arguments << (Fullscreen ? "1" : "0");
+ arguments << (vid_Fullscreen ? "1" : "0");
process->start("hw", arguments);
demo = new QByteArray;
demo->append(seed.toLocal8Bit());
@@ -218,7 +234,7 @@
QString HWGame::GetThemeBySeed()
{
- QFile themesfile("Data/Themes/themes.cfg");
+ QFile themesfile(QString(DATA_PATH) + "/Themes/themes.cfg");
QStringList themes;
if (themesfile.open(QIODevice::ReadOnly))
{
@@ -263,4 +279,58 @@
QDataStream stream(&demofile);
stream.writeRawData(demo->constData(), demo->size());
demofile.close();
+ delete demo;
}
+
+void HWGame::PlayDemo(const QString & demofilename)
+{
+ gameType = gtDemo;
+ QFile demofile(demofilename);
+ if (!demofile.open(QIODevice::ReadOnly))
+ {
+ QMessageBox::critical(this,
+ tr("Error"),
+ tr("Cannot open demofile %s").arg(demofilename),
+ tr("Quit"));
+ return ;
+ }
+
+ // read demo
+ QDataStream stream(&demofile);
+ toSendBuf = new QByteArray();
+ char buf[512];
+ quint32 readbytes;
+ do
+ {
+ readbytes = stream.readRawData((char *)&buf, 512);
+ toSendBuf -> append(QByteArray((char *)&buf, readbytes));
+
+ } while (readbytes > 0);
+ demofile.close();
+
+ // cut seed
+ quint32 index = toSendBuf->indexOf(10);
+ if (!index)
+ {
+ QMessageBox::critical(this,
+ tr("Error"),
+ tr("Corrupted demo file %s").arg(demofilename),
+ tr("Quit"));
+ return ;
+ }
+ seed = QString(toSendBuf->left(index++));
+ toSendBuf->remove(0, index);
+
+ // run engine
+ QProcess * process;
+ QStringList arguments;
+ process = new QProcess;
+ arguments << resolutions[0][vid_Resolution];
+ arguments << resolutions[1][vid_Resolution];
+ arguments << GetThemeBySeed();
+ arguments << "46631";
+ arguments << seed;
+ arguments << (vid_Fullscreen ? "1" : "0");
+ process->start("hw", arguments);
+ demo = new QByteArray;
+}
--- a/QTfrontend/game.h Tue Dec 06 19:46:40 2005 +0000
+++ b/QTfrontend/game.h Wed Dec 07 20:36:55 2005 +0000
@@ -51,12 +51,18 @@
{
Q_OBJECT
public:
- HWGame();
- void Start(int Resolution, bool Fullscreen);
+ HWGame(int Resolution, bool Fullscreen);
+ void Start();
void AddTeam(const QString & team);
+ void PlayDemo(const QString & demofilename);
private:
- QTcpServer * IPCServer;
+ enum GameType {
+ gtLocal = 1,
+ gtDemo = 2,
+ gtNet = 3
+ };
+ QTcpServer * IPCServer;
QTcpSocket * IPCSocket;
char msgbuf[MAXMSGCHARS];
quint8 msgbufsize;
@@ -66,12 +72,17 @@
int TeamCount;
RNDStr seedgen;
QByteArray * demo;
+ QByteArray * toSendBuf;
+ int vid_Resolution;
+ bool vid_Fullscreen;
+ GameType gameType;
void SendConfig();
void SendTeamConfig(int index);
void ParseMessage();
void SendIPC(const char * msg, quint8 len);
void SendIPC(const QByteArray & buf);
+ void SendIPCRaw(const char * msg, quint32 len);
void SaveDemo(const QString & filename);
QString GetThemeBySeed();
--- a/QTfrontend/hwform.cpp Tue Dec 06 19:46:40 2005 +0000
+++ b/QTfrontend/hwform.cpp Wed Dec 07 20:36:55 2005 +0000
@@ -66,15 +66,24 @@
binds << sdlkeys[i][1];
}
- for(int i = 0; i < BINDS_NUMBER; i++)
+ quint16 widind = 0, top = 0;
+ for(quint8 i = 0; i < BINDS_NUMBER; i++)
{
- LBind[i] = new QLabel(ui.GBoxBinds);
- LBind[i]->setGeometry(QRect(10, 23 + i * 30, 60, 20));
+ LBind[i] = new QLabel(ui.BindsBox->widget(widind));
+ LBind[i]->setGeometry(QRect(10, top + 3, 60, 20));
LBind[i]->setText(cbinds[i].name);
LBind[i]->setAlignment(Qt::AlignRight);
- CBBind[i] = new QComboBox(ui.GBoxBinds);
- CBBind[i]->setGeometry(QRect(80, 20 + i * 30, 80, 20));
+ CBBind[i] = new QComboBox(ui.BindsBox->widget(widind));
+ CBBind[i]->setGeometry(QRect(80, top, 80, 20));
CBBind[i]->addItems(binds);
+ if (cbinds[i].chwidget)
+ {
+ top = 0;
+ widind++;
+ } else
+ {
+ top += 30;
+ }
}
QDir tmpdir;
@@ -136,18 +145,22 @@
}
settings.close();
}
+
connect(ui.BtnSPBack, SIGNAL(clicked()), this, SLOT(GoToMain()));
+ connect(ui.BtnDemosBack, SIGNAL(clicked()), this, SLOT(GoToMain()));
connect(ui.BtnSetupBack, SIGNAL(clicked()), this, SLOT(GoToMain()));
connect(ui.BtnMPBack, SIGNAL(clicked()), this, SLOT(GoToMain()));
connect(ui.BtnSinglePlayer, SIGNAL(clicked()), this, SLOT(GoToSinglePlayer()));
connect(ui.BtnSetup, SIGNAL(clicked()), this, SLOT(GoToSetup()));
connect(ui.BtnMultiplayer, SIGNAL(clicked()), this, SLOT(GoToMultiplayer()));
+ connect(ui.BtnDemos, SIGNAL(clicked()), this, SLOT(GoToDemos()));
connect(ui.BtnNewTeam, SIGNAL(clicked()), this, SLOT(NewTeam()));
connect(ui.BtnEditTeam, SIGNAL(clicked()), this, SLOT(EditTeam()));
connect(ui.BtnTeamSave, SIGNAL(clicked()), this, SLOT(TeamSave()));
connect(ui.BtnTeamDiscard, SIGNAL(clicked()), this, SLOT(TeamDiscard()));
connect(ui.BtnSimpleGame, SIGNAL(clicked()), this, SLOT(SimpleGame()));
connect(ui.BtnSaveOptions, SIGNAL(clicked()), this, SLOT(SaveOptions()));
+ connect(ui.BtnPlayDemo, SIGNAL(clicked()), this, SLOT(PlayDemo()));
connect(ui.CBGrave, SIGNAL(activated(const QString &)), this, SLOT(CBGrave_activated(const QString &)));
connect(ui.CBFort, SIGNAL(activated(const QString &)), this, SLOT(CBFort_activated(const QString &)));
ui.Pages->setCurrentIndex(ID_PAGE_MAIN);
@@ -172,6 +185,17 @@
{
ui.Pages->setCurrentIndex(ID_PAGE_MULTIPLAYER);
}
+
+void HWForm::GoToDemos()
+{
+ QDir tmpdir;
+ tmpdir.cd(DATA_PATH);
+ tmpdir.cd("Demos");
+ tmpdir.setFilter(QDir::Files);
+ ui.DemosList->addItems(tmpdir.entryList(QStringList("*.hwd_1")).replaceInStrings(QRegExp("^(.*).hwd_1"), "\\1"));
+ ui.Pages->setCurrentIndex(ID_PAGE_DEMOS);
+}
+
void HWForm::NewTeam()
{
tmpTeam = new HWTeam("unnamed");
@@ -204,10 +228,10 @@
void HWForm::SimpleGame()
{
- game = new HWGame();
+ game = new HWGame(ui.CBResolution->currentIndex(), ui.CBFullscreen->isChecked());
game->AddTeam(cfgdir.absolutePath() + "/team.cfg");
game->AddTeam(cfgdir.absolutePath() + "/team.cfg");
- game->Start(ui.CBResolution->currentIndex(), ui.CBFullscreen->isChecked());
+ game->Start();
}
void HWForm::CBGrave_activated(const QString & gravename)
@@ -240,3 +264,20 @@
stream << "fullscreen " << ui.CBFullscreen->isChecked() << endl;
settings.close();
}
+
+void HWForm::PlayDemo()
+{
+ QListWidgetItem * curritem = ui.DemosList->currentItem();
+ if (!curritem)
+ {
+ QMessageBox::critical(this,
+ tr("Error"),
+ tr("Please, select demo from the list above"),
+ tr("OK"));
+ return ;
+ }
+ game = new HWGame(ui.CBResolution->currentIndex(), ui.CBFullscreen->isChecked());
+ game->PlayDemo(QString(DATA_PATH) + "/Demos/" + curritem->text() + ".hwd_1");
+}
+
+
--- a/QTfrontend/hwform.h Tue Dec 06 19:46:40 2005 +0000
+++ b/QTfrontend/hwform.h Wed Dec 07 20:36:55 2005 +0000
@@ -58,13 +58,15 @@
void GoToSinglePlayer();
void GoToSetup();
void GoToMultiplayer();
+ void GoToDemos();
void NewTeam();
void EditTeam();
void TeamSave();
void TeamDiscard();
void SimpleGame();
void SaveOptions();
-
+ void PlayDemo();
+
public slots:
void CBGrave_activated(const QString & gravename);
void CBFort_activated(const QString & gravename);
@@ -76,10 +78,11 @@
HWTeam * tmpTeam;
};
-#define ID_PAGE_MAIN 4
#define ID_PAGE_SINGLEPLAYER 0
+#define ID_PAGE_SETUP_TEAM 1
#define ID_PAGE_SETUP 2
-#define ID_PAGE_SETUP_TEAM 1
#define ID_PAGE_MULTIPLAYER 3
+#define ID_PAGE_DEMOS 4
+#define ID_PAGE_MAIN 5
#endif
--- a/QTfrontend/hwform.ui Tue Dec 06 19:46:40 2005 +0000
+++ b/QTfrontend/hwform.ui Wed Dec 07 20:36:55 2005 +0000
@@ -50,39 +50,9 @@
</size>
</property>
<property name="currentIndex" >
- <number>4</number>
+ <number>1</number>
</property>
<widget class="QWidget" name="page" >
- <widget class="QPushButton" name="BtnSPBack" >
- <property name="geometry" >
- <rect>
- <x>230</x>
- <y>170</y>
- <width>161</width>
- <height>41</height>
- </rect>
- </property>
- <property name="font" >
- <font>
- <family>MS Shell Dlg</family>
- <pointsize>14</pointsize>
- <weight>50</weight>
- <italic>false</italic>
- <bold>false</bold>
- <underline>false</underline>
- <strikeout>false</strikeout>
- </font>
- </property>
- <property name="text" >
- <string>Back</string>
- </property>
- <property name="checkable" >
- <bool>false</bool>
- </property>
- <property name="checked" >
- <bool>false</bool>
- </property>
- </widget>
<widget class="QPushButton" name="BtnSimpleGame" >
<property name="geometry" >
<rect>
@@ -113,43 +83,11 @@
<bool>false</bool>
</property>
</widget>
- </widget>
- <widget class="QWidget" name="page" >
- <widget class="QPushButton" name="BtnTeamSave" >
+ <widget class="QPushButton" name="BtnSPBack" >
<property name="geometry" >
<rect>
- <x>460</x>
- <y>340</y>
- <width>161</width>
- <height>41</height>
- </rect>
- </property>
- <property name="font" >
- <font>
- <family>MS Shell Dlg</family>
- <pointsize>14</pointsize>
- <weight>50</weight>
- <italic>false</italic>
- <bold>false</bold>
- <underline>false</underline>
- <strikeout>false</strikeout>
- </font>
- </property>
- <property name="text" >
- <string>Save</string>
- </property>
- <property name="checkable" >
- <bool>false</bool>
- </property>
- <property name="checked" >
- <bool>false</bool>
- </property>
- </widget>
- <widget class="QPushButton" name="BtnTeamDiscard" >
- <property name="geometry" >
- <rect>
- <x>460</x>
- <y>400</y>
+ <x>230</x>
+ <y>170</y>
<width>161</width>
<height>41</height>
</rect>
@@ -166,7 +104,7 @@
</font>
</property>
<property name="text" >
- <string>Discard</string>
+ <string>Back</string>
</property>
<property name="checkable" >
<bool>false</bool>
@@ -175,6 +113,8 @@
<bool>false</bool>
</property>
</widget>
+ </widget>
+ <widget class="QWidget" name="page" >
<widget class="QGroupBox" name="GBoxHedgehogs" >
<property name="geometry" >
<rect>
@@ -188,112 +128,6 @@
<string>Team Members</string>
</property>
</widget>
- <widget class="QGroupBox" name="GBoxBinds" >
- <property name="geometry" >
- <rect>
- <x>190</x>
- <y>10</y>
- <width>181</width>
- <height>321</height>
- </rect>
- </property>
- <property name="title" >
- <string>Key binds</string>
- </property>
- </widget>
- <widget class="QGroupBox" name="GBoxFort" >
- <property name="geometry" >
- <rect>
- <x>390</x>
- <y>110</y>
- <width>181</width>
- <height>221</height>
- </rect>
- </property>
- <property name="title" >
- <string>Fort</string>
- </property>
- <widget class="QComboBox" name="CBFort" >
- <property name="geometry" >
- <rect>
- <x>10</x>
- <y>20</y>
- <width>161</width>
- <height>21</height>
- </rect>
- </property>
- <property name="currentIndex" >
- <number>-1</number>
- </property>
- <property name="maxCount" >
- <number>65535</number>
- </property>
- </widget>
- <widget class="QLabel" name="FortPreview" >
- <property name="geometry" >
- <rect>
- <x>10</x>
- <y>50</y>
- <width>161</width>
- <height>161</height>
- </rect>
- </property>
- <property name="text" >
- <string/>
- </property>
- <property name="pixmap" >
- <pixmap/>
- </property>
- <property name="scaledContents" >
- <bool>true</bool>
- </property>
- </widget>
- </widget>
- <widget class="QGroupBox" name="GBoxGrave" >
- <property name="geometry" >
- <rect>
- <x>390</x>
- <y>10</y>
- <width>181</width>
- <height>91</height>
- </rect>
- </property>
- <property name="title" >
- <string>Grave</string>
- </property>
- <widget class="QComboBox" name="CBGrave" >
- <property name="geometry" >
- <rect>
- <x>10</x>
- <y>20</y>
- <width>161</width>
- <height>21</height>
- </rect>
- </property>
- <property name="currentIndex" >
- <number>-1</number>
- </property>
- <property name="maxCount" >
- <number>65535</number>
- </property>
- </widget>
- <widget class="QLabel" name="GravePreview" >
- <property name="geometry" >
- <rect>
- <x>80</x>
- <y>50</y>
- <width>32</width>
- <height>32</height>
- </rect>
- </property>
- <property name="text" >
- <string/>
- </property>
- <property name="scaledContents" >
- <bool>true</bool>
- </property>
- </widget>
- </widget>
<widget class="QGroupBox" name="GBoxTeam" >
<property name="geometry" >
<rect>
@@ -360,6 +194,219 @@
</item>
</widget>
</widget>
+ <widget class="QPushButton" name="BtnTeamDiscard" >
+ <property name="geometry" >
+ <rect>
+ <x>440</x>
+ <y>400</y>
+ <width>161</width>
+ <height>41</height>
+ </rect>
+ </property>
+ <property name="font" >
+ <font>
+ <family>MS Shell Dlg</family>
+ <pointsize>14</pointsize>
+ <weight>50</weight>
+ <italic>false</italic>
+ <bold>false</bold>
+ <underline>false</underline>
+ <strikeout>false</strikeout>
+ </font>
+ </property>
+ <property name="text" >
+ <string>Discard</string>
+ </property>
+ <property name="checkable" >
+ <bool>false</bool>
+ </property>
+ <property name="checked" >
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="BtnTeamSave" >
+ <property name="geometry" >
+ <rect>
+ <x>440</x>
+ <y>340</y>
+ <width>161</width>
+ <height>41</height>
+ </rect>
+ </property>
+ <property name="font" >
+ <font>
+ <family>MS Shell Dlg</family>
+ <pointsize>14</pointsize>
+ <weight>50</weight>
+ <italic>false</italic>
+ <bold>false</bold>
+ <underline>false</underline>
+ <strikeout>false</strikeout>
+ </font>
+ </property>
+ <property name="text" >
+ <string>Save</string>
+ </property>
+ <property name="checkable" >
+ <bool>false</bool>
+ </property>
+ <property name="checked" >
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="QGroupBox" name="GBoxFort" >
+ <property name="geometry" >
+ <rect>
+ <x>420</x>
+ <y>110</y>
+ <width>181</width>
+ <height>221</height>
+ </rect>
+ </property>
+ <property name="title" >
+ <string>Fort</string>
+ </property>
+ <widget class="QComboBox" name="CBFort" >
+ <property name="geometry" >
+ <rect>
+ <x>10</x>
+ <y>20</y>
+ <width>161</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <property name="currentIndex" >
+ <number>-1</number>
+ </property>
+ <property name="maxCount" >
+ <number>65535</number>
+ </property>
+ </widget>
+ <widget class="QLabel" name="FortPreview" >
+ <property name="geometry" >
+ <rect>
+ <x>10</x>
+ <y>50</y>
+ <width>161</width>
+ <height>161</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="pixmap" >
+ <pixmap/>
+ </property>
+ <property name="scaledContents" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </widget>
+ <widget class="QGroupBox" name="GBoxGrave" >
+ <property name="geometry" >
+ <rect>
+ <x>420</x>
+ <y>10</y>
+ <width>181</width>
+ <height>91</height>
+ </rect>
+ </property>
+ <property name="title" >
+ <string>Grave</string>
+ </property>
+ <widget class="QComboBox" name="CBGrave" >
+ <property name="geometry" >
+ <rect>
+ <x>10</x>
+ <y>20</y>
+ <width>161</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <property name="currentIndex" >
+ <number>-1</number>
+ </property>
+ <property name="maxCount" >
+ <number>65535</number>
+ </property>
+ </widget>
+ <widget class="QLabel" name="GravePreview" >
+ <property name="geometry" >
+ <rect>
+ <x>80</x>
+ <y>50</y>
+ <width>32</width>
+ <height>32</height>
+ </rect>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="scaledContents" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </widget>
+ <widget class="QGroupBox" name="GBoxBinds" >
+ <property name="geometry" >
+ <rect>
+ <x>200</x>
+ <y>10</y>
+ <width>201</width>
+ <height>381</height>
+ </rect>
+ </property>
+ <property name="title" >
+ <string>Key binds</string>
+ </property>
+ <widget class="QToolBox" name="BindsBox" >
+ <property name="geometry" >
+ <rect>
+ <x>10</x>
+ <y>20</y>
+ <width>181</width>
+ <height>351</height>
+ </rect>
+ </property>
+ <property name="lineWidth" >
+ <number>0</number>
+ </property>
+ <property name="currentIndex" >
+ <number>1</number>
+ </property>
+ <widget class="QWidget" name="page" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>181</width>
+ <height>297</height>
+ </rect>
+ </property>
+ <attribute name="label" >
+ <string>Actions</string>
+ </attribute>
+ </widget>
+ <widget class="QWidget" name="page" >
+ <attribute name="label" >
+ <string>Weapons</string>
+ </attribute>
+ </widget>
+ <widget class="QWidget" name="page" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>163</width>
+ <height>252</height>
+ </rect>
+ </property>
+ <attribute name="label" >
+ <string>Other</string>
+ </attribute>
+ </widget>
+ </widget>
+ </widget>
</widget>
<widget class="QWidget" name="page" >
<widget class="QGroupBox" name="groupBox" >
@@ -595,6 +642,78 @@
</property>
</widget>
</widget>
+ <widget class="QWidget" name="page" >
+ <widget class="QPushButton" name="BtnPlayDemo" >
+ <property name="geometry" >
+ <rect>
+ <x>240</x>
+ <y>330</y>
+ <width>161</width>
+ <height>41</height>
+ </rect>
+ </property>
+ <property name="font" >
+ <font>
+ <family>MS Shell Dlg</family>
+ <pointsize>14</pointsize>
+ <weight>50</weight>
+ <italic>false</italic>
+ <bold>false</bold>
+ <underline>false</underline>
+ <strikeout>false</strikeout>
+ </font>
+ </property>
+ <property name="text" >
+ <string>Play demo</string>
+ </property>
+ <property name="checkable" >
+ <bool>false</bool>
+ </property>
+ <property name="checked" >
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="BtnDemosBack" >
+ <property name="geometry" >
+ <rect>
+ <x>240</x>
+ <y>380</y>
+ <width>161</width>
+ <height>41</height>
+ </rect>
+ </property>
+ <property name="font" >
+ <font>
+ <family>MS Shell Dlg</family>
+ <pointsize>14</pointsize>
+ <weight>50</weight>
+ <italic>false</italic>
+ <bold>false</bold>
+ <underline>false</underline>
+ <strikeout>false</strikeout>
+ </font>
+ </property>
+ <property name="text" >
+ <string>Back</string>
+ </property>
+ <property name="checkable" >
+ <bool>false</bool>
+ </property>
+ <property name="checked" >
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="QListWidget" name="DemosList" >
+ <property name="geometry" >
+ <rect>
+ <x>170</x>
+ <y>10</y>
+ <width>311</width>
+ <height>311</height>
+ </rect>
+ </property>
+ </widget>
+ </widget>
<widget class="QWidget" name="pageMain" >
<widget class="QPushButton" name="BtnSinglePlayer" >
<property name="geometry" >
@@ -686,36 +805,6 @@
<bool>false</bool>
</property>
</widget>
- <widget class="QPushButton" name="BtnDemos" >
- <property name="geometry" >
- <rect>
- <x>230</x>
- <y>270</y>
- <width>161</width>
- <height>41</height>
- </rect>
- </property>
- <property name="font" >
- <font>
- <family>MS Shell Dlg</family>
- <pointsize>14</pointsize>
- <weight>50</weight>
- <italic>false</italic>
- <bold>false</bold>
- <underline>false</underline>
- <strikeout>false</strikeout>
- </font>
- </property>
- <property name="text" >
- <string>Demos</string>
- </property>
- <property name="checkable" >
- <bool>false</bool>
- </property>
- <property name="checked" >
- <bool>false</bool>
- </property>
- </widget>
<widget class="QPushButton" name="BtnExit" >
<property name="geometry" >
<rect>
@@ -776,6 +865,36 @@
<bool>false</bool>
</property>
</widget>
+ <widget class="QPushButton" name="BtnDemos" >
+ <property name="geometry" >
+ <rect>
+ <x>230</x>
+ <y>270</y>
+ <width>161</width>
+ <height>41</height>
+ </rect>
+ </property>
+ <property name="font" >
+ <font>
+ <family>MS Shell Dlg</family>
+ <pointsize>14</pointsize>
+ <weight>50</weight>
+ <italic>false</italic>
+ <bold>false</bold>
+ <underline>false</underline>
+ <strikeout>false</strikeout>
+ </font>
+ </property>
+ <property name="text" >
+ <string>Demos</string>
+ </property>
+ <property name="checkable" >
+ <bool>false</bool>
+ </property>
+ <property name="checked" >
+ <bool>false</bool>
+ </property>
+ </widget>
</widget>
</widget>
</widget>
--- a/QTfrontend/team.cpp Tue Dec 06 19:46:40 2005 +0000
+++ b/QTfrontend/team.cpp Wed Dec 07 20:36:55 2005 +0000
@@ -1,165 +1,165 @@
-/*
- * Hedgewars, a worms-like game
- * Copyright (c) 2005 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 <QFile>
-#include <QTextStream>
-#include "team.h"
-#include "hwform.h"
-
-HWTeam::HWTeam(const QString & teamname)
-{
- TeamName = teamname;
- for (int i = 0; i < 8; i++) HHName[i].sprintf("hedgehog %d", i);
- Grave = "Simple";
- Fort = "Barrelhouse";
- for(int i = 0; i < BINDS_NUMBER; i++)
- {
- binds[i].action = cbinds[i].action;
- binds[i].strbind = cbinds[i].strbind;
- }
- dir = "";
-}
-
-bool HWTeam::LoadFromFile()
-{
- QFile cfgfile(dir + "/" + TeamName + ".cfg");
- if (!cfgfile.open(QIODevice::ReadOnly)) return false;
- QTextStream stream(&cfgfile);
- stream.setCodec("UTF-8");
- QString str;
- QString action;
-
- while (!stream.atEnd())
- {
- str = stream.readLine();
- if (str.startsWith(";")) continue;
- if (str.startsWith("name team "))
- {
- str.remove(0, 10);
- TeamName = str;
- } else
- if (str.startsWith("name hh"))
- {
- str.remove(0, 7);
- long i = str.left(1).toLong();
- if ((i < 0) || (i > 7)) continue;
- str.remove(0, 2);
- HHName[i] = str;
- } else
- if (str.startsWith("grave "))
- {
- str.remove(0, 6);
- Grave = str;
- } else
- if (str.startsWith("fort "))
- {
- str.remove(0, 5);
- Fort = str;
- } else
- if (str.startsWith("bind "))
- {
- str.remove(0, 5);
- action = str.section(' ', 1);
- str = str.section(' ', 0, 0);
- str.truncate(15);
- for (int i = 0; i < BINDS_NUMBER; i++)
- if (action == binds[i].action)
- {
- binds[i].strbind = str;
- break;
- }
- }
- }
- cfgfile.close();
- return true;
-}
-
-bool HWTeam::SaveToFile()
-{
- QFile cfgfile(dir + "/" + TeamName + ".cfg");
- if (!cfgfile.open(QIODevice::WriteOnly)) return false;
- QTextStream stream(&cfgfile);
- stream.setCodec("UTF-8");
- stream << "; Generated by Hedgewars, do not modify" << endl;
- stream << "name team " << TeamName << endl;
- for (int i = 0; i < BINDS_NUMBER; i++)
- stream << "name hh" << i << " " << HHName[i] << endl;
- stream << "grave " << Grave << endl;
- stream << "fort " << Fort << endl;
- for(int i = 0; i < BINDS_NUMBER; i++)
- {
- stream << "bind " << binds[i].strbind << " " << binds[i].action << endl;
- }
- cfgfile.close();
- return true;
-}
-
-void HWTeam::SetToPage(HWForm * hwform)
-{
- hwform->TeamNameEdit->setText(TeamName);
- for(int i = 0; i < 8; i++)
- {
- hwform->HHNameEdit[i]->setText(HHName[i]);
- }
- hwform->ui.CBGrave->setCurrentIndex(hwform->ui.CBGrave->findText(Grave));
- hwform->CBGrave_activated(Grave);
-
- hwform->ui.CBFort->setCurrentIndex(hwform->ui.CBFort->findText(Fort));
- hwform->CBFort_activated(Fort);
-
- for(int i = 0; i < BINDS_NUMBER; i++)
- {
- hwform->CBBind[i]->setCurrentIndex(hwform->CBBind[i]->findText(binds[i].strbind));
- }
-}
-
-void HWTeam::GetFromPage(HWForm * hwform)
-{
- TeamName = hwform->TeamNameEdit->text();
- for(int i = 0; i < 8; i++)
- {
- HHName[i] = hwform->HHNameEdit[i]->text();
- }
-
- Grave = hwform->ui.CBGrave->currentText();
- Fort = hwform->ui.CBFort->currentText();
- for(int i = 0; i < 8; i++)
- {
- binds[i].strbind = hwform->CBBind[i]->currentText();
- }
-}
-
-void HWTeam::SetCfgDir(const QString & dir)
-{
- this->dir = dir;
-}
+/*
+ * Hedgewars, a worms-like game
+ * Copyright (c) 2005 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 <QFile>
+#include <QTextStream>
+#include "team.h"
+#include "hwform.h"
+
+HWTeam::HWTeam(const QString & teamname)
+{
+ TeamName = teamname;
+ for (int i = 0; i < 8; i++) HHName[i].sprintf("hedgehog %d", i);
+ Grave = "Simple";
+ Fort = "Barrelhouse";
+ for(int i = 0; i < BINDS_NUMBER; i++)
+ {
+ binds[i].action = cbinds[i].action;
+ binds[i].strbind = cbinds[i].strbind;
+ }
+ dir = "";
+}
+
+bool HWTeam::LoadFromFile()
+{
+ QFile cfgfile(dir + "/" + TeamName + ".cfg");
+ if (!cfgfile.open(QIODevice::ReadOnly)) return false;
+ QTextStream stream(&cfgfile);
+ stream.setCodec("UTF-8");
+ QString str;
+ QString action;
+
+ while (!stream.atEnd())
+ {
+ str = stream.readLine();
+ if (str.startsWith(";")) continue;
+ if (str.startsWith("name team "))
+ {
+ str.remove(0, 10);
+ TeamName = str;
+ } else
+ if (str.startsWith("name hh"))
+ {
+ str.remove(0, 7);
+ long i = str.left(1).toLong();
+ if ((i < 0) || (i > 7)) continue;
+ str.remove(0, 2);
+ HHName[i] = str;
+ } else
+ if (str.startsWith("grave "))
+ {
+ str.remove(0, 6);
+ Grave = str;
+ } else
+ if (str.startsWith("fort "))
+ {
+ str.remove(0, 5);
+ Fort = str;
+ } else
+ if (str.startsWith("bind "))
+ {
+ str.remove(0, 5);
+ action = str.section(' ', 1);
+ str = str.section(' ', 0, 0);
+ str.truncate(15);
+ for (int i = 0; i < BINDS_NUMBER; i++)
+ if (action == binds[i].action)
+ {
+ binds[i].strbind = str;
+ break;
+ }
+ }
+ }
+ cfgfile.close();
+ return true;
+}
+
+bool HWTeam::SaveToFile()
+{
+ QFile cfgfile(dir + "/" + TeamName + ".cfg");
+ if (!cfgfile.open(QIODevice::WriteOnly)) return false;
+ QTextStream stream(&cfgfile);
+ stream.setCodec("UTF-8");
+ stream << "; Generated by Hedgewars, do not modify" << endl;
+ stream << "name team " << TeamName << endl;
+ for (int i = 0; i < 8; i++)
+ stream << "name hh" << i << " " << HHName[i] << endl;
+ stream << "grave " << Grave << endl;
+ stream << "fort " << Fort << endl;
+ for(int i = 0; i < BINDS_NUMBER; i++)
+ {
+ stream << "bind " << binds[i].strbind << " " << binds[i].action << endl;
+ }
+ cfgfile.close();
+ return true;
+}
+
+void HWTeam::SetToPage(HWForm * hwform)
+{
+ hwform->TeamNameEdit->setText(TeamName);
+ for(int i = 0; i < 8; i++)
+ {
+ hwform->HHNameEdit[i]->setText(HHName[i]);
+ }
+ hwform->ui.CBGrave->setCurrentIndex(hwform->ui.CBGrave->findText(Grave));
+ hwform->CBGrave_activated(Grave);
+
+ hwform->ui.CBFort->setCurrentIndex(hwform->ui.CBFort->findText(Fort));
+ hwform->CBFort_activated(Fort);
+
+ for(int i = 0; i < BINDS_NUMBER; i++)
+ {
+ hwform->CBBind[i]->setCurrentIndex(hwform->CBBind[i]->findText(binds[i].strbind));
+ }
+}
+
+void HWTeam::GetFromPage(HWForm * hwform)
+{
+ TeamName = hwform->TeamNameEdit->text();
+ for(int i = 0; i < 8; i++)
+ {
+ HHName[i] = hwform->HHNameEdit[i]->text();
+ }
+
+ Grave = hwform->ui.CBGrave->currentText();
+ Fort = hwform->ui.CBFort->currentText();
+ for(int i = 0; i < 8; i++)
+ {
+ binds[i].strbind = hwform->CBBind[i]->currentText();
+ }
+}
+
+void HWTeam::SetCfgDir(const QString & dir)
+{
+ this->dir = dir;
+}