# HG changeset patch # User unc0rr # Date 1160067729 0 # Node ID f97a7a3dc8f6f9c65ad7fc5f200924898d0b2a89 # Parent 57c2ef19f7192eafc83b06f28303a74982d01350 - Update more headers - set svn:eol-style to native diff -r 57c2ef19f719 -r f97a7a3dc8f6 CMakeLists.txt --- a/CMakeLists.txt Thu Oct 05 16:33:18 2006 +0000 +++ b/CMakeLists.txt Thu Oct 05 17:02:09 2006 +0000 @@ -1,36 +1,36 @@ -project(hedgewars) - -cmake_minimum_required(VERSION 2.4.0) - -set(SHAREPATH share/hedgewars/) - -add_subdirectory(QTfrontend) -add_subdirectory(hedgewars) -add_subdirectory(share) - -if(WIN32 AND NOT UNIX) - add_subdirectory(bin) -endif(WIN32 AND NOT UNIX) - -set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Hedgewars, a turn-based strategy") -set(CPACK_PACKAGE_VENDOR "Hedgewars") -set(CPACK_PACKAGE_VERSION_MAJOR "0") -set(CPACK_PACKAGE_VERSION_MINOR "2") -set(CPACK_PACKAGE_VERSION_PATCH "0") -set(CPACK_PACKAGE_FILE_NAME "hedgewars-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") -set(CPACK_PACKAGE_EXECUTABLES "hedgewars" "hwengine") -#set(CPACK_RESOURCE_FILE_LICENSE "COPYING.txt") - -if(WIN32 AND NOT UNIX) - set(CPACK_NSIS_DISPLAY_NAME "Hedgewars, a cross-platform, open-source turn-based Worms-like strategy") - set(CPACK_NSIS_HELP_LINK "http://www.hedgewars.org/") - set(CPACK_NSIS_URL_INFO_ABOUT "http://www.hedgewars.org/") - set(CPACK_NSIS_CONTACT "unC0Rr@gmail.com") - set(CPACK_NSIS_MODIFY_PATH ON) - set(CPACK_PACKAGE_EXECUTABLES "hedgewars" "hedgewars") -else(WIN32 AND NOT UNIX) - set(CPACK_STRIP_FILES "bin/hedgewars;bin/hwengine") -endif(WIN32 AND NOT UNIX) - -include(CPack) - +project(hedgewars) + +cmake_minimum_required(VERSION 2.4.0) + +set(SHAREPATH share/hedgewars/) + +add_subdirectory(QTfrontend) +add_subdirectory(hedgewars) +add_subdirectory(share) + +if(WIN32 AND NOT UNIX) + add_subdirectory(bin) +endif(WIN32 AND NOT UNIX) + +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Hedgewars, a turn-based strategy") +set(CPACK_PACKAGE_VENDOR "Hedgewars") +set(CPACK_PACKAGE_VERSION_MAJOR "0") +set(CPACK_PACKAGE_VERSION_MINOR "2") +set(CPACK_PACKAGE_VERSION_PATCH "0") +set(CPACK_PACKAGE_FILE_NAME "hedgewars-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") +set(CPACK_PACKAGE_EXECUTABLES "hedgewars" "hwengine") +#set(CPACK_RESOURCE_FILE_LICENSE "COPYING.txt") + +if(WIN32 AND NOT UNIX) + set(CPACK_NSIS_DISPLAY_NAME "Hedgewars, a cross-platform, open-source turn-based Worms-like strategy") + set(CPACK_NSIS_HELP_LINK "http://www.hedgewars.org/") + set(CPACK_NSIS_URL_INFO_ABOUT "http://www.hedgewars.org/") + set(CPACK_NSIS_CONTACT "unC0Rr@gmail.com") + set(CPACK_NSIS_MODIFY_PATH ON) + set(CPACK_PACKAGE_EXECUTABLES "hedgewars" "hedgewars") +else(WIN32 AND NOT UNIX) + set(CPACK_STRIP_FILES "bin/hedgewars;bin/hwengine") +endif(WIN32 AND NOT UNIX) + +include(CPack) + diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/CMakeLists.txt --- a/QTfrontend/CMakeLists.txt Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/CMakeLists.txt Thu Oct 05 17:02:09 2006 +0000 @@ -1,91 +1,91 @@ -find_package(Qt4 REQUIRED) - -include_directories(${QT_INCLUDES} .) - -if(WIN32 AND NOT UNIX) - set(HEDGEWARS_BINDIR ".") -else(WIN32 AND NOT UNIX) - set(HEDGEWARS_BINDIR ${CMAKE_INSTALL_PREFIX}) -endif(WIN32 AND NOT UNIX) - -configure_file(${hedgewars_SOURCE_DIR}/QTfrontend/main.cpp.in - ${hedgewars_SOURCE_DIR}/QTfrontend/main.cpp) - -set(hwfr_src - game.cpp - main.cpp - hwform.cpp - team.cpp - netclient.cpp - teamselect.cpp - teamselhelper.cpp - frameTeam.cpp - vertScrollArea.cpp - gameuiconfig.cpp - ui_hwform.cpp - gamecfgwidget.cpp - pages.cpp - SquareLabel.cpp - hedgehogerWidget.cpp - hwmap.cpp - mapContainer.cpp - tcpBase.cpp) - -if (WIN32) - set(hwfr_src ${hwfr_src} res/hedgewars.rc) -endif (WIN32) - -set(hwfr_moc_hdrs - game.h - hwform.h - binds.h - netclient.h - teamselect.h - teamselhelper.h - frameTeam.h - vertScrollArea.h - gameuiconfig.h - ui_hwform.h - gamecfgwidget.h - predefteams.h - pages.h - SquareLabel.h - hedgehogerWidget.h - hwmap.h - mapContainer.h - tcpBase.h) - - -set(hwfr_rez - hedgewars.qrc) - -qt4_add_resources(hwfr_rez_src - ${hwfr_rez}) - -qt4_wrap_cpp(hwfr_moc_srcs - ${hwfr_moc_hdrs}) - -add_executable(hedgewars WIN32 - ${hwfr_src} - ${hwfr_moc_srcs} - ${hwfr_rez_src}) - -target_link_libraries(hedgewars - ${QT_QTCORE_LIBRARY} - ${QT_QTGUI_LIBRARY} - ${QT_QTNETWORK_LIBRARY} - ${QT_QTMAIN_LIBRARY}) - -install(PROGRAMS "hedgewars${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION bin) - - -if(WIN32 AND NOT UNIX) - string(REPLACE "\\" "/" QT_BIN_DIR $ENV{QTDIR}/bin) - - install(FILES - "${QT_BIN_DIR}/QtNetwork4.dll" - "${QT_BIN_DIR}/QtGui4.dll" - "${QT_BIN_DIR}/QtCore4.dll" - "${QT_BIN_DIR}/mingwm10.dll" - DESTINATION bin) -endif(WIN32 AND NOT UNIX) +find_package(Qt4 REQUIRED) + +include_directories(${QT_INCLUDES} .) + +if(WIN32 AND NOT UNIX) + set(HEDGEWARS_BINDIR ".") +else(WIN32 AND NOT UNIX) + set(HEDGEWARS_BINDIR ${CMAKE_INSTALL_PREFIX}) +endif(WIN32 AND NOT UNIX) + +configure_file(${hedgewars_SOURCE_DIR}/QTfrontend/main.cpp.in + ${hedgewars_SOURCE_DIR}/QTfrontend/main.cpp) + +set(hwfr_src + game.cpp + main.cpp + hwform.cpp + team.cpp + netclient.cpp + teamselect.cpp + teamselhelper.cpp + frameTeam.cpp + vertScrollArea.cpp + gameuiconfig.cpp + ui_hwform.cpp + gamecfgwidget.cpp + pages.cpp + SquareLabel.cpp + hedgehogerWidget.cpp + hwmap.cpp + mapContainer.cpp + tcpBase.cpp) + +if (WIN32) + set(hwfr_src ${hwfr_src} res/hedgewars.rc) +endif (WIN32) + +set(hwfr_moc_hdrs + game.h + hwform.h + binds.h + netclient.h + teamselect.h + teamselhelper.h + frameTeam.h + vertScrollArea.h + gameuiconfig.h + ui_hwform.h + gamecfgwidget.h + predefteams.h + pages.h + SquareLabel.h + hedgehogerWidget.h + hwmap.h + mapContainer.h + tcpBase.h) + + +set(hwfr_rez + hedgewars.qrc) + +qt4_add_resources(hwfr_rez_src + ${hwfr_rez}) + +qt4_wrap_cpp(hwfr_moc_srcs + ${hwfr_moc_hdrs}) + +add_executable(hedgewars WIN32 + ${hwfr_src} + ${hwfr_moc_srcs} + ${hwfr_rez_src}) + +target_link_libraries(hedgewars + ${QT_QTCORE_LIBRARY} + ${QT_QTGUI_LIBRARY} + ${QT_QTNETWORK_LIBRARY} + ${QT_QTMAIN_LIBRARY}) + +install(PROGRAMS "hedgewars${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION bin) + + +if(WIN32 AND NOT UNIX) + string(REPLACE "\\" "/" QT_BIN_DIR $ENV{QTDIR}/bin) + + install(FILES + "${QT_BIN_DIR}/QtNetwork4.dll" + "${QT_BIN_DIR}/QtGui4.dll" + "${QT_BIN_DIR}/QtCore4.dll" + "${QT_BIN_DIR}/mingwm10.dll" + DESTINATION bin) +endif(WIN32 AND NOT UNIX) diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/SquareLabel.cpp --- a/QTfrontend/SquareLabel.cpp Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/SquareLabel.cpp Thu Oct 05 17:02:09 2006 +0000 @@ -1,41 +1,41 @@ -/* - * 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 -#include -#include "SquareLabel.h" - -SquareLabel::SquareLabel(QWidget * parent) : - QLabel(parent) -{ - -} - -void SquareLabel::paintEvent(QPaintEvent * event) -{ - QPainter painter(this); - int pixsize; - if (width() > height()) { - pixsize = height(); - painter.translate((width() - pixsize) / 2, 0); - } else { - pixsize = width(); - painter.translate(0, (height() - pixsize) / 2); - } - painter.drawPixmap(0, 0, pixsize, pixsize, pixmap()->scaled(pixsize, pixsize, Qt::KeepAspectRatio)); -} +/* + * 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 +#include +#include "SquareLabel.h" + +SquareLabel::SquareLabel(QWidget * parent) : + QLabel(parent) +{ + +} + +void SquareLabel::paintEvent(QPaintEvent * event) +{ + QPainter painter(this); + int pixsize; + if (width() > height()) { + pixsize = height(); + painter.translate((width() - pixsize) / 2, 0); + } else { + pixsize = width(); + painter.translate(0, (height() - pixsize) / 2); + } + painter.drawPixmap(0, 0, pixsize, pixsize, pixmap()->scaled(pixsize, pixsize, Qt::KeepAspectRatio)); +} diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/SquareLabel.h --- a/QTfrontend/SquareLabel.h Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/SquareLabel.h Thu Oct 05 17:02:09 2006 +0000 @@ -1,35 +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 _SQUARELABEL_H -#define _SQUARELABEL_H - -#include - -class SquareLabel : public QLabel -{ - Q_OBJECT - -public: - SquareLabel(QWidget * parent = 0); - -protected: - virtual void paintEvent(QPaintEvent * event); -}; - -#endif // _SQUARELABEL_H +/* + * 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 _SQUARELABEL_H +#define _SQUARELABEL_H + +#include + +class SquareLabel : public QLabel +{ + Q_OBJECT + +public: + SquareLabel(QWidget * parent = 0); + +protected: + virtual void paintEvent(QPaintEvent * event); +}; + +#endif // _SQUARELABEL_H diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/binds.h --- a/QTfrontend/binds.h Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/binds.h Thu Oct 05 17:02:09 2006 +0000 @@ -1,68 +1,68 @@ -/* - * Hedgewars, a worms-like game - * Copyright (c) 2005, 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 BINDS_H -#define BINDS_H - -#include -#include - -#define BINDS_NUMBER 29 - -struct BindAction -{ - QString action; - QString strbind; - const char * name; - bool chwidget; -}; - -const BindAction cbinds[BINDS_NUMBER] = -{ - {"+up", "up", QT_TRANSLATE_NOOP("binds", "up"), false}, - {"+left", "left", QT_TRANSLATE_NOOP("binds", "left"), false}, - {"+right", "right", QT_TRANSLATE_NOOP("binds", "right"), false}, - {"+down", "down", QT_TRANSLATE_NOOP("binds", "down"), false}, - {"ljump", "return", QT_TRANSLATE_NOOP("binds", "jump"), false}, - {"hjump", "backspace", QT_TRANSLATE_NOOP("binds", "jump"), false}, - {"+attack", "space", QT_TRANSLATE_NOOP("binds", "attack"), false}, - {"put", "mousel", QT_TRANSLATE_NOOP("binds", "put"), false}, - {"switch", "tab", QT_TRANSLATE_NOOP("binds", "switch"), false}, - {"findhh", "h", QT_TRANSLATE_NOOP("binds", "find hedgehog"), true}, - {"ammomenu", "mouser", QT_TRANSLATE_NOOP("binds", "ammo menu"), false}, - {"slot 1", "f1", QT_TRANSLATE_NOOP("binds", "slot 1"), false}, - {"slot 2", "f2", QT_TRANSLATE_NOOP("binds", "slot 2"), false}, - {"slot 3", "f3", QT_TRANSLATE_NOOP("binds", "slot 3"), false}, - {"slot 4", "f4", QT_TRANSLATE_NOOP("binds", "slot 4"), false}, - {"slot 5", "f5", QT_TRANSLATE_NOOP("binds", "slot 5"), false}, - {"slot 6", "f6", QT_TRANSLATE_NOOP("binds", "slot 6"), false}, - {"slot 7", "f7", QT_TRANSLATE_NOOP("binds", "slot 7"), false}, - {"slot 8", "f8", QT_TRANSLATE_NOOP("binds", "slot 8"), true}, - {"timer 1", "1", QT_TRANSLATE_NOOP("binds", "timer 1 sec"), false}, - {"timer 2", "2", QT_TRANSLATE_NOOP("binds", "timer 2 sec"), false}, - {"timer 3", "3", QT_TRANSLATE_NOOP("binds", "timer 3 sec"), false}, - {"timer 4", "4", QT_TRANSLATE_NOOP("binds", "timer 4 sec"), false}, - {"timer 5", "5", QT_TRANSLATE_NOOP("binds", "timer 5 sec"), true}, - {"+voldown", "9", QT_TRANSLATE_NOOP("binds", "volume down"), false}, - {"+volup", "0", QT_TRANSLATE_NOOP("binds", "volume up"), false}, - {"fullscr", "f", QT_TRANSLATE_NOOP("binds", "change mode"), false}, - {"capture", "c", QT_TRANSLATE_NOOP("binds", "capture"), false}, - {"quit", "escape", QT_TRANSLATE_NOOP("binds", "quit"), true} -}; - -#endif // BINDS_H +/* + * Hedgewars, a worms-like game + * Copyright (c) 2005, 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 BINDS_H +#define BINDS_H + +#include +#include + +#define BINDS_NUMBER 29 + +struct BindAction +{ + QString action; + QString strbind; + const char * name; + bool chwidget; +}; + +const BindAction cbinds[BINDS_NUMBER] = +{ + {"+up", "up", QT_TRANSLATE_NOOP("binds", "up"), false}, + {"+left", "left", QT_TRANSLATE_NOOP("binds", "left"), false}, + {"+right", "right", QT_TRANSLATE_NOOP("binds", "right"), false}, + {"+down", "down", QT_TRANSLATE_NOOP("binds", "down"), false}, + {"ljump", "return", QT_TRANSLATE_NOOP("binds", "jump"), false}, + {"hjump", "backspace", QT_TRANSLATE_NOOP("binds", "jump"), false}, + {"+attack", "space", QT_TRANSLATE_NOOP("binds", "attack"), false}, + {"put", "mousel", QT_TRANSLATE_NOOP("binds", "put"), false}, + {"switch", "tab", QT_TRANSLATE_NOOP("binds", "switch"), false}, + {"findhh", "h", QT_TRANSLATE_NOOP("binds", "find hedgehog"), true}, + {"ammomenu", "mouser", QT_TRANSLATE_NOOP("binds", "ammo menu"), false}, + {"slot 1", "f1", QT_TRANSLATE_NOOP("binds", "slot 1"), false}, + {"slot 2", "f2", QT_TRANSLATE_NOOP("binds", "slot 2"), false}, + {"slot 3", "f3", QT_TRANSLATE_NOOP("binds", "slot 3"), false}, + {"slot 4", "f4", QT_TRANSLATE_NOOP("binds", "slot 4"), false}, + {"slot 5", "f5", QT_TRANSLATE_NOOP("binds", "slot 5"), false}, + {"slot 6", "f6", QT_TRANSLATE_NOOP("binds", "slot 6"), false}, + {"slot 7", "f7", QT_TRANSLATE_NOOP("binds", "slot 7"), false}, + {"slot 8", "f8", QT_TRANSLATE_NOOP("binds", "slot 8"), true}, + {"timer 1", "1", QT_TRANSLATE_NOOP("binds", "timer 1 sec"), false}, + {"timer 2", "2", QT_TRANSLATE_NOOP("binds", "timer 2 sec"), false}, + {"timer 3", "3", QT_TRANSLATE_NOOP("binds", "timer 3 sec"), false}, + {"timer 4", "4", QT_TRANSLATE_NOOP("binds", "timer 4 sec"), false}, + {"timer 5", "5", QT_TRANSLATE_NOOP("binds", "timer 5 sec"), true}, + {"+voldown", "9", QT_TRANSLATE_NOOP("binds", "volume down"), false}, + {"+volup", "0", QT_TRANSLATE_NOOP("binds", "volume up"), false}, + {"fullscr", "f", QT_TRANSLATE_NOOP("binds", "change mode"), false}, + {"capture", "c", QT_TRANSLATE_NOOP("binds", "capture"), false}, + {"quit", "escape", QT_TRANSLATE_NOOP("binds", "quit"), true} +}; + +#endif // BINDS_H diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/frameTeam.cpp --- a/QTfrontend/frameTeam.cpp Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/frameTeam.cpp Thu Oct 05 17:02:09 2006 +0000 @@ -1,61 +1,61 @@ -/* - * Hedgewars, a worms-like game - * Copyright (c) 2006 Ulyanov Igor - * - * 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 "frameTeam.h" -#include "teamselhelper.h" - -#include -#include - -using namespace std; - -FrameTeams::FrameTeams(QWidget* parent) : - QWidget(parent), maxHedgehogsPerGame(18), overallHedgehogs(0), mainLayout(this) -{ - mainLayout.setSpacing(1); -} - -void FrameTeams::addTeam(HWTeam team, bool willPlay) -{ - TeamShowWidget* pTeamShowWidget =new TeamShowWidget(team, willPlay, this); -// int hght=teamToWidget.empty() ? 0 : teamToWidget.begin()->second->size().height(); - teamToWidget.insert(make_pair(team, pTeamShowWidget)); - mainLayout.addWidget(pTeamShowWidget); - QResizeEvent* pevent=new QResizeEvent(parentWidget()->size(), parentWidget()->size()); - QCoreApplication::postEvent(parentWidget(), pevent); -} - -void FrameTeams::removeTeam(HWTeam team) -{ - tmapTeamToWidget::iterator it=teamToWidget.find(team); - mainLayout.removeWidget(it->second); - delete it->second; - teamToWidget.erase(team); -} - -QWidget* FrameTeams::getTeamWidget(HWTeam team) -{ - tmapTeamToWidget::iterator it=teamToWidget.find(team); - QWidget* ret = it!=teamToWidget.end() ? it->second : 0; - return ret; -} - -bool FrameTeams::isFullTeams() const -{ - return overallHedgehogs==maxHedgehogsPerGame; -} +/* + * Hedgewars, a worms-like game + * Copyright (c) 2006 Ulyanov Igor + * + * 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 "frameTeam.h" +#include "teamselhelper.h" + +#include +#include + +using namespace std; + +FrameTeams::FrameTeams(QWidget* parent) : + QWidget(parent), maxHedgehogsPerGame(18), overallHedgehogs(0), mainLayout(this) +{ + mainLayout.setSpacing(1); +} + +void FrameTeams::addTeam(HWTeam team, bool willPlay) +{ + TeamShowWidget* pTeamShowWidget =new TeamShowWidget(team, willPlay, this); +// int hght=teamToWidget.empty() ? 0 : teamToWidget.begin()->second->size().height(); + teamToWidget.insert(make_pair(team, pTeamShowWidget)); + mainLayout.addWidget(pTeamShowWidget); + QResizeEvent* pevent=new QResizeEvent(parentWidget()->size(), parentWidget()->size()); + QCoreApplication::postEvent(parentWidget(), pevent); +} + +void FrameTeams::removeTeam(HWTeam team) +{ + tmapTeamToWidget::iterator it=teamToWidget.find(team); + mainLayout.removeWidget(it->second); + delete it->second; + teamToWidget.erase(team); +} + +QWidget* FrameTeams::getTeamWidget(HWTeam team) +{ + tmapTeamToWidget::iterator it=teamToWidget.find(team); + QWidget* ret = it!=teamToWidget.end() ? it->second : 0; + return ret; +} + +bool FrameTeams::isFullTeams() const +{ + return overallHedgehogs==maxHedgehogsPerGame; +} diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/frameTeam.h --- a/QTfrontend/frameTeam.h Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/frameTeam.h Thu Oct 05 17:02:09 2006 +0000 @@ -2,33 +2,18 @@ * Hedgewars, a worms-like game * Copyright (c) 2006 Ulyanov Igor * - * 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: + * 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 * - * 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 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. * - * 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. + * 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 _FRAME_TEAM_INCLUDED diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/game.cpp --- a/QTfrontend/game.cpp Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/game.cpp Thu Oct 05 17:02:09 2006 +0000 @@ -1,281 +1,281 @@ -/* - * Hedgewars, a worms-like game - * Copyright (c) 2005, 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 -#include -#include -#include -#include -#include -#include -#include - -#include "game.h" -#include "hwconsts.h" -#include "gameuiconfig.h" -#include "gamecfgwidget.h" - -HWGame::HWGame(GameUIConfig * config, GameCFGWidget * gamecfg) : - TCPBase(true) -{ - this->config = config; - this->gamecfg = gamecfg; - TeamCount = 0; - seed = ""; -} - -void HWGame::onClientDisconnect() -{ - SaveDemo(cfgdir->absolutePath() + "/Demos/LastRound.hwd_1"); -} - -void HWGame::SendTeamConfig(int index) -{ - LocalCFG(teams[index]); -} - -void HWGame::SendConfig() -{ - SendIPC(QString("eseed %1").arg(seed).toAscii()); - SendIPC(QString("etheme %1").arg(config->GetRandomTheme()).toAscii()); - SendIPC("TL"); - SendIPC(QString("e$gmflags %1").arg(gamecfg->getGameFlags()).toAscii()); - - for (int i = 0; i < TeamCount; i++) - { - SendIPC("eaddteam"); - LocalCFG(teams[i]); - SendIPC(QString("ecolor %1").arg(65535 << i * 8).toAscii()); - for (int t = 0; t < hdNum[teams[i]]; t++) - SendIPC(QString("eadd hh%1 0").arg(t).toAscii()); - } -} - -void HWGame::SendQuickConfig() -{ - SendIPC(QString("eseed %1").arg(seed).toAscii()); - SendIPC(QString("etheme %1").arg(config->GetRandomTheme()).toAscii()); - SendIPC("TL"); - SendIPC(QString("e$gmflags %1").arg(gamecfg->getGameFlags()).toAscii()); - SendIPC("eaddteam"); - LocalCFG(0); - SendIPC("ecolor 65535"); - SendIPC("eadd hh0 0"); - SendIPC("eadd hh1 0"); - SendIPC("eadd hh2 0"); - SendIPC("eadd hh3 0"); - SendIPC("eaddteam"); - LocalCFG(2); - SendIPC("ecolor 16776960"); - SendIPC("eadd hh0 1"); - SendIPC("eadd hh1 1"); - SendIPC("eadd hh2 1"); - SendIPC("eadd hh3 1"); -} - -void HWGame::ParseMessage(const QByteArray & msg) -{ - switch(msg.data()[1]) { - case '?': { - if (gameType == gtNet) - emit SendNet(QByteArray("\x01""?")); - else - SendIPC("!"); - break; - } - case 'C': { - switch (gameType) { - case gtLocal: { - SendConfig(); - break; - } - case gtQLocal: { - SendQuickConfig(); - break; - } - case gtDemo: break; - case gtNet: { - SendIPC("TN"); - emit SendNet(QByteArray("\x01""C")); - break; - } - } - break; - } - case 'E': { - QMessageBox::critical(0, - "Hedgewars: error message", - QString().append(msg.mid(2)).left(msg.size() - 6), - QMessageBox::Ok, - QMessageBox::NoButton, - QMessageBox::NoButton); - return; - } - case '+': { - if (gameType == gtNet) - { - emit SendNet(msg); - } - break; - } - default: { - if (gameType == gtNet) - { - emit SendNet(msg); - } - demo->append(msg); - } - } -} - -void HWGame::FromNet(const QByteArray & msg) -{ - RawSendIPC(msg); -} - -void HWGame::onClientRead() -{ - quint8 msglen; - quint32 bufsize; - while (((bufsize = readbuffer.size()) > 0) && - ((msglen = readbuffer.data()[0]) < bufsize)) - { - QByteArray msg = readbuffer.left(msglen + 1); - readbuffer.remove(0, msglen + 1); - ParseMessage(msg); - } -} - -QStringList HWGame::setArguments() -{ - QStringList arguments; - arguments << resolutions[0][config->vid_Resolution()]; - arguments << resolutions[1][config->vid_Resolution()]; - arguments << "16"; - arguments << "46631"; - arguments << (config->vid_Fullscreen() ? "1" : "0"); - arguments << (config->isSoundEnabled() ? "1" : "0"); - arguments << tr("en.txt"); - arguments << "128"; - return arguments; -} - -void HWGame::AddTeam(const QString & teamname, unsigned char numHedgedogs) -{ - if (TeamCount == 5) return; - teams[TeamCount] = teamname; - TeamCount++; - hdNum[teamname]=numHedgedogs; -} - -void HWGame::SaveDemo(const QString & filename) -{ - demo->replace(QByteArray("\x02TL"), QByteArray("\x02TD")); - demo->replace(QByteArray("\x02TN"), QByteArray("\x02TD")); - - QFile demofile(filename); - if (!demofile.open(QIODevice::WriteOnly)) - { - QMessageBox::critical(0, - tr("Error"), - tr("Cannot save demo to file %1").arg(filename), - tr("Quit")); - return ; - } - 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(0, - tr("Error"), - tr("Cannot open demofile %1").arg(demofilename), - tr("Quit")); - return ; - } - - // read demo - QDataStream stream(&demofile); - char buf[512]; - int readbytes; - do - { - readbytes = stream.readRawData((char *)&buf, 512); - toSendBuf.append(QByteArray((char *)&buf, readbytes)); - //SendIPC(QByteArray((char *)&buf, readbytes)); - - } while (readbytes > 0); - demofile.close(); - - // run engine - demo = new QByteArray; - Start(); -} - -void HWGame::StartNet() -{ - gameType = gtNet; - demo = new QByteArray; - Start(); -} - -void HWGame::StartLocal() -{ - gameType = gtLocal; - if (TeamCount < 2) return; - seed = gamecfg->getCurrentSeed();//QUuid::createUuid().toString(); - demo = new QByteArray; - Start(); -} - -void HWGame::StartQuick() -{ - gameType = gtQLocal; - seed = gamecfg->getCurrentSeed();//QUuid::createUuid().toString(); - demo = new QByteArray; - Start(); -} - - -void HWGame::LocalCFG(const QString & teamname) -{ - HWTeam team(teamname); - if (!team.LoadFromFile()) { - QMessageBox::critical(0, - "Error", - QString("Cannot load team config ""%1""").arg(teamname), - QMessageBox::Ok, - QMessageBox::NoButton, - QMessageBox::NoButton); - return; - } - RawSendIPC(team.IPCTeamInfo()); -} - -void HWGame::LocalCFG(quint8 num) -{ - HWTeam team(num); - RawSendIPC(team.IPCTeamInfo()); -} +/* + * Hedgewars, a worms-like game + * Copyright (c) 2005, 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 +#include +#include +#include +#include +#include +#include +#include + +#include "game.h" +#include "hwconsts.h" +#include "gameuiconfig.h" +#include "gamecfgwidget.h" + +HWGame::HWGame(GameUIConfig * config, GameCFGWidget * gamecfg) : + TCPBase(true) +{ + this->config = config; + this->gamecfg = gamecfg; + TeamCount = 0; + seed = ""; +} + +void HWGame::onClientDisconnect() +{ + SaveDemo(cfgdir->absolutePath() + "/Demos/LastRound.hwd_1"); +} + +void HWGame::SendTeamConfig(int index) +{ + LocalCFG(teams[index]); +} + +void HWGame::SendConfig() +{ + SendIPC(QString("eseed %1").arg(seed).toAscii()); + SendIPC(QString("etheme %1").arg(config->GetRandomTheme()).toAscii()); + SendIPC("TL"); + SendIPC(QString("e$gmflags %1").arg(gamecfg->getGameFlags()).toAscii()); + + for (int i = 0; i < TeamCount; i++) + { + SendIPC("eaddteam"); + LocalCFG(teams[i]); + SendIPC(QString("ecolor %1").arg(65535 << i * 8).toAscii()); + for (int t = 0; t < hdNum[teams[i]]; t++) + SendIPC(QString("eadd hh%1 0").arg(t).toAscii()); + } +} + +void HWGame::SendQuickConfig() +{ + SendIPC(QString("eseed %1").arg(seed).toAscii()); + SendIPC(QString("etheme %1").arg(config->GetRandomTheme()).toAscii()); + SendIPC("TL"); + SendIPC(QString("e$gmflags %1").arg(gamecfg->getGameFlags()).toAscii()); + SendIPC("eaddteam"); + LocalCFG(0); + SendIPC("ecolor 65535"); + SendIPC("eadd hh0 0"); + SendIPC("eadd hh1 0"); + SendIPC("eadd hh2 0"); + SendIPC("eadd hh3 0"); + SendIPC("eaddteam"); + LocalCFG(2); + SendIPC("ecolor 16776960"); + SendIPC("eadd hh0 1"); + SendIPC("eadd hh1 1"); + SendIPC("eadd hh2 1"); + SendIPC("eadd hh3 1"); +} + +void HWGame::ParseMessage(const QByteArray & msg) +{ + switch(msg.data()[1]) { + case '?': { + if (gameType == gtNet) + emit SendNet(QByteArray("\x01""?")); + else + SendIPC("!"); + break; + } + case 'C': { + switch (gameType) { + case gtLocal: { + SendConfig(); + break; + } + case gtQLocal: { + SendQuickConfig(); + break; + } + case gtDemo: break; + case gtNet: { + SendIPC("TN"); + emit SendNet(QByteArray("\x01""C")); + break; + } + } + break; + } + case 'E': { + QMessageBox::critical(0, + "Hedgewars: error message", + QString().append(msg.mid(2)).left(msg.size() - 6), + QMessageBox::Ok, + QMessageBox::NoButton, + QMessageBox::NoButton); + return; + } + case '+': { + if (gameType == gtNet) + { + emit SendNet(msg); + } + break; + } + default: { + if (gameType == gtNet) + { + emit SendNet(msg); + } + demo->append(msg); + } + } +} + +void HWGame::FromNet(const QByteArray & msg) +{ + RawSendIPC(msg); +} + +void HWGame::onClientRead() +{ + quint8 msglen; + quint32 bufsize; + while (((bufsize = readbuffer.size()) > 0) && + ((msglen = readbuffer.data()[0]) < bufsize)) + { + QByteArray msg = readbuffer.left(msglen + 1); + readbuffer.remove(0, msglen + 1); + ParseMessage(msg); + } +} + +QStringList HWGame::setArguments() +{ + QStringList arguments; + arguments << resolutions[0][config->vid_Resolution()]; + arguments << resolutions[1][config->vid_Resolution()]; + arguments << "16"; + arguments << "46631"; + arguments << (config->vid_Fullscreen() ? "1" : "0"); + arguments << (config->isSoundEnabled() ? "1" : "0"); + arguments << tr("en.txt"); + arguments << "128"; + return arguments; +} + +void HWGame::AddTeam(const QString & teamname, unsigned char numHedgedogs) +{ + if (TeamCount == 5) return; + teams[TeamCount] = teamname; + TeamCount++; + hdNum[teamname]=numHedgedogs; +} + +void HWGame::SaveDemo(const QString & filename) +{ + demo->replace(QByteArray("\x02TL"), QByteArray("\x02TD")); + demo->replace(QByteArray("\x02TN"), QByteArray("\x02TD")); + + QFile demofile(filename); + if (!demofile.open(QIODevice::WriteOnly)) + { + QMessageBox::critical(0, + tr("Error"), + tr("Cannot save demo to file %1").arg(filename), + tr("Quit")); + return ; + } + 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(0, + tr("Error"), + tr("Cannot open demofile %1").arg(demofilename), + tr("Quit")); + return ; + } + + // read demo + QDataStream stream(&demofile); + char buf[512]; + int readbytes; + do + { + readbytes = stream.readRawData((char *)&buf, 512); + toSendBuf.append(QByteArray((char *)&buf, readbytes)); + //SendIPC(QByteArray((char *)&buf, readbytes)); + + } while (readbytes > 0); + demofile.close(); + + // run engine + demo = new QByteArray; + Start(); +} + +void HWGame::StartNet() +{ + gameType = gtNet; + demo = new QByteArray; + Start(); +} + +void HWGame::StartLocal() +{ + gameType = gtLocal; + if (TeamCount < 2) return; + seed = gamecfg->getCurrentSeed();//QUuid::createUuid().toString(); + demo = new QByteArray; + Start(); +} + +void HWGame::StartQuick() +{ + gameType = gtQLocal; + seed = gamecfg->getCurrentSeed();//QUuid::createUuid().toString(); + demo = new QByteArray; + Start(); +} + + +void HWGame::LocalCFG(const QString & teamname) +{ + HWTeam team(teamname); + if (!team.LoadFromFile()) { + QMessageBox::critical(0, + "Error", + QString("Cannot load team config ""%1""").arg(teamname), + QMessageBox::Ok, + QMessageBox::NoButton, + QMessageBox::NoButton); + return; + } + RawSendIPC(team.IPCTeamInfo()); +} + +void HWGame::LocalCFG(quint8 num) +{ + HWTeam team(num); + RawSendIPC(team.IPCTeamInfo()); +} diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/game.h --- a/QTfrontend/game.h Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/game.h Thu Oct 05 17:02:09 2006 +0000 @@ -1,81 +1,81 @@ -/* - * Hedgewars, a worms-like game - * Copyright (c) 2005, 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 GAME_H -#define GAME_H - -#include -#include -#include -#include "team.h" - -#include - -#include "tcpBase.h" - -class GameUIConfig; -class GameCFGWidget; - -class HWGame : public TCPBase -{ - Q_OBJECT -public: - HWGame(GameUIConfig * config, GameCFGWidget * gamecfg); - void AddTeam(const QString & team, unsigned char numHedgedogs); - void PlayDemo(const QString & demofilename); - void StartLocal(); - void StartQuick(); - void StartNet(); - - protected: - virtual QStringList setArguments(); - virtual void onClientRead(); - virtual void onClientDisconnect(); - -signals: - void SendNet(const QByteArray & msg); - -public slots: - void FromNet(const QByteArray & msg); - void LocalCFG(const QString & teamname); - void LocalCFG(quint8 num); - -private: - enum GameType { - gtLocal = 1, - gtQLocal = 2, - gtDemo = 3, - gtNet = 4 - }; - char msgbuf[MAXMSGCHARS]; - QString teams[5]; - std::map hdNum; - QString seed; - int TeamCount; - GameUIConfig * config; - GameCFGWidget * gamecfg; - GameType gameType; - - void SendConfig(); - void SendQuickConfig(); - void SendTeamConfig(int index); - void ParseMessage(const QByteArray & msg); - void SaveDemo(const QString & filename); -}; - -#endif +/* + * Hedgewars, a worms-like game + * Copyright (c) 2005, 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 GAME_H +#define GAME_H + +#include +#include +#include +#include "team.h" + +#include + +#include "tcpBase.h" + +class GameUIConfig; +class GameCFGWidget; + +class HWGame : public TCPBase +{ + Q_OBJECT +public: + HWGame(GameUIConfig * config, GameCFGWidget * gamecfg); + void AddTeam(const QString & team, unsigned char numHedgedogs); + void PlayDemo(const QString & demofilename); + void StartLocal(); + void StartQuick(); + void StartNet(); + + protected: + virtual QStringList setArguments(); + virtual void onClientRead(); + virtual void onClientDisconnect(); + +signals: + void SendNet(const QByteArray & msg); + +public slots: + void FromNet(const QByteArray & msg); + void LocalCFG(const QString & teamname); + void LocalCFG(quint8 num); + +private: + enum GameType { + gtLocal = 1, + gtQLocal = 2, + gtDemo = 3, + gtNet = 4 + }; + char msgbuf[MAXMSGCHARS]; + QString teams[5]; + std::map hdNum; + QString seed; + int TeamCount; + GameUIConfig * config; + GameCFGWidget * gamecfg; + GameType gameType; + + void SendConfig(); + void SendQuickConfig(); + void SendTeamConfig(int index); + void ParseMessage(const QByteArray & msg); + void SaveDemo(const QString & filename); +}; + +#endif diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/gamecfgwidget.cpp --- a/QTfrontend/gamecfgwidget.cpp Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/gamecfgwidget.cpp Thu Oct 05 17:02:09 2006 +0000 @@ -1,43 +1,43 @@ -/* - * 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 -#include "gamecfgwidget.h" - -GameCFGWidget::GameCFGWidget(QWidget* parent) : - QWidget(parent), mainLayout(this) -{ - CB_mode_Forts = new QCheckBox(this); - CB_mode_Forts->setText(QCheckBox::tr("Forts mode")); - mainLayout.addWidget(CB_mode_Forts); - pMapContainer=new HWMapContainer(this); - mainLayout.addWidget(pMapContainer, 80); -} - -quint32 GameCFGWidget::getGameFlags() -{ - quint32 result = 0; - if (CB_mode_Forts->isChecked()) - result |= 1; - return result; -} - -QString GameCFGWidget::getCurrentSeed() const -{ - return pMapContainer->getCurrentSeed(); -} +/* + * 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 +#include "gamecfgwidget.h" + +GameCFGWidget::GameCFGWidget(QWidget* parent) : + QWidget(parent), mainLayout(this) +{ + CB_mode_Forts = new QCheckBox(this); + CB_mode_Forts->setText(QCheckBox::tr("Forts mode")); + mainLayout.addWidget(CB_mode_Forts); + pMapContainer=new HWMapContainer(this); + mainLayout.addWidget(pMapContainer, 80); +} + +quint32 GameCFGWidget::getGameFlags() +{ + quint32 result = 0; + if (CB_mode_Forts->isChecked()) + result |= 1; + return result; +} + +QString GameCFGWidget::getCurrentSeed() const +{ + return pMapContainer->getCurrentSeed(); +} diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/gamecfgwidget.h --- a/QTfrontend/gamecfgwidget.h Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/gamecfgwidget.h Thu Oct 05 17:02:09 2006 +0000 @@ -1,45 +1,45 @@ -/* - * 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 GAMECONFIGWIDGET_H -#define GAMECONFIGWIDGET_H - -#include -#include -#include - -#include "mapContainer.h" - -class GameCFGWidget : public QWidget -{ - Q_OBJECT - -public: - GameCFGWidget(QWidget* parent=0); - quint32 getGameFlags(); - QString getCurrentSeed() const; - -private slots: - -private: - QCheckBox * CB_mode_Forts; - QVBoxLayout mainLayout; - HWMapContainer* pMapContainer; -}; - -#endif // GAMECONFIGWIDGET_H +/* + * 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 GAMECONFIGWIDGET_H +#define GAMECONFIGWIDGET_H + +#include +#include +#include + +#include "mapContainer.h" + +class GameCFGWidget : public QWidget +{ + Q_OBJECT + +public: + GameCFGWidget(QWidget* parent=0); + quint32 getGameFlags(); + QString getCurrentSeed() const; + +private slots: + +private: + QCheckBox * CB_mode_Forts; + QVBoxLayout mainLayout; + HWMapContainer* pMapContainer; +}; + +#endif // GAMECONFIGWIDGET_H diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/gameuiconfig.cpp --- a/QTfrontend/gameuiconfig.cpp Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/gameuiconfig.cpp Thu Oct 05 17:02:09 2006 +0000 @@ -1,131 +1,131 @@ -/* - * 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 -#include -#include "gameuiconfig.h" -#include "hwform.h" -#include "pages.h" -#include "hwconsts.h" - -GameUIConfig::GameUIConfig(HWForm * FormWidgets) - : QObject() -{ - Form = FormWidgets; - - 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.pageOptions->CBResolution->setCurrentIndex(str.mid(11).toLong()); - } else - if (str.startsWith("fullscreen ")) - { - Form->ui.pageOptions->CBFullscreen->setChecked(str.mid(11).toLong()); - } else - if (str.startsWith("sound ")) - { - Form->ui.pageOptions->CBEnableSound->setChecked(str.mid(6).toLong()); - } else - if (str.startsWith("nick ")) - { - Form->ui.pageNet->editNetNick->setText(str.mid(5)); - } else - if (str.startsWith("ip ")) - { - Form->ui.pageNet->editIP->setText(str.mid(3)); - } - } - settings.close(); - } - - QFile themesfile(datadir->absolutePath() + "/Themes/themes.cfg"); - if (themesfile.open(QIODevice::ReadOnly)) { - QTextStream stream(&themesfile); - QString str; - while (!stream.atEnd()) - { - Themes << stream.readLine(); - } - themesfile.close(); - } else { - QMessageBox::critical(0, "Error", "Cannot access themes.cfg", "OK"); - } -} - -QStringList GameUIConfig::GetTeamsList() -{ - QStringList teamslist = cfgdir->entryList(QStringList("*.cfg")); - QStringList cleanedList; - for (QStringList::Iterator it = teamslist.begin(); it != teamslist.end(); ++it ) { - QString tmpTeamStr=(*it).replace(QRegExp("^(.*).cfg$"), "\\1"); - cleanedList.push_back(tmpTeamStr); - } - return cleanedList; -} - -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.pageOptions->CBResolution->currentIndex() << endl; - stream << "fullscreen " << Form->ui.pageOptions->CBFullscreen->isChecked() << endl; - stream << "sound " << Form->ui.pageOptions->CBEnableSound->isChecked() << endl; - stream << "nick " << Form->ui.pageNet->editNetNick->text() << endl; - stream << "ip " << Form->ui.pageNet->editIP->text() << endl; - settings.close(); -} - -int GameUIConfig::vid_Resolution() -{ - return Form->ui.pageOptions->CBResolution->currentIndex(); -} - -bool GameUIConfig::vid_Fullscreen() -{ - return Form->ui.pageOptions->CBFullscreen->isChecked(); -} - -bool GameUIConfig::isSoundEnabled() -{ - return Form->ui.pageOptions->CBEnableSound->isChecked(); -} - -QString GameUIConfig::GetRandomTheme() -{ - return (Themes.size() > 0) ? Themes[rand() % Themes.size()] : QString("steel"); -} +/* + * 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 +#include +#include "gameuiconfig.h" +#include "hwform.h" +#include "pages.h" +#include "hwconsts.h" + +GameUIConfig::GameUIConfig(HWForm * FormWidgets) + : QObject() +{ + Form = FormWidgets; + + 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.pageOptions->CBResolution->setCurrentIndex(str.mid(11).toLong()); + } else + if (str.startsWith("fullscreen ")) + { + Form->ui.pageOptions->CBFullscreen->setChecked(str.mid(11).toLong()); + } else + if (str.startsWith("sound ")) + { + Form->ui.pageOptions->CBEnableSound->setChecked(str.mid(6).toLong()); + } else + if (str.startsWith("nick ")) + { + Form->ui.pageNet->editNetNick->setText(str.mid(5)); + } else + if (str.startsWith("ip ")) + { + Form->ui.pageNet->editIP->setText(str.mid(3)); + } + } + settings.close(); + } + + QFile themesfile(datadir->absolutePath() + "/Themes/themes.cfg"); + if (themesfile.open(QIODevice::ReadOnly)) { + QTextStream stream(&themesfile); + QString str; + while (!stream.atEnd()) + { + Themes << stream.readLine(); + } + themesfile.close(); + } else { + QMessageBox::critical(0, "Error", "Cannot access themes.cfg", "OK"); + } +} + +QStringList GameUIConfig::GetTeamsList() +{ + QStringList teamslist = cfgdir->entryList(QStringList("*.cfg")); + QStringList cleanedList; + for (QStringList::Iterator it = teamslist.begin(); it != teamslist.end(); ++it ) { + QString tmpTeamStr=(*it).replace(QRegExp("^(.*).cfg$"), "\\1"); + cleanedList.push_back(tmpTeamStr); + } + return cleanedList; +} + +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.pageOptions->CBResolution->currentIndex() << endl; + stream << "fullscreen " << Form->ui.pageOptions->CBFullscreen->isChecked() << endl; + stream << "sound " << Form->ui.pageOptions->CBEnableSound->isChecked() << endl; + stream << "nick " << Form->ui.pageNet->editNetNick->text() << endl; + stream << "ip " << Form->ui.pageNet->editIP->text() << endl; + settings.close(); +} + +int GameUIConfig::vid_Resolution() +{ + return Form->ui.pageOptions->CBResolution->currentIndex(); +} + +bool GameUIConfig::vid_Fullscreen() +{ + return Form->ui.pageOptions->CBFullscreen->isChecked(); +} + +bool GameUIConfig::isSoundEnabled() +{ + return Form->ui.pageOptions->CBEnableSound->isChecked(); +} + +QString GameUIConfig::GetRandomTheme() +{ + return (Themes.size() > 0) ? Themes[rand() % Themes.size()] : QString("steel"); +} diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/gameuiconfig.h --- a/QTfrontend/gameuiconfig.h Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/gameuiconfig.h Thu Oct 05 17:02:09 2006 +0000 @@ -1,50 +1,50 @@ -/* - * 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 GAMECONFIG_H -#define GAMECONFIG_H - -#include -#include -#include - -class HWForm; - -class GameUIConfig : public QObject -{ - Q_OBJECT - -public: - GameUIConfig(HWForm * FormWidgets); - QStringList GetTeamsList(); - int vid_Resolution(); - bool vid_Fullscreen(); - bool isSoundEnabled(); - QString GetRandomTheme(); - -private slots: - -public slots: - void SaveOptions(); - -private: - HWForm * Form; - QStringList Themes; -}; - -#endif +/* + * 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 GAMECONFIG_H +#define GAMECONFIG_H + +#include +#include +#include + +class HWForm; + +class GameUIConfig : public QObject +{ + Q_OBJECT + +public: + GameUIConfig(HWForm * FormWidgets); + QStringList GetTeamsList(); + int vid_Resolution(); + bool vid_Fullscreen(); + bool isSoundEnabled(); + QString GetRandomTheme(); + +private slots: + +public slots: + void SaveOptions(); + +private: + HWForm * Form; + QStringList Themes; +}; + +#endif diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/hedgehogerWidget.cpp --- a/QTfrontend/hedgehogerWidget.cpp Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/hedgehogerWidget.cpp Thu Oct 05 17:02:09 2006 +0000 @@ -1,79 +1,79 @@ -/* - * Hedgewars, a worms-like game - * Copyright (c) 2006 Ulyanov Igor - * - * 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 "hedgehogerWidget.h" - -#include -#include - -#include "frameTeam.h" - -CHedgehogerWidget::CHedgehogerWidget(QWidget * parent) : - QWidget(parent) -{ - if(parent) { - pOurFrameTeams=dynamic_cast(parent->parentWidget()); - } - if(pOurFrameTeams->overallHedgehogs+4>pOurFrameTeams->maxHedgehogsPerGame) { - numHedgehogs=pOurFrameTeams->maxHedgehogsPerGame-pOurFrameTeams->overallHedgehogs; - } else numHedgehogs=4; - pOurFrameTeams->overallHedgehogs+=numHedgehogs; -} - -CHedgehogerWidget::~CHedgehogerWidget() -{ - pOurFrameTeams->overallHedgehogs-=numHedgehogs; -} - -void CHedgehogerWidget::mousePressEvent ( QMouseEvent * event ) -{ - if(event->button()==Qt::LeftButton) { - event->accept(); - if(numHedgehogs < 8 && pOurFrameTeams->overallHedgehogs<18) { - numHedgehogs++; - pOurFrameTeams->overallHedgehogs++; - } - } else if (event->button()==Qt::RightButton) { - event->accept(); - if(numHedgehogs > 3) { - numHedgehogs--; - pOurFrameTeams->overallHedgehogs--; - } - } else { - event->ignore(); - return; - } - repaint(); -} - -void CHedgehogerWidget::paintEvent(QPaintEvent* event) -{ - QImage image(":/res/hh25x25.png"); - - QPainter painter(this); - - for(int i=0; i + * + * 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 "hedgehogerWidget.h" + +#include +#include + +#include "frameTeam.h" + +CHedgehogerWidget::CHedgehogerWidget(QWidget * parent) : + QWidget(parent) +{ + if(parent) { + pOurFrameTeams=dynamic_cast(parent->parentWidget()); + } + if(pOurFrameTeams->overallHedgehogs+4>pOurFrameTeams->maxHedgehogsPerGame) { + numHedgehogs=pOurFrameTeams->maxHedgehogsPerGame-pOurFrameTeams->overallHedgehogs; + } else numHedgehogs=4; + pOurFrameTeams->overallHedgehogs+=numHedgehogs; +} + +CHedgehogerWidget::~CHedgehogerWidget() +{ + pOurFrameTeams->overallHedgehogs-=numHedgehogs; +} + +void CHedgehogerWidget::mousePressEvent ( QMouseEvent * event ) +{ + if(event->button()==Qt::LeftButton) { + event->accept(); + if(numHedgehogs < 8 && pOurFrameTeams->overallHedgehogs<18) { + numHedgehogs++; + pOurFrameTeams->overallHedgehogs++; + } + } else if (event->button()==Qt::RightButton) { + event->accept(); + if(numHedgehogs > 3) { + numHedgehogs--; + pOurFrameTeams->overallHedgehogs--; + } + } else { + event->ignore(); + return; + } + repaint(); +} + +void CHedgehogerWidget::paintEvent(QPaintEvent* event) +{ + QImage image(":/res/hh25x25.png"); + + QPainter painter(this); + + for(int i=0; i * - * 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: + * 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 * - * 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 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. * - * 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. + * 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 _HEDGEHOGER_WIDGET diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/hwconsts.h --- a/QTfrontend/hwconsts.h Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/hwconsts.h Thu Oct 05 17:02:09 2006 +0000 @@ -1,29 +1,29 @@ -/* - * Hedgewars, a worms-like game - * Copyright (c) 2005, 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 - -const char resolutions[2][4][5] = -{ - {"640", "800", "1024", "1280"}, - {"480", "600", "768", "1024"} -}; - -extern QDir * cfgdir; -extern QDir * datadir; -extern QDir * bindir; +/* + * Hedgewars, a worms-like game + * Copyright (c) 2005, 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 + +const char resolutions[2][4][5] = +{ + {"640", "800", "1024", "1280"}, + {"480", "600", "768", "1024"} +}; + +extern QDir * cfgdir; +extern QDir * datadir; +extern QDir * bindir; diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/hwform.cpp --- a/QTfrontend/hwform.cpp Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/hwform.cpp Thu Oct 05 17:02:09 2006 +0000 @@ -1,251 +1,251 @@ -/* - * Hedgewars, a worms-like game - * Copyright (c) 2005, 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 -#include -#include -#include -#include -#include -#include -#include -#include - -#include "hwform.h" -#include "game.h" -#include "team.h" -#include "netclient.h" -#include "teamselect.h" -#include "gameuiconfig.h" -#include "pages.h" -#include "hwconsts.h" - -HWForm::HWForm(QWidget *parent) - : QMainWindow(parent) -{ - ui.setupUi(this); - - config = new GameUIConfig(this); - - QStringList teamslist = config->GetTeamsList(); - - if(teamslist.empty()) { - HWTeam defaultTeam("DefaultTeam"); - defaultTeam.SaveToFile(); - teamslist.push_back("DefaultTeam"); - } - - for (QStringList::Iterator it = teamslist.begin(); it != teamslist.end(); ++it ) - { - ui.pageMultiplayer->teamsSelect->addTeam(*it); - ui.pageOptions->CBTeamName->addItem(*it); - } - - 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->BtnDemos, SIGNAL(clicked()), this, SLOT(GoToDemos())); - connect(ui.pageMain->BtnNet, SIGNAL(clicked()), this, SLOT(GoToNet())); - connect(ui.pageMain->BtnExit, SIGNAL(clicked()), this, SLOT(close())); - - connect(ui.pageLocalGame->BtnBack, SIGNAL(clicked()), this, SLOT(GoToMain())); - connect(ui.pageLocalGame->BtnSimpleGame, SIGNAL(clicked()), this, SLOT(SimpleGame())); - - connect(ui.pageEditTeam->BtnTeamSave, SIGNAL(clicked()), this, SLOT(TeamSave())); - connect(ui.pageEditTeam->BtnTeamDiscard, SIGNAL(clicked()), this, SLOT(TeamDiscard())); - - connect(ui.pageMultiplayer->BtnBack, SIGNAL(clicked()), this, SLOT(GoToMain())); - connect(ui.pageMultiplayer->BtnStartMPGame, SIGNAL(clicked()), this, SLOT(StartMPGame())); - - connect(ui.pagePlayDemo->BtnBack, SIGNAL(clicked()), this, SLOT(GoToMain())); - connect(ui.pagePlayDemo->BtnPlayDemo, SIGNAL(clicked()), this, SLOT(PlayDemo())); - - connect(ui.pageOptions->BtnBack, SIGNAL(clicked()), this, SLOT(GoToMain())); - connect(ui.pageOptions->BtnNewTeam, SIGNAL(clicked()), this, SLOT(NewTeam())); - connect(ui.pageOptions->BtnEditTeam, SIGNAL(clicked()), this, SLOT(EditTeam())); - connect(ui.pageOptions->BtnSaveOptions, SIGNAL(clicked()), config, SLOT(SaveOptions())); - - connect(ui.pageNet->BtnBack, SIGNAL(clicked()), this, SLOT(GoToMain())); - connect(ui.pageNet->BtnNetConnect, SIGNAL(clicked()), this, SLOT(NetConnect())); - - connect(ui.pageNetGame->BtnBack, SIGNAL(clicked()), this, SLOT(GoToNetChat())); - connect(ui.pageNetGame->BtnAddTeam, SIGNAL(clicked()), this, SLOT(NetAddTeam())); - connect(ui.pageNetGame->BtnGo, SIGNAL(clicked()), this, SLOT(NetStartGame())); - - connect(ui.pageNetChat->BtnDisconnect, SIGNAL(clicked()), this, SLOT(NetDisconnect())); - connect(ui.pageNetChat->BtnJoin, SIGNAL(clicked()), this, SLOT(NetJoin())); - connect(ui.pageNetChat->BtnCreate, SIGNAL(clicked()), this, SLOT(NetCreate())); - - ui.Pages->setCurrentIndex(ID_PAGE_MAIN); -} - -void HWForm::GoToMain() -{ - ui.Pages->setCurrentIndex(ID_PAGE_MAIN); -} - -void HWForm::GoToSinglePlayer() -{ - ui.Pages->setCurrentIndex(ID_PAGE_SINGLEPLAYER); -} - -void HWForm::GoToSetup() -{ - ui.Pages->setCurrentIndex(ID_PAGE_SETUP); -} - -void HWForm::GoToMultiplayer() -{ - ui.pageMultiplayer->teamsSelect->resetPlayingTeams(config->GetTeamsList()); - ui.Pages->setCurrentIndex(ID_PAGE_MULTIPLAYER); -} - -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_1")).replaceInStrings(QRegExp("^(.*).hwd_1"), "\\1")); - ui.Pages->setCurrentIndex(ID_PAGE_DEMOS); -} - -void HWForm::GoToNet() -{ - ui.Pages->setCurrentIndex(ID_PAGE_NET); -} - -void HWForm::GoToNetChat() -{ - ui.Pages->setCurrentIndex(ID_PAGE_NETCHAT); -} - -void HWForm::NewTeam() -{ - tmpTeam = new HWTeam("unnamed"); - tmpTeam->SetToPage(this); - ui.Pages->setCurrentIndex(ID_PAGE_SETUP_TEAM); -} - -void HWForm::EditTeam() -{ - tmpTeam = new HWTeam(ui.pageOptions->CBTeamName->currentText()); - tmpTeam->LoadFromFile(); - tmpTeam->SetToPage(this); - ui.Pages->setCurrentIndex(ID_PAGE_SETUP_TEAM); -} - -void HWForm::TeamSave() -{ - tmpTeam->GetFromPage(this); - tmpTeam->SaveToFile(); - delete tmpTeam; - ui.Pages->setCurrentIndex(ID_PAGE_SETUP); -} - -void HWForm::TeamDiscard() -{ - ui.Pages->setCurrentIndex(ID_PAGE_SETUP); -} - -void HWForm::SimpleGame() -{ - game = new HWGame(config, ui.pageLocalGame->gameCFG); - game->StartQuick(); -} - -void HWForm::PlayDemo() -{ - QListWidgetItem * curritem = ui.pagePlayDemo->DemosList->currentItem(); - if (!curritem) - { - QMessageBox::critical(this, - tr("Error"), - tr("Please, select demo from the list above"), - tr("OK")); - return ; - } - game = new HWGame(config, 0); - game->PlayDemo(cfgdir->absolutePath() + "/Demos/" + curritem->text() + ".hwd_1"); -} - -void HWForm::NetConnect() -{ - hwnet = new HWNet(config); - connect(hwnet, SIGNAL(Connected()), this, SLOT(GoToNetChat())); - connect(hwnet, SIGNAL(AddGame(const QString &)), this, SLOT(AddGame(const QString &))); - connect(hwnet, SIGNAL(EnteredGame()), this, SLOT(NetGameEnter())); - connect(hwnet, SIGNAL(ChangeInTeams(const QStringList &)), this, SLOT(ChangeInNetTeams(const QStringList &))); - hwnet->Connect(ui.pageNet->editIP->text(), 6667, ui.pageNet->editNetNick->text()); - config->SaveOptions(); -} - -void HWForm::NetDisconnect() -{ - hwnet->Disconnect(); - GoToNet(); -} - -void HWForm::AddGame(const QString & chan) -{ - ui.pageNetChat->ChannelsList->addItem(chan); -} - -void HWForm::NetGameEnter() -{ - ui.Pages->setCurrentIndex(ID_PAGE_NETCFG); -} - -void HWForm::NetJoin() -{ - hwnet->JoinGame("#hw"); -} - -void HWForm::NetCreate() -{ - hwnet->JoinGame("#hw"); -} - -void HWForm::NetAddTeam() -{ - HWTeam team("DefaultTeam"); - team.LoadFromFile(); - hwnet->AddTeam(team); -} - -void HWForm::NetStartGame() -{ - hwnet->StartGame(); -} - -void HWForm::ChangeInNetTeams(const QStringList & teams) -{ - ui.pageNetGame->listNetTeams->clear(); - ui.pageNetGame->listNetTeams->addItems(teams); -} - -void HWForm::StartMPGame() -{ - game = new HWGame(config, ui.pageMultiplayer->gameCFG); - list teamslist=ui.pageMultiplayer->teamsSelect->getPlayingTeams(); - for (list::const_iterator it = teamslist.begin(); it != teamslist.end(); ++it ) { - game->AddTeam(it->TeamName, ui.pageMultiplayer->teamsSelect->numHedgedogs(it->TeamName)); - } - game->StartLocal(); -} +/* + * Hedgewars, a worms-like game + * Copyright (c) 2005, 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 +#include +#include +#include +#include +#include +#include +#include +#include + +#include "hwform.h" +#include "game.h" +#include "team.h" +#include "netclient.h" +#include "teamselect.h" +#include "gameuiconfig.h" +#include "pages.h" +#include "hwconsts.h" + +HWForm::HWForm(QWidget *parent) + : QMainWindow(parent) +{ + ui.setupUi(this); + + config = new GameUIConfig(this); + + QStringList teamslist = config->GetTeamsList(); + + if(teamslist.empty()) { + HWTeam defaultTeam("DefaultTeam"); + defaultTeam.SaveToFile(); + teamslist.push_back("DefaultTeam"); + } + + for (QStringList::Iterator it = teamslist.begin(); it != teamslist.end(); ++it ) + { + ui.pageMultiplayer->teamsSelect->addTeam(*it); + ui.pageOptions->CBTeamName->addItem(*it); + } + + 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->BtnDemos, SIGNAL(clicked()), this, SLOT(GoToDemos())); + connect(ui.pageMain->BtnNet, SIGNAL(clicked()), this, SLOT(GoToNet())); + connect(ui.pageMain->BtnExit, SIGNAL(clicked()), this, SLOT(close())); + + connect(ui.pageLocalGame->BtnBack, SIGNAL(clicked()), this, SLOT(GoToMain())); + connect(ui.pageLocalGame->BtnSimpleGame, SIGNAL(clicked()), this, SLOT(SimpleGame())); + + connect(ui.pageEditTeam->BtnTeamSave, SIGNAL(clicked()), this, SLOT(TeamSave())); + connect(ui.pageEditTeam->BtnTeamDiscard, SIGNAL(clicked()), this, SLOT(TeamDiscard())); + + connect(ui.pageMultiplayer->BtnBack, SIGNAL(clicked()), this, SLOT(GoToMain())); + connect(ui.pageMultiplayer->BtnStartMPGame, SIGNAL(clicked()), this, SLOT(StartMPGame())); + + connect(ui.pagePlayDemo->BtnBack, SIGNAL(clicked()), this, SLOT(GoToMain())); + connect(ui.pagePlayDemo->BtnPlayDemo, SIGNAL(clicked()), this, SLOT(PlayDemo())); + + connect(ui.pageOptions->BtnBack, SIGNAL(clicked()), this, SLOT(GoToMain())); + connect(ui.pageOptions->BtnNewTeam, SIGNAL(clicked()), this, SLOT(NewTeam())); + connect(ui.pageOptions->BtnEditTeam, SIGNAL(clicked()), this, SLOT(EditTeam())); + connect(ui.pageOptions->BtnSaveOptions, SIGNAL(clicked()), config, SLOT(SaveOptions())); + + connect(ui.pageNet->BtnBack, SIGNAL(clicked()), this, SLOT(GoToMain())); + connect(ui.pageNet->BtnNetConnect, SIGNAL(clicked()), this, SLOT(NetConnect())); + + connect(ui.pageNetGame->BtnBack, SIGNAL(clicked()), this, SLOT(GoToNetChat())); + connect(ui.pageNetGame->BtnAddTeam, SIGNAL(clicked()), this, SLOT(NetAddTeam())); + connect(ui.pageNetGame->BtnGo, SIGNAL(clicked()), this, SLOT(NetStartGame())); + + connect(ui.pageNetChat->BtnDisconnect, SIGNAL(clicked()), this, SLOT(NetDisconnect())); + connect(ui.pageNetChat->BtnJoin, SIGNAL(clicked()), this, SLOT(NetJoin())); + connect(ui.pageNetChat->BtnCreate, SIGNAL(clicked()), this, SLOT(NetCreate())); + + ui.Pages->setCurrentIndex(ID_PAGE_MAIN); +} + +void HWForm::GoToMain() +{ + ui.Pages->setCurrentIndex(ID_PAGE_MAIN); +} + +void HWForm::GoToSinglePlayer() +{ + ui.Pages->setCurrentIndex(ID_PAGE_SINGLEPLAYER); +} + +void HWForm::GoToSetup() +{ + ui.Pages->setCurrentIndex(ID_PAGE_SETUP); +} + +void HWForm::GoToMultiplayer() +{ + ui.pageMultiplayer->teamsSelect->resetPlayingTeams(config->GetTeamsList()); + ui.Pages->setCurrentIndex(ID_PAGE_MULTIPLAYER); +} + +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_1")).replaceInStrings(QRegExp("^(.*).hwd_1"), "\\1")); + ui.Pages->setCurrentIndex(ID_PAGE_DEMOS); +} + +void HWForm::GoToNet() +{ + ui.Pages->setCurrentIndex(ID_PAGE_NET); +} + +void HWForm::GoToNetChat() +{ + ui.Pages->setCurrentIndex(ID_PAGE_NETCHAT); +} + +void HWForm::NewTeam() +{ + tmpTeam = new HWTeam("unnamed"); + tmpTeam->SetToPage(this); + ui.Pages->setCurrentIndex(ID_PAGE_SETUP_TEAM); +} + +void HWForm::EditTeam() +{ + tmpTeam = new HWTeam(ui.pageOptions->CBTeamName->currentText()); + tmpTeam->LoadFromFile(); + tmpTeam->SetToPage(this); + ui.Pages->setCurrentIndex(ID_PAGE_SETUP_TEAM); +} + +void HWForm::TeamSave() +{ + tmpTeam->GetFromPage(this); + tmpTeam->SaveToFile(); + delete tmpTeam; + ui.Pages->setCurrentIndex(ID_PAGE_SETUP); +} + +void HWForm::TeamDiscard() +{ + ui.Pages->setCurrentIndex(ID_PAGE_SETUP); +} + +void HWForm::SimpleGame() +{ + game = new HWGame(config, ui.pageLocalGame->gameCFG); + game->StartQuick(); +} + +void HWForm::PlayDemo() +{ + QListWidgetItem * curritem = ui.pagePlayDemo->DemosList->currentItem(); + if (!curritem) + { + QMessageBox::critical(this, + tr("Error"), + tr("Please, select demo from the list above"), + tr("OK")); + return ; + } + game = new HWGame(config, 0); + game->PlayDemo(cfgdir->absolutePath() + "/Demos/" + curritem->text() + ".hwd_1"); +} + +void HWForm::NetConnect() +{ + hwnet = new HWNet(config); + connect(hwnet, SIGNAL(Connected()), this, SLOT(GoToNetChat())); + connect(hwnet, SIGNAL(AddGame(const QString &)), this, SLOT(AddGame(const QString &))); + connect(hwnet, SIGNAL(EnteredGame()), this, SLOT(NetGameEnter())); + connect(hwnet, SIGNAL(ChangeInTeams(const QStringList &)), this, SLOT(ChangeInNetTeams(const QStringList &))); + hwnet->Connect(ui.pageNet->editIP->text(), 6667, ui.pageNet->editNetNick->text()); + config->SaveOptions(); +} + +void HWForm::NetDisconnect() +{ + hwnet->Disconnect(); + GoToNet(); +} + +void HWForm::AddGame(const QString & chan) +{ + ui.pageNetChat->ChannelsList->addItem(chan); +} + +void HWForm::NetGameEnter() +{ + ui.Pages->setCurrentIndex(ID_PAGE_NETCFG); +} + +void HWForm::NetJoin() +{ + hwnet->JoinGame("#hw"); +} + +void HWForm::NetCreate() +{ + hwnet->JoinGame("#hw"); +} + +void HWForm::NetAddTeam() +{ + HWTeam team("DefaultTeam"); + team.LoadFromFile(); + hwnet->AddTeam(team); +} + +void HWForm::NetStartGame() +{ + hwnet->StartGame(); +} + +void HWForm::ChangeInNetTeams(const QStringList & teams) +{ + ui.pageNetGame->listNetTeams->clear(); + ui.pageNetGame->listNetTeams->addItems(teams); +} + +void HWForm::StartMPGame() +{ + game = new HWGame(config, ui.pageMultiplayer->gameCFG); + list teamslist=ui.pageMultiplayer->teamsSelect->getPlayingTeams(); + for (list::const_iterator it = teamslist.begin(); it != teamslist.end(); ++it ) { + game->AddTeam(it->TeamName, ui.pageMultiplayer->teamsSelect->numHedgedogs(it->TeamName)); + } + game->StartLocal(); +} diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/hwform.h --- a/QTfrontend/hwform.h Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/hwform.h Thu Oct 05 17:02:09 2006 +0000 @@ -1,83 +1,83 @@ -/* - * Hedgewars, a worms-like game - * Copyright (c) 2005, 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 HWFORM_H -#define HWFORM_H - -#include -#include -#include - -#include "ui_hwform.h" - -class HWGame; -class HWTeam; -class HWNet; -class GameUIConfig; - -class HWForm : public QMainWindow -{ - Q_OBJECT - -public: - HWForm(QWidget *parent = 0); - Ui_HWForm ui; - -private slots: - void GoToMain(); - void GoToSinglePlayer(); - void GoToSetup(); - void GoToMultiplayer(); - void GoToDemos(); - void GoToNet(); - void GoToNetChat(); - void NewTeam(); - void EditTeam(); - void TeamSave(); - void TeamDiscard(); - void SimpleGame(); - void PlayDemo(); - void NetConnect(); - void NetDisconnect(); - void NetJoin(); - void NetCreate(); - void AddGame(const QString & chan); - void NetAddTeam(); - void NetGameEnter(); - void NetStartGame(); - void ChangeInNetTeams(const QStringList & teams); - void StartMPGame(); - -private: - HWGame * game; - HWTeam * tmpTeam; - HWNet * hwnet; - GameUIConfig * config; -}; - -#define ID_PAGE_SINGLEPLAYER 0 -#define ID_PAGE_SETUP_TEAM 1 -#define ID_PAGE_SETUP 2 -#define ID_PAGE_MULTIPLAYER 3 -#define ID_PAGE_DEMOS 4 -#define ID_PAGE_NET 5 -#define ID_PAGE_NETCHAT 6 -#define ID_PAGE_NETCFG 7 -#define ID_PAGE_MAIN 8 - -#endif +/* + * Hedgewars, a worms-like game + * Copyright (c) 2005, 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 HWFORM_H +#define HWFORM_H + +#include +#include +#include + +#include "ui_hwform.h" + +class HWGame; +class HWTeam; +class HWNet; +class GameUIConfig; + +class HWForm : public QMainWindow +{ + Q_OBJECT + +public: + HWForm(QWidget *parent = 0); + Ui_HWForm ui; + +private slots: + void GoToMain(); + void GoToSinglePlayer(); + void GoToSetup(); + void GoToMultiplayer(); + void GoToDemos(); + void GoToNet(); + void GoToNetChat(); + void NewTeam(); + void EditTeam(); + void TeamSave(); + void TeamDiscard(); + void SimpleGame(); + void PlayDemo(); + void NetConnect(); + void NetDisconnect(); + void NetJoin(); + void NetCreate(); + void AddGame(const QString & chan); + void NetAddTeam(); + void NetGameEnter(); + void NetStartGame(); + void ChangeInNetTeams(const QStringList & teams); + void StartMPGame(); + +private: + HWGame * game; + HWTeam * tmpTeam; + HWNet * hwnet; + GameUIConfig * config; +}; + +#define ID_PAGE_SINGLEPLAYER 0 +#define ID_PAGE_SETUP_TEAM 1 +#define ID_PAGE_SETUP 2 +#define ID_PAGE_MULTIPLAYER 3 +#define ID_PAGE_DEMOS 4 +#define ID_PAGE_NET 5 +#define ID_PAGE_NETCHAT 6 +#define ID_PAGE_NETCFG 7 +#define ID_PAGE_MAIN 8 + +#endif diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/hwmap.cpp --- a/QTfrontend/hwmap.cpp Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/hwmap.cpp Thu Oct 05 17:02:09 2006 +0000 @@ -2,34 +2,18 @@ * Hedgewars, a worms-like game * Copyright (c) 2006 Igor Ulyanov * - * 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: + * 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 * - * 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 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. * - * 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. - */ + * 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 "hwmap.h" diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/hwmap.h --- a/QTfrontend/hwmap.h Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/hwmap.h Thu Oct 05 17:02:09 2006 +0000 @@ -2,33 +2,18 @@ * Hedgewars, a worms-like game * Copyright (c) 2006 Igor Ulyanov * - * 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: + * 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 * - * 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 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. * - * 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. + * 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 _HWMAP_INCLUDED diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/main.cpp --- a/QTfrontend/main.cpp Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/main.cpp Thu Oct 05 17:02:09 2006 +0000 @@ -1,80 +1,80 @@ -/* - * Hedgewars, a worms-like game - * Copyright (c) 2005, 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 -#include -#include -#include -#include -#include -#include "hwform.h" -#include "hwconsts.h" - -QDir * bindir; -QDir * cfgdir; -QDir * datadir; - -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); - - QTranslator Translator; - Translator.load(":/translations/hedgewars_" + QLocale::system().name()); - app.installTranslator(&Translator); - - QDir mydir("."); - mydir.cd("bin"); - - bindir = new QDir(mydir); - cfgdir = new QDir(); - - cfgdir->setPath(cfgdir->homePath()); - if (checkForDir(cfgdir->absolutePath() + "/.hedgewars")) - { - checkForDir(cfgdir->absolutePath() + "/.hedgewars/Demos"); - } - cfgdir->cd(".hedgewars"); - - datadir = new QDir(mydir); - datadir->cd("../share/hedgewars/Data"); - - HWForm *Form = new HWForm(); - Form->show(); - return app.exec(); -} +/* + * Hedgewars, a worms-like game + * Copyright (c) 2005, 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 +#include +#include +#include +#include +#include +#include "hwform.h" +#include "hwconsts.h" + +QDir * bindir; +QDir * cfgdir; +QDir * datadir; + +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); + + QTranslator Translator; + Translator.load(":/translations/hedgewars_" + QLocale::system().name()); + app.installTranslator(&Translator); + + QDir mydir("."); + mydir.cd("bin"); + + bindir = new QDir(mydir); + cfgdir = new QDir(); + + cfgdir->setPath(cfgdir->homePath()); + if (checkForDir(cfgdir->absolutePath() + "/.hedgewars")) + { + checkForDir(cfgdir->absolutePath() + "/.hedgewars/Demos"); + } + cfgdir->cd(".hedgewars"); + + datadir = new QDir(mydir); + datadir->cd("../share/hedgewars/Data"); + + HWForm *Form = new HWForm(); + Form->show(); + return app.exec(); +} diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/mapContainer.cpp --- a/QTfrontend/mapContainer.cpp Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/mapContainer.cpp Thu Oct 05 17:02:09 2006 +0000 @@ -1,78 +1,78 @@ -/* - * Hedgewars, a worms-like game - * Copyright (c) 2006 Igor Ulyanov - * - * 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 "mapContainer.h" - -#include -#include -#include -#include -#include -#include -#include - -HWMapContainer::HWMapContainer(QWidget * parent) : - QWidget(parent), mainLayout(this) -{ - imageButt=new QPushButton(this); - imageButt->setMaximumSize(256, 128); - imageButt->setFlat(true); - imageButt->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); - mainLayout.addWidget(imageButt); - connect(imageButt, SIGNAL(clicked()), this, SLOT(changeImage())); - changeImage(); -} - -void HWMapContainer::setImage(const QImage newImage) -{ - QPixmap px(256, 128); - QPixmap pxres(256, 128); - QPainter p(&pxres); - - px.fill(Qt::yellow); - QBitmap bm = QBitmap::fromImage(newImage); - px.setMask(bm); - - QLinearGradient linearGrad(QPoint(128, 0), QPoint(128, 128)); - linearGrad.setColorAt(0, QColor(0, 0, 192)); - linearGrad.setColorAt(1, QColor(0, 0, 64)); - p.fillRect(QRect(0, 0, 256, 128), linearGrad); - p.drawPixmap(QPoint(0, 0), px); - - - imageButt->setIcon(pxres); - imageButt->setIconSize(QSize(256, 128)); -} - -void HWMapContainer::changeImage() -{ - pMap=new HWMap(); - connect(pMap, SIGNAL(ImageReceived(const QImage)), this, SLOT(setImage(const QImage))); - m_seed = QUuid::createUuid().toString(); - pMap->getImage(m_seed.toStdString()); -} - -QString HWMapContainer::getCurrentSeed() const -{ - return m_seed; -} - -void HWMapContainer::resizeEvent ( QResizeEvent * event ) -{ - //imageButt->setIconSize(imageButt->size()); -} +/* + * Hedgewars, a worms-like game + * Copyright (c) 2006 Igor Ulyanov + * + * 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 "mapContainer.h" + +#include +#include +#include +#include +#include +#include +#include + +HWMapContainer::HWMapContainer(QWidget * parent) : + QWidget(parent), mainLayout(this) +{ + imageButt=new QPushButton(this); + imageButt->setMaximumSize(256, 128); + imageButt->setFlat(true); + imageButt->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + mainLayout.addWidget(imageButt); + connect(imageButt, SIGNAL(clicked()), this, SLOT(changeImage())); + changeImage(); +} + +void HWMapContainer::setImage(const QImage newImage) +{ + QPixmap px(256, 128); + QPixmap pxres(256, 128); + QPainter p(&pxres); + + px.fill(Qt::yellow); + QBitmap bm = QBitmap::fromImage(newImage); + px.setMask(bm); + + QLinearGradient linearGrad(QPoint(128, 0), QPoint(128, 128)); + linearGrad.setColorAt(0, QColor(0, 0, 192)); + linearGrad.setColorAt(1, QColor(0, 0, 64)); + p.fillRect(QRect(0, 0, 256, 128), linearGrad); + p.drawPixmap(QPoint(0, 0), px); + + + imageButt->setIcon(pxres); + imageButt->setIconSize(QSize(256, 128)); +} + +void HWMapContainer::changeImage() +{ + pMap=new HWMap(); + connect(pMap, SIGNAL(ImageReceived(const QImage)), this, SLOT(setImage(const QImage))); + m_seed = QUuid::createUuid().toString(); + pMap->getImage(m_seed.toStdString()); +} + +QString HWMapContainer::getCurrentSeed() const +{ + return m_seed; +} + +void HWMapContainer::resizeEvent ( QResizeEvent * event ) +{ + //imageButt->setIconSize(imageButt->size()); +} diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/mapContainer.h --- a/QTfrontend/mapContainer.h Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/mapContainer.h Thu Oct 05 17:02:09 2006 +0000 @@ -2,33 +2,18 @@ * Hedgewars, a worms-like game * Copyright (c) 2006 Igor Ulyanov * - * 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: + * 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 * - * 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 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. * - * 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. + * 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 _HWMAP_CONTAINER_INCLUDED diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/netclient.cpp --- a/QTfrontend/netclient.cpp Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/netclient.cpp Thu Oct 05 17:02:09 2006 +0000 @@ -1,497 +1,497 @@ -/* - * Hedgewars, a worms-like game - * Copyright (c) 2005, 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 -#include -#include "netclient.h" -#include "game.h" -#include "gameuiconfig.h" - -HWNet::HWNet(GameUIConfig * config) - : QObject() -{ - this->config = config; - state = nsDisconnected; - IRCmsg_cmd_text = new QRegExp("^[A-Z]+ :.+$"); - IRCmsg_number_param = new QRegExp("^:\\S+ [0-9]{3} .+$"); - IRCmsg_who_cmd_target = new QRegExp("^:\\S+ [A-Z]+ \\S+$"); // last \\S should mean 'the 1st char is not ":"' - IRCmsg_who_cmd_text = new QRegExp("^:\\S+ [A-Z]+ :.+$"); - IRCmsg_who_cmd_target_text = new QRegExp("^:\\S+ [A-Z]+ \\S+ :.+$"); - isOp = false; - teamsCount = 0; - - connect(&NetSocket, SIGNAL(readyRead()), this, SLOT(ClientRead())); - connect(&NetSocket, SIGNAL(connected()), this, SLOT(OnConnect())); - connect(&NetSocket, SIGNAL(disconnected()), this, SLOT(OnDisconnect())); - connect(&NetSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, - SLOT(displayError(QAbstractSocket::SocketError))); -} - -void HWNet::ClientRead() -{ - while (NetSocket.canReadLine()) - { - ParseLine(NetSocket.readLine().trimmed()); - } -} - -void HWNet::displayError(QAbstractSocket::SocketError socketError) -{ - switch (socketError) - { - case QAbstractSocket::RemoteHostClosedError: - break; - case QAbstractSocket::HostNotFoundError: - QMessageBox::information(0, tr("Error"), - tr("The host was not found. Please check the host name and port settings.")); - break; - case QAbstractSocket::ConnectionRefusedError: - QMessageBox::information(0, tr("Error"), - tr("Connection refused")); - break; - default: - QMessageBox::information(0, tr("Error"), - NetSocket.errorString()); - } -} - -void HWNet::Connect(const QString & hostName, quint16 port, const QString & nick) -{ - state = nsConnecting; - NetSocket.connectToHost(hostName, port); - mynick = nick; - opnick = ""; - opCount = 0; -} - - -void HWNet::OnConnect() -{ - state = nsConnected; - RawSendNet(QString("USER hwgame 1 2 Hedgewars game")); - RawSendNet(QString("NICK %1").arg(mynick)); -} - -void HWNet::OnDisconnect() -{ - state = nsDisconnected; -} - -void HWNet::Perform() -{ - -} - -void HWNet::JoinGame(const QString & game) -{ - state = nsJoining; - RawSendNet(QString("JOIN %1").arg(game)); -} - -void HWNet::Disconnect() -{ - switch (state) - { - case nsDisconnected: - { - break; - } - case nsConnecting: - case nsQuitting: - { - NetSocket.disconnect(); - break; - } - default: - { - state = nsQuitting; - RawSendNet(QString("QUIT :oops")); - } - } -} - -void HWNet::RawSendNet(const QString & str) -{ - RawSendNet(str.toUtf8()); -} - -void HWNet::RawSendNet(const QByteArray & buf) -{ - if (buf.size() > 510) return; - NetSocket.write(buf); - NetSocket.write("\x0d\x0a", 2); -} - -void HWNet::SendNet(const QByteArray & buf) -{ - if ((state == nsGaming) || (state == nsStarting)) - { - QString msg = QString(buf.toBase64()); - if ((msg == "AUM=") && (mynick == opnick)) - { - ConfigAsked(); - } else - if (msg == "AT8=") - { - // its ping ("?") - } else - { - if (state == nsGaming) - { - NetBuffer += buf; - } else - { - RawSendNet(QString("PRIVMSG %1 :"MAGIC_CHAR MAGIC_CHAR"%2").arg(channel, msg)); - } - } - } -} - -void HWNet::FlushNetBuf() -{ - if (NetBuffer.size() > 0) - { - RawSendNet(QString("PRIVMSG %1 :"MAGIC_CHAR MAGIC_CHAR"%2").arg(channel, QString(NetBuffer.toBase64()))); - NetBuffer.clear(); - } -} - -void HWNet::ParseLine(const QByteArray & line) -{ - QString msg = QString::fromUtf8 (line.data(), line.size()); - //QMessageBox::information(0, "", msg); - if (IRCmsg_cmd_text->exactMatch(msg)) - { - msgcmd_textHandler(msg); - } else - if (IRCmsg_number_param->exactMatch(msg)) - { - msgnumber_paramHandler(msg); - } else - if (IRCmsg_who_cmd_text->exactMatch(msg)) - { - msgwho_cmd_textHandler(msg); - } else - if (IRCmsg_who_cmd_target->exactMatch(msg)) - { - msgwho_cmd_targetHandler(msg); - } else - if (IRCmsg_who_cmd_target_text->exactMatch(msg)) - { - msgwho_cmd_target_textHandler(msg); - } -} - -void HWNet::msgcmd_textHandler(const QString & msg) -{ - QStringList list = msg.split(" :"); - if (list[0] == "PING") - { - RawSendNet(QString("PONG %1").arg(list[1])); - } -} - -void HWNet::msgnumber_paramHandler(const QString & msg) -{ - int pos = msg.indexOf(" :"); - QString text = msg.mid(pos + 2); - QStringList list = msg.mid(0, pos).split(" "); - bool ok; - quint16 number = list[1].toInt(&ok); - if (!ok) - return ; - switch (number) - { - case 001 : - { - Perform(); - emit Connected(); - break; - } - case 322 : // RPL_LIST - { - emit AddGame(list[3]); - break; - } - case 353 : // RPL_NAMREPLY - { - QStringList ops = text.split(" ").filter(QRegExp("^@\\S+$")); - opCount += ops.size(); - if (ops.size() == 1) - { - opnick = ops[0].mid(1); - } - break; - } - case 366 : // RPL_ENDOFNAMES - { - if (opCount != 1) - { - opnick = ""; - } - opCount = 0; - break; - } - case 432 : // ERR_ERRONEUSNICKNAME - case 433 : // ERR_NICKNAMEINUSE - { - QMessageBox::information(0, "Your net nickname is in use or cannot be used", msg); - // ask for another nick - } - } -} - -void HWNet::msgwho_cmd_targetHandler(const QString & msg) -{ - QStringList list = msg.split(" "); - QString who = list[0].mid(1).split("!")[0]; - if (list[1] == "NICK") - { - if (mynick == who) - mynick = list[2]; - if (opnick == who) - opnick = list[2]; - } -} - -void HWNet::msgwho_cmd_textHandler(const QString & msg) -{ - int pos = msg.indexOf(" :"); - QString text = msg.mid(pos + 2); - QStringList list = msg.mid(0, pos).split(" "); - QString who = list[0].mid(1).split("!")[0]; - if (list[1] == "JOIN") - { - if (who == mynick) - { - channel = text; - state = nsJoined; - emit EnteredGame(); - RawSendNet(QString("PRIVMSG %1 :Hello!").arg(channel)); - } - } -} -void HWNet::msgwho_cmd_target_textHandler(const QString & msg) -{ - int pos = msg.indexOf(" :"); - QString text = msg.mid(pos + 2); - QStringList list = msg.mid(0, pos).split(" "); - QString who = list[0].mid(1).split("!")[0]; - if (list[1] == "PRIVMSG") - { - if (list[2] == opnick) - { - hwp_opmsg(who, text); - } else - if (list[2] == channel) - { - hwp_chanmsg(who, text); - } - } -} - -void HWNet::hwp_opmsg(const QString & who, const QString & msg) -{ - if (state != nsJoined) - return ; - if (!msg.startsWith(MAGIC_CHAR)) - return ; - QStringList list = msg.split(MAGIC_CHAR, QString::SkipEmptyParts); - if (list[0] == "A") - { - list.removeFirst(); - if (list.size() != 9) - return ; - if (teamsCount < 5) - { - teams[teamsCount].nick = who; - teams[teamsCount].hhs = list; - teamsCount++; - QString teamnames; - for(int i = 0; i < teamsCount; i++) - { - teamnames += MAGIC_CHAR; - teamnames += teams[i].hhs[0]; - } - QString tmsg = QString(MAGIC_CHAR"=%2").arg(teamnames); - RawSendNet(QString("PRIVMSG %1 :").arg(channel) + tmsg); - hwp_chanmsg(mynick, tmsg); - } - } -} - -void HWNet::ConfigAsked() -{ - configasks++; - if (configasks == playerscnt) - { - quint32 color = 65535; - #define ADD(a) { \ - QByteArray strmsg; \ - strmsg.append(a); \ - quint8 sz = strmsg.size(); \ - cache.append(QByteArray((char *)&sz, 1)); \ - cache.append(strmsg); \ - } - { - QByteArray cache; - ADD("eseed " + seed); - ADD("e$gmflags 0"); - ADD(QString("etheme %1").arg(config->GetRandomTheme())); - QString _msg = MAGIC_CHAR MAGIC_CHAR + QString(cache.toBase64()); - RawSendNet(QString("PRIVMSG %1 :%2").arg(channel, _msg)); - hwp_chanmsg(mynick, _msg); - } - for (int i = 0; i < teamsCount; i++) - { - QString msg; - msg = MAGIC_CHAR "T" MAGIC_CHAR + teams[i].nick + MAGIC_CHAR + teams[i].hhs.join(MAGIC_CHAR); - RawSendNet(QString("PRIVMSG %1 :%2").arg(channel, msg)); - hwp_chanmsg(mynick, msg); - QByteArray cache; - ADD(QString("ecolor %1").arg(color)); - ADD("eadd hh0 0"); - ADD("eadd hh1 0"); - ADD("eadd hh2 0"); - ADD("eadd hh3 0"); - ADD("eadd hh4 0"); - #undef ADD - QString _msg = MAGIC_CHAR MAGIC_CHAR + QString(cache.toBase64()); - RawSendNet(QString("PRIVMSG %1 :%2").arg(channel, _msg)); - hwp_chanmsg(mynick, _msg); - color <<= 8; - } - SENDCFGSTRNET("!"); - } -} - -void HWNet::hwp_chanmsg(const QString & who, const QString & msg) -{ - if ((state < nsJoined) || (state > nsGaming)) - { - return ; - } - if (state == nsJoined) - { - if (msg.startsWith(MAGIC_CHAR"Start!") && (who == opnick)) - { - state = nsStarting; - RunGame(); - return ; - } - if (msg.startsWith(MAGIC_CHAR"="MAGIC_CHAR) && (who == opnick)) - { - emit ChangeInTeams(msg.mid(3).split(MAGIC_CHAR)); - } - } - if (state == nsStarting) - { - if (msg == MAGIC_CHAR MAGIC_CHAR "AUM=") - { - if (mynick == opnick) ConfigAsked(); - return ; - } - if (msg == MAGIC_CHAR MAGIC_CHAR "ASE=") - { - state = nsGaming; - TimerFlusher = new QTimer(); - connect(TimerFlusher, SIGNAL(timeout()), this, SLOT(FlushNetBuf())); - TimerFlusher->start(2000); - } - if (msg.startsWith(MAGIC_CHAR"T"MAGIC_CHAR)) - { - NetTeamAdded(msg.mid(3)); - } - } - if ((state < nsStarting) || (state > nsGaming)) - { - return; - } - if (msg.startsWith(MAGIC_CHAR MAGIC_CHAR)) // HWP message - { - QByteArray em = QByteArray::fromBase64(msg.mid(2).toAscii()); - emit FromNet(em); - } else // smth other - { - - } -} - -void HWNet::NetTeamAdded(const QString & msg) -{ - QStringList list = msg.split(MAGIC_CHAR, QString::SkipEmptyParts); - if (list.size() != 10) - return ; - SENDCFGSTRLOC("eaddteam"); - if (list[0] == mynick) - { - emit LocalCFG(list[1]); - } else - { - SENDCFGSTRLOC("erdriven"); - SENDCFGSTRLOC(QString("ename team %1").arg(list[1])); - for (int i = 0; i < 8; i++) - { - SENDCFGSTRLOC(QString("ename hh%1 ").arg(i) + list[i + 2]); - } - } -} - -void HWNet::AddTeam(const HWTeam & team) -{ - if (state != nsJoined) - { - return ; - } - RawSendNet(QString("PRIVMSG %1 :").arg(opnick) + MAGIC_CHAR "A" MAGIC_CHAR + - team.TeamName + MAGIC_CHAR + team.HHName[0] + MAGIC_CHAR + team.HHName[1] + MAGIC_CHAR + - team.HHName[2] + MAGIC_CHAR + team.HHName[3] + MAGIC_CHAR + team.HHName[4] + MAGIC_CHAR + - team.HHName[5] + MAGIC_CHAR + team.HHName[6] + MAGIC_CHAR + team.HHName[7]); -} - -void HWNet::StartGame() -{ - if ((opnick != mynick) || (state != nsJoined)) - { - return ; - } - QStringList players; - for (int i = 0; i < teamsCount; i++) - { - if (!players.contains(teams[i].nick)) - { - players.append(teams[i].nick); - } - } - playerscnt = players.size(); - configasks = 0; - - seed = QUuid::createUuid().toString(); - QString msg = QString(MAGIC_CHAR"Start!"); - RawSendNet(QString("PRIVMSG %1 :%2").arg(channel, msg)); - hwp_chanmsg(mynick, msg); -} - -void HWNet::RunGame() -{ - 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 &))); - game->StartNet(); -} +/* + * Hedgewars, a worms-like game + * Copyright (c) 2005, 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 +#include +#include "netclient.h" +#include "game.h" +#include "gameuiconfig.h" + +HWNet::HWNet(GameUIConfig * config) + : QObject() +{ + this->config = config; + state = nsDisconnected; + IRCmsg_cmd_text = new QRegExp("^[A-Z]+ :.+$"); + IRCmsg_number_param = new QRegExp("^:\\S+ [0-9]{3} .+$"); + IRCmsg_who_cmd_target = new QRegExp("^:\\S+ [A-Z]+ \\S+$"); // last \\S should mean 'the 1st char is not ":"' + IRCmsg_who_cmd_text = new QRegExp("^:\\S+ [A-Z]+ :.+$"); + IRCmsg_who_cmd_target_text = new QRegExp("^:\\S+ [A-Z]+ \\S+ :.+$"); + isOp = false; + teamsCount = 0; + + connect(&NetSocket, SIGNAL(readyRead()), this, SLOT(ClientRead())); + connect(&NetSocket, SIGNAL(connected()), this, SLOT(OnConnect())); + connect(&NetSocket, SIGNAL(disconnected()), this, SLOT(OnDisconnect())); + connect(&NetSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, + SLOT(displayError(QAbstractSocket::SocketError))); +} + +void HWNet::ClientRead() +{ + while (NetSocket.canReadLine()) + { + ParseLine(NetSocket.readLine().trimmed()); + } +} + +void HWNet::displayError(QAbstractSocket::SocketError socketError) +{ + switch (socketError) + { + case QAbstractSocket::RemoteHostClosedError: + break; + case QAbstractSocket::HostNotFoundError: + QMessageBox::information(0, tr("Error"), + tr("The host was not found. Please check the host name and port settings.")); + break; + case QAbstractSocket::ConnectionRefusedError: + QMessageBox::information(0, tr("Error"), + tr("Connection refused")); + break; + default: + QMessageBox::information(0, tr("Error"), + NetSocket.errorString()); + } +} + +void HWNet::Connect(const QString & hostName, quint16 port, const QString & nick) +{ + state = nsConnecting; + NetSocket.connectToHost(hostName, port); + mynick = nick; + opnick = ""; + opCount = 0; +} + + +void HWNet::OnConnect() +{ + state = nsConnected; + RawSendNet(QString("USER hwgame 1 2 Hedgewars game")); + RawSendNet(QString("NICK %1").arg(mynick)); +} + +void HWNet::OnDisconnect() +{ + state = nsDisconnected; +} + +void HWNet::Perform() +{ + +} + +void HWNet::JoinGame(const QString & game) +{ + state = nsJoining; + RawSendNet(QString("JOIN %1").arg(game)); +} + +void HWNet::Disconnect() +{ + switch (state) + { + case nsDisconnected: + { + break; + } + case nsConnecting: + case nsQuitting: + { + NetSocket.disconnect(); + break; + } + default: + { + state = nsQuitting; + RawSendNet(QString("QUIT :oops")); + } + } +} + +void HWNet::RawSendNet(const QString & str) +{ + RawSendNet(str.toUtf8()); +} + +void HWNet::RawSendNet(const QByteArray & buf) +{ + if (buf.size() > 510) return; + NetSocket.write(buf); + NetSocket.write("\x0d\x0a", 2); +} + +void HWNet::SendNet(const QByteArray & buf) +{ + if ((state == nsGaming) || (state == nsStarting)) + { + QString msg = QString(buf.toBase64()); + if ((msg == "AUM=") && (mynick == opnick)) + { + ConfigAsked(); + } else + if (msg == "AT8=") + { + // its ping ("?") + } else + { + if (state == nsGaming) + { + NetBuffer += buf; + } else + { + RawSendNet(QString("PRIVMSG %1 :"MAGIC_CHAR MAGIC_CHAR"%2").arg(channel, msg)); + } + } + } +} + +void HWNet::FlushNetBuf() +{ + if (NetBuffer.size() > 0) + { + RawSendNet(QString("PRIVMSG %1 :"MAGIC_CHAR MAGIC_CHAR"%2").arg(channel, QString(NetBuffer.toBase64()))); + NetBuffer.clear(); + } +} + +void HWNet::ParseLine(const QByteArray & line) +{ + QString msg = QString::fromUtf8 (line.data(), line.size()); + //QMessageBox::information(0, "", msg); + if (IRCmsg_cmd_text->exactMatch(msg)) + { + msgcmd_textHandler(msg); + } else + if (IRCmsg_number_param->exactMatch(msg)) + { + msgnumber_paramHandler(msg); + } else + if (IRCmsg_who_cmd_text->exactMatch(msg)) + { + msgwho_cmd_textHandler(msg); + } else + if (IRCmsg_who_cmd_target->exactMatch(msg)) + { + msgwho_cmd_targetHandler(msg); + } else + if (IRCmsg_who_cmd_target_text->exactMatch(msg)) + { + msgwho_cmd_target_textHandler(msg); + } +} + +void HWNet::msgcmd_textHandler(const QString & msg) +{ + QStringList list = msg.split(" :"); + if (list[0] == "PING") + { + RawSendNet(QString("PONG %1").arg(list[1])); + } +} + +void HWNet::msgnumber_paramHandler(const QString & msg) +{ + int pos = msg.indexOf(" :"); + QString text = msg.mid(pos + 2); + QStringList list = msg.mid(0, pos).split(" "); + bool ok; + quint16 number = list[1].toInt(&ok); + if (!ok) + return ; + switch (number) + { + case 001 : + { + Perform(); + emit Connected(); + break; + } + case 322 : // RPL_LIST + { + emit AddGame(list[3]); + break; + } + case 353 : // RPL_NAMREPLY + { + QStringList ops = text.split(" ").filter(QRegExp("^@\\S+$")); + opCount += ops.size(); + if (ops.size() == 1) + { + opnick = ops[0].mid(1); + } + break; + } + case 366 : // RPL_ENDOFNAMES + { + if (opCount != 1) + { + opnick = ""; + } + opCount = 0; + break; + } + case 432 : // ERR_ERRONEUSNICKNAME + case 433 : // ERR_NICKNAMEINUSE + { + QMessageBox::information(0, "Your net nickname is in use or cannot be used", msg); + // ask for another nick + } + } +} + +void HWNet::msgwho_cmd_targetHandler(const QString & msg) +{ + QStringList list = msg.split(" "); + QString who = list[0].mid(1).split("!")[0]; + if (list[1] == "NICK") + { + if (mynick == who) + mynick = list[2]; + if (opnick == who) + opnick = list[2]; + } +} + +void HWNet::msgwho_cmd_textHandler(const QString & msg) +{ + int pos = msg.indexOf(" :"); + QString text = msg.mid(pos + 2); + QStringList list = msg.mid(0, pos).split(" "); + QString who = list[0].mid(1).split("!")[0]; + if (list[1] == "JOIN") + { + if (who == mynick) + { + channel = text; + state = nsJoined; + emit EnteredGame(); + RawSendNet(QString("PRIVMSG %1 :Hello!").arg(channel)); + } + } +} +void HWNet::msgwho_cmd_target_textHandler(const QString & msg) +{ + int pos = msg.indexOf(" :"); + QString text = msg.mid(pos + 2); + QStringList list = msg.mid(0, pos).split(" "); + QString who = list[0].mid(1).split("!")[0]; + if (list[1] == "PRIVMSG") + { + if (list[2] == opnick) + { + hwp_opmsg(who, text); + } else + if (list[2] == channel) + { + hwp_chanmsg(who, text); + } + } +} + +void HWNet::hwp_opmsg(const QString & who, const QString & msg) +{ + if (state != nsJoined) + return ; + if (!msg.startsWith(MAGIC_CHAR)) + return ; + QStringList list = msg.split(MAGIC_CHAR, QString::SkipEmptyParts); + if (list[0] == "A") + { + list.removeFirst(); + if (list.size() != 9) + return ; + if (teamsCount < 5) + { + teams[teamsCount].nick = who; + teams[teamsCount].hhs = list; + teamsCount++; + QString teamnames; + for(int i = 0; i < teamsCount; i++) + { + teamnames += MAGIC_CHAR; + teamnames += teams[i].hhs[0]; + } + QString tmsg = QString(MAGIC_CHAR"=%2").arg(teamnames); + RawSendNet(QString("PRIVMSG %1 :").arg(channel) + tmsg); + hwp_chanmsg(mynick, tmsg); + } + } +} + +void HWNet::ConfigAsked() +{ + configasks++; + if (configasks == playerscnt) + { + quint32 color = 65535; + #define ADD(a) { \ + QByteArray strmsg; \ + strmsg.append(a); \ + quint8 sz = strmsg.size(); \ + cache.append(QByteArray((char *)&sz, 1)); \ + cache.append(strmsg); \ + } + { + QByteArray cache; + ADD("eseed " + seed); + ADD("e$gmflags 0"); + ADD(QString("etheme %1").arg(config->GetRandomTheme())); + QString _msg = MAGIC_CHAR MAGIC_CHAR + QString(cache.toBase64()); + RawSendNet(QString("PRIVMSG %1 :%2").arg(channel, _msg)); + hwp_chanmsg(mynick, _msg); + } + for (int i = 0; i < teamsCount; i++) + { + QString msg; + msg = MAGIC_CHAR "T" MAGIC_CHAR + teams[i].nick + MAGIC_CHAR + teams[i].hhs.join(MAGIC_CHAR); + RawSendNet(QString("PRIVMSG %1 :%2").arg(channel, msg)); + hwp_chanmsg(mynick, msg); + QByteArray cache; + ADD(QString("ecolor %1").arg(color)); + ADD("eadd hh0 0"); + ADD("eadd hh1 0"); + ADD("eadd hh2 0"); + ADD("eadd hh3 0"); + ADD("eadd hh4 0"); + #undef ADD + QString _msg = MAGIC_CHAR MAGIC_CHAR + QString(cache.toBase64()); + RawSendNet(QString("PRIVMSG %1 :%2").arg(channel, _msg)); + hwp_chanmsg(mynick, _msg); + color <<= 8; + } + SENDCFGSTRNET("!"); + } +} + +void HWNet::hwp_chanmsg(const QString & who, const QString & msg) +{ + if ((state < nsJoined) || (state > nsGaming)) + { + return ; + } + if (state == nsJoined) + { + if (msg.startsWith(MAGIC_CHAR"Start!") && (who == opnick)) + { + state = nsStarting; + RunGame(); + return ; + } + if (msg.startsWith(MAGIC_CHAR"="MAGIC_CHAR) && (who == opnick)) + { + emit ChangeInTeams(msg.mid(3).split(MAGIC_CHAR)); + } + } + if (state == nsStarting) + { + if (msg == MAGIC_CHAR MAGIC_CHAR "AUM=") + { + if (mynick == opnick) ConfigAsked(); + return ; + } + if (msg == MAGIC_CHAR MAGIC_CHAR "ASE=") + { + state = nsGaming; + TimerFlusher = new QTimer(); + connect(TimerFlusher, SIGNAL(timeout()), this, SLOT(FlushNetBuf())); + TimerFlusher->start(2000); + } + if (msg.startsWith(MAGIC_CHAR"T"MAGIC_CHAR)) + { + NetTeamAdded(msg.mid(3)); + } + } + if ((state < nsStarting) || (state > nsGaming)) + { + return; + } + if (msg.startsWith(MAGIC_CHAR MAGIC_CHAR)) // HWP message + { + QByteArray em = QByteArray::fromBase64(msg.mid(2).toAscii()); + emit FromNet(em); + } else // smth other + { + + } +} + +void HWNet::NetTeamAdded(const QString & msg) +{ + QStringList list = msg.split(MAGIC_CHAR, QString::SkipEmptyParts); + if (list.size() != 10) + return ; + SENDCFGSTRLOC("eaddteam"); + if (list[0] == mynick) + { + emit LocalCFG(list[1]); + } else + { + SENDCFGSTRLOC("erdriven"); + SENDCFGSTRLOC(QString("ename team %1").arg(list[1])); + for (int i = 0; i < 8; i++) + { + SENDCFGSTRLOC(QString("ename hh%1 ").arg(i) + list[i + 2]); + } + } +} + +void HWNet::AddTeam(const HWTeam & team) +{ + if (state != nsJoined) + { + return ; + } + RawSendNet(QString("PRIVMSG %1 :").arg(opnick) + MAGIC_CHAR "A" MAGIC_CHAR + + team.TeamName + MAGIC_CHAR + team.HHName[0] + MAGIC_CHAR + team.HHName[1] + MAGIC_CHAR + + team.HHName[2] + MAGIC_CHAR + team.HHName[3] + MAGIC_CHAR + team.HHName[4] + MAGIC_CHAR + + team.HHName[5] + MAGIC_CHAR + team.HHName[6] + MAGIC_CHAR + team.HHName[7]); +} + +void HWNet::StartGame() +{ + if ((opnick != mynick) || (state != nsJoined)) + { + return ; + } + QStringList players; + for (int i = 0; i < teamsCount; i++) + { + if (!players.contains(teams[i].nick)) + { + players.append(teams[i].nick); + } + } + playerscnt = players.size(); + configasks = 0; + + seed = QUuid::createUuid().toString(); + QString msg = QString(MAGIC_CHAR"Start!"); + RawSendNet(QString("PRIVMSG %1 :%2").arg(channel, msg)); + hwp_chanmsg(mynick, msg); +} + +void HWNet::RunGame() +{ + 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 &))); + game->StartNet(); +} diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/netclient.h --- a/QTfrontend/netclient.h Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/netclient.h Thu Oct 05 17:02:09 2006 +0000 @@ -1,140 +1,140 @@ -/* - * Hedgewars, a worms-like game - * Copyright (c) 2005 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 NET_H -#define NET_H - -#include -#include -#include -#include -#include -#include "team.h" - -#define MAGIC_CHAR "\x2f" - -struct netTeam -{ - QString nick; - QStringList hhs; -}; - -class GameUIConfig; - -class HWNet : public QObject -{ - Q_OBJECT - -public: - HWNet(GameUIConfig * config); - void Connect(const QString & hostName, quint16 port, const QString & nick); - void Disconnect(); - void JoinGame(const QString & game); - void AddTeam(const HWTeam & team); - void StartGame(); - -signals: - void Connected(); - void AddGame(const QString & chan); - void EnteredGame(); - void FromNet(const QByteArray & buf); - void LocalCFG(const QString & team); - void ChangeInTeams(const QStringList & teams); - -public slots: - void SendNet(const QByteArray & buf); - -private: - enum NetState { - nsDisconnected = 0, - nsConnecting = 1, - nsConnected = 3, - nsJoining = 4, - nsJoined = 5, - nsStarting = 6, - nsGaming = 7, - nsQuitting = 8 - }; - - QTcpSocket NetSocket; - NetState state; - QRegExp * IRCmsg_cmd_text; - QRegExp * IRCmsg_number_param; - QRegExp * IRCmsg_who_cmd_target; - QRegExp * IRCmsg_who_cmd_target_text; - QRegExp * IRCmsg_who_cmd_text; - QString mynick; - QString opnick; - QString channel; - QString seed; - bool isOp; - quint32 opCount; - netTeam teams[5]; - quint8 teamsCount; - int playerscnt; - int configasks; - QByteArray NetBuffer; - QTimer * TimerFlusher; - GameUIConfig * config; - - void RawSendNet(const QString & buf); - void RawSendNet(const QByteArray & buf); - - void ParseLine(const QByteArray & line); - void msgcmd_textHandler(const QString & msg); - void msgnumber_paramHandler(const QString & msg); - void msgwho_cmd_targetHandler(const QString & msg); - void msgwho_cmd_textHandler(const QString & msg); - void msgwho_cmd_target_textHandler(const QString & msg); - - void hwp_opmsg(const QString & who, const QString & msg); - void hwp_chanmsg(const QString & who, const QString & msg); - void ConfigAsked(); - void NetTeamAdded(const QString & msg); - - void RunGame(); - - -private slots: - void ClientRead(); - void OnConnect(); - void OnDisconnect(); - void Perform(); - void displayError(QAbstractSocket::SocketError socketError); - void FlushNetBuf(); -}; - -#define SENDCFGSTRNET(a) {\ - QByteArray strmsg; \ - strmsg.append(a); \ - quint8 sz = strmsg.size(); \ - QByteArray enginemsg = QByteArray((char *)&sz, 1) + strmsg; \ - QString _msg = MAGIC_CHAR MAGIC_CHAR + QString(enginemsg.toBase64()); \ - hwp_chanmsg(mynick, _msg); \ - RawSendNet(QString("PRIVMSG %1 :").arg(channel) + _msg); \ - } - -#define SENDCFGSTRLOC(a) {\ - QByteArray strmsg; \ - strmsg.append(QString(a).toUtf8()); \ - quint8 sz = strmsg.size(); \ - QByteArray enginemsg = QByteArray((char *)&sz, 1) + strmsg; \ - emit FromNet(enginemsg); \ - } - -#endif +/* + * Hedgewars, a worms-like game + * Copyright (c) 2005 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 NET_H +#define NET_H + +#include +#include +#include +#include +#include +#include "team.h" + +#define MAGIC_CHAR "\x2f" + +struct netTeam +{ + QString nick; + QStringList hhs; +}; + +class GameUIConfig; + +class HWNet : public QObject +{ + Q_OBJECT + +public: + HWNet(GameUIConfig * config); + void Connect(const QString & hostName, quint16 port, const QString & nick); + void Disconnect(); + void JoinGame(const QString & game); + void AddTeam(const HWTeam & team); + void StartGame(); + +signals: + void Connected(); + void AddGame(const QString & chan); + void EnteredGame(); + void FromNet(const QByteArray & buf); + void LocalCFG(const QString & team); + void ChangeInTeams(const QStringList & teams); + +public slots: + void SendNet(const QByteArray & buf); + +private: + enum NetState { + nsDisconnected = 0, + nsConnecting = 1, + nsConnected = 3, + nsJoining = 4, + nsJoined = 5, + nsStarting = 6, + nsGaming = 7, + nsQuitting = 8 + }; + + QTcpSocket NetSocket; + NetState state; + QRegExp * IRCmsg_cmd_text; + QRegExp * IRCmsg_number_param; + QRegExp * IRCmsg_who_cmd_target; + QRegExp * IRCmsg_who_cmd_target_text; + QRegExp * IRCmsg_who_cmd_text; + QString mynick; + QString opnick; + QString channel; + QString seed; + bool isOp; + quint32 opCount; + netTeam teams[5]; + quint8 teamsCount; + int playerscnt; + int configasks; + QByteArray NetBuffer; + QTimer * TimerFlusher; + GameUIConfig * config; + + void RawSendNet(const QString & buf); + void RawSendNet(const QByteArray & buf); + + void ParseLine(const QByteArray & line); + void msgcmd_textHandler(const QString & msg); + void msgnumber_paramHandler(const QString & msg); + void msgwho_cmd_targetHandler(const QString & msg); + void msgwho_cmd_textHandler(const QString & msg); + void msgwho_cmd_target_textHandler(const QString & msg); + + void hwp_opmsg(const QString & who, const QString & msg); + void hwp_chanmsg(const QString & who, const QString & msg); + void ConfigAsked(); + void NetTeamAdded(const QString & msg); + + void RunGame(); + + +private slots: + void ClientRead(); + void OnConnect(); + void OnDisconnect(); + void Perform(); + void displayError(QAbstractSocket::SocketError socketError); + void FlushNetBuf(); +}; + +#define SENDCFGSTRNET(a) {\ + QByteArray strmsg; \ + strmsg.append(a); \ + quint8 sz = strmsg.size(); \ + QByteArray enginemsg = QByteArray((char *)&sz, 1) + strmsg; \ + QString _msg = MAGIC_CHAR MAGIC_CHAR + QString(enginemsg.toBase64()); \ + hwp_chanmsg(mynick, _msg); \ + RawSendNet(QString("PRIVMSG %1 :").arg(channel) + _msg); \ + } + +#define SENDCFGSTRLOC(a) {\ + QByteArray strmsg; \ + strmsg.append(QString(a).toUtf8()); \ + quint8 sz = strmsg.size(); \ + QByteArray enginemsg = QByteArray((char *)&sz, 1) + strmsg; \ + emit FromNet(enginemsg); \ + } + +#endif diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/pages.cpp --- a/QTfrontend/pages.cpp Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/pages.cpp Thu Oct 05 17:02:09 2006 +0000 @@ -1,440 +1,440 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "pages.h" -#include "sdlkeys.h" -#include "hwconsts.h" -#include "gamecfgwidget.h" -#include "teamselect.h" -#include "gamecfgwidget.h" -#include "SquareLabel.h" -#include "mapContainer.h" - -PageMain::PageMain(QWidget* parent) : QWidget(parent) -{ - QFont * font14 = new QFont("MS Shell Dlg", 14); - QGridLayout * pageLayout = new QGridLayout(this); - pageLayout->setMargin(25); - pageLayout->setColumnStretch(0, 1); - pageLayout->setColumnStretch(1, 2); - pageLayout->setColumnStretch(2, 1); - - BtnSinglePlayer = new QPushButton(this); - BtnSinglePlayer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - BtnSinglePlayer->setFont(*font14); - BtnSinglePlayer->setText(QPushButton::tr("Single Player")); - pageLayout->addWidget(BtnSinglePlayer, 1, 1); - - BtnMultiplayer = new QPushButton(this); - BtnMultiplayer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - BtnMultiplayer->setFont(*font14); - BtnMultiplayer->setText(QPushButton::tr("Multiplayer")); - pageLayout->addWidget(BtnMultiplayer, 2, 1); - - BtnNet = new QPushButton(this); - BtnNet->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - BtnNet->setFont(*font14); - BtnNet->setText(QPushButton::tr("Net game")); - pageLayout->addWidget(BtnNet, 3, 1); - - BtnDemos = new QPushButton(this); - BtnDemos->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - BtnDemos->setFont(*font14); - BtnDemos->setText(QPushButton::tr("Demos")); - pageLayout->addWidget(BtnDemos, 4, 1); - - BtnSetup = new QPushButton(this); - BtnSetup->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - BtnSetup->setFont(*font14); - BtnSetup->setText(QPushButton::tr("Setup")); - pageLayout->addWidget(BtnSetup, 5, 1); - - BtnExit = new QPushButton(parent); - BtnExit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - BtnExit->setFont(*font14); - BtnExit->setText(QPushButton::tr("Exit")); - pageLayout->addWidget(BtnExit, 6, 1); -} - -PageLocalGame::PageLocalGame(QWidget* parent) : QWidget(parent) -{ - QFont * font14 = new QFont("MS Shell Dlg", 14); - QGridLayout * pageLayout = new QGridLayout(this); - BtnBack = new QPushButton(this); - BtnBack->setFont(*font14); - BtnBack->setText(QPushButton::tr("Back")); - pageLayout->addWidget(BtnBack, 1, 0); - BtnSimpleGame = new QPushButton(this); - BtnSimpleGame->setFont(*font14); - BtnSimpleGame->setText(QPushButton::tr("Simple Game")); - pageLayout->addWidget(BtnSimpleGame, 1, 3); - gameCFG = new GameCFGWidget(this); - pageLayout->addWidget(gameCFG, 0, 0, 1, 2); -} - -PageEditTeam::PageEditTeam(QWidget* parent) : QWidget(parent) -{ - QFont * font14 = new QFont("MS Shell Dlg", 14); - QGridLayout * pageLayout = new QGridLayout(this); - pageLayout->setColumnStretch(0, 100); - pageLayout->setColumnMinimumWidth(0, 150); - pageLayout->setColumnStretch(1, 100); - pageLayout->setColumnMinimumWidth(1, 200); - pageLayout->setColumnStretch(2, 250); - pageLayout->setColumnMinimumWidth(2, 250); - - GBoxTeam = new QGroupBox(this); - GBoxTeam->setTitle(QGroupBox::tr("Team")); - GBoxTeam->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - QGridLayout * GBTLayout = new QGridLayout(GBoxTeam); - TeamNameEdit = new QLineEdit(GBoxTeam); - TeamNameEdit->setMaxLength(15); - GBTLayout->addWidget(TeamNameEdit); - pageLayout->addWidget(GBoxTeam, 0, 0); - - GBoxHedgehogs = new QGroupBox(this); - GBoxHedgehogs->setTitle(QGroupBox::tr("Team Members")); - GBoxHedgehogs->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - QGridLayout * GBHLayout = new QGridLayout(GBoxHedgehogs); - for(int i = 0; i < 8; i++) - { - HHNameEdit[i] = new QLineEdit(GBoxHedgehogs); - HHNameEdit[i]->setGeometry(QRect(10, 20 + i * 30, 141, 20)); - HHNameEdit[i]->setMaxLength(15); - GBHLayout->addWidget(HHNameEdit[i]); - } - pageLayout->addWidget(GBoxHedgehogs, 1, 0, 2, 1); - - BtnTeamDiscard = new QPushButton(this); - BtnTeamDiscard->setFont(*font14); - BtnTeamDiscard->setText(QPushButton::tr("Discard")); - pageLayout->addWidget(BtnTeamDiscard, 4, 0); - - GBoxBinds = new QGroupBox(this); - GBoxBinds->setTitle(QGroupBox::tr("Key binds")); - QGridLayout * GBBLayout = new QGridLayout(GBoxBinds); - BindsBox = new QToolBox(GBoxBinds); - BindsBox->setLineWidth(0); - GBBLayout->addWidget(BindsBox); - page_A = new QWidget(); - BindsBox->addItem(page_A, QToolBox::tr("Actions")); - page_W = new QWidget(); - BindsBox->addItem(page_W, QToolBox::tr("Weapons")); - page_WP = new QWidget(); - BindsBox->addItem(page_WP, QToolBox::tr("Weapon properties")); - page_O = new QWidget(); - BindsBox->addItem(page_O, QToolBox::tr("Other")); - pageLayout->addWidget(GBoxBinds, 0, 1, 5, 1); - - QStringList binds; - for(int i = 0; strlen(sdlkeys[i][1]) > 0; i++) - { - binds << sdlkeys[i][1]; - } - - quint16 widind = 0, i = 0; - while (i < BINDS_NUMBER) { - quint16 num = 0; - QGridLayout * pagelayout = new QGridLayout(BindsBox->widget(widind)); - do { - LBind[i] = new QLabel(BindsBox->widget(widind)); - LBind[i]->setText(QApplication::translate("binds", cbinds[i].name)); - LBind[i]->setAlignment(Qt::AlignRight); - pagelayout->addWidget(LBind[i], num, 0); - CBBind[i] = new QComboBox(BindsBox->widget(widind)); - CBBind[i]->addItems(binds); - pagelayout->addWidget(CBBind[i], num, 1); - num++; - } while (!cbinds[i++].chwidget); - pagelayout->addWidget(new QWidget(BindsBox->widget(widind)), num, 0, 1, 2); - widind++; - } - - GBoxGrave = new QGroupBox(this); - GBoxGrave->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - GBoxGrave->setTitle(QGroupBox::tr("Grave")); - QGridLayout * GBGLayout = new QGridLayout(GBoxGrave); - CBGrave = new QComboBox(GBoxGrave); - CBGrave->setMaxCount(65535); - GBGLayout->addWidget(CBGrave, 0, 0, 1, 3); - GravePreview = new QLabel(GBoxGrave); - GravePreview->setScaledContents(false); - GBGLayout->addWidget(GravePreview, 1, 1); - pageLayout->addWidget(GBoxGrave, 0, 2, 2, 1); - - GBoxFort = new QGroupBox(this); - GBoxFort->setTitle(QGroupBox::tr("Fort")); - QGridLayout * GBFLayout = new QGridLayout(GBoxFort); - CBFort = new QComboBox(GBoxFort); - CBFort->setMaxCount(65535); - GBFLayout->addWidget(CBFort, 0, 0); - FortPreview = new SquareLabel(GBoxFort); - FortPreview->setPixmap(QPixmap()); - FortPreview->setScaledContents(true); - GBFLayout->addWidget(FortPreview, 1, 0); - pageLayout->addWidget(GBoxFort, 2, 2, 1, 1); - - BtnTeamSave = new QPushButton(this); - BtnTeamSave->setFont(*font14); - BtnTeamSave->setText(QPushButton::tr("Save")); - pageLayout->addWidget(BtnTeamSave, 4, 2); - - - QDir tmpdir; - tmpdir.cd(datadir->absolutePath()); - tmpdir.cd("Forts"); - tmpdir.setFilter(QDir::Files); - - CBFort->addItems(tmpdir.entryList(QStringList("*L.png")).replaceInStrings(QRegExp("^(.*)L.png"), "\\1")); - tmpdir.cd("../Graphics/Graves"); - QStringList list = tmpdir.entryList(QStringList("*.png")); - for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) - { - CBGrave->addItem((*it).replace(QRegExp("^(.*).png"), "\\1")); - } - - connect(CBGrave, SIGNAL(activated(const QString &)), this, SLOT(CBGrave_activated(const QString &))); - connect(CBFort, SIGNAL(activated(const QString &)), this, SLOT(CBFort_activated(const QString &))); -} - -void PageEditTeam::CBGrave_activated(const QString & gravename) -{ - QPixmap pix(datadir->absolutePath() + "/Graphics/Graves/" + gravename + ".png"); - GravePreview->setPixmap(pix.copy(0, 0, 32, 32)); -} - -void PageEditTeam::CBFort_activated(const QString & fortname) -{ - QPixmap pix(datadir->absolutePath() + "/Forts/" + fortname + "L.png"); - FortPreview->setPixmap(pix); -} - -PageMultiplayer::PageMultiplayer(QWidget* parent) : QWidget(parent) -{ - QFont * font14 = new QFont("MS Shell Dlg", 14); - QGridLayout * pageLayout = new QGridLayout(this); - - BtnBack = new QPushButton(this); - BtnBack->setFont(*font14); - BtnBack->setText(QPushButton::tr("Back")); - pageLayout->addWidget(BtnBack, 1, 0); - - //HWMapContainer* pMapContainer=new HWMapContainer(this); - //pageLayout->addWidget(pMapContainer, 1, 1); - - gameCFG = new GameCFGWidget(this); - pageLayout->addWidget(gameCFG, 0, 0, 1, 2); - teamsSelect = new TeamSelWidget(this); - pageLayout->addWidget(teamsSelect, 0, 2, 1, 2); - - BtnStartMPGame = new QPushButton(this); - BtnStartMPGame->setFont(*font14); - BtnStartMPGame->setText(QPushButton::tr("Start")); - 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); - QGridLayout * pageLayout = new QGridLayout(this); - groupBox = new QGroupBox(this); - groupBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - groupBox->setTitle(QGroupBox::tr("Teams")); - pageLayout->addWidget(groupBox, 0, 0, 1, 3); - - QGridLayout * GBTlayout = new QGridLayout(groupBox); - BtnNewTeam = new QPushButton(groupBox); - BtnNewTeam->setFont(*font14); - BtnNewTeam->setText(QPushButton::tr("New team")); - GBTlayout->addWidget(BtnNewTeam, 0, 0); - - CBTeamName = new QComboBox(groupBox); - GBTlayout->addWidget(CBTeamName, 0, 1); - - BtnEditTeam = new QPushButton(groupBox); - BtnEditTeam->setFont(*font14); - BtnEditTeam->setText(QPushButton::tr("Edit team")); - GBTlayout->addWidget(BtnEditTeam, 0, 2); - - AGGroupBox = new QGroupBox(this); - AGGroupBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - AGGroupBox->setTitle(QGroupBox::tr("Audio/Graphic options")); - pageLayout->addWidget(AGGroupBox, 1, 0, 1, 3); - - QGridLayout * GBAlayout = new QGridLayout(AGGroupBox); - CBResolution = new QComboBox(AGGroupBox); - CBResolution->addItem("640x480"); - CBResolution->addItem("800x600"); - CBResolution->addItem("1024x768"); - CBResolution->addItem("1280x1024"); - GBAlayout->addWidget(CBResolution, 0, 0); - - CBFullscreen = new QCheckBox(AGGroupBox); - CBFullscreen->setText(QCheckBox::tr("Fullscreen")); - GBAlayout->addWidget(CBFullscreen, 0, 1); - - CBEnableSound = new QCheckBox(AGGroupBox); - CBEnableSound->setText(QCheckBox::tr("Enable sound")); - GBAlayout->addWidget(CBEnableSound, 0, 2); - - pageLayout->addWidget(new QWidget(), 3, 0, 1, 3); - - BtnSaveOptions = new QPushButton(this); - BtnSaveOptions->setFont(*font14); - BtnSaveOptions->setText(QPushButton::tr("Save")); - pageLayout->addWidget(BtnSaveOptions, 4, 2); - - BtnBack = new QPushButton(this); - BtnBack->setFont(*font14); - BtnBack->setText(QPushButton::tr("Back")); - pageLayout->addWidget(BtnBack, 4, 0); -} - -PageNet::PageNet(QWidget* parent) : QWidget(parent) -{ - QFont * font14 = new QFont("MS Shell Dlg", 14); - QGridLayout * pageLayout = new QGridLayout(this); - pageLayout->setColumnStretch(0, 1); - pageLayout->setColumnStretch(1, 1); - pageLayout->setColumnStretch(2, 1); - - NNGroupBox = new QGroupBox(this); - NNGroupBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - NNGroupBox->setTitle(QGroupBox::tr("Net options")); - pageLayout->addWidget(NNGroupBox, 0, 1); - - pageLayout->addWidget(new QWidget(), 1, 1); - - QGridLayout * GBNlayout = new QGridLayout(NNGroupBox); - labelNN = new QLabel(NNGroupBox); - labelNN->setText(QLabel::tr("Net nick")); - GBNlayout->addWidget(labelNN, 0, 0); - - editNetNick = new QLineEdit(NNGroupBox); - editNetNick->setMaxLength(20); - editNetNick->setText(QLineEdit::tr("unnamed")); - GBNlayout->addWidget(editNetNick, 0, 1); - - labelIP = new QLabel(NNGroupBox); - labelIP->setText(QLabel::tr("Server address")); - GBNlayout->addWidget(labelIP, 1, 0); - - editIP = new QLineEdit(NNGroupBox); - editIP->setMaxLength(50); - GBNlayout->addWidget(editIP, 1, 1); - - BtnNetConnect = new QPushButton(this); - BtnNetConnect->setFont(*font14); - BtnNetConnect->setText(QPushButton::tr("Connect")); - pageLayout->addWidget(BtnNetConnect, 2, 2); - - BtnBack = new QPushButton(this); - BtnBack->setFont(*font14); - BtnBack->setText(QPushButton::tr("Back")); - pageLayout->addWidget(BtnBack, 2, 0); -} - -PageNetChat::PageNetChat(QWidget* parent) : QWidget(parent) -{ - QFont * font14 = new QFont("MS Shell Dlg", 14); - QGridLayout * pageLayout = new QGridLayout(this); - pageLayout->setColumnStretch(0, 1); - pageLayout->setColumnStretch(1, 1); - pageLayout->setColumnStretch(2, 1); - - BtnDisconnect = new QPushButton(this); - BtnDisconnect->setFont(*font14); - BtnDisconnect->setText(QPushButton::tr("Disconnect")); - pageLayout->addWidget(BtnDisconnect, 2, 0); - - ChannelsList = new QListWidget(this); - pageLayout->addWidget(ChannelsList, 0, 1); - - BtnJoin = new QPushButton(this); - BtnJoin->setFont(*font14); - BtnJoin->setText(QPushButton::tr("Join")); - pageLayout->addWidget(BtnJoin, 2, 2); - - BtnCreate = new QPushButton(this); - BtnCreate->setFont(*font14); - BtnCreate->setText(QPushButton::tr("Create")); - pageLayout->addWidget(BtnCreate, 1, 2); -} - - -PageNetGame::PageNetGame(QWidget* parent) : QWidget(parent) -{ - QFont * font14 = new QFont("MS Shell Dlg", 14); - QGridLayout * pageLayout = new QGridLayout(this); - pageLayout->setColumnStretch(0, 1); - pageLayout->setColumnStretch(1, 1); - pageLayout->setColumnStretch(2, 1); - - BtnBack = new QPushButton(this); - BtnBack->setFont(*font14); - BtnBack->setText(QPushButton::tr("Back")); - pageLayout->addWidget(BtnBack, 2, 0); - - BtnAddTeam = new QPushButton(this); - BtnAddTeam->setFont(*font14); - BtnAddTeam->setText(QPushButton::tr("Add Team")); - pageLayout->addWidget(BtnAddTeam, 1, 1); - - BtnGo = new QPushButton(this); - BtnGo->setFont(*font14); - BtnGo->setText(QPushButton::tr("Go!")); - pageLayout->addWidget(BtnGo, 2, 2); - - listNetTeams = new QListWidget(this); - pageLayout->addWidget(listNetTeams, 0, 1); -} +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "pages.h" +#include "sdlkeys.h" +#include "hwconsts.h" +#include "gamecfgwidget.h" +#include "teamselect.h" +#include "gamecfgwidget.h" +#include "SquareLabel.h" +#include "mapContainer.h" + +PageMain::PageMain(QWidget* parent) : QWidget(parent) +{ + QFont * font14 = new QFont("MS Shell Dlg", 14); + QGridLayout * pageLayout = new QGridLayout(this); + pageLayout->setMargin(25); + pageLayout->setColumnStretch(0, 1); + pageLayout->setColumnStretch(1, 2); + pageLayout->setColumnStretch(2, 1); + + BtnSinglePlayer = new QPushButton(this); + BtnSinglePlayer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + BtnSinglePlayer->setFont(*font14); + BtnSinglePlayer->setText(QPushButton::tr("Single Player")); + pageLayout->addWidget(BtnSinglePlayer, 1, 1); + + BtnMultiplayer = new QPushButton(this); + BtnMultiplayer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + BtnMultiplayer->setFont(*font14); + BtnMultiplayer->setText(QPushButton::tr("Multiplayer")); + pageLayout->addWidget(BtnMultiplayer, 2, 1); + + BtnNet = new QPushButton(this); + BtnNet->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + BtnNet->setFont(*font14); + BtnNet->setText(QPushButton::tr("Net game")); + pageLayout->addWidget(BtnNet, 3, 1); + + BtnDemos = new QPushButton(this); + BtnDemos->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + BtnDemos->setFont(*font14); + BtnDemos->setText(QPushButton::tr("Demos")); + pageLayout->addWidget(BtnDemos, 4, 1); + + BtnSetup = new QPushButton(this); + BtnSetup->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + BtnSetup->setFont(*font14); + BtnSetup->setText(QPushButton::tr("Setup")); + pageLayout->addWidget(BtnSetup, 5, 1); + + BtnExit = new QPushButton(parent); + BtnExit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + BtnExit->setFont(*font14); + BtnExit->setText(QPushButton::tr("Exit")); + pageLayout->addWidget(BtnExit, 6, 1); +} + +PageLocalGame::PageLocalGame(QWidget* parent) : QWidget(parent) +{ + QFont * font14 = new QFont("MS Shell Dlg", 14); + QGridLayout * pageLayout = new QGridLayout(this); + BtnBack = new QPushButton(this); + BtnBack->setFont(*font14); + BtnBack->setText(QPushButton::tr("Back")); + pageLayout->addWidget(BtnBack, 1, 0); + BtnSimpleGame = new QPushButton(this); + BtnSimpleGame->setFont(*font14); + BtnSimpleGame->setText(QPushButton::tr("Simple Game")); + pageLayout->addWidget(BtnSimpleGame, 1, 3); + gameCFG = new GameCFGWidget(this); + pageLayout->addWidget(gameCFG, 0, 0, 1, 2); +} + +PageEditTeam::PageEditTeam(QWidget* parent) : QWidget(parent) +{ + QFont * font14 = new QFont("MS Shell Dlg", 14); + QGridLayout * pageLayout = new QGridLayout(this); + pageLayout->setColumnStretch(0, 100); + pageLayout->setColumnMinimumWidth(0, 150); + pageLayout->setColumnStretch(1, 100); + pageLayout->setColumnMinimumWidth(1, 200); + pageLayout->setColumnStretch(2, 250); + pageLayout->setColumnMinimumWidth(2, 250); + + GBoxTeam = new QGroupBox(this); + GBoxTeam->setTitle(QGroupBox::tr("Team")); + GBoxTeam->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + QGridLayout * GBTLayout = new QGridLayout(GBoxTeam); + TeamNameEdit = new QLineEdit(GBoxTeam); + TeamNameEdit->setMaxLength(15); + GBTLayout->addWidget(TeamNameEdit); + pageLayout->addWidget(GBoxTeam, 0, 0); + + GBoxHedgehogs = new QGroupBox(this); + GBoxHedgehogs->setTitle(QGroupBox::tr("Team Members")); + GBoxHedgehogs->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + QGridLayout * GBHLayout = new QGridLayout(GBoxHedgehogs); + for(int i = 0; i < 8; i++) + { + HHNameEdit[i] = new QLineEdit(GBoxHedgehogs); + HHNameEdit[i]->setGeometry(QRect(10, 20 + i * 30, 141, 20)); + HHNameEdit[i]->setMaxLength(15); + GBHLayout->addWidget(HHNameEdit[i]); + } + pageLayout->addWidget(GBoxHedgehogs, 1, 0, 2, 1); + + BtnTeamDiscard = new QPushButton(this); + BtnTeamDiscard->setFont(*font14); + BtnTeamDiscard->setText(QPushButton::tr("Discard")); + pageLayout->addWidget(BtnTeamDiscard, 4, 0); + + GBoxBinds = new QGroupBox(this); + GBoxBinds->setTitle(QGroupBox::tr("Key binds")); + QGridLayout * GBBLayout = new QGridLayout(GBoxBinds); + BindsBox = new QToolBox(GBoxBinds); + BindsBox->setLineWidth(0); + GBBLayout->addWidget(BindsBox); + page_A = new QWidget(); + BindsBox->addItem(page_A, QToolBox::tr("Actions")); + page_W = new QWidget(); + BindsBox->addItem(page_W, QToolBox::tr("Weapons")); + page_WP = new QWidget(); + BindsBox->addItem(page_WP, QToolBox::tr("Weapon properties")); + page_O = new QWidget(); + BindsBox->addItem(page_O, QToolBox::tr("Other")); + pageLayout->addWidget(GBoxBinds, 0, 1, 5, 1); + + QStringList binds; + for(int i = 0; strlen(sdlkeys[i][1]) > 0; i++) + { + binds << sdlkeys[i][1]; + } + + quint16 widind = 0, i = 0; + while (i < BINDS_NUMBER) { + quint16 num = 0; + QGridLayout * pagelayout = new QGridLayout(BindsBox->widget(widind)); + do { + LBind[i] = new QLabel(BindsBox->widget(widind)); + LBind[i]->setText(QApplication::translate("binds", cbinds[i].name)); + LBind[i]->setAlignment(Qt::AlignRight); + pagelayout->addWidget(LBind[i], num, 0); + CBBind[i] = new QComboBox(BindsBox->widget(widind)); + CBBind[i]->addItems(binds); + pagelayout->addWidget(CBBind[i], num, 1); + num++; + } while (!cbinds[i++].chwidget); + pagelayout->addWidget(new QWidget(BindsBox->widget(widind)), num, 0, 1, 2); + widind++; + } + + GBoxGrave = new QGroupBox(this); + GBoxGrave->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + GBoxGrave->setTitle(QGroupBox::tr("Grave")); + QGridLayout * GBGLayout = new QGridLayout(GBoxGrave); + CBGrave = new QComboBox(GBoxGrave); + CBGrave->setMaxCount(65535); + GBGLayout->addWidget(CBGrave, 0, 0, 1, 3); + GravePreview = new QLabel(GBoxGrave); + GravePreview->setScaledContents(false); + GBGLayout->addWidget(GravePreview, 1, 1); + pageLayout->addWidget(GBoxGrave, 0, 2, 2, 1); + + GBoxFort = new QGroupBox(this); + GBoxFort->setTitle(QGroupBox::tr("Fort")); + QGridLayout * GBFLayout = new QGridLayout(GBoxFort); + CBFort = new QComboBox(GBoxFort); + CBFort->setMaxCount(65535); + GBFLayout->addWidget(CBFort, 0, 0); + FortPreview = new SquareLabel(GBoxFort); + FortPreview->setPixmap(QPixmap()); + FortPreview->setScaledContents(true); + GBFLayout->addWidget(FortPreview, 1, 0); + pageLayout->addWidget(GBoxFort, 2, 2, 1, 1); + + BtnTeamSave = new QPushButton(this); + BtnTeamSave->setFont(*font14); + BtnTeamSave->setText(QPushButton::tr("Save")); + pageLayout->addWidget(BtnTeamSave, 4, 2); + + + QDir tmpdir; + tmpdir.cd(datadir->absolutePath()); + tmpdir.cd("Forts"); + tmpdir.setFilter(QDir::Files); + + CBFort->addItems(tmpdir.entryList(QStringList("*L.png")).replaceInStrings(QRegExp("^(.*)L.png"), "\\1")); + tmpdir.cd("../Graphics/Graves"); + QStringList list = tmpdir.entryList(QStringList("*.png")); + for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) + { + CBGrave->addItem((*it).replace(QRegExp("^(.*).png"), "\\1")); + } + + connect(CBGrave, SIGNAL(activated(const QString &)), this, SLOT(CBGrave_activated(const QString &))); + connect(CBFort, SIGNAL(activated(const QString &)), this, SLOT(CBFort_activated(const QString &))); +} + +void PageEditTeam::CBGrave_activated(const QString & gravename) +{ + QPixmap pix(datadir->absolutePath() + "/Graphics/Graves/" + gravename + ".png"); + GravePreview->setPixmap(pix.copy(0, 0, 32, 32)); +} + +void PageEditTeam::CBFort_activated(const QString & fortname) +{ + QPixmap pix(datadir->absolutePath() + "/Forts/" + fortname + "L.png"); + FortPreview->setPixmap(pix); +} + +PageMultiplayer::PageMultiplayer(QWidget* parent) : QWidget(parent) +{ + QFont * font14 = new QFont("MS Shell Dlg", 14); + QGridLayout * pageLayout = new QGridLayout(this); + + BtnBack = new QPushButton(this); + BtnBack->setFont(*font14); + BtnBack->setText(QPushButton::tr("Back")); + pageLayout->addWidget(BtnBack, 1, 0); + + //HWMapContainer* pMapContainer=new HWMapContainer(this); + //pageLayout->addWidget(pMapContainer, 1, 1); + + gameCFG = new GameCFGWidget(this); + pageLayout->addWidget(gameCFG, 0, 0, 1, 2); + teamsSelect = new TeamSelWidget(this); + pageLayout->addWidget(teamsSelect, 0, 2, 1, 2); + + BtnStartMPGame = new QPushButton(this); + BtnStartMPGame->setFont(*font14); + BtnStartMPGame->setText(QPushButton::tr("Start")); + 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); + QGridLayout * pageLayout = new QGridLayout(this); + groupBox = new QGroupBox(this); + groupBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + groupBox->setTitle(QGroupBox::tr("Teams")); + pageLayout->addWidget(groupBox, 0, 0, 1, 3); + + QGridLayout * GBTlayout = new QGridLayout(groupBox); + BtnNewTeam = new QPushButton(groupBox); + BtnNewTeam->setFont(*font14); + BtnNewTeam->setText(QPushButton::tr("New team")); + GBTlayout->addWidget(BtnNewTeam, 0, 0); + + CBTeamName = new QComboBox(groupBox); + GBTlayout->addWidget(CBTeamName, 0, 1); + + BtnEditTeam = new QPushButton(groupBox); + BtnEditTeam->setFont(*font14); + BtnEditTeam->setText(QPushButton::tr("Edit team")); + GBTlayout->addWidget(BtnEditTeam, 0, 2); + + AGGroupBox = new QGroupBox(this); + AGGroupBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + AGGroupBox->setTitle(QGroupBox::tr("Audio/Graphic options")); + pageLayout->addWidget(AGGroupBox, 1, 0, 1, 3); + + QGridLayout * GBAlayout = new QGridLayout(AGGroupBox); + CBResolution = new QComboBox(AGGroupBox); + CBResolution->addItem("640x480"); + CBResolution->addItem("800x600"); + CBResolution->addItem("1024x768"); + CBResolution->addItem("1280x1024"); + GBAlayout->addWidget(CBResolution, 0, 0); + + CBFullscreen = new QCheckBox(AGGroupBox); + CBFullscreen->setText(QCheckBox::tr("Fullscreen")); + GBAlayout->addWidget(CBFullscreen, 0, 1); + + CBEnableSound = new QCheckBox(AGGroupBox); + CBEnableSound->setText(QCheckBox::tr("Enable sound")); + GBAlayout->addWidget(CBEnableSound, 0, 2); + + pageLayout->addWidget(new QWidget(), 3, 0, 1, 3); + + BtnSaveOptions = new QPushButton(this); + BtnSaveOptions->setFont(*font14); + BtnSaveOptions->setText(QPushButton::tr("Save")); + pageLayout->addWidget(BtnSaveOptions, 4, 2); + + BtnBack = new QPushButton(this); + BtnBack->setFont(*font14); + BtnBack->setText(QPushButton::tr("Back")); + pageLayout->addWidget(BtnBack, 4, 0); +} + +PageNet::PageNet(QWidget* parent) : QWidget(parent) +{ + QFont * font14 = new QFont("MS Shell Dlg", 14); + QGridLayout * pageLayout = new QGridLayout(this); + pageLayout->setColumnStretch(0, 1); + pageLayout->setColumnStretch(1, 1); + pageLayout->setColumnStretch(2, 1); + + NNGroupBox = new QGroupBox(this); + NNGroupBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + NNGroupBox->setTitle(QGroupBox::tr("Net options")); + pageLayout->addWidget(NNGroupBox, 0, 1); + + pageLayout->addWidget(new QWidget(), 1, 1); + + QGridLayout * GBNlayout = new QGridLayout(NNGroupBox); + labelNN = new QLabel(NNGroupBox); + labelNN->setText(QLabel::tr("Net nick")); + GBNlayout->addWidget(labelNN, 0, 0); + + editNetNick = new QLineEdit(NNGroupBox); + editNetNick->setMaxLength(20); + editNetNick->setText(QLineEdit::tr("unnamed")); + GBNlayout->addWidget(editNetNick, 0, 1); + + labelIP = new QLabel(NNGroupBox); + labelIP->setText(QLabel::tr("Server address")); + GBNlayout->addWidget(labelIP, 1, 0); + + editIP = new QLineEdit(NNGroupBox); + editIP->setMaxLength(50); + GBNlayout->addWidget(editIP, 1, 1); + + BtnNetConnect = new QPushButton(this); + BtnNetConnect->setFont(*font14); + BtnNetConnect->setText(QPushButton::tr("Connect")); + pageLayout->addWidget(BtnNetConnect, 2, 2); + + BtnBack = new QPushButton(this); + BtnBack->setFont(*font14); + BtnBack->setText(QPushButton::tr("Back")); + pageLayout->addWidget(BtnBack, 2, 0); +} + +PageNetChat::PageNetChat(QWidget* parent) : QWidget(parent) +{ + QFont * font14 = new QFont("MS Shell Dlg", 14); + QGridLayout * pageLayout = new QGridLayout(this); + pageLayout->setColumnStretch(0, 1); + pageLayout->setColumnStretch(1, 1); + pageLayout->setColumnStretch(2, 1); + + BtnDisconnect = new QPushButton(this); + BtnDisconnect->setFont(*font14); + BtnDisconnect->setText(QPushButton::tr("Disconnect")); + pageLayout->addWidget(BtnDisconnect, 2, 0); + + ChannelsList = new QListWidget(this); + pageLayout->addWidget(ChannelsList, 0, 1); + + BtnJoin = new QPushButton(this); + BtnJoin->setFont(*font14); + BtnJoin->setText(QPushButton::tr("Join")); + pageLayout->addWidget(BtnJoin, 2, 2); + + BtnCreate = new QPushButton(this); + BtnCreate->setFont(*font14); + BtnCreate->setText(QPushButton::tr("Create")); + pageLayout->addWidget(BtnCreate, 1, 2); +} + + +PageNetGame::PageNetGame(QWidget* parent) : QWidget(parent) +{ + QFont * font14 = new QFont("MS Shell Dlg", 14); + QGridLayout * pageLayout = new QGridLayout(this); + pageLayout->setColumnStretch(0, 1); + pageLayout->setColumnStretch(1, 1); + pageLayout->setColumnStretch(2, 1); + + BtnBack = new QPushButton(this); + BtnBack->setFont(*font14); + BtnBack->setText(QPushButton::tr("Back")); + pageLayout->addWidget(BtnBack, 2, 0); + + BtnAddTeam = new QPushButton(this); + BtnAddTeam->setFont(*font14); + BtnAddTeam->setText(QPushButton::tr("Add Team")); + pageLayout->addWidget(BtnAddTeam, 1, 1); + + BtnGo = new QPushButton(this); + BtnGo->setFont(*font14); + BtnGo->setText(QPushButton::tr("Go!")); + pageLayout->addWidget(BtnGo, 2, 2); + + listNetTeams = new QListWidget(this); + pageLayout->addWidget(listNetTeams, 0, 1); +} diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/pages.h --- a/QTfrontend/pages.h Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/pages.h Thu Oct 05 17:02:09 2006 +0000 @@ -1,186 +1,186 @@ -/* - * 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 PAGES_H -#define PAGES_H - -#include - -#include "binds.h" - -class GameCFGWidget; -class QPushButton; -class QGroupBox; -class QComboBox; -class QLabel; -class QToolBox; -class QLineEdit; -class TeamSelWidget; -class DemosList; -class QListWidget; -class QCheckBox; -class SquareLabel; - -class PageMain : public QWidget -{ - Q_OBJECT - -public: - PageMain(QWidget* parent = 0); - - QPushButton *BtnSinglePlayer; - QPushButton *BtnMultiplayer; - QPushButton *BtnNet; - QPushButton *BtnSetup; - QPushButton *BtnDemos; - QPushButton *BtnExit; -}; - -class PageLocalGame : public QWidget -{ - Q_OBJECT - -public: - PageLocalGame(QWidget* parent = 0); - - QPushButton *BtnSimpleGame; - QPushButton *BtnBack; - GameCFGWidget *gameCFG; -}; - -class PageEditTeam : public QWidget -{ - Q_OBJECT - -public: - PageEditTeam(QWidget* parent = 0); - QGroupBox *GBoxHedgehogs; - QGroupBox *GBoxTeam; - QGroupBox *GBoxFort; - QComboBox *CBFort; - SquareLabel *FortPreview; - QGroupBox *GBoxGrave; - QComboBox *CBGrave; - QLabel *GravePreview; - QGroupBox *GBoxBinds; - QToolBox *BindsBox; - QWidget *page_A; - QWidget *page_W; - QWidget *page_WP; - QWidget *page_O; - QPushButton *BtnTeamDiscard; - QPushButton *BtnTeamSave; - QLineEdit * TeamNameEdit; - QLineEdit * HHNameEdit[8]; - QComboBox * CBBind[BINDS_NUMBER]; - -public slots: - void CBGrave_activated(const QString & gravename); - void CBFort_activated(const QString & gravename); - -private: - QLabel * LBind[BINDS_NUMBER]; -}; - -class PageMultiplayer : public QWidget -{ - Q_OBJECT - -public: - PageMultiplayer(QWidget* parent = 0); - - QPushButton *BtnBack; - GameCFGWidget *gameCFG; - TeamSelWidget *teamsSelect; - 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 - -public: - PageOptions(QWidget* parent = 0); - - QPushButton *BtnBack; - QGroupBox *groupBox; - QPushButton *BtnNewTeam; - QPushButton *BtnEditTeam; - QComboBox *CBTeamName; - QGroupBox *AGGroupBox; - QComboBox *CBResolution; - QCheckBox *CBEnableSound; - QCheckBox *CBFullscreen; - QPushButton *BtnSaveOptions; -}; - -class PageNet : public QWidget -{ - Q_OBJECT - -public: - PageNet(QWidget* parent = 0); - - QPushButton *BtnBack; - QPushButton *BtnNetConnect; - QGroupBox *NNGroupBox; - QLabel *labelNN; - QLineEdit *editNetNick; - QLabel *labelIP; - QLineEdit * editIP; -}; - -class PageNetChat : public QWidget -{ - Q_OBJECT - -public: - PageNetChat(QWidget* parent = 0); - - QPushButton *BtnDisconnect; - QListWidget *ChannelsList; - QPushButton *BtnJoin; - QPushButton *BtnCreate; -}; - -class PageNetGame : public QWidget -{ - Q_OBJECT - -public: - PageNetGame(QWidget* parent = 0); - - QPushButton *BtnBack; - QPushButton *BtnAddTeam; - QPushButton *BtnGo; - QListWidget *listNetTeams; -}; - -#endif // PAGES_H +/* + * 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 PAGES_H +#define PAGES_H + +#include + +#include "binds.h" + +class GameCFGWidget; +class QPushButton; +class QGroupBox; +class QComboBox; +class QLabel; +class QToolBox; +class QLineEdit; +class TeamSelWidget; +class DemosList; +class QListWidget; +class QCheckBox; +class SquareLabel; + +class PageMain : public QWidget +{ + Q_OBJECT + +public: + PageMain(QWidget* parent = 0); + + QPushButton *BtnSinglePlayer; + QPushButton *BtnMultiplayer; + QPushButton *BtnNet; + QPushButton *BtnSetup; + QPushButton *BtnDemos; + QPushButton *BtnExit; +}; + +class PageLocalGame : public QWidget +{ + Q_OBJECT + +public: + PageLocalGame(QWidget* parent = 0); + + QPushButton *BtnSimpleGame; + QPushButton *BtnBack; + GameCFGWidget *gameCFG; +}; + +class PageEditTeam : public QWidget +{ + Q_OBJECT + +public: + PageEditTeam(QWidget* parent = 0); + QGroupBox *GBoxHedgehogs; + QGroupBox *GBoxTeam; + QGroupBox *GBoxFort; + QComboBox *CBFort; + SquareLabel *FortPreview; + QGroupBox *GBoxGrave; + QComboBox *CBGrave; + QLabel *GravePreview; + QGroupBox *GBoxBinds; + QToolBox *BindsBox; + QWidget *page_A; + QWidget *page_W; + QWidget *page_WP; + QWidget *page_O; + QPushButton *BtnTeamDiscard; + QPushButton *BtnTeamSave; + QLineEdit * TeamNameEdit; + QLineEdit * HHNameEdit[8]; + QComboBox * CBBind[BINDS_NUMBER]; + +public slots: + void CBGrave_activated(const QString & gravename); + void CBFort_activated(const QString & gravename); + +private: + QLabel * LBind[BINDS_NUMBER]; +}; + +class PageMultiplayer : public QWidget +{ + Q_OBJECT + +public: + PageMultiplayer(QWidget* parent = 0); + + QPushButton *BtnBack; + GameCFGWidget *gameCFG; + TeamSelWidget *teamsSelect; + 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 + +public: + PageOptions(QWidget* parent = 0); + + QPushButton *BtnBack; + QGroupBox *groupBox; + QPushButton *BtnNewTeam; + QPushButton *BtnEditTeam; + QComboBox *CBTeamName; + QGroupBox *AGGroupBox; + QComboBox *CBResolution; + QCheckBox *CBEnableSound; + QCheckBox *CBFullscreen; + QPushButton *BtnSaveOptions; +}; + +class PageNet : public QWidget +{ + Q_OBJECT + +public: + PageNet(QWidget* parent = 0); + + QPushButton *BtnBack; + QPushButton *BtnNetConnect; + QGroupBox *NNGroupBox; + QLabel *labelNN; + QLineEdit *editNetNick; + QLabel *labelIP; + QLineEdit * editIP; +}; + +class PageNetChat : public QWidget +{ + Q_OBJECT + +public: + PageNetChat(QWidget* parent = 0); + + QPushButton *BtnDisconnect; + QListWidget *ChannelsList; + QPushButton *BtnJoin; + QPushButton *BtnCreate; +}; + +class PageNetGame : public QWidget +{ + Q_OBJECT + +public: + PageNetGame(QWidget* parent = 0); + + QPushButton *BtnBack; + QPushButton *BtnAddTeam; + QPushButton *BtnGo; + QListWidget *listNetTeams; +}; + +#endif // PAGES_H diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/predefteams.h --- a/QTfrontend/predefteams.h Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/predefteams.h Thu Oct 05 17:02:09 2006 +0000 @@ -1,82 +1,82 @@ -/* - * 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 PREDEFTEAMS_H -#define PREDEFTEAMS_H - -#include - -#define PREDEFTEAMS_COUNT 3 - -struct PredefinedTeam -{ - const char * TeamName; - const char * hh0name; - const char * hh1name; - const char * hh2name; - const char * hh3name; - const char * hh4name; - const char * hh5name; - const char * hh6name; - const char * hh7name; - QString Grave; - QString Fort; -}; - - -const PredefinedTeam pteams[PREDEFTEAMS_COUNT] = -{ - { - QT_TRANSLATE_NOOP("teams", "Hedgehogs"), - QT_TRANSLATE_NOOP("teams", "hedgehog 1"), - QT_TRANSLATE_NOOP("teams", "hedgehog 2"), - QT_TRANSLATE_NOOP("teams", "hedgehog 3"), - QT_TRANSLATE_NOOP("teams", "hedgehog 4"), - QT_TRANSLATE_NOOP("teams", "hedgehog 5"), - QT_TRANSLATE_NOOP("teams", "hedgehog 6"), - QT_TRANSLATE_NOOP("teams", "hedgehog 7"), - QT_TRANSLATE_NOOP("teams", "hedgehog 8"), - "Simple", "Island" - }, - { - QT_TRANSLATE_NOOP("teams", "Goddess"), - QT_TRANSLATE_NOOP("teams", "Isis"), - QT_TRANSLATE_NOOP("teams", "Astarte"), - QT_TRANSLATE_NOOP("teams", "Diana"), - QT_TRANSLATE_NOOP("teams", "Aphrodite"), - QT_TRANSLATE_NOOP("teams", "Hecate"), - QT_TRANSLATE_NOOP("teams", "Demeter"), - QT_TRANSLATE_NOOP("teams", "Kali"), - QT_TRANSLATE_NOOP("teams", "Inanna"), - "Bone", "Island" - }, - { - QT_TRANSLATE_NOOP("teams", "Fruits"), - QT_TRANSLATE_NOOP("teams", "Banana"), - QT_TRANSLATE_NOOP("teams", "Apple"), - QT_TRANSLATE_NOOP("teams", "Orange"), - QT_TRANSLATE_NOOP("teams", "Lemon"), - QT_TRANSLATE_NOOP("teams", "Pineapple"), - QT_TRANSLATE_NOOP("teams", "Mango"), - QT_TRANSLATE_NOOP("teams", "Peach"), - QT_TRANSLATE_NOOP("teams", "Plum"), - "coffin", "Barrelhouse" - } -}; - -#endif // PREDEFTEAMS_H +/* + * 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 PREDEFTEAMS_H +#define PREDEFTEAMS_H + +#include + +#define PREDEFTEAMS_COUNT 3 + +struct PredefinedTeam +{ + const char * TeamName; + const char * hh0name; + const char * hh1name; + const char * hh2name; + const char * hh3name; + const char * hh4name; + const char * hh5name; + const char * hh6name; + const char * hh7name; + QString Grave; + QString Fort; +}; + + +const PredefinedTeam pteams[PREDEFTEAMS_COUNT] = +{ + { + QT_TRANSLATE_NOOP("teams", "Hedgehogs"), + QT_TRANSLATE_NOOP("teams", "hedgehog 1"), + QT_TRANSLATE_NOOP("teams", "hedgehog 2"), + QT_TRANSLATE_NOOP("teams", "hedgehog 3"), + QT_TRANSLATE_NOOP("teams", "hedgehog 4"), + QT_TRANSLATE_NOOP("teams", "hedgehog 5"), + QT_TRANSLATE_NOOP("teams", "hedgehog 6"), + QT_TRANSLATE_NOOP("teams", "hedgehog 7"), + QT_TRANSLATE_NOOP("teams", "hedgehog 8"), + "Simple", "Island" + }, + { + QT_TRANSLATE_NOOP("teams", "Goddess"), + QT_TRANSLATE_NOOP("teams", "Isis"), + QT_TRANSLATE_NOOP("teams", "Astarte"), + QT_TRANSLATE_NOOP("teams", "Diana"), + QT_TRANSLATE_NOOP("teams", "Aphrodite"), + QT_TRANSLATE_NOOP("teams", "Hecate"), + QT_TRANSLATE_NOOP("teams", "Demeter"), + QT_TRANSLATE_NOOP("teams", "Kali"), + QT_TRANSLATE_NOOP("teams", "Inanna"), + "Bone", "Island" + }, + { + QT_TRANSLATE_NOOP("teams", "Fruits"), + QT_TRANSLATE_NOOP("teams", "Banana"), + QT_TRANSLATE_NOOP("teams", "Apple"), + QT_TRANSLATE_NOOP("teams", "Orange"), + QT_TRANSLATE_NOOP("teams", "Lemon"), + QT_TRANSLATE_NOOP("teams", "Pineapple"), + QT_TRANSLATE_NOOP("teams", "Mango"), + QT_TRANSLATE_NOOP("teams", "Peach"), + QT_TRANSLATE_NOOP("teams", "Plum"), + "coffin", "Barrelhouse" + } +}; + +#endif // PREDEFTEAMS_H diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/sdlkeys.h --- a/QTfrontend/sdlkeys.h Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/sdlkeys.h Thu Oct 05 17:02:09 2006 +0000 @@ -1,148 +1,148 @@ -/* - * Hedgewars, a worms-like game - * Copyright (c) 2005 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 - */ - -char sdlkeys[][2][16] = -{ - {"mousel", "mousel"}, - {"mousem", "mousem"}, - {"mouser", "mouser"}, - {"backspace", "backspace"}, - {"tab", "tab"}, - {"clear", "clear"}, - {"return", "return"}, - {"pause", "pause"}, - {"escape", "escape"}, - {"space", "space"}, - {"!", "!"}, - {"\"", "\""}, - {"#", "#"}, - {"$", "$"}, - {"&", "&"}, - {"'", "'"}, - {"(", "("}, - {")", ")"}, - {"*", "*"}, - {"+", "+"}, - {",", ","}, - {"-", "-"}, - {".", "."}, - {"/", "/"}, - {"0", "0"}, - {"1", "1"}, - {"2", "2"}, - {"3", "3"}, - {"4", "4"}, - {"5", "5"}, - {"6", "6"}, - {"7", "7"}, - {"8", "8"}, - {"9", "9"}, - {":", ":"}, - {";", ";"}, - {"<", "<"}, - {"=", "="}, - {">", ">"}, - {"?", "?"}, - {"@", "@"}, - {"[", "["}, - {"\\", "\\"}, - {"]", "]"}, - {"^", "^"}, - {"_", "_"}, - {"`", "`"}, - {"a", "a"}, - {"b", "b"}, - {"c", "c"}, - {"d", "d"}, - {"e", "e"}, - {"f", "f"}, - {"g", "g"}, - {"h", "h"}, - {"i", "i"}, - {"j", "j"}, - {"k", "k"}, - {"l", "l"}, - {"m", "m"}, - {"n", "n"}, - {"o", "o"}, - {"p", "p"}, - {"q", "q"}, - {"r", "r"}, - {"s", "s"}, - {"t", "t"}, - {"u", "u"}, - {"v", "v"}, - {"w", "w"}, - {"x", "x"}, - {"y", "y"}, - {"z", "z"}, - {"delete", "delete"}, - {"[0]", "[0]"}, - {"[1]", "[1]"}, - {"[2]", "[2]"}, - {"[3]", "[3]"}, - {"[4]", "[4]"}, - {"[5]", "[5]"}, - {"[6]", "[6]"}, - {"[7]", "[7]"}, - {"[8]", "[8]"}, - {"[9]", "[9]"}, - {"[.]", "[.]"}, - {"[/]", "[/]"}, - {"[*]", "[*]"}, - {"[-]", "[-]"}, - {"[+]", "[+]"}, - {"enter", "enter"}, - {"equals", "equals"}, - {"up", "up"}, - {"down", "down"}, - {"right", "right"}, - {"left", "left"}, - {"insert", "insert"}, - {"home", "home"}, - {"end", "end"}, - {"page up", "page up"}, - {"page down", "page down"}, - {"f1", "f1"}, - {"f2", "f2"}, - {"f3", "f3"}, - {"f4", "f4"}, - {"f5", "f5"}, - {"f6", "f6"}, - {"f7", "f7"}, - {"f8", "f8"}, - {"f9", "f9"}, - {"f10", "f10"}, - {"f11", "f11"}, - {"f12", "f12"}, - {"f13", "f13"}, - {"f14", "f14"}, - {"f15", "f15"}, - {"numlock", "numlock"}, - {"caps_lock", "caps_lock"}, - {"scroll_lock", "scroll_lock"}, - {"right_shift", "right_shift"}, - {"left_shift", "left_shift"}, - {"right_ctrl", "right_ctrl"}, - {"left_ctrl", "left_ctrl"}, - {"right_alt", "right_alt"}, - {"left_alt", "left_alt"}, - {"right_meta", "right_meta"}, - {"left_meta", "left_meta"}, - {"", ""} -}; +/* + * Hedgewars, a worms-like game + * Copyright (c) 2005 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 + */ + +char sdlkeys[][2][16] = +{ + {"mousel", "mousel"}, + {"mousem", "mousem"}, + {"mouser", "mouser"}, + {"backspace", "backspace"}, + {"tab", "tab"}, + {"clear", "clear"}, + {"return", "return"}, + {"pause", "pause"}, + {"escape", "escape"}, + {"space", "space"}, + {"!", "!"}, + {"\"", "\""}, + {"#", "#"}, + {"$", "$"}, + {"&", "&"}, + {"'", "'"}, + {"(", "("}, + {")", ")"}, + {"*", "*"}, + {"+", "+"}, + {",", ","}, + {"-", "-"}, + {".", "."}, + {"/", "/"}, + {"0", "0"}, + {"1", "1"}, + {"2", "2"}, + {"3", "3"}, + {"4", "4"}, + {"5", "5"}, + {"6", "6"}, + {"7", "7"}, + {"8", "8"}, + {"9", "9"}, + {":", ":"}, + {";", ";"}, + {"<", "<"}, + {"=", "="}, + {">", ">"}, + {"?", "?"}, + {"@", "@"}, + {"[", "["}, + {"\\", "\\"}, + {"]", "]"}, + {"^", "^"}, + {"_", "_"}, + {"`", "`"}, + {"a", "a"}, + {"b", "b"}, + {"c", "c"}, + {"d", "d"}, + {"e", "e"}, + {"f", "f"}, + {"g", "g"}, + {"h", "h"}, + {"i", "i"}, + {"j", "j"}, + {"k", "k"}, + {"l", "l"}, + {"m", "m"}, + {"n", "n"}, + {"o", "o"}, + {"p", "p"}, + {"q", "q"}, + {"r", "r"}, + {"s", "s"}, + {"t", "t"}, + {"u", "u"}, + {"v", "v"}, + {"w", "w"}, + {"x", "x"}, + {"y", "y"}, + {"z", "z"}, + {"delete", "delete"}, + {"[0]", "[0]"}, + {"[1]", "[1]"}, + {"[2]", "[2]"}, + {"[3]", "[3]"}, + {"[4]", "[4]"}, + {"[5]", "[5]"}, + {"[6]", "[6]"}, + {"[7]", "[7]"}, + {"[8]", "[8]"}, + {"[9]", "[9]"}, + {"[.]", "[.]"}, + {"[/]", "[/]"}, + {"[*]", "[*]"}, + {"[-]", "[-]"}, + {"[+]", "[+]"}, + {"enter", "enter"}, + {"equals", "equals"}, + {"up", "up"}, + {"down", "down"}, + {"right", "right"}, + {"left", "left"}, + {"insert", "insert"}, + {"home", "home"}, + {"end", "end"}, + {"page up", "page up"}, + {"page down", "page down"}, + {"f1", "f1"}, + {"f2", "f2"}, + {"f3", "f3"}, + {"f4", "f4"}, + {"f5", "f5"}, + {"f6", "f6"}, + {"f7", "f7"}, + {"f8", "f8"}, + {"f9", "f9"}, + {"f10", "f10"}, + {"f11", "f11"}, + {"f12", "f12"}, + {"f13", "f13"}, + {"f14", "f14"}, + {"f15", "f15"}, + {"numlock", "numlock"}, + {"caps_lock", "caps_lock"}, + {"scroll_lock", "scroll_lock"}, + {"right_shift", "right_shift"}, + {"left_shift", "left_shift"}, + {"right_ctrl", "right_ctrl"}, + {"left_ctrl", "left_ctrl"}, + {"right_alt", "right_alt"}, + {"left_alt", "left_alt"}, + {"right_meta", "right_meta"}, + {"left_meta", "left_meta"}, + {"", ""} +}; diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/tcpBase.cpp --- a/QTfrontend/tcpBase.cpp Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/tcpBase.cpp Thu Oct 05 17:02:09 2006 +0000 @@ -1,151 +1,151 @@ -/* - * Hedgewars, a worms-like game - * Copyright (c) 2006 Igor Ulyanov - * - * 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 "tcpBase.h" - -#include -#include - -#include -#include - -#include "hwconsts.h" - -QList srvsList; - -TCPBase::TCPBase(bool demoMode) : - m_isDemoMode(demoMode) -{ - IPCServer = new QTcpServer(this); - connect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection())); - IPCServer->setMaxPendingConnections(1); -} - -void TCPBase::NewConnection() -{ - QTcpSocket * client = IPCServer->nextPendingConnection(); - if(!IPCSocket) { - IPCServer->close(); - IPCSocket = client; - connect(client, SIGNAL(disconnected()), this, SLOT(ClientDisconnect())); - connect(client, SIGNAL(readyRead()), this, SLOT(ClientRead())); - SendToClientFirst(); - } else { - qWarning("2nd IPC client?!"); - client->disconnectFromHost(); - } -} - -void TCPBase::RealStart() -{ - IPCSocket = 0; - if (!IPCServer->listen(QHostAddress::LocalHost, IPC_PORT)) { - QMessageBox::critical(0, tr("Error"), - tr("Unable to start the server: %1.") - .arg(IPCServer->errorString())); - } - - QProcess * process; - process = new QProcess; - connect(process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(StartProcessError(QProcess::ProcessError))); - QStringList arguments=setArguments(); - process->start(bindir->absolutePath() + "/hwengine", arguments); -} - -void TCPBase::ClientDisconnect() -{ - IPCSocket->close(); - IPCServer->close(); - - onClientDisconnect(); - - readbuffer.clear(); - - if(srvsList.size()==1) srvsList.pop_front(); - emit isReadyNow(); -} - -void TCPBase::ClientRead() -{ - readbuffer.append(IPCSocket->readAll()); - onClientRead(); -} - -void TCPBase::StartProcessError(QProcess::ProcessError error) -{ - QMessageBox::critical(0, tr("Error"), - tr("Unable to run engine: %1 (") - .arg(error) + bindir->absolutePath() + "/hwengine)"); -} - -void TCPBase::tcpServerReady() -{ - disconnect(srvsList.front(), SIGNAL(isReadyNow()), *(++srvsList.begin()), SLOT(tcpServerReady())); - srvsList.pop_front(); - - QTimer::singleShot(150, this, SLOT(RealStart())); -} - -void TCPBase::Start() -{ - if(srvsList.isEmpty()) { - srvsList.push_back(this); - } else { - connect(srvsList.back(), SIGNAL(isReadyNow()), this, SLOT(tcpServerReady())); - srvsList.push_back(this); - return; - } - RealStart(); -} - -void TCPBase::onClientRead() -{ -} - -void TCPBase::onClientDisconnect() -{ -} - -void TCPBase::SendToClientFirst() -{ -} - -void TCPBase::SendIPC(const QByteArray & buf) -{ - if (buf.size() > MAXMSGCHARS) return; - quint8 len = buf.size(); - RawSendIPC(QByteArray::fromRawData((char *)&len, 1) + buf); -} - -void TCPBase::RawSendIPC(const QByteArray & buf) -{ - if (!IPCSocket) - { - toSendBuf += buf; - } else - { - if (toSendBuf.size() > 0) - { - IPCSocket->write(toSendBuf); - if(m_isDemoMode) demo->append(toSendBuf); - toSendBuf.clear(); - } - IPCSocket->write(buf); - if(m_isDemoMode) demo->append(buf); - } -} +/* + * Hedgewars, a worms-like game + * Copyright (c) 2006 Igor Ulyanov + * + * 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 "tcpBase.h" + +#include +#include + +#include +#include + +#include "hwconsts.h" + +QList srvsList; + +TCPBase::TCPBase(bool demoMode) : + m_isDemoMode(demoMode) +{ + IPCServer = new QTcpServer(this); + connect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection())); + IPCServer->setMaxPendingConnections(1); +} + +void TCPBase::NewConnection() +{ + QTcpSocket * client = IPCServer->nextPendingConnection(); + if(!IPCSocket) { + IPCServer->close(); + IPCSocket = client; + connect(client, SIGNAL(disconnected()), this, SLOT(ClientDisconnect())); + connect(client, SIGNAL(readyRead()), this, SLOT(ClientRead())); + SendToClientFirst(); + } else { + qWarning("2nd IPC client?!"); + client->disconnectFromHost(); + } +} + +void TCPBase::RealStart() +{ + IPCSocket = 0; + if (!IPCServer->listen(QHostAddress::LocalHost, IPC_PORT)) { + QMessageBox::critical(0, tr("Error"), + tr("Unable to start the server: %1.") + .arg(IPCServer->errorString())); + } + + QProcess * process; + process = new QProcess; + connect(process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(StartProcessError(QProcess::ProcessError))); + QStringList arguments=setArguments(); + process->start(bindir->absolutePath() + "/hwengine", arguments); +} + +void TCPBase::ClientDisconnect() +{ + IPCSocket->close(); + IPCServer->close(); + + onClientDisconnect(); + + readbuffer.clear(); + + if(srvsList.size()==1) srvsList.pop_front(); + emit isReadyNow(); +} + +void TCPBase::ClientRead() +{ + readbuffer.append(IPCSocket->readAll()); + onClientRead(); +} + +void TCPBase::StartProcessError(QProcess::ProcessError error) +{ + QMessageBox::critical(0, tr("Error"), + tr("Unable to run engine: %1 (") + .arg(error) + bindir->absolutePath() + "/hwengine)"); +} + +void TCPBase::tcpServerReady() +{ + disconnect(srvsList.front(), SIGNAL(isReadyNow()), *(++srvsList.begin()), SLOT(tcpServerReady())); + srvsList.pop_front(); + + QTimer::singleShot(150, this, SLOT(RealStart())); +} + +void TCPBase::Start() +{ + if(srvsList.isEmpty()) { + srvsList.push_back(this); + } else { + connect(srvsList.back(), SIGNAL(isReadyNow()), this, SLOT(tcpServerReady())); + srvsList.push_back(this); + return; + } + RealStart(); +} + +void TCPBase::onClientRead() +{ +} + +void TCPBase::onClientDisconnect() +{ +} + +void TCPBase::SendToClientFirst() +{ +} + +void TCPBase::SendIPC(const QByteArray & buf) +{ + if (buf.size() > MAXMSGCHARS) return; + quint8 len = buf.size(); + RawSendIPC(QByteArray::fromRawData((char *)&len, 1) + buf); +} + +void TCPBase::RawSendIPC(const QByteArray & buf) +{ + if (!IPCSocket) + { + toSendBuf += buf; + } else + { + if (toSendBuf.size() > 0) + { + IPCSocket->write(toSendBuf); + if(m_isDemoMode) demo->append(toSendBuf); + toSendBuf.clear(); + } + IPCSocket->write(buf); + if(m_isDemoMode) demo->append(buf); + } +} diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/tcpBase.h --- a/QTfrontend/tcpBase.h Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/tcpBase.h Thu Oct 05 17:02:09 2006 +0000 @@ -1,76 +1,76 @@ -/* - * Hedgewars, a worms-like game - * Copyright (c) 2006 Igor Ulyanov - * - * 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 _TCPBASE_INCLUDED -#define _TCPBASE_INCLUDED - -#include -#include -#include -#include -#include -#include -#include - -#include - -#define IPC_PORT 46631 -#define MAXMSGCHARS 255 - -class TCPBase : public QObject -{ - Q_OBJECT - - public: - TCPBase(bool demoMode); - - signals: - void isReadyNow(); - - protected: - void Start(); - - QByteArray readbuffer; - - QByteArray toSendBuf; - QByteArray * demo; - - void SendIPC(const QByteArray & buf); - void RawSendIPC(const QByteArray & buf); - - virtual QStringList setArguments()=0; - virtual void onClientRead(); - virtual void onClientDisconnect(); - virtual void SendToClientFirst(); - - private: - bool m_isDemoMode; - QTcpServer * IPCServer; - QTcpSocket * IPCSocket; - - private slots: - void RealStart(); - void NewConnection(); - void ClientDisconnect(); - void ClientRead(); - void StartProcessError(QProcess::ProcessError error); - - void tcpServerReady(); -}; - -#endif // _TCPBASE_INCLUDED +/* + * Hedgewars, a worms-like game + * Copyright (c) 2006 Igor Ulyanov + * + * 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 _TCPBASE_INCLUDED +#define _TCPBASE_INCLUDED + +#include +#include +#include +#include +#include +#include +#include + +#include + +#define IPC_PORT 46631 +#define MAXMSGCHARS 255 + +class TCPBase : public QObject +{ + Q_OBJECT + + public: + TCPBase(bool demoMode); + + signals: + void isReadyNow(); + + protected: + void Start(); + + QByteArray readbuffer; + + QByteArray toSendBuf; + QByteArray * demo; + + void SendIPC(const QByteArray & buf); + void RawSendIPC(const QByteArray & buf); + + virtual QStringList setArguments()=0; + virtual void onClientRead(); + virtual void onClientDisconnect(); + virtual void SendToClientFirst(); + + private: + bool m_isDemoMode; + QTcpServer * IPCServer; + QTcpSocket * IPCSocket; + + private slots: + void RealStart(); + void NewConnection(); + void ClientDisconnect(); + void ClientRead(); + void StartProcessError(QProcess::ProcessError error); + + void tcpServerReady(); +}; + +#endif // _TCPBASE_INCLUDED diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/team.cpp --- a/QTfrontend/team.cpp Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/team.cpp Thu Oct 05 17:02:09 2006 +0000 @@ -1,201 +1,201 @@ -/* - * Hedgewars, a worms-like game - * Copyright (c) 2005, 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 -#include -#include -#include "team.h" -#include "hwform.h" -#include "predefteams.h" -#include "pages.h" -#include "hwconsts.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; - } -} - -HWTeam::HWTeam(quint8 num) -{ - num %= PREDEFTEAMS_COUNT; - TeamName = QApplication::translate("teams", pteams[num].TeamName); - HHName[0] = QApplication::translate("teams", pteams[num].hh0name); - HHName[1] = QApplication::translate("teams", pteams[num].hh1name); - HHName[2] = QApplication::translate("teams", pteams[num].hh2name); - HHName[3] = QApplication::translate("teams", pteams[num].hh3name); - HHName[4] = QApplication::translate("teams", pteams[num].hh4name); - HHName[5] = QApplication::translate("teams", pteams[num].hh5name); - HHName[6] = QApplication::translate("teams", pteams[num].hh6name); - HHName[7] = QApplication::translate("teams", pteams[num].hh7name); - Grave = pteams[num].Grave; - Fort = pteams[num].Fort; - for(int i = 0; i < BINDS_NUMBER; i++) - { - binds[i].action = cbinds[i].action; - binds[i].strbind = cbinds[i].strbind; - } -} - - -bool HWTeam::LoadFromFile() -{ - QFile cfgfile(cfgdir->absolutePath() + "/" + 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(cfgdir->absolutePath() + "/" + 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->ui.pageEditTeam->TeamNameEdit->setText(TeamName); - for(int i = 0; i < 8; i++) - { - hwform->ui.pageEditTeam->HHNameEdit[i]->setText(HHName[i]); - } - hwform->ui.pageEditTeam->CBGrave->setCurrentIndex(hwform->ui.pageEditTeam->CBGrave->findText(Grave)); - hwform->ui.pageEditTeam->CBGrave_activated(Grave); - - hwform->ui.pageEditTeam->CBFort->setCurrentIndex(hwform->ui.pageEditTeam->CBFort->findText(Fort)); - hwform->ui.pageEditTeam->CBFort_activated(Fort); - - for(int i = 0; i < BINDS_NUMBER; i++) - { - hwform->ui.pageEditTeam->CBBind[i]->setCurrentIndex(hwform->ui.pageEditTeam->CBBind[i]->findText(binds[i].strbind)); - } -} - -void HWTeam::GetFromPage(HWForm * hwform) -{ - TeamName = hwform->ui.pageEditTeam->TeamNameEdit->text(); - for(int i = 0; i < 8; i++) - { - HHName[i] = hwform->ui.pageEditTeam->HHNameEdit[i]->text(); - } - - Grave = hwform->ui.pageEditTeam->CBGrave->currentText(); - Fort = hwform->ui.pageEditTeam->CBFort->currentText(); - for(int i = 0; i < 8; i++) - { - binds[i].strbind = hwform->ui.pageEditTeam->CBBind[i]->currentText(); - } -} - -QByteArray HWTeam::IPCTeamInfo() const -{ - QByteArray buf; - #define ADD(a) { \ - QByteArray strmsg = a.toUtf8(); \ - quint8 sz = strmsg.size(); \ - buf.append(QByteArray((char *)&sz, 1)); \ - buf.append(strmsg); \ - } - - ADD(QString("ename team " + TeamName)); - for (int i = 0; i < 8; i++) - ADD(QString("ename hh%1 ").arg(i).append(HHName[i])); - ADD(QString("egrave " + Grave)); - ADD(QString("efort " + Fort)); - for(int i = 0; i < BINDS_NUMBER; i++) - { - ADD(QString("ebind " + binds[i].strbind + " " + binds[i].action)); - } - #undef ADD - return buf; -} - -bool HWTeam::operator==(const HWTeam& t1) const { - return TeamName==t1.TeamName; -} - -bool HWTeam::operator<(const HWTeam& t1) const { - return TeamName + * + * 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 "team.h" +#include "hwform.h" +#include "predefteams.h" +#include "pages.h" +#include "hwconsts.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; + } +} + +HWTeam::HWTeam(quint8 num) +{ + num %= PREDEFTEAMS_COUNT; + TeamName = QApplication::translate("teams", pteams[num].TeamName); + HHName[0] = QApplication::translate("teams", pteams[num].hh0name); + HHName[1] = QApplication::translate("teams", pteams[num].hh1name); + HHName[2] = QApplication::translate("teams", pteams[num].hh2name); + HHName[3] = QApplication::translate("teams", pteams[num].hh3name); + HHName[4] = QApplication::translate("teams", pteams[num].hh4name); + HHName[5] = QApplication::translate("teams", pteams[num].hh5name); + HHName[6] = QApplication::translate("teams", pteams[num].hh6name); + HHName[7] = QApplication::translate("teams", pteams[num].hh7name); + Grave = pteams[num].Grave; + Fort = pteams[num].Fort; + for(int i = 0; i < BINDS_NUMBER; i++) + { + binds[i].action = cbinds[i].action; + binds[i].strbind = cbinds[i].strbind; + } +} + + +bool HWTeam::LoadFromFile() +{ + QFile cfgfile(cfgdir->absolutePath() + "/" + 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(cfgdir->absolutePath() + "/" + 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->ui.pageEditTeam->TeamNameEdit->setText(TeamName); + for(int i = 0; i < 8; i++) + { + hwform->ui.pageEditTeam->HHNameEdit[i]->setText(HHName[i]); + } + hwform->ui.pageEditTeam->CBGrave->setCurrentIndex(hwform->ui.pageEditTeam->CBGrave->findText(Grave)); + hwform->ui.pageEditTeam->CBGrave_activated(Grave); + + hwform->ui.pageEditTeam->CBFort->setCurrentIndex(hwform->ui.pageEditTeam->CBFort->findText(Fort)); + hwform->ui.pageEditTeam->CBFort_activated(Fort); + + for(int i = 0; i < BINDS_NUMBER; i++) + { + hwform->ui.pageEditTeam->CBBind[i]->setCurrentIndex(hwform->ui.pageEditTeam->CBBind[i]->findText(binds[i].strbind)); + } +} + +void HWTeam::GetFromPage(HWForm * hwform) +{ + TeamName = hwform->ui.pageEditTeam->TeamNameEdit->text(); + for(int i = 0; i < 8; i++) + { + HHName[i] = hwform->ui.pageEditTeam->HHNameEdit[i]->text(); + } + + Grave = hwform->ui.pageEditTeam->CBGrave->currentText(); + Fort = hwform->ui.pageEditTeam->CBFort->currentText(); + for(int i = 0; i < 8; i++) + { + binds[i].strbind = hwform->ui.pageEditTeam->CBBind[i]->currentText(); + } +} + +QByteArray HWTeam::IPCTeamInfo() const +{ + QByteArray buf; + #define ADD(a) { \ + QByteArray strmsg = a.toUtf8(); \ + quint8 sz = strmsg.size(); \ + buf.append(QByteArray((char *)&sz, 1)); \ + buf.append(strmsg); \ + } + + ADD(QString("ename team " + TeamName)); + for (int i = 0; i < 8; i++) + ADD(QString("ename hh%1 ").arg(i).append(HHName[i])); + ADD(QString("egrave " + Grave)); + ADD(QString("efort " + Fort)); + for(int i = 0; i < BINDS_NUMBER; i++) + { + ADD(QString("ebind " + binds[i].strbind + " " + binds[i].action)); + } + #undef ADD + return buf; +} + +bool HWTeam::operator==(const HWTeam& t1) const { + return TeamName==t1.TeamName; +} + +bool HWTeam::operator<(const HWTeam& t1) const { + return TeamName - * - * 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 TEAM_H -#define TEAM_H - -#include -#include "binds.h" - -class HWForm; -class GameUIConfig; - -class HWTeam -{ - public: - HWTeam(const QString & teamname); - HWTeam(quint8 num); - - QString TeamName; - QString HHName[8]; - QString Grave; - QString Fort; - BindAction binds[BINDS_NUMBER]; - - bool LoadFromFile(); - bool SaveToFile(); - void SetToPage(HWForm * hwform); - void GetFromPage(HWForm * hwform); - QByteArray IPCTeamInfo() const; - - bool operator==(const HWTeam& t1) const; - bool operator<(const HWTeam& t1) const; -}; - -#endif +/* + * Hedgewars, a worms-like game + * Copyright (c) 2005 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 TEAM_H +#define TEAM_H + +#include +#include "binds.h" + +class HWForm; +class GameUIConfig; + +class HWTeam +{ + public: + HWTeam(const QString & teamname); + HWTeam(quint8 num); + + QString TeamName; + QString HHName[8]; + QString Grave; + QString Fort; + BindAction binds[BINDS_NUMBER]; + + bool LoadFromFile(); + bool SaveToFile(); + void SetToPage(HWForm * hwform); + void GetFromPage(HWForm * hwform); + QByteArray IPCTeamInfo() const; + + bool operator==(const HWTeam& t1) const; + bool operator<(const HWTeam& t1) const; +}; + +#endif diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/teamselect.cpp --- a/QTfrontend/teamselect.cpp Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/teamselect.cpp Thu Oct 05 17:02:09 2006 +0000 @@ -1,133 +1,133 @@ -/* - * Hedgewars, a worms-like game - * Copyright (c) 2006 Ulyanov Igor - * - * 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 "teamselect.h" -#include "teamselhelper.h" -#include "frameTeam.h" - -void TeamSelWidget::addTeam(HWTeam team) -{ - frameDontPlaying->addTeam(team, false); - curDontPlayingTeams.push_back(team); - QObject::connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), - this, SLOT(changeTeamStatus(HWTeam))); -} - -//void TeamSelWidget::removeTeam(__attribute__ ((unused)) HWTeam team) -//{ - //curDontPlayingTeams.erase(std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team)); -//} - -void TeamSelWidget::changeTeamStatus(HWTeam team) -{ - list::iterator itDontPlay=std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team); - list::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); - - bool willBePlaying=itDontPlay!=curDontPlayingTeams.end(); - - if(!willBePlaying) { - // playing team => dont playing - curDontPlayingTeams.push_back(*itPlay); - curPlayingTeams.erase(itPlay); - } else { - // return if max playing teams reached - if(framePlaying->isFullTeams()) return; - // dont playing team => playing - curPlayingTeams.push_back(*itDontPlay); - curDontPlayingTeams.erase(itDontPlay); - } - - FrameTeams* pRemoveTeams; - FrameTeams* pAddTeams; - if(!willBePlaying) { - pRemoveTeams=framePlaying; - pAddTeams=frameDontPlaying; - } else { - pRemoveTeams=frameDontPlaying; - pAddTeams=framePlaying; - } - - pAddTeams->addTeam(team, willBePlaying); - pRemoveTeams->removeTeam(team); - QObject::connect(pAddTeams->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), - this, SLOT(changeTeamStatus(HWTeam))); - - QSize szh=pAddTeams->sizeHint(); - QSize szh1=pRemoveTeams->sizeHint(); - if(szh.isValid() && szh1.isValid()) { - pAddTeams->resize(pAddTeams->size().width(), szh.height()); - pRemoveTeams->resize(pRemoveTeams->size().width(), szh1.height()); - } -} - -void TeamSelWidget::addScrArea(FrameTeams* pfteams, QColor color) -{ - VertScrArea* area=new VertScrArea(color); - area->setWidget(pfteams); - mainLayout.addWidget(area, 30); -} - -TeamSelWidget::TeamSelWidget(QWidget* parent) : - QWidget(parent), mainLayout(this) -{ - framePlaying=new FrameTeams(); - frameDontPlaying=new FrameTeams(); - addScrArea(framePlaying, QColor("DarkTurquoise")); - addScrArea(frameDontPlaying, QColor("LightGoldenrodYellow")); -} - -void TeamSelWidget::resetPlayingTeams(const QStringList& teamslist) -{ - list::iterator it; - for(it=curPlayingTeams.begin(); it!=curPlayingTeams.end(); it++) { - framePlaying->removeTeam(*it); - } - curPlayingTeams.clear(); - for(it=curDontPlayingTeams.begin(); it!=curDontPlayingTeams.end(); it++) { - frameDontPlaying->removeTeam(*it); - } - curDontPlayingTeams.clear(); - - for (QStringList::ConstIterator it = teamslist.begin(); it != teamslist.end(); ++it ) { - addTeam(*it); - } -} - -bool TeamSelWidget::isPlaying(HWTeam team) const -{ - return std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team)!=curPlayingTeams.end(); -} - -list TeamSelWidget::getPlayingTeams() const -{ - return curPlayingTeams; -} - -unsigned char TeamSelWidget::numHedgedogs(HWTeam team) const -{ - const TeamShowWidget* tsw=dynamic_cast(framePlaying->getTeamWidget(team)); - if(!tsw) return 0; - return tsw->getHedgehogsNum(); -} +/* + * Hedgewars, a worms-like game + * Copyright (c) 2006 Ulyanov Igor + * + * 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 "teamselect.h" +#include "teamselhelper.h" +#include "frameTeam.h" + +void TeamSelWidget::addTeam(HWTeam team) +{ + frameDontPlaying->addTeam(team, false); + curDontPlayingTeams.push_back(team); + QObject::connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), + this, SLOT(changeTeamStatus(HWTeam))); +} + +//void TeamSelWidget::removeTeam(__attribute__ ((unused)) HWTeam team) +//{ + //curDontPlayingTeams.erase(std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team)); +//} + +void TeamSelWidget::changeTeamStatus(HWTeam team) +{ + list::iterator itDontPlay=std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team); + list::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); + + bool willBePlaying=itDontPlay!=curDontPlayingTeams.end(); + + if(!willBePlaying) { + // playing team => dont playing + curDontPlayingTeams.push_back(*itPlay); + curPlayingTeams.erase(itPlay); + } else { + // return if max playing teams reached + if(framePlaying->isFullTeams()) return; + // dont playing team => playing + curPlayingTeams.push_back(*itDontPlay); + curDontPlayingTeams.erase(itDontPlay); + } + + FrameTeams* pRemoveTeams; + FrameTeams* pAddTeams; + if(!willBePlaying) { + pRemoveTeams=framePlaying; + pAddTeams=frameDontPlaying; + } else { + pRemoveTeams=frameDontPlaying; + pAddTeams=framePlaying; + } + + pAddTeams->addTeam(team, willBePlaying); + pRemoveTeams->removeTeam(team); + QObject::connect(pAddTeams->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), + this, SLOT(changeTeamStatus(HWTeam))); + + QSize szh=pAddTeams->sizeHint(); + QSize szh1=pRemoveTeams->sizeHint(); + if(szh.isValid() && szh1.isValid()) { + pAddTeams->resize(pAddTeams->size().width(), szh.height()); + pRemoveTeams->resize(pRemoveTeams->size().width(), szh1.height()); + } +} + +void TeamSelWidget::addScrArea(FrameTeams* pfteams, QColor color) +{ + VertScrArea* area=new VertScrArea(color); + area->setWidget(pfteams); + mainLayout.addWidget(area, 30); +} + +TeamSelWidget::TeamSelWidget(QWidget* parent) : + QWidget(parent), mainLayout(this) +{ + framePlaying=new FrameTeams(); + frameDontPlaying=new FrameTeams(); + addScrArea(framePlaying, QColor("DarkTurquoise")); + addScrArea(frameDontPlaying, QColor("LightGoldenrodYellow")); +} + +void TeamSelWidget::resetPlayingTeams(const QStringList& teamslist) +{ + list::iterator it; + for(it=curPlayingTeams.begin(); it!=curPlayingTeams.end(); it++) { + framePlaying->removeTeam(*it); + } + curPlayingTeams.clear(); + for(it=curDontPlayingTeams.begin(); it!=curDontPlayingTeams.end(); it++) { + frameDontPlaying->removeTeam(*it); + } + curDontPlayingTeams.clear(); + + for (QStringList::ConstIterator it = teamslist.begin(); it != teamslist.end(); ++it ) { + addTeam(*it); + } +} + +bool TeamSelWidget::isPlaying(HWTeam team) const +{ + return std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team)!=curPlayingTeams.end(); +} + +list TeamSelWidget::getPlayingTeams() const +{ + return curPlayingTeams; +} + +unsigned char TeamSelWidget::numHedgedogs(HWTeam team) const +{ + const TeamShowWidget* tsw=dynamic_cast(framePlaying->getTeamWidget(team)); + if(!tsw) return 0; + return tsw->getHedgehogsNum(); +} diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/teamselect.h --- a/QTfrontend/teamselect.h Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/teamselect.h Thu Oct 05 17:02:09 2006 +0000 @@ -2,33 +2,18 @@ * Hedgewars, a worms-like game * Copyright (c) 2006 Ulyanov Igor * - * 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: + * 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 * - * 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 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. * - * 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. + * 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 _TEAM_SELECT_INCLUDED diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/teamselhelper.cpp --- a/QTfrontend/teamselhelper.cpp Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/teamselhelper.cpp Thu Oct 05 17:02:09 2006 +0000 @@ -1,72 +1,72 @@ -/* - * Hedgewars, a worms-like game - * Copyright (c) 2006 Ulyanov Igor - * - * 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 "teamselhelper.h" -#include "hwconsts.h" - -#include -#include -#include - -void TeamLabel::teamButtonClicked() -{ - emit teamActivated(text()); -} - -TeamShowWidget::TeamShowWidget(HWTeam team, bool isPlaying, QWidget * parent) : - QWidget(parent), mainLayout(this), m_team(team), m_isPlaying(isPlaying), phhoger(0) -{ - mainLayout.setSpacing(1); - mainLayout.setMargin(2); - this->setMaximumHeight(35); - QPixmap* px=new QPixmap(QPixmap(datadir->absolutePath() + "/Forts/" + m_team.Fort + "L.png").scaled(40, 40)); - - QPalette newPalette = palette(); - newPalette.setColor(QPalette::Button, palette().color(backgroundRole())); - - QPushButton* butt=new QPushButton(*px, "", this); - butt->setFlat(true); - butt->setGeometry(0, 0, 30, 30); - butt->setMaximumWidth(30); - butt->setPalette(newPalette); - mainLayout.addWidget(butt); - butt->setIconSize(butt->size()); - - QPushButton* bText=new QPushButton(team.TeamName, this); - bText->setPalette(newPalette); - bText->setFlat(true); - mainLayout.addWidget(bText); - - if(m_isPlaying) { - phhoger=new CHedgehogerWidget(this); - mainLayout.addWidget(phhoger); - } - - QObject::connect(butt, SIGNAL(clicked()), this, SLOT(activateTeam())); - QObject::connect(bText, SIGNAL(clicked()), this, SLOT(activateTeam())); -} - -void TeamShowWidget::activateTeam() -{ - emit teamStatusChanged(m_team); -} - -unsigned char TeamShowWidget::getHedgehogsNum() const -{ - return phhoger ? phhoger->getHedgehogsNum() : 0; -} +/* + * Hedgewars, a worms-like game + * Copyright (c) 2006 Ulyanov Igor + * + * 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 "teamselhelper.h" +#include "hwconsts.h" + +#include +#include +#include + +void TeamLabel::teamButtonClicked() +{ + emit teamActivated(text()); +} + +TeamShowWidget::TeamShowWidget(HWTeam team, bool isPlaying, QWidget * parent) : + QWidget(parent), mainLayout(this), m_team(team), m_isPlaying(isPlaying), phhoger(0) +{ + mainLayout.setSpacing(1); + mainLayout.setMargin(2); + this->setMaximumHeight(35); + QPixmap* px=new QPixmap(QPixmap(datadir->absolutePath() + "/Forts/" + m_team.Fort + "L.png").scaled(40, 40)); + + QPalette newPalette = palette(); + newPalette.setColor(QPalette::Button, palette().color(backgroundRole())); + + QPushButton* butt=new QPushButton(*px, "", this); + butt->setFlat(true); + butt->setGeometry(0, 0, 30, 30); + butt->setMaximumWidth(30); + butt->setPalette(newPalette); + mainLayout.addWidget(butt); + butt->setIconSize(butt->size()); + + QPushButton* bText=new QPushButton(team.TeamName, this); + bText->setPalette(newPalette); + bText->setFlat(true); + mainLayout.addWidget(bText); + + if(m_isPlaying) { + phhoger=new CHedgehogerWidget(this); + mainLayout.addWidget(phhoger); + } + + QObject::connect(butt, SIGNAL(clicked()), this, SLOT(activateTeam())); + QObject::connect(bText, SIGNAL(clicked()), this, SLOT(activateTeam())); +} + +void TeamShowWidget::activateTeam() +{ + emit teamStatusChanged(m_team); +} + +unsigned char TeamShowWidget::getHedgehogsNum() const +{ + return phhoger ? phhoger->getHedgehogsNum() : 0; +} diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/teamselhelper.h --- a/QTfrontend/teamselhelper.h Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/teamselhelper.h Thu Oct 05 17:02:09 2006 +0000 @@ -1,67 +1,67 @@ -/* - * Hedgewars, a worms-like game - * Copyright (c) 2006 Ulyanov Igor - * - * 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 _TEAMSEL_HELPER_INCLUDED -#define _TEAMSEL_HELPER_INCLUDED - -#include -#include -#include - -#include "teamselect.h" -#include "hedgehogerWidget.h" - -class TeamLabel : public QLabel -{ - Q_OBJECT - - public: - TeamLabel(const QString& inp_str) : QLabel(inp_str) {}; - - signals: - void teamActivated(QString team_name); - - public slots: - void teamButtonClicked(); - -}; - -class TeamShowWidget : public QWidget -{ - Q_OBJECT - - private slots: - void activateTeam(); - - public: - TeamShowWidget(HWTeam team, bool isPlaying, QWidget * parent); - void setPlaying(bool isPlaying); - unsigned char getHedgehogsNum() const; - - private: - TeamShowWidget(); - QHBoxLayout mainLayout; - HWTeam m_team; - bool m_isPlaying; - CHedgehogerWidget* phhoger; - - signals: - void teamStatusChanged(HWTeam team); -}; - -#endif // _TEAMSEL_HELPER_INCLUDED +/* + * Hedgewars, a worms-like game + * Copyright (c) 2006 Ulyanov Igor + * + * 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 _TEAMSEL_HELPER_INCLUDED +#define _TEAMSEL_HELPER_INCLUDED + +#include +#include +#include + +#include "teamselect.h" +#include "hedgehogerWidget.h" + +class TeamLabel : public QLabel +{ + Q_OBJECT + + public: + TeamLabel(const QString& inp_str) : QLabel(inp_str) {}; + + signals: + void teamActivated(QString team_name); + + public slots: + void teamButtonClicked(); + +}; + +class TeamShowWidget : public QWidget +{ + Q_OBJECT + + private slots: + void activateTeam(); + + public: + TeamShowWidget(HWTeam team, bool isPlaying, QWidget * parent); + void setPlaying(bool isPlaying); + unsigned char getHedgehogsNum() const; + + private: + TeamShowWidget(); + QHBoxLayout mainLayout; + HWTeam m_team; + bool m_isPlaying; + CHedgehogerWidget* phhoger; + + signals: + void teamStatusChanged(HWTeam team); +}; + +#endif // _TEAMSEL_HELPER_INCLUDED diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/ui_hwform.cpp --- a/QTfrontend/ui_hwform.cpp Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/ui_hwform.cpp Thu Oct 05 17:02:09 2006 +0000 @@ -1,82 +1,82 @@ -/* - * 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 -#include -#include "ui_hwform.h" -#include "pages.h" - -void Ui_HWForm::setupUi(QMainWindow *HWForm) -{ - SetupFonts(); - - HWForm->setObjectName(QString::fromUtf8("HWForm")); - HWForm->resize(QSize(620, 430).expandedTo(HWForm->minimumSizeHint())); - HWForm->setMinimumSize(QSize(620, 430)); - HWForm->setWindowTitle(QMainWindow::tr("-= by unC0Rr =-")); - centralWidget = new QWidget(HWForm); - centralWidget->setObjectName(QString::fromUtf8("centralWidget")); - - centralWidget = new QWidget(HWForm); - centralWidget->setObjectName(QString::fromUtf8("centralWidget")); - - SetupPages(centralWidget); - - HWForm->setCentralWidget(centralWidget); - - Pages->setCurrentIndex(0); - - QMetaObject::connectSlotsByName(HWForm); -} - -void Ui_HWForm::SetupFonts() -{ - font14 = new QFont("MS Shell Dlg", 14); -} - -void Ui_HWForm::SetupPages(QWidget *Parent) -{ - Pages = new QStackedLayout(Parent); - - pageLocalGame = new PageLocalGame(); - Pages->addWidget(pageLocalGame); - - pageEditTeam = new PageEditTeam(); - Pages->addWidget(pageEditTeam); - - pageOptions = new PageOptions(); - Pages->addWidget(pageOptions); - - pageMultiplayer = new PageMultiplayer(); - Pages->addWidget(pageMultiplayer); - - pagePlayDemo = new PagePlayDemo(); - Pages->addWidget(pagePlayDemo); - - pageNet = new PageNet(); - Pages->addWidget(pageNet); - - pageNetChat = new PageNetChat(); - Pages->addWidget(pageNetChat); - - pageNetGame = new PageNetGame(); - Pages->addWidget(pageNetGame); - - pageMain = new PageMain(); - Pages->addWidget(pageMain); -} +/* + * 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 +#include +#include "ui_hwform.h" +#include "pages.h" + +void Ui_HWForm::setupUi(QMainWindow *HWForm) +{ + SetupFonts(); + + HWForm->setObjectName(QString::fromUtf8("HWForm")); + HWForm->resize(QSize(620, 430).expandedTo(HWForm->minimumSizeHint())); + HWForm->setMinimumSize(QSize(620, 430)); + HWForm->setWindowTitle(QMainWindow::tr("-= by unC0Rr =-")); + centralWidget = new QWidget(HWForm); + centralWidget->setObjectName(QString::fromUtf8("centralWidget")); + + centralWidget = new QWidget(HWForm); + centralWidget->setObjectName(QString::fromUtf8("centralWidget")); + + SetupPages(centralWidget); + + HWForm->setCentralWidget(centralWidget); + + Pages->setCurrentIndex(0); + + QMetaObject::connectSlotsByName(HWForm); +} + +void Ui_HWForm::SetupFonts() +{ + font14 = new QFont("MS Shell Dlg", 14); +} + +void Ui_HWForm::SetupPages(QWidget *Parent) +{ + Pages = new QStackedLayout(Parent); + + pageLocalGame = new PageLocalGame(); + Pages->addWidget(pageLocalGame); + + pageEditTeam = new PageEditTeam(); + Pages->addWidget(pageEditTeam); + + pageOptions = new PageOptions(); + Pages->addWidget(pageOptions); + + pageMultiplayer = new PageMultiplayer(); + Pages->addWidget(pageMultiplayer); + + pagePlayDemo = new PagePlayDemo(); + Pages->addWidget(pagePlayDemo); + + pageNet = new PageNet(); + Pages->addWidget(pageNet); + + pageNetChat = new PageNetChat(); + Pages->addWidget(pageNetChat); + + pageNetGame = new PageNetGame(); + Pages->addWidget(pageNetGame); + + pageMain = new PageMain(); + Pages->addWidget(pageMain); +} diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/ui_hwform.h --- a/QTfrontend/ui_hwform.h Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/ui_hwform.h Thu Oct 05 17:02:09 2006 +0000 @@ -1,74 +1,74 @@ -/* - * 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 UI_HWFORM_H -#define UI_HWFORM_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class PageMain; -class PageLocalGame; -class PageEditTeam; -class PageMultiplayer; -class PagePlayDemo; -class PageOptions; -class PageNet; -class PageNetChat; -class PageNetGame; - -class Ui_HWForm -{ -public: - QWidget *centralWidget; - - PageMain *pageMain; - PageLocalGame *pageLocalGame; - PageEditTeam *pageEditTeam; - PageMultiplayer *pageMultiplayer; - PagePlayDemo *pagePlayDemo; - PageOptions *pageOptions; - PageNet *pageNet; - PageNetChat *pageNetChat; - PageNetGame *pageNetGame; - - QStackedLayout *Pages; - QFont *font14; - - void setupUi(QMainWindow *HWForm); - void SetupFonts(); - void SetupPages(QWidget *Parent); - void SetupPageNetChat(QWidget *Parent); - void SetupPageNetGame(QWidget *Parent); -}; - -#endif // UI_HWFORM_H +/* + * 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 UI_HWFORM_H +#define UI_HWFORM_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class PageMain; +class PageLocalGame; +class PageEditTeam; +class PageMultiplayer; +class PagePlayDemo; +class PageOptions; +class PageNet; +class PageNetChat; +class PageNetGame; + +class Ui_HWForm +{ +public: + QWidget *centralWidget; + + PageMain *pageMain; + PageLocalGame *pageLocalGame; + PageEditTeam *pageEditTeam; + PageMultiplayer *pageMultiplayer; + PagePlayDemo *pagePlayDemo; + PageOptions *pageOptions; + PageNet *pageNet; + PageNetChat *pageNetChat; + PageNetGame *pageNetGame; + + QStackedLayout *Pages; + QFont *font14; + + void setupUi(QMainWindow *HWForm); + void SetupFonts(); + void SetupPages(QWidget *Parent); + void SetupPageNetChat(QWidget *Parent); + void SetupPageNetGame(QWidget *Parent); +}; + +#endif // UI_HWFORM_H diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/vertScrollArea.cpp --- a/QTfrontend/vertScrollArea.cpp Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/vertScrollArea.cpp Thu Oct 05 17:02:09 2006 +0000 @@ -1,34 +1,34 @@ -/* - * Hedgewars, a worms-like game - * Copyright (c) 2006 Ulyanov Igor - * - * 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 "vertScrollArea.h" - -#include - -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()); -} +/* + * Hedgewars, a worms-like game + * Copyright (c) 2006 Ulyanov Igor + * + * 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 "vertScrollArea.h" + +#include + +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()); +} diff -r 57c2ef19f719 -r f97a7a3dc8f6 QTfrontend/vertScrollArea.h --- a/QTfrontend/vertScrollArea.h Thu Oct 05 16:33:18 2006 +0000 +++ b/QTfrontend/vertScrollArea.h Thu Oct 05 17:02:09 2006 +0000 @@ -1,35 +1,35 @@ -/* - * Hedgewars, a worms-like game - * Copyright (c) 2006 Ulyanov Igor - * - * 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 _VERT_SCROLL_AREA_INCLUDED -#define _VERT_SCROLL_AREA_INCLUDED - -#include - -class VertScrArea : public QScrollArea -{ - Q_OBJECT - -public: - VertScrArea(QColor frameColor, QWidget * parent = 0); - -protected: - virtual void resizeEvent(QResizeEvent * event); -}; - -#endif // _VERT_SCROLL_AREA_INCLUDED +/* + * Hedgewars, a worms-like game + * Copyright (c) 2006 Ulyanov Igor + * + * 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 _VERT_SCROLL_AREA_INCLUDED +#define _VERT_SCROLL_AREA_INCLUDED + +#include + +class VertScrArea : public QScrollArea +{ + Q_OBJECT + +public: + VertScrArea(QColor frameColor, QWidget * parent = 0); + +protected: + virtual void resizeEvent(QResizeEvent * event); +}; + +#endif // _VERT_SCROLL_AREA_INCLUDED diff -r 57c2ef19f719 -r f97a7a3dc8f6 hedgewars/CMakeLists.txt --- a/hedgewars/CMakeLists.txt Thu Oct 05 16:33:18 2006 +0000 +++ b/hedgewars/CMakeLists.txt Thu Oct 05 17:02:09 2006 +0000 @@ -1,42 +1,42 @@ -set(dcc32_tryexe dcc32.exe) -set(fpc_tryexe fpc) -set(hwengine_project "hwengine.dpr") - -find_program(dcc32_executable ${dcc32_tryexe}) -find_program(fpc_executable ${fpc_tryexe}) - -if (dcc32_executable) - exec_program(${dcc32_executable} ARGS "--version" OUTPUT_VARIABLE dcc32_output) -endif (dcc32_executable) - -if (fpc_executable) - exec_program(${fpc_executable} ARGS "-h" OUTPUT_VARIABLE fpc_output) -endif (fpc_executable) - -string(REGEX MATCH "[0-9]+\\.[0-9]+" dcc32version "${dcc32_output}") -if (dcc32version) - set(pascal_compiler ${dcc32_executable}) - set(pascal_compiler_flags "-B" "-W" ${hwengine_project}) -else (dcc32version) - string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" fpc_version "${fpc_output}") - if (fpc_version) - string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" fpc_vers_major "${fpc_version}") - string(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" fpc_vers_minor "${fpc_version}") - string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" fpc_vers_patch "${fpc_version}") - math(EXPR fpc_ver "${fpc_vers_major}*10000 + ${fpc_vers_minor}*100 + ${fpc_vers_patch}") - if (${fpc_ver} LESS "010906") - message("Minimum required version of FreePascal is 2.0.5") - else (${fpc_ver} LESS "010906") - set(pascal_compiler ${fpc_executable}) - set(pascal_compiler_flags "-B" "-Sd" "-Xs" "-OG" "-O2" "-Cs2000000" ${hwengine_project}) - endif (${fpc_ver} LESS "010906") - endif (fpc_version) -endif (dcc32version) - -if (NOT pascal_compiler) - message(FATAL_ERROR "No Pascal compiler found!") -endif (NOT pascal_compiler) - -add_custom_target(hwengine ALL COMMAND "${pascal_compiler}" ${pascal_compiler_flags}) - -install(PROGRAMS "hwengine${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION bin) +set(dcc32_tryexe dcc32.exe) +set(fpc_tryexe fpc) +set(hwengine_project "hwengine.dpr") + +find_program(dcc32_executable ${dcc32_tryexe}) +find_program(fpc_executable ${fpc_tryexe}) + +if (dcc32_executable) + exec_program(${dcc32_executable} ARGS "--version" OUTPUT_VARIABLE dcc32_output) +endif (dcc32_executable) + +if (fpc_executable) + exec_program(${fpc_executable} ARGS "-h" OUTPUT_VARIABLE fpc_output) +endif (fpc_executable) + +string(REGEX MATCH "[0-9]+\\.[0-9]+" dcc32version "${dcc32_output}") +if (dcc32version) + set(pascal_compiler ${dcc32_executable}) + set(pascal_compiler_flags "-B" "-W" ${hwengine_project}) +else (dcc32version) + string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" fpc_version "${fpc_output}") + if (fpc_version) + string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" fpc_vers_major "${fpc_version}") + string(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" fpc_vers_minor "${fpc_version}") + string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" fpc_vers_patch "${fpc_version}") + math(EXPR fpc_ver "${fpc_vers_major}*10000 + ${fpc_vers_minor}*100 + ${fpc_vers_patch}") + if (${fpc_ver} LESS "010906") + message("Minimum required version of FreePascal is 2.0.5") + else (${fpc_ver} LESS "010906") + set(pascal_compiler ${fpc_executable}) + set(pascal_compiler_flags "-B" "-Sd" "-Xs" "-OG" "-O2" "-Cs2000000" ${hwengine_project}) + endif (${fpc_ver} LESS "010906") + endif (fpc_version) +endif (dcc32version) + +if (NOT pascal_compiler) + message(FATAL_ERROR "No Pascal compiler found!") +endif (NOT pascal_compiler) + +add_custom_target(hwengine ALL COMMAND "${pascal_compiler}" ${pascal_compiler_flags}) + +install(PROGRAMS "hwengine${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION bin) diff -r 57c2ef19f719 -r f97a7a3dc8f6 hedgewars/checksdl.dpr --- a/hedgewars/checksdl.dpr Thu Oct 05 16:33:18 2006 +0000 +++ b/hedgewars/checksdl.dpr Thu Oct 05 17:02:09 2006 +0000 @@ -1,31 +1,31 @@ -program checksdl; -{$APPTYPE CONSOLE} -uses - SDLh; - -procedure fail; -begin -writeln('fail'); -halt -end; - -var SDLPrimSurface: PSDL_Surface; - Color: Longword; -begin -Write('Init SDL... '); -if SDL_Init(SDL_INIT_VIDEO) < 0 then fail; -WriteLn('ok'); - -Write('Create primsurface... '); -SDLPrimSurface:= SDL_SetVideoMode(640, 480, 16, 0); -if (SDLPrimSurface = nil) then fail; -WriteLn('ok'); - -Write('Try map color... '); -Color:= $FFFFFF; -Color:= SDL_MapRGB(SDLPrimSurface^.format, (Color shr 16) and $FF, (Color shr 8) and $FF, Color and $FF); -Writeln('ok'); -Writeln('Result = ', Color); - -SDL_Quit() +program checksdl; +{$APPTYPE CONSOLE} +uses + SDLh; + +procedure fail; +begin +writeln('fail'); +halt +end; + +var SDLPrimSurface: PSDL_Surface; + Color: Longword; +begin +Write('Init SDL... '); +if SDL_Init(SDL_INIT_VIDEO) < 0 then fail; +WriteLn('ok'); + +Write('Create primsurface... '); +SDLPrimSurface:= SDL_SetVideoMode(640, 480, 16, 0); +if (SDLPrimSurface = nil) then fail; +WriteLn('ok'); + +Write('Try map color... '); +Color:= $FFFFFF; +Color:= SDL_MapRGB(SDLPrimSurface^.format, (Color shr 16) and $FF, (Color shr 8) and $FF, Color and $FF); +Writeln('ok'); +Writeln('Result = ', Color); + +SDL_Quit() end. \ No newline at end of file diff -r 57c2ef19f719 -r f97a7a3dc8f6 hedgewars/tunsetborder.inc --- a/hedgewars/tunsetborder.inc Thu Oct 05 16:33:18 2006 +0000 +++ b/hedgewars/tunsetborder.inc Thu Oct 05 17:02:09 2006 +0000 @@ -1,8 +1,8 @@ - begin - X:= X + dX; - Y:= Y + dY; - tx:= round(X); - ty:= round(Y); - if ((ty and $FFFFFC00) = 0) and ((tx and $FFFFF800) = 0)and (Land[ty, tx] = $FFFFFF) then - SetLandPixel(ty, tx) + begin + X:= X + dX; + Y:= Y + dY; + tx:= round(X); + ty:= round(Y); + if ((ty and $FFFFFC00) = 0) and ((tx and $FFFFF800) = 0)and (Land[ty, tx] = $FFFFFF) then + SetLandPixel(ty, tx) end; \ No newline at end of file diff -r 57c2ef19f719 -r f97a7a3dc8f6 hedgewars/uLandGraphics.pas --- a/hedgewars/uLandGraphics.pas Thu Oct 05 16:33:18 2006 +0000 +++ b/hedgewars/uLandGraphics.pas Thu Oct 05 17:02:09 2006 +0000 @@ -1,250 +1,250 @@ -unit uLandGraphics; -interface - -type PRangeArray = ^TRangeArray; - TRangeArray = array[0..31] of record - Left, Right: integer; - end; - -procedure DrawExplosion(X, Y, Radius: integer); -procedure DrawHLinesExplosions(ar: PRangeArray; Radius: integer; y, dY: integer; Count: Byte); -procedure DrawTunnel(X, Y, dX, dY: Double; ticks, HalfWidth: integer); -procedure FillRoundInLand(X, Y, Radius: integer; Value: Longword); - -implementation -uses SDLh, uStore, uMisc, uLand, uConsts; - -procedure FillCircleLines(x, y, dx, dy: integer; Value: Longword); -var i: integer; -begin -if ((y + dy) and $FFFFFC00) = 0 then - for i:= max(x - dx, 0) to min(x + dx, 2047) do Land[y + dy, i]:= Value; -if ((y - dy) and $FFFFFC00) = 0 then - for i:= max(x - dx, 0) to min(x + dx, 2047) do Land[y - dy, i]:= Value; -if ((y + dx) and $FFFFFC00) = 0 then - for i:= max(x - dy, 0) to min(x + dy, 2047) do Land[y + dx, i]:= Value; -if ((y - dx) and $FFFFFC00) = 0 then - for i:= max(x - dy, 0) to min(x + dy, 2047) do Land[y - dx, i]:= Value; -end; - -procedure FillRoundInLand(X, Y, Radius: integer; Value: Longword); -var dx, dy, d: integer; -begin - dx:= 0; - dy:= Radius; - d:= 3 - 2 * Radius; - while (dx < dy) do - begin - FillCircleLines(x, y, dx, dy, Value); - if (d < 0) - then d:= d + 4 * dx + 6 - else begin - d:= d + 4 * (dx - dy) + 10; - dec(dy) - end; - inc(dx) - end; - if (dx = dy) then FillCircleLines(x, y, dx, dy, Value); -end; - -procedure ClearLandPixel(y, x: integer); -var p: PByteArray; -begin -p:= @PByteArray(LandSurface.pixels)^[LandSurface.pitch*y]; -case LandSurface.format.BytesPerPixel of - 1: ;// not supported - 2: PWord(@p[x * 2])^:= 0; - 3: begin - p[x * 3 + 0]:= 0; - p[x * 3 + 1]:= 0; - p[x * 3 + 2]:= 0; - end; - 4: PLongword(@p[x * 4])^:= 0; - end -end; - -procedure SetLandPixel(y, x: integer); -var p: PByteArray; -begin -p:= @PByteArray(LandSurface.pixels)^[LandSurface.pitch*y]; -case LandSurface.format.BytesPerPixel of - 1: ;// not supported - 2: PWord(@p[x * 2])^:= cExplosionBorderColor; - 3: begin - p[x * 3 + 0]:= cExplosionBorderColor and $FF; - p[x * 3 + 1]:= (cExplosionBorderColor shr 8) and $FF; - p[x * 3 + 2]:= cExplosionBorderColor shr 16; - end; - 4: PLongword(@p[x * 4])^:= cExplosionBorderColor; - end -end; - -procedure FillLandCircleLines0(x, y, dx, dy: integer); -var i: integer; -begin -if ((y + dy) and $FFFFFC00) = 0 then - for i:= max(x - dx, 0) to min(x + dx, 2047) do ClearLandPixel(y + dy, i); -if ((y - dy) and $FFFFFC00) = 0 then - for i:= max(x - dx, 0) to min(x + dx, 2047) do ClearLandPixel(y - dy, i); -if ((y + dx) and $FFFFFC00) = 0 then - for i:= max(x - dy, 0) to min(x + dy, 2047) do ClearLandPixel(y + dx, i); -if ((y - dx) and $FFFFFC00) = 0 then - for i:= max(x - dy, 0) to min(x + dy, 2047) do ClearLandPixel(y - dx, i); -end; - -procedure FillLandCircleLinesEBC(x, y, dx, dy: integer); -var i: integer; -begin -if ((y + dy) and $FFFFFC00) = 0 then - for i:= max(x - dx, 0) to min(x + dx, 2047) do - if Land[y + dy, i] = COLOR_LAND then SetLandPixel(y + dy, i); -if ((y - dy) and $FFFFFC00) = 0 then - for i:= max(x - dx, 0) to min(x + dx, 2047) do - if Land[y - dy, i] = COLOR_LAND then SetLandPixel(y - dy, i); -if ((y + dx) and $FFFFFC00) = 0 then - for i:= max(x - dy, 0) to min(x + dy, 2047) do - if Land[y + dx, i] = COLOR_LAND then SetLandPixel(y + dx, i); -if ((y - dx) and $FFFFFC00) = 0 then - for i:= max(x - dy, 0) to min(x + dy, 2047) do - if Land[y - dx, i] = COLOR_LAND then SetLandPixel(y - dx, i); -end; - -procedure DrawExplosion(X, Y, Radius: integer); -var dx, dy, d: integer; -begin -FillRoundInLand(X, Y, Radius, 0); - -if SDL_MustLock(LandSurface) then - SDLTry(SDL_LockSurface(LandSurface) >= 0, true); - - dx:= 0; - dy:= Radius; - d:= 3 - 2 * Radius; - while (dx < dy) do - begin - FillLandCircleLines0(x, y, dx, dy); - if (d < 0) - then d:= d + 4 * dx + 6 - else begin - d:= d + 4 * (dx - dy) + 10; - dec(dy) - end; - inc(dx) - end; - if (dx = dy) then FillLandCircleLines0(x, y, dx, dy); - inc(Radius, 4); - dx:= 0; - dy:= Radius; - d:= 3 - 2 * Radius; - while (dx < dy) do - begin - FillLandCircleLinesEBC(x, y, dx, dy); - if (d < 0) - then d:= d + 4 * dx + 6 - else begin - d:= d + 4 * (dx - dy) + 10; - dec(dy) - end; - inc(dx) - end; - if (dx = dy) then FillLandCircleLinesEBC(x, y, dx, dy); - -if SDL_MustLock(LandSurface) then - SDL_UnlockSurface(LandSurface); -end; - -procedure DrawHLinesExplosions(ar: PRangeArray; Radius: integer; y, dY: integer; Count: Byte); -var tx, ty, i: LongInt; -begin -if SDL_MustLock(LandSurface) then - SDL_LockSurface(LandSurface); - -for i:= 0 to Pred(Count) do - begin - for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do - for tx:= max(0, ar[i].Left - Radius) to min(2047, ar[i].Right + Radius) do - ClearLandPixel(y + ty, tx); - inc(y, dY) - end; - -inc(Radius, 4); -dec(y, Count*dY); - -for i:= 0 to Pred(Count) do - begin - for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do - for tx:= max(0, ar[i].Left - Radius) to min(2047, ar[i].Right + Radius) do - if Land[y + ty, tx] = $FFFFFF then - SetLandPixel(y + ty, tx); - inc(y, dY) - end; - -if SDL_MustLock(LandSurface) then - SDL_UnlockSurface(LandSurface); -end; - -// -// - (dX, dY) - direction, vector of length = 0.5 -// -procedure DrawTunnel(X, Y, dX, dY: Double; ticks, HalfWidth: integer); -var nx, ny: Double; - i, t, tx, ty: Longint; -begin // (-dY, dX) is (dX, dY) rotated by PI/2 -if SDL_MustLock(LandSurface) then - SDL_LockSurface(LandSurface); - -nx:= X + dY * (HalfWidth + 8); -ny:= Y - dX * (HalfWidth + 8); - -for i:= 0 to 7 do - begin - X:= nx - 8 * dX; - Y:= ny - 8 * dY; - for t:= -8 to ticks + 8 do - {$include tunsetborder.inc} - nx:= nx - dY; - ny:= ny + dX; - end; - -for i:= -HalfWidth to HalfWidth do - begin - X:= nx - dX * 8; - Y:= ny - dY * 8; - for t:= 0 to 7 do - {$include tunsetborder.inc} - X:= nx; - Y:= ny; - for t:= 0 to ticks do - begin - X:= X + dX; - Y:= Y + dY; - tx:= round(X); - ty:= round(Y); - if ((ty and $FFFFFC00) = 0) and ((tx and $FFFFF800) = 0) then - begin - Land[ty, tx]:= 0; - ClearLandPixel(ty, tx); - end - end; - for t:= 0 to 7 do - {$include tunsetborder.inc} - nx:= nx - dY; - ny:= ny + dX; - end; - -for i:= 0 to 7 do - begin - X:= nx - 8 * dX; - Y:= ny - 8 * dY; - for t:= -8 to ticks + 8 do - {$include tunsetborder.inc} - nx:= nx - dY; - ny:= ny + dX; - end; - -if SDL_MustLock(LandSurface) then - SDL_UnlockSurface(LandSurface) -end; - - -end. +unit uLandGraphics; +interface + +type PRangeArray = ^TRangeArray; + TRangeArray = array[0..31] of record + Left, Right: integer; + end; + +procedure DrawExplosion(X, Y, Radius: integer); +procedure DrawHLinesExplosions(ar: PRangeArray; Radius: integer; y, dY: integer; Count: Byte); +procedure DrawTunnel(X, Y, dX, dY: Double; ticks, HalfWidth: integer); +procedure FillRoundInLand(X, Y, Radius: integer; Value: Longword); + +implementation +uses SDLh, uStore, uMisc, uLand, uConsts; + +procedure FillCircleLines(x, y, dx, dy: integer; Value: Longword); +var i: integer; +begin +if ((y + dy) and $FFFFFC00) = 0 then + for i:= max(x - dx, 0) to min(x + dx, 2047) do Land[y + dy, i]:= Value; +if ((y - dy) and $FFFFFC00) = 0 then + for i:= max(x - dx, 0) to min(x + dx, 2047) do Land[y - dy, i]:= Value; +if ((y + dx) and $FFFFFC00) = 0 then + for i:= max(x - dy, 0) to min(x + dy, 2047) do Land[y + dx, i]:= Value; +if ((y - dx) and $FFFFFC00) = 0 then + for i:= max(x - dy, 0) to min(x + dy, 2047) do Land[y - dx, i]:= Value; +end; + +procedure FillRoundInLand(X, Y, Radius: integer; Value: Longword); +var dx, dy, d: integer; +begin + dx:= 0; + dy:= Radius; + d:= 3 - 2 * Radius; + while (dx < dy) do + begin + FillCircleLines(x, y, dx, dy, Value); + if (d < 0) + then d:= d + 4 * dx + 6 + else begin + d:= d + 4 * (dx - dy) + 10; + dec(dy) + end; + inc(dx) + end; + if (dx = dy) then FillCircleLines(x, y, dx, dy, Value); +end; + +procedure ClearLandPixel(y, x: integer); +var p: PByteArray; +begin +p:= @PByteArray(LandSurface.pixels)^[LandSurface.pitch*y]; +case LandSurface.format.BytesPerPixel of + 1: ;// not supported + 2: PWord(@p[x * 2])^:= 0; + 3: begin + p[x * 3 + 0]:= 0; + p[x * 3 + 1]:= 0; + p[x * 3 + 2]:= 0; + end; + 4: PLongword(@p[x * 4])^:= 0; + end +end; + +procedure SetLandPixel(y, x: integer); +var p: PByteArray; +begin +p:= @PByteArray(LandSurface.pixels)^[LandSurface.pitch*y]; +case LandSurface.format.BytesPerPixel of + 1: ;// not supported + 2: PWord(@p[x * 2])^:= cExplosionBorderColor; + 3: begin + p[x * 3 + 0]:= cExplosionBorderColor and $FF; + p[x * 3 + 1]:= (cExplosionBorderColor shr 8) and $FF; + p[x * 3 + 2]:= cExplosionBorderColor shr 16; + end; + 4: PLongword(@p[x * 4])^:= cExplosionBorderColor; + end +end; + +procedure FillLandCircleLines0(x, y, dx, dy: integer); +var i: integer; +begin +if ((y + dy) and $FFFFFC00) = 0 then + for i:= max(x - dx, 0) to min(x + dx, 2047) do ClearLandPixel(y + dy, i); +if ((y - dy) and $FFFFFC00) = 0 then + for i:= max(x - dx, 0) to min(x + dx, 2047) do ClearLandPixel(y - dy, i); +if ((y + dx) and $FFFFFC00) = 0 then + for i:= max(x - dy, 0) to min(x + dy, 2047) do ClearLandPixel(y + dx, i); +if ((y - dx) and $FFFFFC00) = 0 then + for i:= max(x - dy, 0) to min(x + dy, 2047) do ClearLandPixel(y - dx, i); +end; + +procedure FillLandCircleLinesEBC(x, y, dx, dy: integer); +var i: integer; +begin +if ((y + dy) and $FFFFFC00) = 0 then + for i:= max(x - dx, 0) to min(x + dx, 2047) do + if Land[y + dy, i] = COLOR_LAND then SetLandPixel(y + dy, i); +if ((y - dy) and $FFFFFC00) = 0 then + for i:= max(x - dx, 0) to min(x + dx, 2047) do + if Land[y - dy, i] = COLOR_LAND then SetLandPixel(y - dy, i); +if ((y + dx) and $FFFFFC00) = 0 then + for i:= max(x - dy, 0) to min(x + dy, 2047) do + if Land[y + dx, i] = COLOR_LAND then SetLandPixel(y + dx, i); +if ((y - dx) and $FFFFFC00) = 0 then + for i:= max(x - dy, 0) to min(x + dy, 2047) do + if Land[y - dx, i] = COLOR_LAND then SetLandPixel(y - dx, i); +end; + +procedure DrawExplosion(X, Y, Radius: integer); +var dx, dy, d: integer; +begin +FillRoundInLand(X, Y, Radius, 0); + +if SDL_MustLock(LandSurface) then + SDLTry(SDL_LockSurface(LandSurface) >= 0, true); + + dx:= 0; + dy:= Radius; + d:= 3 - 2 * Radius; + while (dx < dy) do + begin + FillLandCircleLines0(x, y, dx, dy); + if (d < 0) + then d:= d + 4 * dx + 6 + else begin + d:= d + 4 * (dx - dy) + 10; + dec(dy) + end; + inc(dx) + end; + if (dx = dy) then FillLandCircleLines0(x, y, dx, dy); + inc(Radius, 4); + dx:= 0; + dy:= Radius; + d:= 3 - 2 * Radius; + while (dx < dy) do + begin + FillLandCircleLinesEBC(x, y, dx, dy); + if (d < 0) + then d:= d + 4 * dx + 6 + else begin + d:= d + 4 * (dx - dy) + 10; + dec(dy) + end; + inc(dx) + end; + if (dx = dy) then FillLandCircleLinesEBC(x, y, dx, dy); + +if SDL_MustLock(LandSurface) then + SDL_UnlockSurface(LandSurface); +end; + +procedure DrawHLinesExplosions(ar: PRangeArray; Radius: integer; y, dY: integer; Count: Byte); +var tx, ty, i: LongInt; +begin +if SDL_MustLock(LandSurface) then + SDL_LockSurface(LandSurface); + +for i:= 0 to Pred(Count) do + begin + for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do + for tx:= max(0, ar[i].Left - Radius) to min(2047, ar[i].Right + Radius) do + ClearLandPixel(y + ty, tx); + inc(y, dY) + end; + +inc(Radius, 4); +dec(y, Count*dY); + +for i:= 0 to Pred(Count) do + begin + for ty:= max(-Radius, -y) to min(Radius, 1023 - y) do + for tx:= max(0, ar[i].Left - Radius) to min(2047, ar[i].Right + Radius) do + if Land[y + ty, tx] = $FFFFFF then + SetLandPixel(y + ty, tx); + inc(y, dY) + end; + +if SDL_MustLock(LandSurface) then + SDL_UnlockSurface(LandSurface); +end; + +// +// - (dX, dY) - direction, vector of length = 0.5 +// +procedure DrawTunnel(X, Y, dX, dY: Double; ticks, HalfWidth: integer); +var nx, ny: Double; + i, t, tx, ty: Longint; +begin // (-dY, dX) is (dX, dY) rotated by PI/2 +if SDL_MustLock(LandSurface) then + SDL_LockSurface(LandSurface); + +nx:= X + dY * (HalfWidth + 8); +ny:= Y - dX * (HalfWidth + 8); + +for i:= 0 to 7 do + begin + X:= nx - 8 * dX; + Y:= ny - 8 * dY; + for t:= -8 to ticks + 8 do + {$include tunsetborder.inc} + nx:= nx - dY; + ny:= ny + dX; + end; + +for i:= -HalfWidth to HalfWidth do + begin + X:= nx - dX * 8; + Y:= ny - dY * 8; + for t:= 0 to 7 do + {$include tunsetborder.inc} + X:= nx; + Y:= ny; + for t:= 0 to ticks do + begin + X:= X + dX; + Y:= Y + dY; + tx:= round(X); + ty:= round(Y); + if ((ty and $FFFFFC00) = 0) and ((tx and $FFFFF800) = 0) then + begin + Land[ty, tx]:= 0; + ClearLandPixel(ty, tx); + end + end; + for t:= 0 to 7 do + {$include tunsetborder.inc} + nx:= nx - dY; + ny:= ny + dX; + end; + +for i:= 0 to 7 do + begin + X:= nx - 8 * dX; + Y:= ny - 8 * dY; + for t:= -8 to ticks + 8 do + {$include tunsetborder.inc} + nx:= nx - dY; + ny:= ny + dX; + end; + +if SDL_MustLock(LandSurface) then + SDL_UnlockSurface(LandSurface) +end; + + +end. diff -r 57c2ef19f719 -r f97a7a3dc8f6 hedgewars/uLandObjects.pas --- a/hedgewars/uLandObjects.pas Thu Oct 05 16:33:18 2006 +0000 +++ b/hedgewars/uLandObjects.pas Thu Oct 05 17:02:09 2006 +0000 @@ -1,448 +1,448 @@ -(* - * Hedgewars, a worms-like game - * Copyright (c) 2005, 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 - *) - -unit uLandObjects; -interface -uses SDLh; -{$include options.inc} - -procedure AddObjects(InSurface, Surface: PSDL_Surface); -procedure BlitImageAndGenerateCollisionInfo(cpX, cpY: Longword; Image, Surface: PSDL_Surface); - -implementation -uses uLand, uStore, uConsts, uMisc, uConsole, uRandom; -const MaxRects = 256; - MAXOBJECTRECTS = 16; - MAXTHEMEOBJECTS = 32; - -type PRectArray = ^TRectsArray; - TRectsArray = array[0..MaxRects] of TSDL_Rect; - TThemeObject = record - Surf: PSDL_Surface; - inland: TSDL_Rect; - outland: array[0..Pred(MAXOBJECTRECTS)] of TSDL_Rect; - rectcnt: Longword; - Width, Height: Longword; - Maxcnt: Longword; - end; - TThemeObjects = record - Count: integer; - objs: array[0..Pred(MAXTHEMEOBJECTS)] of TThemeObject; - end; - TSprayObject = record - Surf: PSDL_Surface; - Width, Height: Longword; - Maxcnt: Longword; - end; - TSprayObjects = record - Count: integer; - objs: array[0..Pred(MAXTHEMEOBJECTS)] of TSprayObject - end; - -var Rects: PRectArray; - RectCount: Longword; - -procedure BlitImageAndGenerateCollisionInfo(cpX, cpY: Longword; Image, Surface: PSDL_Surface); -var p: PByteArray; - x, y: Longword; - bpp: integer; - r: TSDL_Rect; -begin -r.x:= cpX; -r.y:= cpY; -SDL_UpperBlit(Image, nil, Surface, @r); -WriteToConsole('Generating collision info... '); - -if SDL_MustLock(Image) then - SDLTry(SDL_LockSurface(Image) >= 0, true); - -bpp:= Image.format.BytesPerPixel; -WriteToConsole('('+inttostr(bpp)+') '); -p:= Image.pixels; -case bpp of - 1: OutError('We don''t work with 8 bit surfaces', true); - 2: for y:= 0 to Pred(Image.h) do - begin - for x:= 0 to Pred(Image.w) do - if PWord(@p[x * 2])^ <> 0 then Land[cpY + y, cpX + x]:= COLOR_LAND; - p:= @p[Image.pitch]; - end; - 3: for y:= 0 to Pred(Image.h) do - begin - for x:= 0 to Pred(Image.w) do - if (p[x * 3 + 0] <> 0) - or (p[x * 3 + 1] <> 0) - or (p[x * 3 + 2] <> 0) then Land[cpY + y, cpX + x]:= COLOR_LAND; - p:= @p[Image.pitch]; - end; - 4: for y:= 0 to Pred(Image.h) do - begin - for x:= 0 to Pred(Image.w) do - if PLongword(@p[x * 4])^ <> 0 then Land[cpY + y, cpX + x]:= COLOR_LAND; - p:= @p[Image.pitch]; - end; - end; -if SDL_MustLock(Image) then - SDL_UnlockSurface(Image); -WriteLnToConsole(msgOK) -end; - -procedure AddRect(x1, y1, w1, h1: integer); -begin -with Rects[RectCount] do - begin - x:= x1; - y:= y1; - w:= w1; - h:= h1 - end; -inc(RectCount); -TryDo(RectCount < MaxRects, 'AddRect: overflow', true) -end; - -procedure InitRects; -begin -RectCount:= 0; -New(Rects) -end; - -procedure FreeRects; -begin -Dispose(rects) -end; - -function CheckIntersect(x1, y1, w1, h1: integer): boolean; -var i: Longword; -begin -Result:= false; -i:= 0; -if RectCount > 0 then - repeat - with Rects[i] do - Result:= (x < x1 + w1) and (x1 < x + w) and - (y < y1 + h1) and (y1 < y + h); - inc(i) - until (i = RectCount) or (Result) -end; - -function AddGirder(gX: integer; Surface: PSDL_Surface): boolean; -var tmpsurf: PSDL_Surface; - x1, x2, y, k, i: integer; - r, rr: TSDL_Rect; - - function CountNonZeroz(x, y: integer): Longword; - var i: integer; - begin - Result:= 0; - for i:= y to y + 15 do - if Land[i, x] <> 0 then inc(Result) - end; - -begin -y:= 150; -repeat - inc(y, 24); - x1:= gX; - x2:= gX; - while (x1 > 100) and (CountNonZeroz(x1, y) = 0) do dec(x1, 2); - i:= x1 - 12; - repeat - k:= CountNonZeroz(x1, y); - dec(x1, 2) - until (x1 < 100) or (k = 0) or (k = 16) or (x1 < i); - inc(x1, 2); - if k = 16 then - begin - while (x2 < 1900) and (CountNonZeroz(x2, y) = 0) do inc(x2, 2); - i:= x2 + 12; - repeat - k:= CountNonZeroz(x2, y); - inc(x2, 2) - until (x2 > 1900) or (k = 0) or (k = 16) or (x2 > i); - if (x2 < 1900) and (k = 16) and (x2 - x1 > 250) - and not CheckIntersect(x1 - 32, y - 64, x2 - x1 + 64, 144) then break; - end; -x1:= 0; -until y > 900; -if x1 > 0 then - begin - Result:= true; - tmpsurf:= LoadImage(Pathz[ptGraphics] + '/Girder', false); - rr.x:= x1; - rr.y:= y; - while rr.x + 100 < x2 do - begin - SDL_UpperBlit(tmpsurf, nil, Surface, @rr); - inc(rr.x, 100); - end; - r.x:= 0; - r.y:= 0; - r.w:= x2 - rr.x; - r.h:= 16; - SDL_UpperBlit(tmpsurf, @r, Surface, @rr); - SDL_FreeSurface(tmpsurf); - AddRect(x1 - 8, y - 32, x2 - x1 + 16, 80); - for k:= y to y + 15 do - for i:= x1 to x2 do Land[k, i]:= $FFFFFF - end else Result:= false -end; - -function CheckLand(rect: TSDL_Rect; dX, dY, Color: Longword): boolean; -var i: Longword; -begin -Result:= true; -inc(rect.x, dX); -inc(rect.y, dY); -i:= 0; -{$WARNINGS OFF} -while (i <= rect.w) and Result do - begin - Result:= (Land[rect.y, rect.x + i] = Color) and (Land[rect.y + rect.h, rect.x + i] = Color); - inc(i) - end; -i:= 0; -while (i <= rect.h) and Result do - begin - Result:= (Land[rect.y + i, rect.x] = Color) and (Land[rect.y + i, rect.x + rect.w] = Color); - inc(i) - end; -{$WARNINGS ON} -end; - -function CheckCanPlace(x, y: Longword; var Obj: TThemeObject): boolean; -var i: Longword; -begin -with Obj do - if CheckLand(inland, x, y, $FFFFFF) then - begin - Result:= true; - i:= 1; - while Result and (i <= rectcnt) do - begin - Result:= CheckLand(outland[i], x, y, 0); - inc(i) - end; - if Result then - Result:= not CheckIntersect(x, y, Width, Height) - end else - Result:= false -end; - -function TryPut(var Obj: TThemeObject; Surface: PSDL_Surface): boolean; overload; -const MaxPointsIndex = 2047; -var x, y: Longword; - ar: array[0..MaxPointsIndex] of TPoint; - cnt, i: Longword; -begin -cnt:= 0; -with Obj do - begin - if Maxcnt = 0 then - begin - Result:= false; - exit - end; - x:= 0; - repeat - y:= 0; - repeat - if CheckCanPlace(x, y, Obj) then - begin - ar[cnt].x:= x; - ar[cnt].y:= y; - inc(cnt); - if cnt > MaxPointsIndex then // buffer is full, do not check the rest land - begin - y:= 5000; - x:= 5000; - end - end; - inc(y, 3); - until y > 1023 - Height; - inc(x, getrandom(6) + 3) - until x > 2047 - Width; - Result:= cnt <> 0; - if Result then - begin - i:= getrandom(cnt); - BlitImageAndGenerateCollisionInfo(ar[i].x, ar[i].y, Obj.Surf, Surface); - AddRect(ar[i].x, ar[i].y, Width, Height); - dec(Maxcnt) - end else Maxcnt:= 0 - end -end; - -function TryPut(var Obj: TSprayObject; Surface: PSDL_Surface): boolean; overload; -const MaxPointsIndex = 8095; -var x, y: Longword; - ar: array[0..MaxPointsIndex] of TPoint; - cnt, i: Longword; - r: TSDL_Rect; -begin -cnt:= 0; -with Obj do - begin - if Maxcnt = 0 then - begin - Result:= false; - exit - end; - x:= 0; - r.x:= 0; - r.y:= 0; - r.w:= Width; - r.h:= Height + 16; - repeat - y:= 8; - repeat - if CheckLand(r, x, y - 8, $FFFFFF) - and not CheckIntersect(x, y, Width, Height) then - begin - ar[cnt].x:= x; - ar[cnt].y:= y; - inc(cnt); - if cnt > MaxPointsIndex then // buffer is full, do not check the rest land - begin - y:= 5000; - x:= 5000; - end - end; - inc(y, 12); - until y > 1023 - Height - 8; - inc(x, getrandom(12) + 12) - until x > 2047 - Width; - Result:= cnt <> 0; - if Result then - begin - i:= getrandom(cnt); - r.x:= ar[i].X; - r.y:= ar[i].Y; - r.w:= Width; - r.h:= Height; - SDL_UpperBlit(Obj.Surf, nil, Surface, @r); - AddRect(ar[i].x - 32, ar[i].y - 32, Width + 64, Height + 64); - dec(Maxcnt) - end else Maxcnt:= 0 - end -end; - -procedure ReadThemeInfo(var ThemeObjects: TThemeObjects; var SprayObjects: TSprayObjects); -var s: string; - f: textfile; - i, ii: integer; -begin -s:= Pathz[ptCurrTheme] + '/' + cThemeCFGFilename; -WriteLnToConsole('Reading objects info...'); -AssignFile(f, s); -{$I-} -Reset(f); -Readln(f, s); // skip color -Readln(f, ThemeObjects.Count); -for i:= 0 to Pred(ThemeObjects.Count) do - begin - Readln(f, s); // filename - with ThemeObjects.objs[i] do - begin - Surf:= LoadImage(Pathz[ptCurrTheme] + '/' + s, false); - Read(f, Width, Height); - with inland do Read(f, x, y, w, h); - Read(f, rectcnt); - for ii:= 1 to rectcnt do - with outland[ii] do Read(f, x, y, w, h); - Maxcnt:= 3; - ReadLn(f) - end; - end; - -Readln(f, SprayObjects.Count); -for i:= 0 to Pred(SprayObjects.Count) do - begin - Readln(f, s); // filename - with SprayObjects.objs[i] do - begin - Surf:= LoadImage(Pathz[ptCurrTheme] + '/' + s, false); - Width:= Surf.w; - Height:= Surf.h; - ReadLn(f, Maxcnt) - end; - end; -Closefile(f); -{$I+} -TryDo(IOResult = 0, 'Bad data or cannot access file ' + cThemeCFGFilename, true) -end; - -procedure AddThemeObjects(Surface: PSDL_Surface; var ThemeObjects: TThemeObjects; MaxCount: integer); -var i, ii, t: integer; - b: boolean; -begin -if ThemeObjects.Count = 0 then exit; -WriteLnToConsole('Adding theme objects...'); -i:= 1; -repeat - t:= getrandom(ThemeObjects.Count); - ii:= t; - repeat - inc(ii); - if ii = ThemeObjects.Count then ii:= 0; - b:= TryPut(ThemeObjects.objs[ii], Surface) - until b or (ii = t); - inc(i) -until (i > MaxCount) or not b; -end; - -procedure AddSprayObjects(Surface: PSDL_Surface; var SprayObjects: TSprayObjects; MaxCount: Longword); -var i: Longword; - ii, t: integer; - b: boolean; -begin -if SprayObjects.Count = 0 then exit; -WriteLnToConsole('Adding spray objects...'); -i:= 1; -repeat - t:= getrandom(SprayObjects.Count); - ii:= t; - repeat - inc(ii); - if ii = SprayObjects.Count then ii:= 0; - b:= TryPut(SprayObjects.objs[ii], Surface) - until b or (ii = t); - inc(i) -until (i > MaxCount) or not b; -end; - -procedure AddObjects(InSurface, Surface: PSDL_Surface); -var ThemeObjects: TThemeObjects; - SprayObjects: TSprayObjects; -begin -InitRects; -AddGirder(256, Surface); -AddGirder(512, Surface); -AddGirder(768, Surface); -AddGirder(1024, Surface); -AddGirder(1280, Surface); -AddGirder(1536, Surface); -AddGirder(1792, Surface); -ReadThemeInfo(ThemeObjects, SprayObjects); -AddThemeObjects(Surface, ThemeObjects, 8); -AddProgress; -SDL_UpperBlit(InSurface, nil, Surface, nil); -AddSprayObjects(Surface, SprayObjects, 10); -FreeRects -end; - -end. +(* + * Hedgewars, a worms-like game + * Copyright (c) 2005, 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 + *) + +unit uLandObjects; +interface +uses SDLh; +{$include options.inc} + +procedure AddObjects(InSurface, Surface: PSDL_Surface); +procedure BlitImageAndGenerateCollisionInfo(cpX, cpY: Longword; Image, Surface: PSDL_Surface); + +implementation +uses uLand, uStore, uConsts, uMisc, uConsole, uRandom; +const MaxRects = 256; + MAXOBJECTRECTS = 16; + MAXTHEMEOBJECTS = 32; + +type PRectArray = ^TRectsArray; + TRectsArray = array[0..MaxRects] of TSDL_Rect; + TThemeObject = record + Surf: PSDL_Surface; + inland: TSDL_Rect; + outland: array[0..Pred(MAXOBJECTRECTS)] of TSDL_Rect; + rectcnt: Longword; + Width, Height: Longword; + Maxcnt: Longword; + end; + TThemeObjects = record + Count: integer; + objs: array[0..Pred(MAXTHEMEOBJECTS)] of TThemeObject; + end; + TSprayObject = record + Surf: PSDL_Surface; + Width, Height: Longword; + Maxcnt: Longword; + end; + TSprayObjects = record + Count: integer; + objs: array[0..Pred(MAXTHEMEOBJECTS)] of TSprayObject + end; + +var Rects: PRectArray; + RectCount: Longword; + +procedure BlitImageAndGenerateCollisionInfo(cpX, cpY: Longword; Image, Surface: PSDL_Surface); +var p: PByteArray; + x, y: Longword; + bpp: integer; + r: TSDL_Rect; +begin +r.x:= cpX; +r.y:= cpY; +SDL_UpperBlit(Image, nil, Surface, @r); +WriteToConsole('Generating collision info... '); + +if SDL_MustLock(Image) then + SDLTry(SDL_LockSurface(Image) >= 0, true); + +bpp:= Image.format.BytesPerPixel; +WriteToConsole('('+inttostr(bpp)+') '); +p:= Image.pixels; +case bpp of + 1: OutError('We don''t work with 8 bit surfaces', true); + 2: for y:= 0 to Pred(Image.h) do + begin + for x:= 0 to Pred(Image.w) do + if PWord(@p[x * 2])^ <> 0 then Land[cpY + y, cpX + x]:= COLOR_LAND; + p:= @p[Image.pitch]; + end; + 3: for y:= 0 to Pred(Image.h) do + begin + for x:= 0 to Pred(Image.w) do + if (p[x * 3 + 0] <> 0) + or (p[x * 3 + 1] <> 0) + or (p[x * 3 + 2] <> 0) then Land[cpY + y, cpX + x]:= COLOR_LAND; + p:= @p[Image.pitch]; + end; + 4: for y:= 0 to Pred(Image.h) do + begin + for x:= 0 to Pred(Image.w) do + if PLongword(@p[x * 4])^ <> 0 then Land[cpY + y, cpX + x]:= COLOR_LAND; + p:= @p[Image.pitch]; + end; + end; +if SDL_MustLock(Image) then + SDL_UnlockSurface(Image); +WriteLnToConsole(msgOK) +end; + +procedure AddRect(x1, y1, w1, h1: integer); +begin +with Rects[RectCount] do + begin + x:= x1; + y:= y1; + w:= w1; + h:= h1 + end; +inc(RectCount); +TryDo(RectCount < MaxRects, 'AddRect: overflow', true) +end; + +procedure InitRects; +begin +RectCount:= 0; +New(Rects) +end; + +procedure FreeRects; +begin +Dispose(rects) +end; + +function CheckIntersect(x1, y1, w1, h1: integer): boolean; +var i: Longword; +begin +Result:= false; +i:= 0; +if RectCount > 0 then + repeat + with Rects[i] do + Result:= (x < x1 + w1) and (x1 < x + w) and + (y < y1 + h1) and (y1 < y + h); + inc(i) + until (i = RectCount) or (Result) +end; + +function AddGirder(gX: integer; Surface: PSDL_Surface): boolean; +var tmpsurf: PSDL_Surface; + x1, x2, y, k, i: integer; + r, rr: TSDL_Rect; + + function CountNonZeroz(x, y: integer): Longword; + var i: integer; + begin + Result:= 0; + for i:= y to y + 15 do + if Land[i, x] <> 0 then inc(Result) + end; + +begin +y:= 150; +repeat + inc(y, 24); + x1:= gX; + x2:= gX; + while (x1 > 100) and (CountNonZeroz(x1, y) = 0) do dec(x1, 2); + i:= x1 - 12; + repeat + k:= CountNonZeroz(x1, y); + dec(x1, 2) + until (x1 < 100) or (k = 0) or (k = 16) or (x1 < i); + inc(x1, 2); + if k = 16 then + begin + while (x2 < 1900) and (CountNonZeroz(x2, y) = 0) do inc(x2, 2); + i:= x2 + 12; + repeat + k:= CountNonZeroz(x2, y); + inc(x2, 2) + until (x2 > 1900) or (k = 0) or (k = 16) or (x2 > i); + if (x2 < 1900) and (k = 16) and (x2 - x1 > 250) + and not CheckIntersect(x1 - 32, y - 64, x2 - x1 + 64, 144) then break; + end; +x1:= 0; +until y > 900; +if x1 > 0 then + begin + Result:= true; + tmpsurf:= LoadImage(Pathz[ptGraphics] + '/Girder', false); + rr.x:= x1; + rr.y:= y; + while rr.x + 100 < x2 do + begin + SDL_UpperBlit(tmpsurf, nil, Surface, @rr); + inc(rr.x, 100); + end; + r.x:= 0; + r.y:= 0; + r.w:= x2 - rr.x; + r.h:= 16; + SDL_UpperBlit(tmpsurf, @r, Surface, @rr); + SDL_FreeSurface(tmpsurf); + AddRect(x1 - 8, y - 32, x2 - x1 + 16, 80); + for k:= y to y + 15 do + for i:= x1 to x2 do Land[k, i]:= $FFFFFF + end else Result:= false +end; + +function CheckLand(rect: TSDL_Rect; dX, dY, Color: Longword): boolean; +var i: Longword; +begin +Result:= true; +inc(rect.x, dX); +inc(rect.y, dY); +i:= 0; +{$WARNINGS OFF} +while (i <= rect.w) and Result do + begin + Result:= (Land[rect.y, rect.x + i] = Color) and (Land[rect.y + rect.h, rect.x + i] = Color); + inc(i) + end; +i:= 0; +while (i <= rect.h) and Result do + begin + Result:= (Land[rect.y + i, rect.x] = Color) and (Land[rect.y + i, rect.x + rect.w] = Color); + inc(i) + end; +{$WARNINGS ON} +end; + +function CheckCanPlace(x, y: Longword; var Obj: TThemeObject): boolean; +var i: Longword; +begin +with Obj do + if CheckLand(inland, x, y, $FFFFFF) then + begin + Result:= true; + i:= 1; + while Result and (i <= rectcnt) do + begin + Result:= CheckLand(outland[i], x, y, 0); + inc(i) + end; + if Result then + Result:= not CheckIntersect(x, y, Width, Height) + end else + Result:= false +end; + +function TryPut(var Obj: TThemeObject; Surface: PSDL_Surface): boolean; overload; +const MaxPointsIndex = 2047; +var x, y: Longword; + ar: array[0..MaxPointsIndex] of TPoint; + cnt, i: Longword; +begin +cnt:= 0; +with Obj do + begin + if Maxcnt = 0 then + begin + Result:= false; + exit + end; + x:= 0; + repeat + y:= 0; + repeat + if CheckCanPlace(x, y, Obj) then + begin + ar[cnt].x:= x; + ar[cnt].y:= y; + inc(cnt); + if cnt > MaxPointsIndex then // buffer is full, do not check the rest land + begin + y:= 5000; + x:= 5000; + end + end; + inc(y, 3); + until y > 1023 - Height; + inc(x, getrandom(6) + 3) + until x > 2047 - Width; + Result:= cnt <> 0; + if Result then + begin + i:= getrandom(cnt); + BlitImageAndGenerateCollisionInfo(ar[i].x, ar[i].y, Obj.Surf, Surface); + AddRect(ar[i].x, ar[i].y, Width, Height); + dec(Maxcnt) + end else Maxcnt:= 0 + end +end; + +function TryPut(var Obj: TSprayObject; Surface: PSDL_Surface): boolean; overload; +const MaxPointsIndex = 8095; +var x, y: Longword; + ar: array[0..MaxPointsIndex] of TPoint; + cnt, i: Longword; + r: TSDL_Rect; +begin +cnt:= 0; +with Obj do + begin + if Maxcnt = 0 then + begin + Result:= false; + exit + end; + x:= 0; + r.x:= 0; + r.y:= 0; + r.w:= Width; + r.h:= Height + 16; + repeat + y:= 8; + repeat + if CheckLand(r, x, y - 8, $FFFFFF) + and not CheckIntersect(x, y, Width, Height) then + begin + ar[cnt].x:= x; + ar[cnt].y:= y; + inc(cnt); + if cnt > MaxPointsIndex then // buffer is full, do not check the rest land + begin + y:= 5000; + x:= 5000; + end + end; + inc(y, 12); + until y > 1023 - Height - 8; + inc(x, getrandom(12) + 12) + until x > 2047 - Width; + Result:= cnt <> 0; + if Result then + begin + i:= getrandom(cnt); + r.x:= ar[i].X; + r.y:= ar[i].Y; + r.w:= Width; + r.h:= Height; + SDL_UpperBlit(Obj.Surf, nil, Surface, @r); + AddRect(ar[i].x - 32, ar[i].y - 32, Width + 64, Height + 64); + dec(Maxcnt) + end else Maxcnt:= 0 + end +end; + +procedure ReadThemeInfo(var ThemeObjects: TThemeObjects; var SprayObjects: TSprayObjects); +var s: string; + f: textfile; + i, ii: integer; +begin +s:= Pathz[ptCurrTheme] + '/' + cThemeCFGFilename; +WriteLnToConsole('Reading objects info...'); +AssignFile(f, s); +{$I-} +Reset(f); +Readln(f, s); // skip color +Readln(f, ThemeObjects.Count); +for i:= 0 to Pred(ThemeObjects.Count) do + begin + Readln(f, s); // filename + with ThemeObjects.objs[i] do + begin + Surf:= LoadImage(Pathz[ptCurrTheme] + '/' + s, false); + Read(f, Width, Height); + with inland do Read(f, x, y, w, h); + Read(f, rectcnt); + for ii:= 1 to rectcnt do + with outland[ii] do Read(f, x, y, w, h); + Maxcnt:= 3; + ReadLn(f) + end; + end; + +Readln(f, SprayObjects.Count); +for i:= 0 to Pred(SprayObjects.Count) do + begin + Readln(f, s); // filename + with SprayObjects.objs[i] do + begin + Surf:= LoadImage(Pathz[ptCurrTheme] + '/' + s, false); + Width:= Surf.w; + Height:= Surf.h; + ReadLn(f, Maxcnt) + end; + end; +Closefile(f); +{$I+} +TryDo(IOResult = 0, 'Bad data or cannot access file ' + cThemeCFGFilename, true) +end; + +procedure AddThemeObjects(Surface: PSDL_Surface; var ThemeObjects: TThemeObjects; MaxCount: integer); +var i, ii, t: integer; + b: boolean; +begin +if ThemeObjects.Count = 0 then exit; +WriteLnToConsole('Adding theme objects...'); +i:= 1; +repeat + t:= getrandom(ThemeObjects.Count); + ii:= t; + repeat + inc(ii); + if ii = ThemeObjects.Count then ii:= 0; + b:= TryPut(ThemeObjects.objs[ii], Surface) + until b or (ii = t); + inc(i) +until (i > MaxCount) or not b; +end; + +procedure AddSprayObjects(Surface: PSDL_Surface; var SprayObjects: TSprayObjects; MaxCount: Longword); +var i: Longword; + ii, t: integer; + b: boolean; +begin +if SprayObjects.Count = 0 then exit; +WriteLnToConsole('Adding spray objects...'); +i:= 1; +repeat + t:= getrandom(SprayObjects.Count); + ii:= t; + repeat + inc(ii); + if ii = SprayObjects.Count then ii:= 0; + b:= TryPut(SprayObjects.objs[ii], Surface) + until b or (ii = t); + inc(i) +until (i > MaxCount) or not b; +end; + +procedure AddObjects(InSurface, Surface: PSDL_Surface); +var ThemeObjects: TThemeObjects; + SprayObjects: TSprayObjects; +begin +InitRects; +AddGirder(256, Surface); +AddGirder(512, Surface); +AddGirder(768, Surface); +AddGirder(1024, Surface); +AddGirder(1280, Surface); +AddGirder(1536, Surface); +AddGirder(1792, Surface); +ReadThemeInfo(ThemeObjects, SprayObjects); +AddThemeObjects(Surface, ThemeObjects, 8); +AddProgress; +SDL_UpperBlit(InSurface, nil, Surface, nil); +AddSprayObjects(Surface, SprayObjects, 10); +FreeRects +end; + +end. diff -r 57c2ef19f719 -r f97a7a3dc8f6 hedgewars/uLandTemplates.pas --- a/hedgewars/uLandTemplates.pas Thu Oct 05 16:33:18 2006 +0000 +++ b/hedgewars/uLandTemplates.pas Thu Oct 05 17:02:09 2006 +0000 @@ -1,650 +1,650 @@ -(* - * Hedgewars, a worms-like game - * Copyright (c) 2005, 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 - *) - -unit uLandTemplates; -interface -uses SDLh; -{$INCLUDE options.inc} - -type PPointArray = ^TPointArray; - TPointArray = array[0..64] of TPoint; - TEdgeTemplate = record - BasePoints: PPointArray; - BasePointsCount: Longword; - BezPassCnt: Longword; - PassMin, PassDelta: Longword; - WaveAmplMin, WaveAmplDelta: Double; - WaveFreqMin, WaveFreqDelta: Double; - FillPoints: PPointArray; - FillPointsCount: Longword; - canMirror, canFlip: boolean; - end; - -const Template0Points: array[0..4] of TPoint = - ( - (x: 500; y: 1500), - (x: 350; y: 400), - (x: 1023; y: 820), - (x: 1700; y: 400), - (x: 1550; y: 1500) - ); - Template0FPoints: array[0..0] of TPoint = - ( - (x: 1023; y: 0) - ); - -const Template1Points: array[0..12] of TPoint = - ( - (x: 300; y: 1500), - (x: 300; y: 1000), - (x: 250; y: 750), - (x: 550; y: 480), - (x: 650; y: 780), - (x: 810; y: 780), - (x: 800; y: 500), - (x: 1200; y: 500), - (x: 1300; y: 800), - (x: 1500; y: 500), - (x: 1800; y: 750), - (x: 1750; y: 1000), - (x: 1750; y: 1500) - ); - Template1FPoints: array[0..0] of TPoint = - ( - (x: 1023; y: 0) - ); - -const Template2Points: array[0..28] of TPoint = - ( - (x: 350; y: 1500), - (x: 350; y: 1000), - (x: 190; y: 850), - (x: 500; y: 750), - (x: 520; y: 450), - (x: 190; y: 600), - (x: 210; y: 260), - (x: 800; y: 310), - (x: 1350; y: 220), - (x: 1250; y: 360), - (x: 1550; y: 520), - (x: 1100; y: 400), - (x: 900; y: 470), - (x: 650; y: 400), - (x: 900; y: 750), - (x: 600; y: 750), - (x: 600; y: 850), - (x: 1100; y: 900), - (x: 1200; y: 1000), - (x: 1200; y: 1300), - (x: 1400; y: 1300), - (x: 1400; y: 1000), - (x: 1280; y: 850), - (x: 1150; y: 630), - (x: 1600; y: 850), - (x: 1800; y: 600), - (x: 1900; y: 600), - (x: 1700; y: 1010), - (x: 1700; y: 1500) - ); - Template2FPoints: array[0..0] of TPoint = - ( - (x: 1023; y: 0) - ); - -const Template3Points: array[0..23] of TPoint = - ( - (x: 200; y: 1500), - (x: 200; y: 1000), - (x: 390; y: 650), - (x: 210; y: 260), - (x: 1000; y: 420), - (x: 1100; y: 200), - (x: 1250; y: 420), - (x: 1250; y: 620), - (x: 900; y: 610), - (x: 650; y: 450), - (x: 550; y: 500), - (x: 650; y: 700), - (x: 1200; y: 800), - (x: 1200; y: 1000), - (x: 1200; y: 1200), - (x: 1400; y: 1200), - (x: 1400; y: 1000), - (x: 1280; y: 750), - (x: 1500; y: 600), - (x: 1400; y: 200), - (x: 1800; y: 200), - (x: 1700; y: 600), - (x: 1900; y: 1010), - (x: 1800; y: 1500) - ); - Template3FPoints: array[0..0] of TPoint = - ( - (x: 1023; y: 0) - ); - -const Template4Points: array[0..38] of TPoint = - ( - (x: 200; y: 1500), - (x: 200; y: 1000), - (x: 210; y: 800), - (x: 480; y: 830), - (x: 460; y: 700), - (x: 150; y: 610), - (x: 150; y: 310), - (x: 220; y: 200), - (x: 340; y: 195), - (x: 410; y: 415), - (x: 420; y: 495), - (x: 535; y: 615), - (x: 705; y: 600), - (x: 760; y: 425), - (x: 815; y: 230), - (x: 970; y: 200), - (x: 1050; y: 360), - (x: 850; y: 590), - (x: 1070; y: 790), - (x: 1000; y: 1000), - (x: 1000; y: 1500), - (x: 1250; y: 1500), - (x: 1250; y: 1000), - (x: 1260; y: 830), - (x: 1290; y: 700), - (x: 1270; y: 450), - (x: 1180; y: 280), - (x: 1210; y: 160), - (x: 1370; y: 160), - (x: 1505; y: 205), - (x: 1630; y: 315), - (x: 1660; y: 450), - (x: 1580; y: 620), - (x: 1670; y: 725), - (x: 1800; y: 730), - (x: 1860; y: 680), - (x: 1925; y: 810), - (x: 1800; y: 1000), - (x: 1800; y: 1500) - ); - Template4FPoints: array[0..0] of TPoint = - ( - (x: 1023; y: 0) - ); - -const Template5Points: array[0..10] of TPoint = - ( - (x: 225; y: 1500), - (x: 254; y: 226), - (x: 729; y: 238), - (x: 658; y: 441), - (x: 661; y: 651), - (x: 1023; y: 759), - (x: 1374; y: 648), - (x: 1473; y: 285), - (x: 1803; y: 207), - (x: 1839; y: 801), - (x: 1674; y: 1500) - ); - Template5FPoints: array[0..0] of TPoint = - ( - (x: 1023; y: 0) - ); - -const Template6Points: array[0..20] of TPoint = - ( - (x: 318; y: 1500), - (x: 270; y: 1023), - (x: 252; y: 921), - (x: 480; y: 888), - (x: 492; y: 753), - (x: 654; y: 756), - (x: 687; y: 630), - (x: 906; y: 627), - (x: 987; y: 813), - (x: 1125; y: 825), - (x: 1134; y: 645), - (x: 1236; y: 558), - (x: 1260; y: 438), - (x: 1467; y: 462), - (x: 1536; y: 348), - (x: 1680; y: 402), - (x: 1713; y: 594), - (x: 1593; y: 693), - (x: 1707; y: 774), - (x: 1728; y: 894), - (x: 1788; y: 1500) - ); - Template6FPoints: array[0..0] of TPoint = - ( - (x: 1023; y: 0) - ); - -const Template7Points: array[0..43] of TPoint = - ( - (x: 180; y: 1500), - (x: 411; y: 1020), - (x: 402; y: 912), - (x: 141; y: 897), - (x: 156; y: 729), - (x: 417; y: 813), - (x: 432; y: 585), - (x: 147; y: 570), - (x: 138; y: 435), - (x: 444; y: 417), - (x: 447; y: 207), - (x: 573; y: 261), - (x: 663; y: 201), - (x: 711; y: 375), - (x: 897; y: 411), - (x: 936; y: 498), - (x: 663; y: 558), - (x: 669; y: 762), - (x: 957; y: 723), - (x: 984; y: 864), - (x: 729; y: 879), - (x: 879; y: 1020), - (x: 981; y: 1449), - (x: 1242; y: 1449), - (x: 1476; y: 1020), - (x: 1470; y: 900), - (x: 1284; y: 897), - (x: 1218; y: 774), - (x: 1464; y: 765), - (x: 1464; y: 672), - (x: 1119; y: 630), - (x: 1116; y: 537), - (x: 1485; y: 501), - (x: 1167; y: 246), - (x: 1263; y: 180), - (x: 1572; y: 312), - (x: 1767; y: 162), - (x: 1827; y: 306), - (x: 1647; y: 465), - (x: 1875; y: 621), - (x: 1683; y: 747), - (x: 1665; y: 831), - (x: 1818; y: 951), - (x: 1893; y: 1500) - ); - Template7FPoints: array[0..0] of TPoint = - ( - (x: 1023; y: 0) - ); - -const Template8Points: array[0..23] of TPoint = - ( - (x: 222; y: 1500), - (x: 354; y: 1023), - (x: 249; y: 783), - (x: 240; y: 421), - (x: 411; y: 401), - (x: 432; y: 777), - (x: 573; y: 777), - (x: 567; y: 300), - (x: 696; y: 250), - (x: 744; y: 683), - (x: 897; y: 698), - (x: 885; y: 450), - (x: 1032; y: 479), - (x: 1065; y: 698), - (x: 1200; y: 690), - (x: 1200; y: 218), - (x: 1326; y: 252), - (x: 1359; y: 786), - (x: 1470; y: 810), - (x: 1485; y: 379), - (x: 1608; y: 342), - (x: 1641; y: 819), - (x: 1719; y: 864), - (x: 1746; y: 1500) - ); - Template8FPoints: array[0..0] of TPoint = - ( - (x: 1023; y: 0) - ); - -const Template9Points: array[0..23] of TPoint = - ( - (x: 384; y: 1500), - (x: 210; y: 1023), - (x: 213; y: 891), - (x: 501; y: 861), - (x: 228; y: 657), - (x: 558; y: 676), - (x: 561; y: 513), - (x: 246; y: 354), - (x: 609; y: 393), - (x: 876; y: 309), - (x: 759; y: 576), - (x: 759; y: 762), - (x: 1113; y: 750), - (x: 1128; y: 873), - (x: 1488; y: 870), - (x: 1473; y: 678), - (x: 1182; y: 501), - (x: 1515; y: 507), - (x: 1776; y: 393), - (x: 1668; y: 630), - (x: 1833; y: 714), - (x: 1674; y: 837), - (x: 1800; y: 1020), - (x: 1632; y: 1500) - ); - Template9FPoints: array[0..0] of TPoint = - ( - (x: 1023; y: 0) - ); - -const Template10Points: array[0..13] of TPoint = - ( - (x: 336; y: 1500), - (x: 303; y: 1026), - (x: 225; y: 921), - (x: 216; y: 741), - (x: 774; y: 810), - (x: 687; y: 336), - (x: 975; y: 192), - (x: 1350; y: 324), - (x: 1230; y: 681), - (x: 1257; y: 855), - (x: 1623; y: 846), - (x: 1821; y: 657), - (x: 1911; y: 897), - (x: 1704; y: 1500) - ); - Template10FPoints: array[0..0] of TPoint = - ( - (x: 1023; y: 0) - ); - -const Template11Points: array[0..9] of TPoint = - ( - (x: 270; y: 1500), - (x: 180; y: 795), - (x: 453; y: 753), - (x: 537; y: 900), - (x: 822; y: 729), - (x: 1128; y: 882), - (x: 1269; y: 657), - (x: 1560; y: 915), - (x: 1812; y: 867), - (x: 1854; y: 1500) - ); - Template11FPoints: array[0..0] of TPoint = - ( - (x: 1023; y: 0) - ); - -const Template12Points: array[0..38] of TPoint = - ( - (x: 201; y: 1500), - (x: 207; y: 920), - (x: 360; y: 901), - (x: 345; y: 822), - (x: 183; y: 810), - (x: 183; y: 632), - (x: 327; y: 628), - (x: 165; y: 402), - (x: 462; y: 443), - (x: 555; y: 272), - (x: 525; y: 556), - (x: 618; y: 647), - (x: 483; y: 712), - (x: 468; y: 860), - (x: 810; y: 884), - (x: 879; y: 796), - (x: 756; y: 764), - (x: 771; y: 620), - (x: 960; y: 625), - (x: 969; y: 517), - (x: 771; y: 503), - (x: 768; y: 395), - (x: 1092; y: 412), - (x: 1125; y: 616), - (x: 1029; y: 767), - (x: 1404; y: 858), - (x: 1440; y: 714), - (x: 1293; y: 688), - (x: 1344; y: 320), - (x: 1548; y: 342), - (x: 1494; y: 563), - (x: 1614; y: 570), - (x: 1710; y: 383), - (x: 1860; y: 448), - (x: 1683; y: 664), - (x: 1773; y: 726), - (x: 1578; y: 836), - (x: 1746; y: 918), - (x: 1662; y: 1500) - ); - Template12FPoints: array[0..0] of TPoint = - ( - (x: 1023; y: 0) - ); - -const Template13Points: array[0..13] of TPoint = - ( - (x: 645; y: 1500), - (x: 198; y: 732), - (x: 402; y: 648), - (x: 609; y: 763), - (x: 750; y: 590), - (x: 303; y: 376), - (x: 1023; y: 441), - (x: 1023; y: 316), - (x: 1719; y: 329), - (x: 1695; y: 457), - (x: 1038; y: 576), - (x: 1017; y: 756), - (x: 1803; y: 728), - (x: 1503; y: 1500) - ); - Template13FPoints: array[0..0] of TPoint = - ( - (x: 1023; y: 0) - ); - -const Template14Points: array[0..22] of TPoint = - ( - (x: 177; y: 1500), - (x: 262; y: 1026), - (x: 259; y: 303), - (x: 765; y: 162), - (x: 789; y: 357), - (x: 517; y: 420), - (x: 658; y: 690), - (x: 448; y: 762), - (x: 663; y: 1029), - (x: 765; y: 1440), - (x: 1446; y: 1431), - (x: 1439; y: 1026), - (x: 1416; y: 825), - (x: 1253; y: 840), - (x: 1253; y: 600), - (x: 1551; y: 573), - (x: 1506; y: 390), - (x: 1065; y: 366), - (x: 1077; y: 171), - (x: 1656; y: 156), - (x: 1821; y: 396), - (x: 1716; y: 768), - (x: 1926; y: 1500) - ); - Template14FPoints: array[0..0] of TPoint = - ( - (x: 1023; y: 0) - ); - -const EdgeTemplates: array[0..14] of TEdgeTemplate = - ( - (BasePoints: @Template0Points; - BasePointsCount: Succ(High(Template0Points)); - BezPassCnt: 4; - PassMin: 10; PassDelta: 5; - WaveAmplMin: 17; WaveAmplDelta: 20; - WaveFreqMin: 0.010; WaveFreqDelta: 0.002; - FillPoints: @Template0FPoints; - FillPointsCount: Succ(High(Template0FPoints)); - canMirror: false; canFlip: false; - ), - (BasePoints: @Template1Points; - BasePointsCount: Succ(High(Template1Points)); - BezPassCnt: 3; - PassMin: 10; PassDelta: 2; - WaveAmplMin: 25; WaveAmplDelta: 15; - WaveFreqMin: 0.008; WaveFreqDelta: 0.002; - FillPoints: @Template1FPoints; - FillPointsCount: Succ(High(Template1FPoints)); - canMirror: false; canFlip: false; - ), - (BasePoints: @Template2Points; - BasePointsCount: Succ(High(Template2Points)); - BezPassCnt: 3; - PassMin: 14; PassDelta: 3; - WaveAmplMin: 10; WaveAmplDelta: 10; - WaveFreqMin: 0.010; WaveFreqDelta: 0.002; - FillPoints: @Template2FPoints; - FillPointsCount: Succ(High(Template2FPoints)); - canMirror: true; canFlip: false; - ), - (BasePoints: @Template3Points; - BasePointsCount: Succ(High(Template3Points)); - BezPassCnt: 4; - PassMin: 15; PassDelta: 2; - WaveAmplMin: 8; WaveAmplDelta: 12; - WaveFreqMin: 0.015; WaveFreqDelta: 0.0015; - FillPoints: @Template3FPoints; - FillPointsCount: Succ(High(Template3FPoints)); - canMirror: true; canFlip: false; - ), - (BasePoints: @Template4Points; - BasePointsCount: Succ(High(Template4Points)); - BezPassCnt: 3; - PassMin: 19; PassDelta: 5; - WaveAmplMin: 12; WaveAmplDelta: 14; - WaveFreqMin: 0.008; WaveFreqDelta: 0.001; - FillPoints: @Template4FPoints; - FillPointsCount: Succ(High(Template4FPoints)); - canMirror: true; canFlip: false; - ), - (BasePoints: @Template5Points; - BasePointsCount: Succ(High(Template5Points)); - BezPassCnt: 4; - PassMin: 15; PassDelta: 1; - WaveAmplMin: 15; WaveAmplDelta: 14; - WaveFreqMin: 0.008; WaveFreqDelta: 0.002; - FillPoints: @Template5FPoints; - FillPointsCount: Succ(High(Template5FPoints)); - canMirror: true; canFlip: false; - ), - (BasePoints: @Template6Points; - BasePointsCount: Succ(High(Template6Points)); - BezPassCnt: 3; - PassMin: 15; PassDelta: 1; - WaveAmplMin: 15; WaveAmplDelta: 10; - WaveFreqMin: 0.010; WaveFreqDelta: 0.0015; - FillPoints: @Template6FPoints; - FillPointsCount: Succ(High(Template6FPoints)); - canMirror: true; canFlip: false; - ), - (BasePoints: @Template7Points; - BasePointsCount: Succ(High(Template7Points)); - BezPassCnt: 3; - PassMin: 12; PassDelta: 4; - WaveAmplMin: 5; WaveAmplDelta: 15; - WaveFreqMin: 0.015; WaveFreqDelta: 0.002; - FillPoints: @Template7FPoints; - FillPointsCount: Succ(High(Template7FPoints)); - canMirror: true; canFlip: false; - ), - (BasePoints: @Template8Points; - BasePointsCount: Succ(High(Template8Points)); - BezPassCnt: 4; - PassMin: 9; PassDelta: 3; - WaveAmplMin: 18; WaveAmplDelta: 18; - WaveFreqMin: 0.010; WaveFreqDelta: 0.002; - FillPoints: @Template8FPoints; - FillPointsCount: Succ(High(Template8FPoints)); - canMirror: true; canFlip: false; - ), - (BasePoints: @Template9Points; - BasePointsCount: Succ(High(Template9Points)); - BezPassCnt: 4; - PassMin: 17; PassDelta: 3; - WaveAmplMin: 10; WaveAmplDelta: 10; - WaveFreqMin: 0.010; WaveFreqDelta: 0.002; - FillPoints: @Template9FPoints; - FillPointsCount: Succ(High(Template9FPoints)); - canMirror: true; canFlip: false; - ), - (BasePoints: @Template10Points; - BasePointsCount: Succ(High(Template10Points)); - BezPassCnt: 4; - PassMin: 15; PassDelta: 2; - WaveAmplMin: 15; WaveAmplDelta: 10; - WaveFreqMin: 0.008; WaveFreqDelta: 0.002; - FillPoints: @Template10FPoints; - FillPointsCount: Succ(High(Template10FPoints)); - canMirror: false; canFlip: false; - ), - (BasePoints: @Template11Points; - BasePointsCount: Succ(High(Template11Points)); - BezPassCnt: 4; - PassMin: 15; PassDelta: 1; - WaveAmplMin: 10; WaveAmplDelta: 10; - WaveFreqMin: 0.008; WaveFreqDelta: 0.002; - FillPoints: @Template11FPoints; - FillPointsCount: Succ(High(Template11FPoints)); - canMirror: true; canFlip: false; - ), - (BasePoints: @Template12Points; - BasePointsCount: Succ(High(Template12Points)); - BezPassCnt: 3; - PassMin: 10; PassDelta: 1; - WaveAmplMin: 15; WaveAmplDelta: 15; - WaveFreqMin: 0.005; WaveFreqDelta: 0.003; - FillPoints: @Template12FPoints; - FillPointsCount: Succ(High(Template12FPoints)); - canMirror: true; canFlip: false; - ), - (BasePoints: @Template13Points; - BasePointsCount: Succ(High(Template13Points)); - BezPassCnt: 5; - PassMin: 15; PassDelta: 3; - WaveAmplMin: 18; WaveAmplDelta: 15; - WaveFreqMin: 0.0028; WaveFreqDelta: 0.002; - FillPoints: @Template13FPoints; - FillPointsCount: Succ(High(Template13FPoints)); - canMirror: true; canFlip: false; - ), - (BasePoints: @Template14Points; - BasePointsCount: Succ(High(Template14Points)); - BezPassCnt: 4; - PassMin: 14; PassDelta: 3; - WaveAmplMin: 20; WaveAmplDelta: 15; - WaveFreqMin: 0.003; WaveFreqDelta: 0.002; - FillPoints: @Template14FPoints; - FillPointsCount: Succ(High(Template14FPoints)); - canMirror: true; canFlip: false; - ) - ); - - - -implementation - -end. +(* + * Hedgewars, a worms-like game + * Copyright (c) 2005, 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 + *) + +unit uLandTemplates; +interface +uses SDLh; +{$INCLUDE options.inc} + +type PPointArray = ^TPointArray; + TPointArray = array[0..64] of TPoint; + TEdgeTemplate = record + BasePoints: PPointArray; + BasePointsCount: Longword; + BezPassCnt: Longword; + PassMin, PassDelta: Longword; + WaveAmplMin, WaveAmplDelta: Double; + WaveFreqMin, WaveFreqDelta: Double; + FillPoints: PPointArray; + FillPointsCount: Longword; + canMirror, canFlip: boolean; + end; + +const Template0Points: array[0..4] of TPoint = + ( + (x: 500; y: 1500), + (x: 350; y: 400), + (x: 1023; y: 820), + (x: 1700; y: 400), + (x: 1550; y: 1500) + ); + Template0FPoints: array[0..0] of TPoint = + ( + (x: 1023; y: 0) + ); + +const Template1Points: array[0..12] of TPoint = + ( + (x: 300; y: 1500), + (x: 300; y: 1000), + (x: 250; y: 750), + (x: 550; y: 480), + (x: 650; y: 780), + (x: 810; y: 780), + (x: 800; y: 500), + (x: 1200; y: 500), + (x: 1300; y: 800), + (x: 1500; y: 500), + (x: 1800; y: 750), + (x: 1750; y: 1000), + (x: 1750; y: 1500) + ); + Template1FPoints: array[0..0] of TPoint = + ( + (x: 1023; y: 0) + ); + +const Template2Points: array[0..28] of TPoint = + ( + (x: 350; y: 1500), + (x: 350; y: 1000), + (x: 190; y: 850), + (x: 500; y: 750), + (x: 520; y: 450), + (x: 190; y: 600), + (x: 210; y: 260), + (x: 800; y: 310), + (x: 1350; y: 220), + (x: 1250; y: 360), + (x: 1550; y: 520), + (x: 1100; y: 400), + (x: 900; y: 470), + (x: 650; y: 400), + (x: 900; y: 750), + (x: 600; y: 750), + (x: 600; y: 850), + (x: 1100; y: 900), + (x: 1200; y: 1000), + (x: 1200; y: 1300), + (x: 1400; y: 1300), + (x: 1400; y: 1000), + (x: 1280; y: 850), + (x: 1150; y: 630), + (x: 1600; y: 850), + (x: 1800; y: 600), + (x: 1900; y: 600), + (x: 1700; y: 1010), + (x: 1700; y: 1500) + ); + Template2FPoints: array[0..0] of TPoint = + ( + (x: 1023; y: 0) + ); + +const Template3Points: array[0..23] of TPoint = + ( + (x: 200; y: 1500), + (x: 200; y: 1000), + (x: 390; y: 650), + (x: 210; y: 260), + (x: 1000; y: 420), + (x: 1100; y: 200), + (x: 1250; y: 420), + (x: 1250; y: 620), + (x: 900; y: 610), + (x: 650; y: 450), + (x: 550; y: 500), + (x: 650; y: 700), + (x: 1200; y: 800), + (x: 1200; y: 1000), + (x: 1200; y: 1200), + (x: 1400; y: 1200), + (x: 1400; y: 1000), + (x: 1280; y: 750), + (x: 1500; y: 600), + (x: 1400; y: 200), + (x: 1800; y: 200), + (x: 1700; y: 600), + (x: 1900; y: 1010), + (x: 1800; y: 1500) + ); + Template3FPoints: array[0..0] of TPoint = + ( + (x: 1023; y: 0) + ); + +const Template4Points: array[0..38] of TPoint = + ( + (x: 200; y: 1500), + (x: 200; y: 1000), + (x: 210; y: 800), + (x: 480; y: 830), + (x: 460; y: 700), + (x: 150; y: 610), + (x: 150; y: 310), + (x: 220; y: 200), + (x: 340; y: 195), + (x: 410; y: 415), + (x: 420; y: 495), + (x: 535; y: 615), + (x: 705; y: 600), + (x: 760; y: 425), + (x: 815; y: 230), + (x: 970; y: 200), + (x: 1050; y: 360), + (x: 850; y: 590), + (x: 1070; y: 790), + (x: 1000; y: 1000), + (x: 1000; y: 1500), + (x: 1250; y: 1500), + (x: 1250; y: 1000), + (x: 1260; y: 830), + (x: 1290; y: 700), + (x: 1270; y: 450), + (x: 1180; y: 280), + (x: 1210; y: 160), + (x: 1370; y: 160), + (x: 1505; y: 205), + (x: 1630; y: 315), + (x: 1660; y: 450), + (x: 1580; y: 620), + (x: 1670; y: 725), + (x: 1800; y: 730), + (x: 1860; y: 680), + (x: 1925; y: 810), + (x: 1800; y: 1000), + (x: 1800; y: 1500) + ); + Template4FPoints: array[0..0] of TPoint = + ( + (x: 1023; y: 0) + ); + +const Template5Points: array[0..10] of TPoint = + ( + (x: 225; y: 1500), + (x: 254; y: 226), + (x: 729; y: 238), + (x: 658; y: 441), + (x: 661; y: 651), + (x: 1023; y: 759), + (x: 1374; y: 648), + (x: 1473; y: 285), + (x: 1803; y: 207), + (x: 1839; y: 801), + (x: 1674; y: 1500) + ); + Template5FPoints: array[0..0] of TPoint = + ( + (x: 1023; y: 0) + ); + +const Template6Points: array[0..20] of TPoint = + ( + (x: 318; y: 1500), + (x: 270; y: 1023), + (x: 252; y: 921), + (x: 480; y: 888), + (x: 492; y: 753), + (x: 654; y: 756), + (x: 687; y: 630), + (x: 906; y: 627), + (x: 987; y: 813), + (x: 1125; y: 825), + (x: 1134; y: 645), + (x: 1236; y: 558), + (x: 1260; y: 438), + (x: 1467; y: 462), + (x: 1536; y: 348), + (x: 1680; y: 402), + (x: 1713; y: 594), + (x: 1593; y: 693), + (x: 1707; y: 774), + (x: 1728; y: 894), + (x: 1788; y: 1500) + ); + Template6FPoints: array[0..0] of TPoint = + ( + (x: 1023; y: 0) + ); + +const Template7Points: array[0..43] of TPoint = + ( + (x: 180; y: 1500), + (x: 411; y: 1020), + (x: 402; y: 912), + (x: 141; y: 897), + (x: 156; y: 729), + (x: 417; y: 813), + (x: 432; y: 585), + (x: 147; y: 570), + (x: 138; y: 435), + (x: 444; y: 417), + (x: 447; y: 207), + (x: 573; y: 261), + (x: 663; y: 201), + (x: 711; y: 375), + (x: 897; y: 411), + (x: 936; y: 498), + (x: 663; y: 558), + (x: 669; y: 762), + (x: 957; y: 723), + (x: 984; y: 864), + (x: 729; y: 879), + (x: 879; y: 1020), + (x: 981; y: 1449), + (x: 1242; y: 1449), + (x: 1476; y: 1020), + (x: 1470; y: 900), + (x: 1284; y: 897), + (x: 1218; y: 774), + (x: 1464; y: 765), + (x: 1464; y: 672), + (x: 1119; y: 630), + (x: 1116; y: 537), + (x: 1485; y: 501), + (x: 1167; y: 246), + (x: 1263; y: 180), + (x: 1572; y: 312), + (x: 1767; y: 162), + (x: 1827; y: 306), + (x: 1647; y: 465), + (x: 1875; y: 621), + (x: 1683; y: 747), + (x: 1665; y: 831), + (x: 1818; y: 951), + (x: 1893; y: 1500) + ); + Template7FPoints: array[0..0] of TPoint = + ( + (x: 1023; y: 0) + ); + +const Template8Points: array[0..23] of TPoint = + ( + (x: 222; y: 1500), + (x: 354; y: 1023), + (x: 249; y: 783), + (x: 240; y: 421), + (x: 411; y: 401), + (x: 432; y: 777), + (x: 573; y: 777), + (x: 567; y: 300), + (x: 696; y: 250), + (x: 744; y: 683), + (x: 897; y: 698), + (x: 885; y: 450), + (x: 1032; y: 479), + (x: 1065; y: 698), + (x: 1200; y: 690), + (x: 1200; y: 218), + (x: 1326; y: 252), + (x: 1359; y: 786), + (x: 1470; y: 810), + (x: 1485; y: 379), + (x: 1608; y: 342), + (x: 1641; y: 819), + (x: 1719; y: 864), + (x: 1746; y: 1500) + ); + Template8FPoints: array[0..0] of TPoint = + ( + (x: 1023; y: 0) + ); + +const Template9Points: array[0..23] of TPoint = + ( + (x: 384; y: 1500), + (x: 210; y: 1023), + (x: 213; y: 891), + (x: 501; y: 861), + (x: 228; y: 657), + (x: 558; y: 676), + (x: 561; y: 513), + (x: 246; y: 354), + (x: 609; y: 393), + (x: 876; y: 309), + (x: 759; y: 576), + (x: 759; y: 762), + (x: 1113; y: 750), + (x: 1128; y: 873), + (x: 1488; y: 870), + (x: 1473; y: 678), + (x: 1182; y: 501), + (x: 1515; y: 507), + (x: 1776; y: 393), + (x: 1668; y: 630), + (x: 1833; y: 714), + (x: 1674; y: 837), + (x: 1800; y: 1020), + (x: 1632; y: 1500) + ); + Template9FPoints: array[0..0] of TPoint = + ( + (x: 1023; y: 0) + ); + +const Template10Points: array[0..13] of TPoint = + ( + (x: 336; y: 1500), + (x: 303; y: 1026), + (x: 225; y: 921), + (x: 216; y: 741), + (x: 774; y: 810), + (x: 687; y: 336), + (x: 975; y: 192), + (x: 1350; y: 324), + (x: 1230; y: 681), + (x: 1257; y: 855), + (x: 1623; y: 846), + (x: 1821; y: 657), + (x: 1911; y: 897), + (x: 1704; y: 1500) + ); + Template10FPoints: array[0..0] of TPoint = + ( + (x: 1023; y: 0) + ); + +const Template11Points: array[0..9] of TPoint = + ( + (x: 270; y: 1500), + (x: 180; y: 795), + (x: 453; y: 753), + (x: 537; y: 900), + (x: 822; y: 729), + (x: 1128; y: 882), + (x: 1269; y: 657), + (x: 1560; y: 915), + (x: 1812; y: 867), + (x: 1854; y: 1500) + ); + Template11FPoints: array[0..0] of TPoint = + ( + (x: 1023; y: 0) + ); + +const Template12Points: array[0..38] of TPoint = + ( + (x: 201; y: 1500), + (x: 207; y: 920), + (x: 360; y: 901), + (x: 345; y: 822), + (x: 183; y: 810), + (x: 183; y: 632), + (x: 327; y: 628), + (x: 165; y: 402), + (x: 462; y: 443), + (x: 555; y: 272), + (x: 525; y: 556), + (x: 618; y: 647), + (x: 483; y: 712), + (x: 468; y: 860), + (x: 810; y: 884), + (x: 879; y: 796), + (x: 756; y: 764), + (x: 771; y: 620), + (x: 960; y: 625), + (x: 969; y: 517), + (x: 771; y: 503), + (x: 768; y: 395), + (x: 1092; y: 412), + (x: 1125; y: 616), + (x: 1029; y: 767), + (x: 1404; y: 858), + (x: 1440; y: 714), + (x: 1293; y: 688), + (x: 1344; y: 320), + (x: 1548; y: 342), + (x: 1494; y: 563), + (x: 1614; y: 570), + (x: 1710; y: 383), + (x: 1860; y: 448), + (x: 1683; y: 664), + (x: 1773; y: 726), + (x: 1578; y: 836), + (x: 1746; y: 918), + (x: 1662; y: 1500) + ); + Template12FPoints: array[0..0] of TPoint = + ( + (x: 1023; y: 0) + ); + +const Template13Points: array[0..13] of TPoint = + ( + (x: 645; y: 1500), + (x: 198; y: 732), + (x: 402; y: 648), + (x: 609; y: 763), + (x: 750; y: 590), + (x: 303; y: 376), + (x: 1023; y: 441), + (x: 1023; y: 316), + (x: 1719; y: 329), + (x: 1695; y: 457), + (x: 1038; y: 576), + (x: 1017; y: 756), + (x: 1803; y: 728), + (x: 1503; y: 1500) + ); + Template13FPoints: array[0..0] of TPoint = + ( + (x: 1023; y: 0) + ); + +const Template14Points: array[0..22] of TPoint = + ( + (x: 177; y: 1500), + (x: 262; y: 1026), + (x: 259; y: 303), + (x: 765; y: 162), + (x: 789; y: 357), + (x: 517; y: 420), + (x: 658; y: 690), + (x: 448; y: 762), + (x: 663; y: 1029), + (x: 765; y: 1440), + (x: 1446; y: 1431), + (x: 1439; y: 1026), + (x: 1416; y: 825), + (x: 1253; y: 840), + (x: 1253; y: 600), + (x: 1551; y: 573), + (x: 1506; y: 390), + (x: 1065; y: 366), + (x: 1077; y: 171), + (x: 1656; y: 156), + (x: 1821; y: 396), + (x: 1716; y: 768), + (x: 1926; y: 1500) + ); + Template14FPoints: array[0..0] of TPoint = + ( + (x: 1023; y: 0) + ); + +const EdgeTemplates: array[0..14] of TEdgeTemplate = + ( + (BasePoints: @Template0Points; + BasePointsCount: Succ(High(Template0Points)); + BezPassCnt: 4; + PassMin: 10; PassDelta: 5; + WaveAmplMin: 17; WaveAmplDelta: 20; + WaveFreqMin: 0.010; WaveFreqDelta: 0.002; + FillPoints: @Template0FPoints; + FillPointsCount: Succ(High(Template0FPoints)); + canMirror: false; canFlip: false; + ), + (BasePoints: @Template1Points; + BasePointsCount: Succ(High(Template1Points)); + BezPassCnt: 3; + PassMin: 10; PassDelta: 2; + WaveAmplMin: 25; WaveAmplDelta: 15; + WaveFreqMin: 0.008; WaveFreqDelta: 0.002; + FillPoints: @Template1FPoints; + FillPointsCount: Succ(High(Template1FPoints)); + canMirror: false; canFlip: false; + ), + (BasePoints: @Template2Points; + BasePointsCount: Succ(High(Template2Points)); + BezPassCnt: 3; + PassMin: 14; PassDelta: 3; + WaveAmplMin: 10; WaveAmplDelta: 10; + WaveFreqMin: 0.010; WaveFreqDelta: 0.002; + FillPoints: @Template2FPoints; + FillPointsCount: Succ(High(Template2FPoints)); + canMirror: true; canFlip: false; + ), + (BasePoints: @Template3Points; + BasePointsCount: Succ(High(Template3Points)); + BezPassCnt: 4; + PassMin: 15; PassDelta: 2; + WaveAmplMin: 8; WaveAmplDelta: 12; + WaveFreqMin: 0.015; WaveFreqDelta: 0.0015; + FillPoints: @Template3FPoints; + FillPointsCount: Succ(High(Template3FPoints)); + canMirror: true; canFlip: false; + ), + (BasePoints: @Template4Points; + BasePointsCount: Succ(High(Template4Points)); + BezPassCnt: 3; + PassMin: 19; PassDelta: 5; + WaveAmplMin: 12; WaveAmplDelta: 14; + WaveFreqMin: 0.008; WaveFreqDelta: 0.001; + FillPoints: @Template4FPoints; + FillPointsCount: Succ(High(Template4FPoints)); + canMirror: true; canFlip: false; + ), + (BasePoints: @Template5Points; + BasePointsCount: Succ(High(Template5Points)); + BezPassCnt: 4; + PassMin: 15; PassDelta: 1; + WaveAmplMin: 15; WaveAmplDelta: 14; + WaveFreqMin: 0.008; WaveFreqDelta: 0.002; + FillPoints: @Template5FPoints; + FillPointsCount: Succ(High(Template5FPoints)); + canMirror: true; canFlip: false; + ), + (BasePoints: @Template6Points; + BasePointsCount: Succ(High(Template6Points)); + BezPassCnt: 3; + PassMin: 15; PassDelta: 1; + WaveAmplMin: 15; WaveAmplDelta: 10; + WaveFreqMin: 0.010; WaveFreqDelta: 0.0015; + FillPoints: @Template6FPoints; + FillPointsCount: Succ(High(Template6FPoints)); + canMirror: true; canFlip: false; + ), + (BasePoints: @Template7Points; + BasePointsCount: Succ(High(Template7Points)); + BezPassCnt: 3; + PassMin: 12; PassDelta: 4; + WaveAmplMin: 5; WaveAmplDelta: 15; + WaveFreqMin: 0.015; WaveFreqDelta: 0.002; + FillPoints: @Template7FPoints; + FillPointsCount: Succ(High(Template7FPoints)); + canMirror: true; canFlip: false; + ), + (BasePoints: @Template8Points; + BasePointsCount: Succ(High(Template8Points)); + BezPassCnt: 4; + PassMin: 9; PassDelta: 3; + WaveAmplMin: 18; WaveAmplDelta: 18; + WaveFreqMin: 0.010; WaveFreqDelta: 0.002; + FillPoints: @Template8FPoints; + FillPointsCount: Succ(High(Template8FPoints)); + canMirror: true; canFlip: false; + ), + (BasePoints: @Template9Points; + BasePointsCount: Succ(High(Template9Points)); + BezPassCnt: 4; + PassMin: 17; PassDelta: 3; + WaveAmplMin: 10; WaveAmplDelta: 10; + WaveFreqMin: 0.010; WaveFreqDelta: 0.002; + FillPoints: @Template9FPoints; + FillPointsCount: Succ(High(Template9FPoints)); + canMirror: true; canFlip: false; + ), + (BasePoints: @Template10Points; + BasePointsCount: Succ(High(Template10Points)); + BezPassCnt: 4; + PassMin: 15; PassDelta: 2; + WaveAmplMin: 15; WaveAmplDelta: 10; + WaveFreqMin: 0.008; WaveFreqDelta: 0.002; + FillPoints: @Template10FPoints; + FillPointsCount: Succ(High(Template10FPoints)); + canMirror: false; canFlip: false; + ), + (BasePoints: @Template11Points; + BasePointsCount: Succ(High(Template11Points)); + BezPassCnt: 4; + PassMin: 15; PassDelta: 1; + WaveAmplMin: 10; WaveAmplDelta: 10; + WaveFreqMin: 0.008; WaveFreqDelta: 0.002; + FillPoints: @Template11FPoints; + FillPointsCount: Succ(High(Template11FPoints)); + canMirror: true; canFlip: false; + ), + (BasePoints: @Template12Points; + BasePointsCount: Succ(High(Template12Points)); + BezPassCnt: 3; + PassMin: 10; PassDelta: 1; + WaveAmplMin: 15; WaveAmplDelta: 15; + WaveFreqMin: 0.005; WaveFreqDelta: 0.003; + FillPoints: @Template12FPoints; + FillPointsCount: Succ(High(Template12FPoints)); + canMirror: true; canFlip: false; + ), + (BasePoints: @Template13Points; + BasePointsCount: Succ(High(Template13Points)); + BezPassCnt: 5; + PassMin: 15; PassDelta: 3; + WaveAmplMin: 18; WaveAmplDelta: 15; + WaveFreqMin: 0.0028; WaveFreqDelta: 0.002; + FillPoints: @Template13FPoints; + FillPointsCount: Succ(High(Template13FPoints)); + canMirror: true; canFlip: false; + ), + (BasePoints: @Template14Points; + BasePointsCount: Succ(High(Template14Points)); + BezPassCnt: 4; + PassMin: 14; PassDelta: 3; + WaveAmplMin: 20; WaveAmplDelta: 15; + WaveFreqMin: 0.003; WaveFreqDelta: 0.002; + FillPoints: @Template14FPoints; + FillPointsCount: Succ(High(Template14FPoints)); + canMirror: true; canFlip: false; + ) + ); + + + +implementation + +end. diff -r 57c2ef19f719 -r f97a7a3dc8f6 hedgewars/uLocale.pas --- a/hedgewars/uLocale.pas Thu Oct 05 16:33:18 2006 +0000 +++ b/hedgewars/uLocale.pas Thu Oct 05 17:02:09 2006 +0000 @@ -1,73 +1,73 @@ -(* - * 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 - *) - -unit uLocale; -interface -type TAmmoStrId = (sidGrenade, sidClusterBomb, sidBazooka, sidUFO, sidShotgun, - sidPickHammer, sidSkip, sidRope, sidMine, sidDEagle, - sidDynamite, sidBaseballBat, sidFirePunch, sidSeconds); - TMsgStrId = (sidStartFight, sidDraw, sidWinner, sidVolume); -var trammo: array[TAmmoStrId] of string; - trmsg: array[TMsgStrId] of string; - -procedure LoadLocale(FileName: string); -function Format(fmt: shortstring; var arg: shortstring): shortstring; - -implementation -uses uMisc; - -procedure LoadLocale(FileName: string); -var s: shortstring; - f: textfile; - a, b, c: integer; -begin -{$I-} -AssignFile(f, FileName); -reset(f); -TryDo(IOResult = 0, 'Cannot load locale "' + FileName + '"', true); -while not eof(f) do - begin - readln(f, s); - if Length(s) = 0 then continue; - if s[1] = ';' then continue; - TryDo(Length(s) > 6, 'Load locale: empty string', true); - val(s[1]+s[2], a, c); - TryDo(c = 0, 'Load locale: numbers should be two-digit', true); - TryDo(s[3] = ':', 'Load locale: ":" expected', true); - val(s[4]+s[5], b, c); - TryDo(c = 0, 'Load locale: numbers should be two-digit', true); - TryDo(s[6] = '=', 'Load locale: "=" expected', true); - Delete(s, 1, 6); - case a of - 0: if (b >=0) and (b <= ord(High(TAmmoStrId))) then trammo[TAmmoStrId(b)]:= s; - 1: if (b >=0) and (b <= ord(High(TMsgStrId))) then trmsg[TMsgStrId(b)]:= s; - end; - end; -closefile(f) -{$I+} -end; - -function Format(fmt: shortstring; var arg: shortstring): shortstring; -var i: integer; -begin -i:= Pos('%1', fmt); -if i = 0 then Result:= fmt - else Result:= copy(fmt, 1, i - 1) + arg + Format(copy(fmt, i + 2, Length(fmt) - i - 1), arg) -end; - -end. +(* + * 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 + *) + +unit uLocale; +interface +type TAmmoStrId = (sidGrenade, sidClusterBomb, sidBazooka, sidUFO, sidShotgun, + sidPickHammer, sidSkip, sidRope, sidMine, sidDEagle, + sidDynamite, sidBaseballBat, sidFirePunch, sidSeconds); + TMsgStrId = (sidStartFight, sidDraw, sidWinner, sidVolume); +var trammo: array[TAmmoStrId] of string; + trmsg: array[TMsgStrId] of string; + +procedure LoadLocale(FileName: string); +function Format(fmt: shortstring; var arg: shortstring): shortstring; + +implementation +uses uMisc; + +procedure LoadLocale(FileName: string); +var s: shortstring; + f: textfile; + a, b, c: integer; +begin +{$I-} +AssignFile(f, FileName); +reset(f); +TryDo(IOResult = 0, 'Cannot load locale "' + FileName + '"', true); +while not eof(f) do + begin + readln(f, s); + if Length(s) = 0 then continue; + if s[1] = ';' then continue; + TryDo(Length(s) > 6, 'Load locale: empty string', true); + val(s[1]+s[2], a, c); + TryDo(c = 0, 'Load locale: numbers should be two-digit', true); + TryDo(s[3] = ':', 'Load locale: ":" expected', true); + val(s[4]+s[5], b, c); + TryDo(c = 0, 'Load locale: numbers should be two-digit', true); + TryDo(s[6] = '=', 'Load locale: "=" expected', true); + Delete(s, 1, 6); + case a of + 0: if (b >=0) and (b <= ord(High(TAmmoStrId))) then trammo[TAmmoStrId(b)]:= s; + 1: if (b >=0) and (b <= ord(High(TMsgStrId))) then trmsg[TMsgStrId(b)]:= s; + end; + end; +closefile(f) +{$I+} +end; + +function Format(fmt: shortstring; var arg: shortstring): shortstring; +var i: integer; +begin +i:= Pos('%1', fmt); +if i = 0 then Result:= fmt + else Result:= copy(fmt, 1, i - 1) + arg + Format(copy(fmt, i + 2, Length(fmt) - i - 1), arg) +end; + +end. diff -r 57c2ef19f719 -r f97a7a3dc8f6 share/CMakeLists.txt --- a/share/CMakeLists.txt Thu Oct 05 16:33:18 2006 +0000 +++ b/share/CMakeLists.txt Thu Oct 05 17:02:09 2006 +0000 @@ -1,1 +1,1 @@ -add_subdirectory(hedgewars) +add_subdirectory(hedgewars) diff -r 57c2ef19f719 -r f97a7a3dc8f6 share/hedgewars/CMakeLists.txt --- a/share/hedgewars/CMakeLists.txt Thu Oct 05 16:33:18 2006 +0000 +++ b/share/hedgewars/CMakeLists.txt Thu Oct 05 17:02:09 2006 +0000 @@ -1,1 +1,1 @@ -add_subdirectory(Data) +add_subdirectory(Data) diff -r 57c2ef19f719 -r f97a7a3dc8f6 share/hedgewars/Data/CMakeLists.txt --- a/share/hedgewars/Data/CMakeLists.txt Thu Oct 05 16:33:18 2006 +0000 +++ b/share/hedgewars/Data/CMakeLists.txt Thu Oct 05 17:02:09 2006 +0000 @@ -1,3 +1,3 @@ -foreach(dir "Fonts" "Forts" "Graphics" "Locale" "Maps" "Sounds" "Themes") - add_subdirectory(${dir}) +foreach(dir "Fonts" "Forts" "Graphics" "Locale" "Maps" "Sounds" "Themes") + add_subdirectory(${dir}) endforeach(dir) \ No newline at end of file diff -r 57c2ef19f719 -r f97a7a3dc8f6 share/hedgewars/Data/Graphics/AmmoMenu/CMakeLists.txt --- a/share/hedgewars/Data/Graphics/AmmoMenu/CMakeLists.txt Thu Oct 05 16:33:18 2006 +0000 +++ b/share/hedgewars/Data/Graphics/AmmoMenu/CMakeLists.txt Thu Oct 05 17:02:09 2006 +0000 @@ -1,8 +1,8 @@ -install(FILES - AmmoName.png - Ammos.png - BrdrLines.png - Selection.png - Slot.png - SlotKeys.png +install(FILES + AmmoName.png + Ammos.png + BrdrLines.png + Selection.png + Slot.png + SlotKeys.png DESTINATION ${SHAREPATH}Data/Graphics/AmmoMenu) \ No newline at end of file diff -r 57c2ef19f719 -r f97a7a3dc8f6 share/hedgewars/Data/Graphics/CMakeLists.txt --- a/share/hedgewars/Data/Graphics/CMakeLists.txt Thu Oct 05 16:33:18 2006 +0000 +++ b/share/hedgewars/Data/Graphics/CMakeLists.txt Thu Oct 05 17:02:09 2006 +0000 @@ -1,37 +1,37 @@ -add_subdirectory(Graves) -add_subdirectory(AmmoMenu) -install(FILES - Arrow.png - BigDigits.png - BlueWater.png - Bomb.png - Case.png - ClBomb.png - Clouds.png - ClParticle.png - Console.png - Crosshair.png - dynamite.png - Expl50.png - Finger.png - FirstAid.png - Flame.png - Frame.png - Girder.png - Grenade.png - Hedgehog.png - Lag.png - MineOff.png - MineOn.png - Power.png - PowerBar.png - RopeHook.png - RopeNode.png - SmokeTrace.png - Targetp.png - thinking.png - UFO.png - WindBar.png - WindL.png - WindR.png +add_subdirectory(Graves) +add_subdirectory(AmmoMenu) +install(FILES + Arrow.png + BigDigits.png + BlueWater.png + Bomb.png + Case.png + ClBomb.png + Clouds.png + ClParticle.png + Console.png + Crosshair.png + dynamite.png + Expl50.png + Finger.png + FirstAid.png + Flame.png + Frame.png + Girder.png + Grenade.png + Hedgehog.png + Lag.png + MineOff.png + MineOn.png + Power.png + PowerBar.png + RopeHook.png + RopeNode.png + SmokeTrace.png + Targetp.png + thinking.png + UFO.png + WindBar.png + WindL.png + WindR.png DESTINATION ${SHAREPATH}Data/Graphics) \ No newline at end of file diff -r 57c2ef19f719 -r f97a7a3dc8f6 share/hedgewars/Data/Locale/CMakeLists.txt --- a/share/hedgewars/Data/Locale/CMakeLists.txt Thu Oct 05 16:33:18 2006 +0000 +++ b/share/hedgewars/Data/Locale/CMakeLists.txt Thu Oct 05 17:02:09 2006 +0000 @@ -1,4 +1,4 @@ -install(FILES - en.txt - ru.txt +install(FILES + en.txt + ru.txt DESTINATION ${SHAREPATH}Data/Locale) \ No newline at end of file diff -r 57c2ef19f719 -r f97a7a3dc8f6 share/hedgewars/Data/Locale/en.txt --- a/share/hedgewars/Data/Locale/en.txt Thu Oct 05 16:33:18 2006 +0000 +++ b/share/hedgewars/Data/Locale/en.txt Thu Oct 05 17:02:09 2006 +0000 @@ -1,21 +1,21 @@ -; English locale - -00:00=Grenade -00:01=ClusterBomb -00:02=Bazooka -00:03=UFO -00:04=Shotgun -00:05=PickHammer -00:06=Skip -00:07=Rope -00:08=Mine -00:09=DEagle -00:10=Dynamite -00:11=BaseballBat -00:12=Fire Punch -00:13=sec - -01:00=Let's fight! -01:01=Round draw -01:02=%1 wins! +; English locale + +00:00=Grenade +00:01=ClusterBomb +00:02=Bazooka +00:03=UFO +00:04=Shotgun +00:05=PickHammer +00:06=Skip +00:07=Rope +00:08=Mine +00:09=DEagle +00:10=Dynamite +00:11=BaseballBat +00:12=Fire Punch +00:13=sec + +01:00=Let's fight! +01:01=Round draw +01:02=%1 wins! 01:03=Volume %1% \ No newline at end of file diff -r 57c2ef19f719 -r f97a7a3dc8f6 share/hedgewars/Data/Locale/ru.txt --- a/share/hedgewars/Data/Locale/ru.txt Thu Oct 05 16:33:18 2006 +0000 +++ b/share/hedgewars/Data/Locale/ru.txt Thu Oct 05 17:02:09 2006 +0000 @@ -1,21 +1,21 @@ -; Перевод сообщений на русский - -00:00=Бомба -00:01=Кластерная бомба -00:02=Базука -00:03=НЛО -00:04=Ружьё -00:05=Отбойный молоток -00:06=Пропустить ход -00:07=Верёвка -00:08=Мина -00:09=Дезерт -00:10=Динамит -00:11=Бейсбольная бита -00:12=Огненный удар -00:13=сек - -01:00=Вперёд к победе! -01:01=Ничья -01:02=Победила команда %1! +; Перевод сообщений на русский + +00:00=Бомба +00:01=Кластерная бомба +00:02=Базука +00:03=НЛО +00:04=Ружьё +00:05=Отбойный молоток +00:06=Пропустить ход +00:07=Верёвка +00:08=Мина +00:09=Дезерт +00:10=Динамит +00:11=Бейсбольная бита +00:12=Огненный удар +00:13=сек + +01:00=Вперёд к победе! +01:01=Ничья +01:02=Победила команда %1! 01:03=Громкость %1% \ No newline at end of file diff -r 57c2ef19f719 -r f97a7a3dc8f6 share/hedgewars/Data/Sounds/CMakeLists.txt --- a/share/hedgewars/Data/Sounds/CMakeLists.txt Thu Oct 05 16:33:18 2006 +0000 +++ b/share/hedgewars/Data/Sounds/CMakeLists.txt Thu Oct 05 17:02:09 2006 +0000 @@ -1,11 +1,11 @@ -install(FILES - explosion.ogg - graveimpact.ogg - grenadeimpact.ogg - minetick.ogg - shotgunfire.ogg - shotgunreload.ogg - splash.ogg - throwpowerup.ogg - throwrelease.ogg +install(FILES + explosion.ogg + graveimpact.ogg + grenadeimpact.ogg + minetick.ogg + shotgunfire.ogg + shotgunreload.ogg + splash.ogg + throwpowerup.ogg + throwrelease.ogg DESTINATION ${SHAREPATH}Data/Sounds) \ No newline at end of file diff -r 57c2ef19f719 -r f97a7a3dc8f6 share/hedgewars/Data/Themes/CMakeLists.txt --- a/share/hedgewars/Data/Themes/CMakeLists.txt Thu Oct 05 16:33:18 2006 +0000 +++ b/share/hedgewars/Data/Themes/CMakeLists.txt Thu Oct 05 17:02:09 2006 +0000 @@ -1,5 +1,5 @@ -foreach(dir avematan bubbles ethereal norsk steel tibet wood xtheme) - add_subdirectory(${dir}) -endforeach(dir) - -install(FILES themes.cfg DESTINATION ${SHAREPATH}Data/Themes) +foreach(dir avematan bubbles ethereal norsk steel tibet wood xtheme) + add_subdirectory(${dir}) +endforeach(dir) + +install(FILES themes.cfg DESTINATION ${SHAREPATH}Data/Themes) diff -r 57c2ef19f719 -r f97a7a3dc8f6 share/hedgewars/Data/Themes/avematan/CMakeLists.txt --- a/share/hedgewars/Data/Themes/avematan/CMakeLists.txt Thu Oct 05 16:33:18 2006 +0000 +++ b/share/hedgewars/Data/Themes/avematan/CMakeLists.txt Thu Oct 05 17:02:09 2006 +0000 @@ -1,11 +1,11 @@ -install(FILES - a.png - Border.png - e.png - horizont.png - inf.png - LandTex.png - Sky.png - sqrt.png - theme.cfg - DESTINATION ${SHAREPATH}Data/Themes/avematan) +install(FILES + a.png + Border.png + e.png + horizont.png + inf.png + LandTex.png + Sky.png + sqrt.png + theme.cfg + DESTINATION ${SHAREPATH}Data/Themes/avematan) diff -r 57c2ef19f719 -r f97a7a3dc8f6 share/hedgewars/Data/Themes/avematan/theme.cfg --- a/share/hedgewars/Data/Themes/avematan/theme.cfg Thu Oct 05 16:33:18 2006 +0000 +++ b/share/hedgewars/Data/Themes/avematan/theme.cfg Thu Oct 05 17:02:09 2006 +0000 @@ -1,11 +1,13 @@ -8388608 -4 -a -186 221 65 220 45 1 1 0 0 186 180 -e -150 181 56 180 33 1 2 0 65 117 90 65 0 95 118 -inf -248 112 220 5 22 18 1 0 0 205 112 -sqrt -264 249 2 191 7 25 3 25 183 82 66 68 54 81 131 117 2 146 55 -0 +8388608 +5 +a +186 221 65 220 45 1 1 0 0 186 180 +e +150 181 56 180 33 1 2 0 65 117 90 65 0 95 118 +inf +248 112 220 5 22 18 1 0 0 205 112 +inf +248 112 0 48 4 18 1 29 0 219 112 +sqrt +264 249 2 191 7 25 3 25 183 82 66 68 54 81 131 117 2 146 55 +0 diff -r 57c2ef19f719 -r f97a7a3dc8f6 share/hedgewars/Data/Themes/bubbles/CMakeLists.txt --- a/share/hedgewars/Data/Themes/bubbles/CMakeLists.txt Thu Oct 05 16:33:18 2006 +0000 +++ b/share/hedgewars/Data/Themes/bubbles/CMakeLists.txt Thu Oct 05 17:02:09 2006 +0000 @@ -1,8 +1,8 @@ -install(FILES - Border.png - horizont.png - LandTex.png - round.png - Sky.png - theme.cfg - DESTINATION ${SHAREPATH}Data/Themes/bubbles) +install(FILES + Border.png + horizont.png + LandTex.png + round.png + Sky.png + theme.cfg + DESTINATION ${SHAREPATH}Data/Themes/bubbles) diff -r 57c2ef19f719 -r f97a7a3dc8f6 share/hedgewars/Data/Themes/bubbles/theme.cfg --- a/share/hedgewars/Data/Themes/bubbles/theme.cfg Thu Oct 05 16:33:18 2006 +0000 +++ b/share/hedgewars/Data/Themes/bubbles/theme.cfg Thu Oct 05 17:02:09 2006 +0000 @@ -1,5 +1,5 @@ -2829989 -1 -round -167 242 90 242 10 1 3 0 0 97 97 63 61 95 115 100 190 67 26 -0 +2829989 +1 +round +167 242 90 242 10 1 3 0 0 97 97 63 61 95 115 100 190 67 26 +0 diff -r 57c2ef19f719 -r f97a7a3dc8f6 share/hedgewars/Data/Themes/ethereal/theme.cfg --- a/share/hedgewars/Data/Themes/ethereal/theme.cfg Thu Oct 05 16:33:18 2006 +0000 +++ b/share/hedgewars/Data/Themes/ethereal/theme.cfg Thu Oct 05 17:02:09 2006 +0000 @@ -1,3 +1,3 @@ -32896 -0 -0 +32896 +0 +0 diff -r 57c2ef19f719 -r f97a7a3dc8f6 share/hedgewars/Data/Themes/norsk/theme.cfg --- a/share/hedgewars/Data/Themes/norsk/theme.cfg Thu Oct 05 16:33:18 2006 +0000 +++ b/share/hedgewars/Data/Themes/norsk/theme.cfg Thu Oct 05 17:02:09 2006 +0000 @@ -1,3 +1,3 @@ -32896 -0 -0 +32896 +0 +0 diff -r 57c2ef19f719 -r f97a7a3dc8f6 share/hedgewars/Data/Themes/steel/CMakeLists.txt --- a/share/hedgewars/Data/Themes/steel/CMakeLists.txt Thu Oct 05 16:33:18 2006 +0000 +++ b/share/hedgewars/Data/Themes/steel/CMakeLists.txt Thu Oct 05 17:02:09 2006 +0000 @@ -1,12 +1,12 @@ -install(FILES - 01.png - 02.png - Border.png - Clouds.16.png - Clouds.32.png - horizont.png - LandTex.png - Sky.16.png - Sky.32.png - theme.cfg - DESTINATION ${SHAREPATH}Data/Themes/steel) +install(FILES + 01.png + 02.png + Border.png + Clouds.16.png + Clouds.32.png + horizont.png + LandTex.png + Sky.16.png + Sky.32.png + theme.cfg + DESTINATION ${SHAREPATH}Data/Themes/steel) diff -r 57c2ef19f719 -r f97a7a3dc8f6 share/hedgewars/Data/Themes/steel/theme.cfg --- a/share/hedgewars/Data/Themes/steel/theme.cfg Thu Oct 05 16:33:18 2006 +0000 +++ b/share/hedgewars/Data/Themes/steel/theme.cfg Thu Oct 05 17:02:09 2006 +0000 @@ -1,7 +1,7 @@ -2105376 -2 -01 -122 178 4 175 114 2 1 0 0 122 132 -02 -366 363 363 300 3 44 2 119 110 198 205 0 0 171 175 -0 +2105376 +2 +01 +122 178 4 175 114 2 1 0 0 122 132 +02 +366 363 363 300 3 44 2 119 110 198 205 0 0 171 175 +0 diff -r 57c2ef19f719 -r f97a7a3dc8f6 share/hedgewars/Data/Themes/themes.cfg --- a/share/hedgewars/Data/Themes/themes.cfg Thu Oct 05 16:33:18 2006 +0000 +++ b/share/hedgewars/Data/Themes/themes.cfg Thu Oct 05 17:02:09 2006 +0000 @@ -1,6 +1,6 @@ -avematan -bubbles -steel -tibet -wood -xtheme +avematan +bubbles +steel +tibet +wood +xtheme diff -r 57c2ef19f719 -r f97a7a3dc8f6 share/hedgewars/Data/Themes/tibet/CMakeLists.txt --- a/share/hedgewars/Data/Themes/tibet/CMakeLists.txt Thu Oct 05 16:33:18 2006 +0000 +++ b/share/hedgewars/Data/Themes/tibet/CMakeLists.txt Thu Oct 05 17:02:09 2006 +0000 @@ -1,12 +1,12 @@ -install(FILES - Border.png - chha.png - horizont.png - LandTex.png - ma.png - nga.png - sa.png - Sky.png - ta1.png - theme.cfg - DESTINATION ${SHAREPATH}Data/Themes/tibet) +install(FILES + Border.png + chha.png + horizont.png + LandTex.png + ma.png + nga.png + sa.png + Sky.png + ta1.png + theme.cfg + DESTINATION ${SHAREPATH}Data/Themes/tibet) diff -r 57c2ef19f719 -r f97a7a3dc8f6 share/hedgewars/Data/Themes/tibet/theme.cfg --- a/share/hedgewars/Data/Themes/tibet/theme.cfg Thu Oct 05 16:33:18 2006 +0000 +++ b/share/hedgewars/Data/Themes/tibet/theme.cfg Thu Oct 05 17:02:09 2006 +0000 @@ -1,13 +1,13 @@ -4989440 -5 -chha -167 127 26 118 94 9 2 5 9 127 94 135 2 29 29 -ma -145 117 88 98 22 11 2 9 4 105 90 120 1 23 25 -nga -131 111 115 95 11 13 2 7 6 95 91 105 6 18 17 -sa -153 111 2 83 14 12 2 9 9 140 57 25 65 96 40 -ta1 -125 139 58 130 16 8 1 5 7 119 100 -0 +4989440 +5 +chha +167 127 26 118 94 9 2 5 9 127 94 135 2 29 29 +ma +145 117 88 98 22 11 2 9 4 105 90 120 1 23 25 +nga +131 111 115 95 11 13 2 7 6 95 91 105 6 18 17 +sa +153 111 2 83 14 12 2 9 9 140 57 25 65 96 40 +ta1 +125 139 58 130 16 8 1 5 7 119 100 +0 diff -r 57c2ef19f719 -r f97a7a3dc8f6 share/hedgewars/Data/Themes/wood/CMakeLists.txt --- a/share/hedgewars/Data/Themes/wood/CMakeLists.txt Thu Oct 05 16:33:18 2006 +0000 +++ b/share/hedgewars/Data/Themes/wood/CMakeLists.txt Thu Oct 05 17:02:09 2006 +0000 @@ -1,11 +1,11 @@ -install(FILES - Border.png - gr1.png - horizont.png - LandTex.png - leaf1.png - leaf2.png - Sky.png - tree.png - theme.cfg - DESTINATION ${SHAREPATH}Data/Themes/wood) +install(FILES + Border.png + gr1.png + horizont.png + LandTex.png + leaf1.png + leaf2.png + Sky.png + tree.png + theme.cfg + DESTINATION ${SHAREPATH}Data/Themes/wood) diff -r 57c2ef19f719 -r f97a7a3dc8f6 share/hedgewars/Data/Themes/wood/theme.cfg --- a/share/hedgewars/Data/Themes/wood/theme.cfg Thu Oct 05 16:33:18 2006 +0000 +++ b/share/hedgewars/Data/Themes/wood/theme.cfg Thu Oct 05 17:02:09 2006 +0000 @@ -1,11 +1,11 @@ -5129753 -2 -tree -105 225 41 224 22 1 1 0 0 105 203 -gr1 -121 129 47 123 27 4 1 0 0 121 105 -2 -leaf1 -5 -leaf2 -5 +5129753 +2 +tree +105 225 41 224 22 1 1 0 0 105 203 +gr1 +121 129 47 123 27 4 1 0 0 121 105 +2 +leaf1 +5 +leaf2 +5 diff -r 57c2ef19f719 -r f97a7a3dc8f6 share/hedgewars/Data/Themes/xtheme/CMakeLists.txt --- a/share/hedgewars/Data/Themes/xtheme/CMakeLists.txt Thu Oct 05 16:33:18 2006 +0000 +++ b/share/hedgewars/Data/Themes/xtheme/CMakeLists.txt Thu Oct 05 17:02:09 2006 +0000 @@ -1,8 +1,8 @@ -install(FILES - Border.png - horizont.png - LandTex.png - plant1.png - Sky.png - theme.cfg - DESTINATION ${SHAREPATH}Data/Themes/xtheme) +install(FILES + Border.png + horizont.png + LandTex.png + plant1.png + Sky.png + theme.cfg + DESTINATION ${SHAREPATH}Data/Themes/xtheme) diff -r 57c2ef19f719 -r f97a7a3dc8f6 share/hedgewars/Data/Themes/xtheme/theme.cfg --- a/share/hedgewars/Data/Themes/xtheme/theme.cfg Thu Oct 05 16:33:18 2006 +0000 +++ b/share/hedgewars/Data/Themes/xtheme/theme.cfg Thu Oct 05 17:02:09 2006 +0000 @@ -1,5 +1,5 @@ -8388608 -1 -plant1 -128 128 35 127 29 1 2 12 7 63 108 75 26 49 52 -0 +8388608 +1 +plant1 +128 128 35 127 29 1 2 12 7 63 108 75 26 49 52 +0