@@ -1568,6 +1568,19 @@ void BuyMenuGUI::Update() {
1568
1568
1569
1569
GUIListPanel::Item* pItem = m_pShopList->GetItem (mousePosX, mousePosY);
1570
1570
1571
+ if (pItem && m_MenuCategory == PRESETS) {
1572
+ // The presets list must have a mouse-down event to select an item, whereas we implicitly select items on hover in other categories
1573
+ m_LastHoveredMouseIndex = pItem->m_ID ;
1574
+
1575
+ // Play select sound if new index
1576
+ if (m_ListItemIndex != pItem->m_ID ) {
1577
+ g_GUISound.SelectionChangeSound ()->Play (m_pController->GetPlayer ());
1578
+ }
1579
+
1580
+ m_pShopList->SetSelectedIndex (m_CategoryItemIndex[m_MenuCategory] = m_ListItemIndex = pItem->m_ID );
1581
+ }
1582
+
1583
+
1571
1584
// If a module group list item, toggle its expansion and update the list
1572
1585
if (pItem && pItem->m_ExtraIndex >= 0 ) {
1573
1586
// Make appropriate sound
@@ -1649,15 +1662,17 @@ void BuyMenuGUI::Update() {
1649
1662
// See if it's hovering over any item
1650
1663
GUIListPanel::Item* pItem = m_pShopList->GetItem (mousePosX, mousePosY);
1651
1664
if (pItem) {
1652
- // Don't let mouse movement change the index if it's still hovering inside the same item.
1653
- // This is to avoid erratic selection curosr if using both mouse and keyboard to work the menu
1654
- if (m_LastHoveredMouseIndex != pItem->m_ID ) {
1665
+ // On presets Menu, you must actively click to select an item. Anywhere else, an implicit hover will select
1666
+ if (m_MenuCategory != PRESETS && m_LastHoveredMouseIndex != pItem->m_ID ) {
1667
+ // Don't let mouse movement change the index if it's still hovering inside the same item.
1668
+ // This is to avoid erratic selection curosr if using both mouse and keyboard to work the menu
1655
1669
m_LastHoveredMouseIndex = pItem->m_ID ;
1656
1670
1657
1671
// Play select sound if new index
1658
- if (m_ListItemIndex != pItem->m_ID )
1672
+ if (m_ListItemIndex != pItem->m_ID ) {
1659
1673
g_GUISound.SelectionChangeSound ()->Play (m_pController->GetPlayer ());
1660
- // Update the seleciton in both the GUI control and our menu
1674
+ }
1675
+
1661
1676
m_pShopList->SetSelectedIndex (m_CategoryItemIndex[m_MenuCategory] = m_ListItemIndex = pItem->m_ID );
1662
1677
}
1663
1678
}
@@ -1851,6 +1866,7 @@ void BuyMenuGUI::CategoryChange(bool focusOnCategoryTabs) {
1851
1866
m_Logo->SetVisible (false );
1852
1867
m_pSaveButton->SetVisible (true );
1853
1868
m_pClearButton->SetVisible (true );
1869
+ m_pShopList->SetHighlightAsIfAlwaysFocused (true );
1854
1870
// Add and done!
1855
1871
AddPresetsToItemList ();
1856
1872
return ;
@@ -1860,6 +1876,7 @@ void BuyMenuGUI::CategoryChange(bool focusOnCategoryTabs) {
1860
1876
m_Logo->SetVisible (true );
1861
1877
m_pSaveButton->SetVisible (false );
1862
1878
m_pClearButton->SetVisible (false );
1879
+ m_pShopList->SetHighlightAsIfAlwaysFocused (false );
1863
1880
}
1864
1881
1865
1882
// The vector of lists which will be filled with catalog objects, grouped by which data module they were read from
@@ -1980,33 +1997,33 @@ bool BuyMenuGUI::DeployLoadout(int index) {
1980
1997
1981
1998
m_SelectedLoadoutIndex = index;
1982
1999
1983
- // Clear the cart, we're going to refill it with the selected loadout
1984
- m_pCartList->ClearList ();
1985
-
1986
2000
// Check if the craft is available
1987
2001
const ACraft* pCraft = m_Loadouts[index].GetDeliveryCraft ();
2002
+ bool shouldReplaceCraft = pCraft && (m_pSelectedCraft == nullptr || m_pCartList->GetItemList ()->empty ());
2003
+ if (shouldReplaceCraft) {
2004
+ if (!IsAlwaysAllowedItem (pCraft->GetModuleAndPresetName ())) {
2005
+ if (IsProhibitedItem (pCraft->GetModuleAndPresetName ())) {
2006
+ shouldReplaceCraft = false ;
2007
+ }
1988
2008
1989
- if (pCraft) {
1990
- bool craftAvailable = true ;
1991
-
1992
- if (IsAllowedItem (pCraft->GetModuleAndPresetName ()))
1993
- craftAvailable = true ;
1994
-
1995
- if (IsProhibitedItem (pCraft->GetModuleAndPresetName ()))
1996
- craftAvailable = false ;
1997
-
1998
- if (m_OnlyShowOwnedItems && craftAvailable) {
1999
- if (GetOwnedItemsAmount (pCraft->GetModuleAndPresetName ()) > 0 )
2000
- craftAvailable = true ;
2001
- else
2002
- craftAvailable = false ;
2009
+ if (m_OnlyShowOwnedItems && GetOwnedItemsAmount (pCraft->GetModuleAndPresetName ()) == 0 ) {
2010
+ shouldReplaceCraft = false ;
2011
+ }
2003
2012
}
2013
+ }
2004
2014
2005
- if (IsAlwaysAllowedItem (pCraft->GetModuleAndPresetName ()))
2006
- craftAvailable = true ;
2015
+ // Set the craft to what the loadout specifies, if anything
2016
+ if (shouldReplaceCraft) {
2017
+ m_pSelectedCraft = pCraft;
2007
2018
2008
- if (!craftAvailable)
2009
- return false ;
2019
+ // Take into account whether these are native or not, and multiply the cost accordingly
2020
+ m_pCraftBox->SetText (m_pSelectedCraft->GetPresetName ());
2021
+ m_pCraftBox->SetRightText (m_pSelectedCraft->GetGoldValueString (m_NativeTechModule, m_ForeignCostMult));
2022
+
2023
+ m_pCraftNameLabel->SetText (m_pSelectedCraft->GetPresetName ());
2024
+ m_pCraftPriceLabel->SetText (m_pSelectedCraft->GetGoldValueString (m_NativeTechModule, m_ForeignCostMult));
2025
+ UpdateTotalPassengersLabel (dynamic_cast <const ACraft*>(m_pSelectedCraft), m_pCraftPassengersLabel);
2026
+ UpdateTotalMassLabel (dynamic_cast <const ACraft*>(m_pSelectedCraft), m_pCraftMassLabel);
2010
2027
}
2011
2028
2012
2029
// Get and add all the stuff in the selected loadout
@@ -2039,18 +2056,6 @@ bool BuyMenuGUI::DeployLoadout(int index) {
2039
2056
if (canAdd)
2040
2057
AddCartItem ((*cItr)->GetPresetName (), (*cItr)->GetGoldValueString (m_NativeTechModule, m_ForeignCostMult), pItemBitmap, *cItr);
2041
2058
}
2042
- // Now set the craft to what the loadout specifies, if anything
2043
- if (m_Loadouts[index].GetDeliveryCraft ()) {
2044
- m_pSelectedCraft = m_Loadouts[index].GetDeliveryCraft ();
2045
- // Take into account whether these are native or not, and multiply the cost accordingly
2046
- m_pCraftBox->SetText (m_pSelectedCraft->GetPresetName ());
2047
- m_pCraftBox->SetRightText (m_pSelectedCraft->GetGoldValueString (m_NativeTechModule, m_ForeignCostMult));
2048
-
2049
- m_pCraftNameLabel->SetText (m_pSelectedCraft->GetPresetName ());
2050
- m_pCraftPriceLabel->SetText (m_pSelectedCraft->GetGoldValueString (m_NativeTechModule, m_ForeignCostMult));
2051
- UpdateTotalPassengersLabel (dynamic_cast <const ACraft*>(m_pSelectedCraft), m_pCraftPassengersLabel);
2052
- UpdateTotalMassLabel (dynamic_cast <const ACraft*>(m_pSelectedCraft), m_pCraftMassLabel);
2053
- }
2054
2059
2055
2060
// Update labels with the new config's values
2056
2061
UpdateTotalCostLabel ();
0 commit comments