Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
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
//------------------------------------------------------------------------------------------------
6
class
SCR_InventoryInspectionUI
:
ScriptedWidgetComponent
7
{
8
protected
WorkspaceWidget
m_workspaceWidget
= null;
9
Widget
m_widget
= null;
10
protected
RenderTargetWidget
m_wItemRender
= null;
11
protected
InputManager
m_pInputmanager
= null;
12
InventoryItemComponent
m_pItem
= null;
13
SCR_InventoryStorageBaseUI
m_inventoryStorage
= null;
14
BaseWorld
m_PreviewWorld
= null;
15
ref
SharedItemRef
m_PreviewSharedItemRef
= null;
16
int
m_PreviewCamera
= -1;
17
GenericEntity
m_PreviewEntity
= null;
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
;
23
protected
SCR_InventoryNavigationButtonBack
m_wButtonTraverseBack
;
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
51
CreatePreview
();
52
53
m_wButtonTraverseBack
=
SCR_InventoryNavigationButtonBack
.Cast(
SCR_InventoryNavigationButtonBack
.GetInputButtonComponent(
"ButtonTraverseBack"
,
m_widget
) );
54
if
(
m_wButtonTraverseBack
)
55
{
56
m_wButtonTraverseBack
.SetVisible(
true
);
57
m_wButtonTraverseBack
.m_OnActivated.Insert(
m_inventoryStorage
.GetInventoryMenuHandler().Action_Inspect );
58
}
59
}
60
61
//------------------------------------------------------------------------------------------------
63
void
DeletePreview
()
64
{
65
if
(
m_PreviewSharedItemRef
)
66
{
67
m_PreviewCamera
= -1;
68
m_PreviewEntity
= null;
69
m_PreviewWorld
= null;
70
m_PreviewSharedItemRef
= null;
71
}
72
}
73
74
//------------------------------------------------------------------------------------------------
76
protected
void
CreatePreview
()
77
{
78
DeletePreview
();
79
80
m_PreviewSharedItemRef
=
BaseWorld
.CreateWorld(
"InspectionPreview"
,
"InspectionPreview"
);
81
m_PreviewWorld
=
m_PreviewSharedItemRef
.GetRef();
82
m_PreviewCamera
= 0;
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.
97
m_PreviewEntity
=
GenericEntity
.Cast(
m_pItem
.CreatePreviewEntity(
m_PreviewWorld
,
m_PreviewCamera
));
98
CenterPreviewObject
(
vector
.Zero);
99
ResetPreviewCamera
();
100
101
m_wItemRender
.SetWorld(
m_PreviewWorld
,
m_PreviewCamera
);
102
//m_wItemRender.Update();
103
}
104
105
//------------------------------------------------------------------------------------------------
107
void
Destroy
()
108
{
109
DeletePreview
();
110
m_widget
.RemoveHandler(
this
);
111
m_widget
.RemoveFromHierarchy();
112
}
113
114
//------------------------------------------------------------------------------------------------
115
Widget
GetWidget
() {
return
m_widget
; }
116
117
//------------------------------------------------------------------------------------------------
119
void
CenterPreviewObject
(
vector
center)
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
//------------------------------------------------------------------------------------------------
129
void
ResetPreviewCamera
()
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);
136
m_PreviewTargetRotation
=
m_PreviewRotation
;
137
m_PreviewTargetDistance
=
m_PreviewDistance
;
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"
);
152
m_PreviewTargetDistance
=
Math
.Clamp(
m_PreviewTargetDistance
, 0.1, 2);
153
154
if
(
m_InputMouseRotate
)
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
167
m_PreviewRotation
+= (
m_PreviewTargetRotation
-
m_PreviewRotation
) * lerpTime;
168
m_PreviewDistance
+= (
m_PreviewTargetDistance
-
m_PreviewDistance
) * lerpTime;
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
//------------------------------------------------------------------------------------------------
193
void
~SCR_InventoryInspectionUI
()
194
{
195
DeletePreview
();
196
}
197
};
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
EntityEditorProps
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
Definition
SCR_CompassComponent.c:10
category
params category
Definition
SCR_VehicleDamageManagerComponent.c:302
BaseWorld
Definition
BaseWorld.c:13
GenericEntity
Definition
GenericEntity.c:16
InputManager
Input management system for user interactions.
Definition
InputManager.c:20
InventoryItemComponent
Definition
InventoryItemComponent.c:13
Math3D
Definition
Math3D.c:13
Math
Definition
Math.c:13
RenderTargetWidget
Definition
RenderTargetWidget.c:13
Resource
Object holding reference to resource. In destructor release the resource.
Definition
Resource.c:25
SCR_InventoryInspectionUI::DeletePreview
void DeletePreview()
Deletes the preview world.
Definition
SCR_InventoryInspectionUI.c:63
SCR_InventoryInspectionUI::m_pInputmanager
InputManager m_pInputmanager
Definition
SCR_InventoryInspectionUI.c:11
SCR_InventoryInspectionUI::UpdateView
void UpdateView(float timeSlice)
Update the preview.
Definition
SCR_InventoryInspectionUI.c:147
SCR_InventoryInspectionUI::ITEM_LAYOUT
const string ITEM_LAYOUT
Definition
SCR_InventoryInspectionUI.c:26
SCR_InventoryInspectionUI::m_PreviewWorld
BaseWorld m_PreviewWorld
Definition
SCR_InventoryInspectionUI.c:14
SCR_InventoryInspectionUI::m_workspaceWidget
WorkspaceWidget m_workspaceWidget
Definition
SCR_InventoryInspectionUI.c:8
SCR_InventoryInspectionUI::m_widget
Widget m_widget
Definition
SCR_InventoryInspectionUI.c:9
SCR_InventoryInspectionUI::ResetPreviewCamera
void ResetPreviewCamera()
Resets the camera to the default rotation and distance based on the preview object's size.
Definition
SCR_InventoryInspectionUI.c:129
SCR_InventoryInspectionUI::m_PreviewTargetDistance
float m_PreviewTargetDistance
Definition
SCR_InventoryInspectionUI.c:21
SCR_InventoryInspectionUI::m_pItem
InventoryItemComponent m_pItem
Definition
SCR_InventoryInspectionUI.c:12
SCR_InventoryInspectionUI::m_InputMouseRotate
bool m_InputMouseRotate
Definition
SCR_InventoryInspectionUI.c:22
SCR_InventoryInspectionUI::m_inventoryStorage
SCR_InventoryStorageBaseUI m_inventoryStorage
Definition
SCR_InventoryInspectionUI.c:13
SCR_InventoryInspectionUI::SCR_InventoryInspectionUI
void SCR_InventoryInspectionUI(InventoryItemComponent pComponent=null, SCR_InventoryStorageBaseUI pStorageUI=null, BaseWorld playerWorld=null)
Definition
SCR_InventoryInspectionUI.c:177
SCR_InventoryInspectionUI::m_PreviewSharedItemRef
ref SharedItemRef m_PreviewSharedItemRef
Definition
SCR_InventoryInspectionUI.c:15
SCR_InventoryInspectionUI::m_PreviewEntity
GenericEntity m_PreviewEntity
Definition
SCR_InventoryInspectionUI.c:17
SCR_InventoryInspectionUI::CenterPreviewObject
void CenterPreviewObject(vector center)
Centers the preview object to the input position.
Definition
SCR_InventoryInspectionUI.c:119
SCR_InventoryInspectionUI::Init
void Init()
Definition
SCR_InventoryInspectionUI.c:45
SCR_InventoryInspectionUI::Destroy
void Destroy()
Removes just the UI slot.
Definition
SCR_InventoryInspectionUI.c:107
SCR_InventoryInspectionUI::m_wItemRender
RenderTargetWidget m_wItemRender
Definition
SCR_InventoryInspectionUI.c:10
SCR_InventoryInspectionUI::OnMouseButtonUp
override bool OnMouseButtonUp(Widget w, int x, int y, int button)
Definition
SCR_InventoryInspectionUI.c:37
SCR_InventoryInspectionUI::m_PreviewCamera
int m_PreviewCamera
Definition
SCR_InventoryInspectionUI.c:16
SCR_InventoryInspectionUI::m_PreviewRotation
vector m_PreviewRotation
Definition
SCR_InventoryInspectionUI.c:18
SCR_InventoryInspectionUI::m_PreviewTargetRotation
vector m_PreviewTargetRotation
Definition
SCR_InventoryInspectionUI.c:20
SCR_InventoryInspectionUI::m_PreviewDistance
float m_PreviewDistance
Definition
SCR_InventoryInspectionUI.c:19
SCR_InventoryInspectionUI::OnMouseButtonDown
override bool OnMouseButtonDown(Widget w, int x, int y, int button)
Definition
SCR_InventoryInspectionUI.c:29
SCR_InventoryInspectionUI::~SCR_InventoryInspectionUI
void ~SCR_InventoryInspectionUI()
Definition
SCR_InventoryInspectionUI.c:193
SCR_InventoryInspectionUI::m_wButtonTraverseBack
SCR_InventoryNavigationButtonBack m_wButtonTraverseBack
Definition
SCR_InventoryInspectionUI.c:23
SCR_InventoryInspectionUI::CreatePreview
void CreatePreview()
Creates the preview world.
Definition
SCR_InventoryInspectionUI.c:76
SCR_InventoryInspectionUI::GetWidget
Widget GetWidget()
Definition
SCR_InventoryInspectionUI.c:115
SCR_InventoryNavigationButtonBack
Interactive non-focus button showing hint, and triggering actions.
Definition
SCR_InventoryNavigationButtonBack.c:5
SCR_InventoryStorageBaseUI
Definition
SCR_InventoryStorageBaseUI.c:7
ScriptedWidgetComponent
Definition
ScriptedWidgetComponent.c:13
SharedItemRef
Definition
SharedItemRef.c:13
Widget
Definition
Widget.c:13
WorkspaceWidget
Definition
WorkspaceWidget.c:16
vector
Definition
vector.c:13
CameraType
CameraType
Definition
CameraType.c:14
scripts
Game
UI
Inventory
SCR_InventoryInspectionUI.c
Generated by
1.17.0