# HG changeset patch # User nemo # Date 1327962738 18000 # Node ID f77bb02b669f5ab667220418b871f2344c037495 # Parent 65602f1ef0f89ccb7db4114ae5a8bb2cfa986707 astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h" diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/HWApplication.cpp --- a/QTfrontend/HWApplication.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/HWApplication.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -22,15 +22,17 @@ #include "hwform.h" HWApplication::HWApplication(int &argc, char **argv): - QApplication(argc, argv) + QApplication(argc, argv) { } -bool HWApplication::event(QEvent *event) { +bool HWApplication::event(QEvent *event) +{ QFileOpenEvent *openEvent; - switch (event->type()) { + switch (event->type()) + { case QEvent::FileOpen: openEvent = (QFileOpenEvent *)event; if (form) form->PlayDemoQuick(openEvent->file()); diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/HWApplication.h --- a/QTfrontend/HWApplication.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/HWApplication.h Mon Jan 30 17:32:18 2012 -0500 @@ -35,14 +35,14 @@ */ class HWApplication : public QApplication { - Q_OBJECT -public: - HWApplication(int &argc, char **argv); - ~HWApplication() {}; + Q_OBJECT + public: + HWApplication(int &argc, char **argv); + ~HWApplication() {}; - HWForm *form; -protected: - bool event(QEvent *); + HWForm *form; + protected: + bool event(QEvent *); }; #endif diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/KB.h --- a/QTfrontend/KB.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/KB.h Mon Jan 30 17:32:18 2012 -0500 @@ -26,9 +26,9 @@ const QString KBMessages[KBmsgsCount] = { QT_TRANSLATE_NOOP("KB", "SDL_ttf returned error while rendering text, " - "most propably it is related to the bug " - "in freetype2. It's recommended to update your " - "freetype lib.") + "most propably it is related to the bug " + "in freetype2. It's recommended to update your " + "freetype lib.") }; #endif // KB_H diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/M3InstallController.h --- a/QTfrontend/M3InstallController.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/M3InstallController.h Mon Jan 30 17:32:18 2012 -0500 @@ -42,7 +42,9 @@ //#endif -@interface M3InstallController : NSObject { +@interface M3InstallController : +NSObject +{ NSAlert *alert; } diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/NSWorkspace_RBAdditions.h --- a/QTfrontend/NSWorkspace_RBAdditions.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/NSWorkspace_RBAdditions.h Mon Jan 30 17:32:18 2012 -0500 @@ -32,6 +32,7 @@ //- NSWorkspace_RBimagefilepath: should be present for disk images only. Shows the path of the disk image file. //- NSWorkspace_RBserverURL: should be present for remote volumes only. Shows the server URL. -- (NSDictionary*)propertiesForPath:(NSString*)path; +- (NSDictionary*)propertiesForPath: +(NSString*)path; @end diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/achievements.cpp --- a/QTfrontend/achievements.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/achievements.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -21,7 +21,8 @@ #include "achievements.h" // TODO: use some structs instead? -const char achievements[][6][256] = { +const char achievements[][6][256] = +{ // 6 array members each: id, caption, description, image, required number, attributes /* {"rounds1", QT_TRANSLATE_NOOP("achievements", "No complete Newbie!"), QT_TRANSLATE_NOOP("achievements", "Manage to survive %1 games playing on the official server, no matter if it's a draw or win."), "nonewb", "1", ""}, diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/drawmapscene.cpp --- a/QTfrontend/drawmapscene.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/drawmapscene.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -58,7 +58,8 @@ QPointF pos = mouseEvent->scenePos(); path.setElementPositionAt(c - 1, pos.x(), pos.y()); - } else + } + else { path.lineTo(mouseEvent->scenePos()); paths.first().append(mouseEvent->scenePos().toPoint()); @@ -127,7 +128,8 @@ oldItems.clear(); // do this since clear() would _destroy_ all items - while(items().size()) { + while(items().size()) + { oldItems.push_front(items().first()); removeItem(items().first()); } @@ -214,7 +216,7 @@ while(i < points.size()) { if( (i != points.size() - 1) - && (sqr(prevPoint.x() - points[i].x()) + sqr(prevPoint.y() - points[i].y()) < 1000) + && (sqr(prevPoint.x() - points[i].x()) + sqr(prevPoint.y() - points[i].y()) < 1000) ) points.removeAt(i); else @@ -246,7 +248,7 @@ path.moveTo(p); foreach(QPoint p, points) - path.lineTo(p); + path.lineTo(p); } return path; diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/drawmapscene.h --- a/QTfrontend/drawmapscene.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/drawmapscene.h Mon Jan 30 17:32:18 2012 -0500 @@ -28,34 +28,34 @@ class DrawMapScene : public QGraphicsScene { -Q_OBJECT -public: - explicit DrawMapScene(QObject *parent = 0); + Q_OBJECT + public: + explicit DrawMapScene(QObject *parent = 0); - QByteArray encode(); - void decode(QByteArray data); + QByteArray encode(); + void decode(QByteArray data); -signals: - void pathChanged(); + signals: + void pathChanged(); -public slots: - void undo(); - void clearMap(); - void simplifyLast(); + public slots: + void undo(); + void clearMap(); + void simplifyLast(); -private: - QPen m_pen; - QBrush m_brush; - QGraphicsPathItem * m_currPath; - Paths paths; - Paths oldPaths; - QList oldItems; + private: + QPen m_pen; + QBrush m_brush; + QGraphicsPathItem * m_currPath; + Paths paths; + Paths oldPaths; + QList oldItems; - virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent); - virtual void mousePressEvent(QGraphicsSceneMouseEvent * mouseEvent); - virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent * mouseEvent); + virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent); + virtual void mousePressEvent(QGraphicsSceneMouseEvent * mouseEvent); + virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent * mouseEvent); - QPainterPath pointsToPath(const QList points); + QPainterPath pointsToPath(const QList points); }; #endif // DRAWMAPSCENE_H diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/game.cpp --- a/QTfrontend/game.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/game.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -35,9 +35,9 @@ QString training, campaign; // TODO: Cleaner solution? HWGame::HWGame(GameUIConfig * config, GameCFGWidget * gamecfg, QString ammo, TeamSelWidget* pTeamSelWidget) : - TCPBase(true), - ammostr(ammo), - m_pTeamSelWidget(pTeamSelWidget) + TCPBase(true), + ammostr(ammo), + m_pTeamSelWidget(pTeamSelWidget) { this->config = config; this->gamecfg = gamecfg; @@ -51,12 +51,13 @@ void HWGame::onClientDisconnect() { - switch (gameType) { + switch (gameType) + { case gtSave: if (gameState == gsInterrupted || gameState == gsHalted) emit HaveRecord(false, demo); else if (gameState == gsFinished) - emit HaveRecord(true, demo); + emit HaveRecord(true, demo); break; case gtDemo: break; @@ -74,7 +75,8 @@ { QByteArray buf; QString gt; - switch (gameType) { + switch (gameType) + { case gtDemo: gt = "TD"; break; @@ -98,7 +100,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())); ; } } @@ -116,7 +118,7 @@ HWProto::addStringToBuffer(teamscfg, "TL"); HWProto::addStringToBuffer(teamscfg, QString("etheme %1") - .arg((themesModel->rowCount() > 0) ? themesModel->index(rand() % themesModel->rowCount()).data().toString() : "steel")); + .arg((themesModel->rowCount() > 0) ? themesModel->index(rand() % themesModel->rowCount()).data().toString() : "steel")); HWProto::addStringToBuffer(teamscfg, "eseed " + QUuid::createUuid().toString()); HWTeam team1; @@ -125,7 +127,7 @@ team1.setNumHedgehogs(4); HWNamegen::teamRandomNames(team1,true); HWProto::addStringListToBuffer(teamscfg, - team1.teamGameConfig(100)); + team1.teamGameConfig(100)); HWTeam team2; team2.setDifficulty(4); @@ -135,7 +137,7 @@ 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))); @@ -173,48 +175,61 @@ void HWGame::ParseMessage(const QByteArray & msg) { - switch(msg.at(1)) { - case '?': { + switch(msg.at(1)) + { + case '?': + { SendIPC("!"); break; } - case 'C': { - switch (gameType) { - case gtLocal: { + case 'C': + { + switch (gameType) + { + case gtLocal: + { SendConfig(); break; } - case gtQLocal: { + case gtQLocal: + { SendQuickConfig(); break; } case gtSave: - case gtDemo: break; - case gtNet: { + case gtDemo: + break; + case gtNet: + { SendNetConfig(); break; } - case gtTraining: { + case gtTraining: + { SendTrainingConfig(); break; } - case gtCampaign: { + case gtCampaign: + { SendCampaignConfig(); break; } } break; } - case 'E': { + case 'E': + { int size = msg.size(); emit ErrorMessage(QString("Last two engine messages:\n") + QString().append(msg.mid(2)).left(size - 4)); return; } - case 'K': { + case 'K': + { ulong kb = msg.mid(2).toULong(); - if (kb==1) { - qWarning("%s", KBMessages[kb - 1].toLocal8Bit().constData()); - return; + if (kb==1) + { + qWarning("%s", KBMessages[kb - 1].toLocal8Bit().constData()); + return; } if (kb && kb <= KBmsgsCount) { @@ -222,23 +237,28 @@ } return; } - case 'i': { + case 'i': + { emit GameStats(msg.at(2), QString::fromUtf8(msg.mid(3))); break; } - case 'Q': { + case 'Q': + { SetGameState(gsInterrupted); break; } - case 'q': { + case 'q': + { SetGameState(gsFinished); break; } - case 'H': { + case 'H': + { SetGameState(gsHalted); break; } - case 's': { + case 's': + { int size = msg.size(); QString msgbody = QString::fromUtf8(msg.mid(2).left(size - 4)); emit SendChat(msgbody); @@ -248,13 +268,15 @@ demo.append(buf); break; } - case 'b': { + case 'b': + { int size = msg.size(); QString msgbody = QString::fromUtf8(msg.mid(2).left(size - 4)); emit SendTeamMessage(msgbody); break; } - default: { + default: + { if (gameType == gtNet && !netSuspend) { emit SendNet(msg); diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/game.h --- a/QTfrontend/game.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/game.h Mon Jan 30 17:32:18 2012 -0500 @@ -29,7 +29,8 @@ class GameCFGWidget; class TeamSelWidget; -enum GameState { +enum GameState +{ gsNotStarted = 0, gsStarted = 1, gsInterrupted = 2, @@ -43,64 +44,65 @@ class HWGame : public TCPBase { - Q_OBJECT -public: - HWGame(GameUIConfig * config, GameCFGWidget * gamecfg, QString ammo, TeamSelWidget* pTeamSelWidget = 0); - virtual ~HWGame(); - void AddTeam(const QString & team); - void PlayDemo(const QString & demofilename, bool isSave); - void StartLocal(); - void StartQuick(); - void StartNet(); - void StartTraining(const QString & file); - void StartCampaign(const QString & file); - void abort(); - GameState gameState; - bool netSuspend; + Q_OBJECT + public: + HWGame(GameUIConfig * config, GameCFGWidget * gamecfg, QString ammo, TeamSelWidget* pTeamSelWidget = 0); + virtual ~HWGame(); + void AddTeam(const QString & team); + void PlayDemo(const QString & demofilename, bool isSave); + void StartLocal(); + void StartQuick(); + void StartNet(); + void StartTraining(const QString & file); + void StartCampaign(const QString & file); + void abort(); + GameState gameState; + bool netSuspend; - protected: - virtual QStringList getArguments(); - virtual void onClientRead(); - virtual void onClientDisconnect(); + protected: + virtual QStringList getArguments(); + virtual void onClientRead(); + virtual void onClientDisconnect(); -signals: - void SendNet(const QByteArray & msg); - void SendChat(const QString & msg); - void SendTeamMessage(const QString & msg); - void GameStateChanged(GameState gameState); - void GameStats(char type, const QString & info); - void HaveRecord(bool isDemo, const QByteArray & record); - void ErrorMessage(const QString &); + signals: + void SendNet(const QByteArray & msg); + void SendChat(const QString & msg); + void SendTeamMessage(const QString & msg); + void GameStateChanged(GameState gameState); + void GameStats(char type, const QString & info); + void HaveRecord(bool isDemo, const QByteArray & record); + void ErrorMessage(const QString &); -public slots: - void FromNet(const QByteArray & msg); - void FromNetChat(const QString & msg); + public slots: + void FromNet(const QByteArray & msg); + void FromNetChat(const QString & msg); -private: - enum GameType { - gtLocal = 1, - gtQLocal = 2, - gtDemo = 3, - gtNet = 4, - gtTraining = 5, - gtCampaign = 6, - gtSave = 7, - }; - char msgbuf[MAXMSGCHARS]; - QString ammostr; - GameUIConfig * config; - GameCFGWidget * gamecfg; - TeamSelWidget* m_pTeamSelWidget; - GameType gameType; + private: + enum GameType + { + gtLocal = 1, + gtQLocal = 2, + gtDemo = 3, + gtNet = 4, + gtTraining = 5, + gtCampaign = 6, + gtSave = 7, + }; + char msgbuf[MAXMSGCHARS]; + QString ammostr; + GameUIConfig * config; + GameCFGWidget * gamecfg; + TeamSelWidget* m_pTeamSelWidget; + GameType gameType; - void commonConfig(); - void SendConfig(); - void SendQuickConfig(); - void SendNetConfig(); - void SendTrainingConfig(); - void SendCampaignConfig(); - void ParseMessage(const QByteArray & msg); - void SetGameState(GameState state); + void commonConfig(); + void SendConfig(); + void SendQuickConfig(); + void SendNetConfig(); + void SendTrainingConfig(); + void SendCampaignConfig(); + void ParseMessage(const QByteArray & msg); + void SetGameState(GameState state); }; #endif diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/gameuiconfig.cpp --- a/QTfrontend/gameuiconfig.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/gameuiconfig.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -44,10 +44,11 @@ Form->ui.pageOptions->WeaponTooltip->setChecked(value("misc/weaponTooltips", true).toBool()); int t = Form->ui.pageOptions->CBResolution->findText(value("video/resolution").toString()); - if (t < 0) { + if (t < 0) + { if (Form->ui.pageOptions->CBResolution->count() > 1) Form->ui.pageOptions->CBResolution->setCurrentIndex(1); - else + else Form->ui.pageOptions->CBResolution->setCurrentIndex(0); } else Form->ui.pageOptions->CBResolution->setCurrentIndex(t); @@ -67,9 +68,9 @@ QString netNick = value("net/nick", "").toString(); Form->ui.pageOptions->editNetNick->setText(netNick); - + Form->ui.pageOptions->editNetPassword->installEventFilter(this); - + int passLength = value("net/passwordlength", 0).toInt(); setNetPasswordLength(passLength); @@ -87,7 +88,7 @@ Form->ui.pageOptions->CBNameWithDate->setChecked(value("misc/appendTimeToRecords", false).toBool()); #ifdef SPARKLE_ENABLED - Form->ui.pageOptions->CBAutoUpdate->setChecked(value("misc/autoUpdate", true).toBool()); + Form->ui.pageOptions->CBAutoUpdate->setChecked(value("misc/autoUpdate", true).toBool()); #endif Form->ui.pageOptions->CBLanguage->setCurrentIndex(Form->ui.pageOptions->CBLanguage->findData(value("misc/locale", "").toString())); @@ -103,16 +104,17 @@ teamdir.cd(cfgdir->absolutePath() + "/Teams"); QStringList teamslist = teamdir.entryList(QStringList("*.hwt"),QDir::Files|QDir::Hidden); QStringList cleanedList; - for (QStringList::Iterator it = teamslist.begin(); it != teamslist.end(); ++it ) { - QString tmpTeamStr=(*it).replace(QRegExp("^(.*)\\.hwt$"), "\\1"); - cleanedList.push_back(tmpTeamStr); + for (QStringList::Iterator it = teamslist.begin(); it != teamslist.end(); ++it ) + { + QString tmpTeamStr=(*it).replace(QRegExp("^(.*)\\.hwt$"), "\\1"); + cleanedList.push_back(tmpTeamStr); } return cleanedList; } void GameUIConfig::resizeToConfigValues() { - Form->resize(value("frontend/width", 800).toUInt(), value("frontend/height", 600).toUInt()); + Form->resize(value("frontend/width", 800).toUInt(), value("frontend/height", 600).toUInt()); } void GameUIConfig::SaveOptions() @@ -130,11 +132,14 @@ bool ffscr = isFrontendFullscreen(); setValue("frontend/fullscreen", ffscr); emit frontendFullscreen(ffscr); - if (!ffscr) { - setValue("frontend/width", Form->width()); - setValue("frontend/height", Form->height()); - } else { - //resizeToConfigValues(); // TODO: why this has been made? + if (!ffscr) + { + setValue("frontend/width", Form->width()); + setValue("frontend/height", Form->height()); + } + else + { + //resizeToConfigValues(); // TODO: why this has been made? } setValue("audio/sound", isSoundEnabled()); @@ -156,13 +161,13 @@ setValue("fps/show", isShowFPSEnabled()); setValue("fps/limit", Form->ui.pageOptions->fpsedit->value()); - + setValue("misc/altdamage", isAltDamageEnabled()); setValue("misc/appendTimeToRecords", appendDateTimeToRecordName()); setValue("misc/locale", language()); #ifdef SPARKLE_ENABLED - setValue("misc/autoUpdate", isAutoUpdateEnabled()); + setValue("misc/autoUpdate", isAutoUpdateEnabled()); #endif Form->gameSettings->sync(); } @@ -204,47 +209,48 @@ quint32 rqClampLess = 0x00000200; // don't clamp textures quint32 rqTooltipsOff = 0x00000400; // tooltips are not drawn quint32 rqDesyncVBlank = 0x00000800; // don't sync on vblank - + quint32 result = (Form->ui.pageOptions->WeaponTooltip->isChecked()) ? rqNone : rqTooltipsOff; - - switch (Form->ui.pageOptions->SLQuality->value()) { - case 5: - break; - case 4: - result |= rqBlurryLand; - break; - case 3: - result |= rqBlurryLand | rqKillFlakes | rqPlainSplash; - break; - case 2: - result |= rqBlurryLand | rqKillFlakes | rqPlainSplash | rq2DWater | - rqAntiBoom | rqSlowMenu; - break; - case 1: - result |= rqBlurryLand | rqKillFlakes | rqPlainSplash | rq2DWater | - rqAntiBoom | rqSlowMenu | rqSimpleRope | rqDesyncVBlank; - break; - case 0: - result |= rqBlurryLand | rqKillFlakes | rqPlainSplash | rq2DWater | - rqAntiBoom | rqSlowMenu | rqSimpleRope | rqDesyncVBlank | - rqNoBackground | rqClampLess; - break; - default: - fprintf(stderr,"unset value from slider"); - break; + + switch (Form->ui.pageOptions->SLQuality->value()) + { + case 5: + break; + case 4: + result |= rqBlurryLand; + break; + case 3: + result |= rqBlurryLand | rqKillFlakes | rqPlainSplash; + break; + case 2: + result |= rqBlurryLand | rqKillFlakes | rqPlainSplash | rq2DWater | + rqAntiBoom | rqSlowMenu; + break; + case 1: + result |= rqBlurryLand | rqKillFlakes | rqPlainSplash | rq2DWater | + rqAntiBoom | rqSlowMenu | rqSimpleRope | rqDesyncVBlank; + break; + case 0: + result |= rqBlurryLand | rqKillFlakes | rqPlainSplash | rq2DWater | + rqAntiBoom | rqSlowMenu | rqSimpleRope | rqDesyncVBlank | + rqNoBackground | rqClampLess; + break; + default: + fprintf(stderr,"unset value from slider"); + break; } - + return result; } bool GameUIConfig::isFrontendEffects() const { - return Form->ui.pageOptions->CBFrontendEffects->isChecked(); + return Form->ui.pageOptions->CBFrontendEffects->isChecked(); } bool GameUIConfig::isFrontendFullscreen() const { - return Form->ui.pageOptions->CBFrontendFullscreen->isChecked(); + return Form->ui.pageOptions->CBFrontendFullscreen->isChecked(); } bool GameUIConfig::isSoundEnabled() @@ -340,7 +346,7 @@ } } } - + // Don't filter anything return false; } diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/gameuiconfig.h --- a/QTfrontend/gameuiconfig.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/gameuiconfig.h Mon Jan 30 17:32:18 2012 -0500 @@ -29,52 +29,52 @@ class GameUIConfig : public QSettings { - Q_OBJECT + Q_OBJECT -public: - HWForm * Form; - GameUIConfig(HWForm * FormWidgets, const QString & fileName); - QStringList GetTeamsList(); - QRect vid_Resolution(); - bool vid_Fullscreen(); - quint32 translateQuality(); - bool isSoundEnabled(); - bool isFrontendSoundEnabled(); - QString language(); - bool isMusicEnabled(); - bool isFrontendMusicEnabled(); - bool isShowFPSEnabled(); - bool isAltDamageEnabled(); - bool appendDateTimeToRecordName(); - quint8 volume(); - quint8 timerInterval(); - quint8 bitDepth(); - QString netNick(); - QByteArray netPasswordHash(); - int netPasswordLength(); - void setNetPasswordLength(int passwordLength); - bool isReducedQuality() const; - bool isFrontendEffects() const; - bool isFrontendFullscreen() const; - void resizeToConfigValues(); - quint32 stereoMode() const; + public: + HWForm * Form; + GameUIConfig(HWForm * FormWidgets, const QString & fileName); + QStringList GetTeamsList(); + QRect vid_Resolution(); + bool vid_Fullscreen(); + quint32 translateQuality(); + bool isSoundEnabled(); + bool isFrontendSoundEnabled(); + QString language(); + bool isMusicEnabled(); + bool isFrontendMusicEnabled(); + bool isShowFPSEnabled(); + bool isAltDamageEnabled(); + bool appendDateTimeToRecordName(); + quint8 volume(); + quint8 timerInterval(); + quint8 bitDepth(); + QString netNick(); + QByteArray netPasswordHash(); + int netPasswordLength(); + void setNetPasswordLength(int passwordLength); + bool isReducedQuality() const; + bool isFrontendEffects() const; + bool isFrontendFullscreen() const; + void resizeToConfigValues(); + quint32 stereoMode() const; #ifdef __APPLE__ #ifdef SPARKLE_ENABLED - bool isAutoUpdateEnabled(); + bool isAutoUpdateEnabled(); #endif #endif - signals: - void frontendFullscreen(bool value); + signals: + void frontendFullscreen(bool value); -public slots: - void SaveOptions(); - void updNetNick(); -private: - bool netPasswordIsValid(); - bool eventFilter(QObject *object, QEvent *event); - quint8 depth; + public slots: + void SaveOptions(); + void updNetNick(); + private: + bool netPasswordIsValid(); + bool eventFilter(QObject *object, QEvent *event); + quint8 depth; }; #endif diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/hwconsts.h --- a/QTfrontend/hwconsts.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/hwconsts.h Mon Jan 30 17:32:18 2012 -0500 @@ -121,7 +121,7 @@ 0xffcfcfc4, /. pastel gray ./ \ 0xffbff000, /. lime ./ \ 0xffffef00, /. yellow ./ \ - // add new colors here + // add new colors here 0 }*/ /* #define HW_TEAMCOLOR_ARRAY { 0xffd12b42, /. red ./ \ diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/hwform.cpp --- a/QTfrontend/hwform.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/hwform.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -109,12 +109,12 @@ QSettings* HWForm::gameSettings = NULL; HWForm::HWForm(QWidget *parent, QString styleSheet) - : QMainWindow(parent) - , game(0) - , pnetserver(0) - , pRegisterServer(0) - , editedTeam(0) - , hwnet(0) + : QMainWindow(parent) + , game(0) + , pnetserver(0) + , pRegisterServer(0) + , editedTeam(0) + , hwnet(0) { // set music track SDLInteraction::instance().setMusicTrack( @@ -181,7 +181,7 @@ connect(ui.pageMain->BtnFeedback, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); pageSwitchMapper->setMapping(ui.pageMain->BtnFeedback, ID_PAGE_FEEDBACK); - + connect(ui.pageMain->BtnNet, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); pageSwitchMapper->setMapping(ui.pageMain->BtnNet, ID_PAGE_NETTYPE); @@ -200,7 +200,7 @@ connect(ui.pageMultiplayer->BtnStartMPGame, SIGNAL(clicked()), this, SLOT(StartMPGame())); connect(ui.pageMultiplayer->teamsSelect, SIGNAL(setEnabledGameStart(bool)), - ui.pageMultiplayer->BtnStartMPGame, SLOT(setEnabled(bool))); + ui.pageMultiplayer->BtnStartMPGame, SLOT(setEnabled(bool))); connect(ui.pageMultiplayer, SIGNAL(SetupClicked()), this, SLOT(IntermediateSetup())); connect(ui.pageMultiplayer->gameCFG, SIGNAL(goToSchemes(int)), this, SLOT(GoToScheme(int))); connect(ui.pageMultiplayer->gameCFG, SIGNAL(goToWeapons(int)), this, SLOT(GoToSelectWeaponSet(int))); @@ -235,7 +235,7 @@ connect(ui.pageNetServer->BtnStart, SIGNAL(clicked()), this, SLOT(NetStartServer())); connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(setEnabledGameStart(bool)), - ui.pageNetGame->BtnStart, SLOT(setEnabled(bool))); + ui.pageNetGame->BtnStart, SLOT(setEnabled(bool))); connect(ui.pageNetGame, SIGNAL(SetupClicked()), this, SLOT(IntermediateSetup())); connect(ui.pageNetGame->pGameCFG, SIGNAL(goToSchemes(int)), this, SLOT(GoToScheme(int))); connect(ui.pageNetGame->pGameCFG, SIGNAL(goToWeapons(int)), this, SLOT(GoToSelectWeaponSet(int))); @@ -269,9 +269,9 @@ connect(ui.pageSelectWeapon->BtnDelete, SIGNAL(clicked()), - ui.pageSelectWeapon->pWeapons, SLOT(deleteWeaponsName())); // executed first + ui.pageSelectWeapon->pWeapons, SLOT(deleteWeaponsName())); // executed first connect(ui.pageSelectWeapon->pWeapons, SIGNAL(weaponsDeleted()), - this, SLOT(UpdateWeapons())); // executed second + this, SLOT(UpdateWeapons())); // executed second //connect(ui.pageSelectWeapon->pWeapons, SIGNAL(weaponsDeleted()), // this, SLOT(GoBack())); // executed third @@ -325,26 +325,26 @@ { case HWNewNet::Connecting: // Connecting case HWNewNet::Connected: - xfire_setvalue(XFIRE_STATUS, "Connecting"); - xfire_setvalue(XFIRE_NICKNAME, "-"); - xfire_setvalue(XFIRE_ROOM, "-"); + xfire_setvalue(XFIRE_STATUS, "Connecting"); + xfire_setvalue(XFIRE_NICKNAME, "-"); + xfire_setvalue(XFIRE_ROOM, "-"); 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; + xfire_setvalue(XFIRE_STATUS, "Online"); + xfire_setvalue(XFIRE_NICKNAME, hwnet->getNick().toAscii()); + xfire_setvalue(XFIRE_ROOM, "In game lobby"); + break; 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; + xfire_setvalue(XFIRE_STATUS, "Online"); + xfire_setvalue(XFIRE_NICKNAME, hwnet->getNick().toAscii()); + xfire_setvalue(XFIRE_ROOM, (hwnet->getRoom() + " (waiting for players)").toAscii()); + break; 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()); - break; + xfire_setvalue(XFIRE_STATUS, "Online"); + xfire_setvalue(XFIRE_NICKNAME, hwnet->getNick().toAscii()); + xfire_setvalue(XFIRE_ROOM, (hwnet->getRoom() + " (playing or spectating)").toAscii()); + break; default: - break; + break; } } else @@ -360,11 +360,12 @@ void HWForm::onFrontendFullscreen(bool value) { - if (value) - setWindowState(windowState() | Qt::WindowFullScreen); - else { - setWindowState(windowState() & static_cast(!Qt::WindowFullScreen)); - } + if (value) + setWindowState(windowState() | Qt::WindowFullScreen); + else + { + setWindowState(windowState() & static_cast(!Qt::WindowFullScreen)); + } } void HWForm::onFrontendEffects(bool value) @@ -379,7 +380,7 @@ /* void HWForm::keyReleaseEvent(QKeyEvent *event) { - if (event->key() == Qt::Key_Escape) + if (event->key() == Qt::Key_Escape) this->GoBack(); } */ @@ -407,14 +408,16 @@ QStringList names = ui.pageSelectWeapon->pWeapons->getWeaponNames(); - for(QVector::iterator it = combos.begin(); it != combos.end(); ++it) { + for(QVector::iterator it = combos.begin(); it != combos.end(); ++it) + { (*it)->clear(); for(int i = 0; i < names.size(); ++i) (*it)->addItem(names[i], ui.pageSelectWeapon->pWeapons->getWeaponsString(names[i])); int pos = (*it)->findText("Default"); - if (pos != -1) { + if (pos != -1) + { (*it)->setCurrentIndex(pos); } } @@ -423,13 +426,17 @@ void HWForm::UpdateTeamsLists(const QStringList* editable_teams) { QStringList teamslist; - if(editable_teams) { - teamslist =* editable_teams; - } else { - teamslist = config->GetTeamsList(); + if(editable_teams) + { + teamslist =* editable_teams; + } + else + { + teamslist = config->GetTeamsList(); } - if(teamslist.empty()) { + if(teamslist.empty()) + { HWTeam defaultTeam(tr("DefaultTeam")); defaultTeam.saveToFile(); teamslist.push_back(tr("DefaultTeam")); @@ -507,7 +514,8 @@ { ui.pageDataDownload->fetchList(); } - if (id == ID_PAGE_DRAWMAP) { + if (id == ID_PAGE_DRAWMAP) + { DrawMapScene * scene; if(lastid == ID_PAGE_MULTIPLAYER) scene = ui.pageMultiplayer->gameCFG->pMapContainer->getDrawMapScene(); @@ -517,55 +525,69 @@ ui.pageDrawMap->drawMapWidget->setScene(scene); } - if (lastid == ID_PAGE_DRAWMAP) { + if (lastid == ID_PAGE_DRAWMAP) + { if (id == ID_PAGE_MULTIPLAYER) ui.pageMultiplayer->gameCFG->pMapContainer->mapDrawingFinished(); else ui.pageNetGame->pGameCFG->pMapContainer->mapDrawingFinished(); } - if (id == ID_PAGE_ROOMSLIST) { - if (hwnet && game && game->gameState == gsStarted) { // abnormal exit - kick or room destruction - send kills. + if (id == ID_PAGE_ROOMSLIST) + { + if (hwnet && game && game->gameState == gsStarted) // abnormal exit - kick or room destruction - send kills. + { game->netSuspend = true; ui.pageRoomsList->displayWarning(tr("Game aborted")); game->abort(); } } - if (id == ID_PAGE_MULTIPLAYER || id == ID_PAGE_NETGAME) { + if (id == ID_PAGE_MULTIPLAYER || id == ID_PAGE_NETGAME) + { QStringList tmNames = config->GetTeamsList(); TeamSelWidget* curTeamSelWidget; ui.pageOptions->setTeamOptionsEnabled(false); - if (id == ID_PAGE_MULTIPLAYER) { + if (id == ID_PAGE_MULTIPLAYER) + { curTeamSelWidget = ui.pageMultiplayer->teamsSelect; - } else { + } + else + { curTeamSelWidget = ui.pageNetGame->pNetTeamsWidget; } QList teamsList; - for (QStringList::iterator it = tmNames.begin(); it != tmNames.end(); it++) { + for (QStringList::iterator it = tmNames.begin(); it != tmNames.end(); it++) + { HWTeam team(*it); team.loadFromFile(); teamsList.push_back(team); } - if (lastid == ID_PAGE_SETUP || lastid == ID_PAGE_DRAWMAP) { // _TEAM - if (editedTeam) { + if (lastid == ID_PAGE_SETUP || lastid == ID_PAGE_DRAWMAP) // _TEAM + { + if (editedTeam) + { curTeamSelWidget->addTeam(*editedTeam); } - } else if (lastid != ID_PAGE_GAMESTATS - && lastid != ID_PAGE_INGAME - && lastid != ID_PAGE_SCHEME - && lastid != ID_PAGE_SELECTWEAPON) { + } + else if (lastid != ID_PAGE_GAMESTATS + && lastid != ID_PAGE_INGAME + && lastid != ID_PAGE_SCHEME + && lastid != ID_PAGE_SELECTWEAPON) + { curTeamSelWidget->resetPlayingTeams(teamsList); } - } else - if (id == ID_PAGE_GAMESTATS) { - ui.pageGameStats->renderStats(); - } + } + else if (id == ID_PAGE_GAMESTATS) + { + ui.pageGameStats->renderStats(); + } - if (id == ID_PAGE_MAIN) { + if (id == ID_PAGE_MAIN) + { ui.pageOptions->setTeamOptionsEnabled(true); } @@ -577,7 +599,7 @@ if (id == ID_PAGE_NETGAME) // joining a room ui.pageNetGame->pChatWidget->loadLists(ui.pageOptions->editNetNick->text()); -// joining the lobby +// joining the lobby else if (id == ID_PAGE_ROOMSLIST) ui.pageRoomsList->chatWidget->loadLists(ui.pageOptions->editNetNick->text()); @@ -782,19 +804,19 @@ { // if (eggTimer.elapsed() < 3000){ #ifdef __APPLE__ - panel->showInstallController(); + panel->showInstallController(); #endif - close(); + close(); // TODO reactivate egg -/* } - else - { - QPushButton * btn = findChild("imageButt"); - if (btn) + /* } + else { - btn->setIcon(QIcon(":/res/bonus.png")); - } - } */ + QPushButton * btn = findChild("imageButt"); + if (btn) + { + btn->setIcon(QIcon(":/res/bonus.png")); + } + } */ } void HWForm::IntermediateSetup() @@ -802,16 +824,19 @@ quint8 id=ui.Pages->currentIndex(); TeamSelWidget* curTeamSelWidget; - if(id == ID_PAGE_MULTIPLAYER) { + if(id == ID_PAGE_MULTIPLAYER) + { curTeamSelWidget = ui.pageMultiplayer->teamsSelect; - } else { + } + else + { curTeamSelWidget = ui.pageNetGame->pNetTeamsWidget; } QStringList tmnames; foreach(HWTeam team, curTeamSelWidget->getNotPlayingTeams()) - tmnames += team.name(); + tmnames += team.name(); //UpdateTeamsLists(&tmnames); // FIXME: still need more work if teamname is updated while configuring UpdateTeamsLists(); @@ -850,9 +875,12 @@ void HWForm::DeleteScheme() { ui.pageScheme->selectScheme->setCurrentIndex(ui.pageOptions->SchemesName->currentIndex()); - if (ui.pageOptions->SchemesName->currentIndex() < ammoSchemeModel->numberOfDefaultSchemes) { + if (ui.pageOptions->SchemesName->currentIndex() < ammoSchemeModel->numberOfDefaultSchemes) + { QMessageBox::warning(0, QMessageBox::tr("Schemes"), QMessageBox::tr("Can not delete default scheme '%1'!").arg(ui.pageOptions->SchemesName->currentText())); - } else { + } + else + { ui.pageScheme->deleteRow(); ammoSchemeModel->Save(); } @@ -876,9 +904,9 @@ if (!curritem) { QMessageBox::critical(this, - tr("Error"), - tr("Please select record from the list above"), - tr("OK")); + tr("Error"), + tr("Please select record from the list above"), + tr("OK")); return; } CreateGame(0, 0, 0); @@ -915,7 +943,8 @@ { 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) { + if (!ok) + { ForcedDisconnect(tr("No password supplied.")); return; } @@ -934,8 +963,9 @@ 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.")); + if (!ok || newNick.isEmpty()) + { + ForcedDisconnect(tr("No nickname supplied.")); return; } @@ -970,7 +1000,7 @@ ui.pageNetGame->displayError(errmsg); break; default: - ui.pageRoomsList->displayError(errmsg); + ui.pageRoomsList->displayError(errmsg); } } @@ -984,7 +1014,8 @@ void HWForm::_NetConnect(const QString & hostName, quint16 port, QString nick) { - if(hwnet) { + if(hwnet) + { hwnet->Disconnect(); delete hwnet; hwnet=0; @@ -1010,95 +1041,95 @@ // rooms list page stuff connect(hwnet, SIGNAL(roomsList(const QStringList&)), - ui.pageRoomsList, SLOT(setRoomsList(const QStringList&))); + ui.pageRoomsList, SLOT(setRoomsList(const QStringList&))); connect(hwnet, SIGNAL(adminAccess(bool)), - ui.pageRoomsList, SLOT(setAdmin(bool))); + ui.pageRoomsList, SLOT(setAdmin(bool))); connect(hwnet, SIGNAL(adminAccess(bool)), - ui.pageRoomsList->chatWidget, SLOT(adminAccess(bool))); + ui.pageRoomsList->chatWidget, SLOT(adminAccess(bool))); connect(hwnet, SIGNAL(serverMessage(const QString&)), - ui.pageRoomsList->chatWidget, SLOT(onServerMessage(const QString&))); + ui.pageRoomsList->chatWidget, SLOT(onServerMessage(const QString&))); connect(ui.pageRoomsList, SIGNAL(askForCreateRoom(const QString &)), - hwnet, SLOT(CreateRoom(const QString&))); + hwnet, SLOT(CreateRoom(const QString&))); connect(ui.pageRoomsList, SIGNAL(askForJoinRoom(const QString &)), - hwnet, SLOT(JoinRoom(const QString&))); + hwnet, SLOT(JoinRoom(const QString&))); // connect(ui.pageRoomsList, SIGNAL(askForCreateRoom(const QString &)), // this, SLOT(NetGameMaster())); // connect(ui.pageRoomsList, SIGNAL(askForJoinRoom(const QString &)), // this, SLOT(NetGameSlave())); connect(ui.pageRoomsList, SIGNAL(askForRoomList()), - hwnet, SLOT(askRoomsList())); + hwnet, SLOT(askRoomsList())); // room status stuff connect(hwnet, SIGNAL(roomMaster(bool)), - this, SLOT(NetGameChangeStatus(bool))); + this, SLOT(NetGameChangeStatus(bool))); // net page stuff connect(hwnet, SIGNAL(chatStringFromNet(const QString&)), - ui.pageNetGame->pChatWidget, SLOT(onChatString(const QString&))); + ui.pageNetGame->pChatWidget, SLOT(onChatString(const QString&))); connect(hwnet, SIGNAL(setReadyStatus(const QString &, bool)), - ui.pageNetGame->pChatWidget, SLOT(setReadyStatus(const QString &, bool))); + ui.pageNetGame->pChatWidget, SLOT(setReadyStatus(const QString &, bool))); connect(hwnet, SIGNAL(chatStringFromMe(const QString&)), - ui.pageNetGame->pChatWidget, SLOT(onChatString(const QString&))); + ui.pageNetGame->pChatWidget, SLOT(onChatString(const QString&))); connect(hwnet, SIGNAL(roomMaster(bool)), - ui.pageNetGame->pChatWidget, SLOT(adminAccess(bool))); + ui.pageNetGame->pChatWidget, SLOT(adminAccess(bool))); connect(ui.pageNetGame->pChatWidget, SIGNAL(chatLine(const QString&)), - hwnet, SLOT(chatLineToNet(const QString&))); + hwnet, SLOT(chatLineToNet(const QString&))); connect(ui.pageNetGame->BtnGo, SIGNAL(clicked()), hwnet, SLOT(ToggleReady())); connect(hwnet, SIGNAL(setMyReadyStatus(bool)), - ui.pageNetGame, SLOT(setReadyStatus(bool))); + ui.pageNetGame, SLOT(setReadyStatus(bool))); // chat widget actions connect(ui.pageNetGame->pChatWidget, SIGNAL(kick(const QString&)), - hwnet, SLOT(kickPlayer(const QString&))); + hwnet, SLOT(kickPlayer(const QString&))); connect(ui.pageNetGame->pChatWidget, SIGNAL(ban(const QString&)), - hwnet, SLOT(banPlayer(const QString&))); + hwnet, SLOT(banPlayer(const QString&))); connect(ui.pageNetGame->pChatWidget, SIGNAL(info(const QString&)), - hwnet, SLOT(infoPlayer(const QString&))); + hwnet, SLOT(infoPlayer(const QString&))); connect(ui.pageNetGame->pChatWidget, SIGNAL(follow(const QString&)), - hwnet, SLOT(followPlayer(const QString&))); + hwnet, SLOT(followPlayer(const QString&))); connect(ui.pageRoomsList->chatWidget, SIGNAL(kick(const QString&)), - hwnet, SLOT(kickPlayer(const QString&))); + hwnet, SLOT(kickPlayer(const QString&))); connect(ui.pageRoomsList->chatWidget, SIGNAL(ban(const QString&)), - hwnet, SLOT(banPlayer(const QString&))); + hwnet, SLOT(banPlayer(const QString&))); connect(ui.pageRoomsList->chatWidget, SIGNAL(info(const QString&)), - hwnet, SLOT(infoPlayer(const QString&))); + hwnet, SLOT(infoPlayer(const QString&))); connect(ui.pageRoomsList->chatWidget, SIGNAL(follow(const QString&)), - hwnet, SLOT(followPlayer(const QString&))); + hwnet, SLOT(followPlayer(const QString&))); // chatting connect(ui.pageRoomsList->chatWidget, SIGNAL(chatLine(const QString&)), - hwnet, SLOT(chatLineToLobby(const QString&))); + hwnet, SLOT(chatLineToLobby(const QString&))); connect(hwnet, SIGNAL(chatStringLobby(const QString&)), - ui.pageRoomsList->chatWidget, SLOT(onChatString(const QString&))); + ui.pageRoomsList->chatWidget, SLOT(onChatString(const QString&))); connect(hwnet, SIGNAL(chatStringLobby(const QString&, const QString&)), - ui.pageRoomsList->chatWidget, SLOT(onChatString(const QString&, const QString&))); + ui.pageRoomsList->chatWidget, SLOT(onChatString(const QString&, const QString&))); connect(hwnet, SIGNAL(chatStringFromMeLobby(const QString&)), - ui.pageRoomsList->chatWidget, SLOT(onChatString(const QString&))); + ui.pageRoomsList->chatWidget, SLOT(onChatString(const QString&))); // nick list stuff connect(hwnet, SIGNAL(nickAdded(const QString&, bool)), - ui.pageNetGame->pChatWidget, SLOT(nickAdded(const QString&, bool))); + ui.pageNetGame->pChatWidget, SLOT(nickAdded(const QString&, bool))); connect(hwnet, SIGNAL(nickRemoved(const QString&)), - ui.pageNetGame->pChatWidget, SLOT(nickRemoved(const QString&))); + ui.pageNetGame->pChatWidget, SLOT(nickRemoved(const QString&))); connect(hwnet, SIGNAL(nickAddedLobby(const QString&, bool)), - ui.pageRoomsList->chatWidget, SLOT(nickAdded(const QString&, bool))); + ui.pageRoomsList->chatWidget, SLOT(nickAdded(const QString&, bool))); connect(hwnet, SIGNAL(nickRemovedLobby(const QString&)), - ui.pageRoomsList->chatWidget, SLOT(nickRemoved(const QString&))); + ui.pageRoomsList->chatWidget, SLOT(nickRemoved(const QString&))); // teams selecting stuff connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(hhogsNumChanged(const HWTeam&)), - hwnet, SLOT(onHedgehogsNumChanged(const HWTeam&))); + hwnet, SLOT(onHedgehogsNumChanged(const HWTeam&))); connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(teamColorChanged(const HWTeam&)), - hwnet, SLOT(onTeamColorChanged(const HWTeam&))); + hwnet, SLOT(onTeamColorChanged(const HWTeam&))); connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(teamWillPlay(HWTeam)), hwnet, SLOT(AddTeam(HWTeam))); connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(acceptRequested(HWTeam)), hwnet, SLOT(AddTeam(HWTeam))); connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(teamNotPlaying(const HWTeam&)), hwnet, SLOT(RemoveTeam(const HWTeam&))); connect(hwnet, SIGNAL(hhnumChanged(const HWTeam&)), - ui.pageNetGame->pNetTeamsWidget, SLOT(changeHHNum(const HWTeam&))); + ui.pageNetGame->pNetTeamsWidget, SLOT(changeHHNum(const HWTeam&))); connect(hwnet, SIGNAL(teamColorChanged(const HWTeam&)), - ui.pageNetGame->pNetTeamsWidget, SLOT(changeTeamColor(const HWTeam&))); + ui.pageNetGame->pNetTeamsWidget, SLOT(changeTeamColor(const HWTeam&))); // admin stuff connect(hwnet, SIGNAL(serverMessageNew(const QString&)), ui.pageAdmin, SLOT(serverMessageNew(const QString &))); @@ -1118,12 +1149,13 @@ 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()) { + while (nick.isEmpty()) + { nick = QInputDialog::getText(this, - QObject::tr("Nickname"), - QObject::tr("Please enter your nickname"), - QLineEdit::Normal, - QDir::home().dirName()); + QObject::tr("Nickname"), + QObject::tr("Please enter your nickname"), + QLineEdit::Normal, + QDir::home().dirName()); config->setValue("net/nick",nick); config->updNetNick(); } @@ -1158,7 +1190,7 @@ if(!pnetserver->StartServer(ui.pageNetServer->sbPort->value())) { QMessageBox::critical(0, tr("Error"), - tr("Unable to start the server")); + tr("Unable to start the server")); delete pnetserver; pnetserver = 0; return; @@ -1167,8 +1199,8 @@ QTimer::singleShot(250, this, SLOT(AsyncNetServerStart())); pRegisterServer = new HWNetUdpServer(0, - ui.pageNetServer->leServerDescr->text(), - ui.pageNetServer->sbPort->value()); + ui.pageNetServer->leServerDescr->text(), + ui.pageNetServer->sbPort->value()); } void HWForm::AsyncNetServerStart() @@ -1178,7 +1210,8 @@ void HWForm::NetDisconnect() { - if(pnetserver) { + if(pnetserver) + { if (pRegisterServer) { pRegisterServer->unregister(); @@ -1197,9 +1230,10 @@ void HWForm::ForcedDisconnect(const QString & reason) { if(pnetserver) return; // we have server - let it care of all things - if (hwnet) { + if (hwnet) + { QMessageBox::warning(this, QMessageBox::tr("Network"), - QMessageBox::tr("Connection to server is lost") + (reason.isEmpty()?"":("\n\n" + HWNewNet::tr("Quit reason: ") + '"' + reason +'"'))); + QMessageBox::tr("Connection to server is lost") + (reason.isEmpty()?"":("\n\n" + HWNewNet::tr("Quit reason: ") + '"' + reason +'"'))); } if (ui.Pages->currentIndex() != ID_PAGE_NET) GoBack(); @@ -1230,8 +1264,8 @@ { QString ammo; ammo = ui.pageMultiplayer->gameCFG->WeaponsName->itemData( - ui.pageMultiplayer->gameCFG->WeaponsName->currentIndex() - ).toString(); + ui.pageMultiplayer->gameCFG->WeaponsName->currentIndex() + ).toString(); CreateGame(ui.pageMultiplayer->gameCFG, ui.pageMultiplayer->teamsSelect, ammo); @@ -1241,8 +1275,10 @@ void HWForm::GameStateChanged(GameState gameState) { quint8 id = ui.Pages->currentIndex(); - switch(gameState) { - case gsStarted: { + switch(gameState) + { + case gsStarted: + { Music(false); if (wBackground) wBackground->stopAnimation(); if (!hwnet || (!hwnet->isRoomChief() || !hwnet->isInRoom())) GoToPage(ID_PAGE_INGAME); @@ -1256,7 +1292,8 @@ setFocusPolicy(Qt::NoFocus); break; } - case gsFinished: { + case gsFinished: + { //setVisible(true); setFocusPolicy(Qt::StrongFocus); if (id == ID_PAGE_INGAME) GoBack(); @@ -1267,14 +1304,16 @@ if (game) game->netSuspend = false; break; } - default: { + default: + { //setVisible(true); setFocusPolicy(Qt::StrongFocus); quint8 id = ui.Pages->currentIndex(); if (id == ID_PAGE_INGAME || // was room chief and the game was aborted - (hwnet && hwnet->isRoomChief() && hwnet->isInRoom() && - (gameState == gsInterrupted || gameState == gsStopped || gameState == gsDestroyed || gameState == gsHalted))) { + (hwnet && hwnet->isRoomChief() && hwnet->isInRoom() && + (gameState == gsInterrupted || gameState == gsStopped || gameState == gsDestroyed || gameState == gsHalted))) + { if (id == ID_PAGE_INGAME) GoBack(); Music(ui.pageOptions->CBEnableFrontendMusic->isChecked()); if (wBackground) wBackground->startAnimation(); @@ -1298,8 +1337,8 @@ void HWForm::ShowErrorMessage(const QString & msg) { QMessageBox::warning(this, - "Hedgewars", - msg); + "Hedgewars", + msg); } void HWForm::GetRecord(bool isDemo, const QByteArray & record) @@ -1307,9 +1346,9 @@ QString filename; QByteArray demo = record; QString recordFileName = - config->appendDateTimeToRecordName() ? - QDateTime::currentDateTime().toString("yyyy-MM-dd_hh-mm") : - "LastRound"; + config->appendDateTimeToRecordName() ? + QDateTime::currentDateTime().toString("yyyy-MM-dd_hh-mm") : + "LastRound"; QStringList versionParts = cVersionString->split('-'); if ( (versionParts.size() == 2) && (!versionParts[1].isEmpty()) && (versionParts[1].contains(':')) ) @@ -1322,7 +1361,8 @@ demo.replace(QByteArray("\x02TS"), QByteArray("\x02TD")); filename = cfgdir->absolutePath() + "/Demos/" + recordFileName + "." + *cProtoVer + ".hwd"; m_lastDemo = demo; - } else + } + else { demo.replace(QByteArray("\x02TL"), QByteArray("\x02TS")); demo.replace(QByteArray("\x02TN"), QByteArray("\x02TS")); @@ -1358,8 +1398,8 @@ { QString ammo; ammo = ui.pageNetGame->pGameCFG->WeaponsName->itemData( - ui.pageNetGame->pGameCFG->WeaponsName->currentIndex() - ).toString(); + ui.pageNetGame->pGameCFG->WeaponsName->currentIndex() + ).toString(); CreateGame(ui.pageNetGame->pGameCFG, ui.pageNetGame->pNetTeamsWidget, ammo); @@ -1419,14 +1459,14 @@ ui.pageNetGame->restrictTeamAdds->disconnect(hwnet); connect(ui.pageNetGame->BtnStart, SIGNAL(clicked()), hwnet, SLOT(startGame())); connect(ui.pageNetGame, SIGNAL(askForUpdateRoomName(const QString &)), - hwnet, SLOT(updateRoomName(const QString &))); + hwnet, SLOT(updateRoomName(const QString &))); connect(ui.pageNetGame->restrictJoins, SIGNAL(triggered()), hwnet, SLOT(toggleRestrictJoins())); connect(ui.pageNetGame->restrictTeamAdds, SIGNAL(triggered()), hwnet, SLOT(toggleRestrictTeamAdds())); connect(ui.pageNetGame->pGameCFG->GameSchemes->model(), SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), ui.pageNetGame->pGameCFG, SLOT(resendSchemeData()) - ); + ); } } @@ -1470,7 +1510,8 @@ { int w = event->size().width(); int h = event->size().height(); - if (wBackground) { + if (wBackground) + { wBackground->setFixedSize(w, h); wBackground->move(0, 0); } @@ -1484,13 +1525,14 @@ ui.pageCampaign->CBSelect->clear(); QStringList entries = HWDataManager::instance().entryList( - "Missions/Campaign", - QDir::Files, - QStringList("*#*.lua") - ); - + "Missions/Campaign", + QDir::Files, + QStringList("*#*.lua") + ); + unsigned int n = entries.count(); - for(unsigned int i = 0; (i < n) && (i <= team.campaignProgress()); i++) { + for(unsigned int i = 0; (i < n) && (i <= team.campaignProgress()); i++) + { ui.pageCampaign->CBSelect->addItem(QString(entries[i]).replace(QRegExp("^(\\d+)#(.+)\\.lua"), QComboBox::tr("Mission") + " \\1: \\2").replace("_", " "), QString(entries[i]).replace(QRegExp("^(.*)\\.lua"), "\\1")); } } @@ -1500,17 +1542,17 @@ { QRect resolution = config->vid_Resolution(); return QString(QString::number(resolution.width()) + " " - + QString::number(resolution.height()) + " " - + QString::number(config->bitDepth()) + " " // bpp - + QString::number(config->volume()) + " " // sound volume - + (config->isMusicEnabled() ? "1" : "0") + " " - + (config->isSoundEnabled() ? "1" : "0") + " " - + config->language() + ".txt " - + (config->vid_Fullscreen() ? "1" : "0") + " " - + (config->isShowFPSEnabled() ? "1" : "0") + " " - + (config->isAltDamageEnabled() ? "1" : "0") + " " - + QString::number(config->timerInterval()) + " " - + QString::number(config->translateQuality())); + + QString::number(resolution.height()) + " " + + QString::number(config->bitDepth()) + " " // bpp + + QString::number(config->volume()) + " " // sound volume + + (config->isMusicEnabled() ? "1" : "0") + " " + + (config->isSoundEnabled() ? "1" : "0") + " " + + config->language() + ".txt " + + (config->vid_Fullscreen() ? "1" : "0") + " " + + (config->isShowFPSEnabled() ? "1" : "0") + " " + + (config->isAltDamageEnabled() ? "1" : "0") + " " + + QString::number(config->timerInterval()) + " " + + QString::number(config->translateQuality())); } void HWForm::AssociateFiles() @@ -1562,7 +1604,7 @@ do { fileName = QInputDialog::getText(this, tr("Demo name"), tr("Demo name:")); - + if(!fileName.isEmpty()) { QString filePath = cfgdir->absolutePath() + "/Demos/" + fileName + "." + *cProtoVer + ".hwd"; @@ -1576,7 +1618,8 @@ demofile.close(); } } - } while(!fileName.isEmpty() && !ok); + } + while(!fileName.isEmpty() && !ok); } } @@ -1586,18 +1629,18 @@ if (!CreateIssueXml()) { QMessageBox::warning(this, QMessageBox::tr("Fields required"), - QMessageBox::tr("Please fill out all fields")); + QMessageBox::tr("Please fill out all fields")); return; } - + //Google login using fake account (feedback.hedgewars@gmail.com) nam = new QNetworkAccessManager(this); connect(nam, SIGNAL(finished(QNetworkReply*)), - this, SLOT(finishedSlot(QNetworkReply*))); + this, SLOT(finishedSlot(QNetworkReply*))); QUrl url(string(string("https://www.google.com/accounts/ClientLogin?" - "accountType=GOOGLE&Email=feedback.hedgewars@gmail.com&Passwd=hwfeedback&service=code&source=HedgewarsFoundation-Hedgewars-") - + (cVersionString?(*cVersionString):QString("")).toStdString()).c_str()); + "accountType=GOOGLE&Email=feedback.hedgewars@gmail.com&Passwd=hwfeedback&service=code&source=HedgewarsFoundation-Hedgewars-") + + (cVersionString?(*cVersionString):QString("")).toStdString()).c_str()); nam->get(QNetworkRequest(url)); } @@ -1609,11 +1652,11 @@ //Check if all necessary information is entered if (summary.isEmpty() || description.isEmpty()) - return false; + return false; issueXml = - "" - "" + "" + "" ""; issueXml.append(summary); issueXml.append(""); @@ -1627,58 +1670,58 @@ { if (reply && reply->error() == QNetworkReply::NoError) { - QByteArray array = reply->readAll(); + QByteArray array = reply->readAll(); QString str(array); if (authToken.length() != 0) - { - QMessageBox::information(this, QMessageBox::tr("Success"), - QMessageBox::tr("Successfully posted the issue on code.google.com!")); - ui.pageFeedback->summary->clear(); - ui.pageFeedback->description->clear(); - authToken = ""; - return; - } + { + QMessageBox::information(this, QMessageBox::tr("Success"), + QMessageBox::tr("Successfully posted the issue on code.google.com!")); + ui.pageFeedback->summary->clear(); + ui.pageFeedback->description->clear(); + authToken = ""; + return; + } - if(!getAuthToken(str)) - { - QMessageBox::warning(this, QMessageBox::tr("Network"), - QMessageBox::tr("Error during authentication with www.google.com")); - return; - } + if(!getAuthToken(str)) + { + QMessageBox::warning(this, QMessageBox::tr("Network"), + QMessageBox::tr("Error during authentication with www.google.com")); + return; + } - QByteArray body(issueXml.toStdString().c_str()); - QNetworkRequest header(QUrl("https://code.google.com/feeds/issues/p/hedgewars/issues/full")); - header.setRawHeader("Content-Length", QString::number(issueXml.length()).toAscii()); - header.setRawHeader("Content-Type", "application/atom+xml"); - header.setRawHeader("Authorization", string( - string("GoogleLogin auth=") + authToken.toStdString()).c_str()); - nam->post(header, body); + QByteArray body(issueXml.toStdString().c_str()); + QNetworkRequest header(QUrl("https://code.google.com/feeds/issues/p/hedgewars/issues/full")); + header.setRawHeader("Content-Length", QString::number(issueXml.length()).toAscii()); + header.setRawHeader("Content-Type", "application/atom+xml"); + header.setRawHeader("Authorization", string( + string("GoogleLogin auth=") + authToken.toStdString()).c_str()); + nam->post(header, body); } else if (authToken.length() == 0) - QMessageBox::warning(this, QMessageBox::tr("Network"), - QMessageBox::tr("Error during authentication with www.google.com")); + QMessageBox::warning(this, QMessageBox::tr("Network"), + QMessageBox::tr("Error during authentication with www.google.com")); else { - QMessageBox::warning(this, QMessageBox::tr("Network"), - QMessageBox::tr("Error creating the issue")); - authToken = ""; + QMessageBox::warning(this, QMessageBox::tr("Network"), + QMessageBox::tr("Error creating the issue")); + authToken = ""; } - + } bool HWForm::getAuthToken(QString str) { - QRegExp ex("Auth=(.+)"); + QRegExp ex("Auth=(.+)"); + + if (-1 == ex.indexIn(str)) + return false; - if (-1 == ex.indexIn(str)) - return false; - - authToken = ex.cap(1); - authToken.remove(QChar('\n')); + authToken = ex.cap(1); + authToken.remove(QChar('\n')); - return true; + return true; } diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/hwform.h --- a/QTfrontend/hwform.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/hwform.h Mon Jan 30 17:32:18 2012 -0500 @@ -55,152 +55,153 @@ class HWForm : public QMainWindow { - Q_OBJECT + Q_OBJECT -public: - HWForm(QWidget *parent = 0, QString styleSheet = ""); - Ui_HWForm ui; - static GameUIConfig * config; - static 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(); - void setButtonDescription(QString desc); - void backDescription(); + public: + HWForm(QWidget *parent = 0, QString styleSheet = ""); + Ui_HWForm ui; + static GameUIConfig * config; + static 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(); + void setButtonDescription(QString desc); + void backDescription(); -private slots: - void GoToSaves(); - void GoToDemos(); - void GoToNet(); - void GoToSelectWeapon(); - void GoToSelectWeaponSet(int index); - void GoToSelectNewWeapon(); - void GoToScheme(int index); - void GoToEditScheme(); - void GoToNewScheme(); - void GoToPage(int id); - void GoBack(); - void OpenSnapshotFolder(); - QString getDemoArguments(); - void AssociateFiles(); - void btnExitPressed(); - void IntermediateSetup(); - void NewTeam(); - void EditTeam(const QString & teamName); - void AfterTeamEdit(); - void DeleteTeam(const QString & teamName); - void DeleteScheme(); - void DeleteWeaponSet(); - void SimpleGame(); - void PlayDemo(); - void startTraining(const QString&); - void StartCampaign(); - void NetConnect(); - void NetConnectServer(const QString & host, quint16 port); - void NetConnectOfficialServer(); - 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(const QString & reason); - void ShowErrorMessage(const QString &); - void GetRecord(bool isDemo, const QByteArray & record); - void CreateNetGame(); - void UpdateWeapons(); - void onFrontendFullscreen(bool value); - void onFrontendEffects(bool value); - void Music(bool checked); - void UpdateCampaignPage(int index); - //Starts the transmission process for the feedback - void SendFeedback(); - //Make a xml representation of the issue to be created - bool CreateIssueXml(); - //Called the first time when receiving authorization token from google, - //second time when receiving the response after posting the issue - void finishedSlot(QNetworkReply* reply); - //Filter the auth token from the reply from google - bool getAuthToken(QString str); + private slots: + void GoToSaves(); + void GoToDemos(); + void GoToNet(); + void GoToSelectWeapon(); + void GoToSelectWeaponSet(int index); + void GoToSelectNewWeapon(); + void GoToScheme(int index); + void GoToEditScheme(); + void GoToNewScheme(); + void GoToPage(int id); + void GoBack(); + void OpenSnapshotFolder(); + QString getDemoArguments(); + void AssociateFiles(); + void btnExitPressed(); + void IntermediateSetup(); + void NewTeam(); + void EditTeam(const QString & teamName); + void AfterTeamEdit(); + void DeleteTeam(const QString & teamName); + void DeleteScheme(); + void DeleteWeaponSet(); + void SimpleGame(); + void PlayDemo(); + void startTraining(const QString&); + void StartCampaign(); + void NetConnect(); + void NetConnectServer(const QString & host, quint16 port); + void NetConnectOfficialServer(); + 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(const QString & reason); + void ShowErrorMessage(const QString &); + void GetRecord(bool isDemo, const QByteArray & record); + void CreateNetGame(); + void UpdateWeapons(); + void onFrontendFullscreen(bool value); + void onFrontendEffects(bool value); + void Music(bool checked); + void UpdateCampaignPage(int index); + //Starts the transmission process for the feedback + void SendFeedback(); + //Make a xml representation of the issue to be created + bool CreateIssueXml(); + //Called the first time when receiving authorization token from google, + //second time when receiving the response after posting the issue + void finishedSlot(QNetworkReply* reply); + //Filter the auth token from the reply from google + bool getAuthToken(QString str); - void NetGameChangeStatus(bool isMaster); - void NetGameMaster(); - void NetGameSlave(); + void NetGameChangeStatus(bool isMaster); + void NetGameMaster(); + void NetGameSlave(); + + void AsyncNetServerStart(); + void NetLeftRoom(const QString & reason); + void selectFirstNetScheme(); - void AsyncNetServerStart(); - void NetLeftRoom(const QString & reason); - void selectFirstNetScheme(); - - void saveDemoWithCustomName(); + void saveDemoWithCustomName(); + + private: + 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); + void CustomizePalettes(); + void resizeEvent(QResizeEvent * event); + //void keyReleaseEvent(QKeyEvent *event); -private: - 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); - void CustomizePalettes(); - void resizeEvent(QResizeEvent * event); - //void keyReleaseEvent(QKeyEvent *event); - - enum PageIDs { - ID_PAGE_SETUP_TEAM = 0, - ID_PAGE_SETUP = 1, - ID_PAGE_MULTIPLAYER = 2, - ID_PAGE_DEMOS = 3, - ID_PAGE_NET = 4, - ID_PAGE_NETGAME = 5, - ID_PAGE_INFO = 6, - ID_PAGE_MAIN = 7, - ID_PAGE_GAMESTATS = 8, - ID_PAGE_SINGLEPLAYER = 9, - ID_PAGE_TRAINING = 10, - ID_PAGE_SELECTWEAPON = 11, - ID_PAGE_NETSERVER = 12, - ID_PAGE_INGAME = 13, - ID_PAGE_ROOMSLIST = 14, - ID_PAGE_CONNECTING = 15, - ID_PAGE_SCHEME = 16, - ID_PAGE_ADMIN = 17, - ID_PAGE_NETTYPE = 18, - ID_PAGE_CAMPAIGN = 19, - ID_PAGE_DRAWMAP = 20, - ID_PAGE_DATADOWNLOAD = 21, - ID_PAGE_FEEDBACK = 22 + enum PageIDs + { + ID_PAGE_SETUP_TEAM = 0, + ID_PAGE_SETUP = 1, + ID_PAGE_MULTIPLAYER = 2, + ID_PAGE_DEMOS = 3, + ID_PAGE_NET = 4, + ID_PAGE_NETGAME = 5, + ID_PAGE_INFO = 6, + ID_PAGE_MAIN = 7, + ID_PAGE_GAMESTATS = 8, + ID_PAGE_SINGLEPLAYER = 9, + ID_PAGE_TRAINING = 10, + ID_PAGE_SELECTWEAPON = 11, + ID_PAGE_NETSERVER = 12, + ID_PAGE_INGAME = 13, + ID_PAGE_ROOMSLIST = 14, + ID_PAGE_CONNECTING = 15, + ID_PAGE_SCHEME = 16, + ID_PAGE_ADMIN = 17, + ID_PAGE_NETTYPE = 18, + ID_PAGE_CAMPAIGN = 19, + ID_PAGE_DRAWMAP = 20, + ID_PAGE_DATADOWNLOAD = 21, + ID_PAGE_FEEDBACK = 22 }; - QPointer game; - QPointer pnetserver; - QPointer pRegisterServer; - QPointer editedTeam; - QPointer hwnet; - HWNamegen * namegen; - AmmoSchemeModel * ammoSchemeModel; - QStack PagesStack; - QTime eggTimer; - BGWidget * wBackground; - QSignalMapper * pageSwitchMapper; - QByteArray m_lastDemo; - QNetworkAccessManager * nam; - QString issueXml; - QString authToken; + QPointer game; + QPointer pnetserver; + QPointer pRegisterServer; + QPointer editedTeam; + QPointer hwnet; + HWNamegen * namegen; + AmmoSchemeModel * ammoSchemeModel; + QStack PagesStack; + QTime eggTimer; + BGWidget * wBackground; + QSignalMapper * pageSwitchMapper; + QByteArray m_lastDemo; + QNetworkAccessManager * nam; + QString issueXml; + QString authToken; - QPropertyAnimation *animationNewSlide; - QPropertyAnimation *animationOldSlide; - QPropertyAnimation *animationNewOpacity; - QPropertyAnimation *animationOldOpacity; + QPropertyAnimation *animationNewSlide; + QPropertyAnimation *animationOldSlide; + QPropertyAnimation *animationNewOpacity; + QPropertyAnimation *animationOldOpacity; #ifdef __APPLE__ - InstallController * panel; + InstallController * panel; #endif - void OnPageShown(quint8 id, quint8 lastid=0); + void OnPageShown(quint8 id, quint8 lastid=0); }; #endif diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/main.cpp --- a/QTfrontend/main.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/main.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -46,7 +46,7 @@ QDate calculateEaster(long year) { int c, n, k, i, j, l, m, d; - + c = year/100; n = year - 19*(year/19); k = (c - 17)/25; @@ -65,23 +65,23 @@ //Checks season and assigns it to the variable season in "hwconsts.h" void checkSeason() { - QDate date = QDate::currentDate(); - - //Christmas? - if (date.month() == 12 && date.day() >= 24 - && date.day() <= 26) - season = SEASON_CHRISTMAS; - //Hedgewars birthday? - else if (date.month() == 10 && date.day() == 31) - { - season = SEASON_HWBDAY; - years_since_foundation = date.year() - 2004; - } - //Easter? - else if (calculateEaster(date.year()) == date) - season = SEASON_EASTER; - else - season = SEASON_NONE; + QDate date = QDate::currentDate(); + + //Christmas? + if (date.month() == 12 && date.day() >= 24 + && date.day() <= 26) + season = SEASON_CHRISTMAS; + //Hedgewars birthday? + else if (date.month() == 10 && date.day() == 31) + { + season = SEASON_HWBDAY; + years_since_foundation = date.year() - 2004; + } + //Easter? + else if (calculateEaster(date.year()) == date) + season = SEASON_EASTER; + else + season = SEASON_NONE; } bool checkForDir(const QString & dir) @@ -91,15 +91,16 @@ if (!tmpdir.mkdir(dir)) { QMessageBox::critical(0, - QObject::tr("Error"), - QObject::tr("Cannot create directory %1").arg(dir), - QObject::tr("OK")); + QObject::tr("Error"), + QObject::tr("Cannot create directory %1").arg(dir), + QObject::tr("OK")); return false; } return true; } -int main(int argc, char *argv[]) { +int main(int argc, char *argv[]) +{ HWApplication app(argc, argv); app.setAttribute(Qt::AA_DontShowIconsInMenus,false); @@ -107,29 +108,36 @@ QMap parsedArgs; { QList::iterator i = arguments.begin(); - while(i != arguments.end()) { + while(i != arguments.end()) + { QString arg = *i; QRegExp opt("--(\\S+)=(.+)"); - if(opt.exactMatch(arg)) { + if(opt.exactMatch(arg)) + { parsedArgs[opt.cap(1)] = opt.cap(2); i = arguments.erase(i); - } else { - ++i; + } + else + { + ++i; } } } - if(parsedArgs.contains("data-dir")) { + if(parsedArgs.contains("data-dir")) + { QFileInfo f(parsedArgs["data-dir"]); - if(!f.exists()) { + if(!f.exists()) + { qWarning() << "WARNING: Cannot open DATA_PATH=" << f.absoluteFilePath(); } *cDataDir = f.absoluteFilePath(); custom_data = true; } - if(parsedArgs.contains("config-dir")) { + if(parsedArgs.contains("config-dir")) + { QFileInfo f(parsedArgs["config-dir"]); *cConfigDir = f.absoluteFilePath(); custom_config = true; @@ -189,11 +197,12 @@ datadir->cd(bindir->absolutePath()); datadir->cd(*cDataDir); - if(!datadir->cd("hedgewars/Data")) { + if(!datadir->cd("hedgewars/Data")) + { QMessageBox::critical(0, QMessageBox::tr("Error"), - QMessageBox::tr("Failed to open data directory:\n%1\n" - "Please check your installation"). - arg(datadir->absolutePath()+"/hedgewars/Data")); + QMessageBox::tr("Failed to open data directory:\n%1\n" + "Please check your installation"). + arg(datadir->absolutePath()+"/hedgewars/Data")); return 1; } @@ -203,8 +212,8 @@ QStringList themes; themes.append(dataMgr.entryList( - "Themes", - QDir::AllDirs | QDir::NoDotAndDotDot) + "Themes", + QDir::AllDirs | QDir::NoDotAndDotDot) ); QList > icons; @@ -213,20 +222,21 @@ for(int i = themes.size() - 1; i >= 0; --i) { QString file = dataMgr.findFileForRead( - QString("Themes/%1/icon.png").arg(themes.at(i)) - ); + QString("Themes/%1/icon.png").arg(themes.at(i)) + ); if(QFile::exists(file)) - { // load icon + { + // load icon QPair ic; ic.first = QIcon(file); // load preview icon ic.second = QIcon( - dataMgr.findFileForRead( - QString("Themes/%1/icon@2x.png").arg(themes.at(i)) - ) - ); + dataMgr.findFileForRead( + QString("Themes/%1/icon@2x.png").arg(themes.at(i)) + ) + ); icons.prepend(ic); } @@ -246,17 +256,17 @@ } mapList = new QStringList(dataMgr.entryList( - QString("Maps"), - QDir::Dirs | QDir::NoDotAndDotDot - ) + QString("Maps"), + QDir::Dirs | QDir::NoDotAndDotDot + ) ); - + scriptList = new QStringList(dataMgr.entryList( QString("Scripts/Multiplayer"), QDir::Files, QStringList("*.lua") - ) - ); + ) + ); QTranslator Translator; { @@ -290,7 +300,7 @@ QString style = ""; QString fname; - + checkSeason(); //For each season, there is an extra stylesheet //Todo: change background for easter and birthday @@ -298,13 +308,17 @@ //with an appropriate background switch (season) { - case SEASON_CHRISTMAS : fname = "christmas.css"; - break; - case SEASON_EASTER : fname = "easter.css"; - break; - case SEASON_HWBDAY : fname = "birthday.css"; - break; - default : fname = "qt.css"; + case SEASON_CHRISTMAS : + fname = "christmas.css"; + break; + case SEASON_EASTER : + fname = "easter.css"; + break; + case SEASON_HWBDAY : + fname = "birthday.css"; + break; + default : + fname = "qt.css"; } // load external stylesheet if there is any diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/model/ammoSchemeModel.cpp --- a/QTfrontend/model/ammoSchemeModel.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/model/ammoSchemeModel.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -23,562 +23,562 @@ #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 - ; + << 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" - ; + << "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 - ; + << "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 - ; + << 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 - ; + << 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 - ; + << 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 - ; + << 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 - ; + << 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 - ; + << 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 - ; + << 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 - ; + << 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 - ; + << 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 - ; + << 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); @@ -595,7 +595,8 @@ int size = fileConfig.beginReadArray("schemes"); - for (int i = 0; i < size; ++i) { + for (int i = 0; i < size; ++i) + { fileConfig.setArrayIndex(i); if (!predefSchemesNames.contains(fileConfig.value(spNames[0]).toString())) @@ -649,9 +650,9 @@ 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) + || index.row() >= schemes.size() + || index.column() >= defaultScheme.size() + || role != Qt::EditRole) return false; schemes[index.row()][index.column()] = value; @@ -687,8 +688,8 @@ bool AmmoSchemeModel::removeRows(int row, int count, const QModelIndex & parent) { if(count != 1 - || row < numberOfDefaultSchemes - || row >= schemes.size()) + || row < numberOfDefaultSchemes + || row >= schemes.size()) return false; beginRemoveRows(parent, row, row); @@ -703,10 +704,10 @@ 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) - ) + || index.row() >= schemes.size() + || index.column() >= defaultScheme.size() + || (role != Qt::EditRole && role != Qt::DisplayRole) + ) return QVariant(); return schemes[index.row()][index.column()]; @@ -716,7 +717,8 @@ { fileConfig.beginWriteArray("schemes", schemes.size() - numberOfDefaultSchemes); - for (int i = 0; i < schemes.size() - numberOfDefaultSchemes; ++i) { + for (int i = 0; i < schemes.size() - numberOfDefaultSchemes; ++i) + { fileConfig.setArrayIndex(i); QList scheme = schemes[i + numberOfDefaultSchemes]; @@ -762,10 +764,10 @@ 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) - ) + || index.row() > 1 + || index.column() >= defaultScheme.size() + || (role != Qt::EditRole && role != Qt::DisplayRole) + ) return QVariant(); return netScheme[index.column()]; diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/model/ammoSchemeModel.h --- a/QTfrontend/model/ammoSchemeModel.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/model/ammoSchemeModel.h Mon Jan 30 17:32:18 2012 -0500 @@ -26,54 +26,54 @@ class AmmoSchemeModel : public QAbstractTableModel { - Q_OBJECT + Q_OBJECT -public: - AmmoSchemeModel(QObject * parent, const QString & fileName); + 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; + 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; + int numberOfDefaultSchemes; + QStringList predefSchemesNames; + QStringList spNames; -public slots: - void Save(); + public slots: + void Save(); -signals: - void dataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight); + signals: + void dataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight); -protected: - QList< QList > schemes; + protected: + QList< QList > schemes; -private: - QSettings fileConfig; + private: + QSettings fileConfig; }; class NetAmmoSchemeModel : public QAbstractTableModel { - Q_OBJECT + Q_OBJECT -public: - NetAmmoSchemeModel(QObject * parent); + 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; + 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); + public slots: + void setNetSchemeConfig(QStringList & cfg); -private: - QList netScheme; + private: + QList netScheme; }; #endif // _AMMO_SCHEME_MODEL_INCLUDED diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/model/hats.cpp --- a/QTfrontend/model/hats.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/model/hats.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -26,29 +26,29 @@ #include "HWDataManager.h" HatsModel::HatsModel(QObject* parent) : - QAbstractListModel(parent) + QAbstractListModel(parent) { HWDataManager & dataMgr = HWDataManager::instance(); QPixmap hhpix = QPixmap( - dataMgr.findFileForRead("Graphics/Hedgehog/Idle.png") - ).copy(0, 0, 32, 32); + dataMgr.findFileForRead("Graphics/Hedgehog/Idle.png") + ).copy(0, 0, 32, 32); // my reserved hats QStringList hatsList = dataMgr.entryList( - "Graphics/Hats/Reserved", - QDir::Files, - QStringList(playerHash+"*.png") - ); + "Graphics/Hats/Reserved", + QDir::Files, + QStringList(playerHash+"*.png") + ); int nReserved = hatsList.size(); // regular hats hatsList.append(dataMgr.entryList( - "Graphics/Hats", - QDir::Files, - QStringList("*.png") - ) + "Graphics/Hats", + QDir::Files, + QStringList("*.png") + ) ); @@ -62,7 +62,7 @@ str = str.remove(QRegExp("\\.png$")); QPixmap pix( dataMgr.findFileForRead( - "Graphics/Hats/" + QString(isReserved?"Reserved/":"") + str + + "Graphics/Hats/" + QString(isReserved?"Reserved/":"") + str + ".png" ) ); @@ -89,7 +89,7 @@ } QVariant HatsModel::headerData(int section, - Qt::Orientation orientation, int role) const + Qt::Orientation orientation, int role) const { Q_UNUSED(section); Q_UNUSED(orientation); @@ -118,8 +118,8 @@ int role) const { if (!index.isValid() || index.row() < 0 - || index.row() >= hats.size() - || (role != Qt::DisplayRole && role != Qt::DecorationRole)) + || index.row() >= hats.size() + || (role != Qt::DisplayRole && role != Qt::DecorationRole)) return QVariant(); if (role == Qt::DisplayRole) diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/model/hats.h --- a/QTfrontend/model/hats.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/model/hats.h Mon Jan 30 17:32:18 2012 -0500 @@ -27,18 +27,18 @@ class HatsModel : public QAbstractListModel { - Q_OBJECT + Q_OBJECT -public: - HatsModel(QObject *parent = 0); + 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 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; + QVariant data(const QModelIndex &index, int role) const; + protected: + QVector > hats; }; #endif // _HATS_INCLUDED diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/model/netserverslist.cpp --- a/QTfrontend/model/netserverslist.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/model/netserverslist.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -22,7 +22,7 @@ #include "netserverslist.h" HWNetServersModel::HWNetServersModel(QObject* parent) : - QAbstractTableModel(parent) + QAbstractTableModel(parent) { } @@ -33,7 +33,7 @@ } QVariant HWNetServersModel::headerData(int section, - Qt::Orientation orientation, int role) const + Qt::Orientation orientation, int role) const { if (role != Qt::DisplayRole) return QVariant(); @@ -42,12 +42,17 @@ { switch (section) { - case 0: return tr("Title"); - case 1: return tr("IP"); - case 2: return tr("Port"); - default: return QVariant(); + case 0: + return tr("Title"); + case 1: + return tr("IP"); + case 2: + return tr("Port"); + default: + return QVariant(); } - } else + } + else return QString("%1").arg(section + 1); } diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/model/netserverslist.h --- a/QTfrontend/model/netserverslist.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/model/netserverslist.h Mon Jan 30 17:32:18 2012 -0500 @@ -24,20 +24,20 @@ class HWNetServersModel : public QAbstractTableModel { - Q_OBJECT + Q_OBJECT -public: - HWNetServersModel(QObject *parent = 0); + 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; + 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(); + public slots: + virtual void updateList(); -protected: - QList games; + protected: + QList games; }; #endif // _NET_SERVERSLIST_INCLUDED diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/model/themesmodel.h --- a/QTfrontend/model/themesmodel.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/model/themesmodel.h Mon Jan 30 17:32:18 2012 -0500 @@ -7,22 +7,22 @@ class ThemesModel : public QAbstractListModel { - Q_OBJECT -public: - explicit ThemesModel(QStringList themes, QObject *parent = 0); + 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); + 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: + signals: -public slots: + public slots: -private: + private: - QList > m_data; + QList > m_data; }; #endif // THEMESMODEL_H diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/net/hwmap.cpp --- a/QTfrontend/net/hwmap.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/net/hwmap.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -21,7 +21,7 @@ #include "hwmap.h" HWMap::HWMap() : - TCPBase(false) + TCPBase(false) { } @@ -84,7 +84,8 @@ } break; } - default: ; + default: + ; } SendIPC("!"); diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/net/hwmap.h --- a/QTfrontend/net/hwmap.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/net/hwmap.h Mon Jan 30 17:32:18 2012 -0500 @@ -36,30 +36,30 @@ class HWMap : public TCPBase { - Q_OBJECT + Q_OBJECT - public: - HWMap(); - virtual ~HWMap(); - void getImage(const QString & seed, int templateFilter, MapGenerator mapgen, int maze_size, const QByteArray & drawMapData); + 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(); + protected: + virtual QStringList getArguments(); + virtual void onClientDisconnect(); + virtual void SendToClientFirst(); - signals: - void ImageReceived(const QImage newImage); - void HHLimitReceived(int hhLimit); + 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: + QString m_seed; + int templateFilter; + MapGenerator m_mapgen; + int m_maze_size; + QByteArray m_drawMapData; - private slots: + private slots: }; #endif // _HWMAP_INCLUDED diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/net/netregister.cpp --- a/QTfrontend/net/netregister.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/net/netregister.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -19,7 +19,7 @@ #include "netregister.h" HWNetRegisterServer::HWNetRegisterServer(QObject *parent, const QString & descr, quint16 port) : - QObject(parent) + QObject(parent) { Q_UNUSED(descr); Q_UNUSED(port); diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/net/netregister.h --- a/QTfrontend/net/netregister.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/net/netregister.h Mon Jan 30 17:32:18 2012 -0500 @@ -23,13 +23,13 @@ class HWNetRegisterServer : public QObject { - Q_OBJECT + Q_OBJECT -public: - HWNetRegisterServer(QObject *parent, const QString & descr, quint16 port); + public: + HWNetRegisterServer(QObject *parent, const QString & descr, quint16 port); -public slots: - virtual void unregister(); + public slots: + virtual void unregister(); }; #endif // _NET_REGISTER_INCLUDED diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/net/netserver.cpp --- a/QTfrontend/net/netserver.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/net/netserver.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -48,5 +48,5 @@ quint16 HWNetServer::getRunningPort() const { - return ds_port; + return ds_port; } diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/net/netserver.h --- a/QTfrontend/net/netserver.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/net/netserver.h Mon Jan 30 17:32:18 2012 -0500 @@ -25,18 +25,18 @@ class HWNetServer : public QObject { - Q_OBJECT + Q_OBJECT -public: - ~HWNetServer(); - bool StartServer(quint16 port); - void StopServer(); - QString getRunningHostName() const; - quint16 getRunningPort() const; + public: + ~HWNetServer(); + bool StartServer(quint16 port); + void StopServer(); + QString getRunningHostName() const; + quint16 getRunningPort() const; -private: - quint16 ds_port; - QProcess process; + private: + quint16 ds_port; + QProcess process; }; #endif // _NETSERVER_INCLUDED diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/net/netudpserver.cpp --- a/QTfrontend/net/netudpserver.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/net/netudpserver.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -22,30 +22,32 @@ #include "netudpserver.h" HWNetUdpServer::HWNetUdpServer(QObject *parent, const QString & descr, quint16 port) : - HWNetRegisterServer(parent, descr, port), - m_descr(descr) + HWNetRegisterServer(parent, descr, port), + m_descr(descr) { - pUdpSocket = new QUdpSocket(this); - pUdpSocket->bind(46631); - connect(pUdpSocket, SIGNAL(readyRead()), this, SLOT(onClientRead())); + pUdpSocket = new QUdpSocket(this); + pUdpSocket->bind(46631); + connect(pUdpSocket, SIGNAL(readyRead()), this, SLOT(onClientRead())); } void HWNetUdpServer::onClientRead() { - while (pUdpSocket->hasPendingDatagrams()) { - QByteArray datagram; - datagram.resize(pUdpSocket->pendingDatagramSize()); - QHostAddress clientAddr; - quint16 clientPort; - pUdpSocket->readDatagram(datagram.data(), datagram.size(), &clientAddr, &clientPort); - if(datagram.startsWith("hedgewars client")) { - // send answer to client - pUdpSocket->writeDatagram(QString("hedgewars server\n%1").arg(m_descr).toUtf8(), clientAddr, clientPort); + while (pUdpSocket->hasPendingDatagrams()) + { + QByteArray datagram; + datagram.resize(pUdpSocket->pendingDatagramSize()); + QHostAddress clientAddr; + quint16 clientPort; + pUdpSocket->readDatagram(datagram.data(), datagram.size(), &clientAddr, &clientPort); + if(datagram.startsWith("hedgewars client")) + { + // send answer to client + pUdpSocket->writeDatagram(QString("hedgewars server\n%1").arg(m_descr).toUtf8(), clientAddr, clientPort); + } } - } } void HWNetUdpServer::unregister() { - deleteLater(); + deleteLater(); } diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/net/netudpserver.h --- a/QTfrontend/net/netudpserver.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/net/netudpserver.h Mon Jan 30 17:32:18 2012 -0500 @@ -27,20 +27,20 @@ class HWNetUdpServer : public HWNetRegisterServer { - Q_OBJECT + Q_OBJECT - public: - HWNetUdpServer(QObject *parent, const QString & descr, quint16 port); + public: + HWNetUdpServer(QObject *parent, const QString & descr, quint16 port); - public slots: - void unregister(); + public slots: + void unregister(); - private slots: - void onClientRead(); + private slots: + void onClientRead(); - private: - QUdpSocket* pUdpSocket; - QString m_descr; + private: + QUdpSocket* pUdpSocket; + QString m_descr; }; #endif // _NET_UDPSERVER_INCLUDED diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/net/netudpwidget.cpp --- a/QTfrontend/net/netudpwidget.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/net/netudpwidget.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -22,7 +22,7 @@ #include "netudpwidget.h" HWNetUdpModel::HWNetUdpModel(QObject* parent) : - HWNetServersModel(parent) + HWNetServersModel(parent) { pUdpSocket = new QUdpSocket(this); @@ -41,7 +41,8 @@ void HWNetUdpModel::onClientRead() { - while (pUdpSocket->hasPendingDatagrams()) { + while (pUdpSocket->hasPendingDatagrams()) + { QByteArray datagram; datagram.resize(pUdpSocket->pendingDatagramSize()); QHostAddress clientAddr; @@ -50,7 +51,8 @@ pUdpSocket->readDatagram(datagram.data(), datagram.size(), &clientAddr, &clientPort); QString packet = QString::fromUtf8(datagram.data()); - if(packet.startsWith("hedgewars server")) { + if(packet.startsWith("hedgewars server")) + { QStringList sl; sl << packet.remove(0, 17) << clientAddr.toString() << "46631"; games.append(sl); @@ -64,9 +66,9 @@ int role) const { if (!index.isValid() || index.row() < 0 - || index.row() >= games.size() - || role != Qt::DisplayRole) - return QVariant(); + || index.row() >= games.size() + || role != Qt::DisplayRole) + return QVariant(); return games[index.row()][index.column()]; } diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/net/netudpwidget.h --- a/QTfrontend/net/netudpwidget.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/net/netudpwidget.h Mon Jan 30 17:32:18 2012 -0500 @@ -26,21 +26,21 @@ class HWNetUdpModel : public HWNetServersModel { - Q_OBJECT + Q_OBJECT -public: - HWNetUdpModel(QObject *parent = 0); + public: + HWNetUdpModel(QObject *parent = 0); - QVariant data(const QModelIndex &index, int role) const; + QVariant data(const QModelIndex &index, int role) const; -public slots: - void updateList(); + public slots: + void updateList(); -private slots: - void onClientRead(); + private slots: + void onClientRead(); -private: - QUdpSocket* pUdpSocket; + private: + QUdpSocket* pUdpSocket; }; #endif // _NET_UDPWIDGET_INCLUDED diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/net/newnetclient.cpp --- a/QTfrontend/net/newnetclient.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/net/newnetclient.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -29,10 +29,10 @@ char delimeter='\n'; HWNewNet::HWNewNet() : - isChief(false), - m_game_connected(false), - loginStep(0), - netClientState(Disconnected) + isChief(false), + m_game_connected(false), + loginStep(0), + netClientState(Disconnected) { // socket stuff connect(&NetSocket, SIGNAL(readyRead()), this, SLOT(ClientRead())); @@ -103,13 +103,13 @@ void HWNewNet::AddTeam(const HWTeam & team) { QString cmd = QString("ADD_TEAM") + delimeter + - team.name() + delimeter + - team.color().name() + delimeter + - team.grave() + delimeter + - team.fort() + delimeter + - team.voicepack() + delimeter + - team.flag() + delimeter + - QString::number(team.difficulty()); + team.name() + delimeter + + team.color().name() + delimeter + + team.grave() + delimeter + + team.fort() + delimeter + + team.voicepack() + delimeter + + team.flag() + delimeter + + QString::number(team.difficulty()); for(int i = 0; i < HEDGEHOGS_PER_TEAM; ++i) { @@ -133,19 +133,19 @@ void HWNewNet::ToggleReady() { - RawSendNet(QString("TOGGLE_READY")); + RawSendNet(QString("TOGGLE_READY")); } void HWNewNet::SendNet(const QByteArray & buf) { - QString msg = QString(buf.toBase64()); + QString msg = QString(buf.toBase64()); - RawSendNet(QString("EM%1%2").arg(delimeter).arg(msg)); + RawSendNet(QString("EM%1%2").arg(delimeter).arg(msg)); } void HWNewNet::RawSendNet(const QString & str) { - RawSendNet(str.toUtf8()); + RawSendNet(str.toUtf8()); } void HWNewNet::RawSendNet(const QByteArray & buf) @@ -157,20 +157,23 @@ void HWNewNet::ClientRead() { - while (NetSocket.canReadLine()) { + while (NetSocket.canReadLine()) + { QString s = QString::fromUtf8(NetSocket.readLine()); if (s.endsWith('\n')) s.chop(1); - if (s.size() == 0) { + if (s.size() == 0) + { ParseCmd(cmdbuf); cmdbuf.clear(); - } else + } + else cmdbuf << s; } } void HWNewNet::OnConnect() -{ +{ netClientState = Connected; } @@ -185,7 +188,8 @@ { m_game_connected = false; - switch (socketError) { + switch (socketError) + { case QAbstractSocket::RemoteHostClosedError: break; case QAbstractSocket::HostNotFoundError: @@ -196,7 +200,7 @@ break; default: emit disconnected(NetSocket.errorString()); - } + } } void HWNewNet::SendPasswordHash(const QString & hash) @@ -206,7 +210,7 @@ void HWNewNet::ParseCmd(const QStringList & lst) { - qDebug() << "Server: " << lst; + qDebug() << "Server: " << lst; if(!lst.size()) { @@ -223,7 +227,8 @@ if (lst[0] == "PROTO") return ; - if (lst[0] == "ERROR") { + if (lst[0] == "ERROR") + { if (lst.size() == 2) emit Error(lst[1]); else @@ -231,7 +236,8 @@ return; } - if (lst[0] == "WARNING") { + if (lst[0] == "WARNING") + { if (lst.size() == 2) emit Warning(lst[1]); else @@ -239,7 +245,8 @@ return; } - if (lst[0] == "CONNECTED") { + if (lst[0] == "CONNECTED") + { if(lst.size() < 3 || lst[2].toInt() < cMinServerVersion) { // TODO: Warn user, disconnect @@ -254,7 +261,8 @@ return; } - if (lst[0] == "PING") { + if (lst[0] == "PING") + { if (lst.size() > 1) RawSendNet(QString("PONG%1%2").arg(delimeter).arg(lst[1])); else @@ -262,14 +270,16 @@ return; } - if (lst[0] == "ROOMS") { + if (lst[0] == "ROOMS") + { QStringList tmp = lst; tmp.removeFirst(); emit roomsList(tmp); return; } - if (lst[0] == "SERVER_MESSAGE") { + if (lst[0] == "SERVER_MESSAGE") + { if(lst.size() < 2) { qWarning("Net: Empty SERVERMESSAGE message"); @@ -279,7 +289,8 @@ return; } - if (lst[0] == "CHAT") { + if (lst[0] == "CHAT") + { if(lst.size() < 3) { qWarning("Net: Empty CHAT message"); @@ -292,7 +303,8 @@ return; } - if (lst[0] == "INFO") { + if (lst[0] == "INFO") + { if(lst.size() < 5) { qWarning("Net: Malformed INFO message"); @@ -307,7 +319,8 @@ return; } - if (lst[0] == "SERVER_VARS") { + if (lst[0] == "SERVER_VARS") + { QStringList tmp = lst; tmp.removeFirst(); while (tmp.size() >= 2) @@ -340,11 +353,12 @@ switch(c) { - case 'r': + case 'r': { for(int i = 2; i < lst.size(); ++i) { - if (lst[i] == mynick) { + if (lst[i] == mynick) + { emit setMyReadyStatus(setFlag); } @@ -357,7 +371,8 @@ return; } - if (lst[0] == "ADD_TEAM") { + if (lst[0] == "ADD_TEAM") + { if(lst.size() != 24) { qWarning("Net: Bad ADDTEAM message"); @@ -369,7 +384,8 @@ return; } - if (lst[0] == "REMOVE_TEAM") { + if (lst[0] == "REMOVE_TEAM") + { if(lst.size() != 2) { qWarning("Net: Bad REMOVETEAM message"); @@ -379,21 +395,24 @@ return; } - if(lst[0] == "ROOMABANDONED") { + if(lst[0] == "ROOMABANDONED") + { netClientState = InLobby; askRoomsList(); emit LeftRoom(tr("Room destroyed")); return; } - if(lst[0] == "KICKED") { + if(lst[0] == "KICKED") + { netClientState = InLobby; askRoomsList(); emit LeftRoom(tr("You got kicked")); return; } - if(lst[0] == "JOINED") { + if(lst[0] == "JOINED") + { if(lst.size() < 2) { qWarning("Net: Bad JOINED message"); @@ -417,7 +436,8 @@ return; } - if(lst[0] == "LOBBY:JOINED") { + if(lst[0] == "LOBBY:JOINED") + { if(lst.size() < 2) { qWarning("Net: Bad JOINED message"); @@ -439,7 +459,8 @@ return; } - if(lst[0] == "LEFT") { + if(lst[0] == "LEFT") + { if(lst.size() < 2) { qWarning("Net: Bad LEFT message"); @@ -453,7 +474,8 @@ return; } - if(lst[0] == "ROOM") { + if(lst[0] == "ROOM") + { if(lst.size() < 2) { qWarning("Net: Bad ROOM message"); @@ -463,7 +485,8 @@ return; } - if(lst[0] == "LOBBY:LEFT") { + if(lst[0] == "LOBBY:LEFT") + { if(lst.size() < 2) { qWarning("Net: Bad LOBBY:LEFT message"); @@ -477,18 +500,21 @@ return; } - if (lst[0] == "RUN_GAME") { + if (lst[0] == "RUN_GAME") + { netClientState = InGame; emit AskForRunGame(); return; } - if (lst[0] == "ASKPASSWORD") { + if (lst[0] == "ASKPASSWORD") + { emit AskForPassword(mynick); return; } - if (lst[0] == "NOTICE") { + if (lst[0] == "NOTICE") + { if(lst.size() < 2) { qWarning("Net: Bad NOTICE message"); @@ -508,7 +534,8 @@ return; } - if (lst[0] == "TEAM_ACCEPTED") { + if (lst[0] == "TEAM_ACCEPTED") + { if (lst.size() != 2) { qWarning("Net: Bad TEAM_ACCEPTED message"); @@ -519,7 +546,8 @@ } - if (lst[0] == "CFG") { + if (lst[0] == "CFG") + { if(lst.size() < 3) { qWarning("Net: Bad CFG message"); @@ -535,7 +563,8 @@ return; } - if (lst[0] == "HH_NUM") { + if (lst[0] == "HH_NUM") + { if (lst.size() != 3) { qWarning("Net: Bad TEAM_ACCEPTED message"); @@ -547,7 +576,8 @@ return; } - if (lst[0] == "TEAM_COLOR") { + if (lst[0] == "TEAM_COLOR") + { if (lst.size() != 3) { qWarning("Net: Bad TEAM_COLOR message"); @@ -559,7 +589,8 @@ return; } - if (lst[0] == "EM") { + if (lst[0] == "EM") + { if(lst.size() < 2) { qWarning("Net: Bad EM message"); @@ -573,7 +604,8 @@ return; } - if (lst[0] == "BYE") { + if (lst[0] == "BYE") + { if (lst.size() < 2) { qWarning("Net: Bad BYE message"); @@ -590,12 +622,14 @@ } - if (lst[0] == "ADMIN_ACCESS") { + if (lst[0] == "ADMIN_ACCESS") + { emit adminAccess(true); return; } - if (lst[0] == "ROOM_CONTROL_ACCESS") { + if (lst[0] == "ROOM_CONTROL_ACCESS") + { if (lst.size() < 2) { qWarning("Net: Bad ROOM_CONTROL_ACCESS message"); @@ -612,35 +646,36 @@ void HWNewNet::onHedgehogsNumChanged(const HWTeam& team) { if (isChief) - RawSendNet(QString("HH_NUM%1%2%1%3") - .arg(delimeter) - .arg(team.name()) - .arg(team.numHedgehogs())); + RawSendNet(QString("HH_NUM%1%2%1%3") + .arg(delimeter) + .arg(team.name()) + .arg(team.numHedgehogs())); } void HWNewNet::onTeamColorChanged(const HWTeam& team) { if (isChief) - RawSendNet(QString("TEAM_COLOR%1%2%1%3") - .arg(delimeter) - .arg(team.name()) - .arg(team.color().name())); + RawSendNet(QString("TEAM_COLOR%1%2%1%3") + .arg(delimeter) + .arg(team.name()) + .arg(team.color().name())); } void HWNewNet::onParamChanged(const QString & param, const QStringList & value) { if (isChief) RawSendNet( - QString("CFG%1%2%1%3") - .arg(delimeter) - .arg(param) - .arg(value.join(QString(delimeter))) - ); + QString("CFG%1%2%1%3") + .arg(delimeter) + .arg(param) + .arg(value.join(QString(delimeter))) + ); } void HWNewNet::chatLineToNet(const QString& str) { - if(str != "") { + if(str != "") + { RawSendNet(QString("CHAT") + delimeter + str); emit(chatStringFromMe(HWProto::formatChatMsg(mynick, str))); } @@ -648,7 +683,8 @@ void HWNewNet::chatLineToLobby(const QString& str) { - if(str != "") { + if(str != "") + { RawSendNet(QString("CHAT") + delimeter + str); emit chatStringLobby(mynick, HWProto::formatChatMsgForFrontend(str)); } @@ -717,7 +753,8 @@ void HWNewNet::followPlayer(const QString & nick) { - if (!isInRoom()) { + if (!isInRoom()) + { RawSendNet(QString("FOLLOW%1%2").arg(delimeter).arg(nick)); isChief = false; } diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/net/newnetclient.h --- a/QTfrontend/net/newnetclient.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/net/newnetclient.h Mon Jan 30 17:32:18 2012 -0500 @@ -36,142 +36,144 @@ class HWNewNet : public QObject { - Q_OBJECT + Q_OBJECT - public: - enum ClientState { Disconnected, Connecting, Connected, InLobby, InRoom, InGame }; + public: + enum ClientState { Disconnected, Connecting, Connected, InLobby, InRoom, InGame }; - HWNewNet(); - ~HWNewNet(); - void Connect(const QString & hostName, quint16 port, const QString & nick); - void Disconnect(); - void SendPasswordHash(const QString & hash); - void NewNick(const QString & nick); - bool isRoomChief(); - bool isInRoom(); - ClientState clientState(); - QString getNick(); - QString getRoom(); - QString getHost(); + HWNewNet(); + ~HWNewNet(); + void Connect(const QString & hostName, quint16 port, const QString & nick); + void Disconnect(); + void SendPasswordHash(const QString & hash); + void NewNick(const QString & nick); + bool isRoomChief(); + bool isInRoom(); + ClientState clientState(); + QString getNick(); + QString getRoom(); + QString getHost(); - private: - bool isChief; - QString mynick; - QString myroom; - QString myhost; - QTcpSocket NetSocket; - QString seed; - bool m_game_connected; + private: + bool isChief; + QString mynick; + QString myroom; + QString myhost; + QTcpSocket NetSocket; + QString seed; + bool m_game_connected; - template - void SendCfgStrNet(T a) { - QByteArray strmsg; - strmsg.append(a); - quint8 sz = strmsg.size(); - QByteArray enginemsg = QByteArray((char *)&sz, 1) + strmsg; - QString _msg = delimeter + QString(enginemsg.toBase64()); - RawSendNet(_msg); - } + template + void SendCfgStrNet(T a) + { + QByteArray strmsg; + strmsg.append(a); + quint8 sz = strmsg.size(); + QByteArray enginemsg = QByteArray((char *)&sz, 1) + strmsg; + QString _msg = delimeter + QString(enginemsg.toBase64()); + RawSendNet(_msg); + } - template - void SendCfgStrLoc(T a) { - QByteArray strmsg; - strmsg.append(QString(a).toUtf8()); - quint8 sz = strmsg.size(); - QByteArray enginemsg = QByteArray((char *)&sz, 1) + strmsg; - emit FromNet(enginemsg); - } + template + void SendCfgStrLoc(T a) + { + QByteArray strmsg; + strmsg.append(QString(a).toUtf8()); + quint8 sz = strmsg.size(); + QByteArray enginemsg = QByteArray((char *)&sz, 1) + strmsg; + emit FromNet(enginemsg); + } - QStringList cmdbuf; + QStringList cmdbuf; - void RawSendNet(const QString & buf); - void RawSendNet(const QByteArray & buf); - void ParseCmd(const QStringList & lst); - void handleNotice(int n); + void RawSendNet(const QString & buf); + void RawSendNet(const QByteArray & buf); + void ParseCmd(const QStringList & lst); + void handleNotice(int n); - int loginStep; - ClientState netClientState; + int loginStep; + ClientState netClientState; - signals: - void AskForRunGame(); - void connected(); - void disconnected(const QString & reason); - void Error(const QString & errmsg); - void Warning(const QString & wrnmsg); - void AskForPassword(const QString & nick); - void NickTaken(const QString & nick); - void AuthFailed(); - void EnteredGame(); - void LeftRoom(const QString & reason); - void nickAdded(const QString& nick, bool notifyNick); - void nickRemoved(const QString& nick); - void nickAddedLobby(const QString& nick, bool notifyNick); - void nickRemovedLobby(const QString& nick); - void FromNet(const QByteArray & buf); - void adminAccess(bool); - void roomMaster(bool); + signals: + void AskForRunGame(); + void connected(); + void disconnected(const QString & reason); + void Error(const QString & errmsg); + void Warning(const QString & wrnmsg); + void AskForPassword(const QString & nick); + void NickTaken(const QString & nick); + void AuthFailed(); + void EnteredGame(); + void LeftRoom(const QString & reason); + void nickAdded(const QString& nick, bool notifyNick); + void nickRemoved(const QString& nick); + void nickAddedLobby(const QString& nick, bool notifyNick); + void nickRemovedLobby(const QString& nick); + void FromNet(const QByteArray & buf); + void adminAccess(bool); + void roomMaster(bool); - void netSchemeConfig(QStringList &); - void paramChanged(const QString & param, const QStringList & value); - void configAsked(); + void netSchemeConfig(QStringList &); + void paramChanged(const QString & param, const QStringList & value); + void configAsked(); - void TeamAccepted(const QString&); - void AddNetTeam(const HWTeam&); - void RemoveNetTeam(const HWTeam&); - void hhnumChanged(const HWTeam&); - void teamColorChanged(const HWTeam&); - void chatStringLobby(const QString&); - void chatStringLobby(const QString&, const QString&); - void chatStringFromNet(const QString&); - void chatStringFromMe(const QString&); - void chatStringFromMeLobby(const QString&); + void TeamAccepted(const QString&); + void AddNetTeam(const HWTeam&); + void RemoveNetTeam(const HWTeam&); + void hhnumChanged(const HWTeam&); + void teamColorChanged(const HWTeam&); + void chatStringLobby(const QString&); + void chatStringLobby(const QString&, const QString&); + void chatStringFromNet(const QString&); + void chatStringFromMe(const QString&); + void chatStringFromMeLobby(const QString&); - void roomsList(const QStringList&); - void serverMessage(const QString &); - void serverMessageNew(const QString &); - void serverMessageOld(const QString &); - void latestProtocolVar(int); + void roomsList(const QStringList&); + void serverMessage(const QString &); + void serverMessageNew(const QString &); + void serverMessageOld(const QString &); + void latestProtocolVar(int); - void setReadyStatus(const QString & nick, bool isReady); - void setMyReadyStatus(bool isReady); + void setReadyStatus(const QString & nick, bool isReady); + void setMyReadyStatus(bool isReady); - public slots: - void ToggleReady(); - void chatLineToNet(const QString& str); - void chatLineToLobby(const QString& str); - void SendTeamMessage(const QString& str); - void SendNet(const QByteArray & buf); - void AddTeam(const HWTeam & team); - void RemoveTeam(const HWTeam& team); - void onHedgehogsNumChanged(const HWTeam& team); - void onTeamColorChanged(const HWTeam& team); - void onParamChanged(const QString & param, const QStringList & value); + public slots: + void ToggleReady(); + void chatLineToNet(const QString& str); + void chatLineToLobby(const QString& str); + void SendTeamMessage(const QString& str); + void SendNet(const QByteArray & buf); + void AddTeam(const HWTeam & team); + void RemoveTeam(const HWTeam& team); + void onHedgehogsNumChanged(const HWTeam& team); + void onTeamColorChanged(const HWTeam& team); + void onParamChanged(const QString & param, const QStringList & value); - void setServerMessageNew(const QString &); - void setServerMessageOld(const QString &); - void setLatestProtocolVar(int proto); - void askServerVars(); + void setServerMessageNew(const QString &); + void setServerMessageOld(const QString &); + void setLatestProtocolVar(int proto); + void askServerVars(); - void JoinRoom(const QString & room); - void CreateRoom(const QString & room); - void updateRoomName(const QString &); - void askRoomsList(); - void gameFinished(bool correcly); - void banPlayer(const QString &); - void kickPlayer(const QString &); - void infoPlayer(const QString &); - void followPlayer(const QString &); - void startGame(); - void toggleRestrictJoins(); - void toggleRestrictTeamAdds(); - void partRoom(); - void clearAccountsCache(); + void JoinRoom(const QString & room); + void CreateRoom(const QString & room); + void updateRoomName(const QString &); + void askRoomsList(); + void gameFinished(bool correcly); + void banPlayer(const QString &); + void kickPlayer(const QString &); + void infoPlayer(const QString &); + void followPlayer(const QString &); + void startGame(); + void toggleRestrictJoins(); + void toggleRestrictTeamAdds(); + void partRoom(); + void clearAccountsCache(); - private slots: - void ClientRead(); - void OnConnect(); - void OnDisconnect(); - void displayError(QAbstractSocket::SocketError socketError); + private slots: + void ClientRead(); + void OnConnect(); + void OnDisconnect(); + void displayError(QAbstractSocket::SocketError socketError); }; #endif // _NEW_NETCLIENT_INCLUDED diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/net/proto.h --- a/QTfrontend/net/proto.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/net/proto.h Mon Jan 30 17:32:18 2012 -0500 @@ -26,15 +26,15 @@ class HWProto : public QObject { - Q_OBJECT + Q_OBJECT -public: - HWProto(); - static QByteArray & addStringToBuffer(QByteArray & buf, const QString & string); - static QByteArray & addByteArrayToBuffer(QByteArray & buf, const QByteArray & msg); - static QByteArray & addStringListToBuffer(QByteArray & buf, const QStringList & strList); - static QString formatChatMsg(const QString & nick, const QString & msg); - static QString formatChatMsgForFrontend(const QString & msg); + public: + HWProto(); + static QByteArray & addStringToBuffer(QByteArray & buf, const QString & string); + static QByteArray & addByteArrayToBuffer(QByteArray & buf, const QByteArray & msg); + static QByteArray & addStringListToBuffer(QByteArray & buf, const QStringList & strList); + static QString formatChatMsg(const QString & nick, const QString & msg); + static QString formatChatMsgForFrontend(const QString & msg); }; #endif // _PROTO_H diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/net/tcpBase.cpp --- a/QTfrontend/net/tcpBase.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/net/tcpBase.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -34,96 +34,102 @@ } TCPBase::TCPBase(bool demoMode) : - m_isDemoMode(demoMode), - IPCSocket(0) + m_isDemoMode(demoMode), + IPCSocket(0) { - if(!IPCServer) { - IPCServer = new QTcpServer(0); - IPCServer->setMaxPendingConnections(1); - if (!IPCServer->listen(QHostAddress::LocalHost)) { - QMessageBox::critical(0, tr("Error"), - tr("Unable to start the server: %1.") - .arg(IPCServer->errorString())); - exit(0); // FIXME - should be graceful exit here + if(!IPCServer) + { + IPCServer = new QTcpServer(0); + IPCServer->setMaxPendingConnections(1); + if (!IPCServer->listen(QHostAddress::LocalHost)) + { + QMessageBox::critical(0, tr("Error"), + tr("Unable to start the server: %1.") + .arg(IPCServer->errorString())); + exit(0); // FIXME - should be graceful exit here + } } - } - ipc_port=IPCServer->serverPort(); + ipc_port=IPCServer->serverPort(); } void TCPBase::NewConnection() { - if(IPCSocket) { - // connection should be already finished - return; - } - disconnect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection())); - IPCSocket = IPCServer->nextPendingConnection(); - if(!IPCSocket) return; - connect(IPCSocket, SIGNAL(disconnected()), this, SLOT(ClientDisconnect())); - connect(IPCSocket, SIGNAL(readyRead()), this, SLOT(ClientRead())); - SendToClientFirst(); + if(IPCSocket) + { + // connection should be already finished + return; + } + disconnect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection())); + IPCSocket = IPCServer->nextPendingConnection(); + if(!IPCSocket) return; + connect(IPCSocket, SIGNAL(disconnected()), this, SLOT(ClientDisconnect())); + connect(IPCSocket, SIGNAL(readyRead()), this, SLOT(ClientRead())); + SendToClientFirst(); } void TCPBase::RealStart() { - connect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection())); - IPCSocket = 0; + connect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection())); + IPCSocket = 0; - QProcess * process; - process = new QProcess; - connect(process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(StartProcessError(QProcess::ProcessError))); - QStringList arguments=getArguments(); + QProcess * process; + process = new QProcess; + connect(process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(StartProcessError(QProcess::ProcessError))); + QStringList arguments=getArguments(); - // redirect everything written on stdout/stderr - if(isDevBuild) - process->setProcessChannelMode(QProcess::ForwardedChannels); - process->start(bindir->absolutePath() + "/hwengine", arguments); + // redirect everything written on stdout/stderr + if(isDevBuild) + process->setProcessChannelMode(QProcess::ForwardedChannels); + process->start(bindir->absolutePath() + "/hwengine", arguments); } void TCPBase::ClientDisconnect() { - disconnect(IPCSocket, SIGNAL(readyRead()), this, SLOT(ClientRead())); - onClientDisconnect(); + disconnect(IPCSocket, SIGNAL(readyRead()), this, SLOT(ClientRead())); + onClientDisconnect(); - if(srvsList.size()==1) srvsList.pop_front(); - emit isReadyNow(); - IPCSocket->deleteLater(); - deleteLater(); + if(srvsList.size()==1) srvsList.pop_front(); + emit isReadyNow(); + IPCSocket->deleteLater(); + deleteLater(); } void TCPBase::ClientRead() { - QByteArray readed=IPCSocket->readAll(); - if(readed.isEmpty()) return; - readbuffer.append(readed); - onClientRead(); + QByteArray readed=IPCSocket->readAll(); + if(readed.isEmpty()) return; + readbuffer.append(readed); + onClientRead(); } void TCPBase::StartProcessError(QProcess::ProcessError error) { - QMessageBox::critical(0, tr("Error"), - tr("Unable to run engine: %1 (") - .arg(error) + bindir->absolutePath() + "/hwengine)"); + QMessageBox::critical(0, tr("Error"), + tr("Unable to run engine: %1 (") + .arg(error) + bindir->absolutePath() + "/hwengine)"); } void TCPBase::tcpServerReady() { - disconnect(srvsList.takeFirst(), SIGNAL(isReadyNow()), this, SLOT(tcpServerReady())); + disconnect(srvsList.takeFirst(), SIGNAL(isReadyNow()), this, SLOT(tcpServerReady())); - RealStart(); + RealStart(); } void TCPBase::Start() { - if(srvsList.isEmpty()) { - srvsList.push_back(this); - } else { - connect(srvsList.back(), SIGNAL(isReadyNow()), this, SLOT(tcpServerReady())); - srvsList.push_back(this); - return; - } + if(srvsList.isEmpty()) + { + srvsList.push_back(this); + } + else + { + connect(srvsList.back(), SIGNAL(isReadyNow()), this, SLOT(tcpServerReady())); + srvsList.push_back(this); + return; + } - RealStart(); + RealStart(); } void TCPBase::onClientRead() @@ -150,7 +156,8 @@ if (!IPCSocket) { toSendBuf += buf; - } else + } + else { if (toSendBuf.size() > 0) { @@ -158,9 +165,10 @@ if(m_isDemoMode) demo.append(toSendBuf); toSendBuf.clear(); } - if(!buf.isEmpty()) { - IPCSocket->write(buf); - if(m_isDemoMode) demo.append(buf); + if(!buf.isEmpty()) + { + IPCSocket->write(buf); + if(m_isDemoMode) demo.append(buf); } } } diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/net/tcpBase.h --- a/QTfrontend/net/tcpBase.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/net/tcpBase.h Mon Jan 30 17:32:18 2012 -0500 @@ -35,47 +35,47 @@ class TCPBase : public QObject { - Q_OBJECT + Q_OBJECT - public: - TCPBase(bool demoMode); - virtual ~TCPBase(); + public: + TCPBase(bool demoMode); + virtual ~TCPBase(); - signals: - void isReadyNow(); + signals: + void isReadyNow(); - protected: - quint16 ipc_port; + protected: + quint16 ipc_port; - void Start(); + void Start(); - QByteArray readbuffer; + QByteArray readbuffer; - QByteArray toSendBuf; - QByteArray demo; + QByteArray toSendBuf; + QByteArray demo; - void SendIPC(const QByteArray & buf); - void RawSendIPC(const QByteArray & buf); + void SendIPC(const QByteArray & buf); + void RawSendIPC(const QByteArray & buf); - virtual QStringList getArguments()=0; - virtual void onClientRead(); - virtual void onClientDisconnect(); - virtual void SendToClientFirst(); + virtual QStringList getArguments()=0; + virtual void onClientRead(); + virtual void onClientDisconnect(); + virtual void SendToClientFirst(); - private: - static QPointer IPCServer; + private: + static QPointer IPCServer; - bool m_isDemoMode; - void RealStart(); - QPointer IPCSocket; + bool m_isDemoMode; + void RealStart(); + QPointer IPCSocket; - private slots: - void NewConnection(); - void ClientDisconnect(); - void ClientRead(); - void StartProcessError(QProcess::ProcessError error); + private slots: + void NewConnection(); + void ClientDisconnect(); + void ClientRead(); + void StartProcessError(QProcess::ProcessError error); - void tcpServerReady(); + void tcpServerReady(); }; #endif // _TCPBASE_INCLUDED diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/sdlkeys.h --- a/QTfrontend/sdlkeys.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/sdlkeys.h Mon Jan 30 17:32:18 2012 -0500 @@ -16,7 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -char sdlkeys[1024][2][128] = { +char sdlkeys[1024][2][128] = +{ {"mousel", QT_TRANSLATE_NOOP("binds (keys)", "Mouse: Left button")}, {"mousem", QT_TRANSLATE_NOOP("binds (keys)", "Mouse: Middle button")}, {"mouser", QT_TRANSLATE_NOOP("binds (keys)", "Mouse: Right button")}, @@ -145,11 +146,12 @@ {"left_alt", QT_TRANSLATE_NOOP("binds (keys)", "Left alt")}, {"right_meta", QT_TRANSLATE_NOOP("binds (keys)", "Right meta")}, {"left_meta", QT_TRANSLATE_NOOP("binds (keys)", "Left meta")} - }; +}; // button name definitions for Microsoft's XBox360 controller // don't modify button order! -char xb360buttons[][128] = { +char xb360buttons[][128] = +{ QT_TRANSLATE_NOOP("binds (keys)", "A button"), QT_TRANSLATE_NOOP("binds (keys)", "B button"), QT_TRANSLATE_NOOP("binds (keys)", "X button"), @@ -164,7 +166,8 @@ // axis name definitions for Microsoft's XBox360 controller // don't modify axis order! -char xbox360axes[][128] = { +char xbox360axes[][128] = +{ QT_TRANSLATE_NOOP("binds (keys)", "Left stick (Right)"), QT_TRANSLATE_NOOP("binds (keys)", "Left stick (Left)"), QT_TRANSLATE_NOOP("binds (keys)", "Left stick (Down)"), diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/team.cpp --- a/QTfrontend/team.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/team.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -83,9 +83,9 @@ HWTeam::HWTeam() : QObject(0) - , m_difficulty(0) - , m_numHedgehogs(4) - , m_isNetTeam(false) + , m_difficulty(0) + , m_numHedgehogs(4) + , m_isNetTeam(false) { m_name = QString("Team"); for (int i = 0; i < HEDGEHOGS_PER_TEAM; i++) @@ -110,23 +110,23 @@ } HWTeam::HWTeam(const HWTeam & other) : - QObject(0) - , OldTeamName(other.OldTeamName) - , m_name(other.m_name) - , m_grave(other.m_grave) - , m_fort(other.m_fort) - , m_flag(other.m_flag) - , m_voicepack(other.m_voicepack) - , m_hedgehogs(other.m_hedgehogs) - , m_difficulty(other.m_difficulty) - , m_binds(other.m_binds) - , m_numHedgehogs(other.m_numHedgehogs) - , m_color(other.m_color) - , m_isNetTeam(other.m_isNetTeam) - , m_owner(other.m_owner) - , m_campaignProgress(other.m_campaignProgress) - , m_rounds(other.m_rounds) - , m_wins(other.m_wins) + QObject(0) + , OldTeamName(other.OldTeamName) + , m_name(other.m_name) + , m_grave(other.m_grave) + , m_fort(other.m_fort) + , m_flag(other.m_flag) + , m_voicepack(other.m_voicepack) + , m_hedgehogs(other.m_hedgehogs) + , m_difficulty(other.m_difficulty) + , m_binds(other.m_binds) + , m_numHedgehogs(other.m_numHedgehogs) + , m_color(other.m_color) + , m_isNetTeam(other.m_isNetTeam) + , m_owner(other.m_owner) + , m_campaignProgress(other.m_campaignProgress) + , m_rounds(other.m_rounds) + , m_wins(other.m_wins) // , AchievementProgress(other.AchievementProgress) { @@ -266,28 +266,30 @@ for (int t = 0; t < m_numHedgehogs; t++) { - sl.push_back(QString("eaddhh %1 %2 %3") - .arg(QString::number(m_difficulty), - QString::number(InitHealth), - m_hedgehogs[t].Name)); - sl.push_back(QString("ehat %1") - .arg(m_hedgehogs[t].Hat)); + sl.push_back(QString("eaddhh %1 %2 %3") + .arg(QString::number(m_difficulty), + QString::number(InitHealth), + m_hedgehogs[t].Name)); + sl.push_back(QString("ehat %1") + .arg(m_hedgehogs[t].Hat)); } return sl; } bool HWTeam::isNetTeam() const { - return m_isNetTeam; + return m_isNetTeam; } -bool HWTeam::operator==(const HWTeam& t1) const { - return m_name==t1.m_name; +bool HWTeam::operator==(const HWTeam& t1) const +{ + return m_name==t1.m_name; } -bool HWTeam::operator<(const HWTeam& t1) const { - return m_name(dist); QSlider * slider = dynamic_cast(dist); QTabWidget * tab = dynamic_cast(dist); - if (HWForm::config->isFrontendSoundEnabled() && (button || textfield || checkbox || droplist || slider || tab)) { + if (HWForm::config->isFrontendSoundEnabled() && (button || textfield || checkbox || droplist || slider || tab)) + { HWDataManager & dataMgr = HWDataManager::instance(); SDLInteraction::instance().playSoundFile(dataMgr.findFileForRead("Sounds/steps.ogg")); } diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/mouseoverfilter.h --- a/QTfrontend/ui/mouseoverfilter.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/mouseoverfilter.h Mon Jan 30 17:32:18 2012 -0500 @@ -8,19 +8,19 @@ class MouseOverFilter : public QObject { - Q_OBJECT -public: - explicit MouseOverFilter(QObject *parent = 0); - void setUi(Ui_HWForm *uiForm); -protected: - bool eventFilter( QObject *dist, QEvent *event ); -signals: + Q_OBJECT + public: + explicit MouseOverFilter(QObject *parent = 0); + void setUi(Ui_HWForm *uiForm); + protected: + bool eventFilter( QObject *dist, QEvent *event ); + signals: -public slots: + public slots: -private: - Ui_HWForm *ui; - AbstractPage* abstractpage; + private: + Ui_HWForm *ui; + AbstractPage* abstractpage; }; diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/AbstractPage.h --- a/QTfrontend/ui/page/AbstractPage.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/AbstractPage.h Mon Jan 30 17:32:18 2012 -0500 @@ -54,7 +54,7 @@ class AbstractPage : public QWidget { - Q_OBJECT + Q_OBJECT public: @@ -112,7 +112,10 @@ * * Use it to define layout (not behavior) of the page's footer. */ - virtual QLayout * footerLayoutDefinition() { return NULL; }; + virtual QLayout * footerLayoutDefinition() + { + return NULL; + }; /** * @brief Used during page construction. diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pageadmin.cpp --- a/QTfrontend/ui/page/pageadmin.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pageadmin.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -32,7 +32,7 @@ // 0 pbAsk = addButton(tr("Fetch data"), pageLayout, 0, 0, 1, 3); - + // 1 QLabel * lblSMN = new QLabel(this); lblSMN->setText(tr("Server message for latest version:")); @@ -66,10 +66,10 @@ tb->setOpenExternalLinks(true); tb->document()->setDefaultStyleSheet(HWChatWidget::styleSheet()); pageLayout->addWidget(tb, 4, 1, 1, 2); - + // 5 pbClearAccountsCache = addButton(tr("Clear Accounts Cache"), pageLayout, 5, 0); - + // 6 pbSetSM = addButton(tr("Set data"), pageLayout, 6, 0, 1, 3); diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pageadmin.h --- a/QTfrontend/ui/page/pageadmin.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pageadmin.h Mon Jan 30 17:32:18 2012 -0500 @@ -23,38 +23,38 @@ class PageAdmin : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageAdmin(QWidget* parent = 0); + public: + PageAdmin(QWidget* parent = 0); -public slots: - void serverMessageNew(const QString & str); - void serverMessageOld(const QString & str); - void protocol(int proto); + public slots: + void serverMessageNew(const QString & str); + void serverMessageOld(const QString & str); + void protocol(int proto); -signals: - void setServerMessageNew(const QString & str); - void setServerMessageOld(const QString & str); - void setProtocol(int proto); - void askServerVars(); - void clearAccountsCache(); + signals: + void setServerMessageNew(const QString & str); + void setServerMessageOld(const QString & str); + void setProtocol(int proto); + void askServerVars(); + void clearAccountsCache(); -protected: - QLayout * bodyLayoutDefinition(); - void connectSignals(); + protected: + QLayout * bodyLayoutDefinition(); + void connectSignals(); -private: - QLineEdit * leServerMessageNew; - QLineEdit * leServerMessageOld; - QPushButton * pbSetSM; - QPushButton * pbAsk; - QSpinBox * sbProtocol; - QTextBrowser * tb; - QPushButton * pbClearAccountsCache; + private: + QLineEdit * leServerMessageNew; + QLineEdit * leServerMessageOld; + QPushButton * pbSetSM; + QPushButton * pbAsk; + QSpinBox * sbProtocol; + QTextBrowser * tb; + QPushButton * pbClearAccountsCache; -private slots: - void smChanged(); + private slots: + void smChanged(); }; #endif diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pagecampaign.cpp --- a/QTfrontend/ui/page/pagecampaign.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pagecampaign.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -36,7 +36,7 @@ pageLayout->addWidget(CBTeam, 1, 1); pageLayout->addWidget(CBSelect, 2, 1); - + BtnStartCampaign = new QPushButton(this); BtnStartCampaign->setFont(*font14); BtnStartCampaign->setText(QPushButton::tr("Go!")); diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pagecampaign.h --- a/QTfrontend/ui/page/pagecampaign.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pagecampaign.h Mon Jan 30 17:32:18 2012 -0500 @@ -23,17 +23,17 @@ class PageCampaign : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageCampaign(QWidget* parent = 0); + public: + PageCampaign(QWidget* parent = 0); - QPushButton *BtnStartCampaign; - QComboBox *CBSelect; - QComboBox *CBTeam; + QPushButton *BtnStartCampaign; + QComboBox *CBSelect; + QComboBox *CBTeam; -protected: - QLayout * bodyLayoutDefinition(); + protected: + QLayout * bodyLayoutDefinition(); }; #endif diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pageconnecting.h --- a/QTfrontend/ui/page/pageconnecting.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pageconnecting.h Mon Jan 30 17:32:18 2012 -0500 @@ -23,17 +23,17 @@ class PageConnecting : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageConnecting(QWidget* parent = 0); + public: + PageConnecting(QWidget* parent = 0); -signals: - void cancelConnection(); + signals: + void cancelConnection(); -protected: - QLayout * bodyLayoutDefinition(); - void connectSignals(); + protected: + QLayout * bodyLayoutDefinition(); + void connectSignals(); }; #endif diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pagedata.cpp --- a/QTfrontend/ui/page/pagedata.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pagedata.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -86,7 +86,8 @@ QProgressBar *progressBar = new QProgressBar(this); progressBarsLayout->addWidget(progressBar); progressBars.insert(reply, progressBar); - } else + } + else { qWarning() << "Page Request" << url.toString(); @@ -166,8 +167,8 @@ zip.setIoDevice(&buffer); if(!zip.open(QuaZip::mdUnzip)) { - qWarning("testRead(): zip.open(): %d", zip.getZipError()); - return false; + qWarning("testRead(): zip.open(): %d", zip.getZipError()); + return false; } QuaZipFile file(&zip); @@ -190,7 +191,8 @@ { QFileInfo fi(filePath); QDir().mkpath(fi.filePath()); - } else + } + else { qDebug() << "Extracting" << filePath; QFile out(filePath); @@ -204,12 +206,14 @@ out.close(); - if(file.getZipError() != UNZ_OK) { + if(file.getZipError() != UNZ_OK) + { qWarning("file.getFileName(): %d", file.getZipError()); return false; } - if(!file.atEnd()) { + if(!file.atEnd()) + { qWarning("read all but not EOF"); return false; } @@ -217,7 +221,8 @@ file.close(); - if(file.getZipError()!=UNZ_OK) { + if(file.getZipError()!=UNZ_OK) + { qWarning("file.close(): %d", file.getZipError()); return false; } diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pagedata.h --- a/QTfrontend/ui/page/pagedata.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pagedata.h Mon Jan 30 17:32:18 2012 -0500 @@ -29,31 +29,31 @@ class PageDataDownload : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageDataDownload(QWidget* parent = 0); + public: + PageDataDownload(QWidget* parent = 0); -public slots: - void fetchList(); + public slots: + void fetchList(); -protected: - QLayout * bodyLayoutDefinition(); - void connectSignals(); + protected: + QLayout * bodyLayoutDefinition(); + void connectSignals(); -private: - DataBrowser *web; - QHash progressBars; - QVBoxLayout *progressBarsLayout; + private: + DataBrowser *web; + QHash progressBars; + QVBoxLayout *progressBarsLayout; - bool extractDataPack(QByteArray * buf); + bool extractDataPack(QByteArray * buf); -private slots: - void request(const QUrl &url); + private slots: + void request(const QUrl &url); - void pageDownloaded(); - void fileDownloaded(); - void downloadProgress(qint64, qint64); + void pageDownloaded(); + void fileDownloaded(); + void downloadProgress(qint64, qint64); }; #endif diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pagedrawmap.h --- a/QTfrontend/ui/page/pagedrawmap.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pagedrawmap.h Mon Jan 30 17:32:18 2012 -0500 @@ -25,26 +25,26 @@ class PageDrawMap : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageDrawMap(QWidget* parent = 0); + public: + PageDrawMap(QWidget* parent = 0); - DrawMapWidget * drawMapWidget; + DrawMapWidget * drawMapWidget; -protected: - QLayout * bodyLayoutDefinition(); - void connectSignals(); + protected: + QLayout * bodyLayoutDefinition(); + void connectSignals(); -private: - QPushButton * pbUndo; - QPushButton * pbClear; - QPushButton * pbLoad; - QPushButton * pbSave; + private: + QPushButton * pbUndo; + QPushButton * pbClear; + QPushButton * pbLoad; + QPushButton * pbSave; -private slots: - void load(); - void save(); + private slots: + void load(); + void save(); }; #endif diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pageeditteam.cpp --- a/QTfrontend/ui/page/pageeditteam.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pageeditteam.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -114,9 +114,9 @@ CBTeamLvl->addItem(QIcon(":/res/botlevels/0.png"), QComboBox::tr("Human")); for(int i = 5; i > 0; i--) CBTeamLvl->addItem( - QIcon(QString(":/res/botlevels/%1.png").arg(6 - i)), - QString("%1 %2").arg(QComboBox::tr("Level")).arg(i) - ); + QIcon(QString(":/res/botlevels/%1.png").arg(6 - i)), + QString("%1 %2").arg(QComboBox::tr("Level")).arg(i) + ); GBTLayout->addWidget(CBTeamLvl, 1, 1); CBGrave = new QComboBox(GBoxTeam); @@ -170,7 +170,8 @@ QWidget * curW = NULL; QGridLayout * pagelayout = NULL; QLabel* l = NULL; - while (i < BINDS_NUMBER) { + while (i < BINDS_NUMBER) + { if(cbinds[i].category != NULL) { if(curW != NULL) @@ -222,21 +223,21 @@ for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++) { connect(HHNameEdit[i], SIGNAL(editingFinished()), signalMapper1, SLOT(map())); - signalMapper1->setMapping(HHNameEdit[i], i); + signalMapper1->setMapping(HHNameEdit[i], i); connect(btnRandomHogName[i], SIGNAL(clicked()), signalMapper2, SLOT(map())); - signalMapper2->setMapping(btnRandomHogName[i], i); + signalMapper2->setMapping(btnRandomHogName[i], i); } connect(btnRandomTeam, SIGNAL(clicked()), this, SLOT(setRandomNames())); - + connect(btnTestSound, SIGNAL(clicked()), this, SLOT(testSound())); connect(CBFort, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(CBFort_activated(const QString &))); } PageEditTeam::PageEditTeam(QWidget* parent) : - AbstractPage(parent) + AbstractPage(parent) { initPage(); @@ -250,7 +251,7 @@ // voicepacks - list = dataMgr.entryList("Sounds/voices", + list = dataMgr.entryList("Sounds/voices", QDir::AllDirs | QDir::NoDotAndDotDot); CBVoicepack->addItems(list); @@ -344,20 +345,20 @@ QString voiceDir = QString("Sounds/voices/") + CBVoicepack->currentText(); QStringList list = dataMgr.entryList( - voiceDir, - QDir::Files, - QStringList() << - "Illgetyou.ogg" << - "Incoming.ogg" << - "Stupid.ogg" << - "Coward.ogg" << - "Firstblood.ogg" - ); + voiceDir, + QDir::Files, + QStringList() << + "Illgetyou.ogg" << + "Incoming.ogg" << + "Stupid.ogg" << + "Coward.ogg" << + "Firstblood.ogg" + ); if (!list.isEmpty()) SDLInteraction::instance().playSoundFile( dataMgr.findFileForRead(voiceDir + "/" + - list[rand() % list.size()]) + list[rand() % list.size()]) ); } diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pageeditteam.h --- a/QTfrontend/ui/page/pageeditteam.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pageeditteam.h Mon Jan 30 17:32:18 2012 -0500 @@ -31,63 +31,63 @@ class PageEditTeam : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageEditTeam(QWidget* parent); + public: + PageEditTeam(QWidget* parent); - void createTeam(const QString & name, const QString & playerHash); - void editTeam(const QString & name, const QString & playerHash); - void deleteTeam(const QString & name); + void createTeam(const QString & name, const QString & playerHash); + void editTeam(const QString & name, const QString & playerHash); + void deleteTeam(const QString & name); -signals: - void teamEdited(); + signals: + void teamEdited(); -public slots: - void CBFort_activated(const QString & gravename); + public slots: + void CBFort_activated(const QString & gravename); -private: - QSignalMapper* signalMapper1; - QSignalMapper* signalMapper2; - QGroupBox *GBoxHedgehogs; - QGroupBox *GBoxTeam; - QGroupBox *GBoxFort; - QComboBox *CBFort; - SquareLabel *FortPreview; - QComboBox *CBGrave; - QComboBox *CBFlag; - QComboBox *CBTeamLvl; - QComboBox *CBVoicepack; - QGroupBox *GBoxBinds; - QToolBox *BindsBox; - QLineEdit * TeamNameEdit; - QLineEdit * HHNameEdit[HEDGEHOGS_PER_TEAM]; - QComboBox * HHHats[HEDGEHOGS_PER_TEAM]; - QComboBox * CBBind[BINDS_NUMBER]; - HWTeam data(); - QString m_playerHash; + private: + QSignalMapper* signalMapper1; + QSignalMapper* signalMapper2; + QGroupBox *GBoxHedgehogs; + QGroupBox *GBoxTeam; + QGroupBox *GBoxFort; + QComboBox *CBFort; + SquareLabel *FortPreview; + QComboBox *CBGrave; + QComboBox *CBFlag; + QComboBox *CBTeamLvl; + QComboBox *CBVoicepack; + QGroupBox *GBoxBinds; + QToolBox *BindsBox; + QLineEdit * TeamNameEdit; + QLineEdit * HHNameEdit[HEDGEHOGS_PER_TEAM]; + QComboBox * HHHats[HEDGEHOGS_PER_TEAM]; + QComboBox * CBBind[BINDS_NUMBER]; + HWTeam data(); + QString m_playerHash; - QLayout * bodyLayoutDefinition(); - QLayout * footerLayoutDefinition(); - void connectSignals(); + QLayout * bodyLayoutDefinition(); + QLayout * footerLayoutDefinition(); + void connectSignals(); - void loadTeam(const HWTeam & team); + void loadTeam(const HWTeam & team); - // page 1 - QPushButton * btnRandomHogName[HEDGEHOGS_PER_TEAM]; - QPushButton * btnRandomTeam; - QPushButton * btnTestSound; + // page 1 + QPushButton * btnRandomHogName[HEDGEHOGS_PER_TEAM]; + QPushButton * btnRandomTeam; + QPushButton * btnTestSound; -private slots: - void saveTeam(); - void setRandomNames(); + private slots: + void saveTeam(); + void setRandomNames(); - void setRandomName(int hh_index); - - /// Plays a random voice sound of the currently edited team. - void testSound(); + void setRandomName(int hh_index); - void fixHHname(int idx); + /// Plays a random voice sound of the currently edited team. + void testSound(); + + void fixHHname(int idx); }; #endif diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pagefeedback.cpp --- a/QTfrontend/ui/page/pagefeedback.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pagefeedback.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -15,7 +15,7 @@ * 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 @@ -28,17 +28,17 @@ { QVBoxLayout * pageLayout = new QVBoxLayout(); QHBoxLayout * summaryLayout = new QHBoxLayout(); - + info = new QLabel(); info->setText( - "" - "

Please give us a feedback!

" - "

We are always happy about suggestions, ideas or bug reports.

" - "

The feedback will be posted as a new issue on our Google Code page.

" - "

" - ); + "" + "

Please give us a feedback!

" + "

We are always happy about suggestions, ideas or bug reports.

" + "

The feedback will be posted as a new issue on our Google Code page.

" + "

" + ); pageLayout->addWidget(info); label_summary = new QLabel(); @@ -61,7 +61,7 @@ QLayout * PageFeedback::footerLayoutDefinition() { QHBoxLayout * bottomLayout = new QHBoxLayout(); - + bottomLayout->setStretch(0,1); //TODO: create logo for send button BtnSend = addButton("Send", bottomLayout, 0, false); diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pagefeedback.h --- a/QTfrontend/ui/page/pagefeedback.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pagefeedback.h Mon Jan 30 17:32:18 2012 -0500 @@ -23,22 +23,22 @@ class PageFeedback : public AbstractPage { - Q_OBJECT + Q_OBJECT + + public: + PageFeedback(QWidget * parent = 0); -public: - PageFeedback(QWidget * parent = 0); - - QPushButton * BtnSend; - QLineEdit * summary; - QTextBrowser * description; - QLabel * info; - QLabel * label_summary; - QLabel * label_description; + QPushButton * BtnSend; + QLineEdit * summary; + QTextBrowser * description; + QLabel * info; + QLabel * label_summary; + QLabel * label_description; -private: - QLayout * bodyLayoutDefinition(); - QLayout * footerLayoutDefinition(); - void connectSignals(); + private: + QLayout * bodyLayoutDefinition(); + QLayout * footerLayoutDefinition(); + void connectSignals(); }; #endif diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pagegamestats.cpp --- a/QTfrontend/ui/page/pagegamestats.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pagegamestats.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -62,7 +62,7 @@ gbl->addWidget(labelGameStats); gb->setLayout(gbl); pageLayout->addWidget(gb, 1, 1, 1, 2); - + // graph graphic = new FitGraphicsView(gb); l = new QLabel(this); @@ -73,7 +73,7 @@ gbl->addWidget(graphic); graphic->scale(1.0, -1.0); graphic->setBackgroundBrush(QBrush(Qt::black)); - + labelGameWin = new QLabel(this); labelGameWin->setTextFormat(Qt::RichText); pageLayout->addWidget(labelGameWin, 0, 0, 1, 2); @@ -160,38 +160,45 @@ void PageGameStats::GameStats(char type, const QString & info) { - switch(type) { - case 'r' : { + switch(type) + { + case 'r' : + { labelGameWin->setText(QString("

%1

").arg(info)); break; } - case 'D' : { + case 'D' : + { int i = info.indexOf(' '); QString message = "

" + PageGameStats::tr("The best shot award was won by %1 with %2 pts.").arg(info.mid(i + 1), info.left(i)) + "

"; AddStatText(message); break; } - case 'k' : { + case 'k' : + { int i = info.indexOf(' '); int num = info.left(i).toInt(); QString message = "

" + PageGameStats::tr("The best killer is %1 with %2 kills in a turn.", "", num).arg(info.mid(i + 1), info.left(i)) + "

"; AddStatText(message); break; } - case 'K' : { + case 'K' : + { int num = info.toInt(); QString message = "

" + PageGameStats::tr("A total of %1 hedgehog(s) were killed during this round.", "", num).arg(num) + "

"; AddStatText(message); break; } - case 'H' : { + case 'H' : + { int i = info.indexOf(' '); quint32 clan = info.left(i).toInt(); quint32 hp = info.mid(i + 1).toUInt(); healthPoints[clan].append(hp); break; } - case 'T': { // local team stats + case 'T': // local team stats + { //AddStatText("

local team: " + info + "

"); QStringList infol = info.split(":"); HWTeam team(infol[0]); @@ -204,9 +211,10 @@ //team.SaveToFile(); // don't save yet } break; - } + } - case 'P' : { + case 'P' : + { int i = info.indexOf(' '); playerPosition++; QString color = info.left(i); @@ -227,17 +235,17 @@ switch (playerPosition) { case 1: - image = ""; - break; - case 2: - image = ""; - break; - case 3: - image = ""; - break; - default: - image = ""; - break; + image = ""; + break; + case 2: + image = ""; + break; + case 3: + image = ""; + break; + default: + image = ""; + break; } QString message; @@ -246,23 +254,26 @@ message = QString("

%1 %2. %3 ").arg(image, QString::number(playerPosition), playername, clanColor.name()) + killstring + "

"; labelGameRank->setText(labelGameRank->text() + message); - break; + break; } - case 's' : { + case 's' : + { int i = info.indexOf(' '); int num = info.left(i).toInt(); QString message = "

" + PageGameStats::tr("%1 thought it's good to shoot his own hedgehogs with %2 pts.", "", num).arg(info.mid(i + 1)).arg(num) + "

"; AddStatText(message); break; } - case 'S' : { + case 'S' : + { int i = info.indexOf(' '); int num = info.left(i).toInt(); QString message = "

" + PageGameStats::tr("%1 killed %2 of his own hedgehogs.", "", num).arg(info.mid(i + 1)).arg(num) + "

"; AddStatText(message); break; } - case 'B' : { + case 'B' : + { int i = info.indexOf(' '); int num = info.left(i).toInt(); QString message = "

" + PageGameStats::tr("%1 was scared and skipped turn %2 times.", "", num).arg(info.mid(i + 1)).arg(num) + "

"; diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pagegamestats.h --- a/QTfrontend/ui/page/pagegamestats.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pagegamestats.h Mon Jan 30 17:32:18 2012 -0500 @@ -27,47 +27,47 @@ class FitGraphicsView : public QGraphicsView { - Q_OBJECT + Q_OBJECT -public: - FitGraphicsView(QWidget* parent = 0); + public: + FitGraphicsView(QWidget* parent = 0); -protected: - void resizeEvent(QResizeEvent * event); + protected: + void resizeEvent(QResizeEvent * event); }; class PageGameStats : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageGameStats(QWidget* parent = 0); + public: + PageGameStats(QWidget* parent = 0); - QPushButton *btnSave; - QLabel *labelGameStats; - QLabel *labelGameWin; - QLabel *labelGameRank; - FitGraphicsView * graphic; + QPushButton *btnSave; + QLabel *labelGameStats; + QLabel *labelGameWin; + QLabel *labelGameRank; + FitGraphicsView * graphic; -public slots: - void GameStats(char type, const QString & info); - void clear(); - void renderStats(); - -signals: - void saveDemoRequested(); + public slots: + void GameStats(char type, const QString & info); + void clear(); + void renderStats(); + + signals: + void saveDemoRequested(); -private: - void AddStatText(const QString & msg); + private: + void AddStatText(const QString & msg); - QMap > healthPoints; - unsigned int playerPosition; - quint32 lastColor; + QMap > healthPoints; + unsigned int playerPosition; + quint32 lastColor; -protected: - QLayout * bodyLayoutDefinition(); - QLayout * footerLayoutDefinition(); - void connectSignals(); + protected: + QLayout * bodyLayoutDefinition(); + QLayout * footerLayoutDefinition(); + void connectSignals(); }; #endif // STATSPAGE_H diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pageinfo.h --- a/QTfrontend/ui/page/pageinfo.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pageinfo.h Mon Jan 30 17:32:18 2012 -0500 @@ -25,18 +25,18 @@ class PageInfo : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageInfo(QWidget* parent = 0); + public: + PageInfo(QWidget* parent = 0); - QPushButton *BtnSnapshots; - About *about; + QPushButton *BtnSnapshots; + About *about; -private: - QLayout * bodyLayoutDefinition(); - QLayout * footerLayoutDefinition(); - void connectSignals(); + private: + QLayout * bodyLayoutDefinition(); + QLayout * footerLayoutDefinition(); + void connectSignals(); }; #endif diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pageingame.h --- a/QTfrontend/ui/page/pageingame.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pageingame.h Mon Jan 30 17:32:18 2012 -0500 @@ -23,7 +23,7 @@ class PageInGame : public AbstractPage { - Q_OBJECT + Q_OBJECT public: PageInGame(QWidget * parent = 0); diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pagemain.cpp --- a/QTfrontend/ui/page/pagemain.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pagemain.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -15,7 +15,7 @@ * 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 @@ -80,7 +80,7 @@ mainNote = new QLabel(this); mainNote->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); mainNote->setWordWrap(true); - + bottomLayout->addWidget(mainNote, 0); bottomLayout->setStretch(0,1); @@ -114,62 +114,62 @@ QString PageMain::randomTip() const { QStringList Tips; - Tips << tr("Simply pick the same color as a friend to play together as a team. Each of you will still control his or her own hedgehogs but they'll win or lose together.", "Tips"); - Tips << tr("Some weapons might do only low damage but they can be a lot more devastating in the right situation. Try to use the Desert Eagle to knock multiple hedgehogs into the water.", "Tips"); - Tips << tr("If you're unsure what to do and don't want to waste ammo, skip one round. But don't let too much time pass as there will be Sudden Death!", "Tips"); - Tips << tr("Want to save ropes? Release the rope in mid air and then shoot again. As long as you don't touch the ground you'll reuse your rope without wasting ammo!", "Tips"); - Tips << tr("If you'd like to keep others from using your preferred nickname on the official server, register an account at http://www.hedgewars.org/.", "Tips"); - Tips << tr("You're bored of default gameplay? Try one of the missions - they'll offer different gameplay depending on the one you picked.", "Tips"); - Tips << tr("By default the game will always record the last game played as a demo. Select 'Local Game' and pick the 'Demos' button on the lower right corner to play or manage them.", "Tips"); - Tips << tr("Hedgewars is Open Source and Freeware we create in our spare time. If you've got problems, ask on our forums but please don't expect 24/7 support!", "Tips"); - Tips << tr("Hedgewars is Open Source and Freeware we create in our spare time. If you like it, help us with a small donation or contribute your own work!", "Tips"); - Tips << tr("Hedgewars is Open Source and Freeware we create in our spare time. Share it with your family and friends as you like!", "Tips"); - Tips << tr("Hedgewars is Open Source and Freeware we create in our spare time. If someone sold you the game, you should try get a refund!", "Tips"); - Tips << tr("From time to time there will be official tournaments. Upcoming events will be announced at http://www.hedgewars.org/ some days in advance.", "Tips"); - Tips << tr("Hedgewars is available in many languages. If the translation in your language seems to be missing or outdated, feel free to contact us!", "Tips"); - Tips << tr("Hedgewars can be run on lots of different operating systems including Microsoft Windows, Mac OS X and Linux.", "Tips"); - Tips << tr("Always remember you're able to set up your own games in local and network/online play. You're not restricted to the 'Simple Game' option.", "Tips"); - Tips << tr("Connect one or more gamepads before starting the game to be able to assign their controls to your teams.", "Tips"); - Tips << tr("Create an account on %1 to keep others from using your most favourite nickname while playing on the official server.", "Tips").arg("http://www.hedgewars.org/"); - Tips << tr("While playing you should give yourself a short break at least once an hour.", "Tips"); - Tips << tr("If your graphics card isn't able to provide hardware accelerated OpenGL, try to enable the low quality mode to improve performance.", "Tips"); - Tips << tr("If your graphics card isn't able to provide hardware accelerated OpenGL, try to update the associated drivers.", "Tips"); - Tips << tr("We're open to suggestions and constructive feedback. If you don't like something or got a great idea, let us know!", "Tips"); - Tips << tr("Especially while playing online be polite and always remember there might be some minors playing with or against you as well!", "Tips"); - Tips << tr("Special game modes such as 'Vampirism' or 'Karma' allow you to develop completely new tactics. Try them in a custom game!", "Tips"); - Tips << tr("The Windows version of Hedgewars supports Xfire. Make sure to add Hedgewars to its game list so your friends can see you playing.", "Tips"); - Tips << tr("You should never install Hedgewars on computers you don't own (school, university, work, etc.). Please ask the responsible person instead!", "Tips"); - Tips << tr("Hedgewars can be perfect for short games during breaks. Just ensure you don't add too many hedgehogs or use an huge map. Reducing time and health might help as well.", "Tips"); - Tips << tr("No hedgehogs were harmed in making this game.", "Tips"); - Tips << tr("There are three different jumps available. Tap [high jump] twice to do a very high/backwards jump.", "Tips"); - Tips << tr("Afraid of falling off a cliff? Hold down [precise] to turn [left] or [right] without actually moving.", "Tips"); - Tips << tr("Some weapons require special strategies or just lots of training, so don't give up on a particular tool if you miss an enemy once.", "Tips"); - Tips << tr("Most weapons won't work once they touch the water. The Homing Bee as well as the Cake are exceptions to this.", "Tips"); - Tips << tr("The Old Limbuger only causes a small explosion. However the wind affected smelly cloud can poison lots of hogs at once.", "Tips"); - Tips << tr("The Piano Strike is the most damaging air strike. You'll lose the hedgehog performing it, so there's a huge downside as well.", "Tips"); - Tips << tr("The Homing Bee can be tricky to use. Its turn radius depends on its velocity, so try to not use full power.", "Tips"); - Tips << tr("Sticky Mines are a perfect tool to create small chain reactions knocking enemy hedgehogs into dire situations ... or water.", "Tips"); - Tips << tr("The Hammer is most effective when used on bridges or girders. Hit hogs will just break through the ground.", "Tips"); - Tips << tr("If you're stuck behind an enemy hedgehog, use the Hammer to free yourself without getting damaged by an explosion.", "Tips"); - Tips << tr("The Cake's maximum walking distance depends on the ground it has to pass. Use [attack] to detonate it early.", "Tips"); - Tips << tr("The Flame Thrower is a weapon but it can be used for tunnel digging as well.", "Tips"); - Tips << tr("Use the Molotov or Flame Thrower to temporary keep hedgehogs from passing terrain such as tunnels or platforms.", "Tips"); - Tips << tr("Want to know who's behind the game? Click on the Hedgewars logo in the main menu to see the credits.", "Tips"); - Tips << tr("Like Hedgewars? Become a fan on %1 or follow us on %2!", "Tips").arg("Facebook").arg("Twitter"); - Tips << tr("Feel free to draw your own graves, hats, flags or even maps and themes! But note that you'll have to share them somewhere to use them online.", "Tips"); - Tips << tr("Really want to wear a specific hat? Donate to us and receive an exclusive hat of your choice!", "Tips"); - // The following tip will require links to app store entries first. - //Tips << tr("Want to play Hedgewars any time? Grab the Mobile version for %1 and %2.", "Tips").arg("").arg(""); - // the ios version is located here: http://itunes.apple.com/us/app/hedgewars/id391234866 - Tips << tr("Keep your video card drivers up to date to avoid issues playing the game.", "Tips"); - Tips << tr("You're able to associate Hedgewars related files (savegames and demo recordings) with the game to launch them right from your favorite file or internet browser.", "Tips"); + Tips << tr("Simply pick the same color as a friend to play together as a team. Each of you will still control his or her own hedgehogs but they'll win or lose together.", "Tips"); + Tips << tr("Some weapons might do only low damage but they can be a lot more devastating in the right situation. Try to use the Desert Eagle to knock multiple hedgehogs into the water.", "Tips"); + Tips << tr("If you're unsure what to do and don't want to waste ammo, skip one round. But don't let too much time pass as there will be Sudden Death!", "Tips"); + Tips << tr("Want to save ropes? Release the rope in mid air and then shoot again. As long as you don't touch the ground you'll reuse your rope without wasting ammo!", "Tips"); + Tips << tr("If you'd like to keep others from using your preferred nickname on the official server, register an account at http://www.hedgewars.org/.", "Tips"); + Tips << tr("You're bored of default gameplay? Try one of the missions - they'll offer different gameplay depending on the one you picked.", "Tips"); + Tips << tr("By default the game will always record the last game played as a demo. Select 'Local Game' and pick the 'Demos' button on the lower right corner to play or manage them.", "Tips"); + Tips << tr("Hedgewars is Open Source and Freeware we create in our spare time. If you've got problems, ask on our forums but please don't expect 24/7 support!", "Tips"); + Tips << tr("Hedgewars is Open Source and Freeware we create in our spare time. If you like it, help us with a small donation or contribute your own work!", "Tips"); + Tips << tr("Hedgewars is Open Source and Freeware we create in our spare time. Share it with your family and friends as you like!", "Tips"); + Tips << tr("Hedgewars is Open Source and Freeware we create in our spare time. If someone sold you the game, you should try get a refund!", "Tips"); + Tips << tr("From time to time there will be official tournaments. Upcoming events will be announced at http://www.hedgewars.org/ some days in advance.", "Tips"); + Tips << tr("Hedgewars is available in many languages. If the translation in your language seems to be missing or outdated, feel free to contact us!", "Tips"); + Tips << tr("Hedgewars can be run on lots of different operating systems including Microsoft Windows, Mac OS X and Linux.", "Tips"); + Tips << tr("Always remember you're able to set up your own games in local and network/online play. You're not restricted to the 'Simple Game' option.", "Tips"); + Tips << tr("Connect one or more gamepads before starting the game to be able to assign their controls to your teams.", "Tips"); + Tips << tr("Create an account on %1 to keep others from using your most favourite nickname while playing on the official server.", "Tips").arg("http://www.hedgewars.org/"); + Tips << tr("While playing you should give yourself a short break at least once an hour.", "Tips"); + Tips << tr("If your graphics card isn't able to provide hardware accelerated OpenGL, try to enable the low quality mode to improve performance.", "Tips"); + Tips << tr("If your graphics card isn't able to provide hardware accelerated OpenGL, try to update the associated drivers.", "Tips"); + Tips << tr("We're open to suggestions and constructive feedback. If you don't like something or got a great idea, let us know!", "Tips"); + Tips << tr("Especially while playing online be polite and always remember there might be some minors playing with or against you as well!", "Tips"); + Tips << tr("Special game modes such as 'Vampirism' or 'Karma' allow you to develop completely new tactics. Try them in a custom game!", "Tips"); + Tips << tr("The Windows version of Hedgewars supports Xfire. Make sure to add Hedgewars to its game list so your friends can see you playing.", "Tips"); + Tips << tr("You should never install Hedgewars on computers you don't own (school, university, work, etc.). Please ask the responsible person instead!", "Tips"); + Tips << tr("Hedgewars can be perfect for short games during breaks. Just ensure you don't add too many hedgehogs or use an huge map. Reducing time and health might help as well.", "Tips"); + Tips << tr("No hedgehogs were harmed in making this game.", "Tips"); + Tips << tr("There are three different jumps available. Tap [high jump] twice to do a very high/backwards jump.", "Tips"); + Tips << tr("Afraid of falling off a cliff? Hold down [precise] to turn [left] or [right] without actually moving.", "Tips"); + Tips << tr("Some weapons require special strategies or just lots of training, so don't give up on a particular tool if you miss an enemy once.", "Tips"); + Tips << tr("Most weapons won't work once they touch the water. The Homing Bee as well as the Cake are exceptions to this.", "Tips"); + Tips << tr("The Old Limbuger only causes a small explosion. However the wind affected smelly cloud can poison lots of hogs at once.", "Tips"); + Tips << tr("The Piano Strike is the most damaging air strike. You'll lose the hedgehog performing it, so there's a huge downside as well.", "Tips"); + Tips << tr("The Homing Bee can be tricky to use. Its turn radius depends on its velocity, so try to not use full power.", "Tips"); + Tips << tr("Sticky Mines are a perfect tool to create small chain reactions knocking enemy hedgehogs into dire situations ... or water.", "Tips"); + Tips << tr("The Hammer is most effective when used on bridges or girders. Hit hogs will just break through the ground.", "Tips"); + Tips << tr("If you're stuck behind an enemy hedgehog, use the Hammer to free yourself without getting damaged by an explosion.", "Tips"); + Tips << tr("The Cake's maximum walking distance depends on the ground it has to pass. Use [attack] to detonate it early.", "Tips"); + Tips << tr("The Flame Thrower is a weapon but it can be used for tunnel digging as well.", "Tips"); + Tips << tr("Use the Molotov or Flame Thrower to temporary keep hedgehogs from passing terrain such as tunnels or platforms.", "Tips"); + Tips << tr("Want to know who's behind the game? Click on the Hedgewars logo in the main menu to see the credits.", "Tips"); + Tips << tr("Like Hedgewars? Become a fan on %1 or follow us on %2!", "Tips").arg("Facebook").arg("Twitter"); + Tips << tr("Feel free to draw your own graves, hats, flags or even maps and themes! But note that you'll have to share them somewhere to use them online.", "Tips"); + Tips << tr("Really want to wear a specific hat? Donate to us and receive an exclusive hat of your choice!", "Tips"); + // The following tip will require links to app store entries first. + //Tips << tr("Want to play Hedgewars any time? Grab the Mobile version for %1 and %2.", "Tips").arg("").arg(""); + // the ios version is located here: http://itunes.apple.com/us/app/hedgewars/id391234866 + Tips << tr("Keep your video card drivers up to date to avoid issues playing the game.", "Tips"); + Tips << tr("You're able to associate Hedgewars related files (savegames and demo recordings) with the game to launch them right from your favorite file or internet browser.", "Tips"); #ifdef _WIN32 - Tips << tr("You can find your Hedgewars configuration files under \"My Documents\\Hedgewars\". Create backups or take the files with you, but don't edit them by hand.", "Tips"); + Tips << tr("You can find your Hedgewars configuration files under \"My Documents\\Hedgewars\". Create backups or take the files with you, but don't edit them by hand.", "Tips"); #elif defined __APPLE__ - Tips << tr("You can find your Hedgewars configuration files under \"Library/Application Support/Hedgewars\" in your home directory. Create backups or take the files with you, but don't edit them by hand.", "Tips"); + Tips << tr("You can find your Hedgewars configuration files under \"Library/Application Support/Hedgewars\" in your home directory. Create backups or take the files with you, but don't edit them by hand.", "Tips"); #else - Tips << tr("You can find your Hedgewars configuration files under \".hedgewars\" in your home directory. Create backups or take the files with you, but don't edit them by hand.", "Tips"); + Tips << tr("You can find your Hedgewars configuration files under \".hedgewars\" in your home directory. Create backups or take the files with you, but don't edit them by hand.", "Tips"); #endif - return Tips[QTime(0, 0, 0).secsTo(QTime::currentTime()) % Tips.length()]; + return Tips[QTime(0, 0, 0).secsTo(QTime::currentTime()) % Tips.length()]; } diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pagemain.h --- a/QTfrontend/ui/page/pagemain.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pagemain.h Mon Jan 30 17:32:18 2012 -0500 @@ -23,25 +23,25 @@ class PageMain : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageMain(QWidget * parent = 0); + public: + PageMain(QWidget * parent = 0); - QPushButton * BtnSinglePlayer; - QPushButton * BtnNet; - QPushButton * BtnSetup; - QPushButton * BtnFeedback; - QPushButton * BtnInfo; - QPushButton * BtnDataDownload; - QLabel * mainNote; + QPushButton * BtnSinglePlayer; + QPushButton * BtnNet; + QPushButton * BtnSetup; + QPushButton * BtnFeedback; + QPushButton * BtnInfo; + QPushButton * BtnDataDownload; + QLabel * mainNote; -private: - QLayout * bodyLayoutDefinition(); - QLayout * footerLayoutDefinition(); - void connectSignals(); + private: + QLayout * bodyLayoutDefinition(); + QLayout * footerLayoutDefinition(); + void connectSignals(); - QString randomTip() const; + QString randomTip() const; }; #endif diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pagemultiplayer.h --- a/QTfrontend/ui/page/pagemultiplayer.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pagemultiplayer.h Mon Jan 30 17:32:18 2012 -0500 @@ -26,24 +26,24 @@ class PageMultiplayer : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageMultiplayer(QWidget* parent = 0); + public: + PageMultiplayer(QWidget* parent = 0); - GameCFGWidget *gameCFG; - TeamSelWidget *teamsSelect; - QPushButton *BtnStartMPGame; + GameCFGWidget *gameCFG; + TeamSelWidget *teamsSelect; + QPushButton *BtnStartMPGame; -signals: - void SetupClicked(); + signals: + void SetupClicked(); -private: - QLayout * bodyLayoutDefinition(); - QLayout * footerLayoutDefinition(); - void connectSignals(); + private: + QLayout * bodyLayoutDefinition(); + QLayout * footerLayoutDefinition(); + void connectSignals(); - QPushButton * btnSetup; + QPushButton * btnSetup; }; #endif diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pagenet.h --- a/QTfrontend/ui/page/pagenet.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pagenet.h Mon Jan 30 17:32:18 2012 -0500 @@ -23,33 +23,33 @@ class PageNet : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageNet(QWidget* parent = 0); + public: + PageNet(QWidget* parent = 0); - QPushButton* BtnUpdateSList; - QTableView * tvServersList; - QPushButton * BtnNetConnect; - QPushButton * BtnNetSvrStart; - QPushButton * BtnSpecifyServer; + QPushButton* BtnUpdateSList; + QTableView * tvServersList; + QPushButton * BtnNetConnect; + QPushButton * BtnNetSvrStart; + QPushButton * BtnSpecifyServer; -public slots: - void updateServersList(); + public slots: + void updateServersList(); -signals: - void connectClicked(const QString & host, quint16 port); + signals: + void connectClicked(const QString & host, quint16 port); -private: - QLayout * bodyLayoutDefinition(); - QLayout * footerLayoutDefinition(); - void connectSignals(); + private: + QLayout * bodyLayoutDefinition(); + QLayout * footerLayoutDefinition(); + void connectSignals(); - QGroupBox * ConnGroupBox; - QGridLayout * GBClayout; + QGroupBox * ConnGroupBox; + QGridLayout * GBClayout; -private slots: - void slotConnect(); + private slots: + void slotConnect(); }; #endif diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pagenetgame.cpp --- a/QTfrontend/ui/page/pagenetgame.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pagenetgame.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -153,9 +153,9 @@ { leRoomName->clear(); QMessageBox::critical(this, - tr("Error"), - tr("Please enter room name"), - tr("OK")); + tr("Error"), + tr("Please enter room name"), + tr("OK")); } } diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pagenetgame.h --- a/QTfrontend/ui/page/pagenetgame.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pagenetgame.h Mon Jan 30 17:32:18 2012 -0500 @@ -29,53 +29,53 @@ class PageNetGame : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageNetGame(QWidget* parent, QSettings * gameSettings); + public: + PageNetGame(QWidget* parent, QSettings * gameSettings); - /** - * Sets the room name to display. - * @param roomName room name to be displayed. - */ - void setRoomName(const QString & roomName); + /** + * Sets the room name to display. + * @param roomName room name to be displayed. + */ + void setRoomName(const QString & roomName); - void displayError(const QString & message); - void displayNotice(const QString & message); - void displayWarning(const QString & message); + void displayError(const QString & message); + void displayNotice(const QString & message); + void displayWarning(const QString & message); - QPushButton *BtnGo; - QPushButton *BtnMaster; - QPushButton *BtnStart; - QPushButton *BtnUpdate; + QPushButton *BtnGo; + QPushButton *BtnMaster; + QPushButton *BtnStart; + QPushButton *BtnUpdate; - QAction * restrictJoins; - QAction * restrictTeamAdds; + QAction * restrictJoins; + QAction * restrictTeamAdds; - HWChatWidget* pChatWidget; + HWChatWidget* pChatWidget; - TeamSelWidget* pNetTeamsWidget; - GameCFGWidget* pGameCFG; + TeamSelWidget* pNetTeamsWidget; + GameCFGWidget* pGameCFG; -public slots: - void setReadyStatus(bool isReady); - void setUser(const QString & nickname); - void onUpdateClick(); - void setMasterMode(bool isMaster); + public slots: + void setReadyStatus(bool isReady); + void setUser(const QString & nickname); + void onUpdateClick(); + void setMasterMode(bool isMaster); -signals: - void SetupClicked(); - void askForUpdateRoomName(const QString &); + signals: + void SetupClicked(); + void askForUpdateRoomName(const QString &); -private: - QLayout * bodyLayoutDefinition(); - QLayout * footerLayoutDefinition(); - void connectSignals(); + private: + QLayout * bodyLayoutDefinition(); + QLayout * footerLayoutDefinition(); + void connectSignals(); - QSettings * m_gameSettings; + QSettings * m_gameSettings; - HistoryLineEdit * leRoomName; - QPushButton * btnSetup; + HistoryLineEdit * leRoomName; + QPushButton * btnSetup; }; #endif diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pagenetserver.h --- a/QTfrontend/ui/page/pagenetserver.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pagenetserver.h Mon Jan 30 17:32:18 2012 -0500 @@ -23,25 +23,25 @@ class PageNetServer : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageNetServer(QWidget* parent = 0); + public: + PageNetServer(QWidget* parent = 0); - QPushButton *BtnStart; - QPushButton *BtnDefault; - QLabel *labelSD; - QLineEdit *leServerDescr; - QLabel *labelPort; - QSpinBox *sbPort; + QPushButton *BtnStart; + QPushButton *BtnDefault; + QLabel *labelSD; + QLineEdit *leServerDescr; + QLabel *labelPort; + QSpinBox *sbPort; -protected: - QLayout * bodyLayoutDefinition(); - QLayout * footerLayoutDefinition(); - void connectSignals(); + protected: + QLayout * bodyLayoutDefinition(); + QLayout * footerLayoutDefinition(); + void connectSignals(); -private slots: - void setDefaultPort(); + private slots: + void setDefaultPort(); }; #endif diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pagenettype.h --- a/QTfrontend/ui/page/pagenettype.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pagenettype.h Mon Jan 30 17:32:18 2012 -0500 @@ -23,16 +23,16 @@ class PageNetType : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageNetType(QWidget* parent = 0); + public: + PageNetType(QWidget* parent = 0); - QPushButton * BtnLAN; - QPushButton * BtnOfficialServer; + QPushButton * BtnLAN; + QPushButton * BtnOfficialServer; -protected: - QLayout * bodyLayoutDefinition(); + protected: + QLayout * bodyLayoutDefinition(); }; #endif diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pageoptions.cpp --- a/QTfrontend/ui/page/pageoptions.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pageoptions.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -59,334 +59,334 @@ QPixmap pmEdit(":/res/edit.png"); QPixmap pmDelete(":/res/delete.png"); - { - teamsBox = new IconedGroupBox(this); - //teamsBox->setContentTopPadding(0); - //teamsBox->setAttribute(Qt::WA_PaintOnScreen, true); - teamsBox->setIcon(QIcon(":/res/teamicon.png")); - teamsBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - teamsBox->setTitle(QGroupBox::tr("Teams")); + { + teamsBox = new IconedGroupBox(this); + //teamsBox->setContentTopPadding(0); + //teamsBox->setAttribute(Qt::WA_PaintOnScreen, true); + teamsBox->setIcon(QIcon(":/res/teamicon.png")); + teamsBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + teamsBox->setTitle(QGroupBox::tr("Teams")); + + QGridLayout * GBTlayout = new QGridLayout(teamsBox); + + CBTeamName = new QComboBox(teamsBox); + GBTlayout->addWidget(CBTeamName, 0, 0); - QGridLayout * GBTlayout = new QGridLayout(teamsBox); + BtnNewTeam = new QPushButton(teamsBox); + BtnNewTeam->setToolTip(tr("New team")); + BtnNewTeam->setIconSize(pmNew.size()); + BtnNewTeam->setIcon(pmNew); + BtnNewTeam->setMaximumWidth(pmNew.width() + 6); + connect(BtnNewTeam, SIGNAL(clicked()), this, SIGNAL(newTeamRequested())); + GBTlayout->addWidget(BtnNewTeam, 0, 1); + + BtnEditTeam = new QPushButton(teamsBox); + BtnEditTeam->setToolTip(tr("Edit team")); + BtnEditTeam->setIconSize(pmEdit.size()); + BtnEditTeam->setIcon(pmEdit); + BtnEditTeam->setMaximumWidth(pmEdit.width() + 6); + connect(BtnEditTeam, SIGNAL(clicked()), this, SLOT(requestEditSelectedTeam())); + GBTlayout->addWidget(BtnEditTeam, 0, 2); + + BtnDeleteTeam = new QPushButton(teamsBox); + BtnDeleteTeam->setToolTip(tr("Delete team")); + BtnDeleteTeam->setIconSize(pmDelete.size()); + BtnDeleteTeam->setIcon(pmDelete); + BtnDeleteTeam->setMaximumWidth(pmDelete.width() + 6); + connect(BtnDeleteTeam, SIGNAL(clicked()), this, SLOT(requestDeleteSelectedTeam())); + GBTlayout->addWidget(BtnDeleteTeam, 0, 3); - CBTeamName = new QComboBox(teamsBox); - GBTlayout->addWidget(CBTeamName, 0, 0); + LblNoEditTeam = new QLabel(teamsBox); + LblNoEditTeam->setText(tr("You can't edit teams from team selection. Go back to main menu to add, edit or delete teams.")); + LblNoEditTeam->setWordWrap(true); + LblNoEditTeam->setVisible(false); + GBTlayout->addWidget(LblNoEditTeam, 0, 0); + + gbTBLayout->addWidget(teamsBox, 0, 0); + } + + { + IconedGroupBox* groupWeapons = new IconedGroupBox(this); + + //groupWeapons->setContentTopPadding(0); + //groupWeapons->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + groupWeapons->setIcon(QIcon(":/res/weaponsicon.png")); + groupWeapons->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + groupWeapons->setTitle(QGroupBox::tr("Schemes and Weapons")); + QGridLayout * WeaponsLayout = new QGridLayout(groupWeapons); - BtnNewTeam = new QPushButton(teamsBox); - BtnNewTeam->setToolTip(tr("New team")); - BtnNewTeam->setIconSize(pmNew.size()); - BtnNewTeam->setIcon(pmNew); - BtnNewTeam->setMaximumWidth(pmNew.width() + 6); - connect(BtnNewTeam, SIGNAL(clicked()), this, SIGNAL(newTeamRequested())); - GBTlayout->addWidget(BtnNewTeam, 0, 1); + QLabel* SchemeLabel = new QLabel(groupWeapons); + SchemeLabel->setText(QLabel::tr("Game scheme")); + WeaponsLayout->addWidget(SchemeLabel, 1, 0); + + SchemesName = new QComboBox(groupWeapons); + WeaponsLayout->addWidget(SchemesName, 1, 1); + + SchemeNew = new QPushButton(groupWeapons); + SchemeNew->setToolTip(tr("New scheme")); + SchemeNew->setIconSize(pmNew.size()); + SchemeNew->setIcon(pmNew); + SchemeNew->setMaximumWidth(pmNew.width() + 6); + WeaponsLayout->addWidget(SchemeNew, 1, 2); + + SchemeEdit = new QPushButton(groupWeapons); + SchemeEdit->setToolTip(tr("Edit scheme")); + SchemeEdit->setIconSize(pmEdit.size()); + SchemeEdit->setIcon(pmEdit); + SchemeEdit->setMaximumWidth(pmEdit.width() + 6); + WeaponsLayout->addWidget(SchemeEdit, 1, 3); - BtnEditTeam = new QPushButton(teamsBox); - BtnEditTeam->setToolTip(tr("Edit team")); - BtnEditTeam->setIconSize(pmEdit.size()); - BtnEditTeam->setIcon(pmEdit); - BtnEditTeam->setMaximumWidth(pmEdit.width() + 6); - connect(BtnEditTeam, SIGNAL(clicked()), this, SLOT(requestEditSelectedTeam())); - GBTlayout->addWidget(BtnEditTeam, 0, 2); + SchemeDelete = new QPushButton(groupWeapons); + SchemeDelete->setToolTip(tr("Delete scheme")); + SchemeDelete->setIconSize(pmDelete.size()); + SchemeDelete->setIcon(pmDelete); + SchemeDelete->setMaximumWidth(pmDelete.width() + 6); + WeaponsLayout->addWidget(SchemeDelete, 1, 4); + + QLabel* WeaponLabel = new QLabel(groupWeapons); + WeaponLabel->setText(QLabel::tr("Weapons")); + WeaponsLayout->addWidget(WeaponLabel, 2, 0); + + WeaponsName = new QComboBox(groupWeapons); + WeaponsLayout->addWidget(WeaponsName, 2, 1); + + WeaponNew = new QPushButton(groupWeapons); + WeaponNew->setToolTip(tr("New weapon set")); + WeaponNew->setIconSize(pmNew.size()); + WeaponNew->setIcon(pmNew); + WeaponNew->setMaximumWidth(pmNew.width() + 6); + WeaponsLayout->addWidget(WeaponNew, 2, 2); + + WeaponEdit = new QPushButton(groupWeapons); + WeaponEdit->setToolTip(tr("Edit weapon set")); + WeaponEdit->setIconSize(pmEdit.size()); + WeaponEdit->setIcon(pmEdit); + WeaponEdit->setMaximumWidth(pmEdit.width() + 6); + WeaponsLayout->addWidget(WeaponEdit, 2, 3); + + WeaponDelete = new QPushButton(groupWeapons); + WeaponDelete->setToolTip(tr("Delete weapon set")); + WeaponDelete->setIconSize(pmDelete.size()); + WeaponDelete->setIcon(pmDelete); + WeaponDelete->setMaximumWidth(pmDelete.width() + 6); + WeaponsLayout->addWidget(WeaponDelete, 2, 4); + + WeaponTooltip = new QCheckBox(this); + WeaponTooltip->setText(QCheckBox::tr("Show ammo menu tooltips")); + WeaponsLayout->addWidget(WeaponTooltip, 3, 0, 1, 4); + + gbTBLayout->addWidget(groupWeapons, 1, 0); + } - BtnDeleteTeam = new QPushButton(teamsBox); - BtnDeleteTeam->setToolTip(tr("Delete team")); - BtnDeleteTeam->setIconSize(pmDelete.size()); - BtnDeleteTeam->setIcon(pmDelete); - BtnDeleteTeam->setMaximumWidth(pmDelete.width() + 6); - connect(BtnDeleteTeam, SIGNAL(clicked()), this, SLOT(requestDeleteSelectedTeam())); - GBTlayout->addWidget(BtnDeleteTeam, 0, 3); + { + IconedGroupBox* groupMisc = new IconedGroupBox(this); + //groupMisc->setContentTopPadding(0); + groupMisc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + groupMisc->setIcon(QIcon(":/res/miscicon.png")); + //groupMisc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + groupMisc->setTitle(QGroupBox::tr("Misc")); + QGridLayout * MiscLayout = new QGridLayout(groupMisc); + + labelNN = new QLabel(groupMisc); + labelNN->setText(QLabel::tr("Net nick")); + MiscLayout->addWidget(labelNN, 0, 0); + + editNetNick = new QLineEdit(groupMisc); + editNetNick->setMaxLength(20); + editNetNick->setText(QLineEdit::tr("unnamed")); + connect(editNetNick, SIGNAL(editingFinished()), this, SLOT(trimNetNick())); + MiscLayout->addWidget(editNetNick, 0, 1); - LblNoEditTeam = new QLabel(teamsBox); - LblNoEditTeam->setText(tr("You can't edit teams from team selection. Go back to main menu to add, edit or delete teams.")); - LblNoEditTeam->setWordWrap(true); - LblNoEditTeam->setVisible(false); - GBTlayout->addWidget(LblNoEditTeam, 0, 0); + labelNetPassword = new QLabel(groupMisc); + labelNetPassword->setText(QLabel::tr("Password")); + MiscLayout->addWidget(labelNetPassword, 1, 0); + + editNetPassword = new QLineEdit(groupMisc); + editNetPassword->setEchoMode(QLineEdit::Password); + MiscLayout->addWidget(editNetPassword, 1, 1); + + QLabel *labelLanguage = new QLabel(groupMisc); + labelLanguage->setText(QLabel::tr("Locale") + " *"); + MiscLayout->addWidget(labelLanguage, 2, 0); - gbTBLayout->addWidget(teamsBox, 0, 0); + CBLanguage = new QComboBox(groupMisc); + QDir tmpdir; + tmpdir.cd(cfgdir->absolutePath()); + tmpdir.cd("Data/Locale"); + tmpdir.setFilter(QDir::Files); + QStringList locs = tmpdir.entryList(QStringList("hedgewars_*.qm")); + CBLanguage->addItem(QComboBox::tr("(System default)"), QString("")); + for(int i = 0; i < locs.count(); i++) + { + QLocale loc(locs[i].replace(QRegExp("hedgewars_(.*)\\.qm"), "\\1")); + CBLanguage->addItem(QLocale::languageToString(loc.language()) + " (" + QLocale::countryToString(loc.country()) + ")", loc.name()); } + tmpdir.cd(datadir->absolutePath()); + tmpdir.cd("Locale"); + tmpdir.setFilter(QDir::Files); + QStringList tmplist = tmpdir.entryList(QStringList("hedgewars_*.qm")); + for(int i = 0; i < tmplist.count(); i++) { - IconedGroupBox* groupWeapons = new IconedGroupBox(this); - - //groupWeapons->setContentTopPadding(0); - //groupWeapons->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - groupWeapons->setIcon(QIcon(":/res/weaponsicon.png")); - groupWeapons->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - groupWeapons->setTitle(QGroupBox::tr("Schemes and Weapons")); - QGridLayout * WeaponsLayout = new QGridLayout(groupWeapons); - - QLabel* SchemeLabel = new QLabel(groupWeapons); - SchemeLabel->setText(QLabel::tr("Game scheme")); - WeaponsLayout->addWidget(SchemeLabel, 1, 0); - - SchemesName = new QComboBox(groupWeapons); - WeaponsLayout->addWidget(SchemesName, 1, 1); - - SchemeNew = new QPushButton(groupWeapons); - SchemeNew->setToolTip(tr("New scheme")); - SchemeNew->setIconSize(pmNew.size()); - SchemeNew->setIcon(pmNew); - SchemeNew->setMaximumWidth(pmNew.width() + 6); - WeaponsLayout->addWidget(SchemeNew, 1, 2); - - SchemeEdit = new QPushButton(groupWeapons); - SchemeEdit->setToolTip(tr("Edit scheme")); - SchemeEdit->setIconSize(pmEdit.size()); - SchemeEdit->setIcon(pmEdit); - SchemeEdit->setMaximumWidth(pmEdit.width() + 6); - WeaponsLayout->addWidget(SchemeEdit, 1, 3); - - SchemeDelete = new QPushButton(groupWeapons); - SchemeDelete->setToolTip(tr("Delete scheme")); - SchemeDelete->setIconSize(pmDelete.size()); - SchemeDelete->setIcon(pmDelete); - SchemeDelete->setMaximumWidth(pmDelete.width() + 6); - WeaponsLayout->addWidget(SchemeDelete, 1, 4); - - QLabel* WeaponLabel = new QLabel(groupWeapons); - WeaponLabel->setText(QLabel::tr("Weapons")); - WeaponsLayout->addWidget(WeaponLabel, 2, 0); - - WeaponsName = new QComboBox(groupWeapons); - WeaponsLayout->addWidget(WeaponsName, 2, 1); - - WeaponNew = new QPushButton(groupWeapons); - WeaponNew->setToolTip(tr("New weapon set")); - WeaponNew->setIconSize(pmNew.size()); - WeaponNew->setIcon(pmNew); - WeaponNew->setMaximumWidth(pmNew.width() + 6); - WeaponsLayout->addWidget(WeaponNew, 2, 2); - - WeaponEdit = new QPushButton(groupWeapons); - WeaponEdit->setToolTip(tr("Edit weapon set")); - WeaponEdit->setIconSize(pmEdit.size()); - WeaponEdit->setIcon(pmEdit); - WeaponEdit->setMaximumWidth(pmEdit.width() + 6); - WeaponsLayout->addWidget(WeaponEdit, 2, 3); - - WeaponDelete = new QPushButton(groupWeapons); - WeaponDelete->setToolTip(tr("Delete weapon set")); - WeaponDelete->setIconSize(pmDelete.size()); - WeaponDelete->setIcon(pmDelete); - WeaponDelete->setMaximumWidth(pmDelete.width() + 6); - WeaponsLayout->addWidget(WeaponDelete, 2, 4); - - WeaponTooltip = new QCheckBox(this); - WeaponTooltip->setText(QCheckBox::tr("Show ammo menu tooltips")); - WeaponsLayout->addWidget(WeaponTooltip, 3, 0, 1, 4); - - gbTBLayout->addWidget(groupWeapons, 1, 0); + if (locs.contains(tmplist[i])) continue; + QLocale loc(tmplist[i].replace(QRegExp("hedgewars_(.*)\\.qm"), "\\1")); + CBLanguage->addItem(QLocale::languageToString(loc.language()) + " (" + QLocale::countryToString(loc.country()) + ")", loc.name()); } - { - IconedGroupBox* groupMisc = new IconedGroupBox(this); - //groupMisc->setContentTopPadding(0); - groupMisc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - groupMisc->setIcon(QIcon(":/res/miscicon.png")); - //groupMisc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - groupMisc->setTitle(QGroupBox::tr("Misc")); - QGridLayout * MiscLayout = new QGridLayout(groupMisc); - - labelNN = new QLabel(groupMisc); - labelNN->setText(QLabel::tr("Net nick")); - MiscLayout->addWidget(labelNN, 0, 0); + MiscLayout->addWidget(CBLanguage, 2, 1); - editNetNick = new QLineEdit(groupMisc); - editNetNick->setMaxLength(20); - editNetNick->setText(QLineEdit::tr("unnamed")); - connect(editNetNick, SIGNAL(editingFinished()), this, SLOT(trimNetNick())); - MiscLayout->addWidget(editNetNick, 0, 1); - - labelNetPassword = new QLabel(groupMisc); - labelNetPassword->setText(QLabel::tr("Password")); - MiscLayout->addWidget(labelNetPassword, 1, 0); - - editNetPassword = new QLineEdit(groupMisc); - editNetPassword->setEchoMode(QLineEdit::Password); - MiscLayout->addWidget(editNetPassword, 1, 1); - - QLabel *labelLanguage = new QLabel(groupMisc); - labelLanguage->setText(QLabel::tr("Locale") + " *"); - MiscLayout->addWidget(labelLanguage, 2, 0); + CBAltDamage = new QCheckBox(groupMisc); + CBAltDamage->setText(QCheckBox::tr("Alternative damage show")); + MiscLayout->addWidget(CBAltDamage, 3, 0, 1, 2); - CBLanguage = new QComboBox(groupMisc); - QDir tmpdir; - tmpdir.cd(cfgdir->absolutePath()); - tmpdir.cd("Data/Locale"); - tmpdir.setFilter(QDir::Files); - QStringList locs = tmpdir.entryList(QStringList("hedgewars_*.qm")); - CBLanguage->addItem(QComboBox::tr("(System default)"), QString("")); - for(int i = 0; i < locs.count(); i++) - { - QLocale loc(locs[i].replace(QRegExp("hedgewars_(.*)\\.qm"), "\\1")); - CBLanguage->addItem(QLocale::languageToString(loc.language()) + " (" + QLocale::countryToString(loc.country()) + ")", loc.name()); - } + CBNameWithDate = new QCheckBox(groupMisc); + CBNameWithDate->setText(QCheckBox::tr("Append date and time to record file name")); + MiscLayout->addWidget(CBNameWithDate, 4, 0, 1, 2); - tmpdir.cd(datadir->absolutePath()); - tmpdir.cd("Locale"); - tmpdir.setFilter(QDir::Files); - QStringList tmplist = tmpdir.entryList(QStringList("hedgewars_*.qm")); - for(int i = 0; i < tmplist.count(); i++) - { - if (locs.contains(tmplist[i])) continue; - QLocale loc(tmplist[i].replace(QRegExp("hedgewars_(.*)\\.qm"), "\\1")); - CBLanguage->addItem(QLocale::languageToString(loc.language()) + " (" + QLocale::countryToString(loc.country()) + ")", loc.name()); - } - - MiscLayout->addWidget(CBLanguage, 2, 1); - - CBAltDamage = new QCheckBox(groupMisc); - CBAltDamage->setText(QCheckBox::tr("Alternative damage show")); - MiscLayout->addWidget(CBAltDamage, 3, 0, 1, 2); - - CBNameWithDate = new QCheckBox(groupMisc); - CBNameWithDate->setText(QCheckBox::tr("Append date and time to record file name")); - MiscLayout->addWidget(CBNameWithDate, 4, 0, 1, 2); - - BtnAssociateFiles = new QPushButton(groupMisc); - BtnAssociateFiles->setText(QPushButton::tr("Associate file extensions")); - BtnAssociateFiles->setEnabled(!custom_data && !custom_config); - MiscLayout->addWidget(BtnAssociateFiles, 5, 0, 1, 2); + BtnAssociateFiles = new QPushButton(groupMisc); + BtnAssociateFiles->setText(QPushButton::tr("Associate file extensions")); + BtnAssociateFiles->setEnabled(!custom_data && !custom_config); + MiscLayout->addWidget(BtnAssociateFiles, 5, 0, 1, 2); #ifdef __APPLE__ #ifdef SPARKLE_ENABLED - CBAutoUpdate = new QCheckBox(groupMisc); - CBAutoUpdate->setText(QCheckBox::tr("Check for updates at startup")); - MiscLayout->addWidget(CBAutoUpdate, 6, 0, 1, 3); + CBAutoUpdate = new QCheckBox(groupMisc); + CBAutoUpdate->setText(QCheckBox::tr("Check for updates at startup")); + MiscLayout->addWidget(CBAutoUpdate, 6, 0, 1, 3); #endif #endif - gbTBLayout->addWidget(groupMisc, 2, 0); - } + gbTBLayout->addWidget(groupMisc, 2, 0); + } - { - AGGroupBox = new IconedGroupBox(this); - //AGGroupBox->setContentTopPadding(0); - AGGroupBox->setIcon(QIcon(":/res/graphicsicon.png")); - //AGGroupBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); - AGGroupBox->setTitle(QGroupBox::tr("Audio/Graphic options")); + { + AGGroupBox = new IconedGroupBox(this); + //AGGroupBox->setContentTopPadding(0); + AGGroupBox->setIcon(QIcon(":/res/graphicsicon.png")); + //AGGroupBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); + AGGroupBox->setTitle(QGroupBox::tr("Audio/Graphic options")); - QVBoxLayout * GBAlayout = new QVBoxLayout(AGGroupBox); - QHBoxLayout * GBAreslayout = new QHBoxLayout(0); - QHBoxLayout * GBAstereolayout = new QHBoxLayout(0); - QHBoxLayout * GBAqualayout = new QHBoxLayout(0); + QVBoxLayout * GBAlayout = new QVBoxLayout(AGGroupBox); + QHBoxLayout * GBAreslayout = new QHBoxLayout(0); + QHBoxLayout * GBAstereolayout = new QHBoxLayout(0); + QHBoxLayout * GBAqualayout = new QHBoxLayout(0); - CBFrontendFullscreen = new QCheckBox(AGGroupBox); - CBFrontendFullscreen->setText(QCheckBox::tr("Frontend fullscreen")); - GBAlayout->addWidget(CBFrontendFullscreen); + CBFrontendFullscreen = new QCheckBox(AGGroupBox); + CBFrontendFullscreen->setText(QCheckBox::tr("Frontend fullscreen")); + GBAlayout->addWidget(CBFrontendFullscreen); - CBFrontendEffects = new QCheckBox(AGGroupBox); - CBFrontendEffects->setText(QCheckBox::tr("Frontend effects")); - GBAlayout->addWidget(CBFrontendEffects); + CBFrontendEffects = new QCheckBox(AGGroupBox); + CBFrontendEffects->setText(QCheckBox::tr("Frontend effects")); + GBAlayout->addWidget(CBFrontendEffects); - CBEnableFrontendSound = new QCheckBox(AGGroupBox); - CBEnableFrontendSound->setText(QCheckBox::tr("Enable frontend sounds")); - GBAlayout->addWidget(CBEnableFrontendSound); + CBEnableFrontendSound = new QCheckBox(AGGroupBox); + CBEnableFrontendSound->setText(QCheckBox::tr("Enable frontend sounds")); + GBAlayout->addWidget(CBEnableFrontendSound); - CBEnableFrontendMusic = new QCheckBox(AGGroupBox); - CBEnableFrontendMusic->setText(QCheckBox::tr("Enable frontend music")); - GBAlayout->addWidget(CBEnableFrontendMusic); + CBEnableFrontendMusic = new QCheckBox(AGGroupBox); + CBEnableFrontendMusic->setText(QCheckBox::tr("Enable frontend music")); + GBAlayout->addWidget(CBEnableFrontendMusic); - QFrame * hr = new QFrame(AGGroupBox); - hr->setFrameStyle(QFrame::HLine); - hr->setLineWidth(3); - hr->setFixedHeight(10); - GBAlayout->addWidget(hr); + QFrame * hr = new QFrame(AGGroupBox); + hr->setFrameStyle(QFrame::HLine); + hr->setLineWidth(3); + hr->setFixedHeight(10); + GBAlayout->addWidget(hr); - QLabel * resolution = new QLabel(AGGroupBox); - resolution->setText(QLabel::tr("Resolution")); - GBAreslayout->addWidget(resolution); + QLabel * resolution = new QLabel(AGGroupBox); + resolution->setText(QLabel::tr("Resolution")); + GBAreslayout->addWidget(resolution); - CBResolution = new QComboBox(AGGroupBox); - GBAreslayout->addWidget(CBResolution); - GBAlayout->addLayout(GBAreslayout); + CBResolution = new QComboBox(AGGroupBox); + GBAreslayout->addWidget(CBResolution); + GBAlayout->addLayout(GBAreslayout); - CBFullscreen = new QCheckBox(AGGroupBox); - CBFullscreen->setText(QCheckBox::tr("Fullscreen")); - GBAlayout->addWidget(CBFullscreen); + CBFullscreen = new QCheckBox(AGGroupBox); + CBFullscreen->setText(QCheckBox::tr("Fullscreen")); + GBAlayout->addWidget(CBFullscreen); + + QLabel * quality = new QLabel(AGGroupBox); + quality->setText(QLabel::tr("Quality")); + quality->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + GBAqualayout->addWidget(quality); - QLabel * quality = new QLabel(AGGroupBox); - quality->setText(QLabel::tr("Quality")); - quality->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - GBAqualayout->addWidget(quality); - - SLQuality = new QSlider(Qt::Horizontal, AGGroupBox); - SLQuality->setTickPosition(QSlider::TicksBelow); - SLQuality->setMaximum(5); - SLQuality->setMinimum(0); - SLQuality->setFixedWidth(150); - GBAqualayout->addWidget(SLQuality); - GBAlayout->addLayout(GBAqualayout); + SLQuality = new QSlider(Qt::Horizontal, AGGroupBox); + SLQuality->setTickPosition(QSlider::TicksBelow); + SLQuality->setMaximum(5); + SLQuality->setMinimum(0); + SLQuality->setFixedWidth(150); + GBAqualayout->addWidget(SLQuality); + GBAlayout->addLayout(GBAqualayout); - QLabel * stereo = new QLabel(AGGroupBox); - stereo->setText(QLabel::tr("Stereo rendering")); - GBAstereolayout->addWidget(stereo); + QLabel * stereo = new QLabel(AGGroupBox); + stereo->setText(QLabel::tr("Stereo rendering")); + GBAstereolayout->addWidget(stereo); - CBStereoMode = new QComboBox(AGGroupBox); - CBStereoMode->addItem(QComboBox::tr("Disabled")); - CBStereoMode->addItem(QComboBox::tr("Red/Cyan")); - CBStereoMode->addItem(QComboBox::tr("Cyan/Red")); - CBStereoMode->addItem(QComboBox::tr("Red/Blue")); - CBStereoMode->addItem(QComboBox::tr("Blue/Red")); - CBStereoMode->addItem(QComboBox::tr("Red/Green")); - CBStereoMode->addItem(QComboBox::tr("Green/Red")); - CBStereoMode->addItem(QComboBox::tr("Side-by-side")); - CBStereoMode->addItem(QComboBox::tr("Top-Bottom")); - CBStereoMode->addItem(QComboBox::tr("Wiggle")); - CBStereoMode->addItem(QComboBox::tr("Red/Cyan grayscale")); - CBStereoMode->addItem(QComboBox::tr("Cyan/Red grayscale")); - CBStereoMode->addItem(QComboBox::tr("Red/Blue grayscale")); - CBStereoMode->addItem(QComboBox::tr("Blue/Red grayscale")); - CBStereoMode->addItem(QComboBox::tr("Red/Green grayscale")); - CBStereoMode->addItem(QComboBox::tr("Green/Red grayscale")); - connect(CBStereoMode, SIGNAL(currentIndexChanged(int)), this, SLOT(forceFullscreen(int))); + CBStereoMode = new QComboBox(AGGroupBox); + CBStereoMode->addItem(QComboBox::tr("Disabled")); + CBStereoMode->addItem(QComboBox::tr("Red/Cyan")); + CBStereoMode->addItem(QComboBox::tr("Cyan/Red")); + CBStereoMode->addItem(QComboBox::tr("Red/Blue")); + CBStereoMode->addItem(QComboBox::tr("Blue/Red")); + CBStereoMode->addItem(QComboBox::tr("Red/Green")); + CBStereoMode->addItem(QComboBox::tr("Green/Red")); + CBStereoMode->addItem(QComboBox::tr("Side-by-side")); + CBStereoMode->addItem(QComboBox::tr("Top-Bottom")); + CBStereoMode->addItem(QComboBox::tr("Wiggle")); + CBStereoMode->addItem(QComboBox::tr("Red/Cyan grayscale")); + CBStereoMode->addItem(QComboBox::tr("Cyan/Red grayscale")); + CBStereoMode->addItem(QComboBox::tr("Red/Blue grayscale")); + CBStereoMode->addItem(QComboBox::tr("Blue/Red grayscale")); + CBStereoMode->addItem(QComboBox::tr("Red/Green grayscale")); + CBStereoMode->addItem(QComboBox::tr("Green/Red grayscale")); + connect(CBStereoMode, SIGNAL(currentIndexChanged(int)), this, SLOT(forceFullscreen(int))); - GBAstereolayout->addWidget(CBStereoMode); - GBAlayout->addLayout(GBAstereolayout); + GBAstereolayout->addWidget(CBStereoMode); + GBAlayout->addLayout(GBAstereolayout); - hr = new QFrame(AGGroupBox); - hr->setFrameStyle(QFrame::HLine); - hr->setLineWidth(3); - hr->setFixedHeight(10); - GBAlayout->addWidget(hr); + hr = new QFrame(AGGroupBox); + hr->setFrameStyle(QFrame::HLine); + hr->setLineWidth(3); + hr->setFixedHeight(10); + GBAlayout->addWidget(hr); - QHBoxLayout * GBAvollayout = new QHBoxLayout(0); - QLabel * vol = new QLabel(AGGroupBox); - vol->setText(QLabel::tr("Initial sound volume")); - GBAvollayout->addWidget(vol); - GBAlayout->addLayout(GBAvollayout); - volumeBox = new QSpinBox(AGGroupBox); - volumeBox->setRange(0, 100); - volumeBox->setSingleStep(5); - GBAvollayout->addWidget(volumeBox); + QHBoxLayout * GBAvollayout = new QHBoxLayout(0); + QLabel * vol = new QLabel(AGGroupBox); + vol->setText(QLabel::tr("Initial sound volume")); + GBAvollayout->addWidget(vol); + GBAlayout->addLayout(GBAvollayout); + volumeBox = new QSpinBox(AGGroupBox); + volumeBox->setRange(0, 100); + volumeBox->setSingleStep(5); + GBAvollayout->addWidget(volumeBox); - CBEnableSound = new QCheckBox(AGGroupBox); - CBEnableSound->setText(QCheckBox::tr("Enable sound")); - GBAlayout->addWidget(CBEnableSound); + CBEnableSound = new QCheckBox(AGGroupBox); + CBEnableSound->setText(QCheckBox::tr("Enable sound")); + GBAlayout->addWidget(CBEnableSound); - CBEnableMusic = new QCheckBox(AGGroupBox); - CBEnableMusic->setText(QCheckBox::tr("Enable music")); - GBAlayout->addWidget(CBEnableMusic); + CBEnableMusic = new QCheckBox(AGGroupBox); + CBEnableMusic->setText(QCheckBox::tr("Enable music")); + GBAlayout->addWidget(CBEnableMusic); - hr = new QFrame(AGGroupBox); - hr->setFrameStyle(QFrame::HLine); - hr->setLineWidth(3); - hr->setFixedHeight(10); - GBAlayout->addWidget(hr); + hr = new QFrame(AGGroupBox); + hr->setFrameStyle(QFrame::HLine); + hr->setLineWidth(3); + hr->setFixedHeight(10); + GBAlayout->addWidget(hr); - QHBoxLayout * GBAfpslayout = new QHBoxLayout(0); - QLabel * maxfps = new QLabel(AGGroupBox); - maxfps->setText(QLabel::tr("FPS limit")); - GBAfpslayout->addWidget(maxfps); - GBAlayout->addLayout(GBAfpslayout); - fpsedit = new FPSEdit(AGGroupBox); - GBAfpslayout->addWidget(fpsedit); + QHBoxLayout * GBAfpslayout = new QHBoxLayout(0); + QLabel * maxfps = new QLabel(AGGroupBox); + maxfps->setText(QLabel::tr("FPS limit")); + GBAfpslayout->addWidget(maxfps); + GBAlayout->addLayout(GBAfpslayout); + fpsedit = new FPSEdit(AGGroupBox); + GBAfpslayout->addWidget(fpsedit); - CBShowFPS = new QCheckBox(AGGroupBox); - CBShowFPS->setText(QCheckBox::tr("Show FPS")); - GBAlayout->addWidget(CBShowFPS); + CBShowFPS = new QCheckBox(AGGroupBox); + CBShowFPS->setText(QCheckBox::tr("Show FPS")); + GBAlayout->addWidget(CBShowFPS); - gbTBLayout->addWidget(AGGroupBox, 0, 1, 3, 1); - } + gbTBLayout->addWidget(AGGroupBox, 0, 1, 3, 1); + } previousQuality = this->SLQuality->value(); previousResolutionIndex = this->CBResolution->currentIndex(); @@ -416,13 +416,16 @@ { bool forced = (index == 7 || index == 8 || index == 9); - if (index != 0) { + if (index != 0) + { this->SLQuality->setValue(this->SLQuality->maximum()); this->SLQuality->setEnabled(false); this->CBFullscreen->setEnabled(!forced); this->CBFullscreen->setChecked(forced ? true : previousFullscreenValue); this->CBResolution->setCurrentIndex(forced ? 0 : previousResolutionIndex); - } else { + } + else + { this->SLQuality->setEnabled(true); this->CBFullscreen->setEnabled(true); this->SLQuality->setValue(previousQuality); diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pageoptions.h --- a/QTfrontend/ui/page/pageoptions.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pageoptions.h Mon Jan 30 17:32:18 2012 -0500 @@ -26,80 +26,80 @@ class PageOptions : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageOptions(QWidget* parent = 0); + public: + PageOptions(QWidget* parent = 0); - QCheckBox *WeaponTooltip; - QPushButton *WeaponNew; - QPushButton *WeaponEdit; - QPushButton *WeaponDelete; - QComboBox *WeaponsName; - QPushButton *SchemeNew; - QPushButton *SchemeEdit; - QPushButton *SchemeDelete; - QComboBox *SchemesName; + QCheckBox *WeaponTooltip; + QPushButton *WeaponNew; + QPushButton *WeaponEdit; + QPushButton *WeaponDelete; + QComboBox *WeaponsName; + QPushButton *SchemeNew; + QPushButton *SchemeEdit; + QPushButton *SchemeDelete; + QComboBox *SchemesName; - QComboBox *CBLanguage; + QComboBox *CBLanguage; - IconedGroupBox *teamsBox;; - QPushButton *BtnAssociateFiles; - QComboBox *CBTeamName; - IconedGroupBox *AGGroupBox; - QComboBox *CBResolution; - QComboBox *CBStereoMode; - QCheckBox *CBEnableSound; - QCheckBox *CBEnableFrontendSound; - QCheckBox *CBEnableMusic; - QCheckBox *CBEnableFrontendMusic; - QCheckBox *CBFullscreen; - QCheckBox *CBFrontendFullscreen; - QCheckBox *CBShowFPS; - QCheckBox *CBAltDamage; - QCheckBox *CBNameWithDate; + IconedGroupBox *teamsBox;; + QPushButton *BtnAssociateFiles; + QComboBox *CBTeamName; + IconedGroupBox *AGGroupBox; + QComboBox *CBResolution; + QComboBox *CBStereoMode; + QCheckBox *CBEnableSound; + QCheckBox *CBEnableFrontendSound; + QCheckBox *CBEnableMusic; + QCheckBox *CBEnableFrontendMusic; + QCheckBox *CBFullscreen; + QCheckBox *CBFrontendFullscreen; + QCheckBox *CBShowFPS; + QCheckBox *CBAltDamage; + QCheckBox *CBNameWithDate; #ifdef __APPLE__ - QCheckBox *CBAutoUpdate; + QCheckBox *CBAutoUpdate; #endif - FPSEdit *fpsedit; - QLabel *labelNN; - QLabel *labelNetPassword; - QSpinBox * volumeBox; - QLineEdit *editNetNick; - QLineEdit *editNetPassword; - QSlider *SLQuality; - QCheckBox *CBFrontendEffects; + FPSEdit *fpsedit; + QLabel *labelNN; + QLabel *labelNetPassword; + QSpinBox * volumeBox; + QLineEdit *editNetNick; + QLineEdit *editNetPassword; + QSlider *SLQuality; + QCheckBox *CBFrontendEffects; - void setTeamOptionsEnabled(bool enabled); + void setTeamOptionsEnabled(bool enabled); -signals: - void newTeamRequested(); - void editTeamRequested(const QString & teamName); - void deleteTeamRequested(const QString & teamName); + signals: + void newTeamRequested(); + void editTeamRequested(const QString & teamName); + void deleteTeamRequested(const QString & teamName); -private: - QLayout * bodyLayoutDefinition(); - QLayout * footerLayoutDefinition(); - void connectSignals(); + private: + QLayout * bodyLayoutDefinition(); + QLayout * footerLayoutDefinition(); + void connectSignals(); - bool previousFullscreenValue; - int previousResolutionIndex; - int previousQuality; - QLabel *LblNoEditTeam; - QPushButton *BtnNewTeam; - QPushButton *BtnEditTeam; - QPushButton *BtnDeleteTeam; + bool previousFullscreenValue; + int previousResolutionIndex; + int previousQuality; + QLabel *LblNoEditTeam; + QPushButton *BtnNewTeam; + QPushButton *BtnEditTeam; + QPushButton *BtnDeleteTeam; -private slots: - void forceFullscreen(int index); - void setFullscreen(int state); - void setResolution(int state); - void setQuality(int value); - void trimNetNick(); - void requestEditSelectedTeam(); - void requestDeleteSelectedTeam(); + private slots: + void forceFullscreen(int index); + void setFullscreen(int state); + void setResolution(int state); + void setQuality(int value); + void trimNetNick(); + void requestEditSelectedTeam(); + void requestDeleteSelectedTeam(); }; #endif diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pageplayrecord.cpp --- a/QTfrontend/ui/page/pageplayrecord.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pageplayrecord.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -31,7 +31,7 @@ QLayout * PagePlayDemo::bodyLayoutDefinition() { QGridLayout * pageLayout = new QGridLayout(); - + pageLayout->setColumnStretch(0, 1); pageLayout->setColumnStretch(1, 2); pageLayout->setColumnStretch(2, 1); @@ -81,7 +81,8 @@ dir.cd("Demos"); extension = "hwd"; BtnPlayDemo->setText(QPushButton::tr("Play demo")); - } else + } + else { dir.cd("Saves"); extension = "hws"; @@ -108,9 +109,9 @@ if (!curritem) { QMessageBox::critical(this, - tr("Error"), - tr("Please select record from the list"), - tr("OK")); + tr("Error"), + tr("Please select record from the list"), + tr("OK")); return ; } QFile rfile(curritem->data(Qt::UserRole).toString()); @@ -124,10 +125,10 @@ if(ok && newname.size()) { QString newfullname = QString("%1/%2.%3.%4") - .arg(finfo.absolutePath()) - .arg(newname) - .arg(*cProtoVer) - .arg(finfo.suffix()); + .arg(finfo.absolutePath()) + .arg(newname) + .arg(*cProtoVer) + .arg(finfo.suffix()); ok = rfile.rename(newfullname); if(!ok) @@ -143,9 +144,9 @@ if (!curritem) { QMessageBox::critical(this, - tr("Error"), - tr("Please select record from the list"), - tr("OK")); + tr("Error"), + tr("Please select record from the list"), + tr("OK")); return ; } QFile rfile(curritem->data(Qt::UserRole).toString()); diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pageplayrecord.h --- a/QTfrontend/ui/page/pageplayrecord.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pageplayrecord.h Mon Jan 30 17:32:18 2012 -0500 @@ -28,33 +28,34 @@ class PagePlayDemo : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - enum RecordType { - RT_Demo, - RT_Save - }; + public: + enum RecordType + { + RT_Demo, + RT_Save + }; - PagePlayDemo(QWidget* parent = 0); + PagePlayDemo(QWidget* parent = 0); - void FillFromDir(RecordType rectype); - bool isSave(); + void FillFromDir(RecordType rectype); + bool isSave(); - QPushButton *BtnPlayDemo; - QPushButton *BtnRenameRecord; - QPushButton *BtnRemoveRecord; - QListWidget *DemosList; + QPushButton *BtnPlayDemo; + QPushButton *BtnRenameRecord; + QPushButton *BtnRemoveRecord; + QListWidget *DemosList; -private: - QLayout * bodyLayoutDefinition(); - void connectSignals(); + private: + QLayout * bodyLayoutDefinition(); + void connectSignals(); - RecordType recType; + RecordType recType; -private slots: - void renameRecord(); - void removeRecord(); + private slots: + void renameRecord(); + void removeRecord(); }; diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pageroomslist.cpp --- a/QTfrontend/ui/page/pageroomslist.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pageroomslist.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -148,7 +148,7 @@ PageRoomsList::PageRoomsList(QWidget* parent, QSettings * gameSettings) : - AbstractPage(parent) + AbstractPage(parent) { m_gameSettings = gameSettings; @@ -160,7 +160,8 @@ CBRules->addItem(ammoSchemeModel->predefSchemesNames.at(i).toAscii().constData()); CBWeapons->addItem(QComboBox::tr("Any")); - for (int i = 0; i < cDefaultAmmos.count(); i++) { + for (int i = 0; i < cDefaultAmmos.count(); i++) + { QPair ammo = cDefaultAmmos.at(i); CBWeapons->addItem(ammo.first.toAscii().constData()); } @@ -199,24 +200,24 @@ QBrush green(QColor(0, 255, 0)); listFromServer = list; - + QString selection = ""; - + if(QTableWidgetItem *item = roomsList->item(roomsList->currentRow(), 0)) selection = item->text(); - + roomsList->clear(); roomsList->setColumnCount(7); roomsList->setHorizontalHeaderLabels( - QStringList() << - QTableWidget::tr("Room Name") << - QTableWidget::tr("C") << - QTableWidget::tr("T") << - QTableWidget::tr("Owner") << - QTableWidget::tr("Map") << - QTableWidget::tr("Rules") << - QTableWidget::tr("Weapons") - ); + QStringList() << + QTableWidget::tr("Room Name") << + QTableWidget::tr("C") << + QTableWidget::tr("T") << + QTableWidget::tr("Owner") << + QTableWidget::tr("Map") << + QTableWidget::tr("Rules") << + QTableWidget::tr("Weapons") + ); // set minimum sizes // roomsList->horizontalHeader()->resizeSection(0, 200); @@ -240,42 +241,67 @@ { // if we are joining a game // TODO: Should NOT be done here - if (gameInLobby) { - if (gameInLobbyName == list[i + 1]) { + if (gameInLobby) + { + if (gameInLobbyName == list[i + 1]) + { gameCanBeJoined = list[i].compare("True"); } } - + // check filter settings - #define NO_FILTER_MATCH roomsList->setRowCount(roomsList->rowCount() - 1); --r; continue - - if (list[i].compare("True") && CBState->currentIndex() == 2) { NO_FILTER_MATCH; } - if (list[i].compare("False") && CBState->currentIndex() == 1) { NO_FILTER_MATCH; } - if (CBRules->currentIndex() != 0 && list[i + 6].compare(CBRules->currentText())) { NO_FILTER_MATCH; } - if (CBWeapons->currentIndex() != 0 && list[i + 7].compare(CBWeapons->currentText())) { NO_FILTER_MATCH; } +#define NO_FILTER_MATCH roomsList->setRowCount(roomsList->rowCount() - 1); --r; continue + + if (list[i].compare("True") && CBState->currentIndex() == 2) + { + NO_FILTER_MATCH; + } + if (list[i].compare("False") && CBState->currentIndex() == 1) + { + NO_FILTER_MATCH; + } + if (CBRules->currentIndex() != 0 && list[i + 6].compare(CBRules->currentText())) + { + NO_FILTER_MATCH; + } + if (CBWeapons->currentIndex() != 0 && list[i + 7].compare(CBWeapons->currentText())) + { + NO_FILTER_MATCH; + } bool found = list[i + 1].contains(searchText->text(), Qt::CaseInsensitive); - if (!found) { - for (int a = 4; a <= 7; ++a) { + if (!found) + { + for (int a = 4; a <= 7; ++a) + { QString compString = list[i + a]; - if (a == 5 && compString == "+rnd+") { + if (a == 5 && compString == "+rnd+") + { compString = "Random Map"; - } else if (a == 5 && compString == "+maze+") { + } + else if (a == 5 && compString == "+maze+") + { compString = "Random Maze"; - } else if (a == 5 && compString == "+drawn+") { + } + else if (a == 5 && compString == "+drawn+") + { compString = "Drawn Map"; } - if (compString.contains(searchText->text(), Qt::CaseInsensitive)) { + if (compString.contains(searchText->text(), Qt::CaseInsensitive)) + { found = true; break; } } } - if (!searchText->text().isEmpty() && !found) { NO_FILTER_MATCH; } - + if (!searchText->text().isEmpty() && !found) + { + NO_FILTER_MATCH; + } + QTableWidgetItem * item; item = new QTableWidgetItem(list[i + 1]); // room name item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); - + // pick appropriate room icon and tooltip (game in progress yes/no; later maybe locked rooms etc.) if(list[i].compare("True")) { @@ -325,7 +351,7 @@ else { item = new QTableWidgetItem(list[i + 5]); // selected map - + // check to see if we've got this map // not perfect but a start if(!mapList->contains(list[i + 5])) @@ -335,12 +361,12 @@ } else { - // todo: mission icon? + // todo: mission icon? // FIXME - need real icons. Disabling until then // item->setIcon(QIcon(":/res/mapCustom.png")); } } - + item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); item->setToolTip(tr("Games may be played on precreated or randomized maps.")); roomsList->setItem(r, 4, item); @@ -368,11 +394,15 @@ roomsList->horizontalHeader()->setResizeMode(6, QHeaderView::ResizeToContents); // TODO: Should NOT be done here - if (gameInLobby) { + if (gameInLobby) + { gameInLobby = false; - if (gameCanBeJoined) { + if (gameCanBeJoined) + { emit askForJoinRoom(gameInLobbyName); - } else { + } + else + { emit askJoinConfirmation(gameInLobbyName); } } @@ -386,9 +416,9 @@ emit askForCreateRoom(roomName->text()); else QMessageBox::critical(this, - tr("Error"), - tr("Please enter room name"), - tr("OK")); + tr("Error"), + tr("Please enter room name"), + tr("OK")); } void PageRoomsList::onJoinClick() @@ -397,23 +427,28 @@ if (!curritem) { QMessageBox::critical(this, - tr("Error"), - tr("Please select room from the list"), - tr("OK")); + tr("Error"), + tr("Please select room from the list"), + tr("OK")); return; } - for (int i = 0; i < listFromServer.size(); i += 8) { - if (listFromServer[i + 1] == curritem->data(Qt::DisplayRole).toString()) { + for (int i = 0; i < listFromServer.size(); i += 8) + { + if (listFromServer[i + 1] == curritem->data(Qt::DisplayRole).toString()) + { gameInLobby = listFromServer[i].compare("True"); break; } } - - if (gameInLobby) { + + if (gameInLobby) + { gameInLobbyName = curritem->data(Qt::DisplayRole).toString(); emit askForRoomList(); - } else { + } + else + { emit askForJoinRoom(curritem->data(Qt::DisplayRole).toString()); } } @@ -434,9 +469,9 @@ void PageRoomsList::onJoinConfirmation(const QString & room) { if (QMessageBox::warning(this, - tr("Warning"), - tr("The game you are trying to join has started.\nDo you still want to join the room?"), - QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) + tr("Warning"), + tr("The game you are trying to join has started.\nDo you still want to join the room?"), + QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { emit askForJoinRoom(room); } diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pageroomslist.h --- a/QTfrontend/ui/page/pageroomslist.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pageroomslist.h Mon Jan 30 17:32:18 2012 -0500 @@ -26,59 +26,59 @@ class PageRoomsList : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageRoomsList(QWidget* parent, QSettings * config); - void displayError(const QString & message); - void displayNotice(const QString & message); - void displayWarning(const QString & message); + public: + PageRoomsList(QWidget* parent, QSettings * config); + void displayError(const QString & message); + void displayNotice(const QString & message); + void displayWarning(const QString & message); - QLineEdit * roomName; - QLineEdit * searchText; - QTableWidget * roomsList; - QPushButton * BtnCreate; - QPushButton * BtnJoin; - QPushButton * BtnRefresh; - QPushButton * BtnAdmin; - QPushButton * BtnClear; - QComboBox * CBState; - QComboBox * CBRules; - QComboBox * CBWeapons; - HWChatWidget * chatWidget; - QLabel * lblCount; + QLineEdit * roomName; + QLineEdit * searchText; + QTableWidget * roomsList; + QPushButton * BtnCreate; + QPushButton * BtnJoin; + QPushButton * BtnRefresh; + QPushButton * BtnAdmin; + QPushButton * BtnClear; + QComboBox * CBState; + QComboBox * CBRules; + QComboBox * CBWeapons; + HWChatWidget * chatWidget; + QLabel * lblCount; -public slots: - void setAdmin(bool); - void setRoomsList(const QStringList & list); - void setUser(const QString & nickname); - void updateNickCounter(int cnt); + public slots: + void setAdmin(bool); + void setRoomsList(const QStringList & list); + void setUser(const QString & nickname); + void updateNickCounter(int cnt); -signals: - void askForCreateRoom(const QString &); - void askForJoinRoom(const QString &); - void askForRoomList(); - void askJoinConfirmation(const QString &); + signals: + void askForCreateRoom(const QString &); + void askForJoinRoom(const QString &); + void askForRoomList(); + void askJoinConfirmation(const QString &); -protected: - QLayout * bodyLayoutDefinition(); - QLayout * footerLayoutDefinition(); - void connectSignals(); + protected: + QLayout * bodyLayoutDefinition(); + QLayout * footerLayoutDefinition(); + void connectSignals(); -private slots: - void onCreateClick(); - void onJoinClick(); - void onRefreshClick(); - void onClearClick(); - void onJoinConfirmation(const QString &); + private slots: + void onCreateClick(); + void onJoinClick(); + void onRefreshClick(); + void onClearClick(); + void onJoinConfirmation(const QString &); -private: - QSettings * m_gameSettings; + private: + QSettings * m_gameSettings; - bool gameInLobby; - QString gameInLobbyName; - QStringList listFromServer; - AmmoSchemeModel * ammoSchemeModel; + bool gameInLobby; + QString gameInLobbyName; + QStringList listFromServer; + AmmoSchemeModel * ammoSchemeModel; }; diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pagescheme.cpp --- a/QTfrontend/ui/page/pagescheme.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pagescheme.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -50,11 +50,11 @@ // TODO name stuff and put CSS into main style sheet gbGameModes->setStyleSheet(".QGroupBox {" - "background-color: #130f2c; background-image:url();" - "}"); + "background-color: #130f2c; background-image:url();" + "}"); gbBasicSettings->setStyleSheet(".QGroupBox {" - "background-color: #130f2c; background-image:url();" - "}"); + "background-color: #130f2c; background-image:url();" + "}"); gbGameModes->setSizePolicy(sp); gbBasicSettings->setSizePolicy(sp); @@ -381,7 +381,7 @@ SB_GetAwayTime->setValue(100); SB_GetAwayTime->setSingleStep(25); glBSLayout->addWidget(SB_GetAwayTime,14,2,1,1); - + l = new QLabel(gbBasicSettings); l->setText(QLabel::tr("Scheme Name:")); @@ -470,7 +470,7 @@ mapper->addMapping(SB_WaterRise, 37); mapper->addMapping(SB_HealthDecrease, 38); mapper->addMapping(SB_RopeModifier, 39); - mapper->addMapping(SB_GetAwayTime, 40); + mapper->addMapping(SB_GetAwayTime, 40); mapper->toFirst(); } @@ -493,7 +493,8 @@ { QMessageBox reallyDelete(QMessageBox::Question, QMessageBox::tr("Schemes"), QMessageBox::tr("Really delete this game scheme?"), QMessageBox::Ok | QMessageBox::Cancel); - if (reallyDelete.exec() == QMessageBox::Ok) { + if (reallyDelete.exec() == QMessageBox::Ok) + { QAbstractItemModel * model = mapper->model(); model->removeRow(selectScheme->currentIndex()); } diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pagescheme.h --- a/QTfrontend/ui/page/pagescheme.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pagescheme.h Mon Jan 30 17:32:18 2012 -0500 @@ -26,78 +26,78 @@ class PageScheme : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageScheme(QWidget* parent = 0); + public: + PageScheme(QWidget* parent = 0); - QPushButton * BtnCopy; - QPushButton * BtnNew; - QPushButton * BtnDelete; - QComboBox * selectScheme; + QPushButton * BtnCopy; + QPushButton * BtnNew; + QPushButton * BtnDelete; + QComboBox * selectScheme; - void setModel(QAbstractItemModel * model); + void setModel(QAbstractItemModel * model); -public slots: - void newRow(); - void copyRow(); - void deleteRow(); + public slots: + void newRow(); + void copyRow(); + void deleteRow(); -protected: - QLayout * bodyLayoutDefinition(); - QLayout * footerLayoutDefinition(); - void connectSignals(); + protected: + QLayout * bodyLayoutDefinition(); + QLayout * footerLayoutDefinition(); + void connectSignals(); -private: - QDataWidgetMapper * mapper; - ToggleButtonWidget * TBW_mode_Forts; - ToggleButtonWidget * TBW_teamsDivide; - ToggleButtonWidget * TBW_solid; - ToggleButtonWidget * TBW_border; - ToggleButtonWidget * TBW_lowGravity; - ToggleButtonWidget * TBW_laserSight; - ToggleButtonWidget * TBW_invulnerable; - ToggleButtonWidget * TBW_resethealth; - ToggleButtonWidget * TBW_vampiric; - ToggleButtonWidget * TBW_karma; - ToggleButtonWidget * TBW_artillery; - ToggleButtonWidget * TBW_randomorder; - ToggleButtonWidget * TBW_king; - ToggleButtonWidget * TBW_placehog; - ToggleButtonWidget * TBW_sharedammo; - ToggleButtonWidget * TBW_disablegirders; - ToggleButtonWidget * TBW_disablelandobjects; - ToggleButtonWidget * TBW_aisurvival; - ToggleButtonWidget * TBW_infattack; - ToggleButtonWidget * TBW_resetweps; - ToggleButtonWidget * TBW_perhogammo; - ToggleButtonWidget * TBW_nowind; - ToggleButtonWidget * TBW_morewind; - ToggleButtonWidget * TBW_tagteam; - ToggleButtonWidget * TBW_bottomborder; + private: + QDataWidgetMapper * mapper; + ToggleButtonWidget * TBW_mode_Forts; + ToggleButtonWidget * TBW_teamsDivide; + ToggleButtonWidget * TBW_solid; + ToggleButtonWidget * TBW_border; + ToggleButtonWidget * TBW_lowGravity; + ToggleButtonWidget * TBW_laserSight; + ToggleButtonWidget * TBW_invulnerable; + ToggleButtonWidget * TBW_resethealth; + ToggleButtonWidget * TBW_vampiric; + ToggleButtonWidget * TBW_karma; + ToggleButtonWidget * TBW_artillery; + ToggleButtonWidget * TBW_randomorder; + ToggleButtonWidget * TBW_king; + ToggleButtonWidget * TBW_placehog; + ToggleButtonWidget * TBW_sharedammo; + ToggleButtonWidget * TBW_disablegirders; + ToggleButtonWidget * TBW_disablelandobjects; + ToggleButtonWidget * TBW_aisurvival; + ToggleButtonWidget * TBW_infattack; + ToggleButtonWidget * TBW_resetweps; + ToggleButtonWidget * TBW_perhogammo; + ToggleButtonWidget * TBW_nowind; + ToggleButtonWidget * TBW_morewind; + ToggleButtonWidget * TBW_tagteam; + ToggleButtonWidget * TBW_bottomborder; - QSpinBox * SB_DamageModifier; - QSpinBox * SB_TurnTime; - QSpinBox * SB_InitHealth; - QSpinBox * SB_SuddenDeath; - QSpinBox * SB_WaterRise; - QSpinBox * SB_HealthDecrease; - FreqSpinBox * SB_CaseProb; - QSpinBox * SB_HealthCrates; - QSpinBox * SB_CrateHealth; - QSpinBox * SB_MinesTime; - QSpinBox * SB_Mines; - QSpinBox * SB_MineDuds; - QSpinBox * SB_Explosives; - QSpinBox * SB_RopeModifier; - QSpinBox * SB_GetAwayTime; - QLineEdit * LE_name; + QSpinBox * SB_DamageModifier; + QSpinBox * SB_TurnTime; + QSpinBox * SB_InitHealth; + QSpinBox * SB_SuddenDeath; + QSpinBox * SB_WaterRise; + QSpinBox * SB_HealthDecrease; + FreqSpinBox * SB_CaseProb; + QSpinBox * SB_HealthCrates; + QSpinBox * SB_CrateHealth; + QSpinBox * SB_MinesTime; + QSpinBox * SB_Mines; + QSpinBox * SB_MineDuds; + QSpinBox * SB_Explosives; + QSpinBox * SB_RopeModifier; + QSpinBox * SB_GetAwayTime; + QLineEdit * LE_name; - QGroupBox * gbGameModes; - QGroupBox * gbBasicSettings; + QGroupBox * gbGameModes; + QGroupBox * gbBasicSettings; -private slots: - void schemeSelected(int); + private slots: + void schemeSelected(int); }; #endif diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pageselectweapon.h --- a/QTfrontend/ui/page/pageselectweapon.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pageselectweapon.h Mon Jan 30 17:32:18 2012 -0500 @@ -25,22 +25,22 @@ class PageSelectWeapon : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageSelectWeapon(QWidget* parent = 0); + public: + PageSelectWeapon(QWidget* parent = 0); - QPushButton *BtnDefault; - QPushButton *BtnDelete; - QPushButton *BtnNew; - QPushButton *BtnCopy; - SelWeaponWidget* pWeapons; - QComboBox* selectWeaponSet; + QPushButton *BtnDefault; + QPushButton *BtnDelete; + QPushButton *BtnNew; + QPushButton *BtnCopy; + SelWeaponWidget* pWeapons; + QComboBox* selectWeaponSet; -protected: - QLayout * bodyLayoutDefinition(); - QLayout * footerLayoutDefinition(); - void connectSignals(); + protected: + QLayout * bodyLayoutDefinition(); + QLayout * footerLayoutDefinition(); + void connectSignals(); }; #endif diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pagesingleplayer.h --- a/QTfrontend/ui/page/pagesingleplayer.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pagesingleplayer.h Mon Jan 30 17:32:18 2012 -0500 @@ -25,23 +25,23 @@ class PageSinglePlayer : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageSinglePlayer(QWidget* parent = 0); + public: + PageSinglePlayer(QWidget* parent = 0); - QPushButton *BtnSimpleGamePage; - QPushButton *BtnTrainPage; - QPushButton *BtnCampaignPage; - QPushButton *BtnMultiplayer; - QPushButton *BtnLoad; - QPushButton *BtnDemos; - GameCFGWidget *gameCFG; + QPushButton *BtnSimpleGamePage; + QPushButton *BtnTrainPage; + QPushButton *BtnCampaignPage; + QPushButton *BtnMultiplayer; + QPushButton *BtnLoad; + QPushButton *BtnDemos; + GameCFGWidget *gameCFG; -private: - QLayout * bodyLayoutDefinition(); - QLayout * footerLayoutDefinition(); - void connectSignals(); + private: + QLayout * bodyLayoutDefinition(); + QLayout * footerLayoutDefinition(); + void connectSignals(); }; #endif diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pagetraining.cpp --- a/QTfrontend/ui/page/pagetraining.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pagetraining.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -125,12 +125,12 @@ loc = QLocale::system().name(); QString infoFile = dataMgr.findFileForRead( - QString("Locale/missions_" + loc + ".txt")); + QString("Locale/missions_" + loc + ".txt")); // if file is non-existant try with language only if (!QFile::exists(infoFile)) infoFile = dataMgr.findFileForRead(QString( - "Locale/missions_" + loc.remove(QRegExp("_.*$")) + ".txt")); + "Locale/missions_" + loc.remove(QRegExp("_.*$")) + ".txt")); // fallback if file for current locale is non-existant if (!QFile::exists(infoFile)) @@ -145,7 +145,7 @@ QStringList missionList = dataMgr.entryList( "Missions/Training", QDir::Files, QStringList("*.lua")). - replaceInStrings(QRegExp("\\.lua$"), ""); + replaceInStrings(QRegExp("\\.lua$"), ""); // scripts to lost - TODO: model? foreach (const QString & mission, missionList) @@ -191,9 +191,9 @@ { // TODO also use .pngs in userdata folder QString thumbFile = dataMgr.findFileForRead( - "Graphics/Missions/Training/" + - lstMissions->currentItem()->data(Qt::UserRole).toString() + - "@2x.png"); + "Graphics/Missions/Training/" + + lstMissions->currentItem()->data(Qt::UserRole).toString() + + "@2x.png"); if (QFile::exists(thumbFile)) btnPreview->setIcon(QIcon(thumbFile)); @@ -201,13 +201,13 @@ btnPreview->setIcon(QIcon(":/res/Trainings.png")); QString realName = lstMissions->currentItem()->data( - Qt::UserRole).toString(); + Qt::UserRole).toString(); - QString caption = m_info->value(realName + ".name", - lstMissions->currentItem()->text()).toString(); + QString caption = m_info->value(realName + ".name", + lstMissions->currentItem()->text()).toString(); QString description = m_info->value(realName + ".desc", - tr("No description available")).toString(); + tr("No description available")).toString(); lblCaption->setText("

" + caption +"

"); lblDescription->setText(description); diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/page/pagetraining.h --- a/QTfrontend/ui/page/pagetraining.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/page/pagetraining.h Mon Jan 30 17:32:18 2012 -0500 @@ -23,34 +23,34 @@ class PageTraining : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageTraining(QWidget* parent = 0); + public: + PageTraining(QWidget* parent = 0); -signals: - void startMission(const QString & scriptName); + signals: + void startMission(const QString & scriptName); -protected: - QLayout * bodyLayoutDefinition(); - QLayout * footerLayoutDefinition(); - void connectSignals(); + protected: + QLayout * bodyLayoutDefinition(); + QLayout * footerLayoutDefinition(); + void connectSignals(); -private: - QPushButton * btnPreview; - QPushButton * btnStart; - QLabel * lblCaption; - QLabel * lblDescription; - QListWidget * lstMissions; - QSettings * m_info; + private: + QPushButton * btnPreview; + QPushButton * btnStart; + QLabel * lblCaption; + QLabel * lblDescription; + QListWidget * lstMissions; + QSettings * m_info; -private slots: - void startSelected(); - void updateInfo(); + private slots: + void startSelected(); + void updateInfo(); }; diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/qaspectratiolayout.cpp --- a/QTfrontend/ui/qaspectratiolayout.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/qaspectratiolayout.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -4,116 +4,141 @@ #include "qaspectratiolayout.h" -QAspectRatioLayout::QAspectRatioLayout(QWidget* parent, int spacing) : QLayout(parent) { - init(spacing); +QAspectRatioLayout::QAspectRatioLayout(QWidget* parent, int spacing) : QLayout(parent) +{ + init(spacing); } -QAspectRatioLayout::QAspectRatioLayout(int spacing) { - init(spacing); +QAspectRatioLayout::QAspectRatioLayout(int spacing) +{ + init(spacing); } -QAspectRatioLayout::~QAspectRatioLayout() { - delete item; - delete lastReceivedRect; - delete _geometry; +QAspectRatioLayout::~QAspectRatioLayout() +{ + delete item; + delete lastReceivedRect; + delete _geometry; } -void QAspectRatioLayout::init(int spacing) { - item = 0; - lastReceivedRect = new QRect(0, 0, 0, 0); - _geometry = new QRect(0, 0, 0, 0); - setSpacing(spacing); +void QAspectRatioLayout::init(int spacing) +{ + item = 0; + lastReceivedRect = new QRect(0, 0, 0, 0); + _geometry = new QRect(0, 0, 0, 0); + setSpacing(spacing); } /* Adds item if place isn't already taken. */ -void QAspectRatioLayout::add(QLayoutItem* item) { - if(!hasItem()) { - replaceItem(item); - } +void QAspectRatioLayout::add(QLayoutItem* item) +{ + if(!hasItem()) + { + replaceItem(item); + } } /* Adds item if place isn't already taken. */ -void QAspectRatioLayout::addItem(QLayoutItem* item) { - if(!hasItem()) { - replaceItem(item); - } +void QAspectRatioLayout::addItem(QLayoutItem* item) +{ + if(!hasItem()) + { + replaceItem(item); + } } /* Adds widget if place isn't already taken. */ -void QAspectRatioLayout::addWidget(QWidget* widget) { - if(!hasItem()) { - replaceItem(new QWidgetItem(widget)); - } +void QAspectRatioLayout::addWidget(QWidget* widget) +{ + if(!hasItem()) + { + replaceItem(new QWidgetItem(widget)); + } } /* Returns the item pointer and dereferences it here. */ -QLayoutItem* QAspectRatioLayout::take() { - QLayoutItem* item = 0; - if(this->hasItem()) { - item = this->item; - this->item = 0; - } - return item; +QLayoutItem* QAspectRatioLayout::take() +{ + QLayoutItem* item = 0; + if(this->hasItem()) + { + item = this->item; + this->item = 0; + } + return item; } /* Returns the item pointer and dereferences it here. */ -QLayoutItem* QAspectRatioLayout::takeAt(int index) { - if(index != 0) { - return 0; - } - return this->take(); +QLayoutItem* QAspectRatioLayout::takeAt(int index) +{ + if(index != 0) + { + return 0; + } + return this->take(); } /* Returns the item pointer. */ -QLayoutItem* QAspectRatioLayout::itemAt(int index) const { - if(index != 0) { - return 0; - } - if(hasItem()) { - return this->item; - } +QLayoutItem* QAspectRatioLayout::itemAt(int index) const +{ + if(index != 0) + { return 0; + } + if(hasItem()) + { + return this->item; + } + return 0; } /* Checks if we have an item. */ -bool QAspectRatioLayout::hasItem() const { - return this->item != 0; +bool QAspectRatioLayout::hasItem() const +{ + return this->item != 0; } /* Returns the count of items which can be either 0 or 1. */ -int QAspectRatioLayout::count() const { - int returnValue = 0; - if(hasItem()) { - returnValue = 1; - } - return returnValue; +int QAspectRatioLayout::count() const +{ + int returnValue = 0; + if(hasItem()) + { + returnValue = 1; + } + return returnValue; } /* Replaces the item with the new and returns the old. */ -QLayoutItem* QAspectRatioLayout::replaceItem(QLayoutItem* item) { - QLayoutItem* old = 0; - if(this->hasItem()) { - old = this->item; - } - this->item = item; - setGeometry(*this->_geometry); - return old; +QLayoutItem* QAspectRatioLayout::replaceItem(QLayoutItem* item) +{ + QLayoutItem* old = 0; + if(this->hasItem()) + { + old = this->item; + } + this->item = item; + setGeometry(*this->_geometry); + return old; } /* Tells which way layout expands. */ -Qt::Orientations QAspectRatioLayout::expandingDirections() const { - return Qt::Horizontal | Qt::Vertical; +Qt::Orientations QAspectRatioLayout::expandingDirections() const +{ + return Qt::Horizontal | Qt::Vertical; } /* Tells which size is preferred. */ -QSize QAspectRatioLayout::sizeHint() const { - return this->item->minimumSize(); +QSize QAspectRatioLayout::sizeHint() const +{ + return this->item->minimumSize(); } /* Tells minimum size. */ -QSize QAspectRatioLayout::minimumSize() const { - return this->item->minimumSize(); +QSize QAspectRatioLayout::minimumSize() const +{ + return this->item->minimumSize(); } /* @@ -121,86 +146,99 @@ * It isn't since width isn't enough to calculate * proper size. */ -bool QAspectRatioLayout::hasHeightForWidth() const { - return false; +bool QAspectRatioLayout::hasHeightForWidth() const +{ + return false; } /* Replaces lastReceivedRect. */ -void QAspectRatioLayout::setLastReceivedRect(const QRect& rect) { - QRect* oldRect = this->lastReceivedRect; - this->lastReceivedRect = new QRect(rect.topLeft(), rect.size()); - delete oldRect; +void QAspectRatioLayout::setLastReceivedRect(const QRect& rect) +{ + QRect* oldRect = this->lastReceivedRect; + this->lastReceivedRect = new QRect(rect.topLeft(), rect.size()); + delete oldRect; } /* Returns geometry */ -QRect QAspectRatioLayout::geometry() { - return QRect(*this->_geometry); +QRect QAspectRatioLayout::geometry() +{ + return QRect(*this->_geometry); } /* Sets geometry to given size. */ -void QAspectRatioLayout::setGeometry(const QRect& rect) { - /* - * We check if the item is set and - * if size is the same previously received. - * If either is false nothing is done. - */ - if(!this->hasItem() || - areRectsEqual(*this->lastReceivedRect, rect)) { - return; - } - /* Replace the last received rectangle. */ - setLastReceivedRect(rect); - /* Calculate proper size for the item relative to the received size. */ - QSize properSize = calculateProperSize(rect.size()); - /* Calculate center location in the rect and with item size. */ - QPoint properLocation = calculateCenterLocation(rect.size(), properSize); - /* Set items geometry */ - this->item->setGeometry(QRect(properLocation, properSize)); - QRect* oldRect = this->_geometry; - /* Cache the calculated geometry. */ - this->_geometry = new QRect(properLocation, properSize); - delete oldRect; - /* Super classes setGeometry */ - QLayout::setGeometry(*this->_geometry); +void QAspectRatioLayout::setGeometry(const QRect& rect) +{ + /* + * We check if the item is set and + * if size is the same previously received. + * If either is false nothing is done. + */ + if(!this->hasItem() || + areRectsEqual(*this->lastReceivedRect, rect)) + { + return; + } + /* Replace the last received rectangle. */ + setLastReceivedRect(rect); + /* Calculate proper size for the item relative to the received size. */ + QSize properSize = calculateProperSize(rect.size()); + /* Calculate center location in the rect and with item size. */ + QPoint properLocation = calculateCenterLocation(rect.size(), properSize); + /* Set items geometry */ + this->item->setGeometry(QRect(properLocation, properSize)); + QRect* oldRect = this->_geometry; + /* Cache the calculated geometry. */ + this->_geometry = new QRect(properLocation, properSize); + delete oldRect; + /* Super classes setGeometry */ + QLayout::setGeometry(*this->_geometry); } /* Takes the shortest side and creates QSize * with the shortest side as width and height. */ -QSize QAspectRatioLayout::calculateProperSize(QSize from) const { - QSize properSize; - if(from.height() * 2 < from.width()) { - properSize.setHeight(from.height() - this->margin()); - properSize.setWidth(from.height() * 2 - this->margin()); - } - else { - properSize.setWidth(from.width() - this->margin()); - properSize.setHeight(from.width() / 2 - this->margin()); - } - return properSize; +QSize QAspectRatioLayout::calculateProperSize(QSize from) const +{ + QSize properSize; + if(from.height() * 2 < from.width()) + { + properSize.setHeight(from.height() - this->margin()); + properSize.setWidth(from.height() * 2 - this->margin()); + } + else + { + properSize.setWidth(from.width() - this->margin()); + properSize.setHeight(from.width() / 2 - this->margin()); + } + return properSize; } /* Calculates center location from the given height and width for item size. */ QPoint QAspectRatioLayout::calculateCenterLocation(QSize from, - QSize itemSize) const { - QPoint centerLocation; - if((from.width() - itemSize.width()) > 0) { - centerLocation.setX((from.width() - itemSize.width())/2); - } - if((from.height() - itemSize.height()) > 0) { - centerLocation.setY((from.height() - itemSize.height())/2); - } - return centerLocation; + QSize itemSize) const +{ + QPoint centerLocation; + if((from.width() - itemSize.width()) > 0) + { + centerLocation.setX((from.width() - itemSize.width())/2); + } + if((from.height() - itemSize.height()) > 0) + { + centerLocation.setY((from.height() - itemSize.height())/2); + } + return centerLocation; } /* Compares if two QRects are equal. */ bool QAspectRatioLayout::areRectsEqual(const QRect& a, - const QRect& b) const { - bool result = false; - if(a.x() == b.x() && - a.y() == b.y() && - a.height() == b.height() && - a.width() == b.width()) { - result = true; - } - return result; + const QRect& b) const +{ + bool result = false; + if(a.x() == b.x() && + a.y() == b.y() && + a.height() == b.height() && + a.width() == b.width()) + { + result = true; + } + return result; } diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/qaspectratiolayout.h --- a/QTfrontend/ui/qaspectratiolayout.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/qaspectratiolayout.h Mon Jan 30 17:32:18 2012 -0500 @@ -16,7 +16,7 @@ { Q_OBJECT -public: + public: QAspectRatioLayout(QWidget* parent, int spacing =-1); QAspectRatioLayout(int spacing = -1); ~QAspectRatioLayout(); @@ -24,7 +24,7 @@ /* Convenience method */ virtual void add(QLayoutItem* item); -/* http://doc.trolltech.com/qlayout.html#addItem */ + /* http://doc.trolltech.com/qlayout.html#addItem */ virtual void addItem(QLayoutItem* item); /* http://doc.trolltech.com/qlayout.html#addWidget */ virtual void addWidget(QWidget* widget); @@ -42,7 +42,7 @@ virtual QLayoutItem* take(); virtual bool hasItem() const; -/* http://doc.trolltech.com/qlayout.html#expandingDirections */ + /* http://doc.trolltech.com/qlayout.html#expandingDirections */ virtual Qt::Orientations expandingDirections() const; /* @@ -60,7 +60,7 @@ /* http://doc.trolltech.com/qlayoutitem.html#hasHeightForWidth */ virtual bool hasHeightForWidth() const; -private: + private: /* Saves the last received rect. */ void setLastReceivedRect(const QRect& rect); /* Used to initialize the object. */ diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/FreqSpinBox.h --- a/QTfrontend/ui/widget/FreqSpinBox.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/FreqSpinBox.h Mon Jan 30 17:32:18 2012 -0500 @@ -35,23 +35,23 @@ */ class FreqSpinBox : public QSpinBox { - Q_OBJECT + Q_OBJECT -public: - /** - * @brief Class constructor. - * @param parent parent widget. - */ - FreqSpinBox(QWidget * parent); + public: + /** + * @brief Class constructor. + * @param parent parent widget. + */ + FreqSpinBox(QWidget * parent); -protected: - /** - * Returns it's value as localized frequency. - * 'Never', 'Every Turn', 'Every 2 Turns', etc. - * @param value integer value to be representing as string. - * @return the turn frequence-like string representation. - */ - QString textFromValue(int value) const; + protected: + /** + * Returns it's value as localized frequency. + * 'Never', 'Every Turn', 'Every 2 Turns', etc. + * @param value integer value to be representing as string. + * @return the turn frequence-like string representation. + */ + QString textFromValue(int value) const; }; diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/HistoryLineEdit.cpp --- a/QTfrontend/ui/widget/HistoryLineEdit.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/HistoryLineEdit.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -27,7 +27,7 @@ #include "HistoryLineEdit.h" HistoryLineEdit::HistoryLineEdit(QWidget * parent, int maxHistorySize) -: QLineEdit(parent) + : QLineEdit(parent) { m_curHistEntryIdx = 0; m_maxHistorySize = maxHistorySize; @@ -80,10 +80,10 @@ { // save possible changes to new entry if ((m_curHistEntryIdx >= m_history->size() || - (text() != m_history->at(m_curHistEntryIdx)))) - { - rememberCurrentText(); - } + (text() != m_history->at(m_curHistEntryIdx)))) + { + rememberCurrentText(); + } if (isGoingUp) m_curHistEntryIdx--; diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/HistoryLineEdit.h --- a/QTfrontend/ui/widget/HistoryLineEdit.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/HistoryLineEdit.h Mon Jan 30 17:32:18 2012 -0500 @@ -38,72 +38,72 @@ /** * @brief QLineEdit that features a history of previous contents, * re-selectable using the arrow keys. - * + * * @author sheepluva * @since 0.9.17 */ class HistoryLineEdit : public QLineEdit { - Q_OBJECT + Q_OBJECT -public: - /** - * @brief Class constructor. - * @param parent parent QWidget. - * @param maxHistorySize maximum amount of history entries kept. - */ - HistoryLineEdit(QWidget * parent = 0, int maxHistorySize = 64); + public: + /** + * @brief Class constructor. + * @param parent parent QWidget. + * @param maxHistorySize maximum amount of history entries kept. + */ + HistoryLineEdit(QWidget * parent = 0, int maxHistorySize = 64); - /** - * @brief Class destructor. - */ - ~HistoryLineEdit(); + /** + * @brief Class destructor. + */ + ~HistoryLineEdit(); - /** - * @brief Appends current text to history (if not only whitespaces); - */ - void rememberCurrentText(); + /** + * @brief Appends current text to history (if not only whitespaces); + */ + void rememberCurrentText(); - /** - * @brief Forget all history. - */ - void reset(); + /** + * @brief Forget all history. + */ + void reset(); -public slots: - /** - * @brief Clears the contents. - */ - void clear(); + public slots: + /** + * @brief Clears the contents. + */ + void clear(); -protected: - /** - * @brief Overrides method of parent class. - * Arrow keys are used for navigating the history. - * - * All other keys are forwarded to the parent's method. - * - * @param event the key event. - */ - virtual void keyPressEvent(QKeyEvent * event); + protected: + /** + * @brief Overrides method of parent class. + * Arrow keys are used for navigating the history. + * + * All other keys are forwarded to the parent's method. + * + * @param event the key event. + */ + virtual void keyPressEvent(QKeyEvent * event); -private: - int m_maxHistorySize; ///< the maximum allowed size for the history - int m_curHistEntryIdx; ///< the index of the displayed used entry + private: + int m_maxHistorySize; ///< the maximum allowed size for the history + int m_curHistEntryIdx; ///< the index of the displayed used entry - QStringList * m_history; ///< history of previous inputs + QStringList * m_history; ///< history of previous inputs - /** - * @brief Navigates content history in the desired direction. - * - * Note: no wrap-around on purpose (so that holding down/up will get the - * the user to the respective end rather than into an endless cycle :P) - * - * @param isGoingUp true: next older entry, false: next more recent entry. - */ - void navigateHistory(bool isGoingUp); + /** + * @brief Navigates content history in the desired direction. + * + * Note: no wrap-around on purpose (so that holding down/up will get the + * the user to the respective end rather than into an endless cycle :P) + * + * @param isGoingUp true: next older entry, false: next more recent entry. + */ + void navigateHistory(bool isGoingUp); }; diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/SmartLineEdit.cpp --- a/QTfrontend/ui/widget/SmartLineEdit.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/SmartLineEdit.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -25,7 +25,7 @@ #include "SmartLineEdit.h" SmartLineEdit::SmartLineEdit(QWidget * parent, int maxHistorySize) -: HistoryLineEdit(parent, maxHistorySize) + : HistoryLineEdit(parent, maxHistorySize) { m_whitespace = QRegExp("\\s"); diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/SmartLineEdit.h --- a/QTfrontend/ui/widget/SmartLineEdit.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/SmartLineEdit.h Mon Jan 30 17:32:18 2012 -0500 @@ -45,108 +45,108 @@ *
  • A Keyword can either be a command (if first word) or * a nickname (completed regardless of position in text).
  • * - * + * * @author sheepluva * @since 0.9.17 */ class SmartLineEdit : public HistoryLineEdit { - Q_OBJECT + Q_OBJECT -public: - /** - * @brief Class constructor. - * @param parent parent QWidget. - * @param maxHistorySize maximum amount of history entries kept. - */ - SmartLineEdit(QWidget * parent = 0, int maxHistorySize = 64); + public: + /** + * @brief Class constructor. + * @param parent parent QWidget. + * @param maxHistorySize maximum amount of history entries kept. + */ + SmartLineEdit(QWidget * parent = 0, int maxHistorySize = 64); - /** - * @brief Class destructor. - */ - ~SmartLineEdit(); + /** + * @brief Class destructor. + */ + ~SmartLineEdit(); - /** - * @brief Adds commands to the auto-completion feature. - * @param commands list of commands to be added. - */ - void addCommands(const QStringList & commands); + /** + * @brief Adds commands to the auto-completion feature. + * @param commands list of commands to be added. + */ + void addCommands(const QStringList & commands); - /** - * @brief Adds a single nickname to the auto-completion feature. - * @param nickname name to be added. - */ - void addNickname(const QString & nickname); + /** + * @brief Adds a single nickname to the auto-completion feature. + * @param nickname name to be added. + */ + void addNickname(const QString & nickname); - /** - * @brief Removes commands from the auto-completion feature. - * @param commands list of commands to be removed. - */ - void removeCommands(const QStringList & commands); + /** + * @brief Removes commands from the auto-completion feature. + * @param commands list of commands to be removed. + */ + void removeCommands(const QStringList & commands); - /** - * @brief Removes a single nickname from the auto-completion feature. - * @param nickname name to be removed. - */ - void removeNickname(const QString & nickname); + /** + * @brief Removes a single nickname from the auto-completion feature. + * @param nickname name to be removed. + */ + void removeNickname(const QString & nickname); - /** - * @brief Forget all keywords and input history. - */ - void reset(); + /** + * @brief Forget all keywords and input history. + */ + void reset(); -protected: - /** - * @brief Overrides method of parent class. - * Forward pressed TAB to parent class' method (for focus handling etc) - * only if line is empty. - * - * @param event the event. - * @return returns true if the event was recognized. - */ - virtual bool event(QEvent * event); + protected: + /** + * @brief Overrides method of parent class. + * Forward pressed TAB to parent class' method (for focus handling etc) + * only if line is empty. + * + * @param event the event. + * @return returns true if the event was recognized. + */ + virtual bool event(QEvent * event); - /** - * @brief Overrides method of parent class. - * Autocompletes if TAB is reported as pressed key in the key event, - * ESC leads to the contents being cleared. - * - * Other keys are forwarded to parent method. - * - * @param event the key event. - */ - virtual void keyPressEvent(QKeyEvent * event); + /** + * @brief Overrides method of parent class. + * Autocompletes if TAB is reported as pressed key in the key event, + * ESC leads to the contents being cleared. + * + * Other keys are forwarded to parent method. + * + * @param event the key event. + */ + virtual void keyPressEvent(QKeyEvent * event); -private: - QRegExp m_whitespace; ///< regexp that matches a whitespace + private: + QRegExp m_whitespace; ///< regexp that matches a whitespace - QStringList * m_cmds; ///< list of recognized commands - QStringList * m_nicks; ///< list of recognized nicknames + QStringList * m_cmds; ///< list of recognized commands + QStringList * m_nicks; ///< list of recognized nicknames - /// recognized nicknames, sorted case-insensitive - QMap * m_sorted_nicks; + /// recognized nicknames, sorted case-insensitive + QMap * m_sorted_nicks; - // these variables contain information about the last replacement - // they get reset whenever cursor is moved or text is changed + // these variables contain information about the last replacement + // they get reset whenever cursor is moved or text is changed - QString m_beforeMatch; ///< the string that was just matched - bool m_hasJustMatched; ///< whether this widget just did an auto-completion - QString m_prefix; ///< prefix of the text replacement this widget just did - QString m_postfix; ///< postfix of the text replacement this widget just did + QString m_beforeMatch; ///< the string that was just matched + bool m_hasJustMatched; ///< whether this widget just did an auto-completion + QString m_prefix; ///< prefix of the text replacement this widget just did + QString m_postfix; ///< postfix of the text replacement this widget just did - /** - * @brief Autocompletes the contents based on the known commands and/or names. - */ - void autoComplete(); + /** + * @brief Autocompletes the contents based on the known commands and/or names. + */ + void autoComplete(); -private slots: - /** - * @brief Resets the information about the last match and text replacement. - */ - void resetAutoCompletionStatus(); + private slots: + /** + * @brief Resets the information about the last match and text replacement. + */ + void resetAutoCompletionStatus(); }; diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/SquareLabel.cpp --- a/QTfrontend/ui/widget/SquareLabel.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/SquareLabel.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -33,10 +33,13 @@ QPainter painter(this); int pixsize; - if (width() > height()) { + if (width() > height()) + { pixsize = height(); painter.translate((width() - pixsize) / 2, 0); - } else { + } + else + { pixsize = width(); painter.translate(0, (height() - pixsize) / 2); } diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/SquareLabel.h --- a/QTfrontend/ui/widget/SquareLabel.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/SquareLabel.h Mon Jan 30 17:32:18 2012 -0500 @@ -24,17 +24,17 @@ class SquareLabel : public QWidget { - Q_OBJECT + Q_OBJECT -public: - SquareLabel(QWidget * parent = 0); + public: + SquareLabel(QWidget * parent = 0); - void setPixmap(const QPixmap & pixmap); -protected: - virtual void paintEvent(QPaintEvent * event); + void setPixmap(const QPixmap & pixmap); + protected: + virtual void paintEvent(QPaintEvent * event); -private: - QPixmap pixmap; + private: + QPixmap pixmap; }; diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/about.cpp --- a/QTfrontend/ui/widget/about.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/about.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -27,7 +27,7 @@ #include "about.h" About::About(QWidget * parent) : - QWidget(parent) + QWidget(parent) { QGridLayout *mainLayout = new QGridLayout(this); @@ -45,16 +45,16 @@ 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 v2") + - "
    " - ); + "" + "

    Hedgewars

    " + "

    " + QLabel::tr("Version") + " " + *cVersionString + "

    " + "

    http://www.hedgewars.org/


    " + + QLabel::tr("This program is distributed under the GNU General Public License v2") + + "
    " + ); lbl1->setWordWrap(true); mainLayout->addWidget(lbl1, 0, 1); @@ -62,33 +62,33 @@ 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>
    " - "Many engine and frontend improvements (and bugs): Richard Karolyi <sheepluva@" "ercatec.net>
    " - "Gamepad and Lua integration: Mario Liebisch <mario.liebisch@gmail.com>
    " - "Many engine improvements and graphics: Carlos Vives <mail@carlosvives.es>
    " - "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>
    " - "

    " + + "" + + 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>
    " + "Many engine and frontend improvements (and bugs): Richard Karolyi <sheepluva@" "ercatec.net>
    " + "Gamepad and Lua integration: Mario Liebisch <mario.liebisch@gmail.com>
    " + "Many engine improvements and graphics: Carlos Vives <mail@carlosvives.es>
    " + "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( + QLabel::tr("Art:") + "" + + QString::fromUtf8( "

    John Dum <fizzy@gmail.com>" "
    " "Joshua Frese <joshfrese@gmail.com>" @@ -105,18 +105,18 @@ "
    " "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("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( + QLabel::tr("Translations:") + "

    " + + QString::fromUtf8( "Brazilian Portuguese: Romulo Fernandes Machado <abra185@gmail.com>
    " "Bulgarian: Svetoslav Stefanov
    " "Czech: Petr Řezáček <rezacek@gmail.com>
    " @@ -139,13 +139,13 @@ "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)" - "

    " - ); + 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); setAcceptDrops(true); diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/about.h --- a/QTfrontend/ui/widget/about.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/about.h Mon Jan 30 17:32:18 2012 -0500 @@ -26,17 +26,17 @@ class About : public QWidget { - Q_OBJECT + Q_OBJECT -public: - About(QWidget * parent = 0); + public: + About(QWidget * parent = 0); -protected: - virtual void dragEnterEvent(QDragEnterEvent * event); - virtual void dropEvent(QDropEvent * event); + protected: + virtual void dragEnterEvent(QDragEnterEvent * event); + virtual void dropEvent(QDropEvent * event); -private: - QTextBrowser * lbl2; + private: + QTextBrowser * lbl2; }; #endif // _ABOUT_H diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/bgwidget.cpp --- a/QTfrontend/ui/widget/bgwidget.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/bgwidget.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -94,13 +94,17 @@ //Simply replace Confetti.png and Egg.png with an appropriate graphic) switch (season) { - case SEASON_CHRISTMAS : fname = "Flake.png"; - break; - case SEASON_EASTER : fname = "Egg.png"; - break; - case SEASON_HWBDAY : fname = "Confetti.png"; - break; - default : fname = "Star.png"; + case SEASON_CHRISTMAS : + fname = "Flake.png"; + break; + case SEASON_EASTER : + fname = "Egg.png"; + break; + case SEASON_HWBDAY : + fname = "Confetti.png"; + break; + default : + fname = "Star.png"; } sprite.load(":/res/" + fname); @@ -118,7 +122,7 @@ QPainter p; p.begin(rotatedSprites[i]); - // p.setRenderHint(QPainter::Antialiasing); + // p.setRenderHint(QPainter::Antialiasing); p.setRenderHint(QPainter::SmoothPixmapTransform); p.translate(translate.x(), translate.y()); p.rotate(4 * i); diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/bgwidget.h --- a/QTfrontend/ui/widget/bgwidget.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/bgwidget.h Mon Jan 30 17:32:18 2012 -0500 @@ -34,46 +34,46 @@ class SpritePosition { -public: - SpritePosition(QWidget * parent, int sw, int sh); - ~SpritePosition(); -private: - float fX; - float fY; - float fXMov; - float fYMov; - int iAngle; - QWidget * wParent; - int iSpriteHeight; - int iSpriteWidth; -public: - void move(); - void reset(); - QPoint pos(); - int getAngle(); - void init(); + public: + SpritePosition(QWidget * parent, int sw, int sh); + ~SpritePosition(); + private: + float fX; + float fY; + float fXMov; + float fYMov; + int iAngle; + QWidget * wParent; + int iSpriteHeight; + int iSpriteWidth; + 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(); - bool enabled; + Q_OBJECT + public: + BGWidget(QWidget * parent); + ~BGWidget(); + void startAnimation(); + void stopAnimation(); + void init(); + bool enabled; -private: - QImage sprite; - QTimer * timerAnimation; - SpritePosition * spritePositions[SPRITE_MAX]; - QImage * rotatedSprites[360]; -protected: - void paintEvent(QPaintEvent * event); -private slots: - void animate(); + 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 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/chatwidget.cpp --- a/QTfrontend/ui/widget/chatwidget.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/chatwidget.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -175,11 +175,11 @@ QRegExp nohierarchy("^.[^ .]+$"); QStringList victims = QString(style). - remove(displayed). // remove visible stuff - trimmed(). - split(split). // get a list of the names - filter(nohierarchy). // only direct class names - replaceInStrings(QRegExp("^."),""); // crop . + remove(displayed). // remove visible stuff + trimmed(). + split(split). // get a list of the names + filter(nohierarchy). // only direct class names + replaceInStrings(QRegExp("^."),""); // crop . if (victims.contains("timestamp")) @@ -240,8 +240,8 @@ HWChatWidget::HWChatWidget(QWidget* parent, QSettings * gameSettings, bool notify) : - QWidget(parent), - mainLayout(this) + QWidget(parent), + mainLayout(this) { this->gameSettings = gameSettings; this->notify = notify; @@ -252,10 +252,10 @@ { if (notify) m_helloSound = HWDataManager::instance().findFileForRead( - "Sounds/voices/Classic/Hello.ogg"); + "Sounds/voices/Classic/Hello.ogg"); m_hilightSound = HWDataManager::instance().findFileForRead( - "Sounds/beep.ogg"); + "Sounds/beep.ogg"); //m_hilightSound = m_helloSound;//"Sounds/beep.ogg"; } @@ -281,7 +281,7 @@ chatText->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); chatText->setOpenLinks(false); connect(chatText, SIGNAL(anchorClicked(const QUrl&)), - this, SLOT(linkClicked(const QUrl&))); + this, SLOT(linkClicked(const QUrl&))); mainLayout.addWidget(chatText, 0, 0, 2, 1); chatNicks = new QListWidget(this); @@ -291,9 +291,9 @@ chatNicks->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); chatNicks->setContextMenuPolicy(Qt::ActionsContextMenu); connect(chatNicks, SIGNAL(itemDoubleClicked(QListWidgetItem *)), - this, SLOT(chatNickDoubleClicked(QListWidgetItem *))); + this, SLOT(chatNickDoubleClicked(QListWidgetItem *))); connect(chatNicks, SIGNAL(currentRowChanged(int)), - this, SLOT(chatNickSelected(int))); + this, SLOT(chatNickSelected(int))); mainLayout.addWidget(chatNicks, 0, 1, 3, 1); @@ -383,11 +383,13 @@ void HWChatWidget::setShowFollow(bool enabled) { - if (enabled) { + if (enabled) + { if (!(chatNicks->actions().contains(acFollow))) chatNicks->insertAction(acFriend, acFollow); } - else { + else + { if (chatNicks->actions().contains(acFollow)) chatNicks->removeAction(acFollow); } @@ -513,7 +515,7 @@ { if (nickname != m_userNick) return QString("%2").arg( - QString(nickname.toUtf8().toBase64())).arg(Qt::escape(nickname)); + QString(nickname.toUtf8().toBase64())).arg(Qt::escape(nickname)); // unlinked nick (if own one) return QString("%1").arg(Qt::escape(nickname)); @@ -531,7 +533,8 @@ { bool isFriend = false; - if (!nick.isEmpty()) { + if (!nick.isEmpty()) + { // don't show chat lines that are from ignored nicks if (ignoreList.contains(nick, Qt::CaseInsensitive)) return; @@ -567,7 +570,7 @@ bool isHL = false; if ((c != 3) && (!nick.isEmpty()) && - (nick != m_userNick) && (!m_userNick.isEmpty())) + (nick != m_userNick) && (!m_userNick.isEmpty())) { QString lcStr = str.toLower(); @@ -638,8 +641,9 @@ emit nickCountUpdate(chatNicks->count()); - if(notifyNick && notify && gameSettings->value("frontend/sound", true).toBool()) { - SDLInteraction::instance().playSoundFile(m_helloSound); + if(notifyNick && notify && gameSettings->value("frontend/sound", true).toBool()) + { + SDLInteraction::instance().playSoundFile(m_helloSound); } } @@ -648,7 +652,7 @@ chatEditLine->removeNickname(nick); foreach(QListWidgetItem * item, chatNicks->findItems(nick, Qt::MatchExactly)) - chatNicks->takeItem(chatNicks->row(item)); + chatNicks->takeItem(chatNicks->row(item)); emit nickCountUpdate(chatNicks->count()); } @@ -686,7 +690,7 @@ foreach (QString word, list) { m_highlights.append(QRegExp( - hlRegExp.arg(QRegExp::escape(word.toLower())))); + hlRegExp.arg(QRegExp::escape(word.toLower())))); } } diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/chatwidget.h --- a/QTfrontend/ui/widget/chatwidget.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/chatwidget.h Mon Jan 30 17:32:18 2012 -0500 @@ -41,17 +41,17 @@ /// Class for custom nickname 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(); + 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; + private: + bool aFriend; + bool isIgnored; }; @@ -66,95 +66,95 @@ class HWChatWidget : public QWidget { - Q_OBJECT + Q_OBJECT - public: - HWChatWidget(QWidget* parent, QSettings * gameSettings, bool notify); - void loadLists(const QString & nick); - void saveLists(const QString & nick); - void setShowReady(bool s); - void setShowFollow(bool enabled); - QStringList ignoreList, friendsList; - static const QString & styleSheet(); - void displayError(const QString & message); - void displayNotice(const QString & message); - void displayWarning(const QString & message); - void setUser(const QString & nickname); + public: + HWChatWidget(QWidget* parent, QSettings * gameSettings, bool notify); + void loadLists(const QString & nick); + void saveLists(const QString & nick); + void setShowReady(bool s); + void setShowFollow(bool enabled); + QStringList ignoreList, friendsList; + static const QString & styleSheet(); + void displayError(const QString & message); + void displayNotice(const QString & message); + void displayWarning(const QString & message); + void setUser(const QString & nickname); -protected: - virtual void dragEnterEvent(QDragEnterEvent * event); - virtual void dropEvent(QDropEvent * event); + protected: + virtual void dragEnterEvent(QDragEnterEvent * event); + virtual void dropEvent(QDropEvent * event); -private: - static QString * s_styleSheet; - static QStringList * s_displayNone; - static bool s_isTimeStamped; - static QString s_tsFormat; - static const QRegExp URLREGEXP; + private: + static QString * s_styleSheet; + static QStringList * s_displayNone; + static bool s_isTimeStamped; + static QString s_tsFormat; + static const QRegExp URLREGEXP; - static void setStyleSheet(const QString & styleSheet = ""); + static void setStyleSheet(const QString & styleSheet = ""); - void loadList(QStringList & list, const QString & file); - void saveList(QStringList & list, const QString & file); - void updateNickItem(QListWidgetItem *item); - void updateNickItems(); - void addLine(const QString & cssClass, QString line, bool isHighlight = false); - bool parseCommand(const QString & line); - void discardStyleSheet(); - void saveStyleSheet(); - QString linkedNick(const QString & nickname); + void loadList(QStringList & list, const QString & file); + void saveList(QStringList & list, const QString & file); + void updateNickItem(QListWidgetItem *item); + void updateNickItems(); + void addLine(const QString & cssClass, QString line, bool isHighlight = false); + bool parseCommand(const QString & line); + void discardStyleSheet(); + void saveStyleSheet(); + QString linkedNick(const QString & nickname); - 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); + 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); + 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: - bool m_isAdmin; - QGridLayout mainLayout; - QTextBrowser* chatText; - QStringList chatStrings; - QListWidget* chatNicks; - SmartLineEdit* chatEditLine; - QAction * acInfo; - QAction * acKick; - QAction * acBan; - QAction * acFollow; - QAction * acIgnore; - QAction * acFriend; - QSettings * gameSettings; - QString m_helloSound; - QString m_hilightSound; - QString m_userNick; - QString m_clickedNick; - QList m_highlights; ///< regular expressions used for highlighting - bool notify; - bool showReady; + private: + bool m_isAdmin; + QGridLayout mainLayout; + QTextBrowser* chatText; + QStringList chatStrings; + QListWidget* chatNicks; + SmartLineEdit* chatEditLine; + QAction * acInfo; + QAction * acKick; + QAction * acBan; + QAction * acFollow; + QAction * acIgnore; + QAction * acFriend; + QSettings * gameSettings; + QString m_helloSound; + QString m_hilightSound; + QString m_userNick; + QString m_clickedNick; + QList m_highlights; ///< regular expressions used for highlighting + 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); + 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 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/databrowser.cpp --- a/QTfrontend/ui/widget/databrowser.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/databrowser.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -24,19 +24,18 @@ { return resources.take(name.toString()); } - else - if(!requestedResources.contains(name.toString())) - { - qDebug() << "Requesting resource" << name.toString(); - requestedResources.insert(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); + 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())); - } + QNetworkReply *reply = manager->get(newRequest); + connect(reply, SIGNAL(finished()), this, SLOT(resourceDownloaded())); + } } return QVariant(); diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/databrowser.h --- a/QTfrontend/ui/widget/databrowser.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/databrowser.h Mon Jan 30 17:32:18 2012 -0500 @@ -8,26 +8,26 @@ class DataBrowser : public QTextBrowser { - Q_OBJECT -public: - explicit DataBrowser(QWidget *parent = 0); + Q_OBJECT + public: + explicit DataBrowser(QWidget *parent = 0); -signals: + signals: -public slots: + 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; + private: + QNetworkAccessManager *manager; - QVariant loadResource(int type, const QUrl & name); + // 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; -private slots: - void resourceDownloaded(); + QVariant loadResource(int type, const QUrl & name); + + private slots: + void resourceDownloaded(); }; #endif // DATABROWSER_H diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/drawmapwidget.cpp --- a/QTfrontend/ui/widget/drawmapwidget.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/drawmapwidget.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -39,12 +39,13 @@ void DrawMapWidget::changeEvent(QEvent *e) { QWidget::changeEvent(e); - switch (e->type()) { - case QEvent::LanguageChange: - ui->retranslateUi(this); - break; - default: - break; + switch (e->type()) + { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; } } diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/drawmapwidget.h --- a/QTfrontend/ui/widget/drawmapwidget.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/drawmapwidget.h Mon Jan 30 17:32:18 2012 -0500 @@ -27,29 +27,30 @@ #include "qaspectratiolayout.h" #include "drawmapscene.h" -namespace Ui { +namespace Ui +{ class Ui_DrawMapWidget { - public: - QGraphicsView *graphicsView; + public: + QGraphicsView *graphicsView; - void setupUi(QWidget *drawMapWidget) - { - QAspectRatioLayout * arLayout = new QAspectRatioLayout(drawMapWidget); - arLayout->setMargin(0); + void setupUi(QWidget *drawMapWidget) + { + QAspectRatioLayout * arLayout = new QAspectRatioLayout(drawMapWidget); + arLayout->setMargin(0); - graphicsView = new QGraphicsView(drawMapWidget); - arLayout->addWidget(graphicsView); + graphicsView = new QGraphicsView(drawMapWidget); + arLayout->addWidget(graphicsView); - retranslateUi(drawMapWidget); + retranslateUi(drawMapWidget); - QMetaObject::connectSlotsByName(drawMapWidget); - } // setupUi + QMetaObject::connectSlotsByName(drawMapWidget); + } // setupUi - void retranslateUi(QWidget *drawMapWidget) - { - Q_UNUSED(drawMapWidget); - } // retranslateUi + void retranslateUi(QWidget *drawMapWidget) + { + Q_UNUSED(drawMapWidget); + } // retranslateUi }; @@ -58,29 +59,29 @@ class DrawMapWidget : public QWidget { - Q_OBJECT + Q_OBJECT -public: - explicit DrawMapWidget(QWidget *parent = 0); - ~DrawMapWidget(); + public: + explicit DrawMapWidget(QWidget *parent = 0); + ~DrawMapWidget(); - void setScene(DrawMapScene * scene); + void setScene(DrawMapScene * scene); -public slots: - void undo(); - void clear(); - void save(const QString & fileName); - void load(const QString & fileName); + 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); + protected: + void changeEvent(QEvent *e); + virtual void resizeEvent(QResizeEvent * event); + virtual void showEvent(QShowEvent * event); -private: - Ui::DrawMapWidget *ui; + private: + Ui::DrawMapWidget *ui; - DrawMapScene * m_scene; + DrawMapScene * m_scene; }; #endif // DRAWMAPWIDGET_H diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/fpsedit.h --- a/QTfrontend/ui/widget/fpsedit.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/fpsedit.h Mon Jan 30 17:32:18 2012 -0500 @@ -23,13 +23,13 @@ class FPSEdit : public QSpinBox { - Q_OBJECT + Q_OBJECT -public: - FPSEdit(QWidget * parent = 0); + public: + FPSEdit(QWidget * parent = 0); -protected: - QString textFromValue (int value) const; + protected: + QString textFromValue (int value) const; }; #endif // _FPSEDIT_H diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/frameTeam.cpp --- a/QTfrontend/ui/widget/frameTeam.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/frameTeam.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -26,7 +26,7 @@ #include "hwconsts.h" FrameTeams::FrameTeams(QWidget* parent) : - QFrame(parent), maxHedgehogsPerGame(48), overallHedgehogs(0), mainLayout(this), nonInteractive(false) + QFrame(parent), maxHedgehogsPerGame(48), overallHedgehogs(0), mainLayout(this), nonInteractive(false) { QPalette newPalette = palette(); newPalette.setColor(QPalette::Window, QColor(0x00, 0x00, 0x00)); @@ -46,7 +46,8 @@ void FrameTeams::setInteractivity(bool interactive) { nonInteractive = !interactive; - for(tmapTeamToWidget::iterator it=teamToWidget.begin(); it!=teamToWidget.end(); ++it) { + for(tmapTeamToWidget::iterator it=teamToWidget.begin(); it!=teamToWidget.end(); ++it) + { TeamShowWidget* pts = dynamic_cast(it.value()); if(!pts) throw; pts->setInteractivity(interactive); @@ -55,74 +56,75 @@ void FrameTeams::resetColors() { - currentColor=availableColors.end() - 1; // ensure next color is the first one + 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; + 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); + 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); + 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); + 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++); - } + 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()); + 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.color()); + TeamShowWidget* pTeamShowWidget = dynamic_cast(getTeamWidget(team)); + if(!pTeamShowWidget) return; + pTeamShowWidget->changeTeamColor(team.color()); } 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; + tmapTeamToWidget::iterator it=teamToWidget.find(team); + QWidget* ret = it!=teamToWidget.end() ? it.value() : 0; + return ret; } bool FrameTeams::isFullTeams() const { - return overallHedgehogs==maxHedgehogsPerGame; + return overallHedgehogs==maxHedgehogsPerGame; } void FrameTeams::emitTeamColorChanged(const HWTeam& team) { - emit teamColorChanged(team); + emit teamColorChanged(team); } diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/frameTeam.h --- a/QTfrontend/ui/widget/frameTeam.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/frameTeam.h Mon Jan 30 17:32:18 2012 -0500 @@ -28,41 +28,41 @@ class FrameTeams : public QFrame { - Q_OBJECT + Q_OBJECT - friend class CHedgehogerWidget; - friend class TeamShowWidget; + 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; + 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&); + signals: + void teamColorChanged(const HWTeam&); - public slots: - void addTeam(HWTeam team, bool willPlay); - void removeTeam(HWTeam team); + public slots: + void addTeam(HWTeam team, bool willPlay); + void removeTeam(HWTeam team); - private: - const int maxHedgehogsPerGame; - int overallHedgehogs; - QList availableColors; - QList::Iterator currentColor; + private: + const int maxHedgehogsPerGame; + int overallHedgehogs; + QList availableColors; + QList::Iterator currentColor; - void emitTeamColorChanged(const HWTeam& team); + void emitTeamColorChanged(const HWTeam& team); - QVBoxLayout mainLayout; - typedef QMap tmapTeamToWidget; - tmapTeamToWidget teamToWidget; - bool nonInteractive; + QVBoxLayout mainLayout; + typedef QMap tmapTeamToWidget; + tmapTeamToWidget teamToWidget; + bool nonInteractive; }; #endif // _FRAME_TAM_INCLUDED diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/gamecfgwidget.cpp --- a/QTfrontend/ui/widget/gamecfgwidget.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/gamecfgwidget.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -34,9 +34,9 @@ #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}\\}") + 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); @@ -59,13 +59,15 @@ Scripts->addItem("Normal"); Scripts->insertSeparator(1); - for (int i = 0; i < scriptList->size(); ++i) { + for (int i = 0; i < scriptList->size(); ++i) + { QString script = (*scriptList)[i].remove(".lua", Qt::CaseInsensitive); QList scriptInfo; scriptInfo.push_back(script); QFile scriptCfgFile(HWDataManager::instance().findFileForRead( - QString("Scripts/Multiplayer/%2.cfg").arg(script))); - if (scriptCfgFile.exists() && scriptCfgFile.open(QFile::ReadOnly)) { + QString("Scripts/Multiplayer/%2.cfg").arg(script))); + if (scriptCfgFile.exists() && scriptCfgFile.open(QFile::ReadOnly)) + { QString scheme; QString weapons; QTextStream input(&scriptCfgFile); @@ -104,7 +106,7 @@ 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()); @@ -283,13 +285,14 @@ } break; } - default: ; + default: + ; } QByteArray result; foreach(QByteArray ba, bcfg) - HWProto::addByteArrayToBuffer(result, ba); + HWProto::addByteArrayToBuffer(result, ba); return result; } @@ -301,10 +304,13 @@ 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 + if ((pos == -1) || illegal) // prevent from overriding schemes with bad ones + { WeaponsName->addItem(name, ammo); WeaponsName->setCurrentIndex(WeaponsName->count() - 1); - } else { + } + else + { WeaponsName->setItemData(pos, ammo); WeaponsName->setCurrentIndex(pos); } @@ -335,38 +341,47 @@ if (slValue.size() == 1) { QString value = slValue[0]; - if (param == "MAP") { + if (param == "MAP") + { pMapContainer->setMap(value); return; } - if (param == "SEED") { + if (param == "SEED") + { pMapContainer->setSeed(value); - if (!seedRegexp.exactMatch(value)) { + if (!seedRegexp.exactMatch(value)) + { pMapContainer->seedEdit->setVisible(true); - } + } return; } - if (param == "THEME") { + if (param == "THEME") + { pMapContainer->setTheme(value); return; } - if (param == "TEMPLATE") { + if (param == "TEMPLATE") + { pMapContainer->setTemplateFilter(value.toUInt()); return; } - if (param == "MAPGEN") { + if (param == "MAPGEN") + { pMapContainer->setMapgen((MapGenerator)value.toUInt()); return; } - if (param == "MAZE_SIZE") { + if (param == "MAZE_SIZE") + { pMapContainer->setMazeSize(value.toUInt()); return; } - if (param == "SCRIPT") { + if (param == "SCRIPT") + { Scripts->setCurrentIndex(Scripts->findText(value)); return; } - if (param == "DRAWNMAP") { + if (param == "DRAWNMAP") + { pMapContainer->setDrawnMapData(qUncompress(QByteArray::fromBase64(slValue[0].toLatin1()))); return; } @@ -374,7 +389,8 @@ if (slValue.size() == 2) { - if (param == "AMMO") { + if (param == "AMMO") + { setNetAmmo(slValue[0], slValue[1]); return; } @@ -389,12 +405,12 @@ pMapContainer->seedEdit->setVisible(true); pMapContainer->setAllMapParameters( - slValue[0], - (MapGenerator)slValue[1].toUInt(), - slValue[2].toUInt(), - seed, - slValue[4].toUInt() - ); + slValue[0], + (MapGenerator)slValue[1].toUInt(), + slValue[2].toUInt(), + seed, + slValue[4].toUInt() + ); return; } } @@ -404,7 +420,8 @@ void GameCFGWidget::ammoChanged(int index) { - if (index >= 0) { + if (index >= 0) + { emit paramChanged( "AMMO", QStringList() << WeaponsName->itemText(index) << WeaponsName->itemData(index).toString() @@ -489,16 +506,19 @@ emit paramChanged("SCHEME", sl); - if (isEnabled() && bindEntries->isEnabled() && bindEntries->isChecked()) { + 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; - } + 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; + } } } } diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/gamecfgwidget.h --- a/QTfrontend/ui/widget/gamecfgwidget.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/gamecfgwidget.h Mon Jan 30 17:32:18 2012 -0500 @@ -34,53 +34,53 @@ class GameCFGWidget : public QGroupBox { - Q_OBJECT + 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: + 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(); + 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(); + 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 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; + private: + QGridLayout mainLayout; + QCheckBox * bindEntries; + QString curNetAmmoName; + QString curNetAmmo; + QRegExp seedRegexp; - void setNetAmmo(const QString& name, const QString& ammo); + void setNetAmmo(const QString& name, const QString& ammo); }; diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/hedgehogerWidget.cpp --- a/QTfrontend/ui/widget/hedgehogerWidget.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/hedgehogerWidget.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -24,53 +24,53 @@ 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;*/ + // 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) { + //if (pOurFrameTeams->overallHedgehogs < pOurFrameTeams->maxHedgehogsPerGame) { numItems++; //pOurFrameTeams->overallHedgehogs++; emit hedgehogsNumChanged(); - //} + //} } void CHedgehogerWidget::decItems() { - numItems--; - //pOurFrameTeams->overallHedgehogs--; - emit hedgehogsNumChanged(); + numItems--; + //pOurFrameTeams->overallHedgehogs--; + emit hedgehogsNumChanged(); } CHedgehogerWidget::~CHedgehogerWidget() { - // TODO: not called? - //pOurFrameTeams->overallHedgehogs-=numItems; + // TODO: not called? + //pOurFrameTeams->overallHedgehogs-=numItems; } void CHedgehogerWidget::setNonInteractive() { - nonInteractive=true; + nonInteractive=true; } void CHedgehogerWidget::setHHNum(unsigned int num) { - /*unsigned int diff = num - numItems; - numItems += diff; - pOurFrameTeams->overallHedgehogs += diff;*/ - numItems = num; - repaint(); + /*unsigned int diff = num - numItems; + numItems += diff; + pOurFrameTeams->overallHedgehogs += diff;*/ + numItems = num; + repaint(); } unsigned char CHedgehogerWidget::getHedgehogsNum() const { - return numItems; + return numItems; } diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/hedgehogerWidget.h --- a/QTfrontend/ui/widget/hedgehogerWidget.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/hedgehogerWidget.h Mon Jan 30 17:32:18 2012 -0500 @@ -26,25 +26,25 @@ class CHedgehogerWidget : public ItemNum { - Q_OBJECT + 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(); + 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(); + signals: + void hedgehogsNumChanged(); - protected: - virtual void incItems(); - virtual void decItems(); + protected: + virtual void incItems(); + virtual void decItems(); - private: - CHedgehogerWidget(); - FrameTeams* pOurFrameTeams; + private: + CHedgehogerWidget(); + FrameTeams* pOurFrameTeams; }; #endif // _HEDGEHOGER_WIDGET diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/igbox.cpp --- a/QTfrontend/ui/widget/igbox.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/igbox.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -36,20 +36,20 @@ { 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) - ); + "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(); diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/igbox.h --- a/QTfrontend/ui/widget/igbox.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/igbox.h Mon Jan 30 17:32:18 2012 -0500 @@ -24,21 +24,21 @@ class IconedGroupBox : public QGroupBox { - Q_OBJECT + Q_OBJECT -public: - IconedGroupBox(QWidget * parent = 0); + public: + IconedGroupBox(QWidget * parent = 0); - void setIcon(const QIcon & icon); - void setTitleTextPadding(int px); - void setContentTopPadding(int px); -protected: - virtual void paintEvent(QPaintEvent * event); + 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; + private: + QIcon icon; + int titleLeftPadding; + int contentTopPadding; }; #endif // _IGBOX_H diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/itemNum.cpp --- a/QTfrontend/ui/widget/itemNum.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/itemNum.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -23,8 +23,8 @@ #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) + 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); @@ -36,29 +36,40 @@ 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(); + 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 if (event->button()==Qt::RightButton && enabled) + { + event->accept(); + if(numItems > minItems) + { + decItems(); + } + else + { + numItems = maxItems+(infinityState?0:-1); + incItems(); + } } - } else { - event->ignore(); - return; - } - repaint(); + else + { + event->ignore(); + return; + } + repaint(); } void ItemNum::wheelEvent ( QWheelEvent * event ) { @@ -86,57 +97,67 @@ if(numItems > minItems) decItems(); } - repaint(); + repaint(); } QSize ItemNum::sizeHint () const { - return QSize((maxItems+1)*12, 32); + return QSize((maxItems+1)*12, 32); } void ItemNum::paintEvent(QPaintEvent* event) { - Q_UNUSED(event); + Q_UNUSED(event); - QPainter painter(this); + 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")); + 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; ipixelMetric(QStyle::PM_LayoutLeftMargin), - 1, - HWApplication::style()->pixelMetric(QStyle::PM_LayoutRightMargin), - HWApplication::style()->pixelMetric(QStyle::PM_LayoutBottomMargin)); + 1, + HWApplication::style()->pixelMetric(QStyle::PM_LayoutRightMargin), + HWApplication::style()->pixelMetric(QStyle::PM_LayoutBottomMargin)); QWidget* mapWidget = new QWidget(this); mainLayout.addWidget(mapWidget, 0, 0, Qt::AlignHCenter); @@ -70,12 +70,12 @@ chooseMap->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); chooseMap->addItem( // FIXME - need real icons. Disabling until then -//QIcon(":/res/mapRandom.png"), -QComboBox::tr("generated map...")); +//QIcon(":/res/mapRandom.png"), + QComboBox::tr("generated map...")); chooseMap->addItem( // FIXME - need real icons. Disabling until then -//QIcon(":/res/mapMaze.png"), -QComboBox::tr("generated maze...")); +//QIcon(":/res/mapMaze.png"), + QComboBox::tr("generated maze...")); chooseMap->addItem(QComboBox::tr("hand drawn map...")); chooseMap->insertSeparator(chooseMap->count()); // separator between generators and missions @@ -86,29 +86,34 @@ numMissions = 0; QFile mapLuaFile; QFile mapCfgFile; - for (int i = 0; i < mapList->size(); ++i) { + for (int i = 0; i < mapList->size(); ++i) + { QString map = (*mapList)[i]; mapCfgFile.setFileName( - QString("%1/Data/Maps/%2/map.cfg") + QString("%1/Data/Maps/%2/map.cfg") + .arg(cfgdir->absolutePath()) + .arg(map)); + if (mapCfgFile.exists()) + { + mapLuaFile.setFileName( + QString("%1/Data/Maps/%2/map.lua") .arg(cfgdir->absolutePath()) .arg(map)); - if (mapCfgFile.exists()) { - mapLuaFile.setFileName( - QString("%1/Data/Maps/%2/map.lua") - .arg(cfgdir->absolutePath()) - .arg(map)); - } else { + } + else + { mapCfgFile.setFileName( - QString("%1/Maps/%2/map.cfg") - .arg(datadir->absolutePath()) - .arg(map)); + QString("%1/Maps/%2/map.cfg") + .arg(datadir->absolutePath()) + .arg(map)); mapLuaFile.setFileName( - QString("%1/Maps/%2/map.lua") - .arg(datadir->absolutePath()) - .arg(map)); + QString("%1/Maps/%2/map.lua") + .arg(datadir->absolutePath()) + .arg(map)); } - if (mapCfgFile.open(QFile::ReadOnly)) { + if (mapCfgFile.open(QFile::ReadOnly)) + { QString theme; quint32 limit = 0; QString scheme; @@ -144,17 +149,17 @@ if(isMission) { - chooseMap->insertItem(missionindex++, + chooseMap->insertItem(missionindex++, // FIXME - need real icons. Disabling until then -//QIcon(":/res/mapMission.png"), -QComboBox::tr("Mission") + ": " + map, mapInfo); +//QIcon(":/res/mapMission.png"), + QComboBox::tr("Mission") + ": " + map, mapInfo); numMissions++; } else chooseMap->addItem( // FIXME - need real icons. Disabling until then -//QIcon(":/res/mapCustom.png"), -map, mapInfo); +//QIcon(":/res/mapCustom.png"), + map, mapInfo); mapCfgFile.close(); } } @@ -218,17 +223,17 @@ // override default style to tighten up theme scroller lvThemes->setStyleSheet(QString( - "QListView{" - "border: solid;" - "border-width: 0px;" - "border-radius: 0px;" - "border-color: transparent;" - "background-color: #0d0544;" - "color: #ffcc00;" - "font: bold 13px;" - "}" - ) - ); + "QListView{" + "border: solid;" + "border-width: 0px;" + "border-radius: 0px;" + "border-color: transparent;" + "background-color: #0d0544;" + "color: #ffcc00;" + "font: bold 13px;" + "}" + ) + ); gbTLayout->addWidget(lvThemes); lvThemes->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum); @@ -289,49 +294,50 @@ void HWMapContainer::mapChanged(int index) { - switch(index) { - case MAPGEN_REGULAR: - mapgen = MAPGEN_REGULAR; - updatePreview(); - gbThemes->show(); - lblFilter->show(); - cbTemplateFilter->show(); - maze_size_label->hide(); - cbMazeSize->hide(); - emit mapChanged("+rnd+"); - emit themeChanged(chooseMap->itemData(index).toList()[1].toString()); - break; - case MAPGEN_MAZE: - mapgen = MAPGEN_MAZE; - updatePreview(); - gbThemes->show(); - lblFilter->hide(); - cbTemplateFilter->hide(); - maze_size_label->show(); - cbMazeSize->show(); - emit mapChanged("+maze+"); - emit themeChanged(chooseMap->itemData(index).toList()[1].toString()); - break; - case MAPGEN_DRAWN: - mapgen = MAPGEN_DRAWN; - updatePreview(); - gbThemes->show(); - lblFilter->hide(); - cbTemplateFilter->hide(); - maze_size_label->hide(); - cbMazeSize->hide(); - emit mapChanged("+drawn+"); - emit themeChanged(chooseMap->itemData(index).toList()[1].toString()); - break; - default: - mapgen = MAPGEN_MAP; - updatePreview(); - gbThemes->hide(); - lblFilter->hide(); - cbTemplateFilter->hide(); - maze_size_label->hide(); - cbMazeSize->hide(); - emit mapChanged(chooseMap->itemData(index).toList()[0].toString()); + switch(index) + { + case MAPGEN_REGULAR: + mapgen = MAPGEN_REGULAR; + updatePreview(); + gbThemes->show(); + lblFilter->show(); + cbTemplateFilter->show(); + maze_size_label->hide(); + cbMazeSize->hide(); + emit mapChanged("+rnd+"); + emit themeChanged(chooseMap->itemData(index).toList()[1].toString()); + break; + case MAPGEN_MAZE: + mapgen = MAPGEN_MAZE; + updatePreview(); + gbThemes->show(); + lblFilter->hide(); + cbTemplateFilter->hide(); + maze_size_label->show(); + cbMazeSize->show(); + emit mapChanged("+maze+"); + emit themeChanged(chooseMap->itemData(index).toList()[1].toString()); + break; + case MAPGEN_DRAWN: + mapgen = MAPGEN_DRAWN; + updatePreview(); + gbThemes->show(); + lblFilter->hide(); + cbTemplateFilter->hide(); + maze_size_label->hide(); + cbMazeSize->hide(); + emit mapChanged("+drawn+"); + emit themeChanged(chooseMap->itemData(index).toList()[1].toString()); + break; + default: + mapgen = MAPGEN_MAP; + updatePreview(); + gbThemes->hide(); + lblFilter->hide(); + cbTemplateFilter->hide(); + maze_size_label->hide(); + cbMazeSize->hide(); + emit mapChanged(chooseMap->itemData(index).toList()[0].toString()); } emit mapgenChanged(mapgen); @@ -374,7 +380,7 @@ get_mapgen(), getMazeSize(), getDrawnMapData() - ); + ); } void HWMapContainer::themeSelected(const QModelIndex & current, const QModelIndex &) @@ -440,7 +446,7 @@ void HWMapContainer::resizeEvent ( QResizeEvent * event ) { Q_UNUSED(event); - //imageButt->setIconSize(imageButt->size()); + //imageButt->setIconSize(imageButt->size()); } void HWMapContainer::intSetSeed(const QString & seed) @@ -467,7 +473,8 @@ break; } - if(id > 0) { + if(id > 0) + { if (pMap) { disconnect(pMap, 0, this, SLOT(setImage(const QImage))); @@ -497,19 +504,19 @@ setRandomSeed(); switch(chooseMap->currentIndex()) { - case MAPGEN_REGULAR: - case MAPGEN_MAZE: - setRandomTheme(); - break; - case MAPGEN_DRAWN: - emit drawMapRequested(); - break; - default: - if(chooseMap->currentIndex() <= numMissions + MAPGEN_MAP + 1) - setRandomMission(); - else - setRandomStatic(); - break; + case MAPGEN_REGULAR: + case MAPGEN_MAZE: + setRandomTheme(); + break; + case MAPGEN_DRAWN: + emit drawMapRequested(); + break; + default: + if(chooseMap->currentIndex() <= numMissions + MAPGEN_MAP + 1) + setRandomMission(); + else + setRandomStatic(); + break; } } @@ -641,27 +648,28 @@ switch(curIndex) { - case MAPGEN_REGULAR: - askForGeneratedPreview(); - break; - case MAPGEN_MAZE: - askForGeneratedPreview(); - break; - case MAPGEN_DRAWN: - askForGeneratedPreview(); - break; - default: - QPixmap mapImage; - QFile tmpfile; - tmpfile.setFileName(cfgdir->absolutePath() + "/Data/Maps/" + chooseMap->itemData(curIndex).toList()[0].toString() + "/preview.png"); - if (!tmpfile.exists()) tmpfile.setFileName(datadir->absolutePath() + "/Maps/" + chooseMap->itemData(curIndex).toList()[0].toString() + "/preview.png"); - if(!mapImage.load(QFileInfo(tmpfile).absoluteFilePath())) { - imageButt->setIcon(QIcon()); - return; - } + case MAPGEN_REGULAR: + askForGeneratedPreview(); + break; + case MAPGEN_MAZE: + askForGeneratedPreview(); + break; + case MAPGEN_DRAWN: + askForGeneratedPreview(); + break; + default: + QPixmap mapImage; + QFile tmpfile; + tmpfile.setFileName(cfgdir->absolutePath() + "/Data/Maps/" + chooseMap->itemData(curIndex).toList()[0].toString() + "/preview.png"); + if (!tmpfile.exists()) tmpfile.setFileName(datadir->absolutePath() + "/Maps/" + chooseMap->itemData(curIndex).toList()[0].toString() + "/preview.png"); + if(!mapImage.load(QFileInfo(tmpfile).absoluteFilePath())) + { + imageButt->setIcon(QIcon()); + return; + } - hhLimit = chooseMap->itemData(curIndex).toList()[2].toInt(); - addInfoToPreview(mapImage); + hhLimit = chooseMap->itemData(curIndex).toList()[2].toInt(); + addInfoToPreview(mapImage); } } diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/mapContainer.h --- a/QTfrontend/ui/widget/mapContainer.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/mapContainer.h Mon Jan 30 17:32:18 2012 -0500 @@ -40,89 +40,89 @@ class HWMapContainer : public QWidget { - Q_OBJECT + Q_OBJECT - public: - HWMapContainer(QWidget * parent=0); - QString getCurrentSeed() const; - QString getCurrentMap() const; - QString getCurrentTheme() const; - int getCurrentHHLimit() const; - QString getCurrentScheme() const; - QString getCurrentWeapons() const; - quint32 getTemplateFilter() const; - MapGenerator get_mapgen(void) const; - int getMazeSize(void) const; - bool getCurrentIsMission() const; - QByteArray getDrawnMapData(); - DrawMapScene * getDrawMapScene(); - void mapDrawingFinished(); - QLineEdit* seedEdit; + public: + HWMapContainer(QWidget * parent=0); + QString getCurrentSeed() const; + QString getCurrentMap() const; + QString getCurrentTheme() const; + int getCurrentHHLimit() const; + QString getCurrentScheme() const; + QString getCurrentWeapons() const; + quint32 getTemplateFilter() const; + MapGenerator get_mapgen(void) const; + int getMazeSize(void) const; + bool getCurrentIsMission() const; + QByteArray getDrawnMapData(); + DrawMapScene * getDrawMapScene(); + void mapDrawingFinished(); + QLineEdit* seedEdit; - public slots: - void askForGeneratedPreview(); - void setSeed(const QString & seed); - void setMap(const QString & map); - void setTheme(const QString & theme); - void setTemplateFilter(int); - void setMapgen(MapGenerator m); - void setMazeSize(int size); - void setDrawnMapData(const QByteArray & ar); - void setAllMapParameters(const QString & map, MapGenerator m, int mazesize, const QString & seed, int tmpl); + public slots: + void askForGeneratedPreview(); + void setSeed(const QString & seed); + void setMap(const QString & map); + void setTheme(const QString & theme); + void setTemplateFilter(int); + void setMapgen(MapGenerator m); + void setMazeSize(int size); + void setDrawnMapData(const QByteArray & ar); + void setAllMapParameters(const QString & map, MapGenerator m, int mazesize, const QString & seed, int tmpl); - signals: - void seedChanged(const QString & seed); - void mapChanged(const QString & map); - void themeChanged(const QString & theme); - void newTemplateFilter(int filter); - void mapgenChanged(MapGenerator m); - void mazeSizeChanged(int s); - void drawMapRequested(); - void drawnMapChanged(const QByteArray & data); + signals: + void seedChanged(const QString & seed); + void mapChanged(const QString & map); + void themeChanged(const QString & theme); + void newTemplateFilter(int filter); + void mapgenChanged(MapGenerator m); + void mazeSizeChanged(int s); + void drawMapRequested(); + void drawnMapChanged(const QByteArray & data); - private slots: - void setImage(const QImage newImage); - void setHHLimit(int hhLimit); - void mapChanged(int index); - void setRandomSeed(); - void setRandomTheme(); - void setRandomMap(); - void setRandomStatic(); - void setRandomMission(); - void themeSelected(const QModelIndex & current, const QModelIndex &); - void addInfoToPreview(QPixmap image); - void seedEdited(); + private slots: + void setImage(const QImage newImage); + void setHHLimit(int hhLimit); + void mapChanged(int index); + void setRandomSeed(); + void setRandomTheme(); + void setRandomMap(); + void setRandomStatic(); + void setRandomMission(); + void themeSelected(const QModelIndex & current, const QModelIndex &); + void addInfoToPreview(QPixmap image); + void seedEdited(); - protected: - virtual void resizeEvent ( QResizeEvent * event ); + protected: + virtual void resizeEvent ( QResizeEvent * event ); - private: - QGridLayout mainLayout; - QPushButton* imageButt; - QComboBox* chooseMap; - IconedGroupBox* gbThemes; - QListView* lvThemes; - HWMap* pMap; - QString m_seed; - QPushButton* seedSet; - QLabel* seedLabel; - int hhLimit; - int templateFilter; - QPixmap hhSmall; - QLabel* lblFilter; - QComboBox* cbTemplateFilter; - QLabel *maze_size_label; - QComboBox *cbMazeSize; - MapGenerator mapgen; - int numMissions; - DrawMapScene drawMapScene; + private: + QGridLayout mainLayout; + QPushButton* imageButt; + QComboBox* chooseMap; + IconedGroupBox* gbThemes; + QListView* lvThemes; + HWMap* pMap; + QString m_seed; + QPushButton* seedSet; + QLabel* seedLabel; + int hhLimit; + int templateFilter; + QPixmap hhSmall; + QLabel* lblFilter; + QComboBox* cbTemplateFilter; + QLabel *maze_size_label; + QComboBox *cbMazeSize; + MapGenerator mapgen; + int numMissions; + DrawMapScene drawMapScene; - void intSetSeed(const QString & seed); - void intSetMap(const QString & map); - void intSetMapgen(MapGenerator m); - void intSetTemplateFilter(int); - void intSetMazeSize(int size); - void updatePreview(); + void intSetSeed(const QString & seed); + void intSetMap(const QString & map); + void intSetMapgen(MapGenerator m); + void intSetTemplateFilter(int); + void intSetMazeSize(int size); + void updatePreview(); }; #endif // _HWMAP_CONTAINER_INCLUDED diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/qpushbuttonwithsound.h --- a/QTfrontend/ui/widget/qpushbuttonwithsound.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/qpushbuttonwithsound.h Mon Jan 30 17:32:18 2012 -0500 @@ -5,16 +5,16 @@ class QPushButtonWithSound : public QPushButton { - Q_OBJECT -public: - explicit QPushButtonWithSound(QWidget *parent = 0); - bool isSoundEnabled; -signals: - -public slots: -private slots: - void buttonClicked(); - + Q_OBJECT + public: + explicit QPushButtonWithSound(QWidget *parent = 0); + bool isSoundEnabled; + signals: + + public slots: + private slots: + void buttonClicked(); + }; #endif // QPUSHBUTTONWITHSOUND_H diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/selectWeapon.cpp --- a/QTfrontend/ui/widget/selectWeapon.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/selectWeapon.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -81,8 +81,8 @@ } SelWeaponWidget::SelWeaponWidget(int numItems, QWidget* parent) : - QFrame(parent), - m_numItems(numItems) + QFrame(parent), + m_numItems(numItems) { wconf = new QSettings(cfgdir->absolutePath() + "/weapons.ini", QSettings::IniFormat, this); @@ -127,7 +127,8 @@ int j = -1; int i = 0, k = 0; - for(; i < m_numItems; ++i) { + for(; i < m_numItems; ++i) + { if (i == 6) continue; if (k % 4 == 0) ++j; SelWeaponItem * swi = new SelWeaponItem(true, i, currentState[i].digitValue(), QImage(":/res/ammopic.png"), QImage(":/res/ammopicgrey.png"), this); @@ -158,10 +159,12 @@ { bool enable = true; for(int i = 0; i < cDefaultAmmos.size(); i++) - if (!cDefaultAmmos[i].first.compare(m_name->text())) { + if (!cDefaultAmmos[i].first.compare(m_name->text())) + { enable = false; } - for(int i = 0; i < m_numItems; ++i) { + for(int i = 0; i < m_numItems; ++i) + { twi::iterator it = weaponItems.find(i); if (it == weaponItems.end()) continue; it.value()[0]->setItemsNum(ammo[i].digitValue()); @@ -179,7 +182,8 @@ void SelWeaponWidget::setDefault() { for(int i = 0; i < cDefaultAmmos.size(); i++) - if (!cDefaultAmmos[i].first.compare(m_name->text())) { + if (!cDefaultAmmos[i].first.compare(m_name->text())) + { return; } setWeapons(*cDefaultAmmoStore); @@ -188,7 +192,8 @@ void SelWeaponWidget::save() { for(int i = 0; i < cDefaultAmmos.size(); i++) - if (!cDefaultAmmos[i].first.compare(m_name->text())) { + if (!cDefaultAmmos[i].first.compare(m_name->text())) + { QMessageBox::warning(0, QMessageBox::tr("Weapons"), QMessageBox::tr("Can not overwrite default weapon set '%1'!").arg(cDefaultAmmos[i].first)); return; } @@ -200,7 +205,8 @@ QString state3; QString state4; - for(int i = 0; i < m_numItems; ++i) { + for(int i = 0; i < m_numItems; ++i) + { twi::const_iterator it = weaponItems.find(i); int num = it == weaponItems.end() ? 9 : it.value()[0]->getItemsNum(); // 9 is for 'skip turn' state1.append(QString::number(num)); @@ -211,7 +217,8 @@ int am = it == weaponItems.end() ? 0 : it.value()[3]->getItemsNum(); state4.append(QString::number(am)); } - if (curWeaponsName != "") { + if (curWeaponsName != "") + { // remove old entry wconf->remove(curWeaponsName); } @@ -235,14 +242,16 @@ if (curWeaponsName == "") return; for(int i = 0; i < cDefaultAmmos.size(); i++) - if (!cDefaultAmmos[i].first.compare(m_name->text())) { + if (!cDefaultAmmos[i].first.compare(m_name->text())) + { QMessageBox::warning(0, QMessageBox::tr("Weapons"), QMessageBox::tr("Can not delete default weapon set '%1'!").arg(cDefaultAmmos[i].first)); return; } QMessageBox reallyDelete(QMessageBox::Question, QMessageBox::tr("Weapons"), QMessageBox::tr("Really delete this weapon set?"), QMessageBox::Ok | QMessageBox::Cancel); - if (reallyDelete.exec() == QMessageBox::Ok) { + if (reallyDelete.exec() == QMessageBox::Ok) + { wconf->remove(curWeaponsName); emit weaponsDeleted(); } @@ -251,7 +260,8 @@ void SelWeaponWidget::newWeaponsName() { QString newName = tr("new"); - if(wconf->contains(newName)) { + if(wconf->contains(newName)) + { //name already used -> look for an appropriate name: int i=2; while(wconf->contains(newName = tr("new")+QString::number(i++))) ; @@ -265,9 +275,12 @@ curWeaponsName = name; - if(name != "" && wconf->contains(name)) { + if(name != "" && wconf->contains(name)) + { setWeapons(wconf->value(name).toString()); - } else { + } + else + { setWeapons(*cDefaultAmmoStore); } } @@ -279,10 +292,12 @@ void SelWeaponWidget::copy() { - if(wconf->contains(curWeaponsName)) { + if(wconf->contains(curWeaponsName)) + { QString ammo = getWeaponsString(curWeaponsName); QString newName = tr("copy of") + " " + curWeaponsName; - if(wconf->contains(newName)) { + if(wconf->contains(newName)) + { //name already used -> look for an appropriate name: int i=2; while(wconf->contains(newName = tr("copy of") + " " + curWeaponsName+QString::number(i++))) ; diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/selectWeapon.h --- a/QTfrontend/ui/widget/selectWeapon.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/selectWeapon.h Mon Jan 30 17:32:18 2012 -0500 @@ -31,62 +31,62 @@ class SelWeaponItem : public QWidget { - Q_OBJECT + Q_OBJECT -public: - SelWeaponItem(bool allowInfinite, int iconNum, int wNum, QImage image, QImage imagegrey, QWidget* parent=0); + public: + SelWeaponItem(bool allowInfinite, int iconNum, int wNum, QImage image, QImage imagegrey, QWidget* parent=0); - unsigned char getItemsNum() const; - void setItemsNum(const unsigned char num); - void setEnabled(bool value); + unsigned char getItemsNum() const; + void setItemsNum(const unsigned char num); + void setEnabled(bool value); - private: - WeaponItem* item; + private: + WeaponItem* item; }; class SelWeaponWidget : public QFrame { - Q_OBJECT + Q_OBJECT - public: - SelWeaponWidget(int numItems, QWidget* parent=0); - QString getWeaponsString(const QString& name) const; - QStringList getWeaponNames() const; + public: + SelWeaponWidget(int numItems, QWidget* parent=0); + QString getWeaponsString(const QString& name) const; + QStringList getWeaponNames() const; - public slots: - void setDefault(); - void setWeapons(const QString& ammo); - //sets the name of the current set - void setWeaponsName(const QString& name); - void deleteWeaponsName(); - void newWeaponsName(); - void save(); - void copy(); + public slots: + void setDefault(); + void setWeapons(const QString& ammo); + //sets the name of the current set + void setWeaponsName(const QString& name); + void deleteWeaponsName(); + void newWeaponsName(); + void save(); + void copy(); - signals: - void weaponsChanged(); - void weaponsDeleted(); + signals: + void weaponsChanged(); + void weaponsDeleted(); - private: - //the name of the current weapon set - QString curWeaponsName; + private: + //the name of the current weapon set + QString curWeaponsName; - QLineEdit* m_name; + QLineEdit* m_name; - //storage for all the weapons sets - QSettings* wconf; + //storage for all the weapons sets + QSettings* wconf; - const int m_numItems; - int operator [] (unsigned int weaponIndex) const; + const int m_numItems; + int operator [] (unsigned int weaponIndex) const; - typedef QList ItemsList; - typedef QMap twi; - twi weaponItems; - //layout element for each tab: - QGridLayout* p1Layout; - QGridLayout* p2Layout; - QGridLayout* p3Layout; - QGridLayout* p4Layout; + typedef QList ItemsList; + typedef QMap twi; + twi weaponItems; + //layout element for each tab: + QGridLayout* p1Layout; + QGridLayout* p2Layout; + QGridLayout* p3Layout; + QGridLayout* p4Layout; }; #endif // _SELECT_WEAPON_INCLUDED diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/teamselect.cpp --- a/QTfrontend/ui/widget/teamselect.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/teamselect.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -32,28 +32,34 @@ void TeamSelWidget::addTeam(HWTeam team) { - if(team.isNetTeam()) { - framePlaying->addTeam(team, true); - curPlayingTeams.push_back(team); - connect(framePlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), - this, SLOT(netTeamStatusChanged(const HWTeam&))); - connect(framePlaying->getTeamWidget(team), SIGNAL(hhNmChanged(const HWTeam&)), + if(team.isNetTeam()) + { + framePlaying->addTeam(team, true); + curPlayingTeams.push_back(team); + connect(framePlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), + this, SLOT(netTeamStatusChanged(const HWTeam&))); + connect(framePlaying->getTeamWidget(team), SIGNAL(hhNmChanged(const HWTeam&)), this, SLOT(hhNumChanged(const HWTeam&))); - dynamic_cast(framePlaying->getTeamWidget(team))->hhNumChanged(); - connect(framePlaying->getTeamWidget(team), SIGNAL(teamColorChanged(const HWTeam&)), + dynamic_cast(framePlaying->getTeamWidget(team))->hhNumChanged(); + connect(framePlaying->getTeamWidget(team), SIGNAL(teamColorChanged(const HWTeam&)), this, SLOT(proxyTeamColorChanged(const HWTeam&))); - } else { - frameDontPlaying->addTeam(team, false); - m_curNotPlayingTeams.push_back(team); - if(m_acceptOuter) { - connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), - this, SLOT(pre_changeTeamStatus(HWTeam))); - } else { - connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), - this, SLOT(changeTeamStatus(HWTeam))); } - } - emit setEnabledGameStart(curPlayingTeams.size()>1); + else + { + frameDontPlaying->addTeam(team, false); + m_curNotPlayingTeams.push_back(team); + if(m_acceptOuter) + { + connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), + this, SLOT(pre_changeTeamStatus(HWTeam))); + } + else + { + connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), + this, SLOT(changeTeamStatus(HWTeam))); + } + } + emit setEnabledGameStart(curPlayingTeams.size()>1); } void TeamSelWidget::setInteractivity(bool interactive) @@ -87,15 +93,15 @@ void TeamSelWidget::changeHHNum(const HWTeam& team) { - QList::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); + QList::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); if(itPlay==curPlayingTeams.end()) { qWarning() << QString("changeHHNum: team '%1' not found").arg(team.name()); return; } - itPlay->setNumHedgehogs(team.numHedgehogs()); + itPlay->setNumHedgehogs(team.numHedgehogs()); - framePlaying->setHHNum(team); + framePlaying->setHHNum(team); } void TeamSelWidget::changeTeamColor(const HWTeam& team) @@ -114,14 +120,16 @@ void TeamSelWidget::removeNetTeam(const HWTeam& team) { //qDebug() << QString("removeNetTeam: removing team '%1'").arg(team.TeamName); - for(;;) { + for(;;) + { QList::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); if(itPlay==curPlayingTeams.end()) { qWarning() << QString("removeNetTeam: team '%1' not found").arg(team.name()); break; } - if(itPlay->isNetTeam()) { + if(itPlay->isNetTeam()) + { QObject::disconnect(framePlaying->getTeamWidget(*itPlay), SIGNAL(teamStatusChanged(HWTeam))); framePlaying->removeTeam(team); curPlayingTeams.erase(itPlay); @@ -133,74 +141,85 @@ void TeamSelWidget::netTeamStatusChanged(const HWTeam& team) { - QList::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); + QList::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); } //void TeamSelWidget::removeTeam(__attribute__ ((unused)) HWTeam team) //{ - //curDontPlayingTeams.erase(std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team)); +//curDontPlayingTeams.erase(std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team)); //} void TeamSelWidget::changeTeamStatus(HWTeam team) { - QList::iterator itDontPlay=std::find(m_curNotPlayingTeams.begin(), m_curNotPlayingTeams.end(), team); - QList::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); + QList::iterator itDontPlay=std::find(m_curNotPlayingTeams.begin(), m_curNotPlayingTeams.end(), team); + QList::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); - bool willBePlaying=itDontPlay!=m_curNotPlayingTeams.end(); + bool willBePlaying=itDontPlay!=m_curNotPlayingTeams.end(); - if(!willBePlaying) { - // playing team => dont playing - m_curNotPlayingTeams.push_back(*itPlay); - emit teamNotPlaying(*itPlay); - curPlayingTeams.erase(itPlay); - } else { - // return if max playing teams reached - if(framePlaying->isFullTeams()) return; - // dont playing team => playing - team=*itDontPlay; // for net team info saving in framePlaying (we have only name with netID from network) - itDontPlay->setColor(framePlaying->getNextColor()); - curPlayingTeams.push_back(*itDontPlay); - if(!m_acceptOuter) emit teamWillPlay(*itDontPlay); - m_curNotPlayingTeams.erase(itDontPlay); - } + if(!willBePlaying) + { + // playing team => dont playing + m_curNotPlayingTeams.push_back(*itPlay); + emit teamNotPlaying(*itPlay); + curPlayingTeams.erase(itPlay); + } + else + { + // return if max playing teams reached + if(framePlaying->isFullTeams()) return; + // dont playing team => playing + team=*itDontPlay; // for net team info saving in framePlaying (we have only name with netID from network) + itDontPlay->setColor(framePlaying->getNextColor()); + curPlayingTeams.push_back(*itDontPlay); + if(!m_acceptOuter) emit teamWillPlay(*itDontPlay); + m_curNotPlayingTeams.erase(itDontPlay); + } - FrameTeams* pRemoveTeams; - FrameTeams* pAddTeams; - if(!willBePlaying) { - pRemoveTeams=framePlaying; - pAddTeams=frameDontPlaying; - } else { - pRemoveTeams=frameDontPlaying; - pAddTeams=framePlaying; - } + FrameTeams* pRemoveTeams; + FrameTeams* pAddTeams; + if(!willBePlaying) + { + pRemoveTeams=framePlaying; + pAddTeams=frameDontPlaying; + } + else + { + pRemoveTeams=frameDontPlaying; + pAddTeams=framePlaying; + } - pAddTeams->addTeam(team, willBePlaying); - pRemoveTeams->removeTeam(team); - if(!team.isNetTeam() && m_acceptOuter && !willBePlaying) { - connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), - this, SLOT(pre_changeTeamStatus(HWTeam))); - } else { - connect(pAddTeams->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), - this, SLOT(changeTeamStatus(HWTeam))); - } - if(willBePlaying) { - connect(framePlaying->getTeamWidget(team), SIGNAL(hhNmChanged(const HWTeam&)), - this, SLOT(hhNumChanged(const HWTeam&))); - dynamic_cast(framePlaying->getTeamWidget(team))->hhNumChanged(); - connect(framePlaying->getTeamWidget(team), SIGNAL(teamColorChanged(const HWTeam&)), - this, SLOT(proxyTeamColorChanged(const HWTeam&))); - emit teamColorChanged(((TeamShowWidget*)framePlaying->getTeamWidget(team))->getTeam()); - } + pAddTeams->addTeam(team, willBePlaying); + pRemoveTeams->removeTeam(team); + if(!team.isNetTeam() && m_acceptOuter && !willBePlaying) + { + connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), + this, SLOT(pre_changeTeamStatus(HWTeam))); + } + else + { + connect(pAddTeams->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), + this, SLOT(changeTeamStatus(HWTeam))); + } + if(willBePlaying) + { + connect(framePlaying->getTeamWidget(team), SIGNAL(hhNmChanged(const HWTeam&)), + this, SLOT(hhNumChanged(const HWTeam&))); + dynamic_cast(framePlaying->getTeamWidget(team))->hhNumChanged(); + connect(framePlaying->getTeamWidget(team), SIGNAL(teamColorChanged(const HWTeam&)), + this, SLOT(proxyTeamColorChanged(const HWTeam&))); + emit teamColorChanged(((TeamShowWidget*)framePlaying->getTeamWidget(team))->getTeam()); + } - QSize szh=pAddTeams->sizeHint(); - QSize szh1=pRemoveTeams->sizeHint(); - if(szh.isValid() && szh1.isValid()) { - pAddTeams->resize(pAddTeams->size().width(), szh.height()); - pRemoveTeams->resize(pRemoveTeams->size().width(), szh1.height()); - } + QSize szh=pAddTeams->sizeHint(); + QSize szh1=pRemoveTeams->sizeHint(); + if(szh.isValid() && szh1.isValid()) + { + pAddTeams->resize(pAddTeams->size().width(), szh.height()); + pRemoveTeams->resize(pRemoveTeams->size().width(), szh1.height()); + } - emit setEnabledGameStart(curPlayingTeams.size()>1); + emit setEnabledGameStart(curPlayingTeams.size()>1); } void TeamSelWidget::addScrArea(FrameTeams* pfteams, QColor color, int fixedHeight) @@ -213,18 +232,18 @@ area->setMinimumHeight(fixedHeight); area->setMaximumHeight(fixedHeight); area->setStyleSheet( - "FrameTeams{" - "border: solid;" - "border-width: 1px;" - "border-radius: 16px;" - "border-color: #ffcc00;" - "}" + "FrameTeams{" + "border: solid;" + "border-width: 1px;" + "border-radius: 16px;" + "border-color: #ffcc00;" + "}" ); } } TeamSelWidget::TeamSelWidget(QWidget* parent) : - QGroupBox(parent), mainLayout(this), m_acceptOuter(false) + QGroupBox(parent), mainLayout(this), m_acceptOuter(false) { setTitle(QGroupBox::tr("Playing teams")); framePlaying = new FrameTeams(); @@ -238,44 +257,44 @@ void TeamSelWidget::setAcceptOuter(bool acceptOuter) { - m_acceptOuter=acceptOuter; + m_acceptOuter=acceptOuter; } void TeamSelWidget::resetPlayingTeams(const QList& teamslist) { - //for(it=curPlayingTeams.begin(); it!=curPlayingTeams.end(); it++) { - //framePlaying->removeTeam(*it); - //} - framePlaying->resetTeams(); - framePlaying->resetColors(); - curPlayingTeams.clear(); - //for(it=curDontPlayingTeams.begin(); it!=curDontPlayingTeams.end(); it++) { - //frameDontPlaying->removeTeam(*it); - //} - frameDontPlaying->resetTeams(); - m_curNotPlayingTeams.clear(); + //for(it=curPlayingTeams.begin(); it!=curPlayingTeams.end(); it++) { + //framePlaying->removeTeam(*it); + //} + framePlaying->resetTeams(); + framePlaying->resetColors(); + curPlayingTeams.clear(); + //for(it=curDontPlayingTeams.begin(); it!=curDontPlayingTeams.end(); it++) { + //frameDontPlaying->removeTeam(*it); + //} + frameDontPlaying->resetTeams(); + m_curNotPlayingTeams.clear(); - foreach(HWTeam team, teamslist) + foreach(HWTeam team, teamslist) addTeam(team); } bool TeamSelWidget::isPlaying(HWTeam team) const { - return std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team)!=curPlayingTeams.end(); + return std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team)!=curPlayingTeams.end(); } QList TeamSelWidget::getPlayingTeams() const { - return curPlayingTeams; + return curPlayingTeams; } QList TeamSelWidget::getNotPlayingTeams() const { - return m_curNotPlayingTeams; + return m_curNotPlayingTeams; } void TeamSelWidget::pre_changeTeamStatus(HWTeam team) { - team.setColor(framePlaying->getNextColor()); - emit acceptRequested(team); + team.setColor(framePlaying->getNextColor()); + emit acceptRequested(team); } diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/teamselect.h --- a/QTfrontend/ui/widget/teamselect.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/teamselect.h Mon Jan 30 17:32:18 2012 -0500 @@ -36,48 +36,48 @@ class TeamSelWidget : public QGroupBox { - Q_OBJECT + Q_OBJECT - public: - TeamSelWidget(QWidget* parent); - void setAcceptOuter(bool acceptOuter); - void removeNetTeam(const HWTeam& team); - void resetPlayingTeams(const QList& teamslist); - bool isPlaying(HWTeam team) const; - QList getPlayingTeams() const; - QList getNotPlayingTeams() const; - void setInteractivity(bool interactive); + public: + TeamSelWidget(QWidget* parent); + void setAcceptOuter(bool acceptOuter); + void removeNetTeam(const HWTeam& team); + void resetPlayingTeams(const QList& teamslist); + bool isPlaying(HWTeam team) const; + QList getPlayingTeams() const; + QList getNotPlayingTeams() const; + void setInteractivity(bool interactive); - public slots: - void addTeam(HWTeam team); - void netTeamStatusChanged(const HWTeam& team); - void changeHHNum(const HWTeam&); - void changeTeamColor(const HWTeam&); - void changeTeamStatus(HWTeam team); + public slots: + void addTeam(HWTeam team); + void netTeamStatusChanged(const HWTeam& team); + void changeHHNum(const HWTeam&); + void changeTeamColor(const HWTeam&); + void changeTeamStatus(HWTeam team); - signals: - void setEnabledGameStart(bool); - void teamWillPlay(HWTeam team); - void teamNotPlaying(const HWTeam& team); - void hhogsNumChanged(const HWTeam&); - void teamColorChanged(const HWTeam&); - void acceptRequested(HWTeam team); + signals: + void setEnabledGameStart(bool); + void teamWillPlay(HWTeam team); + void teamNotPlaying(const HWTeam& team); + void hhogsNumChanged(const HWTeam&); + void teamColorChanged(const HWTeam&); + void acceptRequested(HWTeam team); - private slots: - void pre_changeTeamStatus(HWTeam); - void hhNumChanged(const HWTeam& team); - void proxyTeamColorChanged(const HWTeam& team); + private slots: + void pre_changeTeamStatus(HWTeam); + void hhNumChanged(const HWTeam& team); + void proxyTeamColorChanged(const HWTeam& team); - private: - void addScrArea(FrameTeams* pfteams, QColor color, int maxHeight); - FrameTeams* frameDontPlaying; - FrameTeams* framePlaying; + private: + void addScrArea(FrameTeams* pfteams, QColor color, int maxHeight); + FrameTeams* frameDontPlaying; + FrameTeams* framePlaying; - QVBoxLayout mainLayout; - bool m_acceptOuter; + QVBoxLayout mainLayout; + bool m_acceptOuter; - QList curPlayingTeams; - QList m_curNotPlayingTeams; + QList curPlayingTeams; + QList m_curNotPlayingTeams; }; #endif // _TEAM_SELECT_INCLUDED diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/teamselhelper.cpp --- a/QTfrontend/ui/widget/teamselhelper.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/teamselhelper.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -29,12 +29,12 @@ void TeamLabel::teamButtonClicked() { - emit teamActivated(text()); + emit teamActivated(text()); } TeamShowWidget::TeamShowWidget(HWTeam team, bool isPlaying, QWidget * parent) : - QWidget(parent), mainLayout(this), m_team(team), m_isPlaying(isPlaying), phhoger(0), - colorButt(0) + QWidget(parent), mainLayout(this), m_team(team), m_isPlaying(isPlaying), phhoger(0), + colorButt(0) { QPalette newPalette = palette(); newPalette.setColor(QPalette::Window, QColor(0x00, 0x00, 0x00)); @@ -46,24 +46,25 @@ this->setMaximumHeight(38); this->setMinimumHeight(38); QIcon difficultyIcon=team.isNetTeam() ? - QIcon(QString(":/res/botlevels/net%1.png").arg(m_team.difficulty())) - : QIcon(QString(":/res/botlevels/%1.png").arg(m_team.difficulty())); + QIcon(QString(":/res/botlevels/net%1.png").arg(m_team.difficulty())) + : QIcon(QString(":/res/botlevels/%1.png").arg(m_team.difficulty())); butt = new QPushButton(difficultyIcon, team.name().replace("&","&&"), this); butt->setFlat(true); butt->setToolTip(team.owner()); mainLayout.addWidget(butt); butt->setStyleSheet("QPushButton{" - "icon-size: 48px;" - "text-align: left;" - "background-color: #0d0544;" - "color: orange;" - "font: bold;" - "border-width: 2px;" - "margin: 6px 0px 6px 0px;" - "}"); + "icon-size: 48px;" + "text-align: left;" + "background-color: #0d0544;" + "color: orange;" + "font: bold;" + "border-width: 2px;" + "margin: 6px 0px 6px 0px;" + "}"); - if(m_isPlaying) { + if(m_isPlaying) + { // team color colorButt = new QPushButton(this); colorButt->setMaximumWidth(26); @@ -78,7 +79,9 @@ connect(phhoger, SIGNAL(hedgehogsNumChanged()), this, SLOT(hhNumChanged())); phhoger->setHHNum(team.numHedgehogs()); mainLayout.addWidget(phhoger); - } else { + } + else + { } QObject::connect(butt, SIGNAL(clicked()), this, SLOT(activateTeam())); @@ -87,7 +90,8 @@ void TeamShowWidget::setInteractivity(bool interactive) { - if(m_team.isNetTeam()) { + if(m_team.isNetTeam()) + { butt->setEnabled(interactive); } @@ -97,18 +101,18 @@ void TeamShowWidget::setHHNum(unsigned int num) { - phhoger->setHHNum(num); + phhoger->setHHNum(num); } void TeamShowWidget::hhNumChanged() { - m_team.setNumHedgehogs(phhoger->getHedgehogsNum()); - emit hhNmChanged(m_team); + m_team.setNumHedgehogs(phhoger->getHedgehogsNum()); + emit hhNmChanged(m_team); } void TeamShowWidget::activateTeam() { - emit teamStatusChanged(m_team); + emit teamStatusChanged(m_team); } /*HWTeamTempParams TeamShowWidget::getTeamParams() const @@ -123,26 +127,31 @@ void TeamShowWidget::changeTeamColor(QColor color) { FrameTeams* pOurFrameTeams=dynamic_cast(parentWidget()); - if(!color.isValid()) { - if(++pOurFrameTeams->currentColor==pOurFrameTeams->availableColors.end()) { + if(!color.isValid()) + { + if(++pOurFrameTeams->currentColor==pOurFrameTeams->availableColors.end()) + { pOurFrameTeams->currentColor=pOurFrameTeams->availableColors.begin(); } color=*pOurFrameTeams->currentColor; - } else { + } + else + { // set according color iterator pOurFrameTeams->currentColor=std::find(pOurFrameTeams->availableColors.begin(), - pOurFrameTeams->availableColors.end(), color); - if(pOurFrameTeams->currentColor==pOurFrameTeams->availableColors.end()) { + pOurFrameTeams->availableColors.end(), color); + if(pOurFrameTeams->currentColor==pOurFrameTeams->availableColors.end()) + { // error condition pOurFrameTeams->currentColor=pOurFrameTeams->availableColors.begin(); } } colorButt->setStyleSheet(QString("QPushButton{" - "background-color: %1;" - "border-width: 1px;" - "border-radius: 2px;" - "}").arg(pOurFrameTeams->currentColor->name())); + "background-color: %1;" + "border-width: 1px;" + "border-radius: 2px;" + "}").arg(pOurFrameTeams->currentColor->name())); m_team.setColor(color); emit teamColorChanged(m_team); @@ -150,5 +159,5 @@ HWTeam TeamShowWidget::getTeam() const { - return m_team; + return m_team; } diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/teamselhelper.h --- a/QTfrontend/ui/widget/teamselhelper.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/teamselhelper.h Mon Jan 30 17:32:18 2012 -0500 @@ -30,51 +30,51 @@ class TeamLabel : public QLabel { - Q_OBJECT + Q_OBJECT - public: - TeamLabel(const QString& inp_str) : QLabel(inp_str) {}; + public: + TeamLabel(const QString& inp_str) : QLabel(inp_str) {}; - signals: - void teamActivated(QString team_name); + signals: + void teamActivated(QString team_name); - public slots: - void teamButtonClicked(); + public slots: + void teamButtonClicked(); }; class TeamShowWidget : public QWidget { - Q_OBJECT + Q_OBJECT - public slots: - void changeTeamColor(QColor color=QColor()); - void hhNumChanged(); + public slots: + void changeTeamColor(QColor color=QColor()); + void hhNumChanged(); - private slots: - void activateTeam(); + private slots: + void activateTeam(); - public: - TeamShowWidget(HWTeam team, bool isPlaying, QWidget * parent); - void setPlaying(bool isPlaying); - void setHHNum(unsigned int num); - void setInteractivity(bool interactive); - HWTeam getTeam() const; + public: + TeamShowWidget(HWTeam team, bool isPlaying, QWidget * parent); + void setPlaying(bool isPlaying); + void setHHNum(unsigned int num); + void setInteractivity(bool interactive); + HWTeam getTeam() const; - private: - TeamShowWidget(); - QHBoxLayout mainLayout; - HWTeam m_team; - bool m_isPlaying; - CHedgehogerWidget* phhoger; - QPushButton* colorButt; - QPushButton* butt; + private: + TeamShowWidget(); + QHBoxLayout mainLayout; + HWTeam m_team; + bool m_isPlaying; + CHedgehogerWidget* phhoger; + QPushButton* colorButt; + QPushButton* butt; // QPushButton* bText; - signals: - void teamStatusChanged(HWTeam team); - void hhNmChanged(const HWTeam&); - void teamColorChanged(const HWTeam&); + signals: + void teamStatusChanged(HWTeam team); + void hhNmChanged(const HWTeam&); + void teamColorChanged(const HWTeam&); }; #endif // _TEAMSEL_HELPER_INCLUDED diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/togglebutton.h --- a/QTfrontend/ui/widget/togglebutton.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/togglebutton.h Mon Jan 30 17:32:18 2012 -0500 @@ -28,15 +28,15 @@ class ToggleButtonWidget : public QPushButton { - Q_OBJECT -public: - ToggleButtonWidget(QWidget * parent, QString img); - ~ToggleButtonWidget(); -private: - QPixmap pmChecked; - QPixmap pmDisabled; -private slots: - void eventToggled(bool checked); + Q_OBJECT + public: + ToggleButtonWidget(QWidget * parent, QString img); + ~ToggleButtonWidget(); + private: + QPixmap pmChecked; + QPixmap pmDisabled; + private slots: + void eventToggled(bool checked); }; #endif // TOGGLEBUTTONWIDGET_H diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/vertScrollArea.cpp --- a/QTfrontend/ui/widget/vertScrollArea.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/vertScrollArea.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -22,7 +22,7 @@ #include VertScrArea::VertScrArea(QColor frameColor, QWidget * parent) : - QScrollArea(parent) + QScrollArea(parent) { QPalette newPalette = palette(); newPalette.setColor(QPalette::Background, frameColor); diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/vertScrollArea.h --- a/QTfrontend/ui/widget/vertScrollArea.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/vertScrollArea.h Mon Jan 30 17:32:18 2012 -0500 @@ -24,13 +24,13 @@ class VertScrArea : public QScrollArea { - Q_OBJECT + Q_OBJECT -public: - VertScrArea(QColor frameColor, QWidget * parent = 0); + public: + VertScrArea(QColor frameColor, QWidget * parent = 0); -protected: - virtual void resizeEvent(QResizeEvent * event); + protected: + virtual void resizeEvent(QResizeEvent * event); }; #endif // _VERT_SCROLL_AREA_INCLUDED diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/weaponItem.cpp --- a/QTfrontend/ui/widget/weaponItem.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/weaponItem.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -20,7 +20,7 @@ #include "weaponItem.h" WeaponItem::WeaponItem(const QImage& im, const QImage& img, QWidget * parent) : - ItemNum(im, img, parent, 0) + ItemNum(im, img, parent, 0) { } @@ -30,11 +30,11 @@ void WeaponItem::incItems() { - ++numItems; + ++numItems; } void WeaponItem::decItems() { - --numItems; + --numItems; } diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui/widget/weaponItem.h --- a/QTfrontend/ui/widget/weaponItem.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui/widget/weaponItem.h Mon Jan 30 17:32:18 2012 -0500 @@ -24,21 +24,21 @@ class WeaponItem : public ItemNum { - Q_OBJECT + Q_OBJECT - public: - WeaponItem(const QImage& im, const QImage& img, QWidget * parent); - virtual ~WeaponItem(); + public: + WeaponItem(const QImage& im, const QImage& img, QWidget * parent); + virtual ~WeaponItem(); - signals: - void hedgehogsNumChanged(); + signals: + void hedgehogsNumChanged(); - protected: - virtual void incItems(); - virtual void decItems(); + protected: + virtual void incItems(); + virtual void decItems(); - private: - WeaponItem(); + private: + WeaponItem(); }; #endif // _WEAPON_ITEM diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/ui_hwform.h --- a/QTfrontend/ui_hwform.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/ui_hwform.h Mon Jan 30 17:32:18 2012 -0500 @@ -51,40 +51,40 @@ class Ui_HWForm { -public: - QWidget *centralWidget; + public: + QWidget *centralWidget; - PageMain *pageMain; - PageEditTeam *pageEditTeam; - PageMultiplayer *pageMultiplayer; - PagePlayDemo *pagePlayDemo; - PageOptions *pageOptions; - PageFeedback *pageFeedback; - PageNet *pageNet; - PageNetServer * pageNetServer; - PageNetChat *pageNetChat; - PageNetGame *pageNetGame; - PageInfo *pageInfo; - PageDataDownload *pageDataDownload; - PageGameStats *pageGameStats; - PageSinglePlayer *pageSinglePlayer; - PageTraining *pageTraining; - PageSelectWeapon *pageSelectWeapon; - PageInGame *pageInGame; - PageRoomsList *pageRoomsList; - PageConnecting *pageConnecting; - PageScheme *pageScheme; - PageAdmin *pageAdmin; - PageNetType *pageNetType; - PageCampaign *pageCampaign; - PageDrawMap *pageDrawMap; + PageMain *pageMain; + PageEditTeam *pageEditTeam; + PageMultiplayer *pageMultiplayer; + PagePlayDemo *pagePlayDemo; + PageOptions *pageOptions; + PageFeedback *pageFeedback; + PageNet *pageNet; + PageNetServer * pageNetServer; + PageNetChat *pageNetChat; + PageNetGame *pageNetGame; + PageInfo *pageInfo; + PageDataDownload *pageDataDownload; + PageGameStats *pageGameStats; + PageSinglePlayer *pageSinglePlayer; + PageTraining *pageTraining; + PageSelectWeapon *pageSelectWeapon; + PageInGame *pageInGame; + PageRoomsList *pageRoomsList; + PageConnecting *pageConnecting; + PageScheme *pageScheme; + PageAdmin *pageAdmin; + PageNetType *pageNetType; + PageCampaign *pageCampaign; + PageDrawMap *pageDrawMap; - QStackedLayout *Pages; - QFont *font14; + QStackedLayout *Pages; + QFont *font14; - void setupUi(HWForm *HWForm); - void SetupFonts(); - void SetupPages(QWidget *Parent, HWForm *HWForm); + void setupUi(HWForm *HWForm); + void SetupFonts(); + void SetupPages(QWidget *Parent, HWForm *HWForm); }; #endif // UI_HWFORM_H diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/util/HWDataManager.cpp --- a/QTfrontend/util/HWDataManager.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/util/HWDataManager.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -50,10 +50,10 @@ QStringList HWDataManager::entryList( - const QString & subDirectory, - QDir::Filters filters, - const QStringList & nameFilters - ) const + const QString & subDirectory, + QDir::Filters filters, + const QStringList & nameFilters +) const { QStringList result; @@ -83,7 +83,7 @@ QString HWDataManager::findFileForRead( - const QString & relativeDataFilePath) const + const QString & relativeDataFilePath) const { QString path; @@ -98,7 +98,7 @@ QString HWDataManager::findFileForWrite( - const QString & relativeDataFilePath) const + const QString & relativeDataFilePath) const { if (userData != NULL) { diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/util/HWDataManager.h --- a/QTfrontend/util/HWDataManager.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/util/HWDataManager.h Mon Jan 30 17:32:18 2012 -0500 @@ -36,72 +36,72 @@ /** * @brief Offers access to the data files of hedgewars. - * + * * @see singleton pattern - * + * * @author sheepluva * @since 0.9.17 */ class HWDataManager { -public: - /** - * @brief Returns reference to the singleton instance of this class. - * - * @see singleton pattern - * - * @return reference to the instance. - */ - static HWDataManager & instance(); + public: + /** + * @brief Returns reference to the singleton instance of this class. + * + * @see singleton pattern + * + * @return reference to the instance. + */ + static HWDataManager & instance(); - /** - * @brief Returns a sorted list of data directory entries. - * - * @param subDirectory sub-directory to search. - * @param filters filters for entry type. - * @param nameFilters filters by name patterns. - * @return a sorted list of matches in the subDirectory of data directory. - */ - QStringList entryList(const QString & subDirectory, - QDir::Filters filters = QDir::NoFilter, - const QStringList & nameFilters = QStringList("*") - ) const; + /** + * @brief Returns a sorted list of data directory entries. + * + * @param subDirectory sub-directory to search. + * @param filters filters for entry type. + * @param nameFilters filters by name patterns. + * @return a sorted list of matches in the subDirectory of data directory. + */ + QStringList entryList(const QString & subDirectory, + QDir::Filters filters = QDir::NoFilter, + const QStringList & nameFilters = QStringList("*") + ) const; - /** - * @brief Returns the path for the desires data file. - * - * Use this method if you want to read an existing data file. - * - * @param relativeDataFilePath relative path of the data file. - * @return real path to the file. - */ - QString findFileForRead(const QString & relativeDataFilePath) const; + /** + * @brief Returns the path for the desires data file. + * + * Use this method if you want to read an existing data file. + * + * @param relativeDataFilePath relative path of the data file. + * @return real path to the file. + */ + QString findFileForRead(const QString & relativeDataFilePath) const; - /** - * @brief Returns the path for the data file that is to be written. - * - * Use this method if you want to create or write into a data file. - * - * @param relativeDataFilePath relative path of data file write path. - * @return destination of path data file. - */ - QString findFileForWrite(const QString & relativeDataFilePath) const; + /** + * @brief Returns the path for the data file that is to be written. + * + * Use this method if you want to create or write into a data file. + * + * @param relativeDataFilePath relative path of data file write path. + * @return destination of path data file. + */ + QString findFileForWrite(const QString & relativeDataFilePath) const; -private: - /** - * @brief Class constructor of the singleton. - * - * Not to be used from outside the class, - * use the static {@link HWDataManager::instance()} instead. - * - * @see singleton pattern - */ - HWDataManager(); + private: + /** + * @brief Class constructor of the singleton. + * + * Not to be used from outside the class, + * use the static {@link HWDataManager::instance()} instead. + * + * @see singleton pattern + */ + HWDataManager(); - QDir * defaultData; ///< directory of the installed data - QDir * userData; ///< directory of custom data in the user's directory + QDir * defaultData; ///< directory of the installed data + QDir * userData; ///< directory of custom data in the user's directory }; #endif // HEDGEWARS_HWDATAMANAGER_H diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/util/SDLInteraction.cpp --- a/QTfrontend/util/SDLInteraction.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/util/SDLInteraction.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -63,7 +63,8 @@ stopMusic(); if (m_audioInitialized) { - if (m_music != NULL) { + if (m_music != NULL) + { Mix_HaltMusic(); Mix_FreeMusic(m_music); } @@ -86,7 +87,8 @@ if((modes == (SDL_Rect **)0) || (modes == (SDL_Rect **)-1)) { result << "640x480"; - } else + } + else { for(int i = 0; modes[i]; ++i) if ((modes[i]->w >= 640) && (modes[i]->h >= 480)) @@ -239,9 +241,11 @@ void SDLInteraction::stopMusic() { - if (m_isPlayingMusic && (m_music != NULL)) { + if (m_isPlayingMusic && (m_music != NULL)) + { // fade out music to finish 0,5 seconds from now - while(!Mix_FadeOutMusic(1000) && Mix_PlayingMusic()) { + while(!Mix_FadeOutMusic(1000) && Mix_PlayingMusic()) + { SDL_Delay(100); } } diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/util/SDLInteraction.h --- a/QTfrontend/util/SDLInteraction.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/util/SDLInteraction.h Mon Jan 30 17:32:18 2012 -0500 @@ -32,77 +32,77 @@ /** * @brief Class for interacting with SDL (used for music and keys) - * + * * @see singleton pattern */ class SDLInteraction { -private: - /** - * @brief Class constructor of the singleton. - * - * Not to be used from outside the class, - * use the static {@link HWDataManager::instance()} instead. - * - * @see singleton pattern - */ - SDLInteraction(); + private: + /** + * @brief Class constructor of the singleton. + * + * Not to be used from outside the class, + * use the static {@link HWDataManager::instance()} instead. + * + * @see singleton pattern + */ + SDLInteraction(); - /// Initializes SDL for sound output if needed. - void SDLAudioInit(); + /// Initializes SDL for sound output if needed. + void SDLAudioInit(); - bool m_audioInitialized; ///< true if audio is initialized already - Mix_Music * m_music; ///< pointer to the music channel of the mixer - QString m_musicTrack; ///< path to the music track; - bool m_isPlayingMusic; ///< true if music was started but not stopped again. + bool m_audioInitialized; ///< true if audio is initialized already + Mix_Music * m_music; ///< pointer to the music channel of the mixer + QString m_musicTrack; ///< path to the music track; + bool m_isPlayingMusic; ///< true if music was started but not stopped again. - QMap * m_soundMap; ///< maps sound file paths to channels + QMap * m_soundMap; ///< maps sound file paths to channels - int lastchannel; ///< channel of the last music played + int lastchannel; ///< channel of the last music played -public: - /** - * @brief Returns reference to the singleton instance of this class. - * - * @see singleton pattern - * - * @return reference to the instance. - */ - static SDLInteraction & instance(); + public: + /** + * @brief Returns reference to the singleton instance of this class. + * + * @see singleton pattern + * + * @return reference to the instance. + */ + static SDLInteraction & instance(); - /// Class Destructor. - ~SDLInteraction(); + /// Class Destructor. + ~SDLInteraction(); - /** - * @brief Returns available (screen) resolutions. - * - * @return list of resolutions in the format WIDTHxHEIGHT. - */ - QStringList getResolutions() const; + /** + * @brief Returns available (screen) resolutions. + * + * @return list of resolutions in the format WIDTHxHEIGHT. + */ + QStringList getResolutions() const; - /// Adds all available joystick controlls to the list of SDL keys. - void addGameControllerKeys() const; + /// Adds all available joystick controlls to the list of SDL keys. + void addGameControllerKeys() const; - /** - * @brief Plays a sound file. - * - * @param soundFile path of the sound file. - */ - void playSoundFile(const QString & soundFile); + /** + * @brief Plays a sound file. + * + * @param soundFile path of the sound file. + */ + void playSoundFile(const QString & soundFile); - /** - * @brief Sets the music track to be played (or not). - * - * @param musicFile path of the music file. - */ - void setMusicTrack(const QString & musicFile); + /** + * @brief Sets the music track to be played (or not). + * + * @param musicFile path of the music file. + */ + void setMusicTrack(const QString & musicFile); - /// Starts the background music if not already playing. - void startMusic(); + /// Starts the background music if not already playing. + void startMusic(); - /// Fades out and stops the background music (if playing). - void stopMusic(); + /// Fades out and stops the background music (if playing). + void stopMusic(); }; diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/util/namegen.cpp --- a/QTfrontend/util/namegen.cpp Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/util/namegen.cpp Mon Jan 30 17:32:18 2012 -0500 @@ -126,7 +126,7 @@ // find .txt to load the names from QFile * file = new QFile(HWDataManager::instance().findFileForRead(QString( - "Names/%1.txt").arg(filename))); + "Names/%1.txt").arg(filename))); if (file->exists() && file->open(QIODevice::ReadOnly | QIODevice::Text)) { @@ -143,7 +143,7 @@ delete file; if (list.size() == 0) - list.append(filename); + list.append(filename); return list; } @@ -155,7 +155,7 @@ // find .cfg to load the dicts from QFile * file = new QFile(HWDataManager::instance().findFileForRead(QString( - "Names/%1.cfg").arg(hatname))); + "Names/%1.cfg").arg(hatname))); if (file->exists() && file->open(QIODevice::ReadOnly | QIODevice::Text)) { @@ -172,7 +172,7 @@ delete file; if (list.size() == 0) - list.append(QString("generic")); + list.append(QString("generic")); return list; } @@ -244,10 +244,10 @@ //list all available Graves Graves.append(HWDataManager::instance().entryList( - "Graphics/Graves", - QDir::Files, - QStringList("*.png") - ).replaceInStrings(QRegExp("\\.png$"), "") + "Graphics/Graves", + QDir::Files, + QStringList("*.png") + ).replaceInStrings(QRegExp("\\.png$"), "") ); if(Graves.size()==0) @@ -266,10 +266,10 @@ //list all available Forts Forts.append(HWDataManager::instance().entryList( - "Forts", - QDir::Files, - QStringList("*L.png") - ).replaceInStrings(QRegExp("L\\.png$"), "") + "Forts", + QDir::Files, + QStringList("*L.png") + ).replaceInStrings(QRegExp("L\\.png$"), "") ); if(Forts.size()==0) diff -r 65602f1ef0f8 -r f77bb02b669f QTfrontend/util/namegen.h --- a/QTfrontend/util/namegen.h Mon Jan 30 23:20:28 2012 +0100 +++ b/QTfrontend/util/namegen.h Mon Jan 30 17:32:18 2012 -0500 @@ -27,12 +27,12 @@ class HWNamegen { -public: + public: - static void teamRandomName(HWTeam & team, const int HedgehogNumber); - static void teamRandomNames(HWTeam & team, const bool changeteamname); + static void teamRandomName(HWTeam & team, const int HedgehogNumber); + static void teamRandomNames(HWTeam & team, const bool changeteamname); -private: + private: HWNamegen(); static QList TypesTeamnames;