2141 } |
2141 } |
2142 } |
2142 } |
2143 |
2143 |
2144 void HWForm::UpdateCampaignPageProgress(int index) |
2144 void HWForm::UpdateCampaignPageProgress(int index) |
2145 { |
2145 { |
2146 Q_UNUSED(index); |
|
2147 |
|
2148 QString missionTitle = ui.pageCampaign->CBMission->currentData().toString(); |
2146 QString missionTitle = ui.pageCampaign->CBMission->currentData().toString(); |
2149 UpdateCampaignPage(0); |
2147 UpdateCampaignPage(0); |
|
2148 int missionIndex = 0; |
|
2149 // Restore selected mission (because UpdateCampaignPage repopulated the list) |
2150 for(int i=0;i<ui.pageCampaign->CBMission->count();i++) |
2150 for(int i=0;i<ui.pageCampaign->CBMission->count();i++) |
2151 { |
2151 { |
2152 if (ui.pageCampaign->CBMission->itemData(i).toString() == missionTitle) |
2152 if (ui.pageCampaign->CBMission->itemData(i).toString() == missionTitle) |
2153 { |
2153 { |
2154 ui.pageCampaign->CBMission->setCurrentIndex(i); |
2154 missionIndex = i; |
2155 break; |
2155 break; |
2156 } |
2156 } |
2157 } |
2157 } |
2158 int i = ui.pageCampaign->CBCampaign->currentIndex(); |
2158 |
2159 QString campaignName = ui.pageCampaign->CBCampaign->itemData(i).toString(); |
2159 // Get metadata |
|
2160 int c = ui.pageCampaign->CBCampaign->currentIndex(); |
|
2161 QString campaignName = ui.pageCampaign->CBCampaign->itemData(c).toString(); |
2160 HWTeam team(ui.pageCampaign->CBTeam->currentText()); |
2162 HWTeam team(ui.pageCampaign->CBTeam->currentText()); |
2161 QString tName = team.name(); |
2163 QString tName = team.name(); |
|
2164 |
|
2165 if(index == gsFinished) |
|
2166 { |
|
2167 // Select new mission when current mission went from |
|
2168 // unfinished to finished. |
|
2169 if(ui.pageCampaign->currentMissionWon == false && |
|
2170 isCampMissionWon(campaignName, missionIndex, tName)) |
|
2171 { |
|
2172 // Traverse all missions and pick first mission that |
|
2173 // has not been won. |
|
2174 bool selected = false; |
|
2175 // start from mission that comes after the selected one |
|
2176 for(int m = missionIndex-1; m >= 0;m--) |
|
2177 { |
|
2178 if(!isCampMissionWon(campaignName, m, tName)) |
|
2179 { |
|
2180 missionIndex = m; |
|
2181 selected = true; |
|
2182 break; |
|
2183 } |
|
2184 } |
|
2185 // No mission selected? Let's try again from the end of the list |
|
2186 if(!selected) |
|
2187 { |
|
2188 for(int m = ui.pageCampaign->CBMission->count()-1; m > missionIndex-1; m--) |
|
2189 { |
|
2190 if(!isCampMissionWon(campaignName, m, tName)) |
|
2191 { |
|
2192 missionIndex = m; |
|
2193 break; |
|
2194 } |
|
2195 } |
|
2196 } |
|
2197 // If no mission was selected, the old selection remains unchanged. |
|
2198 } |
|
2199 } |
|
2200 else if(index == gsStarted) |
|
2201 { |
|
2202 // Remember the "won" state of current mission before we start it. |
|
2203 // We'll need it when the game has finished. |
|
2204 ui.pageCampaign->currentMissionWon = isCampMissionWon(campaignName, missionIndex, tName); |
|
2205 } |
|
2206 |
|
2207 ui.pageCampaign->CBMission->setCurrentIndex(missionIndex); |
|
2208 |
|
2209 // Update campaign victory status |
2162 if(isCampWon(campaignName, tName)) |
2210 if(isCampWon(campaignName, tName)) |
2163 ui.pageCampaign->CBCampaign->setItemIcon(i, finishedIcon); |
2211 ui.pageCampaign->CBCampaign->setItemIcon(c, finishedIcon); |
2164 else |
2212 else |
2165 ui.pageCampaign->CBCampaign->setItemIcon(i, notFinishedIcon); |
2213 ui.pageCampaign->CBCampaign->setItemIcon(c, notFinishedIcon); |
2166 } |
2214 } |
2167 |
2215 |
2168 // used for --set-everything [screen width] [screen height] [color dept] [volume] [enable music] [enable sounds] [language file] [full screen] [show FPS] [alternate damage] [timer value] [reduced quality] |
2216 // used for --set-everything [screen width] [screen height] [color dept] [volume] [enable music] [enable sounds] [language file] [full screen] [show FPS] [alternate damage] [timer value] [reduced quality] |
2169 QString HWForm::getDemoArguments() |
2217 QString HWForm::getDemoArguments() |
2170 { |
2218 { |