40 { |
40 { |
41 ui.setupUi(this); |
41 ui.setupUi(this); |
42 |
42 |
43 config = new GameUIConfig(this); |
43 config = new GameUIConfig(this); |
44 |
44 |
45 QStringList teamslist = config->GetTeamsList(); |
45 UpdateTeamsLists(); |
46 |
|
47 if(teamslist.empty()) { |
|
48 HWTeam defaultTeam("DefaultTeam"); |
|
49 defaultTeam.SaveToFile(); |
|
50 teamslist.push_back("DefaultTeam"); |
|
51 } |
|
52 |
|
53 for (QStringList::Iterator it = teamslist.begin(); it != teamslist.end(); ++it ) |
|
54 { |
|
55 ui.pageMultiplayer->teamsSelect->addTeam(*it); |
|
56 ui.pageOptions->CBTeamName->addItem(*it); |
|
57 } |
|
58 |
46 |
59 connect(ui.pageMain->BtnSinglePlayer, SIGNAL(clicked()), this, SLOT(GoToSinglePlayer())); |
47 connect(ui.pageMain->BtnSinglePlayer, SIGNAL(clicked()), this, SLOT(GoToSinglePlayer())); |
60 connect(ui.pageMain->BtnSetup, SIGNAL(clicked()), this, SLOT(GoToSetup())); |
48 connect(ui.pageMain->BtnSetup, SIGNAL(clicked()), this, SLOT(GoToSetup())); |
61 connect(ui.pageMain->BtnMultiplayer, SIGNAL(clicked()), this, SLOT(GoToMultiplayer())); |
49 connect(ui.pageMain->BtnMultiplayer, SIGNAL(clicked()), this, SLOT(GoToMultiplayer())); |
62 connect(ui.pageMain->BtnDemos, SIGNAL(clicked()), this, SLOT(GoToDemos())); |
50 connect(ui.pageMain->BtnDemos, SIGNAL(clicked()), this, SLOT(GoToDemos())); |
95 connect(ui.pageInfo->BtnBack, SIGNAL(clicked()), this, SLOT(GoToMain())); |
83 connect(ui.pageInfo->BtnBack, SIGNAL(clicked()), this, SLOT(GoToMain())); |
96 |
84 |
97 ui.Pages->setCurrentIndex(ID_PAGE_MAIN); |
85 ui.Pages->setCurrentIndex(ID_PAGE_MAIN); |
98 } |
86 } |
99 |
87 |
|
88 void HWForm::UpdateTeamsLists() |
|
89 { |
|
90 QStringList teamslist = config->GetTeamsList(); |
|
91 |
|
92 if(teamslist.empty()) { |
|
93 HWTeam defaultTeam("DefaultTeam"); |
|
94 defaultTeam.SaveToFile(); |
|
95 teamslist.push_back("DefaultTeam"); |
|
96 } |
|
97 |
|
98 ui.pageOptions->CBTeamName->clear(); |
|
99 ui.pageOptions->CBTeamName->addItems(teamslist); |
|
100 } |
|
101 |
100 void HWForm::GoToMain() |
102 void HWForm::GoToMain() |
101 { |
103 { |
102 ui.Pages->setCurrentIndex(ID_PAGE_MAIN); |
104 ui.Pages->setCurrentIndex(ID_PAGE_MAIN); |
103 } |
105 } |
104 |
106 |
122 QStringList tmNames=config->GetTeamsList(); |
124 QStringList tmNames=config->GetTeamsList(); |
123 QList<HWTeam> teamsList; |
125 QList<HWTeam> teamsList; |
124 for(QStringList::iterator it=tmNames.begin(); it!=tmNames.end(); it++) { |
126 for(QStringList::iterator it=tmNames.begin(); it!=tmNames.end(); it++) { |
125 HWTeam team(*it); |
127 HWTeam team(*it); |
126 team.LoadFromFile(); |
128 team.LoadFromFile(); |
127 team.TeamName=*it; // FIXME: we can have different different teamnames in config files |
|
128 teamsList.push_back(team); |
129 teamsList.push_back(team); |
129 } |
130 } |
130 ui.pageMultiplayer->teamsSelect->resetPlayingTeams(teamsList); |
131 ui.pageMultiplayer->teamsSelect->resetPlayingTeams(teamsList); |
131 ui.Pages->setCurrentIndex(ID_PAGE_MULTIPLAYER); |
132 ui.Pages->setCurrentIndex(ID_PAGE_MULTIPLAYER); |
132 } |
133 } |
152 ui.Pages->setCurrentIndex(ID_PAGE_NETCHAT); |
153 ui.Pages->setCurrentIndex(ID_PAGE_NETCHAT); |
153 } |
154 } |
154 |
155 |
155 void HWForm::NewTeam() |
156 void HWForm::NewTeam() |
156 { |
157 { |
157 tmpTeam = new HWTeam("unnamed"); |
158 editedTeam = new HWTeam("unnamed"); |
158 tmpTeam->SetToPage(this); |
159 editedTeam->SetToPage(this); |
159 ui.Pages->setCurrentIndex(ID_PAGE_SETUP_TEAM); |
160 ui.Pages->setCurrentIndex(ID_PAGE_SETUP_TEAM); |
160 } |
161 } |
161 |
162 |
162 void HWForm::EditTeam() |
163 void HWForm::EditTeam() |
163 { |
164 { |
164 tmpTeam = new HWTeam(ui.pageOptions->CBTeamName->currentText()); |
165 editedTeam = new HWTeam(ui.pageOptions->CBTeamName->currentText()); |
165 tmpTeam->LoadFromFile(); |
166 editedTeam->LoadFromFile(); |
166 tmpTeam->SetToPage(this); |
167 editedTeam->SetToPage(this); |
167 ui.Pages->setCurrentIndex(ID_PAGE_SETUP_TEAM); |
168 ui.Pages->setCurrentIndex(ID_PAGE_SETUP_TEAM); |
168 } |
169 } |
169 |
170 |
170 void HWForm::TeamSave() |
171 void HWForm::TeamSave() |
171 { |
172 { |
172 tmpTeam->GetFromPage(this); |
173 editedTeam->GetFromPage(this); |
173 tmpTeam->SaveToFile(); |
174 editedTeam->SaveToFile(); |
174 delete tmpTeam; |
175 delete editedTeam; |
|
176 UpdateTeamsLists(); |
175 ui.Pages->setCurrentIndex(ID_PAGE_SETUP); |
177 ui.Pages->setCurrentIndex(ID_PAGE_SETUP); |
176 } |
178 } |
177 |
179 |
178 void HWForm::TeamDiscard() |
180 void HWForm::TeamDiscard() |
179 { |
181 { |
|
182 delete editedTeam; |
180 ui.Pages->setCurrentIndex(ID_PAGE_SETUP); |
183 ui.Pages->setCurrentIndex(ID_PAGE_SETUP); |
181 } |
184 } |
182 |
185 |
183 void HWForm::SimpleGame() |
186 void HWForm::SimpleGame() |
184 { |
187 { |