Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_RequestedTaskSupportEntity.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
2 [EntityEditorProps(category: "GameScripted/Tasks", description: "Requested task support entity.", color: "0 0 255 255")]
4 {
5 };
6 
7 //------------------------------------------------------------------------------------------------
9 {
10  [Attribute("{75C912A1C89BE6C2}UI/layouts/WidgetLibrary/Buttons/WLib_ButtonText.layout")]
11  protected ResourceName m_sUIRequestButtonResource;
12 
13  [Attribute("0", UIWidgets.ComboBox, "Request type", "", ParamEnumArray.FromEnum(SCR_EUIRequestType))]
14  protected SCR_EUIRequestType m_eRequestType;
15 
16  [Attribute("", UIWidgets.LocaleEditBox, "Request button text.")]
17  protected LocalizedString m_sRequestButtonText;
18 
19  protected SCR_RequestedTask m_LocallyRequestedTask;
20 
21  //------------------------------------------------------------------------------------------------
22  void SetLocallyRequestedTask(notnull SCR_RequestedTask requestedTask)
23  {
24  m_LocallyRequestedTask = requestedTask;
25  }
26 
27  //------------------------------------------------------------------------------------------------
28  SCR_RequestedTask GetLocallyRequestedTask()
29  {
30  return m_LocallyRequestedTask;
31  }
32 
33  //------------------------------------------------------------------------------------------------
34  void SetRequester(notnull SCR_RequestedTask task, SCR_BaseTaskExecutor requester)
35  {
36  if (!GetTaskManager())
37  return;
38 
39  int taskID, requesterID;
40  taskID = task.GetTaskID();
41  requesterID = SCR_BaseTaskExecutor.GetTaskExecutorID(requester);
42 
43  Rpc(RPC_SetRequester, taskID, requesterID);
44  RPC_SetRequester(taskID, requesterID);
45  }
46 
47  //------------------------------------------------------------------------------------------------
48  [RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
49  void RPC_SetRequester(int taskID, int requesterID)
50  {
51  if (!GetTaskManager())
52  return;
53 
55  if (!task)
56  return;
57 
58  SCR_BaseTaskExecutor requester = SCR_BaseTaskExecutor.GetTaskExecutorByID(requesterID);
59  if (!requester)
60  return;
61 
62  task.SetRequester(requester);
63  }
64 
65  //------------------------------------------------------------------------------------------------
66  vector GetRequestPosition()
67  {
68  // By default we take map to world position - from context menu
69 
70  }
71 
72  //------------------------------------------------------------------------------------------------
73  bool CanRequest()
74  {
75  if (!GetTaskManager())
76  return false;
77 
79  if (!supportEntity)
80  return false;
81 
82  return (!supportEntity.GetLocallyRequestedTask());
83  }
84 
85  //------------------------------------------------------------------------------------------------
86  void SetRequestButtonText(notnull TextWidget textWidget)
87  {
88  textWidget.SetTextFormat(m_sRequestButtonText);
89  }
90 
91  //------------------------------------------------------------------------------------------------
92  /*void OnContextualEntryShow(SCR_MapContextualMenuEntry entry, Widget button)
93  {
94  TextWidget textWidget = TextWidget.Cast(button.FindAnyWidget("Text"));
95  if (!textWidget)
96  return;
97 
98  SetRequestButtonText(textWidget);
99  }*/
100 
101  //------------------------------------------------------------------------------------------------
102  void Request()
103  {
104  }
105 
106  //------------------------------------------------------------------------------------------------
107  protected override void RegisterContextualMenuCallbacks()
108  {
109  if (m_sRequestButtonText.IsEmpty())
110  return;
111 
112  SCR_MapRadialUI radialMenu = SCR_MapRadialUI.Cast(SCR_MapEntity.GetMapInstance().GetMapUIComponent(SCR_MapRadialUI));
113  if (!radialMenu)
114  return;
115 
117  if (!entry)
118  return;
119 
120  entry.SetName(m_sRequestButtonText);
121  entry.SetSupportClass(this);
122  entry.GetOnPerform().Insert(Request);
123  //entry.m_OnShow.Insert(OnContextualEntryShow);
124 
125  radialMenu.InsertCustomRadialEntry(entry);
126  }
127 
128  //------------------------------------------------------------------------------------------------
129  Widget CreateButtonAndSetPadding(Widget parentWidget, notnull inout array<Widget> widgets, float left = 4, float top = 4, float right = 4, float bottom = 4)
130  {
131  Widget requestButtonLayout = GetGame().GetWorkspace().CreateWidgets(m_sUIRequestButtonResource, parentWidget);
132  if (!requestButtonLayout)
133  return null;
134 
135  ButtonWidget requestButton = ButtonWidget.Cast(requestButtonLayout.FindAnyWidget("Button"));
136  if (requestButton)
137  {
138  SCR_UIRequestEvacTaskComponent requestTaskComponent = SCR_UIRequestEvacTaskComponent.Cast(requestButton.FindHandler(SCR_UIRequestEvacTaskComponent));
139  if (requestTaskComponent)
140  requestTaskComponent.SetRequestType(m_eRequestType);
141  }
142 
143  VerticalLayoutSlot.SetPadding(requestButtonLayout, left, top, right, bottom);
144 
145  TextWidget textWidget = TextWidget.Cast(requestButtonLayout.FindAnyWidget("Text"));
146  if (textWidget)
147  SetRequestButtonText(textWidget);
148 
149  widgets.Insert(requestButtonLayout);
150 
151  return requestButtonLayout;
152  }
153 };
EntityEditorProps
enum EQueryType EntityEditorProps(category:"GameScripted/Sound", description:"THIS IS THE SCRIPT DESCRIPTION.", color:"0 0 255 255")
Definition: SCR_AmbientSoundsComponent.c:12
SCR_RequestedTaskSupportEntityClass
Definition: SCR_RequestedTaskSupportEntity.c:3
SCR_UIRequestEvacTaskComponent
Definition: SCR_UIRequestEvacTaskComponent.c:1
SCR_MapRadialUI
2D map radial menu UI
Definition: SCR_MapRadialUI.c:13
SCR_BaseTaskSupportEntityClass
Definition: SCR_BaseTaskSupportEntity.c:3
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_RequestedTaskSupportEntity
Definition: SCR_RequestedTaskSupportEntity.c:8
RplRpc
SCR_AchievementsHandlerClass ScriptComponentClass RplRpc(RplChannel.Reliable, RplRcver.Owner)] void UnlockOnClient(AchievementId achievement)
Definition: SCR_AchievementsHandler.c:11
GetTask
SCR_ScenarioFrameworkTask GetTask()
Definition: SCR_ScenarioFrameworkLayerTask.c:65
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_MapMenuRequestedTaskEntry
Definition: SCR_MapMenuCommandingEntry.c:20
GetTaskManager
SCR_BaseTaskManager GetTaskManager()
Definition: SCR_BaseTaskManager.c:7
SCR_MapEntity
Map entity.
Definition: SCR_MapEntity.c:20
SCR_BaseTaskSupportEntity
Definition: SCR_BaseTaskSupportEntity.c:8
SCR_BaseTaskExecutor
Definition: SCR_BaseTaskExecutor.c:7
SCR_RequestedTask
Definition: SCR_RequestedTask.c:8
LocalizedString
Definition: LocalizedString.c:21
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180