Skip to content

Commit 4aa2081

Browse files
committed
Loadouts are now additive, and append their items into the cart instead of replacing everything
Improve preset UI to highlight selected in a different manner. Should look at improving controller nav here too
1 parent 24551d6 commit 4aa2081

File tree

2 files changed

+45
-38
lines changed

2 files changed

+45
-38
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
159159

160160
- The "Clear" Preset button in the Buy Menu now clears the currently selected loadout, instead of the last one in the list.
161161

162+
- Loadouts are now additive, and append their items into the cart instead of replacing the current cart item list.
163+
162164
- Conquest activities will once again fall-back to using base dropships and rockets if a random selection of the selected tech's craft can't find one capable of carrying passengers and/or cargo.
163165

164166
- `MovableMan:OpenAllDoors()`, when passed `NOTEAM`, will now open/close doors specifically for `NOTEAM` (instead of all doors).

Source/Menus/BuyMenuGUI.cpp

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,6 +1568,19 @@ void BuyMenuGUI::Update() {
15681568

15691569
GUIListPanel::Item* pItem = m_pShopList->GetItem(mousePosX, mousePosY);
15701570

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+
15711584
// If a module group list item, toggle its expansion and update the list
15721585
if (pItem && pItem->m_ExtraIndex >= 0) {
15731586
// Make appropriate sound
@@ -1649,15 +1662,17 @@ void BuyMenuGUI::Update() {
16491662
// See if it's hovering over any item
16501663
GUIListPanel::Item* pItem = m_pShopList->GetItem(mousePosX, mousePosY);
16511664
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
16551669
m_LastHoveredMouseIndex = pItem->m_ID;
16561670

16571671
// Play select sound if new index
1658-
if (m_ListItemIndex != pItem->m_ID)
1672+
if (m_ListItemIndex != pItem->m_ID) {
16591673
g_GUISound.SelectionChangeSound()->Play(m_pController->GetPlayer());
1660-
// Update the seleciton in both the GUI control and our menu
1674+
}
1675+
16611676
m_pShopList->SetSelectedIndex(m_CategoryItemIndex[m_MenuCategory] = m_ListItemIndex = pItem->m_ID);
16621677
}
16631678
}
@@ -1851,6 +1866,7 @@ void BuyMenuGUI::CategoryChange(bool focusOnCategoryTabs) {
18511866
m_Logo->SetVisible(false);
18521867
m_pSaveButton->SetVisible(true);
18531868
m_pClearButton->SetVisible(true);
1869+
m_pShopList->SetHighlightAsIfAlwaysFocused(true);
18541870
// Add and done!
18551871
AddPresetsToItemList();
18561872
return;
@@ -1860,6 +1876,7 @@ void BuyMenuGUI::CategoryChange(bool focusOnCategoryTabs) {
18601876
m_Logo->SetVisible(true);
18611877
m_pSaveButton->SetVisible(false);
18621878
m_pClearButton->SetVisible(false);
1879+
m_pShopList->SetHighlightAsIfAlwaysFocused(false);
18631880
}
18641881

18651882
// 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) {
19801997

19811998
m_SelectedLoadoutIndex = index;
19821999

1983-
// Clear the cart, we're going to refill it with the selected loadout
1984-
m_pCartList->ClearList();
1985-
19862000
// Check if the craft is available
19872001
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+
}
19882008

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+
}
20032012
}
2013+
}
20042014

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;
20072018

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);
20102027
}
20112028

20122029
// Get and add all the stuff in the selected loadout
@@ -2039,18 +2056,6 @@ bool BuyMenuGUI::DeployLoadout(int index) {
20392056
if (canAdd)
20402057
AddCartItem((*cItr)->GetPresetName(), (*cItr)->GetGoldValueString(m_NativeTechModule, m_ForeignCostMult), pItemBitmap, *cItr);
20412058
}
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-
}
20542059

20552060
// Update labels with the new config's values
20562061
UpdateTotalCostLabel();

0 commit comments

Comments
 (0)