Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
ctevent.c
Go to the documentation of this file.
1 class CTEvent extends ScriptedWidgetEventHandler
2 {
3  protected int m_Index;
4  protected int m_ActorIndex;
5  protected int m_EventType;
6  protected float m_EventTime;
7 
8  protected CameraToolsMenu m_Menu;
9 
10  protected Widget m_Root;
11  protected TextWidget m_IndexWidget;
12  protected EditBoxWidget m_EventActorWidget;
13  protected EditBoxWidget m_EventTimeWidget;
14  protected EditBoxWidget m_EventTypeWidget;
15  protected CheckBoxWidget m_EventWalkWidget;
16 
18 
19  void CTEvent( int index, int actor, Widget root, bool walk, CameraToolsMenu parent )
20  {
21  m_Menu = parent;
22  m_Index = index;
23  m_ActorIndex = actor;
24 
25  m_Root = GetGame().GetWorkspace().CreateWidgets( "gui/layouts/camera_tools/event_entry.layout", root );
26  m_IndexWidget = TextWidget.Cast( m_Root.FindAnyWidget( "event_id" ) );
27  m_EventActorWidget = EditBoxWidget.Cast( m_Root.FindAnyWidget( "event_actor_edit" ) );
28  m_EventTimeWidget = EditBoxWidget.Cast( m_Root.FindAnyWidget( "event_time_edit" ) );
29  m_EventTypeWidget = EditBoxWidget.Cast( m_Root.FindAnyWidget( "event_type_edit" ) );
30  m_EventWalkWidget = CheckBoxWidget.Cast( m_Root.FindAnyWidget( "auto_walk" ) );
31 
32  m_EventWalkWidget.SetChecked( walk );
33  m_IndexWidget.SetText( m_Index.ToString() );
34  m_EventActorWidget.SetText( m_ActorIndex.ToString() );
35  m_Root.SetHandler( this );
36  }
37 
38  void ~CTEvent()
39  {
40  delete m_Root;
41  }
42 
43  void Play()
44  {
45  PlayerBase player = m_Menu.GetActor( GetEventActor() );
46  if( player )
47  {
48  if( m_EventWalkWidget.IsChecked() )
49  {
50  player.GetInputController().OverrideMovementAngle( true, 1 );
51  player.GetInputController().OverrideMovementSpeed( true, 1 );
52  }
53  else
54  {
55  if( player.GetCommand_Action() )
56  {
57  //player.GetCommand_Action().Cancel();
58  }
59  m_Callback = player.StartCommand_Action( GetEventType(), EmoteCB, DayZPlayerConstants.STANCEMASK_ALL );
60  m_Callback.EnableCancelCondition(true);
61  }
62  }
63  }
64 
65  void Stop()
66  {
67  if( m_Callback )
68  {
69  m_Callback.Cancel();
70  m_Callback = null;
71  }
72  PlayerBase player = m_Menu.GetActor( GetEventActor() );
73  if( player )
74  {
75  player.GetInputController().OverrideMovementSpeed( true, 0 );
76  }
77  }
78 
79  bool IsTime( float start_time, float end_time )
80  {
81  if( m_EventTime >= start_time )
82  {
83  if( m_EventTime <= end_time )
84  {
85  return true;
86  }
87  }
88  return false;
89  }
90 
91  void SetEventTime( float time )
92  {
93  m_EventTime = time;
94  m_EventTimeWidget.SetText( time.ToString() );
95  }
96 
97  void SetEventType( int type )
98  {
99  m_EventTypeWidget.SetText( type.ToString() );
100  }
101 
102  float GetEventTime()
103  {
104  m_EventTime = m_EventTimeWidget.GetText().ToFloat();
105  return m_EventTime;
106  }
107 
108  int GetEventType()
109  {
110  return m_EventTypeWidget.GetText().ToInt();
111  }
112 
113  int GetEventActor()
114  {
115  return m_EventActorWidget.GetText().ToInt();
116  }
117 
118  bool GetEventWalk()
119  {
120  return m_EventWalkWidget.IsChecked();
121  }
122 
123  void Select()
124  {
125  m_Root.FindAnyWidget( "spacer" ).SetAlpha( 1 );
126  m_IndexWidget.SetColor( ARGBF( 1, 1, 0, 0 ) );
127  m_EventTypeWidget.SetColor( ARGBF( 1, 1, 0, 0 ) );
128  m_EventTypeWidget.SetColor( ARGBF( 1, 1, 0, 0 ) );
129  }
130 
131  void Unselect()
132  {
133  m_Root.FindAnyWidget( "spacer" ).SetAlpha( 0.625 );
134  m_IndexWidget.SetColor( ARGBF( 1, 1, 1, 1 ) );
135  m_EventTypeWidget.SetColor( ARGBF( 1, 1, 1, 1 ) );
136  m_EventTypeWidget.SetColor( ARGBF( 1, 1, 1, 1 ) );
137  }
138 }
GetGame
proto native CGame GetGame()
Play
ParticleSource Play(int particle_id, Object parent_obj, vector local_pos="0 0 0", vector local_ori="0 0 0")
Legacy function for backwards compatibility with 1.01 and below.
Definition: particlemanager.c:226
EditBoxWidget
Definition: enwidgets.c:353
m_Menu
protected ServerBrowserMenuNew m_Menu
Definition: serverbrowsertab.c:30
PlayerBase
Definition: playerbaseclient.c:1
EmoteCB
Definition: emotemanager.c:1
TextWidget
Definition: enwidgets.c:219
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
HumanCommandActionCallback
Definition: statecb.c:1
ARGBF
int ARGBF(float fa, float fr, float fg, float fb)
Converts <0.0, 1.0> ARGB into color.
Definition: proto.c:332
m_Callback
EmoteCB m_Callback
Definition: emotemanager.c:120
Widget
Definition: enwidgets.c:189
m_Root
protected Widget m_Root
Definition: sizetochild.c:91
ScriptedWidgetEventHandler
map: item x vector(index, width, height)
Definition: enwidgets.c:650
Stop
void Stop()
Stops all elements this effect consists of.
Definition: effect.c:179