Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class UIChooseSpecializations extends UIInventory dependson(X2EventListener_RPG_StrategyListener);
- var array<SoldierSpecialization> SpecializationsPool;
- var array<Commodity> CommodityPool;
- var int SelectedIndexPool;
- var array<SoldierSpecialization> SpecializationsChosen;
- var array<Commodity> CommoditiesChosen;
- var int SelectedIndexChosen;
- var array<int> SelectedItems;
- var UIX2PanelHeader PoolHeader;
- var UIList PoolList;
- var UIX2PanelHeader ChosenHeader;
- var UIList ChosenList;
- // var StateObjectReference m_UnitRef;
- var localized string m_strTitlePool;
- var localized string m_strInventoryLabelPool;
- var localized string m_strTitleChosen;
- var localized string m_strInventoryLabelChosem;
- var localized string m_strChoose;
- var localized string m_strRemove;
- simulated function InitScreen(XComPlayerController InitController, UIMovie InitMovie, optional name InitName)
- {
- `LOG(self.Class.name @ GetFuncName() @ InitController @ InitMovie @ InitName,, 'RPG-UIChooseSpecializations');
- super.InitScreen(InitController, InitMovie, InitName);
- BuildList(PoolList, PoolHeader, 'PoolList', 'PoolHeader',
- 120, m_strTitlePool, m_strInventoryLabelPool);
- BuildList(ChosenList, ChosenHeader, 'ChosenList', 'ChosenHeader',
- 1200, m_strTitleChosen, m_strInventoryLabelChosem);
- PoolList.BG.OnMouseEventDelegate = OnChildMouseEvent;
- ChosenList.BG.OnMouseEventDelegate = OnChildMouseEvent;
- PoolList.OnItemDoubleClicked = OnSpecializationsPoolSelected;
- ChosenList.OnItemDoubleClicked = OnSpecializationsChosenSelected;
- SpecializationsPool.Length = 0;
- SpecializationsPool = class'X2TemplateHelper_RPGOverhaul'.static.GetSpecializations();
- //SpecializationsPool.Sort(SortSpecializationsByName);
- CommodityPool = ConvertToCommodities(SpecializationsPool);
- SpecializationsChosen.Length = 0;
- //SpecializationsChosen = class'SoldierSpecializationManager'.static.GetInstance().GetSecondarySpecializationTemplates(true);
- //SpecializationsChosen.Sort(SortSpecializationsByName);
- //CommoditiesChosen = ConvertToCommodities(SpecializationsChosen);
- PopulateData();
- UpdateNavHelp();
- SetBuiltLabel("");
- SetCategory("");
- ListContainer.Hide();
- ItemCard.Hide();
- Navigator.SetSelected(List);
- List.SetSelectedIndex(0);
- }
- simulated function BuildList(out UIList CommList, out UIX2PanelHeader Header, name ListName, name HeaderName,
- int PositionX, optional string HeaderTitle = "", optional string HeaderSubtitle = "")
- {
- CommList = Spawn(class'UIList', self);
- CommList.BGPaddingTop = 90;
- CommList.BGPaddingRight = 30;
- CommList.bSelectFirstAvailable = false;
- CommList.bAnimateOnInit = false;
- CommList.InitList(ListName,
- PositionX, 230,
- 568, 710,
- false, true
- );
- CommList.BG.SetAlpha(75);
- CommList.Show();
- Header = Spawn(class'UIX2PanelHeader', self);
- Header.bAnimateOnInit = false;
- Header.InitPanelHeader(HeaderName, HeaderTitle, HeaderSubtitle);
- Header.SetPosition(PositionX, 150);
- Header.SetHeaderWidth(588);
- Header.Show();
- `LOG(self.Class.name @ GetFuncName() @ CommList @ Header,, 'RPG-UIChooseSpecializations');
- }
- simulated function array<Commodity> ConvertToCommodities(array<SoldierSpecialization> Specializations)
- {
- local SoldierSpecialization Spec;
- local int i;
- local array<Commodity> Commodities;
- local Commodity Comm;
- local X2UniversalSoldierClassInfo Template;
- for (i = 0; i < Specializations.Length; i++)
- {
- Spec = Specializations[i];
- Template = new(None, string(Spec.TemplateName))class'X2UniversalSoldierClassInfo';
- Comm.Title = Template.ClassSpecializationTitle;
- Comm.Image = Template.ClassSpecializationIcon;
- Comm.Desc = Template.ClassSpecializationSummary;
- //Comm.OrderHours = class'SpecialTrainingUtilities'.static.GetSpecialTrainingDays() * 24;
- Commodities.AddItem(Comm);
- }
- return Commodities;
- }
- /*
- function int SortSpecializationsByName(SoldierSpecialization a, SoldierSpecialization b)
- {
- if (a.DisplayName < b.DisplayName)
- return 1;
- else if (a.DisplayName > b.DisplayName)
- return -1;
- else
- return 0;
- }
- */
- simulated function PopulateData()
- {
- local Commodity Template;
- local int i;
- local UIInventory_ClassListItem Item;
- `LOG(self.Class.name @ GetFuncName(),, 'RPG-UIChooseSpecializations');
- PoolList.ClearItems();
- for(i = 0; i < CommodityPool.Length; i++)
- {
- Template = CommodityPool[i];
- Item = Spawn(class'UIInventory_ClassListItem', PoolList.itemContainer);
- Item.InitInventoryListCommodity(Template, , m_strChoose, , , 126);
- if (IsPicked(i))
- {
- Item.SetDisabled(true, "You already have a chosen this specialization.");
- Item.ShouldShowGoodState(true, "This is your chhosem specialization.");
- }
- if (IsRandomSpec(i))
- {
- Item.SetDisabled(true, "Random specialization.");
- }
- }
- ChosenList.ClearItems();
- for(i = 0; i < CommoditiesChosen.Length; i++)
- {
- Template = CommoditiesChosen[i];
- Item = Spawn(class'UIInventory_ClassListItem', ChosenList.itemContainer);
- Item.InitInventoryListCommodity(Template, , m_strRemove, , , 126);
- if (!IsRandomSpec(i))
- Item.SetDisabled(true, "Random specializations cant be removed.");
- }
- }
- simulated function bool IsPicked(int Index)
- {
- return SelectedItems.Find(Index) != INDEX_NONE;
- }
- simulated function bool IsRandomSpec(int Index)
- {
- return false;
- }
- simulated function int GetItemIndex(Commodity Item)
- {
- local int i;
- for(i = 0; i < CommodityPool.Length; i++)
- {
- if(CommodityPool[i] == Item)
- {
- return i;
- }
- }
- return -1;
- }
- simulated function OnSpecializationsPoolSelected(UIList kList, int itemIndex)
- {
- if (itemIndex != SelectedIndexPool)
- {
- SelectedIndexPool = itemIndex;
- }
- if (!IsPicked(SelectedIndexPool))
- {
- SelectedItems.AddItem(SelectedIndexPool);
- PopulateData();
- }
- else
- {
- PlayNegativeSound();
- }
- }
- simulated function OnSpecializationsChosenSelected(UIList kList, int itemIndex)
- {
- if (itemIndex != SelectedIndexChosen)
- {
- SelectedIndexChosen = itemIndex;
- }
- if (!IsRandomSpec(SelectedIndexChosen))
- {
- SelectedItems.AddItem(SelectedIndexChosen);
- PopulateData();
- //Movie.Stack.Pop(self);
- }
- else
- {
- PlayNegativeSound();
- }
- }
- simulated function bool OnUnrealCommand(int cmd, int arg)
- {
- local bool bHandled;
- if (!CheckInputIsReleaseOrDirectionRepeat(cmd, arg))
- return false;
- // Only pay attention to presses or repeats; ignoring other input types
- // NOTE: Ensure repeats only occur with arrow keys
- bHandled = super.OnUnrealCommand(cmd, arg);
- if (bHandled)
- {
- if (List.GetSelectedItem() != none)
- SelectedIndexPool = List.GetItemIndex(List.GetSelectedItem());
- }
- /* TODO: Fix controller support
- else
- {
- if (`ISCONTROLLERACTIVE && CanTrainSpecialization(SelectedIndexPool))
- {
- switch (cmd)
- {
- case class'UIUtilities_Input'.const.FXS_BUTTON_A :
- OnSpecializationsPoolSelected(List, SelectedIndexPool);
- bHandled = true;
- break;
- }
- }
- }
- */
- return bHandled;
- }
- simulated function UpdateNavHelp()
- {
- local UINavigationHelp NavHelp;
- NavHelp = `HQPRES.m_kAvengerHUD.NavHelp;
- NavHelp.ClearButtonHelp();
- NavHelp.bIsVerticalHelp = `ISCONTROLLERACTIVE;
- NavHelp.AddBackButton(OnCancel);
- if(`ISCONTROLLERACTIVE && !IsPicked(SelectedIndexPool))
- {
- NavHelp.AddSelectNavHelp();
- }
- }
- simulated function PlayNegativeSound()
- {
- if(!`ISCONTROLLERACTIVE)
- class'UIUtilities_Sound'.static.PlayNegativeSound();
- }
- simulated function RefreshFacility()
- {
- local UIScreen QueueScreen;
- QueueScreen = Movie.Stack.GetScreen(class'UIFacility_Academy');
- if (QueueScreen != None)
- UIFacility_Academy(QueueScreen).RealizeFacility();
- }
- simulated function OnCancelButton(UIButton kButton) { OnCancel(); }
- simulated function OnCancel()
- {
- CloseScreen();
- Movie.Stack.PopFirstInstanceOfClass(class'UIArmory');
- }
- simulated function OnChildMouseEvent(UIPanel Control, int Cmd)
- {
- switch(Cmd)
- {
- case class'UIUtilities_Input'.const.FXS_L_MOUSE_OUT:
- PoolList.ClearSelection();
- ChosenList.ClearSelection();
- break;
- }
- }
- //==============================================================================
- simulated function OnLoseFocus()
- {
- super.OnLoseFocus();
- `HQPRES.m_kAvengerHUD.NavHelp.ClearButtonHelp();
- }
- simulated function OnReceiveFocus()
- {
- super.OnReceiveFocus();
- `HQPRES.m_kAvengerHUD.NavHelp.ClearButtonHelp();
- `HQPRES.m_kAvengerHUD.NavHelp.AddBackButton(OnCancel);
- }
- defaultproperties
- {
- bAutoSelectFirstNavigable = false
- bHideOnLoseFocus = true
- InputState = eInputState_Consume
- DisplayTag="UIDisplay_Academy"
- CameraTag="UIDisplay_Academy"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement