1
0
KF2-Dev-Scripts/KFGame/Classes/KFGFxWeeklyObjectivesContainer.uc

272 lines
7.3 KiB
Ucode
Raw Normal View History

2020-12-13 15:01:13 +00:00
//=============================================================================
// KFGFxWeeklyObjectivesContainer
//=============================================================================
// This will be the parent container for the weekly and special event container
//=============================================================================
// Killing Floor 2
// Copyright (C) 2015 Tripwire Interactive LLC
// - Zane Gholson 3/28/2017
//=============================================================================
class KFGFxWeeklyObjectivesContainer extends KFGFxObject_Container
dependson(KFMission_LocalizedStrings);
2023-09-21 19:31:11 +00:00
var int LastWeeklyPopulated;
2020-12-13 15:01:13 +00:00
var bool bLastWeeklyComplete;
var KFPlayerController KFPC;
2023-09-21 19:31:11 +00:00
var KFGFxMenu_StartGame StartGameMenu;
2020-12-13 15:01:13 +00:00
function Initialize( KFGFxObject_Menu NewParentMenu )
{
super.Initialize( NewParentMenu );
2023-09-21 19:31:11 +00:00
StartGameMenu = KFGFxMenu_StartGame(NewParentMenu);
2020-12-13 15:01:13 +00:00
KFPC = KFPlayerController(GetPC());
if(KFPC != none)
{
2023-09-21 19:31:11 +00:00
PopulateData();
2020-12-13 15:01:13 +00:00
}
}
function bool PopulateData()
{
2023-09-21 19:31:11 +00:00
local int IntendedWeeklyIndex, WeeklyIndex, OverrideWeeklyIndex;
2020-12-13 15:01:13 +00:00
local GFxObject DataObject;
local KFWeeklyOutbreakInformation WeeklyInfo;
2023-09-21 19:31:11 +00:00
local byte CurrentMenuState;
local bool bWeeklyComplete, bIsCustomWeekly;
2020-12-13 15:01:13 +00:00
2023-09-21 19:31:11 +00:00
IntendedWeeklyIndex = class'KFGameEngine'.static.GetIntendedWeeklyEventIndexMod();
2022-05-11 15:13:25 +00:00
WeeklyIndex = -1;
2023-09-21 19:31:11 +00:00
OverrideWeeklyIndex = -1;
// If the Start Game Menu is opened and in some of the next states,.. we can read a different weekly selection
if (StartGameMenu != none)
{
CurrentMenuState = StartGameMenu.GetStartMenuState();
2020-12-13 15:01:13 +00:00
2023-09-21 19:31:11 +00:00
Switch (EStartMenuState(CurrentMenuState))
{
case ECreateGame:
case ESoloGame:
if (StartGameMenu.OptionsComponent.GetWeeklySelectorIndex() != 0)
{
OverrideWeeklyIndex = StartGameMenu.OptionsComponent.GetWeeklySelectorIndex() - 1;
}
break;
}
}
if (KFPC.WorldInfo.NetMode == NM_Client)
{
if (KFPC != none && KFGameReplicationInfo(KFPC.WorldInfo.GRI) != none)
{
WeeklyIndex = KFGameReplicationInfo(KFPC.WorldInfo.GRI).CurrentWeeklyIndex;
}
else
{
GetPC().SetTimer(0.5f, false, nameof(PopulateData));
}
}
else
2020-12-13 15:01:13 +00:00
{
2023-09-21 19:31:11 +00:00
if (OverrideWeeklyIndex >= 0)
2022-05-11 15:13:25 +00:00
{
2023-09-21 19:31:11 +00:00
WeeklyIndex = OverrideWeeklyIndex;
}
else
{
WeeklyIndex = class'KFGameEngine'.static.GetWeeklyEventIndexMod();
}
}
if (WeeklyIndex != -1)
{
bIsCustomWeekly = IntendedWeeklyIndex != WeeklyIndex;
}
bWeeklyComplete = KFPC.IsWeeklyEventComplete();
if (bWeeklyComplete != bLastWeeklyComplete || LastWeeklyPopulated != WeeklyIndex)
{
LastWeeklyPopulated = WeeklyIndex;
bLastWeeklyComplete = bWeeklyComplete;
LocalizeMenu(bIsCustomWeekly);
if (WeeklyIndex >= 0)
{
WeeklyInfo = class'KFMission_LocalizedStrings'.static.GetWeeklyOutbreakInfoByIndex(WeeklyIndex);
2022-05-11 15:13:25 +00:00
}
else
{
WeeklyInfo = class'KFMission_LocalizedStrings'.static.GetCurrentWeeklyOutbreakInfo();
}
2020-12-13 15:01:13 +00:00
2023-09-21 19:31:11 +00:00
if (WeeklyInfo == none)
2020-12-13 15:01:13 +00:00
{
return false;
}
2023-09-21 19:31:11 +00:00
DataObject = CreateObject("Object");
2020-12-13 15:01:13 +00:00
DataObject.SetString("label", WeeklyInfo.FriendlyName);
2023-09-21 19:31:11 +00:00
2022-05-11 15:13:25 +00:00
if(WeeklyInfo.ModifierDescriptions.length > 0)
2020-12-13 15:01:13 +00:00
{
DataObject.SetString("description", WeeklyInfo.DescriptionStrings[0]);
}
2023-09-21 19:31:11 +00:00
2020-12-13 15:01:13 +00:00
DataObject.SetString("iconPath", "img://"$WeeklyInfo.IconPath);
DataObject.SetBool("complete", bWeeklyComplete);
DataObject.SetBool("showProgres", false);
DataObject.SetFloat("progress", 0);
DataObject.SetString("textValue", "");
SetObject("weeklyObjectiveData", DataObject);
2022-05-11 15:13:25 +00:00
if (WeeklyInfo.ModifierDescriptions.Length > 0)
{
SetString("weeklyDescription", WeeklyInfo.ModifierDescriptions[0]);
}
PopulateModifiers(WeeklyInfo);
2023-09-21 19:31:11 +00:00
PopulateRewards(WeeklyInfo, WeeklyIndex, bIsCustomWeekly);
2020-12-13 15:01:13 +00:00
return true;
}
return false;
}
2022-05-11 15:13:25 +00:00
function PopulateModifiers(KFWeeklyOutbreakInformation WeeklyInfo)
2020-12-13 15:01:13 +00:00
{
local int i;
local GFxObject DataObject;
local GFxObject DataProvider; //array containing the data objects
2022-05-11 15:13:25 +00:00
if (WeeklyInfo == none || (GetPC().WorldInfo.NetMode == NM_Client && KFPC.WorldInfo.GRI == none))
{
return;
}
2020-12-13 15:01:13 +00:00
DataProvider = CreateArray();
2022-05-11 15:13:25 +00:00
2020-12-13 15:01:13 +00:00
for (i = 0; i < WeeklyInfo.ModifierDescriptions.length; i++)
{
DataObject = CreateObject("Object");
DataObject.SetString("label", ""); //no lable at the moment
2022-05-11 15:13:25 +00:00
DataObject.SetString("description", WeeklyInfo.ModifierDescriptions[i]);
2020-12-13 15:01:13 +00:00
//DataObject.SetString("iconPath", "img://"$WeeklyInfo.ModifierIconPaths[i]);
DataProvider.SetElementObject(i, DataObject); //add it to the array
}
SetObject("modifiers", DataProvider); //pass to SWF
}
2023-09-21 19:31:11 +00:00
function PopulateRewards(KFWeeklyOutbreakInformation WeeklyInfo, int WeeklyIndex, bool bIsCustomWeekly)
2020-12-13 15:01:13 +00:00
{
local int i, ItemCount;
local GFxObject DataProvider; //array containing the data objects
local GFxObject GfxRewardItem;
2022-05-11 15:13:25 +00:00
if (WeeklyInfo == none)
{
return;
}
2020-12-13 15:01:13 +00:00
ItemCount = 0;
DataProvider = CreateArray();
2022-05-11 15:13:25 +00:00
WeeklyInfo.RewardIDs = class'KFOnlineStatsWrite'.static.GetWeeklyOutbreakRewards(WeeklyIndex);
2020-12-13 15:01:13 +00:00
for (i = 0; i < WeeklyInfo.RewardIDs.length; i++)
{
GfxRewardItem = CreateRewardItem(WeeklyInfo, WeeklyInfo.RewardIDs[i]);
if(GfxRewardItem != none)
{
DataProvider.SetElementObject(ItemCount, GfxRewardItem); //add it to the array
ItemCount++;
}
}
2023-09-21 19:31:11 +00:00
if (bIsCustomWeekly == false)
{
SetObject("rewards", DataProvider); //pass to SWF
SetInt("vaultDoshReward", class'KFOnlineStatsWrite'.static.GetWeeklyEventReward());
}
else
{
SetInt("setHideRewards", 1);
}
2020-12-13 15:01:13 +00:00
}
function GFxObject CreateRewardItem(KFWeeklyOutbreakInformation WeeklyInfo,int ItemID)
{
local GFxObject DataObject;
local int ItemIndex;
local ItemProperties RewardItem;
local OnlineSubsystem OnlineSub;
OnlineSub = Class'GameEngine'.static.GetOnlineSubsystem();
if(OnlineSub == none)
{
return none;
}
ItemIndex = OnlineSub.ItemPropertiesList.Find('Definition',ItemID);
if( ItemIndex == INDEX_NONE )
{
`log("ItemID not found: " @ItemID);
return none;
}
RewardItem = OnlineSub.ItemPropertiesList[ItemIndex];
DataObject = CreateObject( "Object" );
DataObject.SetString("label", RewardItem.Name);
DataObject.SetString("iconPath", "img://"$RewardItem.IconURL);
return DataObject;
}
2023-09-21 19:31:11 +00:00
function LocalizeMenu(bool bIsCustomWeekly)
2020-12-13 15:01:13 +00:00
{
local GFxObject TextObject;
TextObject = CreateObject("Object");
2023-09-21 19:31:11 +00:00
2020-12-13 15:01:13 +00:00
// Localize static text
TextObject.SetString("currentModifier", class'KFMission_LocalizedStrings'.default.CurrentWeeklySettingsString);
TextObject.SetString("reward", class'KFMission_LocalizedStrings'.default.RewardsString);
2023-09-21 19:31:11 +00:00
TextObject.SetString("granted", class'KFMission_LocalizedStrings'.default.GrantedWeeklyString);
if (bIsCustomWeekly)
{
TextObject.SetString("weekly", class'KFMission_LocalizedStrings'.default.WeeklyString $class'KFMission_LocalizedStrings'.default.WeeklyCustomString);
}
else
{
TextObject.SetString("weekly", class'KFMission_LocalizedStrings'.default.WeeklyString);
}
2020-12-13 15:01:13 +00:00
TextObject.SetString("overview", class'KFMission_LocalizedStrings'.default.WeeklyOverview);
TextObject.SetString("vaultDosh", class'KFMission_LocalizedStrings'.default.VaultDoshString);
2023-09-21 19:31:11 +00:00
2020-12-13 15:01:13 +00:00
SetObject("localizedText", TextObject);
2022-05-11 15:13:25 +00:00
}
2023-09-21 19:31:11 +00:00
defaultproperties
{
LastWeeklyPopulated = -1
bLastWeeklyComplete = false
}