Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add event for overriding resistance faction icon #1134 #1136

Merged

Conversation

FearTheBunnies
Copy link
Contributor

This is for issue #1134 which will allow mods to override the resistance faction icon when using custom hero classes.

@FearTheBunnies FearTheBunnies marked this pull request as ready for review January 29, 2022 03:55
@Iridar Iridar added the ready-to-review A pull request is ready to be reviewed label Jan 31, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Jan 31, 2022

Pull request modifies event listener templates

Difference (click to expand)
diff --git a/target/CHL_Event_Compiletest.uc b/target/CHL_Event_Compiletest.uc
index 6a129ae..c229218 100644
--- a/target/CHL_Event_Compiletest.uc
+++ b/target/CHL_Event_Compiletest.uc
@@ -919,6 +919,27 @@ static function EventListenerReturn OnOverrideShowPromoteIcon(Object EventData,
 	return ELR_NoInterrupt;
 }
 
+static function EventListenerReturn OnOverrideStackedClassIcon(Object EventData, Object EventSource, XComGameState GameState, Name EventID, Object CallbackObject)
+{
+	local XComGameState_Unit UnitState;
+	local XComLWTuple Tuple;
+	local array<string> Images;
+	local bool bInvertImage;
+
+	UnitState = XComGameState_Unit(EventSource);
+	Tuple = XComLWTuple(EventData);
+
+	Images = Tuple.Data[0].as;
+	bInvertImage = Tuple.Data[1].b;
+
+	// Your code here
+
+	Tuple.Data[0].as = Images;
+	Tuple.Data[1].b = bInvertImage;
+
+	return ELR_NoInterrupt;
+}
+
 static function EventListenerReturn OnOverrideTotalNumKills(Object EventData, Object EventSource, XComGameState GameState, Name EventID, Object CallbackObject)
 {
 	local XComGameState_Unit UnitState;
What? (click to expand)

The Highlander documentation tool generates event listener examples from event specifications.
This comment contains the modifications that would be made to the copy-pasteable event listeners in documentation, for PR authors and reviewers to inspect for correctness, and will automatically be kept up-to-date whenever this PR is updated.

Copy link
Member

@Xymanek Xymanek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In many places where you changed FactionState.GetFactionIcon() to UnitState.GetResistanceFactionIcon(), said code is wrapped into if (FactionState != none) - rending the feature useless for non-faction soldiers.

Instead, you should store the result of UnitState.GetResistanceFactionIcon() and change the checks to if (FactionIcon.Images.Length > 0)

@FearTheBunnies
Copy link
Contributor Author

In many places where you changed FactionState.GetFactionIcon() to UnitState.GetResistanceFactionIcon(), said code is wrapped into if (FactionState != none) - rending the feature useless for non-faction soldiers.

Instead, you should store the result of UnitState.GetResistanceFactionIcon() and change the checks to if (FactionIcon.Images.Length > 0)

Not opposed to changing the check, but was curious your thoughts on it. Originally that icon was only related to faction heroes, so this change would be expanding the functionality and I am wanting to make sure we're good with that.

@Xymanek
Copy link
Member

Xymanek commented Feb 14, 2022

While I understand the history behind the current setup, I think it's a disservice to the overall flexibility of the system - IMO they should've just converted all icons to stacked (albeit with a single item for traditional class icons). As such, I think it's a good idea to allow the stacked icons to be usable for normal soldiers

@Xymanek Xymanek added waiting-on-author A pull request is waiting on changes from the author and removed ready-to-review A pull request is ready to be reviewed labels Feb 26, 2022
@Xymanek Xymanek added this to the 1.24.0 milestone Feb 26, 2022
@FearTheBunnies
Copy link
Contributor Author

Updated the logic to make the event more generic so that non-hero soldiers can get the same benefit for having a stacked class icon instead of a flat class icon if a class author so wishes it. Also cleaned up the other couple of small asks.

@Xymanek
Copy link
Member

Xymanek commented Mar 2, 2022

Please force push this branch so that there is 1 commit for adding game files and 1 commit for all the changes

@FearTheBunnies
Copy link
Contributor Author

Flattened the commit and fixed documentation.

@Xymanek Xymanek merged commit f1f1f26 into X2CommunityCore:master Mar 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting-on-author A pull request is waiting on changes from the author
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Request: Add event for overriding Resistance Faction Icon in XComGameState_Unit
3 participants