Skip to content

Commit

Permalink
Fixed customization and camera, added commanders choice, added dialog…
Browse files Browse the repository at this point in the history
… for deployment
  • Loading branch information
bountygiver committed Mar 12, 2018
1 parent fb944d0 commit 3ec3dd9
Show file tree
Hide file tree
Showing 18 changed files with 1,118 additions and 149 deletions.
17 changes: 16 additions & 1 deletion WaveCOMWOTC/Config/XComGame.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
[WOTCWaveCOM.X2DownloadableContentInfo_WOTCWaveCOM]
DLCIdentifier="WOTCWaveCOM"
DLCIdentifier="WOTCWaveCOM"

[BetterSecondWaveSupport.X2DownloadableContentInfo_BetterSecondWaveSupport]
+AddSecondWave=(ID="WaveCOMCommandersChoice", DifficultyValue=0)

[ExtendedMissionTimers SecondWaveOptionObject]
Disabled=true

[ExtendedAvatarProject SecondWaveOptionObject]
Disabled=true

[PlayingForKeeps SecondWaveOptionObject]
Disabled=true

[WaveCOMCommandersChoice SecondWaveOptionObject]
CanChangeInCampaign=true
3 changes: 3 additions & 0 deletions WaveCOMWOTC/Localization/BetterSecondWaveSupport.int
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[WaveCOMCommandersChoice SecondWaveOptionObject]
Tooltip="Allows you to choose the soldier class of each promoted rookie. This is the only Commander's Choice Second Wave option that works with WaveCOM"
Description="(WaveCOM) Commander's Choice: Allow you to select classes of promoted rookies"
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class WaveCOM_Camera_Customization extends X2Camera_Fixed;

var public TPOV CameraViewX;

function SetCameraView(const out TPOV InCameraView)
{
CameraViewX = InCameraView;
}

