8 protected WorkspaceWidget m_workspaceWidget =
null;
9 Widget m_widget =
null;
10 protected RenderTargetWidget m_wItemRender =
null;
11 protected InputManager m_pInputmanager =
null;
14 BaseWorld m_PreviewWorld =
null;
15 ref SharedItemRef m_PreviewSharedItemRef =
null;
16 int m_PreviewCamera = -1;
18 vector m_PreviewRotation = vector.Zero;
19 float m_PreviewDistance = 0;
20 vector m_PreviewTargetRotation = vector.Zero;
21 float m_PreviewTargetDistance = 0;
22 bool m_InputMouseRotate =
false;
26 const string ITEM_LAYOUT =
"{9A9CCE3707075EF4}UI/layouts/Menus/Inventory/InventoryInspectionPanel.layout";
29 override bool OnMouseButtonDown(Widget w,
int x,
int y,
int button)
32 m_InputMouseRotate =
true;
37 override bool OnMouseButtonUp(Widget w,
int x,
int y,
int button)
40 m_InputMouseRotate =
false;
47 m_widget = m_workspaceWidget.CreateWidgets( ITEM_LAYOUT );
48 m_widget.AddHandler(
this );
49 m_wItemRender = RenderTargetWidget.Cast( m_widget.FindAnyWidget(
"InspectRender" ) );
54 if ( m_wButtonTraverseBack )
56 m_wButtonTraverseBack.SetVisible(
true );
57 m_wButtonTraverseBack.m_OnActivated.Insert( m_inventoryStorage.GetInventoryMenuHandler().Action_Inspect );
65 if (m_PreviewSharedItemRef)
69 m_PreviewWorld =
null;
70 m_PreviewSharedItemRef =
null;
76 protected void CreatePreview()
80 m_PreviewSharedItemRef = BaseWorld.CreateWorld(
"InspectionPreview",
"InspectionPreview");
81 m_PreviewWorld = m_PreviewSharedItemRef.GetRef();
84 m_PreviewWorld.SetCameraType(m_PreviewCamera, CameraType.PERSPECTIVE);
85 m_PreviewWorld.SetCameraFarPlane(m_PreviewCamera, 50);
86 m_PreviewWorld.SetCameraNearPlane(m_PreviewCamera, 0.001);
92 Resource rsc = Resource.Load(
"{4391FE7994EE6FE2}worlds/Sandbox/InventoryPreviewWorld10.et");
94 GetGame().SpawnEntityPrefab(rsc, m_PreviewWorld);
98 CenterPreviewObject(vector.Zero);
101 m_wItemRender.SetWorld(m_PreviewWorld, m_PreviewCamera);
110 m_widget.RemoveHandler(
this );
111 m_widget.RemoveFromHierarchy();
115 Widget GetWidget() {
return m_widget; }
119 void CenterPreviewObject(vector center)
129 void ResetPreviewCamera()
134 m_PreviewRotation =
"-45 -20 0";
135 m_PreviewDistance = vector.Distance(mins, maxs);
136 m_PreviewTargetRotation = m_PreviewRotation;
137 m_PreviewTargetDistance = m_PreviewDistance;
140 Math3D.AnglesToMatrix(m_PreviewRotation, camMat);
141 camMat[3] = m_PreviewDistance * camMat[2] * -1;
142 m_PreviewWorld.SetCameraEx(m_PreviewCamera, camMat);
147 void UpdateView(
float timeSlice)
151 m_PreviewTargetDistance += timeSlice * -0.003 * Math.Clamp(m_PreviewTargetDistance, 0, 1) * m_pInputmanager.GetActionValue(
"Inventory_InspectZoom");
152 m_PreviewTargetDistance = Math.Clamp(m_PreviewTargetDistance, 0.1, 2);
154 if (m_InputMouseRotate)
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];
159 else if (m_pInputmanager.GetLastUsedInputDevice() == EInputDeviceType.GAMEPAD)
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];
165 float lerpTime = Math.Clamp(timeSlice * 5, 0, 1);
167 m_PreviewRotation += (m_PreviewTargetRotation - m_PreviewRotation) * lerpTime;
168 m_PreviewDistance += (m_PreviewTargetDistance - m_PreviewDistance) * lerpTime;
171 Math3D.AnglesToMatrix(m_PreviewRotation, camMat);
172 camMat[3] = m_PreviewDistance * camMat[2] * -1;
173 m_PreviewWorld.SetCameraEx(m_PreviewCamera, camMat);
182 m_pItem = pComponent;
183 m_inventoryStorage = pStorageUI;
185 m_workspaceWidget =
GetGame().GetWorkspace();
186 m_pInputmanager =
GetGame().GetInputManager();