From 3613201880e291223ca6d1cd12ca32a7fe1b8bb4 Mon Sep 17 00:00:00 2001 From: Iridar Date: Sat, 28 Jan 2023 16:11:23 +0600 Subject: [PATCH] FIx Issue #84 - move SPARKs and other large units slightly to the right so they no longer obscure the promotion screen. --- .../Config/XComPromotionUIMod.ini | 6 +- .../Classes/CPS_UIArmory_PromotionHero.uc | 76 +++++++++++++++++++ 2 files changed, 81 insertions(+), 1 deletion(-) diff --git a/X2WOTCCommunityPromotionScreen/Config/XComPromotionUIMod.ini b/X2WOTCCommunityPromotionScreen/Config/XComPromotionUIMod.ini index a880c1c..b6d30b7 100644 --- a/X2WOTCCommunityPromotionScreen/Config/XComPromotionUIMod.ini +++ b/X2WOTCCommunityPromotionScreen/Config/XComPromotionUIMod.ini @@ -17,4 +17,8 @@ [X2WOTCCommunityPromotionScreen.CPS_UIArmory_PromotionHero] ;Toggle debug logging into Launch.log -;bLog = false \ No newline at end of file +;bLog = false + +; Move large units, like SPARKs, slightly to the side to prevent them from obscuring the promotion screen. +LargeUnitPawnOffset = -10 +LargeUnitPawnOffset_Brigadier = -30 diff --git a/X2WOTCCommunityPromotionScreen/Src/X2WOTCCommunityPromotionScreen/Classes/CPS_UIArmory_PromotionHero.uc b/X2WOTCCommunityPromotionScreen/Src/X2WOTCCommunityPromotionScreen/Classes/CPS_UIArmory_PromotionHero.uc index 773d054..2a50a92 100644 --- a/X2WOTCCommunityPromotionScreen/Src/X2WOTCCommunityPromotionScreen/Classes/CPS_UIArmory_PromotionHero.uc +++ b/X2WOTCCommunityPromotionScreen/Src/X2WOTCCommunityPromotionScreen/Classes/CPS_UIArmory_PromotionHero.uc @@ -11,6 +11,11 @@ var UIScrollbar Scrollbar; var config bool bLog; +// Vars for Issue #84 +var private config int LargeUnitPawnOffset_Brigadier; +var private config int LargeUnitPawnOffset; +// End Issue #84 + // Vars for Issue #7 enum EReasonLocked { @@ -289,6 +294,77 @@ simulated function PopulateData() HidePreview(); } +// Begin Issue #84 +private function MaybeAddLargeArmoryScaleOffset() +{ + local XComUnitPawnNativeBase NativePawn; + local PointInSpace PlacementActor; + local vector PawnLocation; + local XComGameState_Unit Unit; + + Unit = GetUnit(); + if (Unit == none || !Unit.UseLargeArmoryScale()) + return; + + NativePawn = XComUnitPawnNativeBase(ActorPawn); + if (NativePawn == none) + return; + + PlacementActor = GetPlacementActor(); + if (PlacementActor == none) + return; + + PawnLocation = PlacementActor.Location; + if (bHasBrigadierRank) + { + PawnLocation.X += LargeUnitPawnOffset_Brigadier; + } + else + { + PawnLocation.X += LargeUnitPawnOffset; + } + NativePawn.SetLocationNoCollisionCheck(PawnLocation); +} + +private function ResetPawnLocation() +{ + local XComUnitPawnNativeBase NativePawn; + local PointInSpace PlacementActor; + + `LOG(self.Class.name @ GetFuncName(), bLog, 'PromotionScreen'); + + NativePawn = XComUnitPawnNativeBase(ActorPawn); + if (NativePawn == none) + return; + + PlacementActor = GetPlacementActor(); + if (PlacementActor == none) + return; + + NativePawn.SetLocationNoCollisionCheck(PlacementActor.Location); +} +// End Issue #84 + +simulated function CreateSoldierPawn(optional Rotator DesiredRotation) +{ + `LOG(self.Class.name @ GetFuncName(), bLog, 'PromotionScreen'); + + super.CreateSoldierPawn(DesiredRotation); + + // Single line for Issue #84 - Add horizontal offset to large units so they don't obscure the promotion screen. + MaybeAddLargeArmoryScaleOffset(); +} + +simulated function OnRemoved() +{ + `LOG(self.Class.name @ GetFuncName(), bLog, 'PromotionScreen'); + + // Single line for Issue #84 - move pawn back to its original armory location. + ResetPawnLocation(); + + super.OnRemoved(); +} + // Start Issue #36 // // We override ChangeSelectedColumn() so that we can inject better behavior