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

Allow Facility Staff Slot UI class to be overridden depending on facility #201

Open
robojumper opened this issue Mar 15, 2017 · 2 comments

Comments

@robojumper
Copy link
Member

Currently, UIFacilityStaffContainer does this:

switch (Movie.Stack.GetCurrentClass())
{
case class'UIFacility_Academy':
	StaffSlots.AddItem(Spawn(class'UIFacility_AcademySlot', self).InitStaffSlot(self, LocationRef, i, onStaffUpdatedDelegate));
	break;
case class'UIFacility_AdvancedWarfareCenter':
	if (StaffSlot.IsSoldierSlot())
		StaffSlots.AddItem(Spawn(class'UIFacility_AdvancedWarfareCenterSlot', self).InitStaffSlot(self, LocationRef, i, onStaffUpdatedDelegate));
	else
		StaffSlots.AddItem(Spawn(class'UIFacility_StaffSlot', self).InitStaffSlot(self, LocationRef, i, onStaffUpdatedDelegate));
	break;
case class'UIFacility_PsiLab':
	if (StaffSlot.IsSoldierSlot())
		StaffSlots.AddItem(Spawn(class'UIFacility_PsiLabSlot', self).InitStaffSlot(self, LocationRef, i, onStaffUpdatedDelegate));
	else
		StaffSlots.AddItem(Spawn(class'UIFacility_StaffSlot', self).InitStaffSlot(self, LocationRef, i, onStaffUpdatedDelegate));
	break;
default:
	StaffSlots.AddItem(Spawn(class'UIFacility_StaffSlot', self).InitStaffSlot(self, LocationRef, i, onStaffUpdatedDelegate));
	break;
}

which is bad because it doesn't allow new Staff Slot types without major hackery using UIScreenListeners and also doesn't allow overrides of UIFacility classes.

A mechanism would be needed to expand this behavior to allow custom UIFacility_StaffSlot classes.

@robojumper
Copy link
Member Author

My idea would be adding a property + getter to X2StaffSlotTemplate that returns the UI class for the staff slot. That way, we can break up this whole switch statement and replace it with something more sensible.

@robojumper
Copy link
Member Author

Considerations: Adding a delegate / member to X2StaffSlotTemplate is a change in data layout, which is fine at the moment.
However, if it were to be made a native class in the future (not that I expect it to), this approach would break, in addition to mods that were to use it.
A safer option would be making it a function that reads from a config map, but can be overridden by subclasses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant