# HG changeset patch # User unc0rr # Date 1187632179 0 # Node ID 94db15de0392f135197602bf35205a8fef87b260 # Parent 6b0af3860192df7c8e893c94456f58a34dc25283 - Some changes to make build process clear - There could be 1-8 hedgehogs (was 3-8) in team - Start implementing 'Load' page diff -r 6b0af3860192 -r 94db15de0392 QTfrontend/CMakeLists.txt --- a/QTfrontend/CMakeLists.txt Mon Aug 20 16:05:59 2007 +0000 +++ b/QTfrontend/CMakeLists.txt Mon Aug 20 17:49:39 2007 +0000 @@ -33,10 +33,8 @@ endif(DEFINED DATA_INSTALL_DIR) endif(WIN32 AND NOT UNIX) -configure_file(${hedgewars_SOURCE_DIR}/QTfrontend/main.cpp.in - ${hedgewars_SOURCE_DIR}/QTfrontend/main.cpp) -configure_file(${hedgewars_SOURCE_DIR}/QTfrontend/hwconsts.h.in - ${hedgewars_SOURCE_DIR}/QTfrontend/hwconsts.h) +configure_file(${hedgewars_SOURCE_DIR}/QTfrontend/hwconsts.cpp.in + ${hedgewars_SOURCE_DIR}/QTfrontend/hwconsts.cpp) set(hwfr_src game.cpp @@ -66,7 +64,9 @@ netudpwidget.cpp chatwidget.cpp binds.cpp - SDLs.cpp) + SDLs.cpp + playrecordpage.cpp + hwconsts.cpp) if (WIN32) set(hwfr_src ${hwfr_src} res/hedgewars.rc) @@ -96,13 +96,15 @@ netudpserver.h netudpwidget.h chatwidget.h - SDLs.h) + SDLs.h + playrecordpage.h) set(hwfr_hdrs binds.h ui_hwform.h predefteams.h KB.h + hwconsts.h ) set(hwfr_rez diff -r 6b0af3860192 -r 94db15de0392 QTfrontend/hedgehogerWidget.cpp --- a/QTfrontend/hedgehogerWidget.cpp Mon Aug 20 16:05:59 2007 +0000 +++ b/QTfrontend/hedgehogerWidget.cpp Mon Aug 20 17:49:39 2007 +0000 @@ -57,7 +57,7 @@ } } else if (event->button()==Qt::RightButton) { event->accept(); - if(numHedgehogs > 3) { + if(numHedgehogs > 1) { numHedgehogs--; pOurFrameTeams->overallHedgehogs--; emit hedgehogsNumChanged(); diff -r 6b0af3860192 -r 94db15de0392 QTfrontend/hedgewars.pro --- a/QTfrontend/hedgewars.pro Mon Aug 20 16:05:59 2007 +0000 +++ b/QTfrontend/hedgewars.pro Mon Aug 20 17:49:39 2007 +0000 @@ -39,7 +39,9 @@ netudpserver.h \ netudpwidget.h \ chatwidget.h \ - SDLs.h + SDLs.h \ + playrecordpage.h \ + hwconsts.h SOURCES += binds.cpp \ @@ -69,7 +71,9 @@ netudpserver.cpp \ netudpwidget.cpp \ chatwidget.cpp \ - SDLs.cpp + SDLs.cpp \ + playrecordpage.cpp \ + hwconsts.cpp TRANSLATIONS += ../share/hedgewars/Data/Locale/hedgewars_ru.ts diff -r 6b0af3860192 -r 94db15de0392 QTfrontend/hwconsts.cpp.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/hwconsts.cpp.in Mon Aug 20 17:49:39 2007 +0000 @@ -0,0 +1,28 @@ +/* + * Hedgewars, a worms-like game + * Copyright (c) 2007 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 "hwconsts.h" + +QString * cProtoVer = new QString("${HEDGEWARS_PROTO_VER}"); +QString * cDataDir = new QString("${HEDGEWARS_DATADIR}"); + +QDir * bindir = new QDir("${HEDGEWARS_BINDIR}"); +QDir * cfgdir = new QDir(); +QDir * datadir = new QDir(); + +QStringList * Themes; diff -r 6b0af3860192 -r 94db15de0392 QTfrontend/hwconsts.h.in --- a/QTfrontend/hwconsts.h.in Mon Aug 20 16:05:59 2007 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -/* - * Hedgewars, a worms-like game - * Copyright (c) 2005-2007 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 -#include - -extern QDir * cfgdir; -extern QDir * datadir; -extern QDir * bindir; -extern QStringList * Themes; - -const QString cProtoVer("${HEDGEWARS_PROTO_VER}"); diff -r 6b0af3860192 -r 94db15de0392 QTfrontend/hwform.cpp --- a/QTfrontend/hwform.cpp Mon Aug 20 16:05:59 2007 +0000 +++ b/QTfrontend/hwform.cpp Mon Aug 20 17:49:39 2007 +0000 @@ -43,6 +43,7 @@ #include "netudpserver.h" #include "netudpwidget.h" #include "chatwidget.h" +#include "playrecordpage.h" HWForm::HWForm(QWidget *parent) : QMainWindow(parent), pnetserver(0), pUdpServer(0), editedTeam(0) @@ -56,6 +57,7 @@ connect(ui.pageMain->BtnSinglePlayer, SIGNAL(clicked()), this, SLOT(GoToSinglePlayer())); connect(ui.pageMain->BtnSetup, SIGNAL(clicked()), this, SLOT(GoToSetup())); connect(ui.pageMain->BtnMultiplayer, SIGNAL(clicked()), this, SLOT(GoToMultiplayer())); + connect(ui.pageMain->BtnLoad, SIGNAL(clicked()), this, SLOT(GoToSaves())); connect(ui.pageMain->BtnDemos, SIGNAL(clicked()), this, SLOT(GoToDemos())); connect(ui.pageMain->BtnNet, SIGNAL(clicked()), this, SLOT(GoToNet())); connect(ui.pageMain->BtnInfo, SIGNAL(clicked()), this, SLOT(GoToInfo())); @@ -149,15 +151,23 @@ GoToPage(ID_PAGE_MULTIPLAYER); } +void HWForm::GoToSaves() +{ + QDir tmpdir; + tmpdir.cd(cfgdir->absolutePath()); + tmpdir.cd("Saves"); + ui.pagePlayDemo->FillFromDir(tmpdir); + + GoToPage(ID_PAGE_DEMOS); +} + void HWForm::GoToDemos() { QDir tmpdir; tmpdir.cd(cfgdir->absolutePath()); tmpdir.cd("Demos"); - tmpdir.setFilter(QDir::Files); - ui.pagePlayDemo->DemosList->clear(); - ui.pagePlayDemo->DemosList->addItems(tmpdir.entryList(QStringList("*.hwd_" + cProtoVer)) - .replaceInStrings(QRegExp("^(.*).hwd_" + cProtoVer), "\\1")); + ui.pagePlayDemo->FillFromDir(tmpdir); + GoToPage(ID_PAGE_DEMOS); } @@ -298,7 +308,7 @@ return ; } CreateGame(0, 0); - game->PlayDemo(cfgdir->absolutePath() + "/Demos/" + curritem->text() + ".hwd_" + cProtoVer); + game->PlayDemo(cfgdir->absolutePath() + "/Demos/" + curritem->text() + ".hwd_" + *cProtoVer); } void HWForm::NetConnectServer() @@ -500,12 +510,12 @@ { demo.replace(QByteArray("\x02TL"), QByteArray("\x02TD")); demo.replace(QByteArray("\x02TN"), QByteArray("\x02TD")); - filename = cfgdir->absolutePath() + "/Demos/LastRound.hwd_" + cProtoVer; + filename = cfgdir->absolutePath() + "/Demos/LastRound.hwd_" + *cProtoVer; } else { demo.replace(QByteArray("\x02TL"), QByteArray("\x02TS")); demo.replace(QByteArray("\x02TN"), QByteArray("\x02TS")); - filename = cfgdir->absolutePath() + "/Saves/LastRound.hws_" + cProtoVer; + filename = cfgdir->absolutePath() + "/Saves/LastRound.hws_" + *cProtoVer; } diff -r 6b0af3860192 -r 94db15de0392 QTfrontend/hwform.h --- a/QTfrontend/hwform.h Mon Aug 20 16:05:59 2007 +0000 +++ b/QTfrontend/hwform.h Mon Aug 20 17:49:39 2007 +0000 @@ -46,6 +46,7 @@ void GoToSinglePlayer(); void GoToSetup(); void GoToMultiplayer(); + void GoToSaves(); void GoToDemos(); void GoToNet(); void GoToInfo(); diff -r 6b0af3860192 -r 94db15de0392 QTfrontend/main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/main.cpp Mon Aug 20 17:49:39 2007 +0000 @@ -0,0 +1,95 @@ +/* + * Hedgewars, a worms-like game + * Copyright (c) 2005-2007 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 +#include +#include +#include +#include +#include +#include +#include "hwform.h" +#include "hwconsts.h" + +bool checkForDir(const QString & dir) +{ + QDir tmpdir; + if (!tmpdir.exists(dir)) + if (!tmpdir.mkdir(dir)) + { + QMessageBox::critical(0, + QObject::tr("Error"), + QObject::tr("Cannot create directory %1").arg(dir), + QObject::tr("OK")); + return false; + } + return true; +} + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + QDateTime now = QDateTime::currentDateTime(); + QDateTime zero; + srand(now.secsTo(zero)); + + Q_INIT_RESOURCE(hedgewars); + + bindir->cd("bin"); // workaround over NSIS installer + + cfgdir->setPath(cfgdir->homePath()); + if (checkForDir(cfgdir->absolutePath() + "/.hedgewars")) + { + checkForDir(cfgdir->absolutePath() + "/.hedgewars/Demos"); + checkForDir(cfgdir->absolutePath() + "/.hedgewars/Saves"); + } + cfgdir->cd(".hedgewars"); + + datadir->cd(bindir->absolutePath()); + datadir->cd(*cDataDir); + if(!datadir->cd("hedgewars/Data")) { + QMessageBox::critical(0, QMessageBox::tr("Error"), + QMessageBox::tr("Failed to open data directory:\n%1\n" + "Please check your installation"). + arg(datadir->absolutePath()+"/hedgewars/Data")); + return 1; + } + + QTranslator Translator; + Translator.load(datadir->absolutePath() + "/Locale/hedgewars_" + QLocale::system().name()); + app.installTranslator(&Translator); + + Themes = new QStringList(); + QFile themesfile(datadir->absolutePath() + "/Themes/themes.cfg"); + if (themesfile.open(QIODevice::ReadOnly)) { + QTextStream stream(&themesfile); + QString str; + while (!stream.atEnd()) + { + Themes->append(stream.readLine()); + } + themesfile.close(); + } else { + QMessageBox::critical(0, "Error", "Cannot access themes.cfg", "OK"); + } + + HWForm *Form = new HWForm(); + Form->show(); + return app.exec(); +} diff -r 6b0af3860192 -r 94db15de0392 QTfrontend/pages.cpp --- a/QTfrontend/pages.cpp Mon Aug 20 16:05:59 2007 +0000 +++ b/QTfrontend/pages.cpp Mon Aug 20 17:49:39 2007 +0000 @@ -42,6 +42,7 @@ #include "netudpwidget.h" #include "chatwidget.h" #include "SDLs.h" +#include "playrecordpage.h" PageMain::PageMain(QWidget* parent) : QWidget(parent) { @@ -70,23 +71,29 @@ BtnNet->setText(QPushButton::tr("Net game")); pageLayout->addWidget(BtnNet, 3, 1); + BtnLoad = new QPushButton(this); + BtnLoad->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + BtnLoad->setFont(*font14); + BtnLoad->setText(QPushButton::tr("Load")); + pageLayout->addWidget(BtnLoad, 4, 1); + BtnDemos = new QPushButton(this); BtnDemos->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); BtnDemos->setFont(*font14); BtnDemos->setText(QPushButton::tr("Demos")); - pageLayout->addWidget(BtnDemos, 4, 1); + pageLayout->addWidget(BtnDemos, 5, 1); BtnSetup = new QPushButton(this); BtnSetup->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); BtnSetup->setFont(*font14); BtnSetup->setText(QPushButton::tr("Setup")); - pageLayout->addWidget(BtnSetup, 5, 1); + pageLayout->addWidget(BtnSetup, 6, 1); BtnInfo = new QPushButton(this); BtnInfo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); BtnInfo->setFont(*font14); BtnInfo->setText(QPushButton::tr("About")); - pageLayout->addWidget(BtnInfo, 6, 1); + pageLayout->addWidget(BtnInfo, 7, 1); BtnExit = new QPushButton(parent); BtnExit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); @@ -306,30 +313,6 @@ pageLayout->addWidget(BtnStartMPGame, 1, 3); } -PagePlayDemo::PagePlayDemo(QWidget* parent) : QWidget(parent) -{ - QFont * font14 = new QFont("MS Shell Dlg", 14); - QGridLayout * pageLayout = new QGridLayout(this); - pageLayout->setColumnStretch(0, 1); - pageLayout->setColumnStretch(1, 2); - pageLayout->setColumnStretch(2, 1); - - BtnBack = new QPushButton(this); - BtnBack->setFont(*font14); - BtnBack->setText(QPushButton::tr("Back")); - pageLayout->addWidget(BtnBack, 1, 0); - - BtnPlayDemo = new QPushButton(this); - BtnPlayDemo->setGeometry(QRect(240, 330, 161, 41)); - BtnPlayDemo->setFont(*font14); - BtnPlayDemo->setText(QPushButton::tr("Play demo")); - pageLayout->addWidget(BtnPlayDemo, 1, 2); - - DemosList = new QListWidget(this); - DemosList->setGeometry(QRect(170, 10, 311, 311)); - pageLayout->addWidget(DemosList, 0, 1); -} - PageOptions::PageOptions(QWidget* parent) : QWidget(parent) { QFont * font14 = new QFont("MS Shell Dlg", 14); diff -r 6b0af3860192 -r 94db15de0392 QTfrontend/pages.h --- a/QTfrontend/pages.h Mon Aug 20 16:05:59 2007 +0000 +++ b/QTfrontend/pages.h Mon Aug 20 17:49:39 2007 +0000 @@ -54,6 +54,7 @@ QPushButton *BtnMultiplayer; QPushButton *BtnNet; QPushButton *BtnSetup; + QPushButton *BtnLoad; QPushButton *BtnDemos; QPushButton *BtnInfo; QPushButton *BtnExit; @@ -122,18 +123,6 @@ QPushButton *BtnStartMPGame; }; -class PagePlayDemo : public QWidget -{ - Q_OBJECT - -public: - PagePlayDemo(QWidget* parent = 0); - - QPushButton *BtnBack; - QPushButton *BtnPlayDemo; - QListWidget *DemosList; -}; - class PageOptions : public QWidget { Q_OBJECT diff -r 6b0af3860192 -r 94db15de0392 QTfrontend/playrecordpage.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/playrecordpage.cpp Mon Aug 20 17:49:39 2007 +0000 @@ -0,0 +1,59 @@ +/* + * Hedgewars, a worms-like game + * Copyright (c) 2006, 2007 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 +#include +#include +#include + +#include "hwconsts.h" +#include "playrecordpage.h" + +PagePlayDemo::PagePlayDemo(QWidget* parent) : QWidget(parent) +{ + QFont * font14 = new QFont("MS Shell Dlg", 14); + QGridLayout * pageLayout = new QGridLayout(this); + pageLayout->setColumnStretch(0, 1); + pageLayout->setColumnStretch(1, 2); + pageLayout->setColumnStretch(2, 1); + + BtnBack = new QPushButton(this); + BtnBack->setFont(*font14); + BtnBack->setText(QPushButton::tr("Back")); + pageLayout->addWidget(BtnBack, 1, 0); + + BtnPlayDemo = new QPushButton(this); + BtnPlayDemo->setGeometry(QRect(240, 330, 161, 41)); + BtnPlayDemo->setFont(*font14); + BtnPlayDemo->setText(QPushButton::tr("Play demo")); + pageLayout->addWidget(BtnPlayDemo, 1, 2); + + DemosList = new QListWidget(this); + DemosList->setGeometry(QRect(170, 10, 311, 311)); + pageLayout->addWidget(DemosList, 0, 1); +} + +void PagePlayDemo::FillFromDir(QDir dir) +{ + dir.setFilter(QDir::Files); + DemosList->clear(); + DemosList->addItems(dir.entryList(QStringList("*.hwd_" + *cProtoVer)) + .replaceInStrings(QRegExp("^(.*).hwd_" + *cProtoVer + "$"), "\\1")); + +} + diff -r 6b0af3860192 -r 94db15de0392 QTfrontend/playrecordpage.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/playrecordpage.h Mon Aug 20 17:49:39 2007 +0000 @@ -0,0 +1,43 @@ +/* + * Hedgewars, a worms-like game + * Copyright (c) 2006, 2007 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 PLAYRECORDPAGE_H +#define PLAYRECORDPAGE_H + +#include +#include + +class QPushButton; +class QListWidget; + +class PagePlayDemo : public QWidget +{ + Q_OBJECT + +public: + PagePlayDemo(QWidget* parent = 0); + + void FillFromDir(QDir dir); + + QPushButton *BtnBack; + QPushButton *BtnPlayDemo; + QListWidget *DemosList; +}; + + +#endif // PLAYRECORDPAGE_H diff -r 6b0af3860192 -r 94db15de0392 QTfrontend/ui_hwform.cpp --- a/QTfrontend/ui_hwform.cpp Mon Aug 20 16:05:59 2007 +0000 +++ b/QTfrontend/ui_hwform.cpp Mon Aug 20 17:49:39 2007 +0000 @@ -23,6 +23,7 @@ #include "ui_hwform.h" #include "pages.h" +#include "playrecordpage.h" void Ui_HWForm::setupUi(QMainWindow *HWForm) {