Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_CameraInfoEditorUIComponent.c
Go to the documentation of this file.
2 {
3  [Attribute(desc: "%1: vertical FOV (multiplier)\n%2: focal length (mm)\n%3 focus distance (m)")]
4  protected LocalizedString m_Text;
5 
6  [Attribute("35")]
7  protected int m_CameraLens;
8 
9  protected SCR_ManualCamera m_Camera;
10  protected TextWidget m_TextWidget;
11 
12  protected SCR_FocusManualCameraComponent m_FocusComponent;
13  protected SCR_ZoomManualCameraComponent m_ZoomComponent;
14 
15  //------------------------------------------------------------------------------------------------
16  protected void Refresh()
17  {
18  float verticalFOV = m_Camera.GetVerticalFOV();
19  float zoomCoef = m_Camera.GetDefaultFOV() / verticalFOV;
20  int focalLength = zoomCoef * m_CameraLens;
21 
22  float focusDistance = -1;
23  if (m_FocusComponent)
24  focusDistance = m_FocusComponent.GetFocusDistance();
25 
26  string focusDistanceString = "-";
27  if (focusDistance != -1)
28  focusDistanceString = focusDistance.ToString(1, 1);
29 
30  m_TextWidget.SetTextFormat(m_Text, zoomCoef.ToString(1, 1), focalLength, focusDistanceString);
31  }
32 
33  //------------------------------------------------------------------------------------------------
34  protected void InitCamera(SCR_ManualCamera camera)
35  {
36  m_Camera = camera;
37 
38  m_ZoomComponent = SCR_ZoomManualCameraComponent.Cast(m_Camera.FindCameraComponent(SCR_ZoomManualCameraComponent));
39  if (m_ZoomComponent)
40  m_ZoomComponent.GetOnZoomChange().Insert(Refresh);
41 
42  m_FocusComponent = SCR_FocusManualCameraComponent.Cast(m_Camera.FindCameraComponent(SCR_FocusManualCameraComponent));
43  if (m_FocusComponent)
44  m_FocusComponent.GetOnFocusDistanceChange().Insert(Refresh);
45 
46  Refresh();
47  }
48 
49  //------------------------------------------------------------------------------------------------
50  protected void OnCameraCreate(SCR_ManualCamera camera)
51  {
52  InitCamera(camera);
53 
55  cameraManager.GetOnCameraCreate().Remove(OnCameraCreate);
56  }
57 
58  //------------------------------------------------------------------------------------------------
59  override void HandlerAttachedScripted(Widget w)
60  {
61  m_TextWidget = TextWidget.Cast(w);
62  if (!m_TextWidget)
63  {
64  Debug.Error("SCR_CameraInfoEditorUIComponent must be attached to a text widget!");
65  return;
66  }
67 
69  if (!cameraManager)
70  return;
71 
72  SCR_ManualCamera camera = cameraManager.GetCamera();
73  if (camera)
74  {
75  InitCamera(camera);
76  }
77  else
78  {
79  cameraManager.GetOnCameraCreate().Insert(OnCameraCreate);
80  return;
81  }
82  }
83 
84  //------------------------------------------------------------------------------------------------
85  override void HandlerDeattached(Widget w)
86  {
87  super.HandlerDeattached(w);
88 
89  if (m_ZoomComponent)
90  m_ZoomComponent.GetOnZoomChange().Remove(Refresh);
91 
92  if (m_FocusComponent)
93  m_FocusComponent.GetOnFocusDistanceChange().Remove(Refresh);
94  }
95 }
SCR_ManualCamera
Definition: SCR_ManualCamera.c:16
MenuRootSubComponent
Definition: MenuRootSubComponent.c:5
SCR_CameraEditorComponent
Definition: SCR_CameraEditorComponent.c:13
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
m_Camera
protected SCR_ManualCamera m_Camera
Definition: SCR_BaseManualCameraComponent.c:14
m_TextWidget
protected TextWidget m_TextWidget
Definition: SCR_HighlightedEditorUIComponent.c:26
SCR_CameraInfoEditorUIComponent
Definition: SCR_CameraInfoEditorUIComponent.c:1
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_FocusManualCameraComponent
Focus camera on cursor position.
Definition: SCR_FocusManualCameraComponent.c:5
SCR_ZoomManualCameraComponent
Adjust camera field of view.
Definition: SCR_ZoomManualCameraComponent.c:5
LocalizedString
Definition: LocalizedString.c:21