Skip to content

Commit

Permalink
Modified UIAlert to use the "TrainingComplete" alert for positive tra…
Browse files Browse the repository at this point in the history
…its -

This has the same set of UI elements as Alert_NegativeSoldierEvent for negative traits
but with a neutral colour scheme & promotion-like-icon.

Updated XcomHQPresentationLayer to check whether traits are positive or negative
before calling the notifybanner (this is the piece which places the trait notifications
on the bottom left of the screen). Adjusted the icons in the notification area to make
more sense.

Adjusted the UIAvengerHUD OnClickTraitIcon function so if someone clicks on a soldier
with a negative or positive trait, it takes them to the correct UI Panel.
  • Loading branch information
BlackDog86 committed Jun 26, 2023
1 parent d35f137 commit d38839c
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 78 deletions.
82 changes: 33 additions & 49 deletions X2WOTCCommunityHighlander/Src/XComGame/Classes/UIAlert.uc
Original file line number Diff line number Diff line change
Expand Up @@ -954,14 +954,15 @@ simulated function BuildAlert()
case 'eAlert_RescueSoldier':
BuildRescueSoldierAlert();
break;

//Begin Issue #1081
// Use the same trait-build function but pass in arguments for positive & negative as needed
case 'eAlert_NegativeTraitAcquired':
BuildNegativeTraitAcquiredAlert();
BuildTraitAcquiredAlert(false);
break;
case 'eAlert_PositiveTraitAcquired':
BuildPositiveTraitAcquiredAlert();
BuildTraitAcquiredAlert(true);
break;

//End Issue #1081
case 'eAlert_InspiredResearchAvailable':
BuildInspiredResearchAvailableAlert();
break;
Expand Down Expand Up @@ -1242,8 +1243,9 @@ simulated function Name GetLibraryID()
case 'eAlert_RescueSoldier': return 'XPACK_Alert_MissionSplash';

case 'eAlert_NegativeTraitAcquired': return 'Alert_NegativeSoldierEvent';
case 'eAlert_PositiveTraitAcquired': return 'Alert_AssignStaff';

//Issue #1081
//Changed Alert_Assignstaff to Alert_TrainingComplete to present an improved UI panel for positive traits
case 'eAlert_PositiveTraitAcquired': return 'Alert_TrainingComplete';
case 'eAlert_InspiredResearchAvailable': return 'Alert_ItemAvailable';
case 'eAlert_BreakthroughResearchAvailable': return 'Alert_ItemAvailable';
case 'eAlert_BreakthroughResearchComplete': return 'Alert_ItemAvailable';
Expand Down Expand Up @@ -4062,10 +4064,15 @@ simulated function BuildSuperSoldierAlert()
LibraryPanel.MC.FunctionString("UpdateImage", class'X2StrategyGameRulesetDataStructures'.static.GetDynamicStringProperty(DisplayPropertySet, 'StaffPicture'));
}

