@@ -102,6 +102,7 @@ void BuyMenuGUI::Clear() {
102
102
m_pSaveButton = 0 ;
103
103
m_pClearButton = 0 ;
104
104
m_Loadouts.clear ();
105
+ m_SelectedLoadoutIndex = -1 ;
105
106
m_PurchaseMade = false ;
106
107
107
108
m_EnforceMaxPassengersConstraint = true ;
@@ -118,7 +119,7 @@ void BuyMenuGUI::Clear() {
118
119
m_LastEquipmentScrollPosition = -1 ;
119
120
m_LastMainScrollPosition = -1 ;
120
121
m_FirstMainTab = CRAFT;
121
- m_LastMainTab = SETS ;
122
+ m_LastMainTab = PRESETS ;
122
123
m_FirstEquipmentTab = TOOLS;
123
124
m_LastEquipmentTab = SHIELDS;
124
125
}
@@ -183,7 +184,7 @@ int BuyMenuGUI::Create(Controller* pController) {
183
184
m_pCategoryTabs[GUNS] = dynamic_cast <GUITab*>(m_pGUIController->GetControl (" GunsTab" ));
184
185
m_pCategoryTabs[BOMBS] = dynamic_cast <GUITab*>(m_pGUIController->GetControl (" BombsTab" ));
185
186
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" ));
187
188
RefreshTabDisabledStates ();
188
189
189
190
m_pShopList = dynamic_cast <GUIListBox*>(m_pGUIController->GetControl (" CatalogLB" ));
@@ -332,6 +333,7 @@ void BuyMenuGUI::DuplicateCartItem(const int itemIndex) {
332
333
bool BuyMenuGUI::LoadAllLoadoutsFromFile () {
333
334
// First clear out all loadouts
334
335
m_Loadouts.clear ();
336
+ m_SelectedLoadoutIndex = -1 ;
335
337
// Try to load the player's loadout settings from file, if there is one
336
338
char loadoutPath[256 ];
337
339
@@ -724,7 +726,7 @@ void BuyMenuGUI::RefreshTabDisabledStates() {
724
726
m_pCategoryTabs[GUNS]->SetEnabled (smartBuyMenuNavigationDisabled || m_SelectingEquipment);
725
727
m_pCategoryTabs[BOMBS]->SetEnabled (smartBuyMenuNavigationDisabled || m_SelectingEquipment);
726
728
m_pCategoryTabs[SHIELDS]->SetEnabled (smartBuyMenuNavigationDisabled || m_SelectingEquipment);
727
- m_pCategoryTabs[SETS ]->SetEnabled (smartBuyMenuNavigationDisabled || !m_SelectingEquipment);
729
+ m_pCategoryTabs[PRESETS ]->SetEnabled (smartBuyMenuNavigationDisabled || !m_SelectingEquipment);
728
730
}
729
731
730
732
void BuyMenuGUI::Update () {
@@ -1020,12 +1022,12 @@ void BuyMenuGUI::Update() {
1020
1022
}
1021
1023
1022
1024
// ///////////////////////////////////////
1023
- // SETS BUTTONS focus
1025
+ // PRESETS BUTTONS focus
1024
1026
1025
1027
if (m_MenuFocus == SETBUTTONS) {
1026
1028
if (m_FocusChange) {
1027
1029
// Set the correct special Sets category so the sets buttons show up
1028
- m_MenuCategory = SETS ;
1030
+ m_MenuCategory = PRESETS ;
1029
1031
CategoryChange ();
1030
1032
m_pSaveButton->SetFocus ();
1031
1033
m_FocusChange = 0 ;
@@ -1034,12 +1036,13 @@ void BuyMenuGUI::Update() {
1034
1036
if (m_pController->IsState (PRESS_FACEBUTTON)) {
1035
1037
if (m_pSaveButton->HasFocus ())
1036
1038
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 );
1039
1041
// Update the list of loadout presets so the removal shows up
1040
1042
CategoryChange ();
1041
1043
// Set focus back on the save button (CatChange changed it)
1042
1044
m_pClearButton->SetFocus ();
1045
+ m_SelectedLoadoutIndex = -1 ;
1043
1046
}
1044
1047
g_GUISound.ItemChangeSound ()->Play (m_pController->GetPlayer ());
1045
1048
}
@@ -1222,7 +1225,7 @@ void BuyMenuGUI::Update() {
1222
1225
CategoryChange (false );
1223
1226
}
1224
1227
// 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 ) {
1226
1229
// Beep if there's an error
1227
1230
if (!DeployLoadout (m_ListItemIndex))
1228
1231
g_GUISound.UserErrorSound ()->Play (m_pController->GetPlayer ());
@@ -1506,12 +1509,14 @@ void BuyMenuGUI::Update() {
1506
1509
// CLEAR button clicks
1507
1510
if (anEvent.GetControl () == m_pClearButton) {
1508
1511
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
+ }
1515
1520
// Set focus back on the clear button (CatChange changed it)
1516
1521
m_pClearButton->SetFocus ();
1517
1522
m_MenuFocus = SETBUTTONS;
@@ -1577,7 +1582,7 @@ void BuyMenuGUI::Update() {
1577
1582
CategoryChange (false );
1578
1583
}
1579
1584
// 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 ) {
1581
1586
// Beep if there's an error
1582
1587
if (!DeployLoadout (m_ListItemIndex))
1583
1588
g_GUISound.UserErrorSound ()->Play (m_pController->GetPlayer ());
@@ -1769,6 +1774,11 @@ void BuyMenuGUI::Update() {
1769
1774
}
1770
1775
}
1771
1776
}
1777
+
1778
+ if (m_MenuCategory == PRESETS) {
1779
+ m_pSaveButton->SetEnabled (!m_pCartList->GetItemList ()->empty ());
1780
+ m_pClearButton->SetEnabled (m_SelectedLoadoutIndex != -1 );
1781
+ }
1772
1782
}
1773
1783
1774
1784
void BuyMenuGUI::Draw (BITMAP* drawBitmap) const {
@@ -1837,7 +1847,7 @@ void BuyMenuGUI::CategoryChange(bool focusOnCategoryTabs) {
1837
1847
m_pShopList->ClearList ();
1838
1848
1839
1849
// 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 ) {
1841
1851
m_Logo->SetVisible (false );
1842
1852
m_pSaveButton->SetVisible (true );
1843
1853
m_pClearButton->SetVisible (true );
@@ -1963,8 +1973,12 @@ void BuyMenuGUI::SaveCurrentLoadout() {
1963
1973
}
1964
1974
1965
1975
bool BuyMenuGUI::DeployLoadout (int index) {
1966
- if (index < 0 || index >= m_Loadouts.size ())
1976
+ if (index < 0 || index >= m_Loadouts.size ()) {
1977
+ m_SelectedLoadoutIndex = -1 ;
1967
1978
return false ;
1979
+ }
1980
+
1981
+ m_SelectedLoadoutIndex = index;
1968
1982
1969
1983
// Clear the cart, we're going to refill it with the selected loadout
1970
1984
m_pCartList->ClearList ();
@@ -2138,6 +2152,8 @@ void BuyMenuGUI::AddObjectsToItemList(std::vector<std::list<Entity*>>& moduleLis
2138
2152
}
2139
2153
2140
2154
void BuyMenuGUI::AddPresetsToItemList () {
2155
+ m_SelectedLoadoutIndex = -1 ;
2156
+
2141
2157
GUIBitmap* pItemBitmap = 0 ;
2142
2158
std::string loadoutLabel;
2143
2159
float loadoutCost;
0 commit comments