# HG changeset patch # User Wuzzy # Date 1545172120 -3600 # Node ID 6ab8335fe0a6cebafcd4c86884e332b26c65f7e3 # Parent bfacce4ff920f11cd9b1cc9ce22160b369b02bdd Save and restore last campaign/training team selection in settings.ini diff -r bfacce4ff920 -r 6ab8335fe0a6 QTfrontend/hwform.cpp --- a/QTfrontend/hwform.cpp Tue Dec 18 22:53:49 2018 +0100 +++ b/QTfrontend/hwform.cpp Tue Dec 18 23:28:40 2018 +0100 @@ -219,6 +219,7 @@ previousTeamName = ""; UpdateTeamsLists(); InitCampaignPage(); + RestoreSingleplayerTeamSelection(); UpdateCampaignPage(0); UpdateCampaignPageTeam(0); UpdateCampaignPageMission(0); @@ -928,6 +929,11 @@ GoBack(); } + if (curid == ID_PAGE_CAMPAIGN) + config->setValue("frontend/lastSingleplayerTeam", ui.pageCampaign->CBTeam->currentText()); + if (curid == ID_PAGE_TRAINING) + config->setValue("frontend/lastSingleplayerTeam", ui.pageTraining->CBTeam->currentText()); + if (curid == ID_PAGE_ROOMSLIST || curid == ID_PAGE_CONNECTING) NetDisconnect(); if (curid == ID_PAGE_NETGAME && hwnet && hwnet->isInRoom()) hwnet->partRoom(); // need to work on this, can cause invalid state for admin quit trying to prevent bad state message on kick @@ -2054,6 +2060,21 @@ QString tName = team.name(); ui.pageCampaign->CBCampaign->addItem(getRealCampName(campaignName), campaignName); } + +} + +void HWForm::RestoreSingleplayerTeamSelection() +{ + QString lastTeam = config->value("frontend/lastSingleplayerTeam", QString()).toString(); + if (!lastTeam.isNull() && !lastTeam.isEmpty()) + { + int index = ui.pageCampaign->CBTeam->findData(lastTeam, Qt::DisplayRole); + if(index != -1) + ui.pageCampaign->CBTeam->setCurrentIndex(index); + index = ui.pageTraining->CBTeam->findData(lastTeam, Qt::DisplayRole); + if(index != -1) + ui.pageTraining->CBTeam->setCurrentIndex(index); + } } void HWForm::UpdateCampaignPage(int index) diff -r bfacce4ff920 -r 6ab8335fe0a6 QTfrontend/hwform.h --- a/QTfrontend/hwform.h Tue Dec 18 22:53:49 2018 +0100 +++ b/QTfrontend/hwform.h Tue Dec 18 23:28:40 2018 +0100 @@ -137,6 +137,7 @@ void UpdateCampaignPageMission(int index); void UpdateTrainingPageTeam(int index); void InitCampaignPage(); + void RestoreSingleplayerTeamSelection(); void showFeedbackDialog(); void showFeedbackDialogNetChecked();