simulated function BuildNegativeTraitAcquiredAlert()
/// HL-Docs: bugfix:FixPositiveTraitUI; Issue:1081;
/// Removed duplicate 'positive traits' function - now handle all traits in the same one with a bool to indicate whether trait is positive or negative
/// Since Alert_NegativeSoldierEvent is a subclass of Alert_Trainingcomplete in flash, they take exactly the same arguments
/// This allows passing details to the panels using the same .uc code (but generating different outputs)
/// All specific references to 'negative' traits in the function have been removed
simulated function BuildTraitAcquiredAlert(bool bPositiveTrait)
{
local XComGameState_Unit UnitState;
local X2TraitTemplate NegativeTrait;
local X2TraitTemplate Trait;
local XGBaseCrewMgr CrewMgr;
local XComGameState_HeadquartersRoom RoomState;
local Vector ForceLocation;
Expand All @@ -4082,7 +4089,7 @@ simulated function BuildNegativeTraitAcquiredAlert()

EventTemplateManager = class'X2EventListenerTemplateManager'.static.GetEventListenerTemplateManager();

NegativeTrait = X2TraitTemplate(EventTemplateManager.FindEventListenerTemplate(
Trait = X2TraitTemplate(EventTemplateManager.FindEventListenerTemplate(
class'X2StrategyGameRulesetDataStructures'.static.GetDynamicNameProperty(DisplayPropertySet, 'PrimaryTraitTemplate')));

UnitState = XComGameState_Unit(`XCOMHISTORY.GetGameStateForObjectID(
Expand All @@ -4104,10 +4111,10 @@ simulated function BuildNegativeTraitAcquiredAlert()
// End Issue #106
RankName = Caps(UnitState.GetSoldierRankName()); // Issue #408

TraitDesc = NegativeTrait.TraitDescription;
if (NegativeTrait.TraitQuotes.Length > 0)
TraitDesc = Trait.TraitDescription;
if (Trait.TraitQuotes.Length > 0)
{
TraitDesc $= "\n\n" $ NegativeTrait.TraitQuotes[`SYNC_RAND(NegativeTrait.TraitQuotes.Length)];
TraitDesc $= "\n\n" $ Trait.TraitQuotes[`SYNC_RAND(Trait.TraitQuotes.Length)];
}

// Move the camera
Expand All @@ -4126,59 +4133,36 @@ simulated function BuildNegativeTraitAcquiredAlert()

// Send over to flash
LibraryPanel.MC.BeginFunctionOp("UpdateData");
LibraryPanel.MC.QueueString(m_strNegativeTraitAcquiredTitle);
// Start Issue# 1081
// Check trait type and pass localised string into to UI panel
If (bPositiveTrait)
{
LibraryPanel.MC.QueueString(m_strPositiveTraitAcquiredTitle);
}
Else
{
LibraryPanel.MC.QueueString(m_strNegativeTraitAcquiredTitle);
}
LibraryPanel.MC.QueueString("");
LibraryPanel.MC.QueueString(ClassIcon);
LibraryPanel.MC.QueueString(RankName);
LibraryPanel.MC.QueueString(UnitState.GetName(eNameType_FullNick));
LibraryPanel.MC.QueueString(ClassName);
LibraryPanel.MC.QueueString(NegativeTrait.IconImage); // Ability Icon
LibraryPanel.MC.QueueString(NegativeTrait.TraitFriendlyName); // Ability Label
LibraryPanel.MC.QueueString(NegativeTrait.TraitScientificName); // Ability Name
LibraryPanel.MC.QueueString(Trait.IconImage); // Ability Icon
LibraryPanel.MC.QueueString(Trait.TraitFriendlyName); // Ability Label
LibraryPanel.MC.QueueString(Trait.TraitScientificName); // Ability Name
LibraryPanel.MC.QueueString(TraitDesc); // Ability Description
LibraryPanel.MC.QueueString("");
LibraryPanel.MC.QueueString(m_strOk);
LibraryPanel.MC.EndOp();
GetOrStartWaitingForStaffImage();

// Always hide the "Continue" button, since this is just an informational popup
Button2.SetGamepadIcon(class'UIUtilities_Input'.static.GetAdvanceButtonIcon()); //bsg-hlee (05.09.17): Changing the icon to A.
Button1.Hide();
Button1.DisableNavigation();
}

simulated function BuildPositiveTraitAcquiredAlert()
{
local XComGameState_Unit UnitState;
local X2TraitTemplate PositiveTrait, NegativeTrait;
local X2EventListenerTemplateManager EventTemplateManager;

EventTemplateManager = class'X2EventListenerTemplateManager'.static.GetEventListenerTemplateManager();

PositiveTrait = X2TraitTemplate(EventTemplateManager.FindEventListenerTemplate(
class'X2StrategyGameRulesetDataStructures'.static.GetDynamicNameProperty(DisplayPropertySet, 'PrimaryTraitTemplate')));
NegativeTrait = X2TraitTemplate(EventTemplateManager.FindEventListenerTemplate(
class'X2StrategyGameRulesetDataStructures'.static.GetDynamicNameProperty(DisplayPropertySet, 'SecondaryTraitTemplate')));

UnitState = XComGameState_Unit(`XCOMHISTORY.GetGameStateForObjectID(
class'X2StrategyGameRulesetDataStructures'.static.GetDynamicIntProperty(DisplayPropertySet, 'UnitRef')));

// Send over to flash
LibraryPanel.MC.BeginFunctionOp("UpdateData");
LibraryPanel.MC.QueueString(m_strSoldierShakenHeader); //ATTENTION
LibraryPanel.MC.QueueString(m_strPositiveTraitAcquiredTitle);
LibraryPanel.MC.QueueString(""); //ICON
LibraryPanel.MC.QueueString(Caps(UnitState.GetName(eNameType_FullNick))); //STAFF AVAILABLE STRING
LibraryPanel.MC.QueueString("Positive Trait '" $ PositiveTrait.TraitFriendlyName $ "' acquired, replacing '" $ NegativeTrait.TraitFriendlyName $ "'."); //TODO: localize me
LibraryPanel.MC.QueueString(PositiveTrait.TraitDescription); //TODO: localize me
LibraryPanel.MC.QueueString("");
LibraryPanel.MC.QueueString(m_strOK); //OK
LibraryPanel.MC.EndOp();
GetOrStartWaitingForStaffImage();
//This panel has only one button, for confirm.
Button2.DisableNavigation();
Button2.Hide();
}

simulated function BuildSoldierShakenAlert()
{
local XComGameState_Unit UnitState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,31 +270,40 @@ function UITraitIcon CreateTraitIcon(XComGameState_Unit Unit, bool bPositive)

function OnClickTraitIcon(UITraitIcon Icon)
{
local int UntiID;
local int UnitID;
local XComGameState_Unit Unit;
local XComGameState NewGameState;
//start issue #85: variables required to check the trait template of what we've been given
local X2EventListenerTemplateManager EventTemplateManager;
local X2TraitTemplate TraitTemplate;
//end issue #85

UntiID = int(GetRightMost(string(Icon.MCName)));
Unit = XComGameState_Unit(`XCOMHISTORY.GetGameStateForObjectID(UntiID));
UnitID = int(GetRightMost(string(Icon.MCName)));
Unit = XComGameState_Unit(`XCOMHISTORY.GetGameStateForObjectID(UnitID));

if(Unit == none) return;

//start issue #85: init variables here to check for trait template. If Positive, we cancel this callback.
EventTemplateManager = class'X2EventListenerTemplateManager'.static.GetEventListenerTemplateManager();
TraitTemplate = X2TraitTemplate(EventTemplateManager.FindEventListenerTemplate(Unit.AlertTraits[0]));
//while it's an array, we go with the base game's assumption of having only one trait to worry about when it changes

if(TraitTemplate.bPositiveTrait)
return;
//end issue #85

//start issue #1081
//removed code which early exits the function if the user clicks on a positive trait

NewGameState = class'XComGameStateContext_ChangeContainer'.static.CreateChangeState("Unit Trait Display Cleanup");
Unit = XComGameState_Unit(NewGameState.ModifyStateObject(class'XComGameState_Unit', Unit.ObjectID));
XComHQPresentationLayer(Movie.Pres).UINegativeTraitAlert(NewGameState, Unit, Unit.AlertTraits[0]);
//added code which takes the user to the appropriate UI panel when they click on a positive or negative trait
if(TraitTemplate.bPositiveTrait)
{
XComHQPresentationLayer(Movie.Pres).UITraitAlert(NewGameState, Unit, Unit.AlertTraits[0], true);
}
else
{
XComHQPresentationLayer(Movie.Pres).UITraitAlert(NewGameState, Unit, Unit.AlertTraits[0], false);
}
// end issue #1081
`XCOMGAME.GameRuleset.SubmitGameState(NewGameState);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ var() bool bHasSeenCovertActionRiskIntroPopup;
var() bool bHasReceivedResistanceOrderPopup;
var() bool bHasSeenCantChangeOrdersPopup;
var() bool bHasSeenSoldierBondPopup;
var() bool bHasSeenNegativeTraitPopup;
//Issue# 1081 - Alter bool name so it applies to both positive and negative traits
var() bool bHasSeenTraitPopup;

// Tactical Tutorial Flags
var() bool bHasSeenTacticalTutorialSoldierBonds;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ simulated function ExitPostMissionSequence()
DLCInfos[i].OnExitPostMissionSequence();
}

PostMissionNegativeTraitNotifies();
PostMissionTraitNotifies();
PostMissionBondNotifies();

if( `CHEATMGR.bShouldAutosaveBeforeEveryAction )
Expand Down Expand Up @@ -429,7 +429,11 @@ private function PostMissionBondNotifies()
`XCOMGAME.GameRuleset.SubmitGameState(NewGameState);
}
private function PostMissionNegativeTraitNotifies()
/// HL-Docs: bugfix:FixPositiveTraitUI; Issue:1081;
/// Altered function name to fit with PostMissionBondNotifies
/// Adjusted NotifyBanner function to depend on trait status (positive or negative) & adjusted icons
/// Function Now passes a bool conditionally into UITraitAlert in order to select the correct positive or negative trait panel accordingly
private function PostMissionTraitNotifies()
{
local XComGameStateHistory History;
local XComGameState NewGameState;
Expand Down Expand Up @@ -457,29 +461,45 @@ private function PostMissionNegativeTraitNotifies()
foreach UnitState.WorldMessageTraits(TraitName)
{
TraitTemplate = X2TraitTemplate(EventTemplateManager.FindEventListenerTemplate(TraitName));
if(TraitTemplate != none)
{
NotifyBanner(UnitState.GetName(eNameType_Full), "img:///UILibrary_StrategyImages.X2StrategyMap.MapPin_Poi", class'UIAlert'.default.m_strNegativeTraitAcquiredTitle, TraitTemplate.TraitFriendlyName, eUIState_Bad);

//Begin Issue# 1081
if(TraitTemplate.bPositiveTrait)
{
NotifyBanner(UnitState.GetName(eNameType_Full), "img:///UILibrary_StrategyImages.X2StrategyMap.MapPin_GoldenPath", class'UIAlert'.default.m_strPositiveTraitAcquiredTitle, TraitTemplate.TraitFriendlyName, eUIState_Good);
}
else
{
NotifyBanner(UnitState.GetName(eNameType_Full), "img:///UILibrary_StrategyImages.X2StrategyMap.MapPin_Landing", class'UIAlert'.default.m_strNegativeTraitAcquiredTitle, TraitTemplate.TraitFriendlyName, eUIState_Bad);
}

if(PopupCount == 0)
{
PopupCount++;
PopupUnit = UnitState;
StoredTraitName = TraitName;
}
}
// Bring popupcount inside the foreach (unitstate)
if(PopupCount > 0 && !XComHQ.bHasSeenTraitPopup)
{
PopupCount++;
PopupUnit = UnitState;
StoredTraitName = TraitName;
XComHQ.bHasSeenTraitPopup = true;
// Bring up the positive or negative alert panel according to trait template
If (TraitTemplate.bPositiveTrait)
{
UITraitAlert(NewGameState, PopupUnit, StoredTraitName, true);
}
Else
{
UITraitAlert(NewGameState, PopupUnit, StoredTraitName, false);
}
}
}
}

// End issue# 1081
UnitState.WorldMessageTraits.Length = 0;
}

if(PopupCount > 0 && !XComHQ.bHasSeenNegativeTraitPopup)
{
XComHQ.bHasSeenNegativeTraitPopup = true;
UINegativeTraitAlert(NewGameState, PopupUnit, StoredTraitName);
}


`XCOMGAME.GameRuleset.SubmitGameState(NewGameState);
}

Expand Down Expand Up @@ -1717,14 +1737,24 @@ function UISoldierBondConfirm(XComGameState_Unit UnitRef1, XComGameState_Unit Un
}
}

function UINegativeTraitAlert(XComGameState NewGameState, XComGameState_Unit UnitState, Name TraitTemplateName)
/// HL-Docs: bugfix:FixPositiveTraitUI; Issue:1081;
/// Function adjusted to require a bool to be passed-in to determine which trait UI is brought up
function UITraitAlert(XComGameState NewGameState, XComGameState_Unit UnitState, Name TraitTemplateName, bool bPositiveTrait)
{
local DynamicPropertySet PropertySet;

UnitState.AlertTraits.RemoveItem(TraitTemplateName);
UnitState.WorldMessageTraits.RemoveItem(TraitTemplateName);

BuildUIAlert(PropertySet, 'eAlert_NegativeTraitAcquired', None, 'OnNegativeTraitAcquired', "Geoscape_CrewMemberLevelledUp", false);
//Begin issue #1081
if (bPositiveTrait)
{
BuildUIAlert(PropertySet, 'eAlert_PositiveTraitAcquired', None, 'OnPositiveTraitAcquired', "Geoscape_CrewMemberLevelledUp", false);
}
else
{
BuildUIAlert(PropertySet, 'eAlert_NegativeTraitAcquired', None, 'OnNegativeTraitAcquired', "Geoscape_CrewMemberLevelledUp", false);
}
//End issue #1081
class'X2StrategyGameRulesetDataStructures'.static.AddDynamicIntProperty(PropertySet, 'UnitRef', UnitState.ObjectID);
class'X2StrategyGameRulesetDataStructures'.static.AddDynamicNameProperty(PropertySet, 'PrimaryTraitTemplate', TraitTemplateName);
class'X2StrategyGameRulesetDataStructures'.static.AddDynamicNameProperty(PropertySet, 'SecondaryTraitTemplate', '');
Expand Down

0 comments on commit d38839c

Please sign in to comment.