Advertisement
RustyDios

pexm3slot

Oct 24th, 2020
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 8.56 KB | None | 0 0
  1. //*******************************************************************************************
  2. //  FILE:   Psionics Ex Machina. stuff                                
  3. //  
  4. //  File created    25/07/20    21:00
  5. //  LAST UPDATED    25/10/20    00:01
  6. //
  7. //  PSIONICS TRAINING STAFF SLOT,   LEBs No More dropdowns incorporated - with Kdm's controller support
  8. //
  9. //*******************************************************************************************
  10. class UIFacility_PexMLabSlot extends UIFacility_StaffSlot dependson(UIPersonnel);
  11.  
  12. var localized string m_strPexMTrainingDialogTitle;
  13. var localized string m_strPexMTrainingDialogText;
  14. var localized string m_strStopPexMTrainingDialogTitle;
  15. var localized string m_strStopPexMTrainingDialogText;
  16. var localized string m_strPauseAbilityTrainingDialogTitle;
  17. var localized string m_strPauseAbilityTrainingDialogText;
  18.  
  19. simulated function UIStaffSlot InitStaffSlot(UIStaffContainer OwningContainer, StateObjectReference LocationRef, int SlotIndex, delegate<OnStaffUpdated> onStaffUpdatedDel)
  20. {
  21.     super.InitStaffSlot(OwningContainer, LocationRef, SlotIndex, onStaffUpdatedDel);
  22.    
  23.     return self;
  24. }
  25.  
  26. //-----------------------------------------------------------------------------
  27. simulated function OnClickStaffSlot(UIPanel kControl, int cmd)
  28. {
  29.     local XComGameState_StaffSlot StaffSlot;
  30.     local XComGameState_Unit UnitState;
  31.     local string PopupText;
  32.  
  33.     StaffSlot = XComGameState_StaffSlot(`XCOMHISTORY.GetGameStateForObjectID(StaffSlotRef.ObjectID));
  34.  
  35.     switch (cmd)
  36.     {
  37.         // KDM : Added FXS_L_MOUSE_UP since this is what OnUnrealCommand() pipes into ShowDropDown() for controllers.
  38.         case class'UIUtilities_Input'.const.FXS_L_MOUSE_UP:
  39.         case class'UIUtilities_Input'.const.FXS_L_MOUSE_DOUBLE_UP:
  40.         case class'UIUtilities_Input'.const.FXS_L_MOUSE_UP_DELAYED:
  41.             if (StaffSlot.IsLocked())
  42.             {
  43.                 ShowUpgradeFacility();  //if slot is locked jump to upgrades
  44.             }
  45.             else if (StaffSlot.IsSlotEmpty())
  46.             {
  47.                 OnPexMLabTrainSelected();   //if unlocked and empty open new drop down lists
  48.             }
  49.             else // Ask the user to confirm that they want to empty the slot and stop training
  50.             {
  51.                 UnitState = StaffSlot.GetAssignedStaff();
  52.  
  53.                 if (UnitState.GetStatus() == eStatus_Training) //eStatus_PsiTesting) //(IsTraining() || IsPsiTraining() || IsPsiAbilityTraining())
  54.                 {
  55.                     PopupText = m_strStopPexMTrainingDialogText;
  56.                     PopupText = Repl(PopupText, "%UNITNAME", UnitState.GetName(eNameType_RankFull));
  57.  
  58.                     ConfirmEmptyProjectSlotPopup(m_strStopPexMTrainingDialogTitle, PopupText);
  59.                 }
  60.                 else if (UnitState.GetStatus() != eStatus_Training) //eStatus_PsiTesting) (IsTraining() || IsPsiTraining() || IsPsiAbilityTraining())
  61.                 {
  62.                     //there shouldn't be anyone in the slot 'not training' but just in case, pause/resume training ?
  63.                     PopupText = m_strPauseAbilityTrainingDialogText;
  64.                     PopupText = Repl(PopupText, "%UNITNAME", UnitState.GetName(eNameType_RankFull));
  65.  
  66.                     ConfirmEmptyProjectSlotPopup(m_strPauseAbilityTrainingDialogTitle, PopupText, false);
  67.                 }
  68.             }
  69.             break;
  70.  
  71.         case class'UIUtilities_Input'.const.FXS_L_MOUSE_OUT:
  72.         case class'UIUtilities_Input'.const.FXS_L_MOUSE_RELEASE_OUTSIDE:
  73.             if (!StaffSlot.IsLocked())
  74.             {
  75.                 StaffContainer.HideDropDown(self);  //hide the original list if not locked
  76.             }
  77.             break;
  78.     }  
  79. }
  80.  
  81. simulated function ShowDropDown()       //moved to using on click staff slot for controllers
  82. {
  83.     OnClickStaffSlot(none, class'UIUtilities_Input'.const.FXS_L_MOUSE_UP);
  84. }
  85.  
  86. //no special treatment necessary since LW2 doesnt have special psilab slots
  87. simulated function QueueDropDownDisplay()
  88. {
  89.     //OnClickStaffSlot(none, class'UIUtilities_Input'.const.FXS_L_MOUSE_DOUBLE_UP);
  90.     m_QueuedDropDown = true;
  91.     //ShowDropDown();
  92. }
  93.  
  94. simulated function OnPexMLabTrainSelected()
  95. {
  96.     if(IsDisabled)
  97.     {
  98.         return;
  99.     }
  100.  
  101.     ShowSoldierList(eUIAction_Accept, none);
  102. }
  103.  
  104. simulated function ShowSoldierList(eUIAction eAction, UICallbackData xUserData)
  105. {
  106.     local UIPersonnel_PexM kPersonnelList;
  107.     local XComHQPresentationLayer HQPres;
  108.     local XComGameState_StaffSlot StaffSlotState;
  109.    
  110.     if (eAction == eUIAction_Accept)
  111.     {
  112.         HQPres = `HQPRES;
  113.         StaffSlotState = XComGameState_StaffSlot(`XCOMHISTORY.GetGameStateForObjectID(StaffSlotRef.ObjectID));
  114.  
  115.         //Don't allow clicking of Personnel List is active or if staffslot is filled
  116.         if(HQPres.ScreenStack.IsNotInStack(class'UIPersonnel') && !StaffSlotState.IsSlotFilled())
  117.         {
  118.             kPersonnelList = Spawn( class'UIPersonnel_PexM', HQPres);
  119.             kPersonnelList.m_eListType = eUIPersonnel_Soldiers;
  120.             kPersonnelList.onSelectedDelegate = OnSoldierSelected;
  121.             kPersonnelList.m_bRemoveWhenUnitSelected = true;
  122.             kPersonnelList.SlotRef = StaffSlotRef;
  123.             HQPres.ScreenStack.Push( kPersonnelList );
  124.         }
  125.     }
  126. }
  127.  
  128. simulated function OnSoldierSelected(StateObjectReference _UnitRef)
  129. {
  130.     local XComGameState_Unit Unit;
  131.  
  132.     Unit = XComGameState_Unit(`XCOMHISTORY.GetGameStateForObjectID(_UnitRef.ObjectID));
  133.  
  134.     if (Unit.GetSoldierClassTemplateName() == 'PsiOperative')
  135.     {
  136.         // DO NOTHING FOR PSI OPS <> MAYBE CHANGE THIS TO STANDARD PSI TRAINING ?
  137.         //`HQPRES.UIChoosePsiAbility(_UnitRef, StaffSlotRef);
  138.     }
  139.     else
  140.     {
  141.         PexMPromoteDialog(Unit);
  142.     }
  143. }
  144.  
  145. simulated function OnPersonnelSelected(StaffUnitInfo UnitInfo)
  146. {
  147.     local XComGameState_Unit Unit;
  148.    
  149.     Unit = XComGameState_Unit(`XCOMHISTORY.GetGameStateForObjectID(UnitInfo.UnitRef.ObjectID));
  150.    
  151.     if (Unit.GetSoldierClassTemplateName() == 'PsiOperative')
  152.     {
  153.         // DO NOTHING FOR PSI OPS <> MAYBE CHANGE THIS TO STANDARD PSI TRAINING
  154.         //`HQPRES.UIChoosePsiAbility(UnitInfo.UnitRef, StaffSlotRef);
  155.     }
  156.     else
  157.     {
  158.         PexMPromoteDialog(Unit);
  159.     }
  160. }
  161.  
  162. simulated function PexMPromoteDialog(XComGameState_Unit Unit)
  163. {
  164.     local XGParamTag LocTag;
  165.     local TDialogueBoxData DialogData;
  166.     local XComGameState_HeadquartersXCom XComHQ;
  167.     local int TrainingRateModifier;
  168.     local UICallbackData_StateObjectReference CallbackData;
  169.  
  170.     XComHQ = XComGameState_HeadquartersXCom(`XCOMHISTORY.GetSingleGameStateObjectForClass(class'XComGameState_HeadquartersXCom'));
  171.     TrainingRateModifier = XComHQ.PsiTrainingRate / XComHQ.XComHeadquarters_DefaultPsiTrainingWorkPerHour;
  172.  
  173.     LocTag = XGParamTag(`XEXPANDCONTEXT.FindTag("XGParam"));
  174.     LocTag.StrValue0 = Unit.GetName(eNameType_RankFull);
  175.     LocTag.IntValue0 = (XComHQ.GetPsiTrainingDays() / TrainingRateModifier);
  176.  
  177.     CallbackData = new class'UICallbackData_StateObjectReference';
  178.     CallbackData.ObjectRef = Unit.GetReference();
  179.     DialogData.xUserData = CallbackData;
  180.     DialogData.fnCallbackEx = PexMPromoteDialogCallback;
  181.  
  182.     DialogData.eType = eDialog_Alert;
  183.     DialogData.strTitle = m_strPexMTrainingDialogTitle;
  184.     DialogData.strText = `XEXPAND.ExpandString(m_strPexMTrainingDialogText);
  185.     DialogData.strAccept = class'UIUtilities_Text'.default.m_strGenericYes;
  186.     DialogData.strCancel = class'UIUtilities_Text'.default.m_strGenericNo;
  187.  
  188.     Movie.Pres.UIRaiseDialog(DialogData);
  189. }
  190.  
  191. simulated function PexMPromoteDialogCallback(Name eAction, UICallbackData xUserData)
  192. {  
  193.     local XComGameState_HeadquartersXCom XComHQ;
  194.     local XComGameState_StaffSlot StaffSlot;
  195.     local XComGameState_FacilityXCom FacilityState;
  196.     local UICallbackData_StateObjectReference CallbackData;
  197.     local StaffUnitInfo UnitInfo;
  198.  
  199.     CallbackData = UICallbackData_StateObjectReference(xUserData);
  200.  
  201.     if(eAction == 'eUIAction_Accept')
  202.     {      
  203.         StaffSlot = XComGameState_StaffSlot(`XCOMHISTORY.GetGameStateForObjectID(StaffSlotRef.ObjectID));
  204.        
  205.         if (StaffSlot != none)
  206.         {
  207.             UnitInfo.UnitRef = CallbackData.ObjectRef;
  208.             StaffSlot.FillSlot(UnitInfo); // The Training project is started when the staff slot is filled
  209.             //the training project IS: XComGameState_HeadquartersProjectPexMTraining
  210.            
  211.             `XSTRATEGYSOUNDMGR.PlaySoundEvent("StrategyUI_Staff_Assign");
  212.            
  213.             XComHQ = class'UIUtilities_Strategy'.static.GetXComHQ();
  214.             FacilityState = StaffSlot.GetFacility();
  215.             if (FacilityState.GetNumEmptyStaffSlots() > 0)
  216.             {
  217.                 StaffSlot = FacilityState.GetStaffSlot(FacilityState.GetEmptyStaffSlotIndex());
  218.  
  219.                 if ((StaffSlot.IsScientistSlot() && XComHQ.GetNumberOfUnstaffedScientists() > 0) ||
  220.                     (StaffSlot.IsEngineerSlot() && XComHQ.GetNumberOfUnstaffedEngineers() > 0))
  221.                 {
  222.                     `HQPRES.UIStaffSlotOpen(FacilityState.GetReference(), StaffSlot.GetMyTemplate());
  223.                 }
  224.             }
  225.         }
  226.  
  227.         UpdateData();   //goes deep into UIStaffSlot via UIFacility_StaffSlot to set the slotstate
  228.         //Update(StaffSlotState.GetNameDisplayString(),     Caps(StaffSlotState.GetBonusDisplayString()),       StaffSlotState.GetUnitTypeImage());
  229.     }
  230. }
  231.  
  232. //==============================================================================
  233.  
  234. defaultproperties
  235. {
  236.     width = 370;
  237.     height = 65;
  238. }
  239.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement