Skip to content

Commit a86a5c7

Browse files
committed
More consistent use of override events in logic responsible for showing or hiding perks.
1 parent 44e45e0 commit a86a5c7

File tree

1 file changed

+54
-39
lines changed

1 file changed

+54
-39
lines changed

X2WOTCCommunityPromotionScreen/Src/X2WOTCCommunityPromotionScreen/Classes/CPS_UIArmory_PromotionHero.uc

Lines changed: 54 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,8 @@ function bool UpdateAbilityIcons_Override(out CPS_UIArmory_PromotionHeroColumn C
494494

495495
// Start variables for Issue #69
496496
local CPSAbilityMetaInfo MetaInfo;
497-
local bool bUnreachedRankPerk;
498497
local bool bHidePerk;
498+
local bool bCanPurchasePerk;
499499
// End variables for Issue #69
500500

501501
AbilityTemplateManager = class'X2AbilityTemplateManager'.static.GetAbilityTemplateManager();
@@ -512,9 +512,7 @@ function bool UpdateAbilityIcons_Override(out CPS_UIArmory_PromotionHeroColumn C
512512

513513
// MaxPosition is the maximum value for Position
514514
MaxPosition = Max(AbilityTree.Length - NUM_ABILITIES_PER_COLUMN, MaxPosition);
515-
516515
Column.AbilityNames.Length = 0;
517-
bUnreachedRankPerk = Column.Rank >= Unit.GetRank();
518516

519517
for (iAbility = Position; iAbility < Position + NUM_ABILITIES_PER_COLUMN; iAbility++)
520518
{
@@ -533,24 +531,33 @@ function bool UpdateAbilityIcons_Override(out CPS_UIArmory_PromotionHeroColumn C
533531
{
534532
Column.AbilityNames.AddItem(AbilityTemplate.DataName);
535533
}
536-
537-
FillAbilityMetaInfo(MetaInfo, Unit, Column.Rank, iAbility, AbilityTemplate.DataName);
538534

539-
switch (`GETMCMVAR(SHOW_UNREACHED_PERKS_MODE))
535+
bCanPurchasePerk = CanPurchaseAbility(Column.Rank, iAbility, AbilityTemplate.DataName);
536+
if (bCanPurchasePerk)
540537
{
541-
// Hide Training Center perks. All of them are hidden if the Training Center is not built or if the perk is higher than current rank.
542-
case 1:
543-
bHidePerk = !MetaInfo.bClassAbility && (!bCanSpendAP || bUnreachedRankPerk);
544-
break;
545-
// Always show all perks.
546-
case 2:
547538
bHidePerk = false;
548-
break;
549-
// Hide all perks from unreached ranks. Training Center perks are always hidden until Training Center is constructed.
550-
case 0:
551-
default:
552-
bHidePerk = bUnreachedRankPerk || !MetaInfo.bClassAbility && !bCanSpendAP;
553-
break;
539+
}
540+
else
541+
{
542+
FillAbilityMetaInfo(MetaInfo, Unit, Column.Rank, iAbility, AbilityTemplate.DataName);
543+
TriggerOverrideCanPurchaseAbilityProperties(MetaInfo, Unit);
544+
545+
switch (`GETMCMVAR(SHOW_UNREACHED_PERKS_MODE))
546+
{
547+
// Hide Training Center perks. All of them are hidden if the Training Center is not built or if the perk is higher than current rank.
548+
case 1:
549+
bHidePerk = !MetaInfo.bClassAbility && (!MetaInfo.bUnitCanSpendAP || !MetaInfo.bUnitMeetsRankRequirement);
550+
break;
551+
// Always show all perks.
552+
case 2:
553+
bHidePerk = false;
554+
break;
555+
// Hide all perks from unreached ranks. Training Center perks are always hidden until Training Center is constructed.
556+
case 0:
557+
default:
558+
bHidePerk = !MetaInfo.bUnitMeetsRankRequirement || !MetaInfo.bClassAbility && !MetaInfo.bUnitCanSpendAP;
559+
break;
560+
}
554561
}
555562

556563
if (bHidePerk)
@@ -575,7 +582,7 @@ function bool UpdateAbilityIcons_Override(out CPS_UIArmory_PromotionHeroColumn C
575582
BGColor = class'UIUtilities_Colors'.const.BLACK_HTML_COLOR;
576583
bHasColumnAbility = true;
577584
}
578-
else if(CanPurchaseAbility(Column.Rank, iAbility, AbilityTemplate.DataName))
585+
else if(bCanPurchasePerk)
579586
{
580587
// The ability is unlocked and unpurchased, and can be afforded
581588
ButtonState = eUIPromotionState_Normal;
@@ -1311,12 +1318,12 @@ function PreviewAbility(int Rank, int Branch)
13111318
// Variable for Issue #128
13121319
local string MutuallyExclusiveNames;
13131320
local bool bHidePerk;
1314-
local bool bUnreachedRankPerk;
13151321

13161322
// Variable for Issue #55
13171323
local string SlotName;
13181324

13191325
// Variable for Issue #69
1326+
local bool bCanPurchasePerk;
13201327
local CPSAbilityMetaInfo MetaInfo;
13211328

13221329
// NPSBDP Patch
@@ -1334,24 +1341,36 @@ function PreviewAbility(int Rank, int Branch)
13341341
}
13351342

13361343
AbilityTree = Unit.GetRankAbilities(Rank);
1337-
FillAbilityMetaInfo(MetaInfo, Unit, Rank, Branch, AbilityTree[Branch].AbilityName);
1338-
bUnreachedRankPerk = Rank >= Unit.GetRank();
13391344

1340-
switch (`GETMCMVAR(SHOW_UNREACHED_PERKS_MODE))
1345+
// Start Issue #7
1346+
CanPurchaseAbilityEx(Rank, Branch, AbilityTree[Branch].AbilityName, DisabledReason);
1347+
// End Issue #7
1348+
1349+
if (DisabledReason == "")
13411350
{
1342-
// Hide Training Center perks. All of them are hidden if the Training Center is not built or if the perk is higher than current rank.
1343-
case 1:
1344-
bHidePerk = !MetaInfo.bClassAbility && (!bCanSpendAP || bUnreachedRankPerk);
1345-
break;
1346-
// Always show all perks.
1347-
case 2:
13481351
bHidePerk = false;
1349-
break;
1350-
// Hide all perks from unreached ranks. Training Center perks are always hidden until Training Center is constructed.
1351-
case 0:
1352-
default:
1353-
bHidePerk = bUnreachedRankPerk || !MetaInfo.bClassAbility && !bCanSpendAP;
1354-
break;
1352+
}
1353+
else
1354+
{
1355+
FillAbilityMetaInfo(MetaInfo, Unit, Rank, Branch, AbilityTree[Branch].AbilityName);
1356+
TriggerOverrideCanPurchaseAbilityProperties(MetaInfo, Unit);
1357+
1358+
switch (`GETMCMVAR(SHOW_UNREACHED_PERKS_MODE))
1359+
{
1360+
// Hide Training Center perks. All of them are hidden if the Training Center is not built or if the perk is higher than current rank.
1361+
case 1:
1362+
bHidePerk = !MetaInfo.bClassAbility && (!MetaInfo.bUnitCanSpendAP || !MetaInfo.bUnitMeetsRankRequirement);
1363+
break;
1364+
// Always show all perks.
1365+
case 2:
1366+
bHidePerk = false;
1367+
break;
1368+
// Hide all perks from unreached ranks. Training Center perks are always hidden until Training Center is constructed.
1369+
case 0:
1370+
default:
1371+
bHidePerk = !MetaInfo.bUnitMeetsRankRequirement || !MetaInfo.bClassAbility && !MetaInfo.bUnitCanSpendAP;
1372+
break;
1373+
}
13551374
}
13561375

13571376
if (bHidePerk)
@@ -1376,10 +1395,6 @@ function PreviewAbility(int Rank, int Branch)
13761395
AbilityName = AbilityTemplate.LocFriendlyName != "" ? AbilityTemplate.LocFriendlyName : ("Missing 'LocFriendlyName' for " $ AbilityTemplate.DataName);
13771396
AbilityDesc = AbilityTemplate.HasLongDescription() ? AbilityTemplate.GetMyLongDescription(, Unit) : ("Missing 'LocLongDescription' for " $ AbilityTemplate.DataName);
13781397

1379-
// Start Issue #7
1380-
CanPurchaseAbilityEx(Rank, Branch, AbilityTemplate.DataName, DisabledReason);
1381-
// End Issue #7
1382-
13831398
// Don't display cost information if the ability has already been purchased
13841399
if (Unit.HasSoldierAbility(AbilityTemplate.DataName))
13851400
{

0 commit comments

Comments
 (0)