"Setup" button instead of "New team", exclude playing teams from setup
FIXME: still need more work if teamname is updated while configuring (or team added)
--- a/QTfrontend/hwform.cpp Sun Jun 03 17:21:57 2007 +0000
+++ b/QTfrontend/hwform.cpp Sun Jun 03 22:19:47 2007 +0000
@@ -45,7 +45,7 @@
#include "chatwidget.h"
HWForm::HWForm(QWidget *parent)
- : QMainWindow(parent), pnetserver(0), pUdpServer(0)
+ : QMainWindow(parent), pnetserver(0), pUdpServer(0), editedTeam(0)
{
ui.setupUi(this);
@@ -94,20 +94,25 @@
connect(ui.pageNetGame->BtnGo, SIGNAL(clicked()), this, SLOT(NetStartGame()));
connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(setEnabledGameStart(bool)),
ui.pageNetGame->BtnGo, SLOT(setEnabled(bool)));
- connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(NewTeam()), this, SLOT(NewTeam()));
+ connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(SetupClicked()), this, SLOT(IntermediateSetup()));
connect(ui.pageInfo->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
connect(ui.pageGameStats->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack()));
- connect(ui.pageMultiplayer->teamsSelect, SIGNAL(NewTeam()), this, SLOT(NewTeam()));
+ connect(ui.pageMultiplayer->teamsSelect, SIGNAL(SetupClicked()), this, SLOT(IntermediateSetup()));
GoToPage(ID_PAGE_MAIN);
}
-void HWForm::UpdateTeamsLists()
+void HWForm::UpdateTeamsLists(const QStringList* editable_teams)
{
- QStringList teamslist = config->GetTeamsList();
+ QStringList teamslist;
+ if(editable_teams) {
+ teamslist=*editable_teams;
+ } else {
+ teamslist = config->GetTeamsList();
+ }
if(teamslist.empty()) {
HWTeam defaultTeam("DefaultTeam");
@@ -177,8 +182,10 @@
team.LoadFromFile();
teamsList.push_back(team);
}
- if(lastid==ID_PAGE_SETUP_TEAM) {
- if (editedTeam) curTeamSelWidget->addTeam(*editedTeam);
+ if(lastid==ID_PAGE_SETUP) { // _TEAM
+ if (editedTeam) {
+ curTeamSelWidget->addTeam(*editedTeam);
+ }
} else {
curTeamSelWidget->resetPlayingTeams(teamsList);
}
@@ -187,8 +194,9 @@
void HWForm::GoToPage(quint8 id)
{
+ quint8 lastid=ui.Pages->currentIndex();
PagesStack.push(ui.Pages->currentIndex());
- OnPageShown(id);
+ OnPageShown(id, lastid);
ui.Pages->setCurrentIndex(id);
}
@@ -221,6 +229,26 @@
}
}
+void HWForm::IntermediateSetup()
+{
+ quint8 id=ui.Pages->currentIndex();
+ TeamSelWidget* curTeamSelWidget;
+ if(id == ID_PAGE_MULTIPLAYER) {
+ curTeamSelWidget=ui.pageMultiplayer->teamsSelect;
+ } else {
+ curTeamSelWidget=ui.pageNetGame->pNetTeamsWidget;
+ }
+ QList<HWTeam> teams=curTeamSelWidget->getDontPlayingTeams();
+ QStringList tmnames;
+ for(QList<HWTeam>::iterator it = teams.begin(); it != teams.end(); ++it) {
+ qDebug() << it->TeamName;
+ tmnames+=it->TeamName;
+ }
+ UpdateTeamsLists(&tmnames); // FIXME: still need more work if teamname is updated while configuring
+
+ GoToPage(ID_PAGE_SETUP);
+}
+
void HWForm::NewTeam()
{
editedTeam = new HWTeam("unnamed");
@@ -240,10 +268,10 @@
{
editedTeam->GetFromPage(this);
editedTeam->SaveToFile();
+ delete editedTeam;
+ editedTeam=0;
UpdateTeamsLists();
GoBack();
- delete editedTeam;
- editedTeam=0;
}
void HWForm::TeamDiscard()
--- a/QTfrontend/hwform.h Sun Jun 03 17:21:57 2007 +0000
+++ b/QTfrontend/hwform.h Sun Jun 03 22:19:47 2007 +0000
@@ -53,6 +53,7 @@
void GoBack();
void btnExitPressed();
void btnExitClicked();
+ void IntermediateSetup();
void NewTeam();
void EditTeam();
void TeamSave();
@@ -76,7 +77,7 @@
private:
void _NetConnect(const QString & hostName, quint16 port, const QString & nick);
- void UpdateTeamsLists();
+ void UpdateTeamsLists(const QStringList* editable_teams=0);
void CreateGame(GameCFGWidget * gamecfg, TeamSelWidget* pTeamSelWidget);
enum PageIDs {
ID_PAGE_SINGLEPLAYER = 0,
--- a/QTfrontend/teamselect.cpp Sun Jun 03 17:21:57 2007 +0000
+++ b/QTfrontend/teamselect.cpp Sun Jun 03 22:19:47 2007 +0000
@@ -196,10 +196,10 @@
QPalette p;
addScrArea(framePlaying, p.color(QPalette::Window).light(105), 200);
addScrArea(frameDontPlaying, p.color(QPalette::Window).dark(105), 0);
- newTeam = new QPushButton(this);
- newTeam->setText(QPushButton::tr("New team"));
- connect(newTeam, SIGNAL(clicked()), this, SLOT(newTeamClicked()));
- mainLayout.addWidget(newTeam);
+ QPushButton * btnSetup = new QPushButton(this);
+ btnSetup->setText(QPushButton::tr("Setup"));
+ connect(btnSetup, SIGNAL(clicked()), this, SIGNAL(SetupClicked()));
+ mainLayout.addWidget(btnSetup);
}
void TeamSelWidget::setAcceptOuter(bool acceptOuter)
@@ -237,13 +237,13 @@
return curPlayingTeams;
}
+QList<HWTeam> TeamSelWidget::getDontPlayingTeams() const
+{
+ return curDontPlayingTeams;
+}
+
void TeamSelWidget::pre_changeTeamStatus(HWTeam team)
{
team.teamColor=framePlaying->getNextColor();
emit acceptRequested(team);
}
-
-void TeamSelWidget::newTeamClicked()
-{
- emit NewTeam();
-}
--- a/QTfrontend/teamselect.h Sun Jun 03 17:21:57 2007 +0000
+++ b/QTfrontend/teamselect.h Sun Jun 03 22:19:47 2007 +0000
@@ -44,6 +44,7 @@
void resetPlayingTeams(const QList<HWTeam>& teamslist);
bool isPlaying(HWTeam team) const;
QList<HWTeam> getPlayingTeams() const;
+ QList<HWTeam> getDontPlayingTeams() const;
void setNonInteractive();
public slots:
@@ -55,7 +56,7 @@
signals:
void setEnabledGameStart(bool);
- void NewTeam();
+ void SetupClicked();
void teamWillPlay(HWTeam team);
void teamNotPlaying(const HWTeam& team);
void hhogsNumChanged(const HWTeam&);
@@ -64,7 +65,6 @@
private slots:
void pre_changeTeamStatus(HWTeam);
- void newTeamClicked();
void hhNumChanged(const HWTeam& team);
void proxyTeamColorChanged(const HWTeam& team);
@@ -75,7 +75,6 @@
QVBoxLayout mainLayout;
bool m_acceptOuter;
- QPushButton * newTeam;
QList<HWTeam> curPlayingTeams;
QList<HWTeam> curDontPlayingTeams;