Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_InventoryInspectionUI.c
Go to the documentation of this file.
1[EntityEditorProps(category: "GameScripted/UI/Inventory", description: "Inventory Item Inspection UI class")]
2
3//------------------------------------------------------------------------------------------------
7{
9 Widget m_widget = null;
11 protected InputManager m_pInputmanager = null;
22 bool m_InputMouseRotate = false;
24
25
26 const string ITEM_LAYOUT = "{9A9CCE3707075EF4}UI/layouts/Menus/Inventory/InventoryInspectionPanel.layout";
27
28 //------------------------------------------------------------------------------------------------
29 override bool OnMouseButtonDown(Widget w, int x, int y, int button)
30 {
31 if (button == 1)
32 m_InputMouseRotate = true;
33 return true;
34 }
35
36 //------------------------------------------------------------------------------------------------
37 override bool OnMouseButtonUp(Widget w, int x, int y, int button)
38 {
39 if (button == 1)
40 m_InputMouseRotate = false;
41 return true;
42 }
43
44 //------------------------------------------------------------------------------------------------
45 protected void Init()
46 {
47 m_widget = m_workspaceWidget.CreateWidgets( ITEM_LAYOUT ); //, m_inventoryStorage.GetInventoryMenuHandler().GetRootWidget() );
48 m_widget.AddHandler( this );
49 m_wItemRender = RenderTargetWidget.Cast( m_widget.FindAnyWidget( "InspectRender" ) );
50
52
53 m_wButtonTraverseBack = SCR_InventoryNavigationButtonBack.Cast( SCR_InventoryNavigationButtonBack.GetInputButtonComponent( "ButtonTraverseBack", m_widget ) );
55 {
56 m_wButtonTraverseBack.SetVisible( true );
57 m_wButtonTraverseBack.m_OnActivated.Insert( m_inventoryStorage.GetInventoryMenuHandler().Action_Inspect );
58 }
59 }
60
61 //------------------------------------------------------------------------------------------------
64 {
66 {
67 m_PreviewCamera = -1;
68 m_PreviewEntity = null;
69 m_PreviewWorld = null;
71 }
72 }
73
74 //------------------------------------------------------------------------------------------------
76 protected void CreatePreview()
77 {
79
80 m_PreviewSharedItemRef = BaseWorld.CreateWorld("InspectionPreview", "InspectionPreview");
83
84 m_PreviewWorld.SetCameraType(m_PreviewCamera, CameraType.PERSPECTIVE);
85 m_PreviewWorld.SetCameraFarPlane(m_PreviewCamera, 50);
86 m_PreviewWorld.SetCameraNearPlane(m_PreviewCamera, 0.001);
87 //m_PreviewWorld.SetCameraVerticalFOV(m_PreviewCamera, 60);
88
89 //Create a preview world entity, this contains the lighting setup for the worlds.
90 //Resource rsc = Resource.Load("{43DA8BEC8468C7F5}worlds/TestMaps/PreviewWorld/PreviewWorld.et");
91 //Resource rsc = Resource.Load("{C63632BF8C1F7849}worlds/TestMaps/PreviewWorld/InspectionWorld.et");
92 Resource rsc = Resource.Load("{4391FE7994EE6FE2}worlds/Sandbox/InventoryPreviewWorld10.et");
93 if (rsc.IsValid())
94 GetGame().SpawnEntityPrefab(rsc, m_PreviewWorld);
95
96 //Create a generic entity that the mesh resource can be assigned to.
100
102 //m_wItemRender.Update();
103 }
104
105 //------------------------------------------------------------------------------------------------
107 void Destroy()
108 {
110 m_widget.RemoveHandler( this );
111 m_widget.RemoveFromHierarchy();
112 }
113
114 //------------------------------------------------------------------------------------------------
116
117 //------------------------------------------------------------------------------------------------
120 {
121 vector mins, maxs;
122 m_PreviewEntity.GetBounds(mins, maxs);
123 m_PreviewEntity.SetOrigin((mins - maxs) * 0.5 - mins + center);
124 m_PreviewEntity.Update();
125 }
126
127 //------------------------------------------------------------------------------------------------
130 {
131 vector mins, maxs;
132 m_PreviewEntity.GetBounds(mins, maxs);
133
134 m_PreviewRotation = "-45 -20 0";
135 m_PreviewDistance = vector.Distance(mins, maxs);
138
139 vector camMat[4];
140 Math3D.AnglesToMatrix(m_PreviewRotation, camMat);
141 camMat[3] = m_PreviewDistance * camMat[2] * -1;
142 m_PreviewWorld.SetCameraEx(m_PreviewCamera, camMat);
143 }
144
145 //------------------------------------------------------------------------------------------------
147 void UpdateView(float timeSlice)
148 {
149 if (!m_PreviewWorld)
150 return;
151 m_PreviewTargetDistance += timeSlice * -0.003 * Math.Clamp(m_PreviewTargetDistance, 0, 1) * m_pInputmanager.GetActionValue("Inventory_InspectZoom");
153
155 {
156 m_PreviewTargetRotation[0] = timeSlice * 0.1 * m_pInputmanager.GetActionValue("Inventory_InspectPanX") + m_PreviewTargetRotation[0];
157 m_PreviewTargetRotation[1] = timeSlice * -0.1 * m_pInputmanager.GetActionValue("Inventory_InspectPanY") + m_PreviewTargetRotation[1];
158 }
159 else if (m_pInputmanager.GetLastUsedInputDevice() == EInputDeviceType.GAMEPAD)
160 {
161 m_PreviewTargetRotation[0] = timeSlice * 100.0 * m_pInputmanager.GetActionValue("Inventory_InspectPanX") + m_PreviewTargetRotation[0];
162 m_PreviewTargetRotation[1] = timeSlice * 100.0 * m_pInputmanager.GetActionValue("Inventory_InspectPanY") + m_PreviewTargetRotation[1];
163 }
164
165 float lerpTime = Math.Clamp(timeSlice * 5, 0, 1);
166
169
170 vector camMat[4];
171 Math3D.AnglesToMatrix(m_PreviewRotation, camMat);
172 camMat[3] = m_PreviewDistance * camMat[2] * -1;
173 m_PreviewWorld.SetCameraEx(m_PreviewCamera, camMat);
174 }
175
176 //------------------------------------------------------------------------------------------------
177 void SCR_InventoryInspectionUI( InventoryItemComponent pComponent = null, SCR_InventoryStorageBaseUI pStorageUI = null, BaseWorld playerWorld = null )
178 {
179 if( !pComponent )
180 return;
181
182 m_pItem = pComponent;
183 m_inventoryStorage = pStorageUI;
184
185 m_workspaceWidget = GetGame().GetWorkspace();
186 m_pInputmanager = GetGame().GetInputManager();
187
188
189 Init();
190 }
191
192 //------------------------------------------------------------------------------------------------
194 {
196 }
197};
ArmaReforgerScripted GetGame()
Definition game.c:1398
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
Input management system for user interactions.
Definition Math.c:13
Object holding reference to resource. In destructor release the resource.
Definition Resource.c:25
void DeletePreview()
Deletes the preview world.
void UpdateView(float timeSlice)
Update the preview.
void ResetPreviewCamera()
Resets the camera to the default rotation and distance based on the preview object's size.
SCR_InventoryStorageBaseUI m_inventoryStorage
void SCR_InventoryInspectionUI(InventoryItemComponent pComponent=null, SCR_InventoryStorageBaseUI pStorageUI=null, BaseWorld playerWorld=null)
void CenterPreviewObject(vector center)
Centers the preview object to the input position.
void Destroy()
Removes just the UI slot.
override bool OnMouseButtonUp(Widget w, int x, int y, int button)
override bool OnMouseButtonDown(Widget w, int x, int y, int button)
SCR_InventoryNavigationButtonBack m_wButtonTraverseBack
void CreatePreview()
Creates the preview world.
Interactive non-focus button showing hint, and triggering actions.
CameraType
Definition CameraType.c:14