File size: 3,772 Bytes
24b81cb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
class CTKeyframe extends ScriptedWidgetEventHandler
{
protected int m_Index;
protected float m_InterpTime;
protected float m_TotalTimeBefore;
protected vector m_Position;
protected vector m_Orientation;
protected CameraToolsMenu m_Menu;
protected Widget m_Root;
protected TextWidget m_IndexWidget;
protected EditBoxWidget m_InterpTimeWidget;
protected EditBoxWidget m_FOVWidget;
protected EditBoxWidget m_DOFWidget;
protected EditBoxWidget m_PinWidget;
protected TextWidget m_TotalTimeWidget;
void CTKeyframe( int index, vector pos, vector orient, float int_value, float fov, float dof, int pin, float time_before, Widget root, CameraToolsMenu parent )
{
m_Menu = parent;
m_Root = GetGame().GetWorkspace().CreateWidgets( "gui/layouts/camera_tools/keyframe_entry.layout", root );
m_IndexWidget = TextWidget.Cast( m_Root.FindAnyWidget( "keyframe_id" ) );
m_InterpTimeWidget = EditBoxWidget.Cast( m_Root.FindAnyWidget( "keyframe_time_edit" ) );
m_FOVWidget = EditBoxWidget.Cast( m_Root.FindAnyWidget( "keyframe_fov_edit" ) );
m_DOFWidget = EditBoxWidget.Cast( m_Root.FindAnyWidget( "keyframe_dof_edit" ) );
m_PinWidget = EditBoxWidget.Cast( m_Root.FindAnyWidget( "keyframe_pin_edit" ) );
m_TotalTimeWidget = TextWidget.Cast( m_Root.FindAnyWidget( "keyframe_time" ) );
m_Index = index;
m_TotalTimeBefore = time_before;
m_Position = pos;
m_Orientation = orient;
SetInterpTime( int_value );
SetFOV( fov );
SetDOF( dof );
SetPin( pin );
m_IndexWidget.SetText( m_Index.ToString() );
m_Root.SetHandler( this );
}
void ~CTKeyframe()
{
delete m_Root;
}
float GetInterpTime()
{
string time_text = m_InterpTimeWidget.GetText();
m_InterpTime = time_text.ToFloat();
return m_InterpTime;
}
void SetPin( int pin )
{
m_PinWidget.SetText( pin.ToString() );
}
int GetPin()
{
return m_PinWidget.GetText().ToInt();
}
void SetFOV( float fov )
{
m_FOVWidget.SetText( fov.ToString() );
}
float GetFOV()
{
return m_FOVWidget.GetText().ToFloat();
}
void SetDOF( float dof )
{
m_DOFWidget.SetText( dof.ToString() );
}
float GetDOF()
{
return m_DOFWidget.GetText().ToFloat();
}
void SetPosition( vector pos )
{
m_Position = pos;
}
void SetOrientation( vector orient )
{
m_Orientation = orient;
}
vector GetPosition()
{
return m_Position;
}
vector GetOrientation()
{
return m_Orientation;
}
void SetTimeBefore( float time )
{
m_TotalTimeBefore = time;
m_TotalTimeWidget.SetText( ( m_TotalTimeBefore + m_InterpTime ).ToString() );
}
void SetInterpTime( float time )
{
m_InterpTime = time;
m_InterpTimeWidget.SetText( m_InterpTime.ToString() );
m_TotalTimeWidget.SetText( ( m_TotalTimeBefore + m_InterpTime ).ToString() );
}
void Select()
{
m_Root.FindAnyWidget( "spacer" ).SetAlpha( 1 );
m_IndexWidget.SetColor( ARGBF( 1, 1, 0, 0 ) );
m_InterpTimeWidget.SetColor( ARGBF( 1, 1, 0, 0 ) );
m_TotalTimeWidget.SetColor( ARGBF( 1, 1, 0, 0 ) );
}
void Unselect()
{
m_Root.FindAnyWidget( "spacer" ).SetAlpha( 0.625 );
m_IndexWidget.SetColor( ARGBF( 1, 1, 1, 1 ) );
m_InterpTimeWidget.SetColor( ARGBF( 1, 1, 1, 1 ) );
m_TotalTimeWidget.SetColor( ARGBF( 1, 1, 1, 1 ) );
}
override bool OnClick( Widget w, int x, int y, int button )
{
if( w == m_Root )
{
m_Menu.SelectKeyframe( this );
return true;
}
return false;
}
override bool OnFocus( Widget w, int x, int y )
{
if( IsFocusable( w ) )
{
m_Menu.SelectKeyframe( this );
return true;
}
return false;
}
bool IsFocusable( Widget w )
{
if( w )
{
return ( w == m_InterpTimeWidget || w == m_TotalTimeWidget || w == m_FOVWidget || w == m_DOFWidget );
}
return false;
}
} |