# HG changeset patch
# User jose1711
# Date 1318085696 -7200
# Node ID 5a4ea2c7b9dfb3e61c9c69ed1a78251129fd00d6
# Parent 531f64292489ad5f7c8e2f16b64dd9d3c6418310# Parent e6426c6b2882df17469b888486b79d79b49857bb
merge
diff -r 531f64292489 -r 5a4ea2c7b9df .hgtags
--- a/.hgtags Sat Oct 08 16:45:52 2011 +0200
+++ b/.hgtags Sat Oct 08 16:54:56 2011 +0200
@@ -42,3 +42,7 @@
0000000000000000000000000000000000000000 0.9.9
fee68e3a303998fdfcc69f74775dc84a36f587fb 0.9.9.1
0000000000000000000000000000000000000000 0.9.9.1
+718f98a9df122d73f3ba9add4d1654865199de31 Hedgewars-iOS-1.3
+cba92708277b6d0aeabfff2b878845b7d848bdcd Hedgewars-iOS-1.3.1
+74bc72746bec68806344f4ba7be0d1bc6e05d380 0.9.16-release
+652a199d4f38f5becbec0839f5a1f63294dd89bf Hedgewars-iOS-1.3.2
diff -r 531f64292489 -r 5a4ea2c7b9df CMakeLists.txt
--- a/CMakeLists.txt Sat Oct 08 16:45:52 2011 +0200
+++ b/CMakeLists.txt Sat Oct 08 16:54:56 2011 +0200
@@ -41,8 +41,8 @@
#versioning
set(CPACK_PACKAGE_VERSION_MAJOR 0)
set(CPACK_PACKAGE_VERSION_MINOR 9)
-set(CPACK_PACKAGE_VERSION_PATCH 16${version_suffix})
-set(HEDGEWARS_PROTO_VER 38)
+set(CPACK_PACKAGE_VERSION_PATCH 17${version_suffix})
+set(HEDGEWARS_PROTO_VER 40)
set(HEDGEWARS_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
@@ -132,17 +132,17 @@
endif(APPLE)
-#this snippet sets "Release" mode by default
+#build Debug only when explicitally set
if (NOT CMAKE_BUILD_TYPE)
- set (CMAKE_BUILD_TYPE RELEASE CACHE STRING "Choose the type of build, options are: None Debug Release." FORCE)
+ set (CMAKE_BUILD_TYPE RELEASE CACHE STRING "Choose the type of build, options are: Debug Release." FORCE)
endif (NOT CMAKE_BUILD_TYPE)
-if(CMAKE_BUILD_TYPE MATCHES RELEASE OR CMAKE_BUILD_TYPE MATCHES "Release")
+if(CMAKE_BUILD_TYPE MATCHES DEBUG OR CMAKE_BUILD_TYPE MATCHES "Debug" OR CMAKE_BUILD_TYPE MATCHES "debug")
+ message(STATUS "Building Debug")
+ set(Optz false)
+else()
message(STATUS "Building Release")
set(Optz true)
-else()
- message(STATUS "Building Debug")
- set(Optz false)
endif()
@@ -262,10 +262,10 @@
"config\\\\.inc$"
"hwengine\\\\.desktop$"
"CMakeCache\\\\.txt$"
- "^${CMAKE_CURRENT_SOURCE_DIR}/misc/libopenalbridge"
- "^${CMAKE_CURRENT_SOURCE_DIR}/misc/libfreetype"
- "^${CMAKE_CURRENT_SOURCE_DIR}/misc/liblua"
- "^${CMAKE_CURRENT_SOURCE_DIR}/misc/libtremor"
+# "^${CMAKE_CURRENT_SOURCE_DIR}/misc/libopenalbridge"
+# "^${CMAKE_CURRENT_SOURCE_DIR}/misc/libfreetype"
+# "^${CMAKE_CURRENT_SOURCE_DIR}/misc/liblua"
+# "^${CMAKE_CURRENT_SOURCE_DIR}/misc/libtremor"
"^${CMAKE_CURRENT_SOURCE_DIR}/project_files/HedgewarsMobile/"
"^${CMAKE_CURRENT_SOURCE_DIR}/bin/[a-z]"
"^${CMAKE_CURRENT_SOURCE_DIR}/tools/templates"
diff -r 531f64292489 -r 5a4ea2c7b9df CREDITS
--- a/CREDITS Sat Oct 08 16:45:52 2011 +0200
+++ b/CREDITS Sat Oct 08 16:54:56 2011 +0200
@@ -48,4 +48,16 @@
==========
- Stephen Alexander
+==========
+= SOUNDS
+==========
+- Mine impact sound from http://www.freesound.org/people/adcbicycle/sounds/13947/
+- Hammer sound from http://www.freesound.org/people/Syna-Max/sounds/43586/
+- Sinegun firing sound remixed from
+ http://beta.freesound.org/people/aust_paul/sounds/30935/
+ http://www.freesound.org/people/Edgar/sounds/162/
+ http://www.freesound.org/people/Ionizing/sounds/22033/
+ http://www.freesound.org/people/Jovica/sounds/38317/
+
+
ALL OTHER CONTENT IS PROPERTY OF Andrey Korotaev UNLESS OTHERWISE SPECIFIED
\ No newline at end of file
diff -r 531f64292489 -r 5a4ea2c7b9df ChangeLog.txt
--- a/ChangeLog.txt Sat Oct 08 16:45:52 2011 +0200
+++ b/ChangeLog.txt Sat Oct 08 16:54:56 2011 +0200
@@ -1,20 +1,34 @@
+ features
* bugfixes
-0.9.15 -> ???:
- + New modes: The Specialists, Space Invasion
+0.9.15 -> 0.9.16:
+ + In-game chat now supports backspace-repeat and Escape to close the text input area
+ + Team status bars shrunk/made translucent if they take up a significant portion of the screen
+ + Background music change on sudden death mode
+ + Stereoscopic rendering
+ Installing content (anything under Data/ - maps, sounds, and any such stuff) to user profile allows custom adding/overriding of any Data/ content
+ + Screen for downloadable content
+ + Allow up to 8 teams in a game
+ + New gameplay modes/styles: Racer, The Specialists, Tumbler, Space Invasion, Balanced Random Weapon
+ + New single player missions: Bamboo Thicket, That Sinking Feeling, Newton and the Tree
+ + New Weapon/Utility: Land Spray Gun
+ + New Utility: Time Box
+ + New Game mode: Tag team
+ + New Game option for map bottom border
+ + New Theme: Golf
+ + Many new hats
+ Sudden Death art
- + New Weapon/Utility: Land Spray Gun
- + New Game mode: Tag team
+ Get away time modifier (in %)
- + Allow up to 8 teams in a game
+ Shoppa scheme by default resets ammo
+ Shots are on a tenth of a second delay instead of a 1 and a quarter second delay (fast deagle/portal fire)
+ Defective mines explode if they take enough damage
+ Rope head can attach to hogs/crates/barrels again (rope still passes through them)
+ Control of grenade bounce
+ Drill Strike bombs don't explode when leaving ground, but after a (customizable!) timer
+ + Hammer impacts mines/barrels
+ + Seduction is an Area-of-Effect attack now
+ + Significantly altered flame behavior and damage.
+ + 'Throwing' weapons into hogs (e.g. grenade) no longer does max damage.
+ Ukranian localization of Default voice. support for localized voices
+ Theme cleanup, including the new theme config file change
+ Improvements in scoring and tracking damage
@@ -22,23 +36,32 @@
+ Mudball does not end turn
+ Indicator for height of plane when using napalm
+ Land smoothing (looks less pixelated on generation and damage)
- + Improved lua script support (e.g. possibility to change hats)
+ + Improved lua script support (e.g. set per-hog ammo, place girders, spawn fake crates, switch hogs, change hats)
+ + The names of the ShoppaKingTournament winners are now written on the Trophies in the ShoppaKing and TrophyRace maps!
+ + Allow window resizes during game
+ + Improved fullscreen capabilities
+ + Additional/new sounds (mine impact, sine gun, etc)
+ + Victory/flawless victory sounds
+ * Voices don't overlap (was needed more due to faster game actions due to shortened delays)
* Prevent portaling to impossible locations better
* Snow accumulates more smoothly
* Rope should be less sticky now
+ * Rope shouldn't be able to get Hogs stuck on walls anymore
* Fix for last portal shot always being yellow
* More accurate napalm strike drop location
- * AI fixes
+ * AI fixes (heh, yeah right)
* Fixed locales, such as korean
* Code refactoring
* Various bug/leak fixes
Frontend/Menu and Netgame:
- + Drawing straight lines in drawn map mode
+ + Drawing straight lines in drawn map mode (hold down the control key when clicking, then move mouse to end point and release).
+ + Undo clear in drawn map mode
+ Autokick ignored players joining your room
+ Improved nick sorting in lobby and rooms. (not case-sensitive, letters first, friend @ top, ignored @ bottom)
+ Display player count in lobby
+ Lobby: Player names of online players can be clicked in chat directly so that you don't have to find them in the player list
+ + Room names can be changed by the room admin without recreating the room
* Fix invisible icons in popup menus
* Various fixes and adjustments
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/AbstractPage.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/AbstractPage.cpp Sat Oct 08 16:54:56 2011 +0200
@@ -0,0 +1,101 @@
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2006-2011 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 "AbstractPage.h"
+
+AbstractPage::AbstractPage(QWidget* parent)
+{
+ Q_UNUSED(parent);
+
+ font14 = new QFont("MS Shell Dlg", 14);
+}
+
+void AbstractPage::initPage()
+{
+ QGridLayout * pageLayout = new QGridLayout(this);
+
+ // stretch grid space for body and footer
+ pageLayout->setColumnStretch(0,0);
+ pageLayout->setColumnStretch(1,1);
+ pageLayout->setRowStretch(0,1);
+ pageLayout->setRowStretch(1,0);
+
+ // add back/exit button
+ btnBack = formattedButton(":/res/Exit.png", true);
+ pageLayout->addWidget(btnBack, 1, 0, 1, 1, Qt::AlignLeft | Qt::AlignBottom);
+
+ // add body layout as defined by the subclass
+ pageLayout->addLayout(bodyLayoutDefinition(), 0, 0, 1, 2);
+
+ // add footer layout
+ QLayout * fld = footerLayoutDefinition();
+ if (fld != NULL)
+ pageLayout->addLayout(fld, 1, 1);
+
+ // connect signals
+ connect(btnBack, SIGNAL(clicked()), this, SIGNAL(goBack()));
+ connectSignals();
+}
+
+QPushButton * AbstractPage::formattedButton(const QString & btname, bool hasIcon)
+{
+ QPushButton * btn = new QPushButton(this);
+
+ if (hasIcon)
+ {
+ const QIcon& lp=QIcon(btname);
+ QSize sz = lp.actualSize(QSize(65535, 65535));
+ btn->setIcon(lp);
+ btn->setFixedSize(sz);
+ btn->setIconSize(sz);
+ btn->setFlat(true);
+ btn->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ }
+ else
+ {
+ btn->setFont(*font14);
+ btn->setText(btname);
+ }
+ return btn;
+}
+
+QPushButton * AbstractPage::addButton(const QString & btname, QGridLayout* grid, int wy, int wx, bool hasIcon)
+{
+ QPushButton * btn = formattedButton(btname, hasIcon);
+ grid->addWidget(btn, wy, wx);
+ return btn;
+}
+
+QPushButton * AbstractPage::addButton(const QString & btname, QGridLayout* grid, int wy, int wx, int rowSpan, int columnSpan, bool hasIcon)
+{
+ QPushButton * btn = formattedButton(btname, hasIcon);
+ grid->addWidget(btn, wy, wx, rowSpan, columnSpan);
+ return btn;
+}
+
+QPushButton * AbstractPage::addButton(const QString & btname, QBoxLayout* box, int where, bool hasIcon)
+{
+ QPushButton * btn = formattedButton(btname, hasIcon);
+ box->addWidget(btn, where);
+ return btn;
+}
+
+void AbstractPage::setBackButtonVisible(bool visible)
+{
+ btnBack->setVisible(visible);
+}
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/AbstractPage.h
--- a/QTfrontend/AbstractPage.h Sat Oct 08 16:45:52 2011 +0200
+++ b/QTfrontend/AbstractPage.h Sat Oct 08 16:54:56 2011 +0200
@@ -45,78 +45,51 @@
class QAbstractItemModel;
class QSettings;
class QSlider;
+class QGridlayout;
class AbstractPage : public QWidget
{
Q_OBJECT
- public:
+ signals:
+ void goBack();
- protected:
- AbstractPage(QWidget* parent = 0) {
- Q_UNUSED(parent);
-
- font14 = new QFont("MS Shell Dlg", 14);
- //setFocusPolicy(Qt::StrongFocus);
- }
- virtual ~AbstractPage() {};
+ protected:
+ // constructor and virtual destructor
+ AbstractPage(QWidget * parent = 0);
- QPushButton* addButton(QString btname, QGridLayout* grid, int wy, int wx, bool iconed = false) {
- QPushButton* butt = new QPushButton(this);
- if (!iconed) {
- butt->setFont(*font14);
- butt->setText(btname);
- //butt->setStyleSheet("background-color: #0d0544");
- } else {
- const QIcon& lp=QIcon(btname);
- QSize sz = lp.actualSize(QSize(65535, 65535));
- butt->setIcon(lp);
- butt->setFixedSize(sz);
- butt->setIconSize(sz);
- butt->setFlat(true);
- butt->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
- }
- grid->addWidget(butt, wy, wx);
- return butt;
- };
+ // call this in the constructor of your subclass
+ void initPage();
+
+ // the following methods are used during page construction
+
+ // you MUST implement this method in your subclass
+ // only define layout, not behavior in here
+ virtual QLayout * bodyLayoutDefinition() = 0;
+
+ // you CAN implement this method in your subclass
+ virtual QLayout * footerLayoutDefinition() { return NULL; };
- QPushButton* addButton(QString btname, QGridLayout* grid, int wy, int wx, int rowSpan, int columnSpan, bool iconed = false) {
- QPushButton* butt = new QPushButton(this);
- if (!iconed) {
- butt->setFont(*font14);
- butt->setText(btname);
- } else {
- const QIcon& lp=QIcon(btname);
- QSize sz = lp.actualSize(QSize(65535, 65535));
- butt->setIcon(lp);
- butt->setFixedSize(sz);
- butt->setIconSize(sz);
- butt->setFlat(true);
- butt->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
- }
- grid->addWidget(butt, wy, wx, rowSpan, columnSpan);
- return butt;
- };
+ // you CAN but most likely want to implement this method in your subclass
+ // keep in mind not to expose twidgets as public!
+ // instead define a signal with a meaningful name and connect the widget
+ // signals to your page signals
+ virtual void connectSignals() {};
+
+ virtual ~AbstractPage() {};
- QPushButton* addButton(QString btname, QBoxLayout* box, int where, bool iconed = false) {
- QPushButton* butt = new QPushButton(this);
- if (!iconed) {
- butt->setFont(*font14);
- butt->setText(btname);
- } else {
- const QIcon& lp=QIcon(btname);
- QSize sz = lp.actualSize(QSize(65535, 65535));
- butt->setIcon(lp);
- butt->setFixedSize(sz);
- butt->setIconSize(sz);
- butt->setFlat(true);
- butt->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
- }
- box->addWidget(butt, where);
- return butt;
- };
+ QPushButton * formattedButton(const QString & btname, bool hasIcon = false);
+ QPushButton * addButton(const QString & btname, QGridLayout * grid, int wy, int wx, bool hasIcon = false);
+ QPushButton * addButton(const QString & btname, QGridLayout * grid, int wy, int wx, int rowSpan, int columnSpan, bool hasIcon = false);
+ QPushButton * addButton(const QString & btname, QBoxLayout * box, int where, bool hasIcon = false);
- QFont * font14;
+ void setBackButtonVisible(bool visible = true);
+
+ QFont * font14;
+
+ private:
+
+ QPushButton * btnBack;
};
#endif
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/CMakeLists.txt
--- a/QTfrontend/CMakeLists.txt Sat Oct 08 16:45:52 2011 +0200
+++ b/QTfrontend/CMakeLists.txt Sat Oct 08 16:54:56 2011 +0200
@@ -1,5 +1,6 @@
# Configure for Qt4
set(QT_MIN_VERSION "4.5.0")
+include(CheckLibraryExists)
set(QT_USE_QTCORE TRUE)
set(QT_USE_QTGUI TRUE)
@@ -12,11 +13,28 @@
find_package(Qt4 REQUIRED)
include(${QT_USE_FILE})
+# Check if we need zlib
+check_library_exists(${QT_QTCORE_LIBRARY} inflateInit2_ ${QT_LIBRARY_DIR} QT_PROVIDES_ZLIB_FUNCTIONS)
+
+if(NOT QT_PROVIDES_ZLIB_FUNCTIONS)
+ find_package(ZLIB REQUIRED)
+
+ set(HW_LINK_LIBS ${ZLIB_LIBRARIES} ${HW_LINK_LIBS})
+endif()
+
+
# Configure for SDL
find_package(SDL REQUIRED)
find_package(SDL_mixer REQUIRED)
include_directories(.)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/model)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/net)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ui)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ui/dialog)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ui/page)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ui/widget)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/util)
include_directories(${SDL_INCLUDE_DIR})
include_directories(${SDLMIXER_INCLUDE_DIR})
include_directories(${CMAKE_SOURCE_DIR}/misc/quazip)
@@ -46,76 +64,30 @@
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/hwconsts.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/hwconsts.cpp)
+file(GLOB NetCpp net/*.cpp)
+file(GLOB ModelCpp model/*.cpp)
+file(GLOB_RECURSE UIcpp ui/*.cpp)
+file(GLOB UtilCpp util/*.cpp)
+
set(hwfr_src
- HWApplication.cpp
+ ${ModelCpp}
+ ${NetCpp}
+ ${UIcpp}
+ ${UtilCpp}
+ AbstractPage.cpp
+ achievements.cpp
+ binds.cpp
+ drawmapscene.cpp
game.cpp
+ gameuiconfig.cpp
+ HWApplication.cpp
+ hwform.cpp
main.cpp
- hwform.cpp
+ mapContainer.cpp
+ SDLs.cpp
team.cpp
- namegen.cpp
- teamselect.cpp
- teamselhelper.cpp
- frameTeam.cpp
- vertScrollArea.cpp
- gameuiconfig.cpp
ui_hwform.cpp
- gamecfgwidget.cpp
- pagemain.cpp
- pageeditteam.cpp
- pagemultiplayer.cpp
- pageoptions.cpp
- pagenet.cpp
- pagenetserver.cpp
- pagenetgame.cpp
- pageinfo.cpp
- pagedata.cpp
- pagesingleplayer.cpp
- pagetraining.cpp
- pagecampaign.cpp
- pageselectweapon.cpp
- pageingame.cpp
- pageroomslist.cpp
- pageconnecting.cpp
- pagescheme.cpp
- pagegamestats.cpp
- pageplayrecord.cpp
- pageadmin.cpp
- pagenettype.cpp
- pagedrawmap.cpp
- SquareLabel.cpp
- hats.cpp
- hedgehogerWidget.cpp
- hwmap.cpp
- mapContainer.cpp
- tcpBase.cpp
- about.cpp
- proto.cpp
- fpsedit.cpp
- netserver.cpp
- newnetclient.cpp
- netudpserver.cpp
- netudpwidget.cpp
- netregister.cpp
- netserverslist.cpp
- chatwidget.cpp
- binds.cpp
- SDLs.cpp
${CMAKE_CURRENT_BINARY_DIR}/hwconsts.cpp
- selectWeapon.cpp
- itemNum.cpp
- input_ip.cpp
- igbox.cpp
- weaponItem.cpp
- misc.cpp
- ammoSchemeModel.cpp
- togglebutton.cpp
- bgwidget.cpp
- achievements.cpp
- qaspectratiolayout.cpp
- drawmapwidget.cpp
- drawmapscene.cpp
- themesmodel.cpp
- databrowser.cpp
)
#xfire integration
@@ -134,77 +106,35 @@
set(hwfr_src ${hwfr_src} hedgewars.rc)
endif(MINGW)
+file(GLOB ModelHdr model/*.h)
+file(GLOB NetHdr net/*.h)
+file(GLOB_RECURSE UIhdr ui/*.h)
+file(GLOB UtilHdr util/*.h)
+
+
set(hwfr_moc_hdrs
- HWApplication.h
- game.h
- hats.h
- hwform.h
- teamselect.h
- teamselhelper.h
- frameTeam.h
- vertScrollArea.h
- gameuiconfig.h
- gamecfgwidget.h
+ ${ModelHdr}
+ ${NetHdr}
+ ${UIhdr}
AbstractPage.h
- pagenet.h
- pagemultiplayer.h
- pagenetserver.h
- pageingame.h
- pagetraining.h
- pageeditteam.h
- pageoptions.h
- pagemain.h
- pageinfo.h
- pagedata.h
- pagesingleplayer.h
- pagenettype.h
- pageconnecting.h
- pagedrawmap.h
- pagecampaign.h
- pagenetgame.h
- pageroomslist.h
- pagegamestats.h
- pageadmin.h
- pagescheme.h
- pageselectweapon.h
- pageplayrecord.h
- SquareLabel.h
- hedgehogerWidget.h
- hwmap.h
+ drawmapscene.h
+ game.h
+ gameuiconfig.h
+ HWApplication.h
+ hwform.h
mapContainer.h
- tcpBase.h
- about.h
- proto.h
- fpsedit.h
- netserver.h
- newnetclient.h
- netudpserver.h
- netudpwidget.h
- netregister.h
- netserverslist.h
- chatwidget.h
SDLs.h
- selectWeapon.h
- itemNum.h
- input_ip.h
- igbox.h
- weaponItem.h
- misc.h
- ammoSchemeModel.h
- togglebutton.h
- bgwidget.h
- qaspectratiolayout.h
- drawmapwidget.h
- drawmapscene.h
- themesmodel.h
- databrowser.h
)
set(hwfr_hdrs
+ ${UtilHdr}
+ team.h
+ achievements.h
binds.h
ui_hwform.h
KB.h
hwconsts.h
+ sdlkeys.h
)
set(hwfr_rez hedgewars.qrc)
@@ -216,7 +146,7 @@
if(APPLE)
set(hwfr_src ${hwfr_src} InstallController.cpp CocoaInitializer.mm M3Panel.mm M3InstallController.m NSWorkspace_RBAdditions.m)
- set(HW_LINK_LIBS IOKit)
+ set(HW_LINK_LIBS IOKit ${HW_LINK_LIBS})
if(NOT NOAUTOUPDATE)
find_package(Sparkle)
@@ -260,7 +190,7 @@
endif()
-target_link_libraries(hedgewars ${HW_LINK_LIBS})
+target_link_libraries(hedgewars ${HW_LINK_LIBS})
install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/hedgewars${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION ${target_dir})
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/SquareLabel.cpp
--- a/QTfrontend/SquareLabel.cpp Sat Oct 08 16:45:52 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2006-2011 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"
-#include "hwform.h"
-
-SquareLabel::SquareLabel(QWidget * parent) :
- QWidget(parent)
-{
- if(frontendEffects) setAttribute(Qt::WA_PaintOnScreen, true);
-}
-
-void SquareLabel::paintEvent(QPaintEvent * event)
-{
- Q_UNUSED(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));
-}
-
-void SquareLabel::setPixmap(const QPixmap & pixmap)
-{
- this->pixmap = pixmap;
- repaint();
-}
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/SquareLabel.h
--- a/QTfrontend/SquareLabel.h Sat Oct 08 16:45:52 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2006-2011 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
-#include
-
-class SquareLabel : public QWidget
-{
- Q_OBJECT
-
-public:
- SquareLabel(QWidget * parent = 0);
-
- void setPixmap(const QPixmap & pixmap);
-protected:
- virtual void paintEvent(QPaintEvent * event);
-
-private:
- QPixmap pixmap;
-
-};
-
-#endif // _SQUARELABEL_H
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/about.cpp
--- a/QTfrontend/about.cpp Sat Oct 08 16:45:52 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,146 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2006-2011 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 "about.h"
-#include "hwconsts.h"
-
-About::About(QWidget * parent) :
- QWidget(parent)
-{
- QGridLayout *mainLayout = new QGridLayout(this);
-
- QLabel *imageLabel = new QLabel;
- QImage image(":/res/Hedgehog.png");
- imageLabel->setPixmap(QPixmap::fromImage(image));
- imageLabel->setScaledContents(true);
- imageLabel->setMinimumWidth(2.8);
- imageLabel->setMaximumWidth(280);
- imageLabel->setMinimumHeight(30);
- imageLabel->setMaximumHeight(300);
-
- mainLayout->addWidget(imageLabel, 0, 0, 2, 1);
-
- QLabel *lbl1 = new QLabel(this);
- lbl1->setOpenExternalLinks(true);
- lbl1->setText(
- ""
- "Hedgewars
"
- "
" + QLabel::tr("Version") + " " + *cVersionString + "
"
- "
http://www.hedgewars.org/
" +
- QLabel::tr("This program is distributed under the GNU General Public License") +
- "
"
- );
- lbl1->setWordWrap(true);
- mainLayout->addWidget(lbl1, 0, 1);
-
- QTextBrowser *lbl2 = new QTextBrowser(this);
-
- lbl2->setOpenExternalLinks(true);
- lbl2->setText(
- "" +
- QString("") +
- QLabel::tr("Developers:") +
- "
"
- "Engine, frontend, net server: Andrey Korotaev <unC0Rr@gmail.com>
"
- "Many frontend improvements: Igor Ulyanov <disinbox@gmail.com>
"
- "Many engine and frontend improvements: Derek Pomery <nemo@m8y.org>
"
- "Drill rocket, Ballgun, RC Plane weapons: Martin Boze <afffect@gmail.com>
"
- "Mine number and time game settings: David A. Cuadrado <krawek@gmail.com>
"
- "Frontend improvements: Martin Minarik <ttsmj@pokec.sk>
"
- "Frontend improvements: Kristian Lehmann <email@thexception.net>
"
- "Mac OS X/iPhone port, OpenGL-ES conversion: Vittorio Giovara <vittorio.giovara@gmail.com>
"
- "Gamepad and Lua integration: Mario Liebisch <mario.liebisch@gmail.com>
"
- "Many engine improvements and graphics: Carlos Vives <mail@carlosvives.es>
"
- "Few engine and frontend improvements: Richard Karolyi <sheepluva@ercatec.net>
"
- "Maze maps: Henning Kühn <prg@cooco.de>
"
- "Engine and frontend improvements: Henrik Rostedt <henrik.rostedt@gmail.com>
"
- "Lua game modes and missions: John Lambert <redgrinner@gmail.com>
"
- "Frontend improvements: Mayur Pawashe <zorgiepoo@gmail.com>
"
- "Android port: Richard Deurwaarder <xeli@xelification.com>
"
- "
" +
-
- QLabel::tr("Art:") + "
"
- + QString::fromUtf8(
- "John Dum <fizzy@gmail.com>"
- "
"
- "Joshua Frese <joshfrese@gmail.com>"
- "
"
- "Stanko Tadić <stanko@mfhinc.net>"
- "
"
- "Julien Koesten <julienkoesten@aol.com>"
- "
"
- "Joshua O'Sullivan <coheedftw@hotmail.co.uk>"
- "
"
- "Nils Lück <nils.luck.design@gmail.com>"
- "
"
- "Guillaume Englert <genglert@hybird.org>"
- "
"
- "Hats: Trey Perry <tx.perry.j@gmail.com>"
- "
") +
- QLabel::tr("Sounds:") + "
"
- "Hedgehogs voice: Stephen Alexander <ArmagonNo1@gmail.com>"
- "
"
- "John Dum <fizzy@gmail.com>"
- "
"
- "Jonatan Nilsson <jonatanfan@gmail.com>"
- "
"
- "Daniel Martin <elhombresinremedio@gmail.com>"
- "
" +
-
- QLabel::tr("Translations:") + "
"
- + QString::fromUtf8(
- "Brazilian Portuguese: Romulo Fernandes Machado <abra185@gmail.com>
"
- "Bulgarian: Svetoslav Stefanov
"
- "Czech: Petr Řezáček <rezacek@gmail.com>
"
- "Chinese: Jie Luo <lililjlj@gmail.com>
"
- "English: Andrey Korotaev <unC0Rr@gmail.com>
"
- "Finnish: Nina Kuisma <ninnnu@gmail.com>
"
- "French: Antoine Turmel <geekshadow@gmail.com>
"
- "German: Peter Hüwe <PeterHuewe@gmx.de>, Mario Liebisch <mario.liebisch@gmail.com>
"
- "Greek: <talos_kriti@yahoo.gr>"
- "Italian: Luca Bonora <bonora.luca@gmail.com>
"
- "Japanese: ADAM Etienne <etienne.adam@gmail.com>
"
- "Korean: Anthony Bellew <webmaster@anthonybellew.com>
"
- "Lithuanian: Lukas Urbonas <lukasu08@gmail.com>
"
- "Polish: Maciej Mroziński <mynick2@o2.pl>, Wojciech Latkowski <magik17l@gmail.com>, Piotr Mitana, Maciej Górny
"
- "Portuguese: Fábio Canário <inufabie@gmail.com>
"
- "Russian: Andrey Korotaev <unC0Rr@gmail.com>
"
- "Slovak: Jose Riha
"
- "Spanish: Carlos Vives <mail@carlosvives.es>
"
- "Swedish: Niklas Grahn <raewolusjoon@yaoo.com>, Henrik Rostedt <henrik.rostedt@gmail.com>
"
- "Ukrainian: Eugene V. Lyubimkin <jackyf.devel@gmail.com>, Igor Paliychuk <mansonigor@gmail.com>, Eugene Sakara <eresid@gmail.com>"
- "
") +
-
- QLabel::tr("Special thanks:") + "
"
- "Aleksey Andreev <blaknayabr@gmail.com>
"
- "Aleksander Rudalev <alexv@pomorsu.ru>
"
- "Natasha Korotaeva <layout@pisem.net>
"
- "Adam Higerd (aka ahigerd at FreeNode)"
- "
"
- );
- mainLayout->addWidget(lbl2, 1, 1);
-}
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/about.h
--- a/QTfrontend/about.h Sat Oct 08 16:45:52 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2006-2011 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 _ABOUT_H
-#define _ABOUT_H
-
-#include
-
-
-class About : public QWidget
-{
- Q_OBJECT
-
-public:
- About(QWidget * parent = 0);
-};
-
-#endif // _ABOUT_H
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/ammoSchemeModel.cpp
--- a/QTfrontend/ammoSchemeModel.cpp Sat Oct 08 16:45:52 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,786 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2005-2011 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 "ammoSchemeModel.h"
-#include "hwconsts.h"
-
-QList defaultScheme = QList()
- << QVariant("Default") // name 0
- << QVariant(false) // fortsmode 1
- << QVariant(false) // team divide 2
- << QVariant(false) // solid land 3
- << QVariant(false) // border 4
- << QVariant(false) // low gravity 5
- << QVariant(false) // laser sight 6
- << QVariant(false) // invulnerable 7
- << QVariant(false) // reset health 8
- << QVariant(false) // vampiric 9
- << QVariant(false) // karma 10
- << QVariant(false) // artillery 11
- << QVariant(true) // random order 12
- << QVariant(false) // king 13
- << QVariant(false) // place hog 14
- << QVariant(false) // shared ammo 15
- << QVariant(false) // disable girders 16
- << QVariant(false) // disable land objects 17
- << QVariant(false) // AI survival 18
- << QVariant(false) // inf. attack 19
- << QVariant(false) // reset weps 20
- << QVariant(false) // per hog ammo 21
- << QVariant(false) // no wind 22
- << QVariant(false) // more wind 23
- << QVariant(false) // tag team 24
- << QVariant(false) // bottom border 25
- << QVariant(100) // damage modfier 26
- << QVariant(45) // turn time 27
- << QVariant(100) // init health 28
- << QVariant(15) // sudden death 29
- << QVariant(5) // case prob 30
- << QVariant(3) // mines time 31
- << QVariant(4) // mines number 32
- << QVariant(0) // mine dud pct 33
- << QVariant(2) // explosives 34
- << QVariant(35) // health case pct 35
- << QVariant(25) // health case amt 36
- << QVariant(47) // water rise amt 37
- << QVariant(5) // health dec amt 38
- << QVariant(100) // rope modfier 39
- << QVariant(100) // get away time 40
- ;
-
-AmmoSchemeModel::AmmoSchemeModel(QObject* parent, const QString & fileName) :
- QAbstractTableModel(parent),
- fileConfig(fileName, QSettings::IniFormat)
-{
- predefSchemesNames = QStringList()
- << "Default"
- << "Pro Mode"
- << "Shoppa"
- << "Clean Slate"
- << "Minefield"
- << "Barrel Mayhem"
- << "Tunnel Hogs"
- << "Fort Mode"
- << "Timeless"
- << "Thinking with Portals"
- << "King Mode"
- ;
-
- numberOfDefaultSchemes = predefSchemesNames.size();
-
- spNames = QStringList()
- << "name" // 0
- << "fortsmode" // 1
- << "divteams" // 2
- << "solidland" // 3
- << "border" // 4
- << "lowgrav" // 5
- << "laser" // 6
- << "invulnerability" // 7
- << "resethealth" // 8
- << "vampiric" // 9
- << "karma" // 10
- << "artillery" // 11
- << "randomorder" // 12
- << "king" // 13
- << "placehog" // 14
- << "sharedammo" // 15
- << "disablegirders" // 16
- << "disablelandobjects" // 17
- << "aisurvival" // 18
- << "infattack" // 19
- << "resetweps" // 20
- << "perhogammo" // 21
- << "disablewind" // 22
- << "morewind" // 23
- << "tagteam" // 24
- << "bottomborder" // 25
- << "damagefactor" // 26
- << "turntime" // 27
- << "health" // 28
- << "suddendeath" // 29
- << "caseprobability" // 30
- << "minestime" // 31
- << "minesnum" // 32
- << "minedudpct" // 33
- << "explosives" // 34
- << "healthprobability" // 35
- << "healthcaseamount" // 36
- << "waterrise" // 37
- << "healthdecrease" // 38
- << "ropepct" // 39
- << "getawaytime" // 40
- ;
-
- QList proMode;
- proMode
- << predefSchemesNames[1] // name 0
- << QVariant(false) // fortsmode 1
- << QVariant(false) // team divide 2
- << QVariant(false) // solid land 3
- << QVariant(false) // border 4
- << QVariant(false) // low gravity 5
- << QVariant(false) // laser sight 6
- << QVariant(false) // invulnerable 7
- << QVariant(false) // reset health 8
- << QVariant(false) // vampiric 9
- << QVariant(false) // karma 10
- << QVariant(false) // artillery 11
- << QVariant(true) // random order 12
- << QVariant(false) // king 13
- << QVariant(false) // place hog 14
- << QVariant(true) // shared ammo 15
- << QVariant(false) // disable girders 16
- << QVariant(false) // disable land objects 17
- << QVariant(false) // AI survival 18
- << QVariant(false) // inf. attack 19
- << QVariant(false) // reset weps 20
- << QVariant(false) // per hog ammo 21
- << QVariant(false) // no wind 22
- << QVariant(false) // more wind 23
- << QVariant(false) // tag team 24
- << QVariant(false) // bottom border 25
- << QVariant(100) // damage modfier 26
- << QVariant(15) // turn time 27
- << QVariant(100) // init health 28
- << QVariant(15) // sudden death 29
- << QVariant(0) // case prob 30
- << QVariant(3) // mines time 31
- << QVariant(0) // mines number 32
- << QVariant(0) // mine dud pct 33
- << QVariant(2) // explosives 34
- << QVariant(35) // health case pct 35
- << QVariant(25) // health case amt 36
- << QVariant(47) // water rise amt 37
- << QVariant(5) // health dec amt 38
- << QVariant(100) // rope modfier 39
- << QVariant(100) // get away time 40
- ;
-
- QList shoppa;
- shoppa
- << predefSchemesNames[2] // name 0
- << QVariant(false) // fortsmode 1
- << QVariant(false) // team divide 2
- << QVariant(true) // solid land 3
- << QVariant(true) // border 4
- << QVariant(false) // low gravity 5
- << QVariant(false) // laser sight 6
- << QVariant(false) // invulnerable 7
- << QVariant(false) // reset health 8
- << QVariant(false) // vampiric 9
- << QVariant(false) // karma 10
- << QVariant(false) // artillery 11
- << QVariant(true) // random order 12
- << QVariant(false) // king 13
- << QVariant(false) // place hog 14
- << QVariant(true) // shared ammo 15
- << QVariant(true) // disable girders 16
- << QVariant(false) // disable land objects 17
- << QVariant(false) // AI survival 18
- << QVariant(false) // inf. attack 19
- << QVariant(true) // reset weps 20
- << QVariant(false) // per hog ammo 21
- << QVariant(false) // no wind 22
- << QVariant(false) // more wind 23
- << QVariant(false) // tag team 24
- << QVariant(false) // bottom border 25
- << QVariant(100) // damage modfier 26
- << QVariant(30) // turn time 27
- << QVariant(100) // init health 28
- << QVariant(50) // sudden death 29
- << QVariant(1) // case prob 30
- << QVariant(3) // mines time 31
- << QVariant(0) // mines number 32
- << QVariant(0) // mine dud pct 33
- << QVariant(0) // explosives 34
- << QVariant(0) // health case pct 35
- << QVariant(25) // health case amt 36
- << QVariant(47) // water rise amt 37
- << QVariant(5) // health dec amt 38
- << QVariant(100) // rope modfier 39
- << QVariant(100) // get away time 40
- ;
-
- QList cleanslate;
- cleanslate
- << predefSchemesNames[3] // name 0
- << QVariant(false) // fortsmode 1
- << QVariant(false) // team divide 2
- << QVariant(false) // solid land 3
- << QVariant(false) // border 4
- << QVariant(false) // low gravity 5
- << QVariant(false) // laser sight 6
- << QVariant(false) // invulnerable 7
- << QVariant(true) // reset health 8
- << QVariant(false) // vampiric 9
- << QVariant(false) // karma 10
- << QVariant(false) // artillery 11
- << QVariant(true) // random order 12
- << QVariant(false) // king 13
- << QVariant(false) // place hog 14
- << QVariant(false) // shared ammo 15
- << QVariant(false) // disable girders 16
- << QVariant(false) // disable land objects 17
- << QVariant(false) // AI survival 18
- << QVariant(true) // inf. attack 19
- << QVariant(true) // reset weps 20
- << QVariant(false) // per hog ammo 21
- << QVariant(false) // no wind 22
- << QVariant(false) // more wind 23
- << QVariant(false) // tag team 24
- << QVariant(false) // bottom border 25
- << QVariant(100) // damage modfier 26
- << QVariant(45) // turn time 27
- << QVariant(100) // init health 28
- << QVariant(15) // sudden death 29
- << QVariant(5) // case prob 30
- << QVariant(3) // mines time 31
- << QVariant(4) // mines number 32
- << QVariant(0) // mine dud pct 33
- << QVariant(2) // explosives 34
- << QVariant(35) // health case pct 35
- << QVariant(25) // health case amt 36
- << QVariant(47) // water rise amt 37
- << QVariant(5) // health dec amt 38
- << QVariant(100) // rope modfier 39
- << QVariant(100) // get away time 40
- ;
-
- QList minefield;
- minefield
- << predefSchemesNames[4] // name 0
- << QVariant(false) // fortsmode 1
- << QVariant(false) // team divide 2
- << QVariant(false) // solid land 3
- << QVariant(false) // border 4
- << QVariant(false) // low gravity 5
- << QVariant(false) // laser sight 6
- << QVariant(false) // invulnerable 7
- << QVariant(false) // reset health 8
- << QVariant(false) // vampiric 9
- << QVariant(false) // karma 10
- << QVariant(false) // artillery 11
- << QVariant(true) // random order 12
- << QVariant(false) // king 13
- << QVariant(false) // place hog 14
- << QVariant(true) // shared ammo 15
- << QVariant(true) // disable girders 16
- << QVariant(false) // disable land objects 17
- << QVariant(false) // AI survival 18
- << QVariant(false) // inf. attack 19
- << QVariant(false) // reset weps 20
- << QVariant(false) // per hog ammo 21
- << QVariant(false) // no wind 22
- << QVariant(false) // more wind 23
- << QVariant(false) // tag team 24
- << QVariant(false) // bottom border 25
- << QVariant(100) // damage modfier 26
- << QVariant(30) // turn time 27
- << QVariant(50) // init health 28
- << QVariant(15) // sudden death 29
- << QVariant(0) // case prob 30
- << QVariant(0) // mines time 31
- << QVariant(80) // mines number 32
- << QVariant(0) // mine dud pct 33
- << QVariant(0) // explosives 34
- << QVariant(35) // health case pct 35
- << QVariant(25) // health case amt 36
- << QVariant(47) // water rise amt 37
- << QVariant(5) // health dec amt 38
- << QVariant(100) // rope modfier 39
- << QVariant(100) // get away time 40
- ;
-
- QList barrelmayhem;
- barrelmayhem
- << predefSchemesNames[5] // name 0
- << QVariant(false) // fortsmode 1
- << QVariant(false) // team divide 2
- << QVariant(false) // solid land 3
- << QVariant(false) // border 4
- << QVariant(false) // low gravity 5
- << QVariant(false) // laser sight 6
- << QVariant(false) // invulnerable 7
- << QVariant(false) // reset health 8
- << QVariant(false) // vampiric 9
- << QVariant(false) // karma 10
- << QVariant(false) // artillery 11
- << QVariant(true) // random order 12
- << QVariant(false) // king 13
- << QVariant(false) // place hog 14
- << QVariant(true) // shared ammo 15
- << QVariant(false) // disable girders 16
- << QVariant(false) // disable land objects 17
- << QVariant(false) // AI survival 18
- << QVariant(false) // inf. attack 19
- << QVariant(false) // reset weps 20
- << QVariant(false) // per hog ammo 21
- << QVariant(false) // no wind 22
- << QVariant(false) // more wind 23
- << QVariant(false) // tag team 24
- << QVariant(false) // bottom border 25
- << QVariant(100) // damage modfier 26
- << QVariant(30) // turn time 27
- << QVariant(100) // init health 28
- << QVariant(15) // sudden death 29
- << QVariant(0) // case prob 30
- << QVariant(0) // mines time 31
- << QVariant(0) // mines number 32
- << QVariant(0) // mine dud pct 33
- << QVariant(80) // explosives 34
- << QVariant(35) // health case pct 35
- << QVariant(25) // health case amt 36
- << QVariant(47) // water rise amt 37
- << QVariant(5) // health dec amt 38
- << QVariant(100) // rope modfier 39
- << QVariant(100) // get away time 40
- ;
-
- QList tunnelhogs;
- tunnelhogs
- << predefSchemesNames[6] // name 0
- << QVariant(false) // fortsmode 1
- << QVariant(false) // team divide 2
- << QVariant(false) // solid land 3
- << QVariant(true) // border 4
- << QVariant(false) // low gravity 5
- << QVariant(false) // laser sight 6
- << QVariant(false) // invulnerable 7
- << QVariant(false) // reset health 8
- << QVariant(false) // vampiric 9
- << QVariant(false) // karma 10
- << QVariant(false) // artillery 11
- << QVariant(true) // random order 12
- << QVariant(false) // king 13
- << QVariant(false) // place hog 14
- << QVariant(true) // shared ammo 15
- << QVariant(true) // disable girders 16
- << QVariant(true) // disable land objects 17
- << QVariant(false) // AI survival 18
- << QVariant(false) // inf. attack 19
- << QVariant(false) // reset weps 20
- << QVariant(false) // per hog ammo 21
- << QVariant(false) // no wind 22
- << QVariant(false) // more wind 23
- << QVariant(false) // tag team 24
- << QVariant(false) // bottom border 25
- << QVariant(100) // damage modfier 26
- << QVariant(30) // turn time 27
- << QVariant(100) // init health 28
- << QVariant(15) // sudden death 29
- << QVariant(5) // case prob 30
- << QVariant(3) // mines time 31
- << QVariant(10) // mines number 32
- << QVariant(10) // mine dud pct 33
- << QVariant(10) // explosives 34
- << QVariant(35) // health case pct 35
- << QVariant(25) // health case amt 36
- << QVariant(47) // water rise amt 37
- << QVariant(5) // health dec amt 38
- << QVariant(100) // rope modfier 39
- << QVariant(100) // get away time 40
- ;
-
- QList forts;
- forts
- << predefSchemesNames[7] // name 0
- << QVariant(true) // fortsmode 1
- << QVariant(true) // team divide 2
- << QVariant(false) // solid land 3
- << QVariant(false) // border 4
- << QVariant(true) // low gravity 5
- << QVariant(false) // laser sight 6
- << QVariant(false) // invulnerable 7
- << QVariant(false) // reset health 8
- << QVariant(false) // vampiric 9
- << QVariant(false) // karma 10
- << QVariant(false) // artillery 11
- << QVariant(true) // random order 12
- << QVariant(false) // king 13
- << QVariant(false) // place hog 14
- << QVariant(false) // shared ammo 15
- << QVariant(false) // disable girders 16
- << QVariant(false) // disable land objects 17
- << QVariant(false) // AI survival 18
- << QVariant(false) // inf. attack 19
- << QVariant(false) // reset weps 20
- << QVariant(false) // per hog ammo 21
- << QVariant(false) // no wind 22
- << QVariant(false) // more wind 23
- << QVariant(false) // tag team 24
- << QVariant(false) // bottom border 25
- << QVariant(100) // damage modfier 26
- << QVariant(45) // turn time 27
- << QVariant(100) // init health 28
- << QVariant(15) // sudden death 29
- << QVariant(5) // case prob 30
- << QVariant(3) // mines time 31
- << QVariant(0) // mines number 32
- << QVariant(0) // mine dud pct 33
- << QVariant(0) // explosives 34
- << QVariant(35) // health case pct 35
- << QVariant(25) // health case amt 36
- << QVariant(47) // water rise amt 37
- << QVariant(5) // health dec amt 38
- << QVariant(100) // rope modfier 39
- << QVariant(100) // get away time 40
- ;
-
- QList timeless;
- timeless
- << predefSchemesNames[8] // name 0
- << QVariant(false) // fortsmode 1
- << QVariant(false) // team divide 2
- << QVariant(false) // solid land 3
- << QVariant(false) // border 4
- << QVariant(false) // low gravity 5
- << QVariant(false) // laser sight 6
- << QVariant(false) // invulnerable 7
- << QVariant(false) // reset health 8
- << QVariant(false) // vampiric 9
- << QVariant(false) // karma 10
- << QVariant(false) // artillery 11
- << QVariant(true) // random order 12
- << QVariant(false) // king 13
- << QVariant(false) // place hog 14
- << QVariant(false) // shared ammo 15
- << QVariant(false) // disable girders 16
- << QVariant(false) // disable land objects 17
- << QVariant(false) // AI survival 18
- << QVariant(false) // inf. attack 19
- << QVariant(false) // reset weps 20
- << QVariant(true) // per hog ammo 21
- << QVariant(false) // no wind 22
- << QVariant(false) // more wind 23
- << QVariant(false) // tag team 24
- << QVariant(false) // bottom border 25
- << QVariant(100) // damage modfier 26
- << QVariant(9999) // turn time 27
- << QVariant(100) // init health 28
- << QVariant(15) // sudden death 29
- << QVariant(5) // case prob 30
- << QVariant(3) // mines time 31
- << QVariant(5) // mines number 32
- << QVariant(10) // mine dud pct 33
- << QVariant(2) // explosives 34
- << QVariant(35) // health case pct 35
- << QVariant(30) // health case amt 36
- << QVariant(0) // water rise amt 37
- << QVariant(0) // health dec amt 38
- << QVariant(100) // rope modfier 39
- << QVariant(100) // get away time 40
- ;
-
- QList thinkingportals;
- thinkingportals
- << predefSchemesNames[9] // name 0
- << QVariant(false) // fortsmode 1
- << QVariant(false) // team divide 2
- << QVariant(false) // solid land 3
- << QVariant(false) // border 4
- << QVariant(false) // low gravity 5
- << QVariant(false) // laser sight 6
- << QVariant(false) // invulnerable 7
- << QVariant(false) // reset health 8
- << QVariant(false) // vampiric 9
- << QVariant(false) // karma 10
- << QVariant(true) // artillery 11
- << QVariant(true) // random order 12
- << QVariant(false) // king 13
- << QVariant(false) // place hog 14
- << QVariant(false) // shared ammo 15
- << QVariant(false) // disable girders 16
- << QVariant(false) // disable land objects 17
- << QVariant(false) // AI survival 18
- << QVariant(false) // inf. attack 19
- << QVariant(false) // reset weps 20
- << QVariant(false) // per hog ammo 21
- << QVariant(false) // no wind 22
- << QVariant(false) // more wind 23
- << QVariant(false) // tag team 24
- << QVariant(false) // bottom border 25
- << QVariant(100) // damage modfier 26
- << QVariant(45) // turn time 27
- << QVariant(100) // init health 28
- << QVariant(15) // sudden death 29
- << QVariant(2) // case prob 30
- << QVariant(3) // mines time 31
- << QVariant(5) // mines number 32
- << QVariant(0) // mine dud pct 33
- << QVariant(5) // explosives 34
- << QVariant(25) // health case pct 35
- << QVariant(25) // health case amt 36
- << QVariant(47) // water rise amt 37
- << QVariant(5) // health dec amt 38
- << QVariant(100) // rope modfier 39
- << QVariant(100) // get away time 40
- ;
-
- QList kingmode;
- kingmode
- << predefSchemesNames[10] // name 0
- << QVariant(false) // fortsmode 1
- << QVariant(false) // team divide 2
- << QVariant(false) // solid land 3
- << QVariant(false) // border 4
- << QVariant(false) // low gravity 5
- << QVariant(false) // laser sight 6
- << QVariant(false) // invulnerable 7
- << QVariant(false) // reset health 8
- << QVariant(false) // vampiric 9
- << QVariant(false) // karma 10
- << QVariant(false) // artillery 11
- << QVariant(true) // random order 12
- << QVariant(true) // king 13
- << QVariant(false) // place hog 14
- << QVariant(false) // shared ammo 15
- << QVariant(false) // disable girders 16
- << QVariant(false) // disable land objects 17
- << QVariant(false) // AI survival 18
- << QVariant(false) // inf. attack 19
- << QVariant(false) // reset weps 20
- << QVariant(false) // per hog ammo 21
- << QVariant(false) // no wind 22
- << QVariant(false) // more wind 23
- << QVariant(false) // tag team 24
- << QVariant(false) // bottom border 25
- << QVariant(100) // damage modfier 26
- << QVariant(45) // turn time 27
- << QVariant(100) // init health 28
- << QVariant(15) // sudden death 29
- << QVariant(5) // case prob 30
- << QVariant(3) // mines time 31
- << QVariant(4) // mines number 32
- << QVariant(0) // mine dud pct 33
- << QVariant(2) // explosives 34
- << QVariant(35) // health case pct 35
- << QVariant(25) // health case amt 36
- << QVariant(47) // water rise amt 37
- << QVariant(5) // health dec amt 38
- << QVariant(100) // rope modfier 39
- << QVariant(100) // get away time 40
- ;
-
-
- schemes.append(defaultScheme);
- schemes.append(proMode);
- schemes.append(shoppa);
- schemes.append(cleanslate);
- schemes.append(minefield);
- schemes.append(barrelmayhem);
- schemes.append(tunnelhogs);
- schemes.append(forts);
- schemes.append(timeless);
- schemes.append(thinkingportals);
- schemes.append(kingmode);
-
-
- int size = fileConfig.beginReadArray("schemes");
- for (int i = 0; i < size; ++i) {
- fileConfig.setArrayIndex(i);
-
- if (!predefSchemesNames.contains(fileConfig.value(spNames[0]).toString()))
- {
- QList scheme;
-
- for (int k = 0; k < spNames.size(); ++k)
- scheme << fileConfig.value(spNames[k], defaultScheme[k]);
-
- schemes.append(scheme);
- }
- }
- fileConfig.endArray();
-}
-
-QVariant AmmoSchemeModel::headerData(int section, Qt::Orientation orientation, int role) const
-{
- Q_UNUSED(section);
- Q_UNUSED(orientation);
- Q_UNUSED(role);
-
- return QVariant();
-}
-
-int AmmoSchemeModel::rowCount(const QModelIndex &parent) const
-{
- if (parent.isValid())
- return 0;
- else
- return schemes.size();
-}
-
-int AmmoSchemeModel::columnCount(const QModelIndex & parent) const
-{
- if (parent.isValid())
- return 0;
- else
- return defaultScheme.size();
-}
-
-Qt::ItemFlags AmmoSchemeModel::flags(const QModelIndex & index) const
-{
- Q_UNUSED(index);
-
- return
- Qt::ItemIsEnabled
- | Qt::ItemIsSelectable
- | Qt::ItemIsEditable;
-}
-
-bool AmmoSchemeModel::setData(const QModelIndex & index, const QVariant & value, int role)
-{
- if (!index.isValid() || index.row() < numberOfDefaultSchemes
- || index.row() >= schemes.size()
- || index.column() >= defaultScheme.size()
- || role != Qt::EditRole)
- return false;
-
- schemes[index.row()][index.column()] = value;
-
- emit dataChanged(index, index);
- return true;
-}
-
-bool AmmoSchemeModel::insertRows(int row, int count, const QModelIndex & parent)
-{
- Q_UNUSED(count);
-
- beginInsertRows(parent, schemes.size(), schemes.size());
-
- if (row == -1)
- {
- QList newScheme = defaultScheme;
- newScheme[0] = QVariant(tr("new"));
- schemes.insert(schemes.size(), newScheme);
- }
- else
- {
- QList newScheme = schemes[row];
- newScheme[0] = QVariant(tr("copy of") + " " + newScheme[0].toString());
- schemes.insert(schemes.size(), newScheme);
- }
-
- endInsertRows();
-
- return true;
-}
-
-bool AmmoSchemeModel::removeRows(int row, int count, const QModelIndex & parent)
-{
- if(count != 1
- || row < numberOfDefaultSchemes
- || row >= schemes.size())
- return false;
-
- beginRemoveRows(parent, row, row);
-
- schemes.removeAt(row);
-
- endRemoveRows();
-
- return true;
-}
-
-QVariant AmmoSchemeModel::data(const QModelIndex &index, int role) const
-{
- if (!index.isValid() || index.row() < 0
- || index.row() >= schemes.size()
- || index.column() >= defaultScheme.size()
- || (role != Qt::EditRole && role != Qt::DisplayRole)
- )
- return QVariant();
-
- return schemes[index.row()][index.column()];
-}
-
-void AmmoSchemeModel::Save()
-{
- fileConfig.beginWriteArray("schemes", schemes.size() - numberOfDefaultSchemes);
-
- for (int i = 0; i < schemes.size() - numberOfDefaultSchemes; ++i) {
- fileConfig.setArrayIndex(i);
-
- QList scheme = schemes[i + numberOfDefaultSchemes];
-
- for (int k = 0; k < scheme.size(); ++k)
- fileConfig.setValue(spNames[k], scheme[k]);
- }
- fileConfig.endArray();
-}
-
-
-NetAmmoSchemeModel::NetAmmoSchemeModel(QObject * parent) :
- QAbstractTableModel(parent)
-{
- netScheme = defaultScheme;
-}
-
-QVariant NetAmmoSchemeModel::headerData(int section, Qt::Orientation orientation, int role) const
-{
- Q_UNUSED(section);
- Q_UNUSED(orientation);
- Q_UNUSED(role);
-
- return QVariant();
-}
-
-int NetAmmoSchemeModel::rowCount(const QModelIndex & parent) const
-{
- if (parent.isValid())
- return 0;
- else
- return 1;
-}
-
-int NetAmmoSchemeModel::columnCount(const QModelIndex & parent) const
-{
- if (parent.isValid())
- return 0;
- else
- return defaultScheme.size();
-}
-
-QVariant NetAmmoSchemeModel::data(const QModelIndex &index, int role) const
-{
- if (!index.isValid() || index.row() < 0
- || index.row() > 1
- || index.column() >= defaultScheme.size()
- || (role != Qt::EditRole && role != Qt::DisplayRole)
- )
- return QVariant();
-
- return netScheme[index.column()];
-}
-
-void NetAmmoSchemeModel::setNetSchemeConfig(QStringList & cfg)
-{
- if(cfg.size() != netScheme.size())
- {
- qWarning("Incorrect scheme cfg size");
- return;
- }
-
- for(int i = 0; i < cfg.size(); ++i)
- netScheme[i] = QVariant(cfg[i]);
-
- reset();
-}
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/ammoSchemeModel.h
--- a/QTfrontend/ammoSchemeModel.h Sat Oct 08 16:45:52 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2005-2011 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 _AMMO_SCHEME_MODEL_INCLUDED
-#define _AMMO_SCHEME_MODEL_INCLUDED
-
-#include
-#include
-#include
-#include
-
-class AmmoSchemeModel : public QAbstractTableModel
-{
- Q_OBJECT
-
-public:
- AmmoSchemeModel(QObject * parent, const QString & fileName);
-
- QVariant headerData(int section, Qt::Orientation orientation, int role) const;
- int rowCount(const QModelIndex & parent) const;
- int columnCount(const QModelIndex & parent) const;
- Qt::ItemFlags flags(const QModelIndex & index) const;
- bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);
- bool insertRows(int row, int count, const QModelIndex & parent = QModelIndex());
- bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex());
- QVariant data(const QModelIndex &index, int role) const;
-
- int numberOfDefaultSchemes;
- QStringList predefSchemesNames;
- QStringList spNames;
-
-public slots:
- void Save();
-
-signals:
- void dataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight);
-
-protected:
- QList< QList > schemes;
-
-private:
- QSettings fileConfig;
-};
-
-class NetAmmoSchemeModel : public QAbstractTableModel
-{
- Q_OBJECT
-
-public:
- NetAmmoSchemeModel(QObject * parent);
-
- QVariant headerData(int section, Qt::Orientation orientation, int role) const;
- int rowCount(const QModelIndex & parent) const;
- int columnCount(const QModelIndex & parent) const;
- QVariant data(const QModelIndex &index, int role) const;
-
-public slots:
- void setNetSchemeConfig(QStringList & cfg);
-
-private:
- QList netScheme;
-};
-
-#endif // _AMMO_SCHEME_MODEL_INCLUDED
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/bgwidget.cpp
--- a/QTfrontend/bgwidget.cpp Sat Oct 08 16:45:52 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,143 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2009 Kristian Lehmann
- * Copyright (c) 2009-2011 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 "bgwidget.h"
-
-SpritePosition::SpritePosition(QWidget * parent, int sh)
-{
- wParent = parent;
- iSpriteHeight = sh;
- reset();
-}
-
-SpritePosition::~SpritePosition()
-{
-}
-
-void SpritePosition::move()
-{
- fX += fXMov;
- fY += fYMov;
- iAngle += 4;
- if (iAngle >= 360) iAngle = 0;
- if (fY > wParent->height()) reset();
-}
-
-void SpritePosition::reset()
-{
- fY = -1 * iSpriteHeight;
- fX = (qrand() % ((int)(wParent->width() * 1.5))) - wParent->width()/2;
- fYMov = ((qrand() % 400)+300) / 100.0f;
- fXMov = fYMov * 0.2f+((qrand()%100)/100.0f * 0.6f); //so between 0.2 and 0.6, or 0.5 +/- 0.3
- iAngle = qrand() % 360;
-}
-
-QPoint SpritePosition::pos()
-{
- return QPoint((int)fX,(int)fY);
-}
-
-int SpritePosition::getAngle()
-{
- return iAngle;
-}
-
-void SpritePosition::init()
-{
- fY = qrand() % (wParent->height() + 1);
- fX = qrand() % (wParent->width() + 1);
-}
-
-BGWidget::BGWidget(QWidget * parent) : QWidget(parent)
-{
- setAttribute(Qt::WA_NoSystemBackground, true);
- sprite.load(":/res/Star.png");
-
- setAutoFillBackground(false);
-
- for (int i = 0; i < SPRITE_MAX; i++) spritePositions[i] = new SpritePosition(this, sprite.height());
-
- for (int i = 0; i < 360; i++)
- {
- rotatedSprites[i] = new QImage(sprite.width(), sprite.height(), QImage::Format_ARGB32);
- rotatedSprites[i]->fill(0);
-
- QPoint translate(sprite.width()/2, sprite.height()/2);
-
- QPainter p;
- p.begin(rotatedSprites[i]);
- // p.setRenderHint(QPainter::Antialiasing);
- p.setRenderHint(QPainter::SmoothPixmapTransform);
- p.translate(translate.x(), translate.y());
- p.rotate(i);
- p.translate(-1*translate.x(), -1*translate.y());
- p.drawImage(0, 0, sprite);
- }
-
- timerAnimation = new QTimer();
- connect(timerAnimation, SIGNAL(timeout()), this, SLOT(animate()));
- timerAnimation->setInterval(ANIMATION_INTERVAL);
-}
-
-BGWidget::~BGWidget()
-{
- for (int i = 0; i < SPRITE_MAX; i++) delete spritePositions[i];
- for (int i = 0; i < 360; i++) delete rotatedSprites[i];
- delete timerAnimation;
-}
-
-void BGWidget::paintEvent(QPaintEvent *event)
-{
- Q_UNUSED(event);
-
- QPainter p;
- p.begin(this);
- //p.setRenderHint(QPainter::Antialiasing);
- for (int i = 0; i < SPRITE_MAX; i++)
- {
- QPoint point = spritePositions[i]->pos();
- p.drawImage(point.x(), point.y(), *rotatedSprites[spritePositions[i]->getAngle()]);
- }
- p.end();
-}
-
-void BGWidget::animate()
-{
- for (int i = 0; i < SPRITE_MAX; i++)
- {
- // bottom edge of star *seems* clipped, but in fact, if I switch to just plain old repaint()/update() it is still clipped - artifact of transform? As for 5, is arbitrary number. 4 was noticeably clipping, 5 seemed same as update() - I assume extra room is due to rotation and value really should be calculated proportional to width/height
- update(spritePositions[i]->pos().x(),spritePositions[i]->pos().y(), sprite.width()+5, sprite.height()+5);
- spritePositions[i]->move();
- }
-}
-
-void BGWidget::startAnimation()
-{
- timerAnimation->start();
-}
-
-void BGWidget::stopAnimation()
-{
- timerAnimation->stop();
-}
-
-void BGWidget::init()
-{
- for (int i = 0; i < SPRITE_MAX; i++) spritePositions[i]->init();
-}
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/bgwidget.h
--- a/QTfrontend/bgwidget.h Sat Oct 08 16:45:52 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2009 Kristian Lehmann
- * Copyright (c) 2009-2011 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 BGWIDGET_H
-#define BGWIDGET_H
-
-#include
-//#include
-#include
-#include
-#include
-#include
-#include
-
-#define SPRITE_MAX 12
-
-#define ANIMATION_INTERVAL 40
-
-class SpritePosition
-{
-public:
- SpritePosition(QWidget * parent, int sh);
- ~SpritePosition();
-private:
- float fX;
- float fY;
- float fXMov;
- float fYMov;
- int iAngle;
- QWidget * wParent;
- int iSpriteHeight;
-public:
- void move();
- void reset();
- QPoint pos();
- int getAngle();
- void init();
-};
-
-class BGWidget : public QWidget
-{
- Q_OBJECT
-public:
- BGWidget(QWidget * parent);
- ~BGWidget();
- void startAnimation();
- void stopAnimation();
- void init();
-private:
- QImage sprite;
- QTimer * timerAnimation;
- SpritePosition * spritePositions[SPRITE_MAX];
- QImage * rotatedSprites[360];
-protected:
- void paintEvent(QPaintEvent * event);
-private slots:
- void animate();
-};
-
-#endif // BGWIDGET_H
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/binds.cpp
--- a/QTfrontend/binds.cpp Sat Oct 08 16:45:52 2011 +0200
+++ b/QTfrontend/binds.cpp Sat Oct 08 16:54:56 2011 +0200
@@ -62,9 +62,7 @@
{"confirm", "y", QT_TRANSLATE_NOOP("binds", "confirmation"), NULL, NULL},
{"+voldown", "9", QT_TRANSLATE_NOOP("binds", "volume down"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Modify the game's volume while playing:")},
{"+volup", "0", QT_TRANSLATE_NOOP("binds", "volume up"), NULL, NULL},
-#ifndef _WIN32
{"fullscr", "f12", QT_TRANSLATE_NOOP("binds", "change mode"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Toggle fullscreen mode:")},
-#endif
{"capture", "c", QT_TRANSLATE_NOOP("binds", "capture"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Take a screenshot:")},
{"rotmask", "delete", QT_TRANSLATE_NOOP("binds", "hedgehogs\ninfo"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Toggle labels above hedgehogs:")}
};
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/binds.h
--- a/QTfrontend/binds.h Sat Oct 08 16:45:52 2011 +0200
+++ b/QTfrontend/binds.h Sat Oct 08 16:54:56 2011 +0200
@@ -21,11 +21,7 @@
#include
-#ifdef _WIN32
-#define BINDS_NUMBER 43
-#else
#define BINDS_NUMBER 44
-#endif
struct BindAction
{
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/chatwidget.cpp
--- a/QTfrontend/chatwidget.cpp Sat Oct 08 16:45:52 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,573 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2007 Igor Ulyanov
- * Copyright (c) 2007-2011 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
-#include
-#include
-
-#include "hwconsts.h"
-#include "SDLs.h"
-#include "gameuiconfig.h"
-#include "chatwidget.h"
-
-ListWidgetNickItem::ListWidgetNickItem(const QString& nick, bool isFriend, bool isIgnored) : QListWidgetItem(nick)
-{
- this->aFriend = isFriend;
- this->isIgnored = isIgnored;
-}
-
-void ListWidgetNickItem::setFriend(bool isFriend)
-{
- this->aFriend = isFriend;
-}
-
-void ListWidgetNickItem::setIgnored(bool isIgnored)
-{
- this->isIgnored = isIgnored;
-}
-
-bool ListWidgetNickItem::isFriend()
-{
- return aFriend;
-}
-
-bool ListWidgetNickItem::ignored()
-{
- return isIgnored;
-}
-
-bool ListWidgetNickItem::operator< (const QListWidgetItem & other) const
-{
- // case in-sensitive comparison of the associated strings
- // chars that are no letters are sorted at the end of the list
-
- ListWidgetNickItem otherNick = const_cast(dynamic_cast(other));
-
- // ignored always down
- if (isIgnored != otherNick.ignored())
- return !isIgnored;
-
- // friends always up
- if (aFriend != otherNick.isFriend())
- return aFriend;
-
- QString txt1 = text().toLower();
- QString txt2 = other.text().toLower();
-
- bool firstIsShorter = (txt1.size() < txt2.size());
- int len = firstIsShorter?txt1.size():txt2.size();
-
- for (int i = 0; i < len; i++)
- {
- if (txt1[i] == txt2[i])
- continue;
- if (txt1[i].isLetter() != txt2[i].isLetter())
- return txt1[i].isLetter();
- return (txt1[i] < txt2[i]);
- }
-
- return firstIsShorter;
-}
-
-const char* HWChatWidget::STYLE =
-"\
-a { color:#c8c8ff; }\
-.nick { text-decoration: none; }\
-.UserChat .nick { color:#ffec20; }\
-.FriendChat { color: #08e008; }\
-.FriendChat .nick { color: #20ff20; }\
-.UserJoin { color: #c0c0c0; }\
-.UserJoin .nick { color: #d0d0d0; }\
-.FriendJoin { color: #c0e0c0; }\
-.FriendJoin .nick { color: #d0f0d0; }\
-.UserAction { color: #ff80ff; }\
-.UserAction .nick { color: #ffa0ff; }\
-.FriendAction { color: #ff00ff; }\
-.FriendAction .nick { color: #ff30ff; }\
-";
-
-HWChatWidget::HWChatWidget(QWidget* parent, QSettings * gameSettings, SDLInteraction * sdli, bool notify) :
- QWidget(parent),
- mainLayout(this)
-{
- this->gameSettings = gameSettings;
- this->sdli = sdli;
- this->notify = notify;
- if(notify && gameSettings->value("frontend/sound", true).toBool()) {
- QFile tmpfile;
- sdli->SDLMusicInit();
- for(int i=0;i<4;i++) {
- tmpfile.setFileName(cfgdir->absolutePath() + "/Data/Sounds/voices/Classic/Hello.ogg");
- if (tmpfile.exists()) sound[i] = Mix_LoadWAV(QFileInfo(tmpfile).absoluteFilePath().toLocal8Bit().constData());
- else sound[i] = Mix_LoadWAV(QString(datadir->absolutePath() +
- "/Sounds/voices/Classic/Hello.ogg").toLocal8Bit().constData());
- }
- }
-
- mainLayout.setSpacing(1);
- mainLayout.setMargin(1);
- mainLayout.setSizeConstraint(QLayout::SetMinimumSize);
- mainLayout.setColumnStretch(0, 76);
- mainLayout.setColumnStretch(1, 24);
-
- chatEditLine = new QLineEdit(this);
- chatEditLine->setMaxLength(300);
- connect(chatEditLine, SIGNAL(returnPressed()), this, SLOT(returnPressed()));
-
- mainLayout.addWidget(chatEditLine, 2, 0);
-
- chatText = new QTextBrowser(this);
- chatText->document()->setDefaultStyleSheet(STYLE);
- chatText->setMinimumHeight(20);
- chatText->setMinimumWidth(10);
- chatText->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
- chatText->setOpenLinks(false);
- connect(chatText, SIGNAL(anchorClicked(const QUrl&)),
- this, SLOT(linkClicked(const QUrl&)));
- mainLayout.addWidget(chatText, 0, 0, 2, 1);
-
- chatNicks = new QListWidget(this);
- chatNicks->setMinimumHeight(10);
- chatNicks->setMinimumWidth(10);
- chatNicks->setSortingEnabled(true);
- chatNicks->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
- chatNicks->setContextMenuPolicy(Qt::ActionsContextMenu);
- connect(chatNicks, SIGNAL(itemDoubleClicked(QListWidgetItem *)),
- this, SLOT(chatNickDoubleClicked(QListWidgetItem *)));
- connect(chatNicks, SIGNAL(currentRowChanged(int)),
- this, SLOT(chatNickSelected(int)));
-
- mainLayout.addWidget(chatNicks, 0, 1, 3, 1);
-
- acInfo = new QAction(QAction::tr("Info"), chatNicks);
- acInfo->setIcon(QIcon(":/res/info.png"));
- connect(acInfo, SIGNAL(triggered(bool)), this, SLOT(onInfo()));
- acKick = new QAction(QAction::tr("Kick"), chatNicks);
- acKick->setIcon(QIcon(":/res/kick.png"));
- connect(acKick, SIGNAL(triggered(bool)), this, SLOT(onKick()));
- acBan = new QAction(QAction::tr("Ban"), chatNicks);
- acBan->setIcon(QIcon(":/res/ban.png"));
- connect(acBan, SIGNAL(triggered(bool)), this, SLOT(onBan()));
- acFollow = new QAction(QAction::tr("Follow"), chatNicks);
- acFollow->setIcon(QIcon(":/res/follow.png"));
- connect(acFollow, SIGNAL(triggered(bool)), this, SLOT(onFollow()));
- acIgnore = new QAction(QAction::tr("Ignore"), chatNicks);
- acIgnore->setIcon(QIcon(":/res/ignore.png"));
- connect(acIgnore, SIGNAL(triggered(bool)), this, SLOT(onIgnore()));
- acFriend = new QAction(QAction::tr("Add friend"), chatNicks);
- acFriend->setIcon(QIcon(":/res/addfriend.png"));
- connect(acFriend, SIGNAL(triggered(bool)), this, SLOT(onFriend()));
-
- chatNicks->insertAction(0, acFriend);
- chatNicks->insertAction(0, acInfo);
- chatNicks->insertAction(0, acIgnore);
-
- showReady = false;
- setShowFollow(true);
-}
-
-void HWChatWidget::linkClicked(const QUrl & link)
-{
- if (link.scheme() == "http")
- QDesktopServices::openUrl(link);
- if (link.scheme() == "hwnick")
- {
- // decode nick
- const QString& nick = QString::fromUtf8(QByteArray::fromBase64(link.encodedQuery()));
- QList items = chatNicks->findItems(nick, Qt::MatchExactly);
- if (items.size() < 1)
- return;
- QMenu * popup = new QMenu();
- // selecting an item will automatically scroll there, so let's save old position
- QScrollBar * scrollBar = chatNicks->verticalScrollBar();
- int oldScrollPos = scrollBar->sliderPosition();
- // select the nick which we want to see the actions for
- chatNicks->setCurrentItem(items[0], QItemSelectionModel::Clear);
- // selecting an item will automatically scroll there, so let's save old position
- scrollBar->setSliderPosition(oldScrollPos);
- // load actions
- popup->addActions(chatNicks->actions());
- // display menu popup at mouse cursor position
- popup->popup(QCursor::pos());
- }
-}
-
-void HWChatWidget::setShowFollow(bool enabled)
-{
- if (enabled) {
- if (!(chatNicks->actions().contains(acFollow)))
- chatNicks->insertAction(acFriend, acFollow);
- }
- else {
- if (chatNicks->actions().contains(acFollow))
- chatNicks->removeAction(acFollow);
- }
-}
-
-void HWChatWidget::loadList(QStringList & list, const QString & file)
-{
- list.clear();
- QFile txt(cfgdir->absolutePath() + "/" + file);
- if(!txt.open(QIODevice::ReadOnly))
- return;
- QTextStream stream(&txt);
- stream.setCodec("UTF-8");
-
- while(!stream.atEnd())
- {
- QString str = stream.readLine();
- if(str.startsWith(";") || str.length() == 0)
- continue;
- list << str.trimmed();
- }
- //readd once we require newer Qt than 4.4
- //list.removeDuplicates();
- txt.close();
-}
-
-void HWChatWidget::saveList(QStringList & list, const QString & file)
-{
- QFile txt(cfgdir->absolutePath() + "/" + file);
- if(!txt.open(QIODevice::WriteOnly | QIODevice::Truncate))
- return;
- QTextStream stream(&txt);
- stream.setCodec("UTF-8");
-
- stream << "; this list is used by Hedgewars - do not edit it unless you know what you're doing!" << endl;
- for(int i = 0; i < list.size(); i++)
- stream << list[i] << endl;
- txt.close();
-}
-
-void HWChatWidget::updateNickItem(QListWidgetItem *nickItem)
-{
- QString nick = nickItem->text();
- ListWidgetNickItem * item = dynamic_cast(nickItem);
-
- item->setFriend(friendsList.contains(nick, Qt::CaseInsensitive));
- item->setIgnored(ignoreList.contains(nick, Qt::CaseInsensitive));
-
- if(item->ignored())
- {
- item->setIcon(QIcon(showReady ? (item->data(Qt::UserRole).toBool() ? ":/res/chat_ignore_on.png" : ":/res/chat_ignore_off.png") : ":/res/chat_ignore.png"));
- item->setForeground(Qt::gray);
- }
- else if(item->isFriend())
- {
- item->setIcon(QIcon(showReady ? (item->data(Qt::UserRole).toBool() ? ":/res/chat_friend_on.png" : ":/res/chat_friend_off.png") : ":/res/chat_friend.png"));
- item->setForeground(Qt::green);
- }
- else
- {
- item->setIcon(QIcon(showReady ? (item->data(Qt::UserRole).toBool() ? ":/res/chat_default_on.png" : ":/res/chat_default_off.png") : ":/res/chat_default.png"));
- item->setForeground(QBrush(QColor(0xff, 0xcc, 0x00)));
- }
-}
-
-void HWChatWidget::updateNickItems()
-{
- for(int i = 0; i < chatNicks->count(); i++)
- updateNickItem(chatNicks->item(i));
-
- chatNicks->sortItems();
-}
-
-void HWChatWidget::loadLists(const QString & nick)
-{
- loadList(ignoreList, nick.toLower() + "_ignore.txt");
- loadList(friendsList, nick.toLower() + "_friends.txt");
- updateNickItems();
-}
-
-void HWChatWidget::saveLists(const QString & nick)
-{
- saveList(ignoreList, nick.toLower() + "_ignore.txt");
- saveList(friendsList, nick.toLower() + "_friends.txt");
-}
-
-void HWChatWidget::returnPressed()
-{
- emit chatLine(chatEditLine->text());
- chatEditLine->clear();
-}
-
-
-void HWChatWidget::onChatString(const QString& str)
-{
- onChatString("", str);
-}
-
-const QRegExp HWChatWidget::URLREGEXP = QRegExp("(http://)?(www\\.)?(hedgewars\\.org(/[^ ]*)?)");
-
-void HWChatWidget::onChatString(const QString& nick, const QString& str)
-{
- bool isFriend = false;
-
- if (!nick.isEmpty()) {
- // don't show chat lines that are from ignored nicks
- if (ignoreList.contains(nick, Qt::CaseInsensitive))
- return;
- // friends will get special treatment, of course
- isFriend = friendsList.contains(nick, Qt::CaseInsensitive);
- }
-
- if (chatStrings.size() > 250)
- chatStrings.removeFirst();
-
- QString formattedStr = Qt::escape(str.mid(1));
- // make hedgewars.org urls actual links
- formattedStr = formattedStr.replace(URLREGEXP, "\\3");
-
- // "link" nick, but before that encode it in base64 to make sure it can't intefere with html/url syntax
- // the nick is put as querystring as putting it as host would convert it to it's lower case variant
- if(!nick.isEmpty())
- formattedStr.replace("|nick|",QString("%2").arg(QString(nick.toUtf8().toBase64())).arg(nick));
-
- QString cssClass("UserChat");
-
- // check first character for color code and set color properly
- switch (str[0].toAscii()) {
- case 3:
- cssClass = (isFriend ? "FriendJoin" : "UserJoin");
- break;
- case 2:
- cssClass = (isFriend ? "FriendAction" : "UserAction");
- break;
- default:
- if (isFriend)
- cssClass = "FriendChat";
- }
-
- formattedStr = QString("%1").arg(formattedStr).arg(cssClass);
-
- chatStrings.append(formattedStr);
-
- chatText->setHtml(chatStrings.join("
"));
-
- chatText->moveCursor(QTextCursor::End);
-}
-
-void HWChatWidget::onServerMessage(const QString& str)
-{
- if (chatStrings.size() > 250)
- chatStrings.removeFirst();
-
- chatStrings.append("
" + str + "
");
-
- chatText->setHtml(chatStrings.join("
"));
-
- chatText->moveCursor(QTextCursor::End);
-}
-
-void HWChatWidget::nickAdded(const QString& nick, bool notifyNick)
-{
- QListWidgetItem * item = new ListWidgetNickItem(nick, friendsList.contains(nick, Qt::CaseInsensitive), ignoreList.contains(nick, Qt::CaseInsensitive));
- updateNickItem(item);
- chatNicks->addItem(item);
-
- emit nickCountUpdate(chatNicks->count());
-
- if(notifyNick && notify && gameSettings->value("frontend/sound", true).toBool()) {
- Mix_PlayChannel(-1, sound[rand()%4], 0);
- }
-}
-
-void HWChatWidget::nickRemoved(const QString& nick)
-{
- foreach(QListWidgetItem * item, chatNicks->findItems(nick, Qt::MatchExactly))
- chatNicks->takeItem(chatNicks->row(item));
-
- emit nickCountUpdate(chatNicks->count());
-}
-
-void HWChatWidget::clear()
-{
- chatText->clear();
- chatStrings.clear();
- chatNicks->clear();
-}
-
-void HWChatWidget::onKick()
-{
- QListWidgetItem * curritem = chatNicks->currentItem();
- if (curritem)
- emit kick(curritem->text());
-}
-
-void HWChatWidget::onBan()
-{
- QListWidgetItem * curritem = chatNicks->currentItem();
- if (curritem)
- emit ban(curritem->text());
-}
-
-void HWChatWidget::onInfo()
-{
- QListWidgetItem * curritem = chatNicks->currentItem();
- if (curritem)
- emit info(curritem->text());
-}
-
-void HWChatWidget::onFollow()
-{
- QListWidgetItem * curritem = chatNicks->currentItem();
- if (curritem)
- emit follow(curritem->text());
-}
-
-void HWChatWidget::onIgnore()
-{
- QListWidgetItem * curritem = chatNicks->currentItem();
- if(!curritem)
- return;
-
- if(ignoreList.contains(curritem->text(), Qt::CaseInsensitive)) // already on list - remove him
- {
- ignoreList.removeAll(curritem->text().toLower());
- onChatString(HWChatWidget::tr("%1 *** %2 has been removed from your ignore list").arg('\x03').arg(curritem->text()));
- }
- else // not on list - add
- {
- // don't consider ignored people friends
- if(friendsList.contains(curritem->text(), Qt::CaseInsensitive))
- emit onFriend();
-
- // scroll down on first ignore added so that people see where that nick went to
- if (ignoreList.isEmpty())
- chatNicks->scrollToBottom();
-
- ignoreList << curritem->text().toLower();
- onChatString(HWChatWidget::tr("%1 *** %2 has been added to your ignore list").arg('\x03').arg(curritem->text()));
- }
- updateNickItem(curritem); // update icon/sort order/etc
- chatNicks->sortItems();
- chatNickSelected(0); // update context menu
-}
-
-void HWChatWidget::onFriend()
-{
- QListWidgetItem * curritem = chatNicks->currentItem();
- if(!curritem)
- return;
-
- if(friendsList.contains(curritem->text(), Qt::CaseInsensitive)) // already on list - remove him
- {
- friendsList.removeAll(curritem->text().toLower());
- onChatString(HWChatWidget::tr("%1 *** %2 has been removed from your friends list").arg('\x03').arg(curritem->text()));
- }
- else // not on list - add
- {
- // don't ignore the new friend
- if(ignoreList.contains(curritem->text(), Qt::CaseInsensitive))
- emit onIgnore();
-
- // scroll up on first friend added so that people see where that nick went to
- if (friendsList.isEmpty())
- chatNicks->scrollToTop();
-
- friendsList << curritem->text().toLower();
- onChatString(HWChatWidget::tr("%1 *** %2 has been added to your friends list").arg('\x03').arg(curritem->text()));
- }
- updateNickItem(curritem); // update icon/sort order/etc
- chatNicks->sortItems();
- chatNickSelected(0); // update context menu
-}
-
-void HWChatWidget::chatNickDoubleClicked(QListWidgetItem * item)
-{
- Q_UNUSED(item);
-
- QList actions = chatNicks->actions();
- actions.first()->activate(QAction::Trigger);
-}
-
-void HWChatWidget::chatNickSelected(int index)
-{
- Q_UNUSED(index);
-
- QListWidgetItem* item = chatNicks->currentItem();
- if (!item)
- return;
-
- // update context menu labels according to possible action
- if(ignoreList.contains(item->text(), Qt::CaseInsensitive))
- {
- acIgnore->setText(QAction::tr("Unignore"));
- acIgnore->setIcon(QIcon(":/res/unignore.png"));
- }
- else
- {
- acIgnore->setText(QAction::tr("Ignore"));
- acIgnore->setIcon(QIcon(":/res/ignore.png"));
- }
-
- if(friendsList.contains(item->text(), Qt::CaseInsensitive))
- {
- acFriend->setText(QAction::tr("Remove friend"));
- acFriend->setIcon(QIcon(":/res/remfriend.png"));
- }
- else
- {
- acFriend->setText(QAction::tr("Add friend"));
- acFriend->setIcon(QIcon(":/res/addfriend.png"));
- }
-}
-
-void HWChatWidget::setShowReady(bool s)
-{
- showReady = s;
-}
-
-void HWChatWidget::setReadyStatus(const QString & nick, bool isReady)
-{
- QList items = chatNicks->findItems(nick, Qt::MatchExactly);
- if (items.size() != 1)
- {
- qWarning("Bug: cannot find user in chat");
- return;
- }
-
- items[0]->setData(Qt::UserRole, isReady); // bulb status
- updateNickItem(items[0]);
-
- // ensure we're still showing the status bulbs
- showReady = true;
-}
-
-void HWChatWidget::adminAccess(bool b)
-{
- chatNicks->removeAction(acKick);
- chatNicks->removeAction(acBan);
-
- if(b)
- {
- chatNicks->insertAction(0, acKick);
-// chatNicks->insertAction(0, acBan);
- }
-}
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/chatwidget.h
--- a/QTfrontend/chatwidget.h Sat Oct 08 16:45:52 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,123 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2007 Igor Ulyanov
- * Copyright (c) 2007-2011 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 _CHAT_WIDGET_INCLUDED
-#define _CHAT_WIDGET_INCLUDED
-
-#include
-#include
-#include
-#include
-#include
-
-#include "SDLs.h"
-
-class ListWidgetNickItem;
-class QTextBrowser;
-class QLineEdit;
-class QListWidget;
-class QSettings;
-class SDLInteraction;
-
-// this class is for custom nick sorting
-class ListWidgetNickItem : public QListWidgetItem
-{
-public:
- ListWidgetNickItem(const QString& nick, bool isFriend, bool isIgnored);
- bool operator<(const QListWidgetItem & other) const;
- void setFriend(bool isFriend);
- void setIgnored(bool isIgnored);
- bool isFriend();
- bool ignored();
-
-private:
- bool aFriend;
- bool isIgnored;
-};
-
-class HWChatWidget : public QWidget
-{
- Q_OBJECT
-
- public:
- HWChatWidget(QWidget* parent, QSettings * gameSettings, SDLInteraction * sdli, bool notify);
- void loadLists(const QString & nick);
- void saveLists(const QString & nick);
- void setShowReady(bool s);
- void setShowFollow(bool enabled);
- static const char* STYLE;
- QStringList ignoreList, friendsList;
-
-private:
- void loadList(QStringList & list, const QString & file);
- void saveList(QStringList & list, const QString & file);
- void updateNickItem(QListWidgetItem *item);
- void updateNickItems();
- static const QRegExp URLREGEXP;
-
- public slots:
- void onChatString(const QString& str);
- void onChatString(const QString& nick, const QString& str);
- void onServerMessage(const QString& str);
- void nickAdded(const QString& nick, bool notifyNick);
- void nickRemoved(const QString& nick);
- void clear();
- void setReadyStatus(const QString & nick, bool isReady);
- void adminAccess(bool);
-
- signals:
- void chatLine(const QString& str);
- void kick(const QString & str);
- void ban(const QString & str);
- void info(const QString & str);
- void follow(const QString &);
- void nickCountUpdate(int cnt);
-
- private:
- QGridLayout mainLayout;
- QTextBrowser* chatText;
- QStringList chatStrings;
- QListWidget* chatNicks;
- QLineEdit* chatEditLine;
- QAction * acInfo;
- QAction * acKick;
- QAction * acBan;
- QAction * acFollow;
- QAction * acIgnore;
- QAction * acFriend;
- QSettings * gameSettings;
- SDLInteraction * sdli;
- Mix_Chunk *sound[4];
- bool notify;
- bool showReady;
-
- private slots:
- void returnPressed();
- void onBan();
- void onKick();
- void onInfo();
- void onFollow();
- void onIgnore();
- void onFriend();
- void chatNickDoubleClicked(QListWidgetItem * item);
- void chatNickSelected(int index);
- void linkClicked(const QUrl & link);
-};
-
-#endif // _CHAT_WIDGET_INCLUDED
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/databrowser.cpp
--- a/QTfrontend/databrowser.cpp Sat Oct 08 16:45:52 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-#include
-#include
-#include
-#include
-#include
-
-#include "databrowser.h"
-
-const QNetworkRequest::Attribute typeAttribute = (QNetworkRequest::Attribute)(QNetworkRequest::User + 1);
-const QNetworkRequest::Attribute urlAttribute = (QNetworkRequest::Attribute)(QNetworkRequest::User + 2);
-
-DataBrowser::DataBrowser(QWidget *parent) :
- QTextBrowser(parent)
-{
-
- manager = new QNetworkAccessManager(this);
-}
-
-QVariant DataBrowser::loadResource(int type, const QUrl & name)
-{
- if(type == QTextDocument::ImageResource || type == QTextDocument::StyleSheetResource)
- {
- if(resources.contains(name.toString()))
- {
- return resources.take(name.toString());
- }
- else
- if(!requestedResources.contains(name.toString()))
- {
- qDebug() << "Requesting resource" << name.toString();
- requestedResources.insert(name.toString());
-
- QNetworkRequest newRequest(QUrl("http://www.hedgewars.org" + name.toString()));
- newRequest.setAttribute(typeAttribute, type);
- newRequest.setAttribute(urlAttribute, name);
-
- QNetworkReply *reply = manager->get(newRequest);
- connect(reply, SIGNAL(finished()), this, SLOT(resourceDownloaded()));
- }
- }
-
- return QVariant();
-}
-
-void DataBrowser::resourceDownloaded()
-{
- QNetworkReply * reply = qobject_cast(sender());
-
- if(reply)
- {
- int type = reply->request().attribute(typeAttribute).toInt();
- QUrl url = reply->request().attribute(urlAttribute).toUrl();
- resources.insert(url.toString(), reply->readAll());
- document()->addResource(type, reply->request().url(), QVariant());
- update();
- }
-}
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/databrowser.h
--- a/QTfrontend/databrowser.h Sat Oct 08 16:45:52 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-#ifndef DATABROWSER_H
-#define DATABROWSER_H
-
-#include
-#include
-
-class QNetworkAccessManager;
-
-class DataBrowser : public QTextBrowser
-{
- Q_OBJECT
-public:
- explicit DataBrowser(QWidget *parent = 0);
-
-signals:
-
-public slots:
-
-private:
- QNetworkAccessManager *manager;
-
- // hash and set of QString instead of QUrl to support Qt versions
- // older than 4.7 (those have no support for qHash(const QUrl &))
- QHash resources;
- QSet requestedResources;
-
- QVariant loadResource(int type, const QUrl & name);
-
-private slots:
- void resourceDownloaded();
-};
-
-#endif // DATABROWSER_H
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/drawmapscene.cpp
--- a/QTfrontend/drawmapscene.cpp Sat Oct 08 16:45:52 2011 +0200
+++ b/QTfrontend/drawmapscene.cpp Sat Oct 08 16:54:56 2011 +0200
@@ -108,11 +108,32 @@
emit pathChanged();
}
+ else if(oldItems.size())
+ {
+ while(oldItems.size())
+ addItem(oldItems.takeFirst());
+ paths = oldPaths;
+
+ emit pathChanged();
+ }
}
void DrawMapScene::clearMap()
{
- clear();
+ // don't clear if already cleared
+ if(!items().size())
+ return;
+
+ oldItems.clear();
+
+ // do this since clear() would _destroy_ all items
+ while(items().size()) {
+ oldItems.push_front(items().first());
+ removeItem(items().first());
+ }
+
+ oldPaths = paths;
+
paths.clear();
emit pathChanged();
@@ -146,6 +167,8 @@
void DrawMapScene::decode(QByteArray data)
{
+ oldItems.clear();
+ oldPaths.clear();
clear();
paths.clear();
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/drawmapscene.h
--- a/QTfrontend/drawmapscene.h Sat Oct 08 16:45:52 2011 +0200
+++ b/QTfrontend/drawmapscene.h Sat Oct 08 16:54:56 2011 +0200
@@ -48,6 +48,8 @@
QBrush m_brush;
QGraphicsPathItem * m_currPath;
Paths paths;
+ Paths oldPaths;
+ QList oldItems;
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent);
virtual void mousePressEvent(QGraphicsSceneMouseEvent * mouseEvent);
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/drawmapwidget.cpp
--- a/QTfrontend/drawmapwidget.cpp Sat Oct 08 16:45:52 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,106 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2011 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 "drawmapwidget.h"
-
-DrawMapWidget::DrawMapWidget(QWidget *parent) :
- QWidget(parent),
- ui(new Ui::DrawMapWidget)
-{
- ui->setupUi(this);
-
- m_scene = 0;
-}
-
-DrawMapWidget::~DrawMapWidget()
-{
- delete ui;
-}
-
-void DrawMapWidget::changeEvent(QEvent *e)
-{
- QWidget::changeEvent(e);
- switch (e->type()) {
- case QEvent::LanguageChange:
- ui->retranslateUi(this);
- break;
- default:
- break;
- }
-}
-
-void DrawMapWidget::setScene(DrawMapScene * scene)
-{
- ui->graphicsView->setScene(scene);
- m_scene = scene;
-}
-
-void DrawMapWidget::resizeEvent(QResizeEvent * event)
-{
- Q_UNUSED(event);
-
- if(ui->graphicsView && ui->graphicsView->scene())
- ui->graphicsView->fitInView(ui->graphicsView->scene()->sceneRect(), Qt::KeepAspectRatio);
-}
-
-void DrawMapWidget::showEvent(QShowEvent * event)
-{
- Q_UNUSED(event);
-
- resizeEvent(0);
-}
-
-void DrawMapWidget::undo()
-{
- if(m_scene) m_scene->undo();
-}
-
-void DrawMapWidget::clear()
-{
- if(m_scene) m_scene->clearMap();
-}
-
-void DrawMapWidget::save(const QString & fileName)
-{
- if(m_scene)
- {
- QFile file(fileName);
-
- if(!file.open(QIODevice::WriteOnly))
- QMessageBox::warning(this, tr("File error"), tr("Cannot open file '%1' for writing").arg(fileName));
- else
- file.write(qCompress(m_scene->encode()).toBase64());
- }
-}
-
-void DrawMapWidget::load(const QString & fileName)
-{
- if(m_scene)
- {
- QFile f(fileName);
-
- if(!f.open(QIODevice::ReadOnly))
- QMessageBox::warning(this, tr("File error"), tr("Cannot read file '%1'").arg(fileName));
- else
- m_scene->decode(qUncompress(QByteArray::fromBase64(f.readAll())));
- }
-}
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/drawmapwidget.h
--- a/QTfrontend/drawmapwidget.h Sat Oct 08 16:45:52 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2011 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 DRAWMAPWIDGET_H
-#define DRAWMAPWIDGET_H
-
-#include
-#include
-#include
-#include
-
-#include "qaspectratiolayout.h"
-#include "drawmapscene.h"
-
-namespace Ui {
- class Ui_DrawMapWidget
- {
- public:
- QGraphicsView *graphicsView;
-
- void setupUi(QWidget *drawMapWidget)
- {
- QAspectRatioLayout * arLayout = new QAspectRatioLayout(drawMapWidget);
- arLayout->setMargin(0);
-
- graphicsView = new QGraphicsView(drawMapWidget);
- arLayout->addWidget(graphicsView);
-
- retranslateUi(drawMapWidget);
-
- QMetaObject::connectSlotsByName(drawMapWidget);
- } // setupUi
-
- void retranslateUi(QWidget *drawMapWidget)
- {
- Q_UNUSED(drawMapWidget);
- } // retranslateUi
-
- };
-
- class DrawMapWidget: public Ui_DrawMapWidget {};
-}
-
-class DrawMapWidget : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit DrawMapWidget(QWidget *parent = 0);
- ~DrawMapWidget();
-
- void setScene(DrawMapScene * scene);
-
-public slots:
- void undo();
- void clear();
- void save(const QString & fileName);
- void load(const QString & fileName);
-
-protected:
- void changeEvent(QEvent *e);
- virtual void resizeEvent(QResizeEvent * event);
- virtual void showEvent(QShowEvent * event);
-
-private:
- Ui::DrawMapWidget *ui;
-
- DrawMapScene * m_scene;
-};
-
-#endif // DRAWMAPWIDGET_H
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/fpsedit.cpp
--- a/QTfrontend/fpsedit.cpp Sat Oct 08 16:45:52 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2006-2011 Andrey Korotaev
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "fpsedit.h"
-
-FPSEdit::FPSEdit(QWidget * parent) :
- QSpinBox(parent)
-{
- setRange(1, 34);
- setValue(27);
-}
-
-QString FPSEdit::textFromValue(int value) const
-{
- return QString::number(1000 / (35 - value));
-}
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/fpsedit.h
--- a/QTfrontend/fpsedit.h Sat Oct 08 16:45:52 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2006-2011 Andrey Korotaev
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#ifndef _FPSEDIT_H
-#define _FPSEDIT_H
-
-#include
-
-class FPSEdit : public QSpinBox
-{
- Q_OBJECT
-
-public:
- FPSEdit(QWidget * parent = 0);
-
-protected:
- QString textFromValue (int value) const;
-};
-
-#endif // _FPSEDIT_H
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/frameTeam.cpp
--- a/QTfrontend/frameTeam.cpp Sat Oct 08 16:45:52 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,128 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2006-2007 Igor Ulyanov
- * Copyright (c) 2007-2011 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 "frameTeam.h"
-#include "teamselhelper.h"
-#include "hwconsts.h"
-
-FrameTeams::FrameTeams(QWidget* parent) :
- QFrame(parent), maxHedgehogsPerGame(48), overallHedgehogs(0), mainLayout(this), nonInteractive(false)
-{
- QPalette newPalette = palette();
- newPalette.setColor(QPalette::Window, QColor(0x00, 0x00, 0x00));
- setPalette(newPalette);
- setAutoFillBackground(true);
-
- mainLayout.setSpacing(1);
- mainLayout.setContentsMargins(4, 4, 4, 4);
-
- int i = 0;
- while(colors[i] != 0)
- availableColors.push_back(QColor(colors[i++]));
-
- resetColors();
-}
-
-void FrameTeams::setInteractivity(bool interactive)
-{
- nonInteractive = !interactive;
- for(tmapTeamToWidget::iterator it=teamToWidget.begin(); it!=teamToWidget.end(); ++it) {
- TeamShowWidget* pts = dynamic_cast(it.value());
- if(!pts) throw;
- pts->setInteractivity(interactive);
- }
-}
-
-void FrameTeams::resetColors()
-{
- currentColor=availableColors.end() - 1; // ensure next color is the first one
-}
-
-QColor FrameTeams::getNextColor() const
-{
- QList::ConstIterator nextColor=currentColor;
- ++nextColor;
- if (nextColor==availableColors.end()) nextColor=availableColors.begin();
- return *nextColor;
-}
-
-void FrameTeams::addTeam(HWTeam team, bool willPlay)
-{
- TeamShowWidget* pTeamShowWidget = new TeamShowWidget(team, willPlay, this);
- if(nonInteractive) pTeamShowWidget->setInteractivity(false);
-// int hght=teamToWidget.empty() ? 0 : teamToWidget.begin()->second->size().height();
- mainLayout.addWidget(pTeamShowWidget);
- teamToWidget.insert(team, pTeamShowWidget);
- QResizeEvent* pevent=new QResizeEvent(parentWidget()->size(), parentWidget()->size());
- QCoreApplication::postEvent(parentWidget(), pevent);
-}
-
-void FrameTeams::removeTeam(HWTeam team)
-{
- tmapTeamToWidget::iterator it=teamToWidget.find(team);
- if(it==teamToWidget.end()) return;
- mainLayout.removeWidget(it.value());
- it.value()->deleteLater();
- teamToWidget.erase(it);
-}
-
-void FrameTeams::resetTeams()
-{
- for(tmapTeamToWidget::iterator it=teamToWidget.begin(); it!=teamToWidget.end(); ) {
- mainLayout.removeWidget(it.value());
- it.value()->deleteLater();
- teamToWidget.erase(it++);
- }
-}
-
-void FrameTeams::setHHNum(const HWTeam& team)
-{
- TeamShowWidget* pTeamShowWidget = dynamic_cast(getTeamWidget(team));
- if(!pTeamShowWidget) return;
- pTeamShowWidget->setHHNum(team.numHedgehogs);
-}
-
-void FrameTeams::setTeamColor(const HWTeam& team)
-{
- TeamShowWidget* pTeamShowWidget = dynamic_cast(getTeamWidget(team));
- if(!pTeamShowWidget) return;
- pTeamShowWidget->changeTeamColor(team.teamColor);
-}
-
-QWidget* FrameTeams::getTeamWidget(HWTeam team)
-{
-//qDebug() << "FrameTeams::getTeamWidget getNetID() = " << team.getNetID();
- tmapTeamToWidget::iterator it=teamToWidget.find(team);
- QWidget* ret = it!=teamToWidget.end() ? it.value() : 0;
- return ret;
-}
-
-bool FrameTeams::isFullTeams() const
-{
- return overallHedgehogs==maxHedgehogsPerGame;
-}
-
-void FrameTeams::emitTeamColorChanged(const HWTeam& team)
-{
- emit teamColorChanged(team);
-}
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/frameTeam.h
--- a/QTfrontend/frameTeam.h Sat Oct 08 16:45:52 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2006-2007 Igor Ulyanov
- * Copyright (c) 2007-2011 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 _FRAME_TEAM_INCLUDED
-#define _FRAME_TEAM_INCLUDED
-
-#include
-#include
-#include
-
-#include "teamselect.h"
-
-class FrameTeams : public QFrame
-{
- Q_OBJECT
-
- friend class CHedgehogerWidget;
- friend class TeamShowWidget;
-
- public:
- FrameTeams(QWidget* parent=0);
- QWidget* getTeamWidget(HWTeam team);
- bool isFullTeams() const;
- void resetColors();
- void resetTeams();
- void setHHNum(const HWTeam& team);
- void setTeamColor(const HWTeam& team);
- void setInteractivity(bool interactive);
- QColor getNextColor() const;
-
- signals:
- void teamColorChanged(const HWTeam&);
-
- public slots:
- void addTeam(HWTeam team, bool willPlay);
- void removeTeam(HWTeam team);
-
- private:
- const int maxHedgehogsPerGame;
- int overallHedgehogs;
- QList availableColors;
- QList::Iterator currentColor;
-
- void emitTeamColorChanged(const HWTeam& team);
-
- QVBoxLayout mainLayout;
- typedef QMap tmapTeamToWidget;
- tmapTeamToWidget teamToWidget;
- bool nonInteractive;
-};
-
-#endif // _FRAME_TAM_INCLUDED
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/game.cpp
--- a/QTfrontend/game.cpp Sat Oct 08 16:45:52 2011 +0200
+++ b/QTfrontend/game.cpp Sat Oct 08 16:54:56 2011 +0200
@@ -53,8 +53,13 @@
void HWGame::onClientDisconnect()
{
switch (gameType) {
- case gtDemo:
- if (gameState == gsInterrupted || gameState == gsHalted) emit HaveRecord(false, demo);
+ case gtSave:
+ if (gameState == gsInterrupted || gameState == gsHalted)
+ emit HaveRecord(false, demo);
+ else if (gameState == gsFinished)
+ emit HaveRecord(true, demo);
+ break;
+ case gtDemo:
break;
case gtNet:
emit HaveRecord(true, demo);
@@ -94,7 +99,7 @@
HWProto::addStringToBuffer(buf, QString("eammreinf %1").arg(ammostr.mid(3 * cAmmoNumber, cAmmoNumber)));
if(!gamecfg->schemeData(21).toBool()) HWProto::addStringToBuffer(buf, QString("eammstore"));
HWProto::addStringListToBuffer(buf,
- team.TeamGameConfig(gamecfg->getInitHealth()));
+ team.teamGameConfig(gamecfg->getInitHealth()));
;
}
}
@@ -115,27 +120,23 @@
.arg((themesModel->rowCount() > 0) ? themesModel->index(rand() % themesModel->rowCount()).data().toString() : "steel"));
HWProto::addStringToBuffer(teamscfg, "eseed " + QUuid::createUuid().toString());
- HWNamegen namegen;
-
- HWTeam * team1;
- team1 = new HWTeam;
- team1->difficulty = 0;
- team1->teamColor = QColor(colors[0]);
- team1->numHedgehogs = 4;
- namegen.TeamRandomNames(team1,TRUE);
+ HWTeam team1;
+ team1.setDifficulty(0);
+ team1.setColor(QColor(colors[0]));
+ team1.setNumHedgehogs(4);
+ HWNamegen::teamRandomNames(team1,true);
HWProto::addStringListToBuffer(teamscfg,
- team1->TeamGameConfig(100));
+ team1.teamGameConfig(100));
- HWTeam * team2;
- team2 = new HWTeam;
- team2->difficulty = 4;
- team2->teamColor = QColor(colors[1]);
- team2->numHedgehogs = 4;
- do
- namegen.TeamRandomNames(team2,TRUE);
- while(!team2->TeamName.compare(team1->TeamName) || !team2->Hedgehogs[0].Hat.compare(team1->Hedgehogs[0].Hat));
+ HWTeam team2;
+ team2.setDifficulty(4);
+ team2.setColor(QColor(colors[1]));
+ team2.setNumHedgehogs(4);
+ do
+ HWNamegen::teamRandomNames(team2,true);
+ while(!team2.name().compare(team1.name()) || !team2.hedgehog(0).Hat.compare(team1.hedgehog(0).Hat));
HWProto::addStringListToBuffer(teamscfg,
- team2->TeamGameConfig(100));
+ team2.teamGameConfig(100));
HWProto::addStringToBuffer(teamscfg, QString("eammloadt %1").arg(cDefaultAmmoStore->mid(0, cAmmoNumber)));
HWProto::addStringToBuffer(teamscfg, QString("eammprob %1").arg(cDefaultAmmoStore->mid(cAmmoNumber, cAmmoNumber)));
@@ -188,6 +189,7 @@
SendQuickConfig();
break;
}
+ case gtSave:
case gtDemo: break;
case gtNet: {
SendNetConfig();
@@ -321,9 +323,9 @@
TeamCount++;
}
-void HWGame::PlayDemo(const QString & demofilename)
+void HWGame::PlayDemo(const QString & demofilename, bool isSave)
{
- gameType = gtDemo;
+ gameType = isSave ? gtSave : gtDemo;
QFile demofile(demofilename);
if (!demofile.open(QIODevice::ReadOnly))
{
@@ -394,7 +396,7 @@
{
QByteArray buf;
foreach(HWTeam team, m_pTeamSelWidget->getPlayingTeams())
- HWProto::addStringToBuffer(buf, QString("eteamgone %1").arg(team.TeamName));
+ HWProto::addStringToBuffer(buf, QString("eteamgone %1").arg(team.name()));
RawSendIPC(buf);
}
}
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/game.h
--- a/QTfrontend/game.h Sat Oct 08 16:45:52 2011 +0200
+++ b/QTfrontend/game.h Sat Oct 08 16:54:56 2011 +0200
@@ -48,7 +48,7 @@
HWGame(GameUIConfig * config, GameCFGWidget * gamecfg, QString ammo, TeamSelWidget* pTeamSelWidget = 0);
virtual ~HWGame();
void AddTeam(const QString & team);
- void PlayDemo(const QString & demofilename);
+ void PlayDemo(const QString & demofilename, bool isSave);
void StartLocal();
void StartQuick();
void StartNet();
@@ -84,6 +84,7 @@
gtNet = 4,
gtTraining = 5,
gtCampaign = 6,
+ gtSave = 7,
};
char msgbuf[MAXMSGCHARS];
QString teams[5];
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/gamecfgwidget.cpp
--- a/QTfrontend/gamecfgwidget.cpp Sat Oct 08 16:45:52 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,575 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2006-2011 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 "gamecfgwidget.h"
-#include "igbox.h"
-#include "hwconsts.h"
-#include "ammoSchemeModel.h"
-#include "proto.h"
-
-GameCFGWidget::GameCFGWidget(QWidget* parent) :
- QGroupBox(parent)
- , mainLayout(this)
- , seedRegexp("\\{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\}")
-{
- mainLayout.setMargin(0);
-// mainLayout.setSizeConstraint(QLayout::SetMinimumSize);
-
- pMapContainer = new HWMapContainer(this);
- mainLayout.addWidget(pMapContainer, 0, 0);
-
- IconedGroupBox *GBoxOptions = new IconedGroupBox(this);
- GBoxOptions->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
- mainLayout.addWidget(GBoxOptions, 1, 0);
-
- QGridLayout *GBoxOptionsLayout = new QGridLayout(GBoxOptions);
-
- QLabel *titleLabel = new QLabel(QLabel::tr("Game Options"), GBoxOptions);
- titleLabel->setMargin(7); // TODO: make the text larger/richer!!!!
- GBoxOptionsLayout->addWidget(titleLabel, 0, 0, 1, 0, Qt::AlignHCenter);
- GBoxOptionsLayout->addWidget(new QLabel(QLabel::tr("Style"), GBoxOptions), 1, 0);
-
- Scripts = new QComboBox(GBoxOptions);
- GBoxOptionsLayout->addWidget(Scripts, 1, 1);
-
- Scripts->addItem("Normal");
- Scripts->insertSeparator(1);
-
- for (int i = 0; i < scriptList->size(); ++i) {
- QString script = (*scriptList)[i].remove(".lua", Qt::CaseInsensitive);
- QList scriptInfo;
- scriptInfo.push_back(script);
- QFile scriptCfgFile;
- scriptCfgFile.setFileName(QString("%1/Data/Scripts/Multiplayer/%2.cfg").arg(cfgdir->absolutePath()).arg(script));
- if (!scriptCfgFile.exists()) scriptCfgFile.setFileName(QString("%1/Scripts/Multiplayer/%2.cfg").arg(datadir->absolutePath()).arg(script));
- if (scriptCfgFile.exists() && scriptCfgFile.open(QFile::ReadOnly)) {
- QString scheme;
- QString weapons;
- QTextStream input(&scriptCfgFile);
- input >> scheme;
- input >> weapons;
- if (scheme.isEmpty())
- scheme = "locked";
- scheme.replace("_", " ");
- if (weapons.isEmpty())
- weapons = "locked";
- weapons.replace("_", " ");
- scriptInfo.push_back(scheme);
- scriptInfo.push_back(weapons);
- scriptCfgFile.close();
- }
- else
- {
- scriptInfo.push_back("locked");
- scriptInfo.push_back("locked");
- }
- Scripts->addItem(script.replace("_", " "), scriptInfo);
- }
-
- connect(Scripts, SIGNAL(currentIndexChanged(int)), this, SLOT(scriptChanged(int)));
-
- QWidget *SchemeWidget = new QWidget(GBoxOptions);
- GBoxOptionsLayout->addWidget(SchemeWidget, 2, 0, 1, 2);
-
- QGridLayout *SchemeWidgetLayout = new QGridLayout(SchemeWidget);
- SchemeWidgetLayout->setMargin(0);
-
- GameSchemes = new QComboBox(SchemeWidget);
- SchemeWidgetLayout->addWidget(GameSchemes, 0, 2);
- connect(GameSchemes, SIGNAL(currentIndexChanged(int)), this, SLOT(schemeChanged(int)));
-
- SchemeWidgetLayout->addWidget(new QLabel(QLabel::tr("Scheme"), SchemeWidget), 0, 0);
-
- QPixmap pmEdit(":/res/edit.png");
-
- QPushButton * goToSchemePage = new QPushButton(SchemeWidget);
- goToSchemePage->setToolTip(tr("Edit schemes"));
- goToSchemePage->setIconSize(pmEdit.size());
- goToSchemePage->setIcon(pmEdit);
- goToSchemePage->setMaximumWidth(pmEdit.width() + 6);
- SchemeWidgetLayout->addWidget(goToSchemePage, 0, 3);
- connect(goToSchemePage, SIGNAL(clicked()), this, SLOT(jumpToSchemes()));
-
- SchemeWidgetLayout->addWidget(new QLabel(QLabel::tr("Weapons"), SchemeWidget), 1, 0);
-
- WeaponsName = new QComboBox(SchemeWidget);
- SchemeWidgetLayout->addWidget(WeaponsName, 1, 2);
-
- connect(WeaponsName, SIGNAL(currentIndexChanged(int)), this, SLOT(ammoChanged(int)));
-
- QPushButton * goToWeaponPage = new QPushButton(SchemeWidget);
- goToWeaponPage->setToolTip(tr("Edit weapons"));
- goToWeaponPage->setIconSize(pmEdit.size());
- goToWeaponPage->setIcon(pmEdit);
- goToWeaponPage->setMaximumWidth(pmEdit.width() + 6);
- SchemeWidgetLayout->addWidget(goToWeaponPage, 1, 3);
- connect(goToWeaponPage, SIGNAL(clicked()), this, SLOT(jumpToWeapons()));
-
- bindEntries = new QCheckBox(SchemeWidget);
- bindEntries->setToolTip(tr("When this option is enabled selecting a game scheme will auto-select a weapon"));
- bindEntries->setChecked(true);
- bindEntries->setMaximumWidth(42);
- bindEntries->setStyleSheet( "QCheckBox::indicator:checked { image: url(\":/res/lock.png\"); }"
- "QCheckBox::indicator:unchecked { image: url(\":/res/unlock.png\"); }" );
- SchemeWidgetLayout->addWidget(bindEntries, 0, 1, 0, 1, Qt::AlignVCenter);
-
- connect(pMapContainer, SIGNAL(seedChanged(const QString &)), this, SLOT(seedChanged(const QString &)));
- connect(pMapContainer, SIGNAL(mapChanged(const QString &)), this, SLOT(mapChanged(const QString &)));
- connect(pMapContainer, SIGNAL(mapgenChanged(MapGenerator)), this, SLOT(mapgenChanged(MapGenerator)));
- connect(pMapContainer, SIGNAL(mazeSizeChanged(int)), this, SLOT(maze_sizeChanged(int)));
- connect(pMapContainer, SIGNAL(themeChanged(const QString &)), this, SLOT(themeChanged(const QString &)));
- connect(pMapContainer, SIGNAL(newTemplateFilter(int)), this, SLOT(templateFilterChanged(int)));
- connect(pMapContainer, SIGNAL(drawMapRequested()), this, SIGNAL(goToDrawMap()));
- connect(pMapContainer, SIGNAL(drawnMapChanged(const QByteArray &)), this, SLOT(onDrawnMapChanged(const QByteArray &)));
-}
-
-void GameCFGWidget::jumpToSchemes()
-{
- emit goToSchemes(GameSchemes->currentIndex());
-}
-
-void GameCFGWidget::jumpToWeapons()
-{
- emit goToWeapons(WeaponsName->currentIndex());
-}
-
-QVariant GameCFGWidget::schemeData(int column) const
-{
- return GameSchemes->model()->data(GameSchemes->model()->index(GameSchemes->currentIndex(), column));
-}
-
-quint32 GameCFGWidget::getGameFlags() const
-{
- quint32 result = 0;
-
- if (schemeData(1).toBool())
- result |= 0x00001000; // fort
- if (schemeData(2).toBool())
- result |= 0x00000010; // divide teams
- if (schemeData(3).toBool())
- result |= 0x00000004; // solid land
- if (schemeData(4).toBool())
- result |= 0x00000008; // border
- if (schemeData(5).toBool())
- result |= 0x00000020; // low gravity
- if (schemeData(6).toBool())
- result |= 0x00000040; // laser sight
- if (schemeData(7).toBool())
- result |= 0x00000080; // invulnerable
- if (schemeData(8).toBool())
- result |= 0x00000100; // mines
- if (schemeData(9).toBool())
- result |= 0x00000200; // vampirism
- if (schemeData(10).toBool())
- result |= 0x00000400; // karma
- if (schemeData(11).toBool())
- result |= 0x00000800; // artillery
- if (schemeData(12).toBool())
- result |= 0x00002000; // random
- if (schemeData(13).toBool())
- result |= 0x00004000; // king
- if (schemeData(14).toBool())
- result |= 0x00008000; // place hogs
- if (schemeData(15).toBool())
- result |= 0x00010000; // shared ammo
- if (schemeData(16).toBool())
- result |= 0x00020000; // disable girders
- if (schemeData(17).toBool())
- result |= 0x00040000; // disable land obj
- if (schemeData(18).toBool())
- result |= 0x00080000; // ai survival
- if (schemeData(19).toBool())
- result |= 0x00100000; // infinite attacks
- if (schemeData(20).toBool())
- result |= 0x00200000; // reset weaps
- if (schemeData(21).toBool())
- result |= 0x00400000; // per hog ammo
- if (schemeData(22).toBool())
- result |= 0x00800000; // no wind
- if (schemeData(23).toBool())
- result |= 0x01000000; // more wind
- if (schemeData(24).toBool())
- result |= 0x02000000; // tag team
- if (schemeData(25).toBool())
- result |= 0x04000000; // bottom border
-
- return result;
-}
-
-quint32 GameCFGWidget::getInitHealth() const
-{
- return schemeData(28).toInt();
-}
-
-QByteArray GameCFGWidget::getFullConfig() const
-{
- QList bcfg;
- int mapgen = pMapContainer->get_mapgen();
-
- QString currentMap = pMapContainer->getCurrentMap();
- if (currentMap.size() > 0)
- {
- bcfg << QString("emap " + currentMap).toUtf8();
- if(pMapContainer->getCurrentIsMission())
- bcfg << QString("escript Maps/%1/map.lua").arg(currentMap).toUtf8();
- }
- bcfg << QString("etheme " + pMapContainer->getCurrentTheme()).toUtf8();
-
- if (Scripts->currentIndex() > 0)
- {
- bcfg << QString("escript Scripts/Multiplayer/%1.lua").arg(Scripts->itemData(Scripts->currentIndex()).toList()[0].toString()).toUtf8();
- }
-
- bcfg << QString("eseed " + pMapContainer->getCurrentSeed()).toUtf8();
- bcfg << QString("e$gmflags %1").arg(getGameFlags()).toUtf8();
- bcfg << QString("e$damagepct %1").arg(schemeData(26).toInt()).toUtf8();
- bcfg << QString("e$turntime %1").arg(schemeData(27).toInt() * 1000).toUtf8();
- bcfg << QString("e$sd_turns %1").arg(schemeData(29).toInt()).toUtf8();
- bcfg << QString("e$casefreq %1").arg(schemeData(30).toInt()).toUtf8();
- bcfg << QString("e$minestime %1").arg(schemeData(31).toInt() * 1000).toUtf8();
- bcfg << QString("e$minesnum %1").arg(schemeData(32).toInt()).toUtf8();
- bcfg << QString("e$minedudpct %1").arg(schemeData(33).toInt()).toUtf8();
- bcfg << QString("e$explosives %1").arg(schemeData(34).toInt()).toUtf8();
- bcfg << QString("e$healthprob %1").arg(schemeData(35).toInt()).toUtf8();
- bcfg << QString("e$hcaseamount %1").arg(schemeData(36).toInt()).toUtf8();
- bcfg << QString("e$waterrise %1").arg(schemeData(37).toInt()).toUtf8();
- bcfg << QString("e$healthdec %1").arg(schemeData(38).toInt()).toUtf8();
- bcfg << QString("e$ropepct %1").arg(schemeData(39).toInt()).toUtf8();
- bcfg << QString("e$getawaytime %1").arg(schemeData(40).toInt()).toUtf8();
- bcfg << QString("e$template_filter %1").arg(pMapContainer->getTemplateFilter()).toUtf8();
- bcfg << QString("e$mapgen %1").arg(mapgen).toUtf8();
-
- switch (mapgen)
- {
- case MAPGEN_MAZE:
- bcfg << QString("e$maze_size %1").arg(pMapContainer->getMazeSize()).toUtf8();
- break;
-
- case MAPGEN_DRAWN:
- {
- QByteArray data = pMapContainer->getDrawnMapData();
- while(data.size() > 0)
- {
- QByteArray tmp = data;
- tmp.truncate(200);
- tmp.prepend("edraw ");
- bcfg << tmp;
- data.remove(0, 200);
- }
- break;
- }
- default: ;
- }
-
- QByteArray result;
-
- foreach(QByteArray ba, bcfg)
- HWProto::addByteArrayToBuffer(result, ba);
-
- return result;
-}
-
-void GameCFGWidget::setNetAmmo(const QString& name, const QString& ammo)
-{
- bool illegal = ammo.size() != cDefaultAmmoStore->size();
- if (illegal)
- QMessageBox::critical(this, tr("Error"), tr("Illegal ammo scheme"));
-
- int pos = WeaponsName->findText(name);
- if ((pos == -1) || illegal) { // prevent from overriding schemes with bad ones
- WeaponsName->addItem(name, ammo);
- WeaponsName->setCurrentIndex(WeaponsName->count() - 1);
- } else {
- WeaponsName->setItemData(pos, ammo);
- WeaponsName->setCurrentIndex(pos);
- }
-}
-
-void GameCFGWidget::fullNetConfig()
-{
- ammoChanged(WeaponsName->currentIndex());
-
- seedChanged(pMapContainer->getCurrentSeed());
- templateFilterChanged(pMapContainer->getTemplateFilter());
- themeChanged(pMapContainer->getCurrentTheme());
-
- schemeChanged(GameSchemes->currentIndex());
- scriptChanged(Scripts->currentIndex());
-
- mapgenChanged(pMapContainer->get_mapgen());
- maze_sizeChanged(pMapContainer->getMazeSize());
-
- // map must be the last
- QString map = pMapContainer->getCurrentMap();
- if (map.size())
- mapChanged(map);
-}
-
-void GameCFGWidget::setParam(const QString & param, const QStringList & slValue)
-{
- if (slValue.size() == 1)
- {
- QString value = slValue[0];
- if (param == "MAP") {
- pMapContainer->setMap(value);
- return;
- }
- if (param == "SEED") {
- pMapContainer->setSeed(value);
- if (!seedRegexp.exactMatch(value)) {
- pMapContainer->seedEdit->setVisible(true);
- }
- return;
- }
- if (param == "THEME") {
- pMapContainer->setTheme(value);
- return;
- }
- if (param == "TEMPLATE") {
- pMapContainer->setTemplateFilter(value.toUInt());
- return;
- }
- if (param == "MAPGEN") {
- pMapContainer->setMapgen((MapGenerator)value.toUInt());
- return;
- }
- if (param == "MAZE_SIZE") {
- pMapContainer->setMazeSize(value.toUInt());
- return;
- }
- if (param == "SCRIPT") {
- Scripts->setCurrentIndex(Scripts->findText(value));
- return;
- }
- if (param == "DRAWNMAP") {
- pMapContainer->setDrawnMapData(qUncompress(QByteArray::fromBase64(slValue[0].toLatin1())));
- return;
- }
- }
-
- if (slValue.size() == 2)
- {
- if (param == "AMMO") {
- setNetAmmo(slValue[0], slValue[1]);
- return;
- }
- }
-
- if (slValue.size() == 5)
- {
- if (param == "FULLMAPCONFIG")
- {
- QString seed = slValue[3];
- if (!seedRegexp.exactMatch(seed))
- pMapContainer->seedEdit->setVisible(true);
-
- pMapContainer->setAllMapParameters(
- slValue[0],
- (MapGenerator)slValue[1].toUInt(),
- slValue[2].toUInt(),
- seed,
- slValue[4].toUInt()
- );
- return;
- }
- }
-
- qWarning("Got bad config param from net");
-}
-
-void GameCFGWidget::ammoChanged(int index)
-{
- if (index >= 0) {
- emit paramChanged(
- "AMMO",
- QStringList() << WeaponsName->itemText(index) << WeaponsName->itemData(index).toString()
- );
- }
-}
-
-void GameCFGWidget::mapChanged(const QString & value)
-{
- if(isEnabled() && pMapContainer->getCurrentIsMission())
- {
- Scripts->setEnabled(false);
- Scripts->setCurrentIndex(0);
-
- if (pMapContainer->getCurrentScheme() == "locked")
- {
- GameSchemes->setEnabled(false);
- GameSchemes->setCurrentIndex(GameSchemes->findText("Default"));
- }
- else
- {
- GameSchemes->setEnabled(true);
- int num = GameSchemes->findText(pMapContainer->getCurrentScheme());
- if (num != -1)
- GameSchemes->setCurrentIndex(num);
- else
- GameSchemes->setCurrentIndex(GameSchemes->findText("Default"));
- }
-
- if (pMapContainer->getCurrentWeapons() == "locked")
- {
- WeaponsName->setEnabled(false);
- WeaponsName->setCurrentIndex(WeaponsName->findText("Default"));
- }
- else
- {
- WeaponsName->setEnabled(true);
- int num = WeaponsName->findText(pMapContainer->getCurrentWeapons());
- if (num != -1)
- WeaponsName->setCurrentIndex(num);
- else
- WeaponsName->setCurrentIndex(WeaponsName->findText("Default"));
- }
-
- if (pMapContainer->getCurrentScheme() != "locked" && pMapContainer->getCurrentWeapons() != "locked")
- bindEntries->setEnabled(true);
- else
- bindEntries->setEnabled(false);
- }
- else
- {
- Scripts->setEnabled(true);
- GameSchemes->setEnabled(true);
- WeaponsName->setEnabled(true);
- bindEntries->setEnabled(true);
- }
- emit paramChanged("MAP", QStringList(value));
-}
-
-void GameCFGWidget::templateFilterChanged(int value)
-{
- emit paramChanged("TEMPLATE", QStringList(QString::number(value)));
-}
-
-void GameCFGWidget::seedChanged(const QString & value)
-{
- emit paramChanged("SEED", QStringList(value));
-}
-
-void GameCFGWidget::themeChanged(const QString & value)
-{
- emit paramChanged("THEME", QStringList(value));
-}
-
-void GameCFGWidget::schemeChanged(int index)
-{
- QStringList sl;
-
- int size = GameSchemes->model()->columnCount();
- for(int i = 0; i < size; ++i)
- sl << schemeData(i).toString();
-
- emit paramChanged("SCHEME", sl);
-
- if (isEnabled() && bindEntries->isEnabled() && bindEntries->isChecked()) {
- QString schemeName = GameSchemes->itemText(index);
- for (int i = 0; i < WeaponsName->count(); i++) {
- QString weapName = WeaponsName->itemText(i);
- int res = QString::compare(weapName, schemeName, Qt::CaseSensitive);
- if (0 == res) {
- WeaponsName->setCurrentIndex(i);
- emit ammoChanged(i);
- break;
- }
- }
- }
-}
-
-void GameCFGWidget::scriptChanged(int index)
-{
- if(isEnabled() && index > 0)
- {
- QString scheme = Scripts->itemData(Scripts->currentIndex()).toList()[1].toString();
- QString weapons = Scripts->itemData(Scripts->currentIndex()).toList()[2].toString();
-
- if (scheme == "locked")
- {
- GameSchemes->setEnabled(false);
- GameSchemes->setCurrentIndex(GameSchemes->findText("Default"));
- }
- else
- {
- GameSchemes->setEnabled(true);
- int num = GameSchemes->findText(scheme);
- if (num != -1)
- GameSchemes->setCurrentIndex(num);
- else
- GameSchemes->setCurrentIndex(GameSchemes->findText("Default"));
- }
-
- if (weapons == "locked")
- {
- WeaponsName->setEnabled(false);
- WeaponsName->setCurrentIndex(WeaponsName->findText("Default"));
- }
- else
- {
- WeaponsName->setEnabled(true);
- int num = WeaponsName->findText(weapons);
- if (num != -1)
- WeaponsName->setCurrentIndex(num);
- else
- WeaponsName->setCurrentIndex(WeaponsName->findText("Default"));
- }
-
- if (scheme != "locked" && weapons != "locked")
- bindEntries->setEnabled(true);
- else
- bindEntries->setEnabled(false);
- }
- else
- {
- GameSchemes->setEnabled(true);
- WeaponsName->setEnabled(true);
- bindEntries->setEnabled(true);
- }
- emit paramChanged("SCRIPT", QStringList(Scripts->itemText(index)));
-}
-
-void GameCFGWidget::mapgenChanged(MapGenerator m)
-{
- emit paramChanged("MAPGEN", QStringList(QString::number(m)));
-}
-
-void GameCFGWidget::maze_sizeChanged(int s)
-{
- emit paramChanged("MAZE_SIZE", QStringList(QString::number(s)));
-}
-
-void GameCFGWidget::resendSchemeData()
-{
- schemeChanged(GameSchemes->currentIndex());
-}
-
-void GameCFGWidget::onDrawnMapChanged(const QByteArray & data)
-{
- emit paramChanged("DRAWNMAP", QStringList(qCompress(data, 9).toBase64()));
-}
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/gamecfgwidget.h
--- a/QTfrontend/gamecfgwidget.h Sat Oct 08 16:45:52 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2006-2011 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
-#include
-
-#include "mapContainer.h"
-
-class QCheckBox;
-class QVBoxLayout;
-class QLabel;
-class QTableView;
-
-class GameCFGWidget : public QGroupBox
-{
- Q_OBJECT
-
-public:
- GameCFGWidget(QWidget* parent);
- quint32 getGameFlags() const;
- quint32 getInitHealth() const;
- QByteArray getFullConfig() const;
- QComboBox * Scripts;
- QComboBox * GameSchemes;
- QComboBox * WeaponsName;
- HWMapContainer* pMapContainer;
- QTableView * tv;
- QVariant schemeData(int column) const;
-
-public slots:
- void setParam(const QString & param, const QStringList & value);
- void fullNetConfig();
- void resendSchemeData();
-
-signals:
- void paramChanged(const QString & param, const QStringList & value);
- void goToSchemes(int);
- void goToWeapons(int);
- void goToDrawMap();
-
-private slots:
- void ammoChanged(int index);
- void mapChanged(const QString &);
- void templateFilterChanged(int);
- void seedChanged(const QString &);
- void themeChanged(const QString &);
- void schemeChanged(int);
- void scriptChanged(int);
- void jumpToSchemes();
- void jumpToWeapons();
- void mapgenChanged(MapGenerator m);
- void maze_sizeChanged(int s);
- void onDrawnMapChanged(const QByteArray & data);
-
-private:
- QGridLayout mainLayout;
- QCheckBox * bindEntries;
- QString curNetAmmoName;
- QString curNetAmmo;
- QRegExp seedRegexp;
-
- void setNetAmmo(const QString& name, const QString& ammo);
-
-};
-
-#endif // GAMECONFIGWIDGET_H
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/hats.cpp
--- a/QTfrontend/hats.cpp Sat Oct 08 16:45:52 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,142 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2008-2011 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 "hwconsts.h"
-#include "hwform.h"
-#include "hats.h"
-
-HatsModel::HatsModel(QObject* parent) :
- QAbstractListModel(parent)
-{
- QFile hhfile;
- hhfile.setFileName(cfgdir->absolutePath() + "/Data/Graphics/Hedgehog/Idle.png");
- if (!hhfile.exists()) hhfile.setFileName(datadir->absolutePath() + "/Graphics/Hedgehog/Idle.png");
- QPixmap hhpix = QPixmap(QFileInfo(hhfile).absoluteFilePath()).copy(0, 0, 32, 32);
-
- QDir tmpdir;
- tmpdir.cd(cfgdir->absolutePath());
- tmpdir.cd("Data");
- tmpdir.cd("Graphics");
- tmpdir.cd("Hats");
-
- tmpdir.setFilter(QDir::Files);
-
- QStringList userhatsList = tmpdir.entryList(QStringList("*.png"));
- for (QStringList::Iterator it = userhatsList.begin(); it != userhatsList.end(); ++it )
- {
- QString str = QString(*it).replace(QRegExp("^(.*)\\.png"), "\\1");
- QPixmap pix(cfgdir->absolutePath() + "/Data/Graphics/Hats/" + str + ".png");
-
- QPixmap tmppix(32, 37);
- tmppix.fill(QColor(Qt::transparent));
-
- QPainter painter(&tmppix);
- painter.drawPixmap(QPoint(0, 5), hhpix);
- painter.drawPixmap(QPoint(0, 0), pix.copy(0, 0, 32, 32));
- if(pix.width() > 32)
- painter.drawPixmap(QPoint(0, 0), pix.copy(32, 0, 32, 32));
- painter.end();
-
- hats.append(qMakePair(str, QIcon(tmppix)));
- }
-
- tmpdir.cd(datadir->absolutePath());
- tmpdir.cd("Graphics");
- tmpdir.cd("Hats");
-
- QStringList hatsList = tmpdir.entryList(QStringList("*.png"));
- for (QStringList::Iterator it = hatsList.begin(); it != hatsList.end(); ++it )
- {
- if (userhatsList.contains(*it,Qt::CaseInsensitive)) continue;
- QString str = (*it).replace(QRegExp("^(.*)\\.png"), "\\1");
- QPixmap pix(datadir->absolutePath() + "/Graphics/Hats/" + str + ".png");
-
- QPixmap tmppix(32, 37);
- tmppix.fill(QColor(Qt::transparent));
-
- QPainter painter(&tmppix);
- painter.drawPixmap(QPoint(0, 5), hhpix);
- painter.drawPixmap(QPoint(0, 0), pix.copy(0, 0, 32, 32));
- if(pix.width() > 32)
- painter.drawPixmap(QPoint(0, 0), pix.copy(32, 0, 32, 32));
- painter.end();
-
- hats.append(qMakePair(str, QIcon(tmppix)));
- }
- // Reserved hats
- tmpdir.cd("Reserved");
- hatsList = tmpdir.entryList(QStringList(playerHash+"*.png"));
- for (QStringList::Iterator it = hatsList.begin(); it != hatsList.end(); ++it )
- {
- QString str = (*it).replace(QRegExp("^(.*)\\.png"), "\\1");
- QPixmap pix(datadir->absolutePath() + "/Graphics/Hats/Reserved/" + str + ".png");
-
- QPixmap tmppix(32, 37);
- tmppix.fill(QColor(Qt::transparent));
-
- QPainter painter(&tmppix);
- painter.drawPixmap(QPoint(0, 5), hhpix);
- painter.drawPixmap(QPoint(0, 0), pix.copy(0, 0, 32, 32));
- painter.end();
-
- hats.append(qMakePair("Reserved "+str.remove(0,32), QIcon(tmppix)));
- }
-}
-
-QVariant HatsModel::headerData(int section,
- Qt::Orientation orientation, int role) const
-{
- Q_UNUSED(section);
- Q_UNUSED(orientation);
- Q_UNUSED(role);
-
- return QVariant();
-}
-
-int HatsModel::rowCount(const QModelIndex &parent) const
-{
- if (parent.isValid())
- return 0;
- else
- return hats.size();
-}
-
-/*int HatsModel::columnCount(const QModelIndex & parent) const
-{
- if (parent.isValid())
- return 0;
- else
- return 2;
-}
-*/
-QVariant HatsModel::data(const QModelIndex &index,
- int role) const
-{
- if (!index.isValid() || index.row() < 0
- || index.row() >= hats.size()
- || (role != Qt::DisplayRole && role != Qt::DecorationRole))
- return QVariant();
-
- if (role == Qt::DisplayRole)
- return hats.at(index.row()).first;
- else // role == Qt::DecorationRole
- return hats.at(index.row()).second;
-}
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/hats.h
--- a/QTfrontend/hats.h Sat Oct 08 16:45:52 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2008-2011 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 _HATS_INCLUDED
-#define _HATS_INCLUDED
-
-#include
-#include
-#include
-#include
-#include
-
-class HatsModel : public QAbstractListModel
-{
- Q_OBJECT
-
-public:
- HatsModel(QObject *parent = 0);
-
- QVariant headerData(int section, Qt::Orientation orientation, int role) const;
- int rowCount(const QModelIndex & parent) const;
- //int columnCount(const QModelIndex & parent) const;
-
- QVariant data(const QModelIndex &index, int role) const;
-protected:
- QVector > hats;
-};
-
-#endif // _HATS_INCLUDED
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/hedgehogerWidget.cpp
--- a/QTfrontend/hedgehogerWidget.cpp Sat Oct 08 16:45:52 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2006-2008 Ulyanov Igor
- * Copyright (c) 2008-2011 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 "hedgehogerWidget.h"
-
-#include "frameTeam.h"
-
-CHedgehogerWidget::CHedgehogerWidget(const QImage& im, const QImage& img, QWidget * parent) :
- ItemNum(im, img, parent, 1)
-{
- // TODO: maxHedgehogsPerGame doesn't reset properly and won't match map limits for now
- /*if(parent) {
- pOurFrameTeams = dynamic_cast(parent->parentWidget());
- }
- if(pOurFrameTeams->overallHedgehogs + 4 > pOurFrameTeams->maxHedgehogsPerGame) {
- numItems = pOurFrameTeams->maxHedgehogsPerGame - pOurFrameTeams->overallHedgehogs;
- } else numItems = 4;
- pOurFrameTeams->overallHedgehogs += numItems;*/
-}
-
-void CHedgehogerWidget::incItems()
-{
- //if (pOurFrameTeams->overallHedgehogs < pOurFrameTeams->maxHedgehogsPerGame) {
- numItems++;
- //pOurFrameTeams->overallHedgehogs++;
- emit hedgehogsNumChanged();
- //}
-}
-
-void CHedgehogerWidget::decItems()
-{
- numItems--;
- //pOurFrameTeams->overallHedgehogs--;
- emit hedgehogsNumChanged();
-}
-
-CHedgehogerWidget::~CHedgehogerWidget()
-{
- // TODO: not called?
- //pOurFrameTeams->overallHedgehogs-=numItems;
-}
-
-void CHedgehogerWidget::setNonInteractive()
-{
- nonInteractive=true;
-}
-
-void CHedgehogerWidget::setHHNum(unsigned int num)
-{
- /*unsigned int diff = num - numItems;
- numItems += diff;
- pOurFrameTeams->overallHedgehogs += diff;*/
- numItems = num;
- repaint();
-}
-
-unsigned char CHedgehogerWidget::getHedgehogsNum() const
-{
- return numItems;
-}
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/hedgehogerWidget.h
--- a/QTfrontend/hedgehogerWidget.h Sat Oct 08 16:45:52 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2006-2007 Ulyanov Igor
- * Copyright (c) 2007-2011 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 _HEDGEHOGER_WIDGET
-#define _HEDGEHOGER_WIDGET
-
-#include "itemNum.h"
-
-class FrameTeams;
-
-class CHedgehogerWidget : public ItemNum
-{
- Q_OBJECT
-
- public:
- CHedgehogerWidget(const QImage& im, const QImage& img, QWidget * parent);
- virtual ~CHedgehogerWidget();
- unsigned char getHedgehogsNum() const;
- void setHHNum (unsigned int num);
- void setNonInteractive();
-
- signals:
- void hedgehogsNumChanged();
-
- protected:
- virtual void incItems();
- virtual void decItems();
-
- private:
- CHedgehogerWidget();
- FrameTeams* pOurFrameTeams;
-};
-
-#endif // _HEDGEHOGER_WIDGET
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/hedgewars.qrc
--- a/QTfrontend/hedgewars.qrc Sat Oct 08 16:45:52 2011 +0200
+++ b/QTfrontend/hedgewars.qrc Sat Oct 08 16:54:56 2011 +0200
@@ -45,6 +45,7 @@
res/unchecked.png
res/graphicsicon.png
res/miscicon.png
+ res/Load.png
res/Save.png
res/Record.png
res/weaponsicon.png
@@ -57,31 +58,31 @@
res/PlaySound.png
res/hh_small.png
res/btnDisabled.png
- res/btnForts.png
- res/btnBorder.png
- res/btnInvulnerable.png
- res/btnLaserSight.png
- res/btnLowGravity.png
- res/btnResetHealth.png
- res/btnTeamsDivide.png
- res/btnSolid.png
- res/btnVampiric.png
- res/btnKarma.png
- res/btnArtillery.png
- res/btnRandomOrder.png
- res/btnKing.png
- res/btnPlaceHog.png
- res/btnSharedAmmo.png
- res/btnDisableGirders.png
- res/btnDisableLandObjects.png
- res/btnAISurvival.png
- res/btnInfAttack.png
- res/btnResetWeps.png
- res/btnPerHogAmmo.png
- res/btnNoWind.png
- res/btnMoreWind.png
- res/btnTagTeam.png
- res/btnBottomBorder.png
+ res/btnForts@2x.png
+ res/btnBorder@2x.png
+ res/btnInvulnerable@2x.png
+ res/btnLaserSight@2x.png
+ res/btnLowGravity@2x.png
+ res/btnResetHealth@2x.png
+ res/btnTeamsDivide@2x.png
+ res/btnSolid@2x.png
+ res/btnVampiric@2x.png
+ res/btnKarma@2x.png
+ res/btnArtillery@2x.png
+ res/btnRandomOrder@2x.png
+ res/btnKing@2x.png
+ res/btnPlaceHog@2x.png
+ res/btnSharedAmmo@2x.png
+ res/btnDisableGirders@2x.png
+ res/btnDisableLandObjects@2x.png
+ res/btnAISurvival@2x.png
+ res/btnInfAttack@2x.png
+ res/btnResetWeps@2x.png
+ res/btnPerHogAmmo@2x.png
+ res/btnNoWind@2x.png
+ res/btnMoreWind@2x.png
+ res/btnTagTeam@2x.png
+ res/btnBottomBorder@2x.png
res/iconBox.png
res/iconHealth.png
res/iconSuddenDeath.png
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/hwconsts.h
--- a/QTfrontend/hwconsts.h Sat Oct 08 16:45:52 2011 +0200
+++ b/QTfrontend/hwconsts.h Sat Oct 08 16:54:56 2011 +0200
@@ -58,6 +58,8 @@
extern bool isDevBuild;
#endif
+#define HEDGEHOGS_PER_TEAM 8
+
#define AMMOLINE_DEFAULT_QT "939192942219912103223511100120100000021111010101111101"
#define AMMOLINE_DEFAULT_PROB "040504054160065554655446477657666666615551010111541101"
#define AMMOLINE_DEFAULT_DELAY "000000000000020550000004000700400000000022000000060000"
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/hwform.cpp
--- a/QTfrontend/hwform.cpp Sat Oct 08 16:45:52 2011 +0200
+++ b/QTfrontend/hwform.cpp Sat Oct 08 16:54:56 2011 +0200
@@ -16,6 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
+#include
#include
#include
#include
@@ -43,7 +44,6 @@
#include "hwform.h"
#include "game.h"
#include "team.h"
-#include "namegen.h"
#include "teamselect.h"
#include "selectWeapon.h"
#include "gameuiconfig.h"
@@ -93,7 +93,7 @@
bool frontendEffects = true;
QString playerHash;
-HWForm::HWForm(QWidget *parent)
+HWForm::HWForm(QWidget *parent, QString styleSheet)
: QMainWindow(parent), pnetserver(0), pRegisterServer(0), editedTeam(0), hwnet(0)
{
#ifdef USE_XFIRE
@@ -104,6 +104,7 @@
frontendEffects = gameSettings->value("frontend/effects", true).toBool();
playerHash = QString(QCryptographicHash::hash(gameSettings->value("net/nick","").toString().toLatin1(), QCryptographicHash::Md5).toHex());
+ this->setStyleSheet(styleSheet);
ui.setupUi(this);
setMinimumSize(760, 580);
//setFocusPolicy(Qt::StrongFocus);
@@ -113,7 +114,6 @@
config = new GameUIConfig(this, cfgdir->absolutePath() + "/hedgewars.ini");
- namegen = new HWNamegen();
#ifdef __APPLE__
panel = new M3Panel;
@@ -138,6 +138,12 @@
UpdateCampaignPage(0);
UpdateWeapons();
+ // connect all goBack signals
+ int nPages = ui.Pages->count();
+
+ for (int i = 0; i < nPages; i++)
+ connect(ui.Pages->widget(i), SIGNAL(goBack()), this, SLOT(GoBack()));
+
pageSwitchMapper = new QSignalMapper(this);
connect(pageSwitchMapper, SIGNAL(mapped(int)), this, SLOT(GoToPage(int)));
@@ -159,19 +165,11 @@
connect(ui.pageMain->BtnDataDownload, SIGNAL(clicked()), pageSwitchMapper, SLOT(map()));
pageSwitchMapper->setMapping(ui.pageMain->BtnDataDownload, ID_PAGE_DATADOWNLOAD);
- connect(ui.pageMain->BtnExit, SIGNAL(pressed()), this, SLOT(btnExitPressed()));
- connect(ui.pageMain->BtnExit, SIGNAL(clicked()), this, SLOT(btnExitClicked()));
-
- connect(ui.pageInfo->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
- connect(ui.pageDataDownload->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
+ //connect(ui.pageMain->BtnExit, SIGNAL(pressed()), this, SLOT(btnExitPressed()));
+ //connect(ui.pageMain->BtnExit, SIGNAL(clicked()), this, SLOT(btnExitClicked()));
- connect(ui.pageEditTeam->BtnTeamSave, SIGNAL(clicked()), this, SLOT(TeamSave()));
- connect(ui.pageEditTeam->BtnTeamDiscard, SIGNAL(clicked()), this, SLOT(TeamDiscard()));
+ connect(ui.pageEditTeam, SIGNAL(teamEdited()), this, SLOT(AfterTeamEdit()));
- connect(ui.pageEditTeam->signalMapper, SIGNAL(mapped(const int &)), this, SLOT(RandomName(const int &)));
- connect(ui.pageEditTeam->randTeamButton, SIGNAL(clicked()), this, SLOT(RandomNames()));
-
- connect(ui.pageMultiplayer->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
connect(ui.pageMultiplayer->BtnStartMPGame, SIGNAL(clicked()), this, SLOT(StartMPGame()));
connect(ui.pageMultiplayer->teamsSelect, SIGNAL(setEnabledGameStart(bool)),
ui.pageMultiplayer->BtnStartMPGame, SLOT(setEnabled(bool)));
@@ -180,18 +178,16 @@
connect(ui.pageMultiplayer->gameCFG, SIGNAL(goToWeapons(int)), this, SLOT(GoToSelectWeaponSet(int)));
connect(ui.pageMultiplayer->gameCFG, SIGNAL(goToDrawMap()), pageSwitchMapper, SLOT(map()));
pageSwitchMapper->setMapping(ui.pageMultiplayer->gameCFG, ID_PAGE_DRAWMAP);
-
- connect(ui.pagePlayDemo->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
+
connect(ui.pagePlayDemo->BtnPlayDemo, SIGNAL(clicked()), this, SLOT(PlayDemo()));
connect(ui.pagePlayDemo->DemosList, SIGNAL(doubleClicked (const QModelIndex &)), this, SLOT(PlayDemo()));
- connect(ui.pageOptions->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
- connect(ui.pageOptions->BtnNewTeam, SIGNAL(clicked()), this, SLOT(NewTeam()));
- connect(ui.pageOptions->BtnEditTeam, SIGNAL(clicked()), this, SLOT(EditTeam()));
- connect(ui.pageOptions->BtnDeleteTeam, SIGNAL(clicked()), this, SLOT(DeleteTeam()));
- connect(ui.pageOptions->BtnSaveOptions, SIGNAL(clicked()), config, SLOT(SaveOptions()));
- connect(ui.pageOptions->BtnSaveOptions, SIGNAL(clicked()), this, SLOT(GoBack()));
+ connect(ui.pageOptions, SIGNAL(newTeamRequested()), this, SLOT(NewTeam()));
+ connect(ui.pageOptions, SIGNAL(editTeamRequested(const QString&)), this, SLOT(EditTeam(const QString&)));
+ connect(ui.pageOptions, SIGNAL(deleteTeamRequested(const QString&)), this, SLOT(DeleteTeam(const QString&)));
+ connect(ui.pageOptions->btnSave, SIGNAL(clicked()), config, SLOT(SaveOptions()));
+ connect(ui.pageOptions->btnSave, SIGNAL(clicked()), this, SLOT(GoBack()));
connect(ui.pageOptions->BtnAssociateFiles, SIGNAL(clicked()), this, SLOT(AssociateFiles()));
connect(ui.pageOptions->WeaponEdit, SIGNAL(clicked()), this, SLOT(GoToSelectWeapon()));
@@ -202,17 +198,14 @@
connect(ui.pageOptions->SchemeDelete, SIGNAL(clicked()), this, SLOT(DeleteScheme()));
connect(ui.pageSelectWeapon->pWeapons, SIGNAL(weaponsChanged()), this, SLOT(UpdateWeapons()));
- connect(ui.pageNet->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
connect(ui.pageNet->BtnSpecifyServer, SIGNAL(clicked()), this, SLOT(NetConnect()));
connect(ui.pageNet->BtnNetSvrStart, SIGNAL(clicked()), pageSwitchMapper, SLOT(map()));
pageSwitchMapper->setMapping(ui.pageNet->BtnNetSvrStart, ID_PAGE_NETSERVER);
connect(ui.pageNet, SIGNAL(connectClicked(const QString &, quint16)), this, SLOT(NetConnectServer(const QString &, quint16)));
- connect(ui.pageNetServer->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
connect(ui.pageNetServer->BtnStart, SIGNAL(clicked()), this, SLOT(NetStartServer()));
- connect(ui.pageNetGame->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(setEnabledGameStart(bool)),
ui.pageNetGame->BtnStart, SLOT(setEnabled(bool)));
connect(ui.pageNetGame, SIGNAL(SetupClicked()), this, SLOT(IntermediateSetup()));
@@ -221,14 +214,11 @@
connect(ui.pageNetGame->pGameCFG, SIGNAL(goToDrawMap()), pageSwitchMapper, SLOT(map()));
pageSwitchMapper->setMapping(ui.pageNetGame->pGameCFG, ID_PAGE_DRAWMAP);
- connect(ui.pageRoomsList->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
connect(ui.pageRoomsList->BtnAdmin, SIGNAL(clicked()), pageSwitchMapper, SLOT(map()));
pageSwitchMapper->setMapping(ui.pageRoomsList->BtnAdmin, ID_PAGE_ADMIN);
connect(ui.pageInfo->BtnSnapshots, SIGNAL(clicked()), this, SLOT(OpenSnapshotFolder()));
- connect(ui.pageInfo->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
- connect(ui.pageGameStats->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
connect(ui.pageGameStats, SIGNAL(saveDemoRequested()), this, SLOT(saveDemoWithCustomName()));
connect(ui.pageSinglePlayer->BtnSimpleGamePage, SIGNAL(clicked()), this, SLOT(SimpleGame()));
@@ -243,16 +233,12 @@
connect(ui.pageSinglePlayer->BtnLoad, SIGNAL(clicked()), this, SLOT(GoToSaves()));
connect(ui.pageSinglePlayer->BtnDemos, SIGNAL(clicked()), this, SLOT(GoToDemos()));
- connect(ui.pageSinglePlayer->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
- connect(ui.pageTraining->BtnStartTrain, SIGNAL(clicked()), this, SLOT(StartTraining()));
- connect(ui.pageTraining->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
+ connect(ui.pageTraining, SIGNAL(startMission(const QString&)), this, SLOT(startTraining(const QString&)));
connect(ui.pageCampaign->BtnStartCampaign, SIGNAL(clicked()), this, SLOT(StartCampaign()));
- connect(ui.pageCampaign->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
connect(ui.pageCampaign->CBTeam, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateCampaignPage(int)));
- connect(ui.pageSelectWeapon->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
connect(ui.pageSelectWeapon->BtnDelete, SIGNAL(clicked()),
ui.pageSelectWeapon->pWeapons, SLOT(deleteWeaponsName())); // executed first
@@ -261,16 +247,10 @@
//connect(ui.pageSelectWeapon->pWeapons, SIGNAL(weaponsDeleted()),
// this, SLOT(GoBack())); // executed third
- connect(ui.pageScheme->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
- connect(ui.pageAdmin->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
-
- connect(ui.pageNetType->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
connect(ui.pageNetType->BtnLAN, SIGNAL(clicked()), this, SLOT(GoToNet()));
connect(ui.pageNetType->BtnOfficialServer, SIGNAL(clicked()), this, SLOT(NetConnectOfficialServer()));
- connect(ui.pageDrawMap->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
-
connect(ui.pageConnecting, SIGNAL(cancelConnection()), this, SLOT(GoBack()));
@@ -295,26 +275,27 @@
#ifdef USE_XFIRE
void HWForm::updateXfire(void)
{
- if(hwnet)
+ if(hwnet && (hwnet->clientState() != HWNewNet::Disconnected))
{
xfire_setvalue(XFIRE_SERVER, !hwnet->getHost().compare("netserver.hedgewars.org:46631") ? "Official server" : hwnet->getHost().toAscii());
- switch(hwnet->getClientState())
+ switch(hwnet->clientState())
{
- case 1: // Connecting
+ case HWNewNet::Connecting: // Connecting
+ case HWNewNet::Connected:
xfire_setvalue(XFIRE_STATUS, "Connecting");
xfire_setvalue(XFIRE_NICKNAME, "-");
xfire_setvalue(XFIRE_ROOM, "-");
- case 2: // In lobby
+ case HWNewNet::InLobby: // In lobby
xfire_setvalue(XFIRE_STATUS, "Online");
xfire_setvalue(XFIRE_NICKNAME, hwnet->getNick().toAscii());
xfire_setvalue(XFIRE_ROOM, "In game lobby");
break;
- case 3: // In room
+ case HWNewNet::InRoom: // In room
xfire_setvalue(XFIRE_STATUS, "Online");
xfire_setvalue(XFIRE_NICKNAME, hwnet->getNick().toAscii());
xfire_setvalue(XFIRE_ROOM, (hwnet->getRoom() + " (waiting for players)").toAscii());
break;
- case 5: // In game
+ case HWNewNet::InGame: // In game
xfire_setvalue(XFIRE_STATUS, "Online");
xfire_setvalue(XFIRE_NICKNAME, hwnet->getNick().toAscii());
xfire_setvalue(XFIRE_ROOM, (hwnet->getRoom() + " (playing or spectating)").toAscii());
@@ -398,7 +379,7 @@
if(teamslist.empty()) {
HWTeam defaultTeam(tr("DefaultTeam"));
- defaultTeam.SaveToFile();
+ defaultTeam.saveToFile();
teamslist.push_back(tr("DefaultTeam"));
}
@@ -490,11 +471,7 @@
if (id == ID_PAGE_MULTIPLAYER || id == ID_PAGE_NETGAME) {
QStringList tmNames = config->GetTeamsList();
TeamSelWidget* curTeamSelWidget;
- ui.pageOptions->BtnNewTeam->setVisible(false);
- ui.pageOptions->BtnEditTeam->setVisible(false);
- ui.pageOptions->BtnDeleteTeam->setVisible(false);
- ui.pageOptions->CBTeamName->setVisible(false);
- ui.pageOptions->LblNoEditTeam->setVisible(true);
+ ui.pageOptions->setTeamOptionsEnabled(false);
if (id == ID_PAGE_MULTIPLAYER) {
curTeamSelWidget = ui.pageMultiplayer->teamsSelect;
@@ -505,7 +482,7 @@
QList teamsList;
for (QStringList::iterator it = tmNames.begin(); it != tmNames.end(); it++) {
HWTeam team(*it);
- team.LoadFromFile();
+ team.loadFromFile();
teamsList.push_back(team);
}
@@ -525,11 +502,7 @@
}
if (id == ID_PAGE_MAIN) {
- ui.pageOptions->BtnNewTeam->setVisible(true);
- ui.pageOptions->BtnEditTeam->setVisible(true);
- ui.pageOptions->BtnDeleteTeam->setVisible(true);
- ui.pageOptions->CBTeamName->setVisible(true);
- ui.pageOptions->LblNoEditTeam->setVisible(false);
+ ui.pageOptions->setTeamOptionsEnabled(true);
}
// load and save ignore/friends lists
@@ -560,8 +533,11 @@
void HWForm::GoBack()
{
+ int curid = ui.Pages->currentIndex();
+ if (curid == ID_PAGE_MAIN)
+ exit();
+
int id = PagesStack.isEmpty() ? ID_PAGE_MAIN : PagesStack.pop();
- int curid = ui.Pages->currentIndex();
ui.Pages->setCurrentIndex(id);
OnPageShown(id, curid);
@@ -577,7 +553,7 @@
GoBack();
if (curid == ID_PAGE_ROOMSLIST || curid == ID_PAGE_CONNECTING) NetDisconnect();
- if (curid == ID_PAGE_NETGAME && hwnet) hwnet->partRoom();
+ if (curid == ID_PAGE_NETGAME && hwnet && hwnet->isInRoom()) hwnet->partRoom();
// need to work on this, can cause invalid state for admin quit trying to prevent bad state message on kick
//if (curid == ID_PAGE_NETGAME && (!game || game->gameState != gsStarted)) hwnet->partRoom();
@@ -596,14 +572,15 @@
eggTimer.start();
}
-void HWForm::btnExitClicked()
+void HWForm::exit()
{
- if (eggTimer.elapsed() < 3000){
+// if (eggTimer.elapsed() < 3000){
#ifdef __APPLE__
panel->showInstallController();
#endif
close();
- }
+// TODO reactivate egg
+/* }
else
{
QPushButton * btn = findChild("imageButt");
@@ -611,7 +588,7 @@
{
btn->setIcon(QIcon(":/res/bonus.png"));
}
- }
+ } */
}
void HWForm::IntermediateSetup()
@@ -628,7 +605,7 @@
QStringList tmnames;
foreach(HWTeam team, curTeamSelWidget->getNotPlayingTeams())
- tmnames += team.TeamName;
+ tmnames += team.name();
//UpdateTeamsLists(&tmnames); // FIXME: still need more work if teamname is updated while configuring
UpdateTeamsLists();
@@ -638,61 +615,30 @@
void HWForm::NewTeam()
{
- editedTeam = new HWTeam("unnamed");
- editedTeam->SetToPage(this);
- GoToPage(ID_PAGE_SETUP_TEAM);
-}
-
-void HWForm::EditTeam()
-{
- editedTeam = new HWTeam(ui.pageOptions->CBTeamName->currentText());
- editedTeam->LoadFromFile();
- editedTeam->SetToPage(this);
+ ui.pageEditTeam->createTeam(QLineEdit::tr("unnamed"), playerHash);
+ UpdateTeamsLists();
GoToPage(ID_PAGE_SETUP_TEAM);
}
-void HWForm::DeleteTeam()
+void HWForm::EditTeam(const QString & teamName)
{
- QMessageBox reallyDelete(QMessageBox::Question, QMessageBox::tr("Teams"), QMessageBox::tr("Really delete this team?"), QMessageBox::Ok | QMessageBox::Cancel);
-
- if (reallyDelete.exec() == QMessageBox::Ok) {
- editedTeam = new HWTeam(ui.pageOptions->CBTeamName->currentText());
- editedTeam->DeleteFile();
-
- // Remove from lists
- ui.pageOptions->CBTeamName->removeItem(ui.pageOptions->CBTeamName->currentIndex());
- }
+ ui.pageEditTeam->editTeam(teamName, playerHash);
+ GoToPage(ID_PAGE_SETUP_TEAM);
}
-void HWForm::RandomNames()
-{
- editedTeam->GetFromPage(this);
- namegen->TeamRandomNames(editedTeam, true);
- editedTeam->SetToPage(this);
-}
-
-void HWForm::RandomName(const int &i)
+void HWForm::AfterTeamEdit()
{
- editedTeam->GetFromPage(this);
- namegen->TeamRandomName(editedTeam,i);
- editedTeam->SetToPage(this);
-}
-
-void HWForm::TeamSave()
-{
- editedTeam->GetFromPage(this);
- editedTeam->SaveToFile();
- delete editedTeam;
- editedTeam=0;
UpdateTeamsLists();
GoBack();
}
-void HWForm::TeamDiscard()
+
+void HWForm::DeleteTeam(const QString & teamName)
{
- delete editedTeam;
- editedTeam=0;
- GoBack();
+ ui.pageEditTeam->deleteTeam(teamName);
+ QMessageBox reallyDelete(QMessageBox::Question, QMessageBox::tr("Teams"), QMessageBox::tr("Really delete this team?"), QMessageBox::Ok | QMessageBox::Cancel);
+
+ UpdateTeamsLists();
}
void HWForm::DeleteScheme()
@@ -730,7 +676,7 @@
return;
}
CreateGame(0, 0, 0);
- game->PlayDemo(curritem->data(Qt::UserRole).toString());
+ game->PlayDemo(curritem->data(Qt::UserRole).toString(), ui.pagePlayDemo->isSave());
}
void HWForm::PlayDemoQuick(const QString & demofilename)
@@ -739,7 +685,7 @@
GoBack(); //needed to cleanly disconnect from netgame
GoToPage(ID_PAGE_MAIN);
CreateGame(0, 0, 0);
- game->PlayDemo(demofilename);
+ game->PlayDemo(demofilename, false);
}
void HWForm::NetConnectServer(const QString & host, quint16 port)
@@ -752,7 +698,82 @@
NetConnectServer("netserver.hedgewars.org", 46631);
}
-void HWForm::_NetConnect(const QString & hostName, quint16 port, const QString & nick)
+void HWForm::NetPassword(const QString & nick)
+{
+ bool ok = false;
+ int passLength = config->value("net/passwordlength", 0).toInt();
+ QString hash = config->value("net/passwordhash", "").toString();
+
+ // If the password is blank, ask the user to enter one in
+ if (passLength == 0)
+ {
+ QString password = QInputDialog::getText(this, tr("Password"), tr("Your nickname %1 is\nregistered on Hedgewars.org\nPlease provide your password below\nor pick another nickname in game config:").arg(nick), QLineEdit::Password, passLength==0?NULL:QString(passLength,'\0'), &ok);
+
+ if (!ok) {
+ ForcedDisconnect(tr("No password supplied."));
+ return;
+ }
+
+ hash = QCryptographicHash::hash(password.toLatin1(), QCryptographicHash::Md5).toHex();
+ config->setValue("net/passwordhash", hash);
+ config->setValue("net/passwordlength", password.size());
+ config->setNetPasswordLength(password.size());
+ }
+
+ hwnet->SendPasswordHash(hash);
+}
+
+void HWForm::NetNickTaken(const QString & nick)
+{
+ bool ok = false;
+ QString newNick = QInputDialog::getText(this, tr("Nickname"), tr("Some one already uses\n your nickname %1\non the server.\nPlease pick another nickname:").arg(nick), QLineEdit::Normal, nick, &ok);
+
+ if (!ok || newNick.isEmpty()) {
+ ForcedDisconnect(tr("No nickname supplied."));
+ return;
+ }
+
+ hwnet->NewNick(newNick);
+ config->setValue("net/nick", newNick);
+ config->updNetNick();
+}
+
+void HWForm::NetAuthFailed()
+{
+ // Set the password blank if case the user tries to join and enter his password again
+ config->setValue("net/passwordlength", 0);
+ config->setNetPasswordLength(0);
+}
+
+void HWForm::NetTeamAccepted(const QString & team)
+{
+ ui.pageNetGame->pNetTeamsWidget->changeTeamStatus(team);
+}
+
+void HWForm::NetError(const QString & errmsg)
+{
+ switch (ui.Pages->currentIndex())
+ {
+ case ID_PAGE_INGAME:
+ ShowErrorMessage(errmsg);
+ // no break
+ case ID_PAGE_NETGAME:
+ ui.pageNetGame->pChatWidget->addLine("Error",errmsg);
+ break;
+ default:
+ ui.pageRoomsList->chatWidget->addLine("Error",errmsg);
+ }
+}
+
+void HWForm::NetWarning(const QString & wrnmsg)
+{
+ if (ui.Pages->currentIndex() == ID_PAGE_NETGAME || ui.Pages->currentIndex() == ID_PAGE_INGAME)
+ ui.pageNetGame->pChatWidget->addLine("Warning",wrnmsg);
+ else
+ ui.pageRoomsList->chatWidget->addLine("Warning",wrnmsg);
+}
+
+void HWForm::_NetConnect(const QString & hostName, quint16 port, QString nick)
{
if(hwnet) {
hwnet->Disconnect();
@@ -762,17 +783,22 @@
ui.pageRoomsList->chatWidget->clear();
- hwnet = new HWNewNet(config, ui.pageNetGame->pGameCFG, ui.pageNetGame->pNetTeamsWidget);
+ hwnet = new HWNewNet();
GoToPage(ID_PAGE_CONNECTING);
- connect(hwnet, SIGNAL(showMessage(const QString &)), this, SLOT(ShowErrorMessage(const QString &)), Qt::QueuedConnection);
-
connect(hwnet, SIGNAL(AskForRunGame()), this, SLOT(CreateNetGame()));
- connect(hwnet, SIGNAL(Connected()), this, SLOT(NetConnected()));
+ connect(hwnet, SIGNAL(connected()), this, SLOT(NetConnected()));
+ connect(hwnet, SIGNAL(Error(const QString&)), this, SLOT(NetError(const QString&)));
+ connect(hwnet, SIGNAL(Warning(const QString&)), this, SLOT(NetWarning(const QString&)));
connect(hwnet, SIGNAL(EnteredGame()), this, SLOT(NetGameEnter()));
- connect(hwnet, SIGNAL(LeftRoom()), this, SLOT(NetLeftRoom()));
+ connect(hwnet, SIGNAL(LeftRoom(const QString&)), this, SLOT(NetLeftRoom(const QString&)));
connect(hwnet, SIGNAL(AddNetTeam(const HWTeam&)), this, SLOT(AddNetTeam(const HWTeam&)));
+ connect(hwnet, SIGNAL(RemoveNetTeam(const HWTeam&)), this, SLOT(RemoveNetTeam(const HWTeam&)));
+ connect(hwnet, SIGNAL(TeamAccepted(const QString&)), this, SLOT(NetTeamAccepted(const QString&)));
+ connect(hwnet, SIGNAL(AskForPassword(const QString&)), this, SLOT(NetPassword(const QString&)));
+ connect(hwnet, SIGNAL(NickTaken(const QString&)), this, SLOT(NetNickTaken(const QString&)));
+ connect(hwnet, SIGNAL(AuthFailed()), this, SLOT(NetAuthFailed()));
//connect(ui.pageNetGame->BtnBack, SIGNAL(clicked()), hwnet, SLOT(partRoom()));
// rooms list page stuff
@@ -875,11 +901,25 @@
connect(ui.pageAdmin, SIGNAL(setServerMessageOld(const QString&)), hwnet, SLOT(setServerMessageOld(const QString &)));
connect(ui.pageAdmin, SIGNAL(setProtocol(int)), hwnet, SLOT(setLatestProtocolVar(int)));
connect(ui.pageAdmin, SIGNAL(askServerVars()), hwnet, SLOT(askServerVars()));
- connect(ui.pageAdmin->pbClearAccountsCache, SIGNAL(clicked()), hwnet, SLOT(clearAccountsCache()));
+ connect(ui.pageAdmin, SIGNAL(clearAccountsCache()), hwnet, SLOT(clearAccountsCache()));
// disconnect
- connect(hwnet, SIGNAL(Disconnected()), this, SLOT(ForcedDisconnect()), Qt::QueuedConnection);
+ connect(hwnet, SIGNAL(disconnected(const QString&)), this, SLOT(ForcedDisconnect(const QString&)), Qt::QueuedConnection);
+
+// config stuff
+ connect(hwnet, SIGNAL(paramChanged(const QString &, const QStringList &)), ui.pageNetGame->pGameCFG, SLOT(setParam(const QString &, const QStringList &)));
+ connect(ui.pageNetGame->pGameCFG, SIGNAL(paramChanged(const QString &, const QStringList &)), hwnet, SLOT(onParamChanged(const QString &, const QStringList &)));
+ connect(hwnet, SIGNAL(configAsked()), ui.pageNetGame->pGameCFG, SLOT(fullNetConfig()));
+ while (nick.isEmpty()) {
+ nick = QInputDialog::getText(this,
+ QObject::tr("Nickname"),
+ QObject::tr("Please enter your nickname"),
+ QLineEdit::Normal,
+ QDir::home().dirName());
+ config->setValue("net/nick",nick);
+ config->updNetNick();
+ }
hwnet->Connect(hostName, port, nick);
}
@@ -927,11 +967,6 @@
void HWForm::NetDisconnect()
{
- if(hwnet) {
- hwnet->Disconnect();
- delete hwnet;
- hwnet = 0;
- }
if(pnetserver) {
if (pRegisterServer)
{
@@ -945,15 +980,12 @@
}
}
-void HWForm::ForcedDisconnect()
+void HWForm::ForcedDisconnect(const QString & reason)
{
if(pnetserver) return; // we have server - let it care of all things
if (hwnet) {
- HWNewNet * tmp = hwnet;
- hwnet = 0;
- tmp->deleteLater();
QMessageBox::warning(this, QMessageBox::tr("Network"),
- QMessageBox::tr("Connection to server is lost"));
+ QMessageBox::tr("Connection to server is lost") + (reason.isEmpty()?"":("\n\n" + HWNewNet::tr("Quit reason: ") + '"' + reason +'"')));
}
if (ui.Pages->currentIndex() != ID_PAGE_NET) GoBack();
@@ -975,6 +1007,11 @@
ui.pageNetGame->pNetTeamsWidget->addTeam(team);
}
+void HWForm::RemoveNetTeam(const HWTeam& team)
+{
+ ui.pageNetGame->pNetTeamsWidget->removeNetTeam(team);
+}
+
void HWForm::StartMPGame()
{
QString ammo;
@@ -1089,11 +1126,11 @@
demofile.close();
}
-void HWForm::StartTraining()
+void HWForm::startTraining(const QString & scriptName)
{
CreateGame(0, 0, 0);
- game->StartTraining(ui.pageTraining->CBSelect->itemData(ui.pageTraining->CBSelect->currentIndex()).toString());
+ game->StartTraining(scriptName);
}
void HWForm::StartCampaign()
@@ -1140,6 +1177,9 @@
void HWForm::NetGameChangeStatus(bool isMaster)
{
+ ui.pageNetGame->pGameCFG->setEnabled(isMaster);
+ ui.pageNetGame->pNetTeamsWidget->setInteractivity(isMaster);
+
if (isMaster)
NetGameMaster();
else
@@ -1200,10 +1240,14 @@
ui.pageNetGame->pGameCFG->GameSchemes->setCurrentIndex(0);
}
-void HWForm::NetLeftRoom()
+void HWForm::NetLeftRoom(const QString & reason)
{
if (ui.Pages->currentIndex() == ID_PAGE_NETGAME || ui.Pages->currentIndex() == ID_PAGE_INGAME)
+ {
GoBack();
+ if (!reason.isEmpty())
+ ui.pageRoomsList->chatWidget->addLine("Notice",reason);
+ }
else
qWarning("Left room while not in room");
}
@@ -1231,7 +1275,8 @@
tmpdir.setFilter(QDir::Files);
QStringList userentries = tmpdir.entryList(QStringList("*#*.lua"));
//entries.sort();
- for(int i = 0; (i < userentries.count()) && (i <= team.CampaignProgress); i++)
+ unsigned int n = userentries.count();
+ for(unsigned int i = 0; (i < n) && (i <= team.campaignProgress()); i++)
ui.pageCampaign->CBSelect->addItem(QString(userentries[i]).replace(QRegExp("^(\\d+)#(.+)\\.lua"), QComboBox::tr("Mission") + " \\1: \\2").replace("_", " "), QString(userentries[i]).replace(QRegExp("^(.*)\\.lua"), "\\1"));
tmpdir.cd(datadir->absolutePath());
@@ -1239,7 +1284,8 @@
tmpdir.setFilter(QDir::Files);
QStringList entries = tmpdir.entryList(QStringList("*#*.lua"));
//entries.sort();
- for(int i = 0; (i < entries.count()) && (i <= team.CampaignProgress); i++) {
+ n = entries.count();
+ for(unsigned int i = 0; (i < n) && (i <= team.campaignProgress()); i++) {
if (userentries.contains(entries[i])) continue;
ui.pageCampaign->CBSelect->addItem(QString(entries[i]).replace(QRegExp("^(\\d+)#(.+)\\.lua"), QComboBox::tr("Mission") + " \\1: \\2").replace("_", " "), QString(entries[i]).replace(QRegExp("^(.*)\\.lua"), "\\1"));
}
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/hwform.h
--- a/QTfrontend/hwform.h Sat Oct 08 16:45:52 2011 +0200
+++ b/QTfrontend/hwform.h Sat Oct 08 16:54:56 2011 +0200
@@ -52,13 +52,14 @@
Q_OBJECT
public:
- HWForm(QWidget *parent = 0);
+ HWForm(QWidget *parent = 0, QString styleSheet = "");
Ui_HWForm ui;
SDLInteraction sdli;
GameUIConfig * config;
QSettings * gameSettings; // Same file GameUIConfig points to but without the baggage. Needs sync() calls if you want to get GameUIConfig changes though
void updateXfire();
void PlayDemoQuick(const QString & demofilename);
+ void exit();
private slots:
void GoToSaves();
@@ -76,20 +77,16 @@
QString getDemoArguments();
void AssociateFiles();
void btnExitPressed();
- void btnExitClicked();
void IntermediateSetup();
void NewTeam();
- void EditTeam();
- void DeleteTeam();
- void RandomNames();
- void RandomName(const int &i);
- void TeamSave();
- void TeamDiscard();
+ void EditTeam(const QString & teamName);
+ void AfterTeamEdit();
+ void DeleteTeam(const QString & teamName);
void DeleteScheme();
void DeleteWeaponSet();
void SimpleGame();
void PlayDemo();
- void StartTraining();
+ void startTraining(const QString&);
void StartCampaign();
void NetConnect();
void NetConnectServer(const QString & host, quint16 port);
@@ -97,11 +94,18 @@
void NetStartServer();
void NetDisconnect();
void NetConnected();
+ void NetError(const QString & errmsg);
+ void NetWarning(const QString & wrnmsg);
void NetGameEnter();
+ void NetPassword(const QString & nick);
+ void NetNickTaken(const QString & nick);
+ void NetAuthFailed();
+ void NetTeamAccepted(const QString& team);
void AddNetTeam(const HWTeam& team);
+ void RemoveNetTeam(const HWTeam& team);
void StartMPGame();
void GameStateChanged(GameState gameState);
- void ForcedDisconnect();
+ void ForcedDisconnect(const QString & reason);
void ShowErrorMessage(const QString &);
void GetRecord(bool isDemo, const QByteArray & record);
void CreateNetGame();
@@ -115,13 +119,13 @@
void NetGameSlave();
void AsyncNetServerStart();
- void NetLeftRoom();
+ void NetLeftRoom(const QString & reason);
void selectFirstNetScheme();
void saveDemoWithCustomName();
private:
- void _NetConnect(const QString & hostName, quint16 port, const QString & nick);
+ void _NetConnect(const QString & hostName, quint16 port, QString nick);
void UpdateTeamsLists(const QStringList* editable_teams=0);
void CreateGame(GameCFGWidget * gamecfg, TeamSelWidget* pTeamSelWidget, QString ammo);
void closeEvent(QCloseEvent *event);
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/hwmap.cpp
--- a/QTfrontend/hwmap.cpp Sat Oct 08 16:45:52 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2006-2007 Ulyanov Igor
- * Copyright (c) 2007-2011 Andrey Korotaev
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#include "hwconsts.h"
-#include "hwmap.h"
-
-HWMap::HWMap() :
- TCPBase(false)
-{
-}
-
-HWMap::~HWMap()
-{
-}
-
-void HWMap::getImage(const QString & seed, int filter, MapGenerator mapgen, int maze_size, const QByteArray & drawMapData)
-{
- m_seed = seed;
- templateFilter = filter;
- m_mapgen = mapgen;
- m_maze_size = maze_size;
- if(mapgen == MAPGEN_DRAWN) m_drawMapData = drawMapData;
- Start();
-}
-
-QStringList HWMap::getArguments()
-{
- QStringList arguments;
- arguments << cfgdir->absolutePath();
- arguments << QString("%1").arg(ipc_port);
- arguments << "landpreview";
- return arguments;
-}
-
-void HWMap::onClientDisconnect()
-{
- if (readbuffer.size() == 128 * 32 + 1)
- {
- quint8 *buf = (quint8*) readbuffer.constData();
- QImage im(buf, 256, 128, QImage::Format_Mono);
- im.setNumColors(2);
- emit HHLimitReceived(buf[128 * 32]);
- emit ImageReceived(im);
- }
-}
-
-void HWMap::SendToClientFirst()
-{
- SendIPC(QString("eseed %1").arg(m_seed).toUtf8());
- SendIPC(QString("e$template_filter %1").arg(templateFilter).toUtf8());
- SendIPC(QString("e$mapgen %1").arg(m_mapgen).toUtf8());
-
- switch (m_mapgen)
- {
- case MAPGEN_MAZE:
- SendIPC(QString("e$maze_size %1").arg(m_maze_size).toUtf8());
- break;
-
- case MAPGEN_DRAWN:
- {
- QByteArray data = m_drawMapData;
- while(data.size() > 0)
- {
- QByteArray tmp = data;
- tmp.truncate(200);
- SendIPC("edraw " + tmp);
- data.remove(0, 200);
- }
- break;
- }
- default: ;
- }
-
- SendIPC("!");
-}
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/hwmap.h
--- a/QTfrontend/hwmap.h Sat Oct 08 16:45:52 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2006 Igor Ulyanov
- * Copyright (c) 2006-2011 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 _HWMAP_INCLUDED
-#define _HWMAP_INCLUDED
-
-#include
-#include
-#include
-
-#include "tcpBase.h"
-
-enum MapGenerator
-{
- MAPGEN_REGULAR,
- MAPGEN_MAZE,
- MAPGEN_DRAWN,
- MAPGEN_MAP
-};
-
-class HWMap : public TCPBase
-{
- Q_OBJECT
-
- public:
- HWMap();
- virtual ~HWMap();
- void getImage(const QString & seed, int templateFilter, MapGenerator mapgen, int maze_size, const QByteArray & drawMapData);
-
- protected:
- virtual QStringList getArguments();
- virtual void onClientDisconnect();
- virtual void SendToClientFirst();
-
- signals:
- void ImageReceived(const QImage newImage);
- void HHLimitReceived(int hhLimit);
-
- private:
- QString m_seed;
- int templateFilter;
- MapGenerator m_mapgen;
- int m_maze_size;
- QByteArray m_drawMapData;
-
- private slots:
-};
-
-#endif // _HWMAP_INCLUDED
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/igbox.cpp
--- a/QTfrontend/igbox.cpp Sat Oct 08 16:45:52 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2008-2011 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 "igbox.h"
-
-IconedGroupBox::IconedGroupBox(QWidget * parent)
- : QGroupBox(parent)
-{
-// Has issues with border-radius on children
-// setAttribute(Qt::WA_PaintOnScreen, true);
- titleLeftPadding = 49;
- contentTopPadding = 15;
-}
-
-void IconedGroupBox::setIcon(const QIcon & icon)
-{
- if (this->icon.isNull())
- setStyleSheet(QString(
- "IconedGroupBox{"
- "margin-top: 46px;"
- "margin-left: 12px;"
- "padding: %1px 2px 5px 2px;"
- "}"
- "IconedGroupBox::title{"
- "subcontrol-origin: margin;"
- "subcontrol-position: top left;"
- "padding-left: %2px;"
- "padding-top: %1px;"
- "text-align: left;"
- "}"
- ).arg(contentTopPadding).arg(titleLeftPadding)
- );
-
- this->icon = icon;
- repaint();
-}
-
-void IconedGroupBox::paintEvent(QPaintEvent * event)
-{
- Q_UNUSED(event);
-
- QStylePainter painter(this);
-
- QStyleOptionGroupBox option;
- initStyleOption(&option);
- painter.drawComplexControl(QStyle::CC_GroupBox, option);
-
- icon.paint(&painter, QRect(QPoint(0, 0), icon.actualSize(size())));
-}
-
-void IconedGroupBox::setTitleTextPadding(int px)
-{
- titleLeftPadding = px;
-}
-
-void IconedGroupBox::setContentTopPadding(int px)
-{
- contentTopPadding = px;
-}
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/igbox.h
--- a/QTfrontend/igbox.h Sat Oct 08 16:45:52 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2008-2011 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 _IGBOX_H
-#define _IGBOX_H
-
-#include
-#include
-
-class IconedGroupBox : public QGroupBox
-{
- Q_OBJECT
-
-public:
- IconedGroupBox(QWidget * parent = 0);
-
- void setIcon(const QIcon & icon);
- void setTitleTextPadding(int px);
- void setContentTopPadding(int px);
-protected:
- virtual void paintEvent(QPaintEvent * event);
-
-private:
- QIcon icon;
- int titleLeftPadding;
- int contentTopPadding;
-};
-
-#endif // _IGBOX_H
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/input_ip.cpp
--- a/QTfrontend/input_ip.cpp Sat Oct 08 16:45:52 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2007-2011 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 "input_ip.h"
-
-HWHostPortDialog::HWHostPortDialog(QWidget* parent) : QDialog(parent)
-{
- QGridLayout * layout = new QGridLayout(this);
-
- QLabel * lbHost = new QLabel(this);
- lbHost->setText(QLabel::tr("Host:"));
- layout->addWidget(lbHost, 0, 0);
-
- QLabel * lbPort = new QLabel(this);
- lbPort->setText(QLabel::tr("Port:"));
- layout->addWidget(lbPort, 1, 0);
-
- leHost = new QLineEdit(this);
- layout->addWidget(leHost, 0, 1, 1, 2);
-
- sbPort = new QSpinBox(this);
- sbPort->setMinimum(0);
- sbPort->setMaximum(65535);
- layout->addWidget(sbPort, 1, 1, 1, 2);
-
- pbDefault = new QPushButton(this);
- pbDefault->setText(QPushButton::tr("default"));
- layout->addWidget(pbDefault, 1, 3);
-
- pbOK = new QPushButton(this);
- pbOK->setText(QPushButton::tr("OK"));
- pbOK->setDefault(true);
- layout->addWidget(pbOK, 3, 1);
-
- pbCancel = new QPushButton(this);
- pbCancel->setText(QPushButton::tr("Cancel"));
- layout->addWidget(pbCancel, 3, 2);
-
- connect(pbOK, SIGNAL(clicked()), this, SLOT(accept()));
- connect(pbCancel, SIGNAL(clicked()), this, SLOT(reject()));
- connect(pbDefault, SIGNAL(clicked()), this, SLOT(setDefaultPort()));
-}
-
-void HWHostPortDialog::setDefaultPort()
-{
- sbPort->setValue(46631);
-}
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/input_ip.h
--- a/QTfrontend/input_ip.h Sat Oct 08 16:45:52 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2007-2011 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 INPUT_IP_H
-#define INPUT_IP_H
-
-#include
-#include
-
-class QLineEdit;
-class QSpinBox;
-class QPushButton;
-
-class HWHostPortDialog : public QDialog
-{
- Q_OBJECT
-public:
- HWHostPortDialog(QWidget* parent = 0);
-
- QLineEdit* leHost;
- QSpinBox* sbPort;
-
-private:
- QPushButton* pbOK;
- QPushButton* pbCancel;
- QPushButton * pbDefault;
-
-private slots:
- void setDefaultPort();
-};
-
-
-#endif // INPUT_IP_H
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/itemNum.cpp
--- a/QTfrontend/itemNum.cpp Sat Oct 08 16:45:52 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,114 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2006-2011 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 "itemNum.h"
-#include "hwform.h"
-
-#include
-#include
-
-ItemNum::ItemNum(const QImage& im, const QImage& img, QWidget * parent, unsigned char min, unsigned char max) :
- QFrame(parent), m_im(im), m_img(img), infinityState(false), nonInteractive(false), minItems(min), maxItems(max),
- numItems(min+2 >= max ? min : min+2)
-{
- enabled = true;
- if(frontendEffects) setAttribute(Qt::WA_PaintOnScreen, true);
-}
-
-ItemNum::~ItemNum()
-{
-}
-
-void ItemNum::mousePressEvent ( QMouseEvent * event )
-{
- if(nonInteractive) return;
- if(event->button()==Qt::LeftButton && enabled) {
- event->accept();
- if((infinityState && numItems <= maxItems) || (!infinityState && numItems < maxItems)) {
- incItems();
- } else {
- numItems = minItems+1;
- // appears there's an emit in there
- decItems();
- }
- } else if (event->button()==Qt::RightButton && enabled) {
- event->accept();
- if(numItems > minItems) {
- decItems();
- } else {
- numItems = maxItems+(infinityState?0:-1);
- incItems();
- }
- } else {
- event->ignore();
- return;
- }
- repaint();
-}
-
-QSize ItemNum::sizeHint () const
-{
- return QSize((maxItems+1)*12, 32);
-}
-
-void ItemNum::paintEvent(QPaintEvent* event)
-{
- Q_UNUSED(event);
-
- QPainter painter(this);
-
- if (numItems==maxItems+1) {
- QRect target(0, 0, 100, 32);
- if (enabled) {
- painter.drawImage(target, QImage(":/res/infinity.png"));
- } else {
- painter.drawImage(target, QImage(":/res/infinitygrey.png"));
- }
- } else {
- 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
-#include
-
-#ifndef _ITEM_NUM_INCLUDED
-#define _ITEM_NUM_INCLUDED
-
-class ItemNum : public QFrame
-{
- Q_OBJECT
-
- public:
- void setInfinityState(bool value);
- void setEnabled(bool value);
- unsigned char getItemsNum() const;
- void setItemsNum(const unsigned char num);
-
- private:
- QImage m_im;
- QImage m_img;
- bool infinityState;
- bool enabled;
-
- protected:
- ItemNum(const QImage& im, const QImage& img, QWidget * parent, unsigned char min=2, unsigned char max=8);
- virtual QSize sizeHint () const;
- virtual ~ItemNum()=0;
-
- bool nonInteractive;
- unsigned char minItems;
- unsigned char maxItems;
- unsigned char numItems;
-
- // from QWidget
- virtual void mousePressEvent ( QMouseEvent * event );
- virtual void paintEvent(QPaintEvent* event);
-
- // to be implemented in child
- virtual void incItems()=0;
- virtual void decItems()=0;
-};
-
-#endif // _ITEM_NUM_INCLUDED
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/main.cpp
--- a/QTfrontend/main.cpp Sat Oct 08 16:45:52 2011 +0200
+++ b/QTfrontend/main.cpp Sat Oct 08 16:54:56 2011 +0200
@@ -96,8 +96,8 @@
Q_INIT_RESOURCE(hedgewars);
- qApp->setStyleSheet
- (QString(
+ QString styleSheetFromHell =
+ QString(
"HWForm,QDialog{"
"background-image: url(\":/res/Background.png\");"
"background-position: bottom center;"
@@ -251,6 +251,8 @@
"subcontrol-origin: margin;"
"subcontrol-position: top left;"
"text-align: left;"
+ "left: 15px;"
+ "top: -4px;"
"}"
"QCheckBox::indicator:checked{"
@@ -315,8 +317,7 @@
"background-color: #ffcc00;"
"width: 8px;"
"}"
- )
- );
+ );
bindir->cd("bin"); // workaround over NSIS installer
@@ -484,7 +485,7 @@
CocoaInitializer initializer;
#endif
- app.form = new HWForm();
+ app.form = new HWForm(NULL,styleSheetFromHell);
app.form->show();
return app.exec();
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/mapContainer.cpp
--- a/QTfrontend/mapContainer.cpp Sat Oct 08 16:45:52 2011 +0200
+++ b/QTfrontend/mapContainer.cpp Sat Oct 08 16:54:56 2011 +0200
@@ -114,6 +114,8 @@
QString scheme;
QString weapons;
QList mapInfo;
+ bool isMission = mapLuaFile.exists();
+
QTextStream input(&mapCfgFile);
input >> theme;
input >> limit;
@@ -125,16 +127,22 @@
mapInfo.push_back(limit);
else
mapInfo.push_back(18);
- mapInfo.push_back(mapLuaFile.exists());
+
+
+ mapInfo.push_back(isMission);
+
if (scheme.isEmpty())
scheme = "locked";
scheme.replace("_", " ");
+
if (weapons.isEmpty())
weapons = "locked";
weapons.replace("_", " ");
+
mapInfo.push_back(scheme);
mapInfo.push_back(weapons);
- if(mapLuaFile.exists())
+
+ if(isMission)
{
chooseMap->insertItem(missionindex++,
// FIXME - need real icons. Disabling until then
@@ -509,14 +517,14 @@
{
int i = MAPGEN_MAP + 3 + numMissions + rand() % (chooseMap->count() - MAPGEN_MAP - 3 - numMissions);
chooseMap->setCurrentIndex(i);
- updatePreview();
+ mapChanged(i);
}
void HWMapContainer::setRandomMission()
{
int i = MAPGEN_MAP + 2 + rand() % numMissions;
chooseMap->setCurrentIndex(i);
- updatePreview();
+ mapChanged(i);
}
void HWMapContainer::setRandomSeed()
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/misc.cpp
--- a/QTfrontend/misc.cpp Sat Oct 08 16:45:52 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2005-2011 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 "misc.h"
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/misc.h
--- a/QTfrontend/misc.h Sat Oct 08 16:45:52 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2005-2011 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 _MISC_H
-#define _MISC_H
-
-
-#include
-#include
-
-class FreqSpinBox : public QSpinBox
-{
- Q_OBJECT
-
-public:
- FreqSpinBox(QWidget* parent) : QSpinBox(parent)
- {
-
- }
-
- QString textFromValue(int value) const
- {
- if (!value)
- return tr("Never");
- else
- return tr("Every %1 turn", "", value).arg(value);
- }
-};
-
-
-#endif // _MISC_H
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/model/ammoSchemeModel.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/model/ammoSchemeModel.cpp Sat Oct 08 16:54:56 2011 +0200
@@ -0,0 +1,786 @@
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2005-2011 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 "ammoSchemeModel.h"
+#include "hwconsts.h"
+
+QList defaultScheme = QList()
+ << QVariant("Default") // name 0
+ << QVariant(false) // fortsmode 1
+ << QVariant(false) // team divide 2
+ << QVariant(false) // solid land 3
+ << QVariant(false) // border 4
+ << QVariant(false) // low gravity 5
+ << QVariant(false) // laser sight 6
+ << QVariant(false) // invulnerable 7
+ << QVariant(false) // reset health 8
+ << QVariant(false) // vampiric 9
+ << QVariant(false) // karma 10
+ << QVariant(false) // artillery 11
+ << QVariant(true) // random order 12
+ << QVariant(false) // king 13
+ << QVariant(false) // place hog 14
+ << QVariant(false) // shared ammo 15
+ << QVariant(false) // disable girders 16
+ << QVariant(false) // disable land objects 17
+ << QVariant(false) // AI survival 18
+ << QVariant(false) // inf. attack 19
+ << QVariant(false) // reset weps 20
+ << QVariant(false) // per hog ammo 21
+ << QVariant(false) // no wind 22
+ << QVariant(false) // more wind 23
+ << QVariant(false) // tag team 24
+ << QVariant(false) // bottom border 25
+ << QVariant(100) // damage modfier 26
+ << QVariant(45) // turn time 27
+ << QVariant(100) // init health 28
+ << QVariant(15) // sudden death 29
+ << QVariant(5) // case prob 30
+ << QVariant(3) // mines time 31
+ << QVariant(4) // mines number 32
+ << QVariant(0) // mine dud pct 33
+ << QVariant(2) // explosives 34
+ << QVariant(35) // health case pct 35
+ << QVariant(25) // health case amt 36
+ << QVariant(47) // water rise amt 37
+ << QVariant(5) // health dec amt 38
+ << QVariant(100) // rope modfier 39
+ << QVariant(100) // get away time 40
+ ;
+
+AmmoSchemeModel::AmmoSchemeModel(QObject* parent, const QString & fileName) :
+ QAbstractTableModel(parent),
+ fileConfig(fileName, QSettings::IniFormat)
+{
+ predefSchemesNames = QStringList()
+ << "Default"
+ << "Pro Mode"
+ << "Shoppa"
+ << "Clean Slate"
+ << "Minefield"
+ << "Barrel Mayhem"
+ << "Tunnel Hogs"
+ << "Fort Mode"
+ << "Timeless"
+ << "Thinking with Portals"
+ << "King Mode"
+ ;
+
+ numberOfDefaultSchemes = predefSchemesNames.size();
+
+ spNames = QStringList()
+ << "name" // 0
+ << "fortsmode" // 1
+ << "divteams" // 2
+ << "solidland" // 3
+ << "border" // 4
+ << "lowgrav" // 5
+ << "laser" // 6
+ << "invulnerability" // 7
+ << "resethealth" // 8
+ << "vampiric" // 9
+ << "karma" // 10
+ << "artillery" // 11
+ << "randomorder" // 12
+ << "king" // 13
+ << "placehog" // 14
+ << "sharedammo" // 15
+ << "disablegirders" // 16
+ << "disablelandobjects" // 17
+ << "aisurvival" // 18
+ << "infattack" // 19
+ << "resetweps" // 20
+ << "perhogammo" // 21
+ << "disablewind" // 22
+ << "morewind" // 23
+ << "tagteam" // 24
+ << "bottomborder" // 25
+ << "damagefactor" // 26
+ << "turntime" // 27
+ << "health" // 28
+ << "suddendeath" // 29
+ << "caseprobability" // 30
+ << "minestime" // 31
+ << "minesnum" // 32
+ << "minedudpct" // 33
+ << "explosives" // 34
+ << "healthprobability" // 35
+ << "healthcaseamount" // 36
+ << "waterrise" // 37
+ << "healthdecrease" // 38
+ << "ropepct" // 39
+ << "getawaytime" // 40
+ ;
+
+ QList proMode;
+ proMode
+ << predefSchemesNames[1] // name 0
+ << QVariant(false) // fortsmode 1
+ << QVariant(false) // team divide 2
+ << QVariant(false) // solid land 3
+ << QVariant(false) // border 4
+ << QVariant(false) // low gravity 5
+ << QVariant(false) // laser sight 6
+ << QVariant(false) // invulnerable 7
+ << QVariant(false) // reset health 8
+ << QVariant(false) // vampiric 9
+ << QVariant(false) // karma 10
+ << QVariant(false) // artillery 11
+ << QVariant(true) // random order 12
+ << QVariant(false) // king 13
+ << QVariant(false) // place hog 14
+ << QVariant(true) // shared ammo 15
+ << QVariant(false) // disable girders 16
+ << QVariant(false) // disable land objects 17
+ << QVariant(false) // AI survival 18
+ << QVariant(false) // inf. attack 19
+ << QVariant(false) // reset weps 20
+ << QVariant(false) // per hog ammo 21
+ << QVariant(false) // no wind 22
+ << QVariant(false) // more wind 23
+ << QVariant(false) // tag team 24
+ << QVariant(false) // bottom border 25
+ << QVariant(100) // damage modfier 26
+ << QVariant(15) // turn time 27
+ << QVariant(100) // init health 28
+ << QVariant(15) // sudden death 29
+ << QVariant(0) // case prob 30
+ << QVariant(3) // mines time 31
+ << QVariant(0) // mines number 32
+ << QVariant(0) // mine dud pct 33
+ << QVariant(2) // explosives 34
+ << QVariant(35) // health case pct 35
+ << QVariant(25) // health case amt 36
+ << QVariant(47) // water rise amt 37
+ << QVariant(5) // health dec amt 38
+ << QVariant(100) // rope modfier 39
+ << QVariant(100) // get away time 40
+ ;
+
+ QList shoppa;
+ shoppa
+ << predefSchemesNames[2] // name 0
+ << QVariant(false) // fortsmode 1
+ << QVariant(false) // team divide 2
+ << QVariant(true) // solid land 3
+ << QVariant(true) // border 4
+ << QVariant(false) // low gravity 5
+ << QVariant(false) // laser sight 6
+ << QVariant(false) // invulnerable 7
+ << QVariant(false) // reset health 8
+ << QVariant(false) // vampiric 9
+ << QVariant(false) // karma 10
+ << QVariant(false) // artillery 11
+ << QVariant(true) // random order 12
+ << QVariant(false) // king 13
+ << QVariant(false) // place hog 14
+ << QVariant(true) // shared ammo 15
+ << QVariant(true) // disable girders 16
+ << QVariant(false) // disable land objects 17
+ << QVariant(false) // AI survival 18
+ << QVariant(false) // inf. attack 19
+ << QVariant(true) // reset weps 20
+ << QVariant(false) // per hog ammo 21
+ << QVariant(false) // no wind 22
+ << QVariant(false) // more wind 23
+ << QVariant(false) // tag team 24
+ << QVariant(false) // bottom border 25
+ << QVariant(100) // damage modfier 26
+ << QVariant(30) // turn time 27
+ << QVariant(100) // init health 28
+ << QVariant(50) // sudden death 29
+ << QVariant(1) // case prob 30
+ << QVariant(3) // mines time 31
+ << QVariant(0) // mines number 32
+ << QVariant(0) // mine dud pct 33
+ << QVariant(0) // explosives 34
+ << QVariant(0) // health case pct 35
+ << QVariant(25) // health case amt 36
+ << QVariant(47) // water rise amt 37
+ << QVariant(5) // health dec amt 38
+ << QVariant(100) // rope modfier 39
+ << QVariant(100) // get away time 40
+ ;
+
+ QList cleanslate;
+ cleanslate
+ << predefSchemesNames[3] // name 0
+ << QVariant(false) // fortsmode 1
+ << QVariant(false) // team divide 2
+ << QVariant(false) // solid land 3
+ << QVariant(false) // border 4
+ << QVariant(false) // low gravity 5
+ << QVariant(false) // laser sight 6
+ << QVariant(false) // invulnerable 7
+ << QVariant(true) // reset health 8
+ << QVariant(false) // vampiric 9
+ << QVariant(false) // karma 10
+ << QVariant(false) // artillery 11
+ << QVariant(true) // random order 12
+ << QVariant(false) // king 13
+ << QVariant(false) // place hog 14
+ << QVariant(false) // shared ammo 15
+ << QVariant(false) // disable girders 16
+ << QVariant(false) // disable land objects 17
+ << QVariant(false) // AI survival 18
+ << QVariant(true) // inf. attack 19
+ << QVariant(true) // reset weps 20
+ << QVariant(false) // per hog ammo 21
+ << QVariant(false) // no wind 22
+ << QVariant(false) // more wind 23
+ << QVariant(false) // tag team 24
+ << QVariant(false) // bottom border 25
+ << QVariant(100) // damage modfier 26
+ << QVariant(45) // turn time 27
+ << QVariant(100) // init health 28
+ << QVariant(15) // sudden death 29
+ << QVariant(5) // case prob 30
+ << QVariant(3) // mines time 31
+ << QVariant(4) // mines number 32
+ << QVariant(0) // mine dud pct 33
+ << QVariant(2) // explosives 34
+ << QVariant(35) // health case pct 35
+ << QVariant(25) // health case amt 36
+ << QVariant(47) // water rise amt 37
+ << QVariant(5) // health dec amt 38
+ << QVariant(100) // rope modfier 39
+ << QVariant(100) // get away time 40
+ ;
+
+ QList minefield;
+ minefield
+ << predefSchemesNames[4] // name 0
+ << QVariant(false) // fortsmode 1
+ << QVariant(false) // team divide 2
+ << QVariant(false) // solid land 3
+ << QVariant(false) // border 4
+ << QVariant(false) // low gravity 5
+ << QVariant(false) // laser sight 6
+ << QVariant(false) // invulnerable 7
+ << QVariant(false) // reset health 8
+ << QVariant(false) // vampiric 9
+ << QVariant(false) // karma 10
+ << QVariant(false) // artillery 11
+ << QVariant(true) // random order 12
+ << QVariant(false) // king 13
+ << QVariant(false) // place hog 14
+ << QVariant(true) // shared ammo 15
+ << QVariant(true) // disable girders 16
+ << QVariant(false) // disable land objects 17
+ << QVariant(false) // AI survival 18
+ << QVariant(false) // inf. attack 19
+ << QVariant(false) // reset weps 20
+ << QVariant(false) // per hog ammo 21
+ << QVariant(false) // no wind 22
+ << QVariant(false) // more wind 23
+ << QVariant(false) // tag team 24
+ << QVariant(false) // bottom border 25
+ << QVariant(100) // damage modfier 26
+ << QVariant(30) // turn time 27
+ << QVariant(50) // init health 28
+ << QVariant(15) // sudden death 29
+ << QVariant(0) // case prob 30
+ << QVariant(0) // mines time 31
+ << QVariant(80) // mines number 32
+ << QVariant(0) // mine dud pct 33
+ << QVariant(0) // explosives 34
+ << QVariant(35) // health case pct 35
+ << QVariant(25) // health case amt 36
+ << QVariant(47) // water rise amt 37
+ << QVariant(5) // health dec amt 38
+ << QVariant(100) // rope modfier 39
+ << QVariant(100) // get away time 40
+ ;
+
+ QList barrelmayhem;
+ barrelmayhem
+ << predefSchemesNames[5] // name 0
+ << QVariant(false) // fortsmode 1
+ << QVariant(false) // team divide 2
+ << QVariant(false) // solid land 3
+ << QVariant(false) // border 4
+ << QVariant(false) // low gravity 5
+ << QVariant(false) // laser sight 6
+ << QVariant(false) // invulnerable 7
+ << QVariant(false) // reset health 8
+ << QVariant(false) // vampiric 9
+ << QVariant(false) // karma 10
+ << QVariant(false) // artillery 11
+ << QVariant(true) // random order 12
+ << QVariant(false) // king 13
+ << QVariant(false) // place hog 14
+ << QVariant(true) // shared ammo 15
+ << QVariant(false) // disable girders 16
+ << QVariant(false) // disable land objects 17
+ << QVariant(false) // AI survival 18
+ << QVariant(false) // inf. attack 19
+ << QVariant(false) // reset weps 20
+ << QVariant(false) // per hog ammo 21
+ << QVariant(false) // no wind 22
+ << QVariant(false) // more wind 23
+ << QVariant(false) // tag team 24
+ << QVariant(false) // bottom border 25
+ << QVariant(100) // damage modfier 26
+ << QVariant(30) // turn time 27
+ << QVariant(100) // init health 28
+ << QVariant(15) // sudden death 29
+ << QVariant(0) // case prob 30
+ << QVariant(0) // mines time 31
+ << QVariant(0) // mines number 32
+ << QVariant(0) // mine dud pct 33
+ << QVariant(80) // explosives 34
+ << QVariant(35) // health case pct 35
+ << QVariant(25) // health case amt 36
+ << QVariant(47) // water rise amt 37
+ << QVariant(5) // health dec amt 38
+ << QVariant(100) // rope modfier 39
+ << QVariant(100) // get away time 40
+ ;
+
+ QList tunnelhogs;
+ tunnelhogs
+ << predefSchemesNames[6] // name 0
+ << QVariant(false) // fortsmode 1
+ << QVariant(false) // team divide 2
+ << QVariant(false) // solid land 3
+ << QVariant(true) // border 4
+ << QVariant(false) // low gravity 5
+ << QVariant(false) // laser sight 6
+ << QVariant(false) // invulnerable 7
+ << QVariant(false) // reset health 8
+ << QVariant(false) // vampiric 9
+ << QVariant(false) // karma 10
+ << QVariant(false) // artillery 11
+ << QVariant(true) // random order 12
+ << QVariant(false) // king 13
+ << QVariant(false) // place hog 14
+ << QVariant(true) // shared ammo 15
+ << QVariant(true) // disable girders 16
+ << QVariant(true) // disable land objects 17
+ << QVariant(false) // AI survival 18
+ << QVariant(false) // inf. attack 19
+ << QVariant(false) // reset weps 20
+ << QVariant(false) // per hog ammo 21
+ << QVariant(false) // no wind 22
+ << QVariant(false) // more wind 23
+ << QVariant(false) // tag team 24
+ << QVariant(false) // bottom border 25
+ << QVariant(100) // damage modfier 26
+ << QVariant(30) // turn time 27
+ << QVariant(100) // init health 28
+ << QVariant(15) // sudden death 29
+ << QVariant(5) // case prob 30
+ << QVariant(3) // mines time 31
+ << QVariant(10) // mines number 32
+ << QVariant(10) // mine dud pct 33
+ << QVariant(10) // explosives 34
+ << QVariant(35) // health case pct 35
+ << QVariant(25) // health case amt 36
+ << QVariant(47) // water rise amt 37
+ << QVariant(5) // health dec amt 38
+ << QVariant(100) // rope modfier 39
+ << QVariant(100) // get away time 40
+ ;
+
+ QList forts;
+ forts
+ << predefSchemesNames[7] // name 0
+ << QVariant(true) // fortsmode 1
+ << QVariant(true) // team divide 2
+ << QVariant(false) // solid land 3
+ << QVariant(false) // border 4
+ << QVariant(true) // low gravity 5
+ << QVariant(false) // laser sight 6
+ << QVariant(false) // invulnerable 7
+ << QVariant(false) // reset health 8
+ << QVariant(false) // vampiric 9
+ << QVariant(false) // karma 10
+ << QVariant(false) // artillery 11
+ << QVariant(true) // random order 12
+ << QVariant(false) // king 13
+ << QVariant(false) // place hog 14
+ << QVariant(false) // shared ammo 15
+ << QVariant(false) // disable girders 16
+ << QVariant(false) // disable land objects 17
+ << QVariant(false) // AI survival 18
+ << QVariant(false) // inf. attack 19
+ << QVariant(false) // reset weps 20
+ << QVariant(false) // per hog ammo 21
+ << QVariant(false) // no wind 22
+ << QVariant(false) // more wind 23
+ << QVariant(false) // tag team 24
+ << QVariant(false) // bottom border 25
+ << QVariant(100) // damage modfier 26
+ << QVariant(45) // turn time 27
+ << QVariant(100) // init health 28
+ << QVariant(15) // sudden death 29
+ << QVariant(5) // case prob 30
+ << QVariant(3) // mines time 31
+ << QVariant(0) // mines number 32
+ << QVariant(0) // mine dud pct 33
+ << QVariant(0) // explosives 34
+ << QVariant(35) // health case pct 35
+ << QVariant(25) // health case amt 36
+ << QVariant(47) // water rise amt 37
+ << QVariant(5) // health dec amt 38
+ << QVariant(100) // rope modfier 39
+ << QVariant(100) // get away time 40
+ ;
+
+ QList timeless;
+ timeless
+ << predefSchemesNames[8] // name 0
+ << QVariant(false) // fortsmode 1
+ << QVariant(false) // team divide 2
+ << QVariant(false) // solid land 3
+ << QVariant(false) // border 4
+ << QVariant(false) // low gravity 5
+ << QVariant(false) // laser sight 6
+ << QVariant(false) // invulnerable 7
+ << QVariant(false) // reset health 8
+ << QVariant(false) // vampiric 9
+ << QVariant(false) // karma 10
+ << QVariant(false) // artillery 11
+ << QVariant(true) // random order 12
+ << QVariant(false) // king 13
+ << QVariant(false) // place hog 14
+ << QVariant(false) // shared ammo 15
+ << QVariant(false) // disable girders 16
+ << QVariant(false) // disable land objects 17
+ << QVariant(false) // AI survival 18
+ << QVariant(false) // inf. attack 19
+ << QVariant(false) // reset weps 20
+ << QVariant(true) // per hog ammo 21
+ << QVariant(false) // no wind 22
+ << QVariant(false) // more wind 23
+ << QVariant(false) // tag team 24
+ << QVariant(false) // bottom border 25
+ << QVariant(100) // damage modfier 26
+ << QVariant(9999) // turn time 27
+ << QVariant(100) // init health 28
+ << QVariant(15) // sudden death 29
+ << QVariant(5) // case prob 30
+ << QVariant(3) // mines time 31
+ << QVariant(5) // mines number 32
+ << QVariant(10) // mine dud pct 33
+ << QVariant(2) // explosives 34
+ << QVariant(35) // health case pct 35
+ << QVariant(30) // health case amt 36
+ << QVariant(0) // water rise amt 37
+ << QVariant(0) // health dec amt 38
+ << QVariant(100) // rope modfier 39
+ << QVariant(100) // get away time 40
+ ;
+
+ QList thinkingportals;
+ thinkingportals
+ << predefSchemesNames[9] // name 0
+ << QVariant(false) // fortsmode 1
+ << QVariant(false) // team divide 2
+ << QVariant(false) // solid land 3
+ << QVariant(false) // border 4
+ << QVariant(false) // low gravity 5
+ << QVariant(false) // laser sight 6
+ << QVariant(false) // invulnerable 7
+ << QVariant(false) // reset health 8
+ << QVariant(false) // vampiric 9
+ << QVariant(false) // karma 10
+ << QVariant(true) // artillery 11
+ << QVariant(true) // random order 12
+ << QVariant(false) // king 13
+ << QVariant(false) // place hog 14
+ << QVariant(false) // shared ammo 15
+ << QVariant(false) // disable girders 16
+ << QVariant(false) // disable land objects 17
+ << QVariant(false) // AI survival 18
+ << QVariant(false) // inf. attack 19
+ << QVariant(false) // reset weps 20
+ << QVariant(false) // per hog ammo 21
+ << QVariant(false) // no wind 22
+ << QVariant(false) // more wind 23
+ << QVariant(false) // tag team 24
+ << QVariant(false) // bottom border 25
+ << QVariant(100) // damage modfier 26
+ << QVariant(45) // turn time 27
+ << QVariant(100) // init health 28
+ << QVariant(15) // sudden death 29
+ << QVariant(2) // case prob 30
+ << QVariant(3) // mines time 31
+ << QVariant(5) // mines number 32
+ << QVariant(0) // mine dud pct 33
+ << QVariant(5) // explosives 34
+ << QVariant(25) // health case pct 35
+ << QVariant(25) // health case amt 36
+ << QVariant(47) // water rise amt 37
+ << QVariant(5) // health dec amt 38
+ << QVariant(100) // rope modfier 39
+ << QVariant(100) // get away time 40
+ ;
+
+ QList kingmode;
+ kingmode
+ << predefSchemesNames[10] // name 0
+ << QVariant(false) // fortsmode 1
+ << QVariant(false) // team divide 2
+ << QVariant(false) // solid land 3
+ << QVariant(false) // border 4
+ << QVariant(false) // low gravity 5
+ << QVariant(false) // laser sight 6
+ << QVariant(false) // invulnerable 7
+ << QVariant(false) // reset health 8
+ << QVariant(false) // vampiric 9
+ << QVariant(false) // karma 10
+ << QVariant(false) // artillery 11
+ << QVariant(true) // random order 12
+ << QVariant(true) // king 13
+ << QVariant(false) // place hog 14
+ << QVariant(false) // shared ammo 15
+ << QVariant(false) // disable girders 16
+ << QVariant(false) // disable land objects 17
+ << QVariant(false) // AI survival 18
+ << QVariant(false) // inf. attack 19
+ << QVariant(false) // reset weps 20
+ << QVariant(false) // per hog ammo 21
+ << QVariant(false) // no wind 22
+ << QVariant(false) // more wind 23
+ << QVariant(false) // tag team 24
+ << QVariant(false) // bottom border 25
+ << QVariant(100) // damage modfier 26
+ << QVariant(45) // turn time 27
+ << QVariant(100) // init health 28
+ << QVariant(15) // sudden death 29
+ << QVariant(5) // case prob 30
+ << QVariant(3) // mines time 31
+ << QVariant(4) // mines number 32
+ << QVariant(0) // mine dud pct 33
+ << QVariant(2) // explosives 34
+ << QVariant(35) // health case pct 35
+ << QVariant(25) // health case amt 36
+ << QVariant(47) // water rise amt 37
+ << QVariant(5) // health dec amt 38
+ << QVariant(100) // rope modfier 39
+ << QVariant(100) // get away time 40
+ ;
+
+
+ schemes.append(defaultScheme);
+ schemes.append(proMode);
+ schemes.append(shoppa);
+ schemes.append(cleanslate);
+ schemes.append(minefield);
+ schemes.append(barrelmayhem);
+ schemes.append(tunnelhogs);
+ schemes.append(forts);
+ schemes.append(timeless);
+ schemes.append(thinkingportals);
+ schemes.append(kingmode);
+
+
+ int size = fileConfig.beginReadArray("schemes");
+ for (int i = 0; i < size; ++i) {
+ fileConfig.setArrayIndex(i);
+
+ if (!predefSchemesNames.contains(fileConfig.value(spNames[0]).toString()))
+ {
+ QList scheme;
+
+ for (int k = 0; k < spNames.size(); ++k)
+ scheme << fileConfig.value(spNames[k], defaultScheme[k]);
+
+ schemes.append(scheme);
+ }
+ }
+ fileConfig.endArray();
+}
+
+QVariant AmmoSchemeModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ Q_UNUSED(section);
+ Q_UNUSED(orientation);
+ Q_UNUSED(role);
+
+ return QVariant();
+}
+
+int AmmoSchemeModel::rowCount(const QModelIndex &parent) const
+{
+ if (parent.isValid())
+ return 0;
+ else
+ return schemes.size();
+}
+
+int AmmoSchemeModel::columnCount(const QModelIndex & parent) const
+{
+ if (parent.isValid())
+ return 0;
+ else
+ return defaultScheme.size();
+}
+
+Qt::ItemFlags AmmoSchemeModel::flags(const QModelIndex & index) const
+{
+ Q_UNUSED(index);
+
+ return
+ Qt::ItemIsEnabled
+ | Qt::ItemIsSelectable
+ | Qt::ItemIsEditable;
+}
+
+bool AmmoSchemeModel::setData(const QModelIndex & index, const QVariant & value, int role)
+{
+ if (!index.isValid() || index.row() < numberOfDefaultSchemes
+ || index.row() >= schemes.size()
+ || index.column() >= defaultScheme.size()
+ || role != Qt::EditRole)
+ return false;
+
+ schemes[index.row()][index.column()] = value;
+
+ emit dataChanged(index, index);
+ return true;
+}
+
+bool AmmoSchemeModel::insertRows(int row, int count, const QModelIndex & parent)
+{
+ Q_UNUSED(count);
+
+ beginInsertRows(parent, schemes.size(), schemes.size());
+
+ if (row == -1)
+ {
+ QList newScheme = defaultScheme;
+ newScheme[0] = QVariant(tr("new"));
+ schemes.insert(schemes.size(), newScheme);
+ }
+ else
+ {
+ QList newScheme = schemes[row];
+ newScheme[0] = QVariant(tr("copy of") + " " + newScheme[0].toString());
+ schemes.insert(schemes.size(), newScheme);
+ }
+
+ endInsertRows();
+
+ return true;
+}
+
+bool AmmoSchemeModel::removeRows(int row, int count, const QModelIndex & parent)
+{
+ if(count != 1
+ || row < numberOfDefaultSchemes
+ || row >= schemes.size())
+ return false;
+
+ beginRemoveRows(parent, row, row);
+
+ schemes.removeAt(row);
+
+ endRemoveRows();
+
+ return true;
+}
+
+QVariant AmmoSchemeModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid() || index.row() < 0
+ || index.row() >= schemes.size()
+ || index.column() >= defaultScheme.size()
+ || (role != Qt::EditRole && role != Qt::DisplayRole)
+ )
+ return QVariant();
+
+ return schemes[index.row()][index.column()];
+}
+
+void AmmoSchemeModel::Save()
+{
+ fileConfig.beginWriteArray("schemes", schemes.size() - numberOfDefaultSchemes);
+
+ for (int i = 0; i < schemes.size() - numberOfDefaultSchemes; ++i) {
+ fileConfig.setArrayIndex(i);
+
+ QList scheme = schemes[i + numberOfDefaultSchemes];
+
+ for (int k = 0; k < scheme.size(); ++k)
+ fileConfig.setValue(spNames[k], scheme[k]);
+ }
+ fileConfig.endArray();
+}
+
+
+NetAmmoSchemeModel::NetAmmoSchemeModel(QObject * parent) :
+ QAbstractTableModel(parent)
+{
+ netScheme = defaultScheme;
+}
+
+QVariant NetAmmoSchemeModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ Q_UNUSED(section);
+ Q_UNUSED(orientation);
+ Q_UNUSED(role);
+
+ return QVariant();
+}
+
+int NetAmmoSchemeModel::rowCount(const QModelIndex & parent) const
+{
+ if (parent.isValid())
+ return 0;
+ else
+ return 1;
+}
+
+int NetAmmoSchemeModel::columnCount(const QModelIndex & parent) const
+{
+ if (parent.isValid())
+ return 0;
+ else
+ return defaultScheme.size();
+}
+
+QVariant NetAmmoSchemeModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid() || index.row() < 0
+ || index.row() > 1
+ || index.column() >= defaultScheme.size()
+ || (role != Qt::EditRole && role != Qt::DisplayRole)
+ )
+ return QVariant();
+
+ return netScheme[index.column()];
+}
+
+void NetAmmoSchemeModel::setNetSchemeConfig(QStringList & cfg)
+{
+ if(cfg.size() != netScheme.size())
+ {
+ qWarning("Incorrect scheme cfg size");
+ return;
+ }
+
+ for(int i = 0; i < cfg.size(); ++i)
+ netScheme[i] = QVariant(cfg[i]);
+
+ reset();
+}
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/model/ammoSchemeModel.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/model/ammoSchemeModel.h Sat Oct 08 16:54:56 2011 +0200
@@ -0,0 +1,79 @@
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2005-2011 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 _AMMO_SCHEME_MODEL_INCLUDED
+#define _AMMO_SCHEME_MODEL_INCLUDED
+
+#include
+#include
+#include
+#include
+
+class AmmoSchemeModel : public QAbstractTableModel
+{
+ Q_OBJECT
+
+public:
+ AmmoSchemeModel(QObject * parent, const QString & fileName);
+
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+ int rowCount(const QModelIndex & parent) const;
+ int columnCount(const QModelIndex & parent) const;
+ Qt::ItemFlags flags(const QModelIndex & index) const;
+ bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);
+ bool insertRows(int row, int count, const QModelIndex & parent = QModelIndex());
+ bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex());
+ QVariant data(const QModelIndex &index, int role) const;
+
+ int numberOfDefaultSchemes;
+ QStringList predefSchemesNames;
+ QStringList spNames;
+
+public slots:
+ void Save();
+
+signals:
+ void dataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight);
+
+protected:
+ QList< QList > schemes;
+
+private:
+ QSettings fileConfig;
+};
+
+class NetAmmoSchemeModel : public QAbstractTableModel
+{
+ Q_OBJECT
+
+public:
+ NetAmmoSchemeModel(QObject * parent);
+
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+ int rowCount(const QModelIndex & parent) const;
+ int columnCount(const QModelIndex & parent) const;
+ QVariant data(const QModelIndex &index, int role) const;
+
+public slots:
+ void setNetSchemeConfig(QStringList & cfg);
+
+private:
+ QList netScheme;
+};
+
+#endif // _AMMO_SCHEME_MODEL_INCLUDED
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/model/hats.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/model/hats.cpp Sat Oct 08 16:54:56 2011 +0200
@@ -0,0 +1,142 @@
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2008-2011 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 "hwconsts.h"
+#include "hwform.h"
+#include "hats.h"
+
+HatsModel::HatsModel(QObject* parent) :
+ QAbstractListModel(parent)
+{
+ QFile hhfile;
+ hhfile.setFileName(cfgdir->absolutePath() + "/Data/Graphics/Hedgehog/Idle.png");
+ if (!hhfile.exists()) hhfile.setFileName(datadir->absolutePath() + "/Graphics/Hedgehog/Idle.png");
+ QPixmap hhpix = QPixmap(QFileInfo(hhfile).absoluteFilePath()).copy(0, 0, 32, 32);
+
+ QDir tmpdir;
+ tmpdir.cd(cfgdir->absolutePath());
+ tmpdir.cd("Data");
+ tmpdir.cd("Graphics");
+ tmpdir.cd("Hats");
+
+ tmpdir.setFilter(QDir::Files);
+
+ QStringList userhatsList = tmpdir.entryList(QStringList("*.png"));
+ for (QStringList::Iterator it = userhatsList.begin(); it != userhatsList.end(); ++it )
+ {
+ QString str = QString(*it).replace(QRegExp("^(.*)\\.png"), "\\1");
+ QPixmap pix(cfgdir->absolutePath() + "/Data/Graphics/Hats/" + str + ".png");
+
+ QPixmap tmppix(32, 37);
+ tmppix.fill(QColor(Qt::transparent));
+
+ QPainter painter(&tmppix);
+ painter.drawPixmap(QPoint(0, 5), hhpix);
+ painter.drawPixmap(QPoint(0, 0), pix.copy(0, 0, 32, 32));
+ if(pix.width() > 32)
+ painter.drawPixmap(QPoint(0, 0), pix.copy(32, 0, 32, 32));
+ painter.end();
+
+ hats.append(qMakePair(str, QIcon(tmppix)));
+ }
+
+ tmpdir.cd(datadir->absolutePath());
+ tmpdir.cd("Graphics");
+ tmpdir.cd("Hats");
+
+ QStringList hatsList = tmpdir.entryList(QStringList("*.png"));
+ for (QStringList::Iterator it = hatsList.begin(); it != hatsList.end(); ++it )
+ {
+ if (userhatsList.contains(*it,Qt::CaseInsensitive)) continue;
+ QString str = (*it).replace(QRegExp("^(.*)\\.png"), "\\1");
+ QPixmap pix(datadir->absolutePath() + "/Graphics/Hats/" + str + ".png");
+
+ QPixmap tmppix(32, 37);
+ tmppix.fill(QColor(Qt::transparent));
+
+ QPainter painter(&tmppix);
+ painter.drawPixmap(QPoint(0, 5), hhpix);
+ painter.drawPixmap(QPoint(0, 0), pix.copy(0, 0, 32, 32));
+ if(pix.width() > 32)
+ painter.drawPixmap(QPoint(0, 0), pix.copy(32, 0, 32, 32));
+ painter.end();
+
+ hats.append(qMakePair(str, QIcon(tmppix)));
+ }
+ // Reserved hats
+ tmpdir.cd("Reserved");
+ hatsList = tmpdir.entryList(QStringList(playerHash+"*.png"));
+ for (QStringList::Iterator it = hatsList.begin(); it != hatsList.end(); ++it )
+ {
+ QString str = (*it).replace(QRegExp("^(.*)\\.png"), "\\1");
+ QPixmap pix(datadir->absolutePath() + "/Graphics/Hats/Reserved/" + str + ".png");
+
+ QPixmap tmppix(32, 37);
+ tmppix.fill(QColor(Qt::transparent));
+
+ QPainter painter(&tmppix);
+ painter.drawPixmap(QPoint(0, 5), hhpix);
+ painter.drawPixmap(QPoint(0, 0), pix.copy(0, 0, 32, 32));
+ painter.end();
+
+ hats.append(qMakePair("Reserved "+str.remove(0,32), QIcon(tmppix)));
+ }
+}
+
+QVariant HatsModel::headerData(int section,
+ Qt::Orientation orientation, int role) const
+{
+ Q_UNUSED(section);
+ Q_UNUSED(orientation);
+ Q_UNUSED(role);
+
+ return QVariant();
+}
+
+int HatsModel::rowCount(const QModelIndex &parent) const
+{
+ if (parent.isValid())
+ return 0;
+ else
+ return hats.size();
+}
+
+/*int HatsModel::columnCount(const QModelIndex & parent) const
+{
+ if (parent.isValid())
+ return 0;
+ else
+ return 2;
+}
+*/
+QVariant HatsModel::data(const QModelIndex &index,
+ int role) const
+{
+ if (!index.isValid() || index.row() < 0
+ || index.row() >= hats.size()
+ || (role != Qt::DisplayRole && role != Qt::DecorationRole))
+ return QVariant();
+
+ if (role == Qt::DisplayRole)
+ return hats.at(index.row()).first;
+ else // role == Qt::DecorationRole
+ return hats.at(index.row()).second;
+}
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/model/hats.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/model/hats.h Sat Oct 08 16:54:56 2011 +0200
@@ -0,0 +1,44 @@
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2008-2011 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 _HATS_INCLUDED
+#define _HATS_INCLUDED
+
+#include
+#include
+#include
+#include
+#include
+
+class HatsModel : public QAbstractListModel
+{
+ Q_OBJECT
+
+public:
+ HatsModel(QObject *parent = 0);
+
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+ int rowCount(const QModelIndex & parent) const;
+ //int columnCount(const QModelIndex & parent) const;
+
+ QVariant data(const QModelIndex &index, int role) const;
+protected:
+ QVector > hats;
+};
+
+#endif // _HATS_INCLUDED
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/model/netserverslist.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/model/netserverslist.cpp Sat Oct 08 16:54:56 2011 +0200
@@ -0,0 +1,68 @@
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2007-2011 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 "netserverslist.h"
+
+HWNetServersModel::HWNetServersModel(QObject* parent) :
+ QAbstractTableModel(parent)
+{
+
+}
+
+void HWNetServersModel::updateList()
+{
+
+}
+
+QVariant HWNetServersModel::headerData(int section,
+ Qt::Orientation orientation, int role) const
+{
+ if (role != Qt::DisplayRole)
+ return QVariant();
+
+ if (orientation == Qt::Horizontal)
+ {
+ switch (section)
+ {
+ case 0: return tr("Title");
+ case 1: return tr("IP");
+ case 2: return tr("Port");
+ default: return QVariant();
+ }
+ } else
+ return QString("%1").arg(section + 1);
+}
+
+int HWNetServersModel::rowCount(const QModelIndex &parent) const
+{
+ if (parent.isValid())
+ return 0;
+ else
+ return games.size();
+}
+
+int HWNetServersModel::columnCount(const QModelIndex & parent) const
+{
+ if (parent.isValid())
+ return 0;
+ else
+ return 3;
+}
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/model/netserverslist.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/model/netserverslist.h Sat Oct 08 16:54:56 2011 +0200
@@ -0,0 +1,43 @@
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2007-2011 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_SERVERSLIST_INCLUDED
+#define _NET_SERVERSLIST_INCLUDED
+
+#include
+#include
+
+class HWNetServersModel : public QAbstractTableModel
+{
+ Q_OBJECT
+
+public:
+ HWNetServersModel(QObject *parent = 0);
+
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+ int rowCount(const QModelIndex & parent) const;
+ int columnCount(const QModelIndex & parent) const;
+
+public slots:
+ virtual void updateList();
+
+protected:
+ QList games;
+};
+
+#endif // _NET_SERVERSLIST_INCLUDED
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/model/themesmodel.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/model/themesmodel.cpp Sat Oct 08 16:54:56 2011 +0200
@@ -0,0 +1,49 @@
+
+#include "themesmodel.h"
+
+ThemesModel::ThemesModel(QStringList themes, QObject *parent) :
+ QAbstractListModel(parent)
+{
+#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
+ m_data.reserve(themes.size());
+#endif
+
+ foreach(QString theme, themes)
+ {
+ m_data.append(QHash());
+ m_data.last().insert(Qt::DisplayRole, theme);
+ }
+}
+
+int ThemesModel::rowCount(const QModelIndex &parent) const
+{
+ if(parent.isValid())
+ return 0;
+ else
+ return m_data.size();
+}
+
+QVariant ThemesModel::data(const QModelIndex &index, int role) const
+{
+ if(index.column() > 0 || index.row() >= m_data.size())
+ return QVariant();
+ else
+ return m_data.at(index.row()).value(role);
+}
+
+bool ThemesModel::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+ if(index.column() > 0 || index.row() >= m_data.size())
+ return false;
+ else
+ {
+ m_data[index.row()].insert(role, value);
+
+ return true;
+ }
+
+}
+
+
+
+
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/model/themesmodel.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/model/themesmodel.h Sat Oct 08 16:54:56 2011 +0200
@@ -0,0 +1,28 @@
+#ifndef THEMESMODEL_H
+#define THEMESMODEL_H
+
+#include
+#include
+#include
+
+class ThemesModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ explicit ThemesModel(QStringList themes, QObject *parent = 0);
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role) const;
+ bool setData(const QModelIndex &index, const QVariant &value,
+ int role = Qt::EditRole);
+
+signals:
+
+public slots:
+
+private:
+
+ QList > m_data;
+};
+
+#endif // THEMESMODEL_H
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/namegen.cpp
--- a/QTfrontend/namegen.cpp Sat Oct 08 16:45:52 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,221 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2009 Martin Minarik
- * Copyright (c) 2009-2011 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 "namegen.h"
-#include "hwform.h"
-#include "hwconsts.h"
-
-
-HWNamegen::HWNamegen() :
- TypesAvliable(false)
-{
-
- TypesLoad();
-}
-
-HWNamegen::~HWNamegen()
-{
-}
-
-
-
-void HWNamegen::TeamRandomName(HWTeam*& team, const int HedgehogNumber)
-{
- RandomNameByHat(team, HedgehogNumber);
-}
-
-void HWNamegen::TeamRandomNames(HWTeam*& team, const bool changeteamname)
-{
- if ((TypesHatnames.size() > 0) && TypesAvliable){
-
- int kind = (rand()%(TypesHatnames.size()));
-
- if (changeteamname){
- if (TypesTeamnames[kind].size() > 0){
- team->TeamName = TypesTeamnames[kind][rand()%(TypesTeamnames[kind].size())];
- }
- team->Grave = GetRandomGrave();
- team->Fort = GetRandomFort();
- team->Voicepack = "Default";
- }
-
- //give each hedgehog a random name:
- //TODO: load the dictionary only once! (right now it's loaded once for each hedgehog)
- for(int i = 0; i < 8; i++)
- {
- if ((TypesHatnames[kind].size()) > 0){
- team->Hedgehogs[i].Hat = TypesHatnames[kind][rand()%(TypesHatnames[kind].size())];
- }
- RandomNameByHat(team,i);
- }
-
- }
-
-}
-
-
-void HWNamegen::RandomNameByHat(HWTeam*& team, const int HedgehogNumber)
-{
- QStringList Dictionaries;
- HatCfgLoad(team->Hedgehogs[HedgehogNumber].Hat,Dictionaries);
-
- QStringList Dictionary;
- DictLoad(Dictionaries[rand()%(Dictionaries.size())],Dictionary);
-
- team->Hedgehogs[HedgehogNumber].Name = Dictionary[rand()%(Dictionary.size())];
-}
-
-void HWNamegen::DictLoad(const QString filename, QStringList &list)
-{
- list.clear();
-
- QFile file;
- file.setFileName(QString("%1/Data/Names/%2.txt").arg(cfgdir->absolutePath()).arg(filename));
- if (!file.exists()) file.setFileName(QString("%1/Names/%2.txt").arg(datadir->absolutePath()).arg(filename));
- if (file.open(QIODevice::ReadOnly | QIODevice::Text))
- {
-
- QTextStream in(&file);
- while (!in.atEnd()) {
- QString line = in.readLine();
- if(line != QString(""))
- {list.append(line);}
- }
- }
-
- if (list.size()==0)
- list.append(filename);
-
-}
-
-
-void HWNamegen::HatCfgLoad(const QString hatname, QStringList &list)
-{
- list.clear();
-
- QFile file;
- file.setFileName(QString("%1/Data/Names/%2.cfg").arg(cfgdir->absolutePath()).arg(hatname));
- if (!file.exists()) file.setFileName(QString("%1/Names/%2.cfg").arg(datadir->absolutePath()).arg(hatname));
- if (file.open(QIODevice::ReadOnly | QIODevice::Text))
- {
-
- QTextStream in(&file);
- while (!in.atEnd()) {
- QString line = in.readLine();
- if(line != QString(""))
- {list.append(line);}
- }
- }
-
- if (list.size()==0)
- list.append(QString("generic"));
-
-}
-
-
-void HWNamegen::TypesLoad()
-{
- QFile file;
- file.setFileName(QString("%1/Data/Names/types.ini").arg(cfgdir->absolutePath()));
- if (!file.exists()) file.setFileName(QString("%1/Names/types.ini").arg(datadir->absolutePath()));
- if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
- {TypesAvliable = FALSE; return;}
-
- int counter = 0; //counter starts with 0 (teamnames mode)
- TypesTeamnames.append(QStringList());
- TypesHatnames.append(QStringList());
-
- QTextStream in(&file);
- while (!in.atEnd()) {
- QString line = in.readLine();
- if (line == QString("#####")){
- counter++; //toggle mode (teamnames || hats)
- if ((counter%2) == 0){
- TypesTeamnames.append(QStringList());
- TypesHatnames.append(QStringList());
- }
- } else if ((line == QString("*****")) || (line == QString("*END*"))){
- TypesAvliable = TRUE; return; // bye bye
- } else {
- if ((counter%2) == 0){ // even => teamnames mode
- TypesTeamnames[(counter/2)].append(line);
- } else { // odd => hats mode
- TypesHatnames[((counter-1)/2)].append(line);
- }
- }
-// Types.append(line);
- }
- TypesAvliable = TRUE;
- return;
-}
-
-
-
-QString HWNamegen::GetRandomGrave()
-{
- QStringList Graves;
-
- //list all available Graves
- QDir tmpdir;
- tmpdir.cd(cfgdir->absolutePath());
- tmpdir.cd("Data/Graphics/Graves");
- tmpdir.setFilter(QDir::Files);
- Graves.append(tmpdir.entryList(QStringList("*.png")).replaceInStrings(QRegExp("^(.*)\\.png"), "\\1"));
-
- tmpdir.cd(datadir->absolutePath());
- tmpdir.cd("Graphics/Graves");
- tmpdir.setFilter(QDir::Files);
- QStringList tmpList = tmpdir.entryList(QStringList("*.png")).replaceInStrings(QRegExp("^(.*)\\.png"), "\\1");
- for (QStringList::Iterator it = tmpList.begin(); it != tmpList.end(); ++it)
- if (!Graves.contains(*it,Qt::CaseInsensitive)) Graves.append(*it);
-
- if(Graves.size()==0)
- {
- //do some serious error handling
- return "Error";
- }
-
- //pick a random grave
- return Graves[rand()%(Graves.size())];
-}
-
-QString HWNamegen::GetRandomFort()
-{
- QStringList Forts;
-
- //list all available Forts
- QDir tmpdir;
- tmpdir.cd(datadir->absolutePath());
- tmpdir.cd("Forts");
- tmpdir.setFilter(QDir::Files);
- Forts.append(tmpdir.entryList(QStringList("*L.png")).replaceInStrings(QRegExp("^(.*)L\\.png"), "\\1"));
-
- if(Forts.size()==0)
- {
- //do some serious error handling
- return "Error";
- }
-
- //pick a random fort
- return Forts[rand()%(Forts.size())];
-}
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/namegen.h
--- a/QTfrontend/namegen.h Sat Oct 08 16:45:52 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-/*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2009 Martin Minarik
- * Copyright (c) 2009-2011 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 NAMEGEN_H
-#define NAMEGEN_H
-
-#include
-
-class HWForm;
-class HWTeam;
-
-class HWNamegen
-{
-public:
- HWNamegen();
- ~HWNamegen();
-
- void TeamRandomName(HWTeam*& team, const int HedgehogNumber);
- void TeamRandomNames(HWTeam*& team, const bool changeteamname);
- void RandomNameByHat(HWTeam*& team, const int HedgehogNumber);
-
-private:
-
- QList TypesTeamnames;
- QList TypesHatnames;
- bool TypesAvliable;
- void TypesLoad();
- void DictLoad(const QString filename, QStringList &list);
- void HatCfgLoad(const QString hatname, QStringList &list);
-
- QString GetRandomGrave();
- QString GetRandomFort();
-};
-
-
-
-#endif
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/net/hwmap.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/net/hwmap.cpp Sat Oct 08 16:54:56 2011 +0200
@@ -0,0 +1,91 @@
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2006-2007 Ulyanov Igor
+ * Copyright (c) 2007-2011 Andrey Korotaev
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include "hwconsts.h"
+#include "hwmap.h"
+
+HWMap::HWMap() :
+ TCPBase(false)
+{
+}
+
+HWMap::~HWMap()
+{
+}
+
+void HWMap::getImage(const QString & seed, int filter, MapGenerator mapgen, int maze_size, const QByteArray & drawMapData)
+{
+ m_seed = seed;
+ templateFilter = filter;
+ m_mapgen = mapgen;
+ m_maze_size = maze_size;
+ if(mapgen == MAPGEN_DRAWN) m_drawMapData = drawMapData;
+ Start();
+}
+
+QStringList HWMap::getArguments()
+{
+ QStringList arguments;
+ arguments << cfgdir->absolutePath();
+ arguments << QString("%1").arg(ipc_port);
+ arguments << "landpreview";
+ return arguments;
+}
+
+void HWMap::onClientDisconnect()
+{
+ if (readbuffer.size() == 128 * 32 + 1)
+ {
+ quint8 *buf = (quint8*) readbuffer.constData();
+ QImage im(buf, 256, 128, QImage::Format_Mono);
+ im.setNumColors(2);
+ emit HHLimitReceived(buf[128 * 32]);
+ emit ImageReceived(im);
+ }
+}
+
+void HWMap::SendToClientFirst()
+{
+ SendIPC(QString("eseed %1").arg(m_seed).toUtf8());
+ SendIPC(QString("e$template_filter %1").arg(templateFilter).toUtf8());
+ SendIPC(QString("e$mapgen %1").arg(m_mapgen).toUtf8());
+
+ switch (m_mapgen)
+ {
+ case MAPGEN_MAZE:
+ SendIPC(QString("e$maze_size %1").arg(m_maze_size).toUtf8());
+ break;
+
+ case MAPGEN_DRAWN:
+ {
+ QByteArray data = m_drawMapData;
+ while(data.size() > 0)
+ {
+ QByteArray tmp = data;
+ tmp.truncate(200);
+ SendIPC("edraw " + tmp);
+ data.remove(0, 200);
+ }
+ break;
+ }
+ default: ;
+ }
+
+ SendIPC("!");
+}
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/net/hwmap.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/net/hwmap.h Sat Oct 08 16:54:56 2011 +0200
@@ -0,0 +1,65 @@
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2006 Igor Ulyanov
+ * Copyright (c) 2006-2011 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 _HWMAP_INCLUDED
+#define _HWMAP_INCLUDED
+
+#include
+#include
+#include
+
+#include "tcpBase.h"
+
+enum MapGenerator
+{
+ MAPGEN_REGULAR,
+ MAPGEN_MAZE,
+ MAPGEN_DRAWN,
+ MAPGEN_MAP
+};
+
+class HWMap : public TCPBase
+{
+ Q_OBJECT
+
+ public:
+ HWMap();
+ virtual ~HWMap();
+ void getImage(const QString & seed, int templateFilter, MapGenerator mapgen, int maze_size, const QByteArray & drawMapData);
+
+ protected:
+ virtual QStringList getArguments();
+ virtual void onClientDisconnect();
+ virtual void SendToClientFirst();
+
+ signals:
+ void ImageReceived(const QImage newImage);
+ void HHLimitReceived(int hhLimit);
+
+ private:
+ QString m_seed;
+ int templateFilter;
+ MapGenerator m_mapgen;
+ int m_maze_size;
+ QByteArray m_drawMapData;
+
+ private slots:
+};
+
+#endif // _HWMAP_INCLUDED
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/net/netregister.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/net/netregister.cpp Sat Oct 08 16:54:56 2011 +0200
@@ -0,0 +1,31 @@
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2007-2011 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 "netregister.h"
+
+HWNetRegisterServer::HWNetRegisterServer(QObject *parent, const QString & descr, quint16 port) :
+ QObject(parent)
+{
+ Q_UNUSED(descr);
+ Q_UNUSED(port);
+}
+
+void HWNetRegisterServer::unregister()
+{
+
+}
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/net/netregister.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/net/netregister.h Sat Oct 08 16:54:56 2011 +0200
@@ -0,0 +1,35 @@
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2007-2011 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_REGISTER_INCLUDED
+#define _NET_REGISTER_INCLUDED
+
+#include
+
+class HWNetRegisterServer : public QObject
+{
+ Q_OBJECT
+
+public:
+ HWNetRegisterServer(QObject *parent, const QString & descr, quint16 port);
+
+public slots:
+ virtual void unregister();
+};
+
+#endif // _NET_REGISTER_INCLUDED
diff -r 531f64292489 -r 5a4ea2c7b9df QTfrontend/net/netserver.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/net/netserver.cpp Sat Oct 08 16:54:56 2011 +0200
@@ -0,0 +1,52 @@
+/*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2006-2008 Igor Ulyanov