Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_RadialMenuItemsComponent.c
Go to the documentation of this file.
1 [EntityEditorProps(category: "GameScripted/UI/RadialMenu", description: "Radial menu for item selection")]
2 class SCR_RadialMenuItemsComponentClass : ScriptComponentClass
3 {
4 }
5 
6 class SCR_RadialMenuItemsComponent : ScriptComponent
7 {
8  [Attribute()]
9  protected ref SCR_RadialMenuController m_MenuController;
10 
11  protected const int FIRST_ITEM_SLOT = 4;
12  protected const int SLOT_COUNT = 10;
13 
14  //------------------------------------------------------------------------------------------------
15  override void OnPostInit(IEntity owner)
16  {
17  if (System.IsConsoleApp())
18  return;
19 
20  if (!GetGame().InPlayMode())
21  return;
22 
23  // Will setup radial menu and take control over the menu
24  SetEventMask(owner, EntityEvent.INIT);
25 
26  m_MenuController.GetOnTakeControl().Insert(OnControllerTakeControl);
27  }
28 
29  //------------------------------------------------------------------------------------------------
30  override void EOnInit(IEntity owner)
31  {
32  if (!m_MenuController)
33  return;
34 
35  m_MenuController.GetOnControllerChanged().Insert(OnControllerChanged);
36  }
37 
38  //------------------------------------------------------------------------------------------------
39  protected void OnMenuOpen(SCR_SelectionMenu menu)
40  {
41  SCR_RadialMenu radialMenu = SCR_RadialMenu.Cast(menu);
42 
43  radialMenu.ClearEntries();
44  CreateEntries(radialMenu);
45  }
46 
47  //------------------------------------------------------------------------------------------------
48  protected void Update(SCR_RadialMenu radialMenu)
49  {
50  radialMenu.UpdateEntries();
51  }
52 
53  //------------------------------------------------------------------------------------------------
56  {
57  SCR_RadialMenu radialMenu = controller.GetRadialMenu();
58  if (!radialMenu)
59  return;
60 
61  radialMenu.GetOnOpen().Insert(OnMenuOpen);
62  }
63 
64  //------------------------------------------------------------------------------------------------
65  protected void OnControllerChanged(SCR_RadialMenuController controller, bool hasControl)
66  {
67  SCR_RadialMenu radialMenu = controller.GetRadialMenu();
68  if (!radialMenu)
69  return;
70 
71  radialMenu.GetOnOpen().Remove(OnMenuOpen);
72  }
73 
74  //------------------------------------------------------------------------------------------------
75  protected void CreateEntries(notnull SCR_RadialMenu radialMenu)
76  {
77  ChimeraCharacter character = ChimeraCharacter.Cast(SCR_PlayerController.GetLocalControlledEntity());
78  if (!character)
79  return;
80 
81  CharacterControllerComponent controller = character.GetCharacterController();
82  if (!controller)
83  return;
84 
85  SCR_InventoryStorageManagerComponent storageManager = SCR_InventoryStorageManagerComponent.Cast(controller.GetInventoryStorageManager());
86  if (!storageManager)
87  return;
88 
89  SCR_CharacterInventoryStorageComponent storage = storageManager.GetCharacterStorage();
90  if (!storage)
91  return;
92 
93  // Receive items assigned to quick slots
94  array<ref SCR_SelectionMenuEntry> entries = {};
95  for (int i = FIRST_ITEM_SLOT; i < SLOT_COUNT; i++)
96  {
97  SCR_ItemSelectionMenuEntry itemEntry = new SCR_ItemSelectionMenuEntry(storage, i);
98  entries.Insert(itemEntry);
99  }
100 
101  radialMenu.AddEntries(entries);
102  }
103 }
OnMenuOpen
protected void OnMenuOpen(SCR_SelectionMenu menu)
Definition: SCR_RadialMenuItemsComponent.c:39
OnControllerChanged
protected void OnControllerChanged(SCR_RadialMenuController controller, bool hasControl)
Definition: SCR_RadialMenuItemsComponent.c:65
SCR_PlayerController
Definition: SCR_PlayerController.c:31
SCR_RadialMenuController
Definition: SCR_RadialMenuController.c:8
EntityEditorProps
enum EQueryType EntityEditorProps(category:"GameScripted/Sound", description:"THIS IS THE SCRIPT DESCRIPTION.", color:"0 0 255 255")
Definition: SCR_AmbientSoundsComponent.c:12
ScriptComponent
SCR_SiteSlotEntityClass ScriptComponent
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
CreateEntries
protected void CreateEntries(notnull SCR_RadialMenu radialMenu)
Definition: SCR_RadialMenuItemsComponent.c:75
Update
protected void Update(SCR_RadialMenu radialMenu)
Definition: SCR_RadialMenuItemsComponent.c:48
SCR_RadialMenuItemsComponentClass
Definition: SCR_RadialMenuItemsComponent.c:2
SCR_SelectionMenu
Definition: SCR_SelectionMenu.c:6
Attribute
SCR_RadialMenuItemsComponentClass ScriptComponentClass Attribute()] protected ref SCR_RadialMenuController m_MenuController
Post-process effect of scripted camera.
OnControllerTakeControl
protected void OnControllerTakeControl(SCR_RadialMenuController controller)
Call this when menu controller starts to control the menu.
Definition: SCR_RadialMenuItemsComponent.c:55
FIRST_ITEM_SLOT
const protected int FIRST_ITEM_SLOT
Definition: SCR_RadialMenuItemsComponent.c:11
OnPostInit
override void OnPostInit(IEntity owner)
Editable Mine.
Definition: SCR_RadialMenuItemsComponent.c:15
EOnInit
override void EOnInit(IEntity owner)
Initialise this component with data from FactionsManager.
Definition: SCR_RadialMenuItemsComponent.c:30
SCR_ItemSelectionMenuEntry
Definition: SCR_ItemSelectionMenuEntry.c:1
SLOT_COUNT
const protected int SLOT_COUNT
Definition: SCR_RadialMenuItemsComponent.c:12
SCR_RadialMenu
Definition: SCR_RadialMenu.c:8
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180