Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
cameratoolsmenu.c
Go to the documentation of this file.
1 class CameraToolsMenu extends UIScriptedMenu
2 {
3  protected static CameraToolsMenu m_Instance;
4  vector m_FreeflightCamTransform[4];
5  protected vector m_NextCamPosition;
6 
7  protected float m_Time;
8 
9  protected Camera m_Camera1;
10  protected Camera m_Camera2;
11 
13  protected bool m_IsPlaying;
14  protected int m_NextCameraIndex = 1;
15 
16  protected float m_FollowingTimeFinished;
17  protected ref Param2<int, int> m_FollowingBone;
18 
19  protected CTKeyframe m_SelectedKeyframe;
20  protected CTEvent m_SelectedEvent;
21  protected CTActor m_SelectedActor;
22 
23  protected ref array<ref CTActor> m_Actors;
24  protected ref array<ref CTKeyframe> m_Cameras;
25  protected ref array<ref CTEvent> m_Events;
26 
27  protected Widget m_KeyframeContent;
28  protected Widget m_EventContent;
29 
30  protected XComboBoxWidget m_InterpTypeSpeedCombo;
31  protected XComboBoxWidget m_InterpTypeCombo;
32  protected EditBoxWidget m_BlurEditWidget;
33  protected EditBoxWidget m_ActorTypeWidget;
34 
35  protected EditBoxWidget m_ActorIdWidget;
36  protected EditBoxWidget m_ActorItemTypeWidget;
37 
38  protected ButtonWidget m_AddItem;
39  protected ButtonWidget m_AddHandsItem;
40  protected ButtonWidget m_AddActor;
41  protected ButtonWidget m_Play;
42  protected ButtonWidget m_Stop;
43  protected ButtonWidget m_Save;
44  protected ButtonWidget m_Load;
45 
46  protected ButtonWidget m_AddKeyframe;
47  protected ButtonWidget m_SaveKeyframe;
48  protected ButtonWidget m_DeleteKeyframe;
49  protected ButtonWidget m_ViewKeyframe;
50 
51  protected ButtonWidget m_AddEvent;
52  protected ButtonWidget m_SaveEvent;
53  protected ButtonWidget m_DeleteEvent;
54  protected ButtonWidget m_ViewEvent;
55 
56  protected ButtonWidget m_CopyButton;
57  protected ButtonWidget m_ApplyButton;
58  protected EditBoxWidget m_CameraEditbox;
59  protected TextWidget m_CameraValues;
60 
61  void CameraToolsMenu()
62  {
63  m_Cameras = new array<ref CTKeyframe>;
64  m_Events = new array<ref CTEvent>;
65  m_Actors = new array<ref CTActor>;
66 
67  m_Camera1 = Camera.Cast( GetGame().CreateObject( "staticcamera", GetGame().GetPlayer().GetPosition(), true ) );
68  m_Camera2 = Camera.Cast( GetGame().CreateObject( "staticcamera", GetGame().GetPlayer().GetPosition(), true ) );
69 
70  m_Instance = this;
71  }
72 
73  void ~CameraToolsMenu()
74  {
75  m_Camera1.SetActive( false );
76  m_Camera2.SetActive( false );
77 
78  //GetGame().ObjectDelete( m_Camera1 );
79  //GetGame().ObjectDelete( m_Camera2 );
80 
81  DeveloperFreeCamera.DisableFreeCamera( PlayerBase.Cast( GetGame().GetPlayer() ), false );
82 
83  MissionGameplay ms = MissionGameplay.Cast( GetGame().GetMission() );
84  if (ms)
85  ms.GetHud().Show( true );
86  }
87 
88  override void OnShow()
89  {
90  super.OnShow();
91  if ( !m_IsPlaying )
92  {
93  GetGame().GetMission().AddActiveInputExcludes({"menu"});
94  }
95  }
96 
97  override void OnHide()
98  {
99  super.OnHide();
100  if ( !m_IsPlaying && GetGame() && GetGame().GetMission() && GetGame().GetUIManager())
101  {
102  GetGame().GetUIManager().ShowUICursor(false);
103  GetGame().GetMission().RemoveActiveInputExcludes({"menu"},true);
104  }
105  }
106 
107  void SelectKeyframe( CTKeyframe kf )
108  {
109  if ( m_SelectedKeyframe )
110  m_SelectedKeyframe.Unselect();
111 
112  m_SelectedKeyframe = kf;
113  m_SelectedKeyframe.Select();
114  }
115 
116  void SelectEvent( CTEvent ev )
117  {
118  m_SelectedEvent = ev;
119  }
120 
121  void SelectActor( CTActor ac )
122  {
123  m_SelectedActor = ac;
124  }
125 
126  override Widget Init()
127  {
128  layoutRoot = GetGame().GetWorkspace().CreateWidgets( "gui/layouts/camera_tools/camera_tools.layout" );
129 
130  m_KeyframeContent = layoutRoot.FindAnyWidget( "keyframe_list_content" );
131  m_EventContent = layoutRoot.FindAnyWidget( "events_list_content" );
132  m_InterpTypeCombo = XComboBoxWidget.Cast( layoutRoot.FindAnyWidget( "interp_type" ) );
133  m_InterpTypeSpeedCombo = XComboBoxWidget.Cast( layoutRoot.FindAnyWidget( "interp_speed_type" ) );
134  m_BlurEditWidget = EditBoxWidget.Cast( layoutRoot.FindAnyWidget( "blur_value" ) );
135  m_ActorTypeWidget = EditBoxWidget.Cast( layoutRoot.FindAnyWidget( "add_actor_type" ) );
136  m_ActorIdWidget = EditBoxWidget.Cast( layoutRoot.FindAnyWidget( "add_actor_id" ) );
137  m_ActorItemTypeWidget = EditBoxWidget.Cast( layoutRoot.FindAnyWidget( "add_item_type" ) );
138 
139  m_AddKeyframe = ButtonWidget.Cast( layoutRoot.FindAnyWidget( "add_keyframe" ) );
140  m_AddEvent = ButtonWidget.Cast( layoutRoot.FindAnyWidget( "add_event" ) );
141 
142  m_AddItem = ButtonWidget.Cast( layoutRoot.FindAnyWidget( "add_actor_item" ) );
143  m_AddHandsItem = ButtonWidget.Cast( layoutRoot.FindAnyWidget( "add_actor_item_hands" ) );
144  m_AddActor = ButtonWidget.Cast( layoutRoot.FindAnyWidget( "add_actor" ) );
145  m_Play = ButtonWidget.Cast( layoutRoot.FindAnyWidget( "play" ) );
146  m_Stop = ButtonWidget.Cast( layoutRoot.FindAnyWidget( "stop" ) );
147  m_Save = ButtonWidget.Cast( layoutRoot.FindAnyWidget( "save" ) );
148  m_Load = ButtonWidget.Cast( layoutRoot.FindAnyWidget( "load" ) );
149 
150  m_SaveKeyframe = ButtonWidget.Cast( layoutRoot.FindAnyWidget( "save_keyframe" ) );
151  m_DeleteKeyframe = ButtonWidget.Cast( layoutRoot.FindAnyWidget( "delete_keyframe" ) );
152  m_ViewKeyframe = ButtonWidget.Cast( layoutRoot.FindAnyWidget( "snap_to_keyframe" ) );
153  m_SaveEvent = ButtonWidget.Cast( layoutRoot.FindAnyWidget( "save_event" ) );
154  m_DeleteEvent = ButtonWidget.Cast( layoutRoot.FindAnyWidget( "delete_event" ) );
155  m_ViewEvent = ButtonWidget.Cast( layoutRoot.FindAnyWidget( "snap_to_event" ) );
156 
157  m_CopyButton = ButtonWidget.Cast( layoutRoot.FindAnyWidget( "CopyButton" ) );
158  m_ApplyButton = ButtonWidget.Cast( layoutRoot.FindAnyWidget( "ApplyButton" ) );
159  m_CameraEditbox = EditBoxWidget.Cast( layoutRoot.FindAnyWidget( "CameraEditbox" ) );
160  m_CameraValues = TextWidget.Cast( layoutRoot.FindAnyWidget( "CameraValues" ) );
161 
162  MissionGameplay ms = MissionGameplay.Cast( GetGame().GetMission() );
163  ms.GetHud().Show( false );
164  DeveloperFreeCamera.EnableFreeCameraSceneEditor( PlayerBase.Cast( GetGame().GetPlayer() ) );
165 
166  m_BlurEditWidget.SetText( "0.0" );
167  return layoutRoot;
168  }
169 
170  PlayerBase GetActor( int index )
171  {
172  if ( index > -1 && index < m_Actors.Count() )
173  return PlayerBase.Cast( m_Actors.Get( index ).GetObj() );
174  else
175  return null;
176  }
177 
178  static void PlayAnimOnActor( int actor, int anim )
179  {
180  if ( m_Instance )
181  {
182  PlayerBase p = m_Instance.GetActor( actor );
183  if ( p )
184  {
185  EmoteCB cb = EmoteCB.Cast( p.StartCommand_Action( anim, EmoteCB, DayZPlayerConstants.STANCEMASK_ALL ) );
186  cb.EnableCancelCondition(true);
187  }
188  }
189  }
190 
191  void LoadData()
192  {
193  if ( !FileExist( g_Game.GetMissionFolderPath() + "/CameraTools" ) )
194  MakeDirectory( g_Game.GetMissionFolderPath() + "/CameraTools" );
195 
196  m_Cameras.Clear();
197  m_Events.Clear();
198  m_Actors.Clear();
199 
200  string errorMessage;
201  CTSaveStructure save_data = new CTSaveStructure();
202  if (!JsonFileLoader<ref CTSaveStructure>.LoadFile(g_Game.GetMissionFolderPath() + "/CameraTools/keyframe_data.json", save_data, errorMessage))
203  ErrorEx(errorMessage);
204 
205  m_InterpTypeCombo.SetCurrentItem( save_data.m_InterpType );
206  m_InterpTypeSpeedCombo.SetCurrentItem( save_data.m_InterpSpeed );
207  SetBlurValue( save_data.m_BlurValue );
208 
209  foreach ( Param6<vector, vector, float, float, float, int> transform : save_data.m_Cameras )
210  {
211  CTKeyframe kf = new CTKeyframe( m_Cameras.Count(), transform.param1, transform.param2, transform.param3, transform.param4, transform.param5, transform.param6, GetTotalTime( m_Cameras.Count() ), m_KeyframeContent, this );
212  kf.SetInterpTime( transform.param3 );
213  m_Cameras.Insert( kf );
214  }
215 
216  foreach ( Param4<int, int, float, bool> event_t : save_data.m_Events )
217  {
218  CTEvent ev = new CTEvent( m_Events.Count(), event_t.param1, m_EventContent, event_t.param4, this );
219  ev.SetEventType( event_t.param2 );
220  ev.SetEventTime( event_t.param3 );
221  m_Events.Insert( ev );
222  }
223 
224  foreach ( Param5<vector, vector, string, ref array<string>, string> actor_t : save_data.m_Actors )
225  {
226  CTActor ac = new CTActor( m_Actors.Count(), actor_t.param1, actor_t.param2, actor_t.param3, actor_t.param4, actor_t.param5, this );
227  m_Actors.Insert( ac );
228  }
229  }
230 
231  void SaveData()
232  {
233  if ( !FileExist( g_Game.GetMissionFolderPath() + "/CameraTools" ) )
234  MakeDirectory( g_Game.GetMissionFolderPath() + "/CameraTools" );
235 
236  CTSaveStructure save_data = new CTSaveStructure();
237  save_data.m_InterpType = m_InterpTypeCombo.GetCurrentItem();
238  save_data.m_InterpSpeed = m_InterpTypeSpeedCombo.GetCurrentItem();
239  save_data.m_BlurValue = GetBlurValue();
240 
241  foreach ( CTKeyframe keyframe : m_Cameras )
242  {
243  Param6<vector, vector, float, float, float, int> transform = new Param6<vector, vector, float, float, float, int>( keyframe.GetPosition(), keyframe.GetOrientation(), keyframe.GetInterpTime(), keyframe.GetFOV(), keyframe.GetDOF(), keyframe.GetPin() );
244  save_data.m_Cameras.Insert( transform );
245  }
246 
247  foreach ( CTEvent event_t : m_Events )
248  {
249  Param4<int, int, float, bool> ev = new Param4<int, int, float, bool>( event_t.GetEventActor(), event_t.GetEventType(), event_t.GetEventTime(), event_t.GetEventWalk() );
250  save_data.m_Events.Insert( ev );
251  }
252 
253  foreach ( CTActor actor_t : m_Actors )
254  {
255  Param5<vector, vector, string, ref array<string>, string> ac = new Param5<vector, vector, string, ref array<string>, string>( actor_t.GetPosition(), actor_t.GetRotation(), actor_t.GetActorType(), actor_t.GetItems(), actor_t.GetHandsItem() );
256  save_data.m_Actors.Insert( ac );
257  }
258 
259  string errorMessage;
260  if (!JsonFileLoader<ref CTSaveStructure>.SaveFile(g_Game.GetMissionFolderPath() + "/CameraTools/keyframe_data.json", save_data, errorMessage))
261  ErrorEx(errorMessage);
262  }
263 
264  float GetTotalTime( int index )
265  {
266  float time;
267  index = Math.Clamp( index, 0, m_Cameras.Count() );
268  for ( int i = 0; i < index; i++ )
269  {
270  time += m_Cameras.Get( i ).GetInterpTime();
271  }
272  return time;
273  }
274 
275  void AddKeyframe()
276  {
277  if ( Camera.GetCurrentCamera() )
278  {
279  vector pos = Camera.GetCurrentCamera().GetWorldPosition();
280  vector orient = Camera.GetCurrentCamera().GetOrientation();
281  CTKeyframe kf = new CTKeyframe( m_Cameras.Count(), pos, orient, 1, 70, 50, -1, GetTotalTime( m_Cameras.Count() ), m_KeyframeContent, this );
282  m_Cameras.Insert( kf );
283  SelectKeyframe( kf );
284  }
285  }
286 
287  void SaveKeyframe()
288  {
289  if ( m_SelectedKeyframe && Camera.GetCurrentCamera() )
290  {
291  m_SelectedKeyframe.SetPosition( Camera.GetCurrentCamera().GetWorldPosition() );
292  m_SelectedKeyframe.SetOrientation( Camera.GetCurrentCamera().GetOrientation() );
293  }
294  }
295 
296  void DeleteKeyframe()
297  {
298  if ( m_SelectedKeyframe )
299  {
300  int index = m_Cameras.Find( m_SelectedKeyframe );
301  m_Cameras.Remove( index );
302  index = Math.Clamp( index, 0, m_Cameras.Count() - 1 );
303  if ( m_Cameras.Count() > 0 )
304  {
305  SelectKeyframe( m_Cameras.Get( index ) );
306  }
307  }
308  }
309 
310  void ViewKeyframe()
311  {
312  if ( m_SelectedKeyframe && Camera.GetCurrentCamera() )
313  {
314  Camera.GetCurrentCamera().SetPosition( m_SelectedKeyframe.GetPosition() );
315  Camera.GetCurrentCamera().SetOrientation( m_SelectedKeyframe.GetOrientation() );
316  }
317  }
318 
319  void AddActor( string actor_type )
320  {
321  vector pos = GetCameraLookDir();
322  CTActor ac = new CTActor( m_Actors.Count(), pos, "0 0 0", actor_type, new array<string>, "", this );
323  if ( ac.GetObj() )
324  m_Actors.Insert( ac );
325  }
326 
327  void AddEvent( int actor_index )
328  {
329  if ( actor_index > -1 )
330  {
331  CTEvent ev = new CTEvent( m_Events.Count(), actor_index, m_EventContent, false, this );
332  m_Events.Insert( ev );
333  }
334  }
335 
336 
337  void AddItem( string id, string type )
338  {
339  int id_int = id.ToInt();
340  if ( m_Actors.Count() > id_int && id_int > -1 )
341  {
342  CTActor ac = m_Actors.Get( id_int );
343  if ( ac )
344  ac.AddItem( type );
345  }
346  }
347 
348  void AddHandsItem( string id, string type )
349  {
350  int id_int = id.ToInt();
351  if ( m_Actors.Count() > id_int && id_int > -1 )
352  {
353  CTActor ac = m_Actors.Get( id_int );
354  if ( ac )
355  ac.SetHandsItem( type );
356  }
357  }
358 
359  void SaveEvent()
360  {
361 
362  }
363 
364  void DeleteEvent()
365  {
366 
367  }
368 
369  void ViewEvent()
370  {
371 
372  }
373 
374  Param6<vector, vector, float, float, float, int> GetCameraLine( int index )
375  {
376  if ( index > -1 && index < m_CameraLines.Count() )
377  {
378  return m_CameraLines[index];
379  }
380  return null;
381  }
382 
383  void Play()
384  {
385  if (Camera.GetCurrentCamera())
386  Camera.GetCurrentCamera().GetTransform(m_FreeflightCamTransform);
387  if ( m_Cameras.Count() > 0 )
388  {
389  layoutRoot.Show( false );
390  GetGame().GetUIManager().ShowUICursor( false );
392 
393  foreach ( CTKeyframe keyframe : m_Cameras )
394  {
395  Param6<vector, vector, float, float, float, int> transform = new Param6<vector, vector, float, float, float, int>( keyframe.GetPosition(), keyframe.GetOrientation(), keyframe.GetInterpTime(), keyframe.GetFOV(), keyframe.GetDOF(), keyframe.GetPin() );
396  m_CameraLines.Insert( transform );
397 
398  }
399 
400  foreach ( CTActor ac : m_Actors )
401  {
402  ac.Hide();
403  }
404 
405  foreach ( CTEvent ev : m_Events )
406  {
407  ev.GetEventTime();
408  }
409 
410  DeveloperFreeCamera.DisableFreeCamera( PlayerBase.Cast( GetGame().GetPlayer() ), false );
411 
412  int time = SetCameraData( GetCameraLine( 0 ), GetCameraLine( 1 ) );
413 
414  if ( GetCameraLine( 0 ).param6 > -1 )
415  {
416  m_FollowingTimeFinished = time;
417  m_NextCamPosition = "0 0 0";
418  m_Camera1.SetActive( true );
419  }
420  else
421  {
422  m_NextCamPosition = m_Camera2.GetPosition();
423  m_FollowingTimeFinished = -1;
424  m_Camera1.SetActive( true );
425  m_Camera1.InterpolateTo( m_Camera2, time, m_InterpTypeCombo.GetCurrentItem() );
426  }
427 
428  m_NextCameraIndex = 1;
429  m_IsPlaying = true;
430  m_Time = 0;
431  }
432  }
433 
434  void Stop()
435  {
436  layoutRoot.Show( true );
437  GetGame().GetUIManager().ShowUICursor( true );
438 
439  m_Camera1.SetActive( false );
440  m_Camera2.SetActive( false );
441  FreeDebugCamera.GetInstance().SetActive(true);
442 
443  m_NextCameraIndex = 1;
444  m_IsPlaying = false;
445 
446  foreach ( CTEvent ev : m_Events )
447  {
448  ev.Stop();
449  }
450 
451  foreach ( CTActor ac : m_Actors )
452  {
453  ac.Reset();
454  ac.Show();
455  }
456 
457  Camera.GetCurrentCamera().SetTransform(m_FreeflightCamTransform);
458  }
459 
460  vector GetCameraLookDir()
461  {
462  vector dir = FreeDebugCamera.GetInstance().GetDirection();
463  vector from = FreeDebugCamera.GetInstance().GetPosition();
464  vector to = from + ( dir * 10000 );
465  vector contact_pos;
466  vector contact_dir;
467  int contact_component;
468  Object ev_obj;
469  if ( m_SelectedEvent )
470  ev_obj = GetActor( m_SelectedEvent.GetEventActor() );
471  if ( DayZPhysics.RaycastRV(from, to, contact_pos, contact_dir, contact_component, null, null, ev_obj) )
472  {
473  return contact_pos;
474  }
475 
476  return "0 0 0";
477  }
478 
479  vector GetMouseLookDir()
480  {
481  vector dir = GetGame().GetPointerDirection();
482  vector from = FreeDebugCamera.GetInstance().GetPosition();
483  vector to = from + ( dir * 10000 );
484  vector contact_pos;
485  vector contact_dir;
486  int contact_component;
487  Object ev_obj;
488  if ( m_SelectedEvent )
489  ev_obj = GetActor( m_SelectedEvent.GetEventActor() );
490  if ( DayZPhysics.RaycastRV(from, to, contact_pos, contact_dir, contact_component, null, null, ev_obj) )
491  {
492  return contact_pos;
493  }
494 
495  return "0 0 0";
496  }
497 
498  override void Update( float timeslice )
499  {
500 
501  string camPos = MiscGameplayFunctions.TruncateVecToS(FreeDebugCamera.GetInstance().GetPosition(),0);
502  string camOri = MiscGameplayFunctions.TruncateVecToS(FreeDebugCamera.GetInstance().GetOrientation(),0);
503  m_CameraValues.SetText("Pos:" +camPos + " | Rot:" + camOri);
504 
505  #ifdef DIAG_DEVELOPER
506  if (DiagMenu.GetBool(DiagMenuIDs.CAMERATOOLS_ENABLE_REMOTE_CAMERA_BROADCAST))
507  {
508  Camera cam = Camera.GetCurrentCamera();
509 
510  if (!cam && m_Camera1)
511  cam = m_Camera1;
512  if (cam)
513  {
514  Param4<vector, vector,float,float> p4 = new Param4<vector, vector,float,float>(GetGame().GetCurrentCameraPosition(),GetGame().GetCurrentCameraDirection(), cam.GetNearPlane(), cam.GetCurrentFOV());
515  GetGame().RPCSingleParam(null, ERPCs.DIAG_CAMERATOOLS_CAM_DATA, p4, false);
516  }
517 
518  }
519  #endif
520 
521  if ( m_CameraLines && m_IsPlaying )
522  {
523  foreach ( CTEvent ev : m_Events )
524  {
525  if ( ev.IsTime( m_Time, m_Time + timeslice ) )
526  {
527  ev.Play();
528  }
529  }
530 
531  m_Time += timeslice;
532 
533  if ( !Camera.GetCurrentCamera() || !m_Camera1 || !m_Camera2 )
534  {
535  return;
536  }
537 
538  if ( m_FollowingBone )
539  {
540  PlayerBase p = GetActor( m_FollowingBone.param1 );
541  if ( p )
542  {
543  vector pos = p.GetBonePositionWS( m_FollowingBone.param2 );
544 
545  int bone_index = p.GetBoneIndexByName("LeftHand_Dummy");
546  float bone_rot[4];
547  p.GetBoneRotationWS( bone_index, bone_rot );
548 
549  vector new_orient = Math3D.QuatToAngles(bone_rot);
550 
551  //Print("Rot: "+ new_orient[0] +", "+ new_orient[1] +", "+ new_orient[2]);
552 
553  float temp = new_orient[1];
554  new_orient[0] = new_orient[0] + 325; // vertical
555  new_orient[1] = new_orient[2] + 245;// horizontal
556  new_orient[2] = temp + 290; // tilt
557 
558  //Print("PostRot: "+ new_orient[0] +", "+ new_orient[1] +", "+ new_orient[2]);
559 
560  m_Camera1.SetPosition(pos);
561  m_Camera1.SetOrientation(new_orient);
562  }
563  }
564 
565  if ( m_NextCameraIndex + 1 == m_CameraLines.Count() )
566  {
567  Stop();
568  DeveloperFreeCamera.EnableFreeCameraSceneEditor( PlayerBase.Cast( GetGame().GetPlayer() ) );
569  foreach ( CTEvent ev2 : m_Events )
570  {
571  ev2.Stop();
572  }
573  return;
574  }
575 
576  if ( Camera.GetCurrentCamera().GetPosition() == m_NextCamPosition || ( m_FollowingTimeFinished != -1 && m_Time >= m_FollowingTimeFinished ) )
577  {
578  int time;
579  if ( GetCameraLine( m_NextCameraIndex - 1 ).param6 > -1 )
580  {
581  m_NextCameraIndex--;
582  GetCameraLine( m_NextCameraIndex ).param6 = -1;
583 
584  time = SetCameraData( GetCameraLine( m_NextCameraIndex ), GetCameraLine( m_NextCameraIndex + 1 ) );
585  }
586  else
587  {
588  time = SetCameraData( GetCameraLine( m_NextCameraIndex ), GetCameraLine( m_NextCameraIndex + 1 ) );
589  }
590 
591  m_NextCameraIndex++;
592  if ( GetCameraLine( m_NextCameraIndex - 1 ).param6 > -1 )
593  {
594  m_FollowingTimeFinished = time + m_Time;
595  m_NextCamPosition = "0 0 0";
596  m_Camera1.SetActive( true );
597  }
598  else if ( GetCameraLine( m_NextCameraIndex ) )
599  {
600  m_NextCamPosition = GetCameraLine( m_NextCameraIndex ).param1;
601  m_FollowingTimeFinished = -1;
602  m_Camera1.SetActive( true );
603  m_Camera1.InterpolateTo( m_Camera2, time, m_InterpTypeCombo.GetCurrentItem() );
604  }
605  else
606  {
607  Stop();
608  DeveloperFreeCamera.EnableFreeCameraSceneEditor( PlayerBase.Cast( GetGame().GetPlayer() ) );
609  FreeDebugCamera.GetInstance().SetOrientation( "0 0 0" );
610  foreach( CTEvent ev3 : m_Events )
611  {
612  ev3.Stop();
613  }
614  }
615  }
616  }
617  else
618  {
619  if ( m_Camera1.GetPosition() == m_NextCamPosition )
620  {
621  DeveloperFreeCamera.EnableFreeCameraSceneEditor( PlayerBase.Cast( GetGame().GetPlayer() ) );
622  }
623 
624  for ( int i = 0; i < ( m_Cameras.Count() - 1 ); i++ )
625  {
626  vector pos0 = m_Cameras.Get( i ).GetPosition();
627  vector pos1 = m_Cameras.Get( i + 1 ).GetPosition();
628  Debug.DrawArrow( pos0, pos1, 2, COLOR_RED, ShapeFlags.ONCE );
629  }
630 
631  if ( m_SelectedActor )
632  {
633  if ( !g_Game.IsLeftCtrlDown() )
634  m_SelectedActor.SetPosition( GetMouseLookDir() );
635  else
636  {
637  vector from = m_SelectedActor.GetPosition();
638  vector to = GetMouseLookDir();
639  Debug.DrawArrow( from, to, 0.5, COLOR_RED, ShapeFlags.ONCE );
640  m_SelectedActor.SetRotation( vector.Direction( from,to ).Normalized().VectorToAngles() );
641  }
642 
643  }
644 
645  foreach ( CTActor ac : m_Actors )
646  {
647  ac.Update( timeslice );
648  }
649  }
650  }
651 
652  float SetCameraData( Param6<vector, vector, float, float, float,int> transform1, Param6<vector, vector, float, float, float, int> transform2 )
653  {
654  float int_value = transform1.param3;
655  if ( m_InterpTypeSpeedCombo.GetCurrentItem() == 1 )
656  {
657  int_value = vector.Distance( transform1.param1, transform2.param1 ) / int_value;
658  }
659  PlayerBase p;
660  float pQuat[4];
661  int b_index;
662  if ( transform1.param6 > -1 )
663  {
664  p = GetActor( transform1.param6 );
665  if ( p )
666  {
667  b_index = p.GetBoneIndexByName( "LeftHand_Dummy" );
668  m_FollowingBone = new Param2<int, int>(transform1.param6, b_index);
669  }
670  }
671  else
672  {
673  m_Camera1.SetPosition( transform1.param1 );
674  m_Camera1.SetOrientation( transform1.param2 );
675  m_FollowingBone = null;
676  }
677  m_Camera1.SetFOV( transform1.param4 * Math.DEG2RAD );
678  m_Camera1.SetFocus( transform1.param5, GetBlurValue() );
679 
680  if ( transform2 )
681  {
682  if ( transform2.param6 > -1 )
683  {
684  pQuat[4];
685  p = GetActor( transform2.param6 );
686  if ( p )
687  {
688  b_index = p.GetBoneIndexByName( "LeftHand_Dummy" );
689  if ( b_index != -1 )
690  {
691  m_Camera2.SetPosition( p.GetBonePositionWS( b_index ) );
692 
693  p.GetBoneRotationWS( b_index, pQuat);
694  vector v = Math3D.QuatToAngles( pQuat );
695  v[0] = fixAngle_180_180( v[0] - 180 );
696  v[1] = fixAngle_180_180( v[1] - 270 );
697  v[2] = fixAngle_180_180( v[2] + 90 );
698  DbgUI.Text( v.ToString() );
699  m_Camera2.SetYawPitchRoll( v );
700  }
701  }
702  }
703  else
704  {
705  m_Camera2.SetPosition( transform2.param1 );
706  m_Camera2.SetOrientation( transform2.param2 );
707  }
708 
709  m_Camera2.SetFOV( transform2.param4 * Math.DEG2RAD );
710  m_Camera2.SetFocus( transform2.param5, GetBlurValue() );
711  }
712 
713  return int_value;
714  }
715 
716  void SetBlurValue( float blur )
717  {
718  m_BlurEditWidget.SetText( blur.ToString() );
719  }
720 
721  float GetBlurValue()
722  {
723  return m_BlurEditWidget.GetText().ToFloat();
724  }
725 
726  override bool OnMouseButtonDown( Widget w, int x, int y, int button )
727  {
728  if ( w == layoutRoot && button == MouseState.RIGHT && !m_IsPlaying )
729  {
730  GetGame().GetInput().ResetGameFocus();
731  GetGame().GetInput().ChangeGameFocus(-1);
732  GetGame().GetUIManager().ShowUICursor(false);
733  GetGame().GetMission().RemoveActiveInputExcludes({"menu"});
734  SetFocus( layoutRoot );
735  return true;
736  }
737  else if ( !IsFocusable( w ) )
738  {
739  SetFocus( layoutRoot );
740  }
741  return false;
742  }
743 
744  override bool OnMouseButtonUp( Widget w, int x, int y, int button )
745  {
746  if ( w == layoutRoot && button == MouseState.LEFT )
747  {
748  SelectActor( null );
749  return true;
750  }
751  return false;
752  }
753 
754  override bool OnClick( Widget w, int x, int y, int button )
755  {
756  if ( button == MouseState.LEFT )
757  {
758  if ( w == m_SaveKeyframe )
759  {
760  SaveKeyframe();
761  return true;
762  }
763  else if ( w == m_DeleteKeyframe )
764  {
765  DeleteKeyframe();
766  return true;
767  }
768  else if ( w == m_ViewKeyframe )
769  {
770  ViewKeyframe();
771  return true;
772  }
773  else if ( w == m_SaveEvent )
774  {
775  SaveEvent();
776  return true;
777  }
778  else if ( w == m_DeleteEvent )
779  {
780  DeleteEvent();
781  return true;
782  }
783  else if ( w == m_ViewEvent )
784  {
785  ViewEvent();
786  return true;
787  }
788  else if ( w == m_AddKeyframe )
789  {
790  AddKeyframe();
791  return true;
792  }
793  else if ( w == m_AddEvent )
794  {
795  AddEvent( 0 );
796  return true;
797  }
798  else if ( w == m_Play )
799  {
800  Play();
801  return true;
802  }
803  else if ( w == m_Stop )
804  {
805  Stop();
806  return true;
807  }
808  else if ( w == m_Save )
809  {
810  SaveData();
811  return true;
812  }
813  else if ( w == m_Load )
814  {
815  LoadData();
816  return true;
817  }
818  else if ( w == m_AddActor )
819  {
820  AddActor( m_ActorTypeWidget.GetText() );
821  }
822  else if ( w == m_AddItem )
823  {
824  AddItem( m_ActorIdWidget.GetText(), m_ActorItemTypeWidget.GetText() );
825  }
826  else if ( w == m_AddHandsItem )
827  {
828  AddHandsItem( m_ActorIdWidget.GetText(), m_ActorItemTypeWidget.GetText() );
829  }
830  else if ( w == m_CopyButton )
831  {
832  string clipboardIn = FreeDebugCamera.GetInstance().GetPosition().ToString(false)+"|"+ FreeDebugCamera.GetInstance().GetOrientation().ToString(false);
833  GetGame().CopyToClipboard( clipboardIn );
834 
835  //Print(clipboardIn);
836  }
837  else if ( w == m_ApplyButton )
838  {
839  string camText = m_CameraEditbox.GetText();
840  if (camText && camText.IndexOf("|") !=-1)
841  {
842  int seperatorIndex = camText.IndexOf("|");
843  int length = camText.Length();
844 
845  string posStr = camText.Substring(0,seperatorIndex);
846  string oriStr = camText.Substring(seperatorIndex+1, length - seperatorIndex - 1);
847  FreeDebugCamera.GetInstance().SetPosition(posStr.ToVector());
848  FreeDebugCamera.GetInstance().SetOrientation(oriStr.ToVector());
849  }
850  }
851  }
852  return false;
853  }
854 
855 
856  override bool OnMouseEnter( Widget w, int x, int y )
857  {
858  if ( w == m_CameraEditbox)
859  m_CameraEditbox.SetText("");
860  return true;
861  }
862 
863  override bool OnMouseLeave( Widget w, Widget enterW, int x, int y )
864  {
865  return true;
866  }
867 
868  override bool OnFocus( Widget w, int x, int y )
869  {
870  if ( IsFocusable( w ) )
871  {
872  ColorRed( w );
873  return true;
874  }
875  return false;
876  }
877 
878  override bool OnFocusLost( Widget w, int x, int y )
879  {
880  if ( IsFocusable( w ) )
881  {
882  ColorWhite( w, null );
883  return true;
884  }
885  return false;
886  }
887 
888  bool IsFocusable( Widget w )
889  {
890  if ( w )
891  {
892  return ( w == m_SaveKeyframe || w == m_DeleteKeyframe || w == m_ViewKeyframe || w == m_SaveEvent || w == m_DeleteEvent || w == m_ViewEvent || w == m_AddKeyframe || w == m_AddEvent || w == m_Play || w == m_Stop || w == m_Save || w == m_Load || w == m_InterpTypeCombo );
893  }
894  return false;
895  }
896 
897  override bool OnKeyPress(Widget w, int x, int y, int key)
898  {
899  if (!w && key == KeyCode.KC_P )
900  {
901  if ( !m_IsPlaying )
902  {
903  Play();
904  return true;
905  }
906  else
907  {
908  Stop();
909  return true;
910  }
911  return false;
912  }
913  else if ( g_Game.IsLeftCtrlDown() && key == KeyCode.KC_S )
914  {
915  SaveKeyframe();
916  return true;
917  }
918  else if ( g_Game.IsLeftCtrlDown() && key == KeyCode.KC_Q )
919  {
920  AddKeyframe();
921  return true;
922  }
923  else if ( g_Game.IsLeftCtrlDown() && key == KeyCode.KC_E )
924  {
925  DeleteKeyframe();
926  return true;
927  }
928 
929  else if ( !w && g_Game.IsLeftCtrlDown() )
930  {
931  SelectActor( null );
932  return true;
933  }
934  return false;
935  }
936 
937  //Coloring functions (Until WidgetStyles are useful)
938  void ColorRed( Widget w )
939  {
940  //SetFocus( w );
941  if ( w.IsInherited( ButtonWidget ) )
942  {
943  ButtonWidget button = ButtonWidget.Cast( w );
944  button.SetTextColor( ARGB( 255, 255, 0, 0 ) );
945  button.SetAlpha( 0.9 );
946  }
947  }
948 
949  void ColorWhite( Widget w, Widget enterW )
950  {
951  if ( w.IsInherited( ButtonWidget ) )
952  {
953  ButtonWidget button = ButtonWidget.Cast( w );
954  if (button)
955  {
956  button.SetTextColor( ARGB( 255, 255, 255, 255 ) );
957  button.SetAlpha( 0.75 );
958  }
959  }
960  }
961 }
Param2
Definition: ppeconstants.c:66
GetGame
proto native CGame GetGame()
UIScriptedMenu
Definition: dayzgame.c:63
m_Time
protected float m_Time
Definition: carscript.c:146
m_IsPlaying
protected bool m_IsPlaying
Whether the Effect is currently playing.
Definition: effect.c:37
DeveloperFreeCamera
Definition: developerfreecamera.c:1
DbgUI
Definition: dbgui.c:59
MakeDirectory
proto native bool MakeDirectory(string name)
Makes a directory.
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
DiagMenu
Definition: endebug.c:232
KeyCode
KeyCode
Definition: ensystem.c:156
EditBoxWidget
Definition: enwidgets.c:353
SelectEvent
protected bool SelectEvent()
Definition: spookyareamisc.c:278
OnHide
override void OnHide()
Definition: inventorymenu.c:141
y
Icon y
FileExist
proto bool FileExist(string name)
Check existence of file.
CTSaveStructure
Definition: ctsavestructure.c:1
ErrorEx
enum ShapeType ErrorEx
OnMouseLeave
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
Definition: uihintpanel.c:276
OnMouseButtonUp
override bool OnMouseButtonUp(Widget w, int x, int y, int button)
Definition: radialmenu.c:668
DiagMenuIDs
DiagMenuIDs
Definition: ediagmenuids.c:1
GetPosition
class JsonUndergroundAreaTriggerData GetPosition
Definition: undergroundarealoader.c:9
PlayerBase
Definition: playerbaseclient.c:1
EmoteCB
Definition: emotemanager.c:1
vector
Definition: enconvert.c:105
Init
class InventoryGridController extends ScriptedWidgetEventHandler Init
Definition: uihintpanel.c:46
TextWidget
Definition: enwidgets.c:219
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
ShapeFlags
ShapeFlags
Definition: endebug.c:125
g_Game
DayZGame g_Game
Definition: dayzgame.c:3727
Object
Definition: objecttyped.c:1
COLOR_RED
const int COLOR_RED
Definition: constants.c:64
OnFocusLost
override bool OnFocusLost(Widget w, int x, int y)
Definition: serverbrowsertab.c:235
MouseState
MouseState
Definition: ensystem.c:310
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition: isboxcollidinggeometryproxyclasses.c:27
Update
proto native volatile void Update()
Definition: playersoundmanager.c:125
SetFocus
proto native void SetFocus(Widget w)
x
Icon x
OnMouseButtonDown
bool OnMouseButtonDown(Widget w, int x, int y, int button)
Definition: pluginitemdiagnostic.c:117
GetPlayer
protected void GetPlayer()
Definition: crosshairselector.c:127
Debug
Definition: debug.c:13
DayZPhysics
Definition: dayzphysics.c:123
Camera
Definition: camera.c:69
fixAngle_180_180
float fixAngle_180_180(float pAngle)
Definition: dayzplayercamera_base.c:36
ERPCs
ERPCs
Definition: erpcs.c:1
OnFocus
override bool OnFocus(Widget w, int x, int y)
Definition: serverbrowsertab.c:217
OnShow
override void OnShow()
Definition: controlsxbox.c:349
Widget
Definition: enwidgets.c:189
OnClick
override bool OnClick(Widget w, int x, int y, int button)
buttons clicks
Definition: dayzgame.c:146
Math
Definition: enmath.c:6
OnMouseEnter
override bool OnMouseEnter(Widget w, int x, int y)
Definition: uihintpanel.c:267
ARGB
int ARGB(int a, int r, int g, int b)
Definition: proto.c:322
Math3D
Definition: enmath3d.c:27
Stop
void Stop()
Stops all elements this effect consists of.
Definition: effect.c:179
IsFocusable
bool IsFocusable(Widget w)
Definition: serverbrowsertab.c:284