DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
CTKeyframe.c
Go to the documentation of this file.
1class CTKeyframe extends ScriptedWidgetEventHandler
2{
3 protected int m_Index;
4 protected float m_InterpTime;
5 protected float m_TotalTimeBefore;
6
7 protected vector m_Position;
9 protected CameraToolsMenu m_Menu;
10
11 protected Widget m_Root;
12 protected TextWidget m_IndexWidget;
13 protected EditBoxWidget m_InterpTimeWidget;
14 protected EditBoxWidget m_FOVWidget;
15 protected EditBoxWidget m_DOFWidget;
16 protected EditBoxWidget m_PinWidget;
18
19 void CTKeyframe( int index, vector pos, vector orient, float int_value, float fov, float dof, int pin, float time_before, Widget root, CameraToolsMenu parent )
20 {
21 m_Menu = parent;
22
23 m_Root = GetGame().GetWorkspace().CreateWidgets( "gui/layouts/camera_tools/keyframe_entry.layout", root );
24
25 m_IndexWidget = TextWidget.Cast( m_Root.FindAnyWidget( "keyframe_id" ) );
26 m_InterpTimeWidget = EditBoxWidget.Cast( m_Root.FindAnyWidget( "keyframe_time_edit" ) );
27 m_FOVWidget = EditBoxWidget.Cast( m_Root.FindAnyWidget( "keyframe_fov_edit" ) );
28 m_DOFWidget = EditBoxWidget.Cast( m_Root.FindAnyWidget( "keyframe_dof_edit" ) );
29 m_PinWidget = EditBoxWidget.Cast( m_Root.FindAnyWidget( "keyframe_pin_edit" ) );
30 m_TotalTimeWidget = TextWidget.Cast( m_Root.FindAnyWidget( "keyframe_time" ) );
31
32 m_Index = index;
33 m_TotalTimeBefore = time_before;
34 m_Position = pos;
35 m_Orientation = orient;
36
37 SetInterpTime( int_value );
38 SetFOV( fov );
39 SetDOF( dof );
40 SetPin( pin );
41 m_IndexWidget.SetText( m_Index.ToString() );
42 m_Root.SetHandler( this );
43 }
44
46 {
47 delete m_Root;
48 }
49
51 {
52 string time_text = m_InterpTimeWidget.GetText();
53 m_InterpTime = time_text.ToFloat();
54 return m_InterpTime;
55 }
56
57 void SetPin( int pin )
58 {
59 m_PinWidget.SetText( pin.ToString() );
60 }
61
62 int GetPin()
63 {
64 return m_PinWidget.GetText().ToInt();
65 }
66
67 void SetFOV( float fov )
68 {
69 m_FOVWidget.SetText( fov.ToString() );
70 }
71
72 float GetFOV()
73 {
74 return m_FOVWidget.GetText().ToFloat();
75 }
76
77 void SetDOF( float dof )
78 {
79 m_DOFWidget.SetText( dof.ToString() );
80 }
81
82 float GetDOF()
83 {
84 return m_DOFWidget.GetText().ToFloat();
85 }
86
87 void SetPosition( vector pos )
88 {
89 m_Position = pos;
90 }
91
92 void SetOrientation( vector orient )
93 {
94 m_Orientation = orient;
95 }
96
98 {
99 return m_Position;
100 }
101
103 {
104 return m_Orientation;
105 }
106
107 void SetTimeBefore( float time )
108 {
109 m_TotalTimeBefore = time;
110 m_TotalTimeWidget.SetText( ( m_TotalTimeBefore + m_InterpTime ).ToString() );
111 }
112
113 void SetInterpTime( float time )
114 {
115 m_InterpTime = time;
116 m_InterpTimeWidget.SetText( m_InterpTime.ToString() );
117 m_TotalTimeWidget.SetText( ( m_TotalTimeBefore + m_InterpTime ).ToString() );
118 }
119
120 void Select()
121 {
122 m_Root.FindAnyWidget( "spacer" ).SetAlpha( 1 );
123 m_IndexWidget.SetColor( ARGBF( 1, 1, 0, 0 ) );
124 m_InterpTimeWidget.SetColor( ARGBF( 1, 1, 0, 0 ) );
125 m_TotalTimeWidget.SetColor( ARGBF( 1, 1, 0, 0 ) );
126 }
127
128 void Unselect()
129 {
130 m_Root.FindAnyWidget( "spacer" ).SetAlpha( 0.625 );
131 m_IndexWidget.SetColor( ARGBF( 1, 1, 1, 1 ) );
132 m_InterpTimeWidget.SetColor( ARGBF( 1, 1, 1, 1 ) );
133 m_TotalTimeWidget.SetColor( ARGBF( 1, 1, 1, 1 ) );
134 }
135
136 override bool OnClick( Widget w, int x, int y, int button )
137 {
138 if( w == m_Root )
139 {
140 m_Menu.SelectKeyframe( this );
141 return true;
142 }
143 return false;
144 }
145
146 override bool OnFocus( Widget w, int x, int y )
147 {
148 if( IsFocusable( w ) )
149 {
150 m_Menu.SelectKeyframe( this );
151 return true;
152 }
153 return false;
154 }
155
157 {
158 if( w )
159 {
160 return ( w == m_InterpTimeWidget || w == m_TotalTimeWidget || w == m_FOVWidget || w == m_DOFWidget );
161 }
162 return false;
163 }
164}
vector m_Orientation
protected vector m_Position
Cached world position.
Definition Effect.c:41
proto string ToString()
Icon x
Icon y
protected ServerBrowserMenuNew m_Menu
protected Widget m_Root
Definition SizeToChild.c:91
proto native WorkspaceWidget GetWorkspace()
map: item x vector(index, width, height)
Definition EnWidgets.c:538
protected vector m_Orientation
Definition CTKeyframe.c:8
protected TextWidget m_IndexWidget
Definition CTEvent.c:11
void CTKeyframe(int index, vector pos, vector orient, float int_value, float fov, float dof, int pin, float time_before, Widget root, CameraToolsMenu parent)
Definition CTKeyframe.c:19
protected EditBoxWidget m_PinWidget
Definition CTKeyframe.c:16
protected EditBoxWidget m_InterpTimeWidget
Definition CTKeyframe.c:13
void SetPosition(vector pos)
Definition CTKeyframe.c:87
protected int m_Index
Definition CTEvent.c:3
protected TextWidget m_TotalTimeWidget
Definition CTKeyframe.c:17
void SetInterpTime(float time)
Definition CTKeyframe.c:113
protected float m_InterpTime
Definition CTKeyframe.c:4
protected EditBoxWidget m_FOVWidget
Definition CTKeyframe.c:14
protected float m_TotalTimeBefore
Definition CTKeyframe.c:5
void SetTimeBefore(float time)
Definition CTKeyframe.c:107
protected Widget m_Root
Definition SizeToChild.c:9
void SetOrientation(vector orient)
Definition CTKeyframe.c:92
protected CameraToolsMenu m_Menu
Definition CTEvent.c:8
bool IsFocusable(Widget w)
Definition CTKeyframe.c:156
void SetFOV(float fov)
Definition CTKeyframe.c:67
override bool OnFocus(Widget w, int x, int y)
Definition CTKeyframe.c:146
override bool OnClick(Widget w, int x, int y, int button)
Definition CTKeyframe.c:136
protected vector m_Position
Definition CTKeyframe.c:7
protected EditBoxWidget m_DOFWidget
Definition CTKeyframe.c:15
void SetDOF(float dof)
Definition CTKeyframe.c:77
proto string ToString()
proto native CGame GetGame()
proto native float ToFloat()
Converts string to float.
proto native external Widget CreateWidgets(string layout, Widget parentWidget=NULL, bool immedUpdate=true)
Create widgets from *.layout file.
int ARGBF(float fa, float fr, float fg, float fb)
Converts <0.0, 1.0> ARGB into color.
Definition proto.c:332