function TPOV GetCameraLocationAndOrientation()
{
return CameraViewX;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class WaveCOM_UIArmory_FieldLoadout extends UIArmory_MainMenu;

var UITacticalHUD TacHUDScreen;
var X2Camera_LookAtActor FocusCamera;

simulated function OnAccept()
{
Expand Down Expand Up @@ -238,6 +239,8 @@ static function SyncVisualizers(array<XComGameState_Unit> UnitStates)
local StateObjectReference ItemReference;
local XComGameState NewGameState;
local XComGameState_Item ItemState;
local XComHumanPawn SoldierPawn;
local XGUnit Visualizer;

StateChangeContainer = WaveCOM_SyncVisualizerRuleset(class'WaveCOM_SyncVisualizerRuleset'.static.CreateXComGameStateContext());
//StateChangeContainer.GameRuleType = eGameRule_ForceSyncVisualizers;
Expand All @@ -247,7 +250,14 @@ static function SyncVisualizers(array<XComGameState_Unit> UnitStates)
foreach UnitStates(UnitState)
{
XComGameState_Unit(NewGameState.ModifyStateObject(class'XComGameState_Unit', UnitState.ObjectID));


Visualizer = XGUnit(UnitState.FindOrCreateVisualizer());
SoldierPawn = XComHumanPawn(Visualizer.GetPawn());
if (SoldierPawn != none)
{
SoldierPawn.SetAppearance(UnitState.kAppearance);
//`log("SoldierPawn.SetAppearance",, 'WaveCOM');
}
`log("Unit visualizer sync requested:" @ UnitState.ObjectID,, 'WaveCOM');

foreach UnitState.InventoryItems(ItemReference)
Expand Down Expand Up @@ -404,6 +414,7 @@ simulated function OnCancel()
`log("Cancelling");
super.OnCancel();
UpdateActiveUnit();
`CAMERASTACK.RemoveCamera(FocusCamera);
WCScreen = WaveCOM_UILoadoutButton(TacHUDScreen.GetChildByName('WaveCOMUI'));
if (WCScreen != none)
WCScreen.RefreshCanRankUp();
Expand All @@ -416,7 +427,6 @@ function SetTacHUDScreen(UITacticalHUD Screenie)

function Push_UICustomize_Menu(XComGameState_Unit UnitRef, Actor ActorPawnA)
{
TacHUDScreen.Movie.Pres.InitializeCustomizeManager(UnitRef);
TacHUDScreen.Movie.Stack.Push(TacHUDScreen.Spawn(class'WaveCOM_UICustomize_Menu', TacHUDScreen));
}

Expand Down Expand Up @@ -459,6 +469,7 @@ function Push_UISoldierBonds(StateObjectReference UnitRef)
function Push_UIArmory_Promotion(StateObjectReference UnitRef, optional bool bInstantTransition)
{
local UIArmory_Promotion PromotionUI;
local UIChooseClass ChooseClassUI;
local XComGameState_Unit UnitState;
local XComGameState_HeadquartersXCom XComHQ;
local XComGameState_Item InventoryItem;
Expand All @@ -468,10 +479,18 @@ function Push_UIArmory_Promotion(StateObjectReference UnitRef, optional bool bIn

local XComGameState NewGameState;
UnitState = XComGameState_Unit(`XCOMHISTORY.GetGameStateForObjectID(UnitRef.ObjectID));
if ( UnitState.GetRank() == 0 && UnitState.CanRankUpSoldier() && `SecondWaveEnabled('WaveCOMCommandersChoice') )
{
ChooseClassUI = WaveCOM_UIChooseClass(TacHUDScreen.Movie.Stack.Push(TacHUDScreen.Spawn(class'WaveCOM_UIChooseClass', TacHUDScreen)));
ChooseClassUI.m_UnitRef = UnitRef;
return;
}

EffectContext = class'WaveCOMGameStateContext_UpdateUnit'.static.CreateChangeStateUU("RankUp", UnitState);
NewGameState = EffectContext.GetGameState();
UnitState = XComGameState_Unit(NewGameState.ModifyStateObject(class'XComGameState_Unit', UnitRef.ObjectID));


while (UnitState.CanRankUpSoldier() && !UnitState.bRankedUp)
{
XComHQ = XComGameState_HeadquartersXCom(`XCOMHISTORY.GetSingleGameStateObjectForClass(class'XComGameState_HeadquartersXCom', true));
Expand Down Expand Up @@ -725,12 +744,17 @@ simulated function PopulateData()
{
CustomizeButton.SetDisabled(true, "Customization not supported");
}

FocusCamera.ActorToFollow = XGUnit(`XCOMHISTORY.GetVisualizer(UnitReference.ObjectID)).GetPawn();
}

simulated function InitArmory(StateObjectReference UnitRef, optional name DispEvent, optional name SoldSpawnEvent, optional name NavBackEvent, optional name HideEvent, optional name RemoveEvent, optional bool bInstant = false, optional XComGameState InitCheckGameState)
{
UnitReference = UnitRef;
ResetUnitState();
FocusCamera = new class'X2Camera_LookAtActor';
FocusCamera.UseTether = false;
`CAMERASTACK.AddCamera(FocusCamera);
bUseNavHelp = true;
super(UIArmory).InitArmory(UnitRef, DispEvent, SoldSpawnEvent, NavBackEvent, HideEvent, RemoveEvent, bInstant, InitCheckGameState);

Expand Down Expand Up @@ -1119,4 +1143,4 @@ simulated function bool OnUnrealCommand(int cmd, int arg)
defaultproperties
{
bUseNavHelp = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,88 +170,28 @@ simulated function ChangeActiveList(UIList kActiveList, optional bool bSkipAnima
UpdateNavHelp();
}

function PreviewWeaponPattern(UIList _list, int itemIndex)
// Only allowed to customize name, please use customization menu for everything else
simulated function UpdateCustomization(UIPanel DummyParam)
{
local int newIndex;
local array<X2BodyPartTemplate> BodyParts;
local X2BodyPartTemplateManager PartManager;
local int i;
local XGParamTag LocTag;

CreateCustomizationState();

PartManager = class'X2BodyPartTemplateManager'.static.GetBodyPartTemplateManager();
PartManager.GetFilteredUberTemplates("Patterns", self, `XCOMGAME.SharedBodyPartFilter.FilterAny, BodyParts);
LocTag = XGParamTag(`XEXPANDCONTEXT.FindTag("XGParam"));
LocTag.StrValue0 = Caps(UpdatedWeapon.GetMyTemplate().GetItemFriendlyName(UpdatedWeapon.ObjectID));

newIndex = WrapIndex( itemIndex, 0, BodyParts.Length);

UpdatedWeapon.WeaponAppearance.nmWeaponPattern = BodyParts[newIndex].DataName;

CleanupCustomizationState();
}
SetCustomizeTitle(`XEXPAND.ExpandString(m_strCustomizeWeaponTitle));

function UpdateWeaponPattern(UIList _list, int itemIndex)
{
local int newIndex;
local array<X2BodyPartTemplate> BodyParts;
local X2BodyPartTemplateManager PartManager;
local XComGameState_Unit Unit;
local XGUnit Visualizer;
// WEAPON NAME
//-----------------------------------------------------------------------------------------

CreateCustomizationState();
GetCustomizeItem(i++).UpdateDataDescription(m_strCustomizeWeaponName, OpenWeaponNameInputBox);

PartManager = class'X2BodyPartTemplateManager'.static.GetBodyPartTemplateManager();
PartManager.GetFilteredUberTemplates("Patterns", self, `XCOMGAME.SharedBodyPartFilter.FilterAny, BodyParts);
CustomizeList.SetPosition(CustomizationListX, CustomizationListY - CustomizeList.ShrinkToFit() - CustomizationListYPadding);

newIndex = WrapIndex( itemIndex, 0, BodyParts.Length);

UpdatedWeapon.WeaponAppearance.nmWeaponPattern = BodyParts[newIndex].DataName;

// Transfer the new weapon pattern back to the owner Unit's appearance data ONLY IF the weapon is otherwise unmodified
Unit = GetUnit();
if (Unit != none && !UpdatedWeapon.HasBeenModified())
{
Unit = XComGameState_Unit(CustomizationState.ModifyStateObject(class'XComGameState_Unit', Unit.ObjectID));
Unit.kAppearance.nmWeaponPattern = UpdatedWeapon.WeaponAppearance.nmWeaponPattern;
Visualizer = XGUnit(Unit.FindOrCreateVisualizer());
XComHumanPawn(Visualizer.GetPawn()).SetAppearance(Unit.kAppearance);
}

SubmitCustomizationChanges();
}


function SetWeaponColor(int iColorIndex)
{
local XComGameState_Unit Unit;
local array<string> Colors;
local XGUnit Visualizer;

Colors = GetWeaponColorList();
CreateCustomizationState();
UpdatedWeapon.WeaponAppearance.iWeaponTint = WrapIndex(iColorIndex, 0, Colors.Length);

// Transfer the new weapon color back to the owner Unit's appearance data ONLY IF the weapon is otherwise unmodified
Unit = GetUnit();
if (Unit != none && !UpdatedWeapon.HasBeenModified())
{
Unit = XComGameState_Unit(CustomizationState.ModifyStateObject(class'XComGameState_Unit', Unit.ObjectID));
Unit.kAppearance.iWeaponTint = UpdatedWeapon.WeaponAppearance.iWeaponTint;
Visualizer = XGUnit(Unit.FindOrCreateVisualizer());
XComHumanPawn(Visualizer.GetPawn()).SetAppearance(Unit.kAppearance);
}

SubmitCustomizationChanges();

CloseColorSelector();
CustomizeList.Show();
UpdateCustomization(none);
ShowListItems();
}

function int GetWeaponPatternIndex()
{
return 0;
CleanupCustomizationState();
}

simulated function PrevSoldier()
{
// Do not switch soldiers in this screen
Expand All @@ -261,9 +201,3 @@ simulated function NextSoldier()
{
// Do not switch soldiers in this screen
}

simulated function CustomizeWeaponPattern()
{
XComHQPresentationLayer(Movie.Pres).UIArmory_WeaponTrait(WeaponRef, class'WaveCOM_UICustomize_Props'.default.m_strWeaponPattern, GetWeaponPatternList(),
PreviewWeaponPattern, UpdateWeaponPattern, CanCycleTo, GetWeaponPatternIndex(),,, false);
}
78 changes: 78 additions & 0 deletions WaveCOMWOTC/Src/WOTCWaveCOM/Classes/WaveCOM_UIChooseClass.uc
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
class WaveCOM_UIChooseClass extends UIChooseClass;

simulated function array<Commodity> ConvertClassesToCommodities()
{
local X2SoldierClassTemplate ClassTemplate;
local int iClass;
local array<Commodity> arrCommodoties;
local Commodity ClassComm;

m_arrClasses.Remove(0, m_arrClasses.Length);
m_arrClasses = GetClasses();
m_arrClasses.Sort(SortClassesByName);

for (iClass = 0; iClass < m_arrClasses.Length; iClass++)
{
ClassTemplate = m_arrClasses[iClass];

ClassComm.Title = ClassTemplate.DisplayName;
ClassComm.Image = ClassTemplate.IconImage;
ClassComm.Desc = ClassTemplate.ClassSummary;
ClassComm.OrderHours = 0;

arrCommodoties.AddItem(ClassComm);
}

return arrCommodoties;
}

function bool OnClassSelected(int iOption)
{
local XComGameState NewGameState;
local XComGameState_Unit UnitState;
local XComGameState_HeadquartersXCom NewXComHQ;
local XComGameState_Item InventoryItem;
local array<XComGameState_Item> InventoryItems;
local XGItem ItemVisualizer;

if (m_UnitRef.ObjectID <= 0)
{
return false;
}

NewGameState = class'XComGameStateContext_ChangeContainer'.static.CreateChangeState("Training new rookie");
UnitState = XComGameState_Unit(NewGameState.ModifyStateObject(class'XComGameState_Unit', m_UnitRef.ObjectID));

NewXComHQ = XComGameState_HeadquartersXCom(NewGameState.ModifyStateObject(class'XComGameState_HeadquartersXCom', XComHQ.ObjectID));
class'WaveCOM_UIArmory_FieldLoadout'.static.CleanUpStats(NewGameState, UnitState);
UnitState.RankUpSoldier(NewGameState, m_arrClasses[iOption].DataName);
InventoryItems = UnitState.GetAllInventoryItems(NewGameState);

foreach InventoryItems(InventoryItem)
{
NewXComHQ.PutItemInInventory(NewGameState, InventoryItem);
UnitState.RemoveItemFromInventory(InventoryItem, NewGameState);
ItemVisualizer = XGItem(`XCOMHISTORY.GetVisualizer(InventoryItem.GetReference().ObjectID));
ItemVisualizer.Destroy();
`XCOMHISTORY.SetVisualizer(InventoryItem.GetReference().ObjectID, none);
}
UnitState.ApplySquaddieLoadout(NewGameState, NewXComHQ);
UnitState.ApplyBestGearLoadout(NewGameState); // Make sure the squaddie has the best gear available

UnitState.ValidateLoadout(NewGameState);
if (UnitState.GetSoldierRank() < UnitState.StartingRank)
{
UnitState.bRankedUp = false; // Keep leveling up until it catches up to the appropriate rank.
}

`XCOMGAME.GameRuleset.SubmitGameState(NewGameState);

`XSTRATEGYSOUNDMGR.PlaySoundEvent("StrategyUI_Staff_Assign");

return true;
}

defaultproperties
{
bConsumeMouseEvents = true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,4 @@ function SetNewResearchProject(int iOption)
defaultproperties
{
bConsumeMouseEvents = true;
}
}
Loading

0 comments on commit 3ec3dd9

Please sign in to comment.