Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
ctkeyframe.c
Go to the documentation of this file.
1 class 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;
8  protected vector m_Orientation;
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;
17  protected TextWidget m_TotalTimeWidget;
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 
45  void ~CTKeyframe()
46  {
47  delete m_Root;
48  }
49 
50  float GetInterpTime()
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 
156  bool IsFocusable( Widget w )
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 }
GetGame
proto native CGame GetGame()
m_Position
protected vector m_Position
Cached world position.
Definition: effect.c:41
EditBoxWidget
Definition: enwidgets.c:353
y
Icon y
m_Menu
protected ServerBrowserMenuNew m_Menu
Definition: serverbrowsertab.c:30
ToString
proto string ToString()
GetPosition
class JsonUndergroundAreaTriggerData GetPosition
Definition: undergroundarealoader.c:9
vector
Definition: enconvert.c:105
TextWidget
Definition: enwidgets.c:219
m_Orientation
vector m_Orientation
Definition: bleedingsource.c:15
ARGBF
int ARGBF(float fa, float fr, float fg, float fb)
Converts <0.0, 1.0> ARGB into color.
Definition: proto.c:332
x
Icon x
SetPosition
proto native void SetPosition(vector position)
Set the world position of the Effect.
Definition: effect.c:436
OnFocus
override bool OnFocus(Widget w, int x, int y)
Definition: serverbrowsertab.c:217
Widget
Definition: enwidgets.c:189
OnClick
override bool OnClick(Widget w, int x, int y, int button)
buttons clicks
Definition: dayzgame.c:146
m_Root
protected Widget m_Root
Definition: sizetochild.c:91
ScriptedWidgetEventHandler
map: item x vector(index, width, height)
Definition: enwidgets.c:650
IsFocusable
bool IsFocusable(Widget w)
Definition: serverbrowsertab.c:284
GetOrientation
vector GetOrientation()
Definition: areadamagemanager.c:306