KF2-Server-Extension/ServerExt/Classes/ExtMenu_Gear.uc

679 lines
21 KiB
Ucode
Raw Normal View History

2017-10-20 02:00:49 +00:00
class ExtMenu_Gear extends KFGFxObject_Menu;
var ExtPlayerReplicationInfo ExtPRI;
// var KFGFxObject_TraderItems TraderItems;
2017-10-20 02:00:49 +00:00
var KFGFxGearContainer_PerksSelection PerkSelectionContainer;
var KFCharacterInfo_Human CurrentCharInfo;
var string CharInfoPath;
var int CurrentPerkIndex;
var array<class<KFWeaponDefinition> > CurrentWearponDefList;
var array<Emote> EmoteList;
var bool bWaitingCharList,bIsCustomChar;
2020-11-28 20:04:55 +00:00
function InitializeMenu(KFGFxMoviePlayer_Manager InManager)
2017-10-20 02:00:49 +00:00
{
2020-11-28 19:53:57 +00:00
super(KFGFxObject_Menu).InitializeMenu(InManager);
2020-11-28 20:04:55 +00:00
CheckForCustomizationPawn(GetPC());
2020-11-28 19:53:57 +00:00
LocalizeText();
EmoteList = class'ExtEmoteList'.static.GetEmoteArray();
InitCharacterMenu();
2020-11-28 20:04:55 +00:00
// TraderItems = KFGameReplicationInfo(GetPC().WorldInfo.GRI).TraderItems;
2017-10-20 02:00:49 +00:00
}
2020-11-28 21:54:57 +00:00
2017-10-20 02:00:49 +00:00
function InitCharacterMenu()
{
2020-11-28 19:53:57 +00:00
ExtPRI = ExtPlayerReplicationInfo(GetPC().PlayerReplicationInfo);
2020-11-28 20:12:58 +00:00
if (ExtPRI!=None && ExtPRI.bClientInitChars)
2020-11-28 19:53:57 +00:00
CharListRecieved();
2020-11-28 20:12:58 +00:00
else if (ExtPRI==None)
2020-11-28 19:53:57 +00:00
{
2020-11-28 20:12:58 +00:00
if (GetPC().PlayerReplicationInfo!=None) // Faulty mod setup.
2020-11-28 19:53:57 +00:00
{
bWaitingCharList = true;
return;
}
GetPC().SetTimer(0.1,false,'InitCharacterMenu',Self);
}
else
{
ExtPRI.OnCharListDone = CharListRecieved;
bWaitingCharList = true;
}
2017-10-20 02:00:49 +00:00
}
event bool WidgetInitialized(name WidgetName, name WidgetPath, GFxObject Widget)
2020-11-28 19:53:57 +00:00
{
2020-11-28 20:12:58 +00:00
switch (WidgetName)
2020-11-28 19:53:57 +00:00
{
case 'perkSelectionContainer':
2020-11-28 20:04:55 +00:00
if (PerkSelectionContainer == none)
2020-11-28 19:53:57 +00:00
{
2020-11-28 20:04:55 +00:00
PerkSelectionContainer = KFGFxGearContainer_PerksSelection(Widget);
2020-11-28 19:53:57 +00:00
PerkSelectionContainer.Initialize(self);
}
break;
}
2020-01-09 11:05:13 +00:00
2020-11-28 19:53:57 +00:00
return true;
2017-10-20 02:00:49 +00:00
}
function OnOpen()
{
2020-11-28 19:53:57 +00:00
local PlayerController PC;
2020-01-09 11:05:13 +00:00
2020-11-28 19:53:57 +00:00
PC = GetPC();
2020-11-28 20:12:58 +00:00
if (PC == none)
2020-11-28 19:53:57 +00:00
return;
2020-11-28 20:04:55 +00:00
CheckForCustomizationPawn(PC);
2020-11-28 19:53:57 +00:00
//GetGameViewportClient().HandleInputAxis = OnAxisModified;
2020-01-09 11:05:13 +00:00
2020-11-28 20:04:55 +00:00
if (PC.PlayerReplicationInfo.bReadyToPlay && PC.WorldInfo.GRI.bMatchHasBegun)
2020-11-28 19:53:57 +00:00
{
// Players cannot change characters if they are in a game
SetBool("characterButtonEnabled", false);
}
2020-01-09 11:05:13 +00:00
}
2017-10-20 02:00:49 +00:00
2020-01-09 11:05:13 +00:00
/** The customization pawn won't exist if this menu was opened mid-match */
2020-11-28 20:04:55 +00:00
function CheckForCustomizationPawn(PlayerController PC)
2020-01-09 11:05:13 +00:00
{
2020-11-28 19:53:57 +00:00
local KFPlayerController KFPC;
2020-01-09 11:05:13 +00:00
2020-11-28 20:12:58 +00:00
if (PC.Pawn == None || (!PC.Pawn.IsAliveAndWell() && KFPawn_Customization(PC.Pawn) == None))
2020-11-28 19:53:57 +00:00
{
2020-11-28 20:04:55 +00:00
KFPC = KFPlayerController(PC);
2020-11-28 20:12:58 +00:00
if (KFPC != None)
2020-11-28 19:53:57 +00:00
{
KFPC.SpawnMidGameCustomizationPawn();
}
}
2017-10-20 02:00:49 +00:00
}
function LocalizeText()
{
2020-11-28 19:53:57 +00:00
local GFxObject LocalizedObject;
2017-10-20 02:00:49 +00:00
2020-11-28 19:53:57 +00:00
LocalizedObject = CreateObject("Object");
2017-10-20 02:00:49 +00:00
2020-11-28 19:53:57 +00:00
LocalizedObject.SetString("header", class'KFGFxMenu_Gear'.Default.GearHeaderString);
LocalizedObject.SetString("listButton", class'KFGFxMenu_Gear'.Default.BackString);
LocalizedObject.SetString("bioStringText", class'KFGFxMenu_Gear'.Default.BioString);
LocalizedObject.SetString("charactersString", class'KFGFxMenu_Gear'.Default.CharacterString);
LocalizedObject.SetString("headsString", class'KFGFxMenu_Gear'.Default.HeadString);
LocalizedObject.SetString("emoteString", Class'KFLocalMessage_VoiceComms'.default.VoiceCommsOptionStrings[8]);
LocalizedObject.SetString("bodiesString", class'KFGFxMenu_Gear'.Default.BodyString);
LocalizedObject.SetString("skinsString", class'KFGFxMenu_Gear'.Default.SkinsString);
LocalizedObject.SetString("attachmentsString", class'KFGFxMenu_Gear'.Default.AttachmentsString);
2017-10-20 02:00:49 +00:00
2020-11-28 19:53:57 +00:00
SetObject("localizeText", LocalizedObject);
2017-10-20 02:00:49 +00:00
}
simulated function CharListRecieved()
{
2020-11-28 19:53:57 +00:00
UpdateCharacterList();
UpdateGear();
2017-10-20 02:00:49 +00:00
}
function UpdateEmoteList()
{
2020-11-28 19:53:57 +00:00
local int ItemIndex, i;
local GFxObject DataProvider, SlotObject;
local string TexturePath;
ItemIndex = 0;
DataProvider = CreateArray();
for (i = 0; i < EmoteList.length; i++)
{
2020-11-28 20:04:55 +00:00
if (class'ExtEmoteList'.static.GetUnlockedEmote(EmoteList[i].Id, ExtPlayerController(GetPC())) != 'NONE')
2020-11-28 19:53:57 +00:00
{
2020-11-28 20:04:55 +00:00
SlotObject = CreateObject("Object");
2020-11-28 19:53:57 +00:00
SlotObject.SetInt("ItemIndex", i);
SlotObject.SetString("label", Localize(EmoteList[i].ItemName, "EmoteName", class'KFGFxMenu_Gear'.Default.KFCharacterInfoString));
TexturePath = "img://"$EmoteList[i].IconPath;
SlotObject.SetBool("enabled", true);
SlotObject.SetString("source", TexturePath);
DataProvider.SetElementObject(ItemIndex, SlotObject);
ItemIndex++;
}
else
{
//`log(MyKFPRI.EmoteList[i] @ "is not purchased.");
}
}
SetObject("emoteArray", DataProvider);
2017-10-20 02:00:49 +00:00
}
function UpdateCharacterList()
{
2020-11-28 19:53:57 +00:00
local int i, ItemIndex;
local GFxObject DataProvider, SlotObject;
local string TexturePath;
bWaitingCharList = false;
ItemIndex = 0;
DataProvider = CreateArray();
2020-11-28 20:12:58 +00:00
for (i=0; i<ExtPRI.CharacterArchetypes.length; i++)
2020-11-28 19:53:57 +00:00
{
2020-11-28 20:04:55 +00:00
SlotObject = CreateObject("Object");
2020-11-28 19:53:57 +00:00
SlotObject.SetInt("ItemIndex", i);
SlotObject.SetString("label", Localize(String(ExtPRI.CharacterArchetypes[i].Name), "CharacterName", class'KFGFxMenu_Gear'.Default.KFCharacterInfoString));
SlotObject.SetBool("enabled", true);
TexturePath = "img://"$PathName(ExtPRI.CharacterArchetypes[i].DefaultHeadPortrait);
SlotObject.SetString("source", TexturePath);
DataProvider.SetElementObject(ItemIndex, SlotObject);
ItemIndex++;
}
2020-11-28 20:12:58 +00:00
for (i=0; i<ExtPRI.CustomCharList.length; i++)
2020-11-28 19:53:57 +00:00
{
2020-11-28 20:12:58 +00:00
if (!ExtPRI.IsClientCharLocked(ExtPRI.CharacterArchetypes.length+i))
2020-11-28 19:53:57 +00:00
{
2020-11-28 20:04:55 +00:00
SlotObject = CreateObject("Object");
2020-11-28 19:53:57 +00:00
SlotObject.SetInt("ItemIndex", (ExtPRI.CharacterArchetypes.length+i));
SlotObject.SetString("label", Repl(string(ExtPRI.CustomCharList[i].Char.Name),"_"," "));
SlotObject.SetBool("enabled", true);
TexturePath = "img://"$PathName(ExtPRI.CustomCharList[i].Char.DefaultHeadPortrait);
SlotObject.SetString("source", TexturePath);
DataProvider.SetElementObject(ItemIndex, SlotObject);
ItemIndex++;
}
}
SetObject("characterArray", DataProvider);
2017-10-20 02:00:49 +00:00
}
function UpdateGear()
{
2020-11-28 20:12:58 +00:00
if (bWaitingCharList)
2020-11-28 19:53:57 +00:00
return;
2020-01-09 11:05:13 +00:00
2020-11-28 19:53:57 +00:00
CurrentCharInfo = ExtPRI.GetSelectedArch();
bIsCustomChar = ExtPRI.ReallyUsingCustomChar();
2020-01-09 11:05:13 +00:00
2020-11-28 19:53:57 +00:00
CharInfoPath = String(CurrentCharInfo.Name);
// Set the list of usable bodies for this character
UpdateMeshList(class'KFGFxMenu_Gear'.Default.BodyMeshKey, class'KFGFxMenu_Gear'.Default.BodySkinKey, CurrentCharInfo.BodyVariants, "bodyArray");
// Set the list of usable heads for this character
UpdateMeshList(class'KFGFxMenu_Gear'.Default.HeadMeshKey, class'KFGFxMenu_Gear'.Default.HeadSkinKey, CurrentCharInfo.HeadVariants, "headsArray");
// Set the list of usable attachments for this character
UpdateAttachmentsList(CurrentCharInfo.CosmeticVariants);
UpdateEmoteList();
2020-01-09 11:05:13 +00:00
2020-11-28 19:53:57 +00:00
SetCurrentCharacterButtons();
2017-10-20 02:00:49 +00:00
}
2020-11-28 20:04:55 +00:00
final function string GetMenuName(Object Obj)
2017-10-20 02:00:49 +00:00
{
2020-11-28 19:53:57 +00:00
return Obj==None ? "Empty" : Repl(string(Obj.Name),"_"," ");
2017-10-20 02:00:49 +00:00
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
final function string GetMenuNameStr(string ObjName)
2017-10-20 02:00:49 +00:00
{
2020-11-28 19:53:57 +00:00
local int i;
i = InStr(ObjName,".",true);
2020-11-28 20:12:58 +00:00
if (i!=-1)
2020-11-28 19:53:57 +00:00
ObjName = Mid(ObjName,i+1);
return Repl(ObjName,"_"," ");
2017-10-20 02:00:49 +00:00
}
function UpdateMeshList(string OutfitKey, string SkinKey, array<OutfitVariants> Outfits, string DataArrayString)
{
2020-11-28 19:53:57 +00:00
local int i, ItemIndex;
local GFxObject DataProvider, SlotObject;
local string TexturePath, OutfitName;
local OutfitVariants Outfit;
local SkinVariant FirstSkin;
ItemIndex = 0;
DataProvider = CreateArray();
for (i = 0; i < Outfits.Length; i++)
{
Outfit = Outfits[i];
OutfitName = Localize(CharInfoPath, OutfitKey$i, class'KFGFxMenu_Gear'.Default.KFCharacterInfoString);
2020-11-28 20:12:58 +00:00
if (bIsCustomChar)
2020-11-28 19:53:57 +00:00
OutfitName = GetMenuNameStr(Outfit.MeshName);
2020-11-28 20:04:55 +00:00
if (InStr(OutfitName, "?INT?") != -1)
2020-11-28 19:53:57 +00:00
continue;
2020-11-28 20:04:55 +00:00
SlotObject = CreateObject("Object");
2020-11-28 19:53:57 +00:00
SlotObject.SetInt("ItemIndex", i);
SlotObject.SetString("label", OutfitName);
SlotObject.SetBool("enabled", true);
2020-11-28 20:04:55 +00:00
FirstSkin = UpdateOutfitVariants(OutfitKey, SkinKey, Outfit.SkinVariations, i, SlotObject);
2020-11-28 20:12:58 +00:00
if (string(FirstSkin.UITexture) == "Bad")
2020-11-28 19:53:57 +00:00
continue;
TexturePath = "img://"$PathName(FirstSkin.UITexture);
SlotObject.SetString("source", TexturePath);
DataProvider.SetElementObject(ItemIndex, SlotObject);
ItemIndex++;
}
SetObject(DataArrayString, DataProvider);
}
2017-10-20 02:00:49 +00:00
function SkinVariant UpdateOutfitVariants(string OutfitKey, string KeyName, out array<SkinVariant> SkinVariations, int OutfitIndex, out GFxObject MeshObject)
{
2020-11-28 19:53:57 +00:00
local int i, ItemIndex;
local GFxObject DataProvider, SlotObject;
local SkinVariant Skin;
local SkinVariant FirstSkin;
local string SectionPath;
local string TexturePath;
local bool bFoundFirst;
ItemIndex = 0;
DataProvider = CreateArray();
SectionPath = CharInfoPath$"."$OutfitKey$OutfitIndex;
for (i = 0; i < SkinVariations.length; i++)
{
Skin = SkinVariations[i];
2020-11-28 20:12:58 +00:00
if (!bFoundFirst)
2020-11-28 19:53:57 +00:00
{
FirstSkin = Skin;
bFoundFirst = true;
}
2020-11-28 20:04:55 +00:00
SlotObject = CreateObject("Object");
2020-11-28 19:53:57 +00:00
SlotObject.SetInt("ItemIndex", i);
SlotObject.SetString("label", Localize(SectionPath, KeyName$i, class'KFGFxMenu_Gear'.Default.KFCharacterInfoString));
TexturePath = "img://"$PathName(Skin.UITexture);
SlotObject.SetBool("enabled", true);
SlotObject.SetString("source", TexturePath);
DataProvider.SetElementObject(ItemIndex, SlotObject);
ItemIndex++;
}
MeshObject.SetObject("skinInfo", DataProvider);
return FirstSkin;
2017-10-20 02:00:49 +00:00
}
function UpdateAttachmentsList(array<AttachmentVariants> Attachments)
{
2020-11-28 19:53:57 +00:00
local int i, ItemIndex;
local GFxObject DataProvider, SlotObject;
local string TexturePath;
local AttachmentVariants Variant;
local Pawn MyPawn;
local SkinVariant FirstSkin;
local string AttachmentName;
ItemIndex = 0;
DataProvider = CreateArray();
MyPawn = GetPC().Pawn;
// Insert blank object
2020-11-28 20:04:55 +00:00
SlotObject = CreateObject("Object");
2020-11-28 19:53:57 +00:00
SlotObject.SetString("label", class'KFGFxMenu_Gear'.default.NoneString);
SlotObject.SetString("source", "img://"$class'KFGFxMenu_Gear'.default.ClearImagePath);
SlotObject.SetInt("ItemIndex", INDEX_NONE);
SlotObject.SetBool("enabled", true);
DataProvider.SetElementObject(ItemIndex, SlotObject);
ItemIndex++;
for (i = 0; i < Attachments.Length; i++)
{
Variant = Attachments[i];
2020-11-28 20:04:55 +00:00
if (class'ExtCharacterInfo'.static.IsAttachmentAvailable(CurrentCharInfo, Variant, MyPawn))
2020-11-28 19:53:57 +00:00
{
2020-11-28 20:04:55 +00:00
SlotObject = CreateObject("Object");
2020-11-28 19:53:57 +00:00
SlotObject.SetInt("ItemIndex", i);
2020-11-28 20:04:55 +00:00
FirstSkin = UpdateCosmeticVariants(class'KFGFxMenu_Gear'.default.AttachmentKey, class'KFGFxMenu_Gear'.default.AttachmentSkinKey, Variant.AttachmentItem, i, SlotObject);
2020-11-28 19:53:57 +00:00
AttachmentName = bIsCustomChar ? GetMenuNameStr(Variant.MeshName) : Localize(string(Variant.AttachmentItem.Name), class'KFGFxMenu_Gear'.default.AttachmentKey, class'KFGFxMenu_Gear'.default.KFCharacterInfoString);
SlotObject.SetString("label", AttachmentName);
SlotObject.SetBool("enabled", true);
TexturePath = "img://"$PathName(FirstSkin.UITexture);
SlotObject.SetString("source", TexturePath);
DataProvider.SetElementObject(ItemIndex, SlotObject);
ItemIndex++;
}
}
SetObject("attachmentsArray", DataProvider);
2017-10-20 02:00:49 +00:00
}
function SkinVariant UpdateCosmeticVariants(string OutfitKey, string KeyName, KFCharacterAttachment Attachment, int OutfitIndex, out GFxObject MeshObject)
2017-10-20 02:00:49 +00:00
{
2020-11-28 19:53:57 +00:00
local int i, ItemIndex;
local GFxObject DataProvider, SlotObject;
local SkinVariant Skin;
local SkinVariant FirstSkin;
local string TexturePath;
local bool bFoundFirst;
local string SkinName;
ItemIndex = 0;
DataProvider = CreateArray();
for (i = 0; i < Attachment.SkinVariations.length; i++)
{
Skin = Attachment.SkinVariations[i];
2020-11-28 20:12:58 +00:00
if (!bFoundFirst)
2020-11-28 19:53:57 +00:00
{
FirstSkin = Skin;
bFoundFirst = true;
}
2020-11-28 20:04:55 +00:00
SlotObject = CreateObject("Object");
2020-11-28 19:53:57 +00:00
SlotObject.SetInt("ItemIndex", i);
SkinName = Localize(string(Attachment.Name), KeyName$i, class'KFGFxMenu_Gear'.Default.KFCharacterInfoString);
SlotObject.SetString("label", SkinName);
TexturePath = "img://"$PathName(Skin.UITexture);
SlotObject.SetBool("enabled", true);
SlotObject.SetString("source", TexturePath);
DataProvider.SetElementObject(ItemIndex, SlotObject);
ItemIndex++;
}
MeshObject.SetObject("skinInfo", DataProvider);
return FirstSkin;
2017-10-20 02:00:49 +00:00
}
function SetCurrentCharacterButtons()
{
2020-11-28 19:53:57 +00:00
local bool bCustom;
local GFxObject DataObject;
local byte CharacterIndex, HeadMeshIndex, HeadSkinIndex, BodyMeshIndex, BodySkinIndex;
bCustom = ExtPRI.UsesCustomChar();
DataObject = CreateObject("Object");
CharacterIndex = ExtPRI.RepCustomizationInfo.CharacterIndex;
HeadMeshIndex = ExtPRI.RepCustomizationInfo.HeadMeshIndex;
HeadSkinIndex = ExtPRI.RepCustomizationInfo.HeadSkinIndex;
BodyMeshIndex = ExtPRI.RepCustomizationInfo.BodyMeshIndex;
BodySkinIndex = ExtPRI.RepCustomizationInfo.BodySkinIndex;
2020-11-28 20:12:58 +00:00
if (bCustom)
2020-11-28 19:53:57 +00:00
{
CharacterIndex = ExtPRI.CustomCharacter.CharacterIndex;
HeadMeshIndex = ExtPRI.CustomCharacter.HeadMeshIndex;
HeadSkinIndex = ExtPRI.CustomCharacter.HeadSkinIndex;
BodyMeshIndex = ExtPRI.CustomCharacter.BodyMeshIndex;
BodySkinIndex = ExtPRI.CustomCharacter.BodySkinIndex;
}
2020-11-28 20:04:55 +00:00
DataObject.SetString("selectedCharacter", (bIsCustomChar ? Repl(string(CurrentCharInfo.Name),"_"," ") : Localize(CharInfoPath, "CharacterName", class'KFGFxMenu_Gear'.Default.KFCharacterInfoString)));
DataObject.SetString("characterBio", (bIsCustomChar ? Repl(CurrentCharInfo.ArmMeshPackageName,"|","\n") : Localize(CharInfoPath, "Description", class'KFGFxMenu_Gear'.Default.KFCharacterInfoString)));
DataObject.SetInt("selectedCharacterIndex", CharacterIndex);
2020-11-28 19:53:57 +00:00
2020-11-28 20:04:55 +00:00
SetObject("selectedCharacter", DataObject);
2020-11-28 19:53:57 +00:00
//set head
SetGearButtons(HeadMeshIndex, HeadSkinIndex, class'KFGFxMenu_Gear'.Default.HeadMeshKey, class'KFGFxMenu_Gear'.Default.HeadSkinKey, class'KFGFxMenu_Gear'.Default.HeadFunctionKey);
//set body
SetGearButtons(BodyMeshIndex, BodySkinIndex, class'KFGFxMenu_Gear'.Default.BodyMeshKey, class'KFGFxMenu_Gear'.Default.BodySkinKey, class'KFGFxMenu_Gear'.Default.BodyFunctionKey);
//set attachments
SetAttachmentButtons(class'KFGFxMenu_Gear'.Default.AttachmentKey, class'KFGFxMenu_Gear'.Default.AttachmentFunctionKey);
SetEmoteButton();
2017-10-20 02:00:49 +00:00
}
function SetEmoteButton()
{
2020-11-28 19:53:57 +00:00
local GFxObject DataObject;
local int EmoteIndex;
2020-01-09 11:05:13 +00:00
2020-11-28 20:04:55 +00:00
EmoteIndex = class'ExtEmoteList'.static.GetEmoteIndex(class'ExtEmoteList'.static.GetEquippedEmoteId(ExtPlayerController(GetPC())));
2020-01-09 11:05:13 +00:00
2020-11-28 19:53:57 +00:00
DataObject = CreateObject("Object");
2020-11-28 20:12:58 +00:00
if (EmoteIndex == 255)
2020-11-28 19:53:57 +00:00
{
2020-11-28 20:04:55 +00:00
DataObject.SetString("selectedEmote", "");
DataObject.SetInt("selectedEmoteIndex", 0);
2020-11-28 19:53:57 +00:00
}
else
{
2020-11-28 20:04:55 +00:00
DataObject.SetString("selectedEmote", Localize(EmoteList[EmoteIndex].ItemName, "EmoteName", class'KFGFxMenu_Gear'.Default.KFCharacterInfoString));
DataObject.SetInt("selectedEmoteIndex", 0);
2020-11-28 19:53:57 +00:00
}
2020-01-09 11:05:13 +00:00
2020-11-28 19:53:57 +00:00
SetObject("selectedEmote", DataObject);
2017-10-20 02:00:49 +00:00
}
/** Update the labels for our gear buttons */
2020-01-09 11:05:13 +00:00
function SetGearButtons(int MeshIndex, int SkinIndex, string MeshKey, string SkinKey, string sectionFunctionName)
{
2020-11-28 19:53:57 +00:00
local string SectionPath;
local string CurrentMesh;
local string SkinName, MeshName;
local GFxObject DataObject;
2020-11-28 20:12:58 +00:00
if (bWaitingCharList)
2020-11-28 19:53:57 +00:00
return;
DataObject = CreateObject("Object");
2020-11-28 20:12:58 +00:00
if (MeshIndex == `CLEARED_ATTACHMENT_INDEX)
2020-11-28 19:53:57 +00:00
{
2020-11-28 20:04:55 +00:00
DataObject.SetString(sectionFunctionName, class'KFGFxMenu_Gear'.Default.NoneString);
2020-11-28 19:53:57 +00:00
}
2020-11-28 20:12:58 +00:00
else if (bIsCustomChar)
2020-11-28 19:53:57 +00:00
{
2020-11-28 20:12:58 +00:00
if (MeshKey==class'KFGFxMenu_Gear'.Default.HeadMeshKey)
2020-11-28 19:53:57 +00:00
{
SkinName = GetMenuName(CurrentCharInfo.HeadVariants[MeshIndex].SkinVariations[SkinIndex].Skin);
MeshName = GetMenuNameStr(CurrentCharInfo.HeadVariants[MeshIndex].MeshName);
}
else
{
SkinName = GetMenuName(CurrentCharInfo.BodyVariants[MeshIndex].SkinVariations[SkinIndex].Skin);
MeshName = GetMenuNameStr(CurrentCharInfo.BodyVariants[MeshIndex].MeshName);
}
2020-11-28 20:04:55 +00:00
DataObject.SetString(sectionFunctionName, MeshName @"\n" @SkinName);
2020-11-28 19:53:57 +00:00
}
else
{
CurrentMesh = MeshKey$MeshIndex;
SectionPath = CharInfoPath$"."$CurrentMesh;
SkinName = Localize(SectionPath, SkinKey$SkinIndex, class'KFGFxMenu_Gear'.Default.KFCharacterInfoString);
MeshName = Localize(CharInfoPath, CurrentMesh, class'KFGFxMenu_Gear'.Default.KFCharacterInfoString);
2020-11-28 20:04:55 +00:00
DataObject.SetString(sectionFunctionName, MeshName @"\n" @SkinName);
2020-11-28 19:53:57 +00:00
}
2020-11-28 20:04:55 +00:00
DataObject.SetInt((sectionFunctionName$"Index"), MeshIndex);
DataObject.SetInt((sectionFunctionName$"SkinIndex"), SkinIndex);
2020-11-28 19:53:57 +00:00
2020-11-28 20:04:55 +00:00
SetObject(sectionFunctionName, DataObject);
2017-10-20 02:00:49 +00:00
}
/** Update the labels for our currently equipped attachments */
function SetAttachmentButtons(string AttachmentMeshKey, string sectionFunctionName)
{
2020-11-28 19:53:57 +00:00
local GFxObject DataObject;
local int i, AttachmentIndex;
local bool bCustom;
2020-11-28 20:12:58 +00:00
if (bWaitingCharList)
2020-11-28 19:53:57 +00:00
return;
bCustom = ExtPRI.UsesCustomChar();
DataObject = CreateObject("Object");
2020-11-28 20:12:58 +00:00
for (i = 0; i < `MAX_COSMETIC_ATTACHMENTS; i++)
2020-11-28 19:53:57 +00:00
{
AttachmentIndex = bCustom ? ExtPRI.CustomCharacter.AttachmentMeshIndices[i] : ExtPRI.RepCustomizationInfo.AttachmentMeshIndices[i];
2020-11-28 20:12:58 +00:00
if (AttachmentIndex == `CLEARED_ATTACHMENT_INDEX)
2020-11-28 19:53:57 +00:00
{
DataObject.SetString("selectedAttachment_"$i, "----");
}
else
{
DataObject.SetString("selectedAttachment_"$i, bIsCustomChar ? GetMenuNameStr(CurrentCharInfo.CosmeticVariants[AttachmentIndex].MeshName) : Localize(string(CurrentCharInfo.CosmeticVariants[AttachmentIndex].AttachmentItem.Name), AttachmentMeshKey, class'KFGFxMenu_Gear'.default.KFCharacterInfoString));
}
}
2020-11-28 20:04:55 +00:00
SetObject(sectionFunctionName, DataObject);
2017-10-20 02:00:49 +00:00
}
event OnClose()
{
2020-11-28 19:53:57 +00:00
local PlayerController PC;
2017-10-20 02:00:49 +00:00
2020-11-28 19:53:57 +00:00
super.OnClose();
2017-10-20 02:00:49 +00:00
2020-11-28 19:53:57 +00:00
//GetGameViewportClient().HandleInputAxis = none;
2017-10-20 02:00:49 +00:00
2020-11-28 20:04:55 +00:00
if (class'WorldInfo'.static.IsMenuLevel())
2020-11-28 19:53:57 +00:00
{
Manager.ManagerObject.SetBool("backgroundVisible", true);
}
2017-10-20 02:00:49 +00:00
2020-11-28 19:53:57 +00:00
// If we are alive, in game, with a playable pawn. switch back to first person view when leaving this menu
PC = GetPC();
2020-11-28 20:12:58 +00:00
if (PC != none && PC.WorldInfo.GRI.bMatchHasBegun && PC.Pawn != none && !PC.Pawn.IsA('KFPawn_Customization'))
2020-11-28 19:53:57 +00:00
{
2020-11-28 20:04:55 +00:00
PC.ServerCamera('FirstPerson');
2020-11-28 19:53:57 +00:00
}
2017-10-20 02:00:49 +00:00
}
2020-11-28 20:04:55 +00:00
event bool OnAxisModified(int ControllerId, name Key, float Delta, float DeltaTime, bool bGamepad)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:04:55 +00:00
if (GetPC().PlayerInput.bUsingGamepad)
2020-11-28 19:53:57 +00:00
{
2020-11-28 20:04:55 +00:00
if (Key == 'XboxTypeS_RightX' && Abs(Delta) > class'KFGFxMenu_Gear'.Default.ControllerRotationThreshold)
2020-11-28 19:53:57 +00:00
{
Callback_RotateCamera(Delta * class'KFGFxMenu_Gear'.Default.ControllerRotationRate);
}
}
return false;
2017-10-20 02:00:49 +00:00
}
//==============================================================
// ActionScript Callbacks
//==============================================================
2020-01-09 11:05:13 +00:00
function Callback_Emote(int Index)
2017-10-20 02:00:49 +00:00
{
2020-11-28 19:53:57 +00:00
local KFPlayerController KFPC;
2017-10-20 02:00:49 +00:00
2020-11-28 19:53:57 +00:00
KFPC = KFPlayerController(GetPC());
2020-11-28 20:12:58 +00:00
if (KFPC != none)
2020-11-28 19:53:57 +00:00
{
class'ExtEmoteList'.static.SaveEquippedEmote(EmoteList[Index].ID, ExtPlayerController(KFPC));
2017-10-20 02:00:49 +00:00
2020-11-28 20:04:55 +00:00
if (ExtPawn_Customization(KFPC.Pawn) != none)
2020-11-28 19:53:57 +00:00
{
ExtPawn_Customization(KFPC.Pawn).PlayEmoteAnimation();
}
}
2017-10-20 02:00:49 +00:00
2020-11-28 19:53:57 +00:00
SetEmoteButton();
2017-10-20 02:00:49 +00:00
}
2020-11-28 20:04:55 +00:00
function Callback_RotateCamera(int RotationDirection)
2017-10-20 02:00:49 +00:00
{
2020-11-28 19:53:57 +00:00
local KFPlayerCamera PlayerCamera;
2020-11-28 20:04:55 +00:00
PlayerCamera = KFPlayerCamera(GetPC().PlayerCamera);
if (PlayerCamera != none)
PlayerCamera.CustomizationCam.RotatedCamera(RotationDirection);
2017-10-20 02:00:49 +00:00
}
function Callback_EndRotateCamera()
{
2020-11-28 19:53:57 +00:00
local KFPlayerCamera PlayerCamera;
2017-10-20 02:00:49 +00:00
2020-11-28 20:04:55 +00:00
PlayerCamera = KFPlayerCamera(GetPC().PlayerCamera);
if (PlayerCamera != none)
2020-11-28 19:53:57 +00:00
PlayerCamera.CustomizationCam.StartFadeRotation();
2017-10-20 02:00:49 +00:00
}
2020-11-28 20:04:55 +00:00
function Callback_Weapon(int ItemIndex, int SkinIndex)
2017-10-20 02:00:49 +00:00
{
2020-11-28 19:53:57 +00:00
local KFPawn_Customization KFP;
2017-10-20 02:00:49 +00:00
2020-11-28 19:53:57 +00:00
KFP = KFPawn_Customization(GetPC().Pawn);
2020-11-28 20:12:58 +00:00
if (KFP != none)
2020-11-28 19:53:57 +00:00
KFP.AttachWeaponByItemDefinition(SkinIndex);
2017-10-20 02:00:49 +00:00
}
function Callback_BodyCamera()
{
2020-11-28 20:04:55 +00:00
if (KFPlayerCamera(GetPC().PlayerCamera) != none)
KFPlayerCamera(GetPC().PlayerCamera).CustomizationCam.SetBodyView(0);
2017-10-20 02:00:49 +00:00
}
function Callback_HeadCamera()
{
2020-11-28 20:04:55 +00:00
if (KFPlayerCamera(GetPC().PlayerCamera) != none)
KFPlayerCamera(GetPC().PlayerCamera).CustomizationCam.SetBodyView(1);
2017-10-20 02:00:49 +00:00
}
2020-01-09 11:05:13 +00:00
function Callback_Character(int Index)
2017-10-20 02:00:49 +00:00
{
2020-11-28 19:53:57 +00:00
ExtPRI.ChangeCharacter(Index,!ExtPRI.UsesCustomChar());
UpdateGear();
2017-10-20 02:00:49 +00:00
}
2020-11-28 20:04:55 +00:00
function Callback_Head(int MeshIndex, int SkinIndex)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (!ExtPRI.UsesCustomChar()) // Force client to setup custom character now for this server.
2020-11-28 19:53:57 +00:00
ExtPRI.ChangeCharacter(ExtPRI.RepCustomizationInfo.CharacterIndex,true);
ExtPRI.UpdateCustomization(CO_Head, MeshIndex, SkinIndex);
SetGearButtons(MeshIndex, SkinIndex, class'KFGFxMenu_Gear'.Default.HeadMeshKey, class'KFGFxMenu_Gear'.Default.HeadSkinKey, class'KFGFxMenu_Gear'.Default.HeadFunctionKey);
2017-10-20 02:00:49 +00:00
}
2020-11-28 20:04:55 +00:00
function Callback_Body(int MeshIndex, int SkinIndex)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (!ExtPRI.UsesCustomChar()) // Force client to setup custom character now for this server.
2020-11-28 19:53:57 +00:00
ExtPRI.ChangeCharacter(ExtPRI.RepCustomizationInfo.CharacterIndex,true);
ExtPRI.UpdateCustomization(CO_Body, MeshIndex, SkinIndex);
// When assigning a new body mesh we may need to remove certain attachments
// refresh filters, and update the equipped accessories list
UpdateAttachmentsList(CurrentCharInfo.CosmeticVariants);
SetAttachmentButtons(class'KFGFxMenu_Gear'.Default.AttachmentKey, class'KFGFxMenu_Gear'.Default.AttachmentFunctionKey);
2020-01-09 11:05:13 +00:00
2020-11-28 19:53:57 +00:00
SetGearButtons(MeshIndex, SkinIndex, class'KFGFxMenu_Gear'.Default.BodyMeshKey, class'KFGFxMenu_Gear'.Default.BodySkinKey, class'KFGFxMenu_Gear'.Default.BodyFunctionKey);
2017-10-20 02:00:49 +00:00
}
2020-11-28 20:04:55 +00:00
function Callback_Attachment(int MeshIndex, int SkinIndex)
2017-10-20 02:00:49 +00:00
{
2020-11-28 19:53:57 +00:00
local int SlotIndex;
local KFPawn KFP;
2020-11-28 20:12:58 +00:00
if (!ExtPRI.UsesCustomChar()) // Force client to setup custom character now for this server.
2020-11-28 19:53:57 +00:00
ExtPRI.ChangeCharacter(ExtPRI.RepCustomizationInfo.CharacterIndex,true);
KFP = KFPawn(GetPC().Pawn);
2020-11-28 20:12:58 +00:00
if (KFP!=None && ExtPRI!=None)
2020-11-28 19:53:57 +00:00
{
2020-11-28 20:12:58 +00:00
if (MeshIndex==`CLEARED_ATTACHMENT_INDEX)
2020-11-28 19:53:57 +00:00
ExtPRI.RemoveAttachments();
else
{
class'ExtCharacterInfo'.Static.DetachConflictingAttachments(CurrentCharInfo, MeshIndex, KFP, ExtPRI);
SlotIndex = class'ExtCharacterInfo'.Static.GetAttachmentSlotIndex(CurrentCharInfo, MeshIndex, KFP, ExtPRI);
2020-11-28 20:12:58 +00:00
if (SlotIndex == INDEX_NONE)
2020-11-28 19:53:57 +00:00
{
return;
}
ExtPRI.UpdateCustomization(CO_Attachment, MeshIndex, SkinIndex, SlotIndex);
}
SetAttachmentButtons(class'KFGFxMenu_Gear'.Default.AttachmentKey, class'KFGFxMenu_Gear'.Default.AttachmentFunctionKey);
}
2017-10-20 02:00:49 +00:00
}
defaultproperties
{
SubWidgetBindings.Add((WidgetName="customizationComponent",WidgetClass=class'KFGFxObject_Container'))
SubWidgetBindings.Add((WidgetName="perkSelectionContainer",WidgetClass=class'KFGFxGearContainer_PerksSelection'))
}