@@ -102,6 +102,7 @@ void BuyMenuGUI::Clear() {
102102 m_pSaveButton = 0 ;
103103 m_pClearButton = 0 ;
104104 m_Loadouts.clear ();
105+ m_SelectedLoadoutIndex = -1 ;
105106 m_PurchaseMade = false ;
106107
107108 m_EnforceMaxPassengersConstraint = true ;
@@ -118,7 +119,7 @@ void BuyMenuGUI::Clear() {
118119 m_LastEquipmentScrollPosition = -1 ;
119120 m_LastMainScrollPosition = -1 ;
120121 m_FirstMainTab = CRAFT;
121- m_LastMainTab = SETS ;
122+ m_LastMainTab = PRESETS ;
122123 m_FirstEquipmentTab = TOOLS;
123124 m_LastEquipmentTab = SHIELDS;
124125}
@@ -183,7 +184,7 @@ int BuyMenuGUI::Create(Controller* pController) {
183184 m_pCategoryTabs[GUNS] = dynamic_cast <GUITab*>(m_pGUIController->GetControl (" GunsTab" ));
184185 m_pCategoryTabs[BOMBS] = dynamic_cast <GUITab*>(m_pGUIController->GetControl (" BombsTab" ));
185186 m_pCategoryTabs[SHIELDS] = dynamic_cast <GUITab*>(m_pGUIController->GetControl (" ShieldsTab" ));
186- m_pCategoryTabs[SETS ] = dynamic_cast <GUITab*>(m_pGUIController->GetControl (" SetsTab" ));
187+ m_pCategoryTabs[PRESETS ] = dynamic_cast <GUITab*>(m_pGUIController->GetControl (" SetsTab" ));
187188 RefreshTabDisabledStates ();
188189
189190 m_pShopList = dynamic_cast <GUIListBox*>(m_pGUIController->GetControl (" CatalogLB" ));
@@ -332,6 +333,7 @@ void BuyMenuGUI::DuplicateCartItem(const int itemIndex) {
332333bool BuyMenuGUI::LoadAllLoadoutsFromFile () {
333334 // First clear out all loadouts
334335 m_Loadouts.clear ();
336+ m_SelectedLoadoutIndex = -1 ;
335337 // Try to load the player's loadout settings from file, if there is one
336338 char loadoutPath[256 ];
337339
@@ -724,7 +726,7 @@ void BuyMenuGUI::RefreshTabDisabledStates() {
724726 m_pCategoryTabs[GUNS]->SetEnabled (smartBuyMenuNavigationDisabled || m_SelectingEquipment);
725727 m_pCategoryTabs[BOMBS]->SetEnabled (smartBuyMenuNavigationDisabled || m_SelectingEquipment);
726728 m_pCategoryTabs[SHIELDS]->SetEnabled (smartBuyMenuNavigationDisabled || m_SelectingEquipment);
727- m_pCategoryTabs[SETS ]->SetEnabled (smartBuyMenuNavigationDisabled || !m_SelectingEquipment);
729+ m_pCategoryTabs[PRESETS ]->SetEnabled (smartBuyMenuNavigationDisabled || !m_SelectingEquipment);
728730}
729731
730732void BuyMenuGUI::Update () {
@@ -1020,12 +1022,12 @@ void BuyMenuGUI::Update() {
10201022 }
10211023
10221024 // ///////////////////////////////////////
1023- // SETS BUTTONS focus
1025+ // PRESETS BUTTONS focus
10241026
10251027 if (m_MenuFocus == SETBUTTONS) {
10261028 if (m_FocusChange) {
10271029 // Set the correct special Sets category so the sets buttons show up
1028- m_MenuCategory = SETS ;
1030+ m_MenuCategory = PRESETS ;
10291031 CategoryChange ();
10301032 m_pSaveButton->SetFocus ();
10311033 m_FocusChange = 0 ;
@@ -1034,12 +1036,13 @@ void BuyMenuGUI::Update() {
10341036 if (m_pController->IsState (PRESS_FACEBUTTON)) {
10351037 if (m_pSaveButton->HasFocus ())
10361038 SaveCurrentLoadout ();
1037- else if (m_pClearButton->HasFocus () && m_Loadouts.size () != 0 ) {
1038- m_Loadouts.pop_back ( );
1039+ else if (m_pClearButton->HasFocus () && m_Loadouts.size () != 0 && m_SelectedLoadoutIndex != - 1 ) {
1040+ m_Loadouts.erase (m_Loadouts. begin () + m_SelectedLoadoutIndex );
10391041 // Update the list of loadout presets so the removal shows up
10401042 CategoryChange ();
10411043 // Set focus back on the save button (CatChange changed it)
10421044 m_pClearButton->SetFocus ();
1045+ m_SelectedLoadoutIndex = -1 ;
10431046 }
10441047 g_GUISound.ItemChangeSound ()->Play (m_pController->GetPlayer ());
10451048 }
@@ -1222,7 +1225,7 @@ void BuyMenuGUI::Update() {
12221225 CategoryChange (false );
12231226 }
12241227 // User pressed on a loadout set, so load it into the menu
1225- else if (pItem && m_MenuCategory == SETS ) {
1228+ else if (pItem && m_MenuCategory == PRESETS ) {
12261229 // Beep if there's an error
12271230 if (!DeployLoadout (m_ListItemIndex))
12281231 g_GUISound.UserErrorSound ()->Play (m_pController->GetPlayer ());
@@ -1506,12 +1509,14 @@ void BuyMenuGUI::Update() {
15061509 // CLEAR button clicks
15071510 if (anEvent.GetControl () == m_pClearButton) {
15081511 m_pClearButton->SetFocus ();
1509- if (!m_Loadouts.empty ())
1510- m_Loadouts.pop_back ();
1511- // Update the list of loadout presets so the removal shows up
1512- CategoryChange ();
1513- // Save new loadout config to file
1514- SaveAllLoadoutsToFile ();
1512+ if (m_SelectedLoadoutIndex != -1 ) {
1513+ m_Loadouts.erase (m_Loadouts.begin () + m_SelectedLoadoutIndex);
1514+ // Update the list of loadout presets so the removal shows up
1515+ CategoryChange ();
1516+ // Save new loadout config to file
1517+ SaveAllLoadoutsToFile ();
1518+ m_SelectedLoadoutIndex = -1 ;
1519+ }
15151520 // Set focus back on the clear button (CatChange changed it)
15161521 m_pClearButton->SetFocus ();
15171522 m_MenuFocus = SETBUTTONS;
@@ -1577,7 +1582,7 @@ void BuyMenuGUI::Update() {
15771582 CategoryChange (false );
15781583 }
15791584 // Special case: user clicked on a loadout set, so load it into the menu
1580- else if (pItem && m_MenuCategory == SETS ) {
1585+ else if (pItem && m_MenuCategory == PRESETS ) {
15811586 // Beep if there's an error
15821587 if (!DeployLoadout (m_ListItemIndex))
15831588 g_GUISound.UserErrorSound ()->Play (m_pController->GetPlayer ());
@@ -1769,6 +1774,11 @@ void BuyMenuGUI::Update() {
17691774 }
17701775 }
17711776 }
1777+
1778+ if (m_MenuCategory == PRESETS) {
1779+ m_pSaveButton->SetEnabled (!m_pCartList->GetItemList ()->empty ());
1780+ m_pClearButton->SetEnabled (m_SelectedLoadoutIndex != -1 );
1781+ }
17721782}
17731783
17741784void BuyMenuGUI::Draw (BITMAP* drawBitmap) const {
@@ -1837,7 +1847,7 @@ void BuyMenuGUI::CategoryChange(bool focusOnCategoryTabs) {
18371847 m_pShopList->ClearList ();
18381848
18391849 // Hide/show the logo and special sets category buttons, and add all current presets to the list, and we're done.
1840- if (m_MenuCategory == SETS ) {
1850+ if (m_MenuCategory == PRESETS ) {
18411851 m_Logo->SetVisible (false );
18421852 m_pSaveButton->SetVisible (true );
18431853 m_pClearButton->SetVisible (true );
@@ -1963,8 +1973,12 @@ void BuyMenuGUI::SaveCurrentLoadout() {
19631973}
19641974
19651975bool BuyMenuGUI::DeployLoadout (int index) {
1966- if (index < 0 || index >= m_Loadouts.size ())
1976+ if (index < 0 || index >= m_Loadouts.size ()) {
1977+ m_SelectedLoadoutIndex = -1 ;
19671978 return false ;
1979+ }
1980+
1981+ m_SelectedLoadoutIndex = index;
19681982
19691983 // Clear the cart, we're going to refill it with the selected loadout
19701984 m_pCartList->ClearList ();
@@ -2138,6 +2152,8 @@ void BuyMenuGUI::AddObjectsToItemList(std::vector<std::list<Entity*>>& moduleLis
21382152}
21392153
21402154void BuyMenuGUI::AddPresetsToItemList () {
2155+ m_SelectedLoadoutIndex = -1 ;
2156+
21412157 GUIBitmap* pItemBitmap = 0 ;
21422158 std::string loadoutLabel;
21432159 float loadoutCost;
0 commit comments