public void OnGUI(Rect controlArea, CutsceneWrapper cs, Rect toolbarArea) { cutscene = cs; updateControlLayout(controlArea); drawBackground(); updateTimelineHeader(headerArea, timeRuleArea); if (cutscene != null) { bindControls(cutscene); updateControlState(); float trackGroupsHeight = getTrackGroupsHeight(cutscene); verticalScrollValue = GUI.VerticalScrollbar(verticalScrollbarArea, verticalScrollValue, Mathf.Min(bodyArea.height, trackGroupsHeight), 0f, trackGroupsHeight); Translation = new Vector2(Translation.x, verticalScrollValue); Rect area = new Rect(bodyArea.x, -Translation.y, bodyArea.width, trackGroupsHeight); directorState.Translation = Translation; directorState.Scale = Scale; GUILayout.BeginArea(bodyArea, string.Empty); updateTrackGroups(area, toolbarArea); updateDurationBar(); GUILayout.EndArea(); updateScrubber(); BeginViewGUI(true); updateUserInput(); updateDragAndDrop(); } }
public static void ReflectChanges(Cutscene cutscene, CutsceneWrapper wrapper) { if (cutscene == null || wrapper == null) { return; } cutscene.Duration = wrapper.Duration; { // foreach(var tgw in wrapper.TrackGroups) var __enumerator4 = (wrapper.TrackGroups).GetEnumerator(); while (__enumerator4.MoveNext()) { var tgw = (TrackGroupWrapper)__enumerator4.Current; { TrackGroup tg = tgw.Behaviour as TrackGroup; tg.Ordinal = tgw.Ordinal; { // foreach(var trackWrapper in tgw.Tracks) var __enumerator23 = (tgw.Tracks).GetEnumerator(); while (__enumerator23.MoveNext()) { var trackWrapper = (TimelineTrackWrapper)__enumerator23.Current; { TimelineTrack track = trackWrapper.Behaviour as TimelineTrack; track.Ordinal = trackWrapper.Ordinal; } } } } } } }
public void OnGUI(Rect controlArea, CutsceneWrapper cs) { this.cutscene = cs; this.updateControlLayout(controlArea); this.drawBackground(); this.updateTimelineHeader(this.headerArea, this.timeRuleArea); if (this.cutscene != null) { this.bindControls(this.cutscene); this.updateControlState(); float num = this.getTrackGroupsHeight(this.cutscene); if (Event.current.type == (EventType)6) { this.verticalScrollValue += (17f * Event.current.delta.y) / 3f; } this.verticalScrollValue = GUI.VerticalScrollbar(this.verticalScrollbarArea, this.verticalScrollValue, Mathf.Min(this.bodyArea.height, num), 0f, num); Vector2 vector = new Vector2(base.Translation.x, this.verticalScrollValue); base.Translation = vector; Rect area = new Rect(this.bodyArea.x, -base.Translation.y, this.bodyArea.width, num); this.directorState.Translation = base.Translation; this.directorState.Scale = base.Scale; GUILayout.BeginArea(this.bodyArea, string.Empty); this.updateTrackGroups(area); this.updateDurationBar(); GUILayout.EndArea(); this.updateScrubber(); base.BeginViewGUI(true); this.updateUserInput(); this.updateDragAndDrop(); } }
public static CutsceneWrapper CreateWrapper(Cutscene cutscene) { CutsceneWrapper wrapper = new CutsceneWrapper(cutscene); if (cutscene != null) { wrapper.RunningTime = cutscene.RunningTime; wrapper.Duration = cutscene.Duration; wrapper.IsPlaying = cutscene.State == Cutscene.CutsceneState.PreviewPlaying || cutscene.State == Cutscene.CutsceneState.Playing; foreach (TrackGroup tg in cutscene.TrackGroups) { TrackGroupWrapper tgWrapper = new TrackGroupWrapper(tg); tgWrapper.Ordinal = tg.Ordinal; wrapper.AddTrackGroup(tg, tgWrapper); foreach (TimelineTrack track in tg.GetTracks()) { TimelineTrackWrapper trackWrapper = new TimelineTrackWrapper(track); trackWrapper.Ordinal = track.Ordinal; tgWrapper.AddTrack(track, trackWrapper); foreach (TimelineItem item in track.GetTimelineItems()) { if (item.GetType().IsSubclassOf(typeof(CinemaClipCurve))) { CinemaClipCurve clip = item as CinemaClipCurve; CinemaClipCurveWrapper clipWrapper = new CinemaClipCurveWrapper(clip, clip.Firetime, clip.Duration); trackWrapper.AddItem(clip, clipWrapper); } else if (item.GetType().IsSubclassOf(typeof(CinemaTween))) { } else if (item.GetType().IsSubclassOf(typeof(TimelineActionFixed))) { TimelineActionFixed actionFixed = item as TimelineActionFixed; CinemaActionFixedWrapper actionFixedWrapper = new CinemaActionFixedWrapper(actionFixed, actionFixed.Firetime, actionFixed.Duration, actionFixed.InTime, actionFixed.OutTime, actionFixed.ItemLength); trackWrapper.AddItem(actionFixed, actionFixedWrapper); } else if (item.GetType().IsSubclassOf(typeof(TimelineAction))) { TimelineAction action = item as TimelineAction; CinemaActionWrapper itemWrapper = new CinemaActionWrapper(action, action.Firetime, action.Duration); trackWrapper.AddItem(action, itemWrapper); } else { TimelineItemWrapper itemWrapper = new TimelineItemWrapper(item, item.Firetime); trackWrapper.AddItem(item, itemWrapper); } } } } } return(wrapper); }
/// <summary> /// Draws the GUI for the Timeline Window. /// </summary> protected void OnGUI() { Rect toolbarArea = new Rect(0, 0, base.position.width, TOOLBAR_HEIGHT); Rect controlArea = new Rect(0, TOOLBAR_HEIGHT, base.position.width, base.position.height - TOOLBAR_HEIGHT); updateToolbar(toolbarArea); cutsceneWrapper = DirectorHelper.UpdateWrapper(cutscene, cutsceneWrapper); directorControl.OnGUI(controlArea, cutsceneWrapper); DirectorHelper.ReflectChanges(cutscene, cutsceneWrapper); }
private float getTrackGroupsHeight(CutsceneWrapper cutscene) { float num = 0f; foreach (TrackGroupWrapper current in cutscene.TrackGroups) { if (trackGroupBinding.ContainsKey(current)) { TrackGroupControl trackGroupControl = trackGroupBinding[current]; num += trackGroupControl.GetHeight(); } } return(num); }
private float getTrackGroupsHeight(CutsceneWrapper cutscene) { float num = 0f; foreach (TrackGroupWrapper wrapper in cutscene.TrackGroups) { if (this.trackGroupBinding.ContainsKey(wrapper)) { TrackGroupControl control = this.trackGroupBinding[wrapper]; num += control.GetHeight(); } } return(num); }
private void BindParent(CutsceneWrapper cutscene) { foreach (TrackGroupWrapper wrapper in trackGroupBinding.Keys) { foreach (TrackGroupWrapper wrapper1 in trackGroupBinding.Keys) { if (wrapper.Behaviour.transform.parent == wrapper1.Behaviour.transform) { trackGroupBinding[wrapper].ParentControl = trackGroupBinding[wrapper1]; break; } } } }
/// <summary> /// Draws the GUI for the Timeline Window. /// </summary> protected void OnGUI() { Rect controlArea = new Rect(0, TOOLBAR_HEIGHT, position.width, position.height - TOOLBAR_HEIGHT); updateToolbar(); cutsceneWrapper = DirectorHelper.UpdateWrapper(cutscene, cutsceneWrapper); switch (Event.current.keyCode) { case KeyCode.RightArrow: cutscene.RunningTime += 0.01f; break; case KeyCode.LeftArrow: cutscene.RunningTime -= 0.01f; break; } directorControl.OnGUI(controlArea, cutsceneWrapper, position); DirectorHelper.ReflectChanges(cutscene, cutsceneWrapper); }
public static void ReflectChanges(TimelineManager cutscene, CutsceneWrapper wrapper) { if (cutscene == null || wrapper == null) { return; } cutscene.Duration = wrapper.Duration; foreach (TrackGroupWrapper tgw in wrapper.TrackGroups) { TrackGroup tg = tgw.Behaviour as TrackGroup; tg.Ordinal = tgw.Ordinal; foreach (TimelineTrackWrapper trackWrapper in tgw.Tracks) { TimelineTrack track = trackWrapper.Behaviour as TimelineTrack; track.Ordinal = trackWrapper.Ordinal; } } }
private void bindControls(CutsceneWrapper cutscene) { List <SidebarControl> newSidebarControls = new List <SidebarControl>(); List <SidebarControl> removedSidebarControls = new List <SidebarControl>(); List <TrackItemControl> newTimelineControls = new List <TrackItemControl>(); List <TrackItemControl> removedTimelineControls = new List <TrackItemControl>(); this.bindTrackGroupControls(cutscene, newSidebarControls, removedSidebarControls, newTimelineControls, removedTimelineControls); foreach (SidebarControl local1 in newSidebarControls) { local1.DeleteRequest += new DirectorBehaviourControlHandler(this.control_DeleteRequest); local1.DuplicateRequest += new SidebarControlHandler(this.sidebarControl_Duplicate); local1.SelectRequest += new SidebarControlHandler(this.sidebarControl_SelectRequest); } foreach (SidebarControl local2 in removedSidebarControls) { local2.DeleteRequest -= new DirectorBehaviourControlHandler(this.control_DeleteRequest); local2.DuplicateRequest -= new SidebarControlHandler(this.sidebarControl_Duplicate); local2.SelectRequest -= new SidebarControlHandler(this.sidebarControl_SelectRequest); } foreach (TrackItemControl control in newTimelineControls) { this.timelineControls.Add(control); control.DeleteRequest += new DirectorBehaviourControlHandler(this.control_DeleteRequest); control.RequestTrackItemTranslate += new TranslateTrackItemEventHandler(this.itemControl_RequestTrackItemTranslate); control.TrackItemTranslate += new TranslateTrackItemEventHandler(this.itemControl_TrackItemTranslate); control.TrackItemUpdate += new TrackItemEventHandler(this.itemControl_TrackItemUpdate); } foreach (TrackItemControl control2 in removedTimelineControls) { this.timelineControls.Remove(control2); control2.DeleteRequest -= new DirectorBehaviourControlHandler(this.control_DeleteRequest); control2.RequestTrackItemTranslate -= new TranslateTrackItemEventHandler(this.itemControl_RequestTrackItemTranslate); control2.TrackItemTranslate -= new TranslateTrackItemEventHandler(this.itemControl_TrackItemTranslate); control2.TrackItemUpdate -= new TrackItemEventHandler(this.itemControl_TrackItemUpdate); } }
private void bindControls(CutsceneWrapper cutscene) { List <SidebarControl> list = new List <SidebarControl>(); List <SidebarControl> list2 = new List <SidebarControl>(); List <TrackItemControl> list3 = new List <TrackItemControl>(); List <TrackItemControl> list4 = new List <TrackItemControl>(); bindTrackGroupControls(cutscene, list, list2, list3, list4); foreach (SidebarControl expr_34 in list) { expr_34.DeleteRequest += new DirectorBehaviourControlHandler(control_DeleteRequest); expr_34.DuplicateRequest += new SidebarControlHandler(sidebarControl_Duplicate); expr_34.SelectRequest += new SidebarControlHandler(sidebarControl_SelectRequest); } foreach (SidebarControl expr_93 in list2) { expr_93.DeleteRequest -= new DirectorBehaviourControlHandler(control_DeleteRequest); expr_93.DuplicateRequest -= new SidebarControlHandler(sidebarControl_Duplicate); expr_93.SelectRequest -= new SidebarControlHandler(this.sidebarControl_SelectRequest); } foreach (TrackItemControl current in list3) { timelineControls.Add(current); current.DeleteRequest += control_DeleteRequest; current.RequestTrackItemTranslate += new TranslateTrackItemEventHandler(itemControl_RequestTrackItemTranslate); current.TrackItemTranslate += new TranslateTrackItemEventHandler(itemControl_TrackItemTranslate); current.TrackItemUpdate += new TrackItemEventHandler(this.itemControl_TrackItemUpdate); } foreach (TrackItemControl current2 in list4) { timelineControls.Remove(current2); current2.DeleteRequest -= new DirectorBehaviourControlHandler(this.control_DeleteRequest); current2.RequestTrackItemTranslate -= new TranslateTrackItemEventHandler(this.itemControl_RequestTrackItemTranslate); current2.TrackItemTranslate -= new TranslateTrackItemEventHandler(this.itemControl_TrackItemTranslate); current2.TrackItemUpdate -= new TrackItemEventHandler(this.itemControl_TrackItemUpdate); } }
public static CutsceneWrapper UpdateWrapper(TimelineManager cutscene, CutsceneWrapper wrapper) { if (cutscene == null) { return(null); } if (wrapper == null || !cutscene.Equals(wrapper.Behaviour)) { return(CreateWrapper(cutscene)); } else { wrapper.Behaviour = cutscene; wrapper.Duration = cutscene.Duration; wrapper.IsPlaying = cutscene.State == TimelineManager.TimeLineState.PreviewPlaying || cutscene.State == TimelineManager.TimeLineState.Playing; wrapper.RunningTime = cutscene.RunningTime; List <Behaviour> itemsToRemove = new List <Behaviour>(); foreach (Behaviour behaviour in wrapper.Behaviours) { bool found = false; foreach (TrackGroup group in cutscene.TrackGroups) { if (behaviour.Equals(group)) { found = true; break; } } if (!found || behaviour == null) { itemsToRemove.Add(behaviour); } } foreach (Behaviour trackGroup in itemsToRemove) { wrapper.HasChanged = true; wrapper.RemoveTrackGroup(trackGroup); } foreach (TrackGroup tg in cutscene.TrackGroups) { TrackGroupWrapper tgWrapper = null; if (!wrapper.ContainsTrackGroup(tg, out tgWrapper)) { tgWrapper = new TrackGroupWrapper(tg); tgWrapper.Ordinal = tg.Ordinal; wrapper.AddTrackGroup(tg, tgWrapper); wrapper.HasChanged = true; } foreach (TimelineTrack track in tg.GetTracks()) { TimelineTrackWrapper trackWrapper = null; if (!tgWrapper.ContainsTrack(track, out trackWrapper)) { trackWrapper = new TimelineTrackWrapper(track); trackWrapper.Ordinal = track.Ordinal; tgWrapper.AddTrack(track, trackWrapper); tgWrapper.HasChanged = true; } foreach (TimelineItem item in track.GetTimelineItems()) { TimelineItemWrapper itemWrapper = null; if (!trackWrapper.ContainsItem(item, out itemWrapper)) { if (item.GetType().IsSubclassOf(typeof(ItemClipCurve))) { ItemClipCurve clip = item as ItemClipCurve; itemWrapper = new CinemaClipCurveWrapper(clip, clip.Firetime, clip.Duration); trackWrapper.AddItem(clip, itemWrapper); } else if (item.GetType().IsSubclassOf(typeof(TimelineActionFixed))) { TimelineActionFixed fixedAction = item as TimelineActionFixed; itemWrapper = new CinemaActionFixedWrapper(fixedAction, fixedAction.Firetime, fixedAction.Duration, fixedAction.InTime, fixedAction.OutTime, fixedAction.ItemLength); trackWrapper.AddItem(fixedAction, itemWrapper); } else if (item.GetType().IsSubclassOf(typeof(TimelineAction))) { TimelineAction action = item as TimelineAction; itemWrapper = new CinemaActionWrapper(action, action.Firetime, action.Duration); trackWrapper.AddItem(action, itemWrapper); } else { itemWrapper = new TimelineItemWrapper(item, item.Firetime); trackWrapper.AddItem(item, itemWrapper); } trackWrapper.HasChanged = true; } else { if (GUIUtility.hotControl == 0) { if (itemWrapper.GetType() == (typeof(CinemaClipCurveWrapper))) { ItemClipCurve clip = item as ItemClipCurve; CinemaClipCurveWrapper clipWrapper = itemWrapper as CinemaClipCurveWrapper; clipWrapper.Firetime = clip.Firetime; clipWrapper.Duration = clip.Duration; } else if (itemWrapper.GetType() == (typeof(CinemaTweenWrapper))) { } else if (itemWrapper.GetType() == (typeof(CinemaActionFixedWrapper))) { TimelineActionFixed actionFixed = item as TimelineActionFixed; CinemaActionFixedWrapper actionFixedWrapper = itemWrapper as CinemaActionFixedWrapper; actionFixedWrapper.Firetime = actionFixed.Firetime; actionFixedWrapper.Duration = actionFixed.Duration; actionFixedWrapper.InTime = actionFixed.InTime; actionFixedWrapper.OutTime = actionFixed.OutTime; actionFixedWrapper.ItemLength = actionFixed.ItemLength; } else if (itemWrapper.GetType() == (typeof(CinemaActionWrapper))) { TimelineAction action = item as TimelineAction; CinemaActionWrapper actionWrapper = itemWrapper as CinemaActionWrapper; actionWrapper.Firetime = action.Firetime; actionWrapper.Duration = action.Duration; } else { itemWrapper.Firetime = item.Firetime; } } } } // Remove missing track items List <Behaviour> itemRemovals = new List <Behaviour>(); foreach (Behaviour behaviour in trackWrapper.Behaviours) { bool found = false; foreach (TimelineItem item in track.GetTimelineItems()) { if (behaviour.Equals(item)) { found = true; break; } } if (!found || behaviour == null) { itemRemovals.Add(behaviour); } } foreach (Behaviour item in itemRemovals) { trackWrapper.HasChanged = true; trackWrapper.RemoveItem(item); } trackWrapper.IsLocked = track.lockedStatus; } // Remove missing tracks List <Behaviour> removals = new List <Behaviour>(); foreach (Behaviour behaviour in tgWrapper.Behaviours) { bool found = false; foreach (TimelineTrack track in tg.GetTracks()) { if (behaviour.Equals(track)) { found = true; break; } } if (!found || behaviour == null) { removals.Add(behaviour); } } foreach (Behaviour track in removals) { tgWrapper.HasChanged = true; tgWrapper.RemoveTrack(track); } } } return(wrapper); }
public static CutsceneWrapper CreateWrapper(Cutscene cutscene) { CutsceneWrapper wrapper = new CutsceneWrapper(cutscene); if (cutscene != null) { wrapper.RunningTime = cutscene.RunningTime; wrapper.Duration = cutscene.Duration; wrapper.IsPlaying = cutscene.State == Cutscene.CutsceneState.PreviewPlaying || cutscene.State == Cutscene.CutsceneState.Playing; { var __array5 = cutscene.TrackGroups; var __arrayLength5 = __array5.Length; for (int __i5 = 0; __i5 < __arrayLength5; ++__i5) { var tg = (TrackGroup)__array5[__i5]; { TrackGroupWrapper tgWrapper = new TrackGroupWrapper(tg); tgWrapper.Ordinal = tg.Ordinal; wrapper.AddTrackGroup(tg, tgWrapper); { // foreach(var track in tg.GetTracks()) var __enumerator25 = (tg.GetTracks()).GetEnumerator(); while (__enumerator25.MoveNext()) { var track = (TimelineTrack)__enumerator25.Current; { TimelineTrackWrapper trackWrapper = new TimelineTrackWrapper(track); trackWrapper.Ordinal = track.Ordinal; tgWrapper.AddTrack(track, trackWrapper); { // foreach(var item in track.GetTimelineItems()) var __enumerator33 = (track.GetTimelineItems()).GetEnumerator(); while (__enumerator33.MoveNext()) { var item = (TimelineItem)__enumerator33.Current; { if (item.GetType().IsSubclassOf(typeof(CinemaClipCurve))) { CinemaClipCurve clip = item as CinemaClipCurve; CinemaClipCurveWrapper clipWrapper = new CinemaClipCurveWrapper(clip, clip.Firetime, clip.Duration); trackWrapper.AddItem(clip, clipWrapper); } else if (item.GetType().IsSubclassOf(typeof(CinemaTween))) { } else if (item.GetType().IsSubclassOf(typeof(TimelineActionFixed))) { TimelineActionFixed actionFixed = item as TimelineActionFixed; CinemaActionFixedWrapper actionFixedWrapper = new CinemaActionFixedWrapper(actionFixed, actionFixed.Firetime, actionFixed.Duration, actionFixed.InTime, actionFixed.OutTime, actionFixed.ItemLength); trackWrapper.AddItem(actionFixed, actionFixedWrapper); } else if (item.GetType().IsSubclassOf(typeof(TimelineAction))) { TimelineAction action = item as TimelineAction; CinemaActionWrapper itemWrapper = new CinemaActionWrapper(action, action.Firetime, action.Duration); trackWrapper.AddItem(action, itemWrapper); } else { TimelineItemWrapper itemWrapper = new TimelineItemWrapper(item, item.Firetime); trackWrapper.AddItem(item, itemWrapper); } } } } } } } } } } } return(wrapper); }
public static CutsceneWrapper UpdateWrapper(Cutscene cutscene, CutsceneWrapper wrapper) { if (cutscene == null) { return(null); } if (wrapper == null || !cutscene.Equals(wrapper.Behaviour)) { return(CreateWrapper(cutscene)); } else { wrapper.Behaviour = cutscene; wrapper.Duration = cutscene.Duration; wrapper.IsPlaying = cutscene.State == Cutscene.CutsceneState.PreviewPlaying || cutscene.State == Cutscene.CutsceneState.Playing; wrapper.RunningTime = cutscene.RunningTime; List <Behaviour> itemsToRemove = new List <Behaviour>(); { // foreach(var behaviour in wrapper.Behaviours) var __enumerator1 = (wrapper.Behaviours).GetEnumerator(); while (__enumerator1.MoveNext()) { var behaviour = (Behaviour)__enumerator1.Current; { bool found = false; { // foreach(var group in cutscene.TrackGroups) var __enumerator14 = (cutscene.TrackGroups).GetEnumerator(); while (__enumerator14.MoveNext()) { var group = (TrackGroup)__enumerator14.Current; { if (behaviour.Equals(group)) { found = true; break; } } } } if (!found || behaviour == null) { itemsToRemove.Add(behaviour); } } } } { var __list2 = itemsToRemove; var __listCount2 = __list2.Count; for (int __i2 = 0; __i2 < __listCount2; ++__i2) { var trackGroup = (Behaviour)__list2[__i2]; { wrapper.HasChanged = true; wrapper.RemoveTrackGroup(trackGroup); } } } { var __array3 = cutscene.TrackGroups; var __arrayLength3 = __array3.Length; for (int __i3 = 0; __i3 < __arrayLength3; ++__i3) { var tg = (TrackGroup)__array3[__i3]; { TrackGroupWrapper tgWrapper = null; if (!wrapper.ContainsTrackGroup(tg, out tgWrapper)) { tgWrapper = new TrackGroupWrapper(tg); tgWrapper.Ordinal = tg.Ordinal; wrapper.AddTrackGroup(tg, tgWrapper); wrapper.HasChanged = true; } { // foreach(var track in tg.GetTracks()) var __enumerator19 = (tg.GetTracks()).GetEnumerator(); while (__enumerator19.MoveNext()) { var track = (TimelineTrack)__enumerator19.Current; { TimelineTrackWrapper trackWrapper = null; if (!tgWrapper.ContainsTrack(track, out trackWrapper)) { trackWrapper = new TimelineTrackWrapper(track); trackWrapper.Ordinal = track.Ordinal; tgWrapper.AddTrack(track, trackWrapper); tgWrapper.HasChanged = true; } { // foreach(var item in track.GetTimelineItems()) var __enumerator28 = (track.GetTimelineItems()).GetEnumerator(); while (__enumerator28.MoveNext()) { var item = (TimelineItem)__enumerator28.Current; { TimelineItemWrapper itemWrapper = null; if (!trackWrapper.ContainsItem(item, out itemWrapper)) { if (item.GetType().IsSubclassOf(typeof(CinemaClipCurve))) { CinemaClipCurve clip = item as CinemaClipCurve; itemWrapper = new CinemaClipCurveWrapper(clip, clip.Firetime, clip.Duration); trackWrapper.AddItem(clip, itemWrapper); } else if (item.GetType().IsSubclassOf(typeof(CinemaTween))) { CinemaTween tween = item as CinemaTween; itemWrapper = new CinemaTweenWrapper(tween, tween.Firetime, tween.Duration); trackWrapper.AddItem(tween, itemWrapper); } else if (item.GetType().IsSubclassOf(typeof(TimelineActionFixed))) { TimelineActionFixed fixedAction = item as TimelineActionFixed; itemWrapper = new CinemaActionFixedWrapper(fixedAction, fixedAction.Firetime, fixedAction.Duration, fixedAction.InTime, fixedAction.OutTime, fixedAction.ItemLength); trackWrapper.AddItem(fixedAction, itemWrapper); } else if (item.GetType().IsSubclassOf(typeof(TimelineAction))) { TimelineAction action = item as TimelineAction; itemWrapper = new CinemaActionWrapper(action, action.Firetime, action.Duration); trackWrapper.AddItem(action, itemWrapper); } else { itemWrapper = new TimelineItemWrapper(item, item.Firetime); trackWrapper.AddItem(item, itemWrapper); } trackWrapper.HasChanged = true; } else { if (GUIUtility.hotControl == 0) { if (itemWrapper.GetType() == (typeof(CinemaClipCurveWrapper))) { CinemaClipCurve clip = item as CinemaClipCurve; CinemaClipCurveWrapper clipWrapper = itemWrapper as CinemaClipCurveWrapper; clipWrapper.Firetime = clip.Firetime; clipWrapper.Duration = clip.Duration; } else if (itemWrapper.GetType() == (typeof(CinemaTweenWrapper))) { } else if (itemWrapper.GetType() == (typeof(CinemaActionFixedWrapper))) { TimelineActionFixed actionFixed = item as TimelineActionFixed; CinemaActionFixedWrapper actionFixedWrapper = itemWrapper as CinemaActionFixedWrapper; actionFixedWrapper.Firetime = actionFixed.Firetime; actionFixedWrapper.Duration = actionFixed.Duration; actionFixedWrapper.InTime = actionFixed.InTime; actionFixedWrapper.OutTime = actionFixed.OutTime; actionFixedWrapper.ItemLength = actionFixed.ItemLength; } else if (itemWrapper.GetType() == (typeof(CinemaActionWrapper))) { TimelineAction action = item as TimelineAction; CinemaActionWrapper actionWrapper = itemWrapper as CinemaActionWrapper; actionWrapper.Firetime = action.Firetime; actionWrapper.Duration = action.Duration; } else { itemWrapper.Firetime = item.Firetime; } } } } } } // Remove missing track items List <Behaviour> itemRemovals = new List <Behaviour>(); { // foreach(var behaviour in trackWrapper.Behaviours) var __enumerator30 = (trackWrapper.Behaviours).GetEnumerator(); while (__enumerator30.MoveNext()) { var behaviour = (Behaviour)__enumerator30.Current; { bool found = false; { var __array34 = track.GetTimelineItems(); var __arrayLength34 = __array34.Length; for (int __i34 = 0; __i34 < __arrayLength34; ++__i34) { var item = (TimelineItem)__array34[__i34]; { if (behaviour.Equals(item)) { found = true; break; } } } } if (!found || behaviour == null) { itemRemovals.Add(behaviour); } } } } { var __list31 = itemRemovals; var __listCount31 = __list31.Count; for (int __i31 = 0; __i31 < __listCount31; ++__i31) { var item = (Behaviour)__list31[__i31]; { trackWrapper.HasChanged = true; trackWrapper.RemoveItem(item); } } } } } } // Remove missing tracks List <Behaviour> removals = new List <Behaviour>(); { // foreach(var behaviour in tgWrapper.Behaviours) var __enumerator21 = (tgWrapper.Behaviours).GetEnumerator(); while (__enumerator21.MoveNext()) { var behaviour = (Behaviour)__enumerator21.Current; { bool found = false; { // foreach(var track in tg.GetTracks()) var __enumerator32 = (tg.GetTracks()).GetEnumerator(); while (__enumerator32.MoveNext()) { var track = (TimelineTrack)__enumerator32.Current; { if (behaviour.Equals(track)) { found = true; break; } } } } if (!found || behaviour == null) { removals.Add(behaviour); } } } } { var __list22 = removals; var __listCount22 = __list22.Count; for (int __i22 = 0; __i22 < __listCount22; ++__i22) { var track = (Behaviour)__list22[__i22]; { tgWrapper.HasChanged = true; tgWrapper.RemoveTrack(track); } } } } } } } return(wrapper); }
public static void ReflectChanges(Cutscene cutscene, CutsceneWrapper wrapper) { if (cutscene == null || wrapper == null) return; cutscene.Duration = wrapper.Duration; foreach (TrackGroupWrapper tgw in wrapper.TrackGroups) { TrackGroup tg = tgw.Behaviour as TrackGroup; tg.Ordinal = tgw.Ordinal; foreach (TimelineTrackWrapper trackWrapper in tgw.Tracks) { TimelineTrack track = trackWrapper.Behaviour as TimelineTrack; track.Ordinal = trackWrapper.Ordinal; } } }
private void bindTrackGroupControls(CutsceneWrapper cutscene, List <SidebarControl> newSidebarControls, List <SidebarControl> removedSidebarControls, List <TrackItemControl> newTimelineControls, List <TrackItemControl> removedTimelineControls) { if (cutscene.HasChanged) { foreach (TrackGroupWrapper current in cutscene.TrackGroups) { TrackGroupControl trackGroupControl = null; if (!trackGroupBinding.TryGetValue(current, out trackGroupControl)) { Type[] arg_5F_0 = DirectorControlHelper.GetAllSubTypes(typeof(TrackGroupControl)); Type type = typeof(TrackGroupControl); int num = 2147483647; Type[] array = arg_5F_0; for (int i = 0; i < array.Length; i++) { Type type2 = array[i]; Type type3 = null; object[] customAttributes = type2.GetCustomAttributes(typeof(CutsceneTrackGroupAttribute), true); for (int j = 0; j < customAttributes.Length; j++) { CutsceneTrackGroupAttribute cutsceneTrackGroupAttribute = (CutsceneTrackGroupAttribute)customAttributes[j]; if (cutsceneTrackGroupAttribute != null) { type3 = cutsceneTrackGroupAttribute.TrackGroupType; } } if (type3 == current.Behaviour.GetType()) { type = type2; break; } if (current.Behaviour.GetType().IsSubclassOf(type3)) { Type type4 = current.Behaviour.GetType(); int num2 = 0; while (type4 != null && type4 != type3) { type4 = type4.BaseType; num2++; } if (num2 <= num) { num = num2; type = type2; } } } trackGroupControl = (TrackGroupControl)Activator.CreateInstance(type); trackGroupControl.TrackGroup = current; trackGroupControl.DirectorControl = this; trackGroupControl.Initialize(); trackGroupControl.SetExpandedFromEditorPrefs(); newSidebarControls.Add(trackGroupControl); trackGroupBinding.Add(current, trackGroupControl); } } List <TrackGroupWrapper> list = new List <TrackGroupWrapper>(); foreach (TrackGroupWrapper current2 in this.trackGroupBinding.Keys) { bool flag = false; foreach (TrackGroupWrapper current3 in cutscene.TrackGroups) { if (current2.Equals(current3)) { flag = true; break; } } if (!flag) { removedSidebarControls.Add(trackGroupBinding[current2]); list.Add(current2); } } foreach (TrackGroupWrapper current4 in list) { trackGroupBinding.Remove(current4); } SortedDictionary <int, TrackGroupWrapper> sortedDictionary = new SortedDictionary <int, TrackGroupWrapper>(); List <TrackGroupWrapper> list2 = new List <TrackGroupWrapper>(); foreach (TrackGroupWrapper current5 in this.trackGroupBinding.Keys) { if (current5.Ordinal >= 0 && !sortedDictionary.ContainsKey(current5.Ordinal)) { sortedDictionary.Add(current5.Ordinal, current5); } else { list2.Add(current5); } } int num3 = 0; using (SortedDictionary <int, TrackGroupWrapper> .ValueCollection.Enumerator enumerator4 = sortedDictionary.Values.GetEnumerator()) { while (enumerator4.MoveNext()) { enumerator4.Current.Ordinal = num3; num3++; } } using (List <TrackGroupWrapper> .Enumerator enumerator3 = list2.GetEnumerator()) { while (enumerator3.MoveNext()) { enumerator3.Current.Ordinal = num3; num3++; } } cutscene.HasChanged = false; } foreach (var current6 in trackGroupBinding.Keys) { trackGroupBinding[current6].BindTrackControls(current6, newSidebarControls, removedSidebarControls, newTimelineControls, removedTimelineControls); } }
public static CutsceneWrapper UpdateWrapper(Cutscene cutscene, CutsceneWrapper wrapper) { if (cutscene == null) return null; if (wrapper == null || !cutscene.Equals(wrapper.Behaviour)) { return CreateWrapper(cutscene); } else { wrapper.Behaviour = cutscene; wrapper.Duration = cutscene.Duration; wrapper.IsPlaying = cutscene.State == Cutscene.CutsceneState.PreviewPlaying || cutscene.State == Cutscene.CutsceneState.Playing; wrapper.RunningTime = cutscene.RunningTime; List<Behaviour> itemsToRemove = new List<Behaviour>(); foreach (Behaviour behaviour in wrapper.Behaviours) { bool found = false; foreach (TrackGroup group in cutscene.TrackGroups) { if (behaviour.Equals(group)) { found = true; break; } } if (!found || behaviour == null) { itemsToRemove.Add(behaviour); } } foreach (Behaviour trackGroup in itemsToRemove) { wrapper.HasChanged = true; wrapper.RemoveTrackGroup(trackGroup); } foreach (TrackGroup tg in cutscene.TrackGroups) { TrackGroupWrapper tgWrapper = null; if (!wrapper.ContainsTrackGroup(tg, out tgWrapper)) { tgWrapper = new TrackGroupWrapper(tg); tgWrapper.Ordinal = tg.Ordinal; wrapper.AddTrackGroup(tg, tgWrapper); wrapper.HasChanged = true; } foreach (TimelineTrack track in tg.GetTracks()) { TimelineTrackWrapper trackWrapper = null; if (!tgWrapper.ContainsTrack(track, out trackWrapper)) { trackWrapper = new TimelineTrackWrapper(track); trackWrapper.Ordinal = track.Ordinal; tgWrapper.AddTrack(track, trackWrapper); tgWrapper.HasChanged = true; } foreach (TimelineItem item in track.GetTimelineItems()) { TimelineItemWrapper itemWrapper = null; if (!trackWrapper.ContainsItem(item, out itemWrapper)) { if (item.GetType().IsSubclassOf(typeof(CinemaClipCurve))) { CinemaClipCurve clip = item as CinemaClipCurve; itemWrapper = new CinemaClipCurveWrapper(clip, clip.Firetime, clip.Duration); trackWrapper.AddItem(clip, itemWrapper); } else if (item.GetType().IsSubclassOf(typeof(CinemaTween))) { CinemaTween tween = item as CinemaTween; itemWrapper = new CinemaTweenWrapper(tween, tween.Firetime, tween.Duration); trackWrapper.AddItem(tween, itemWrapper); } else if (item.GetType().IsSubclassOf(typeof(TimelineActionFixed))) { TimelineActionFixed fixedAction = item as TimelineActionFixed; itemWrapper = new CinemaActionFixedWrapper(fixedAction, fixedAction.Firetime, fixedAction.Duration, fixedAction.InTime, fixedAction.OutTime, fixedAction.ItemLength); trackWrapper.AddItem(fixedAction, itemWrapper); } else if (item.GetType().IsSubclassOf(typeof(TimelineAction))) { TimelineAction action = item as TimelineAction; itemWrapper = new CinemaActionWrapper(action, action.Firetime, action.Duration); trackWrapper.AddItem(action, itemWrapper); } else { itemWrapper = new TimelineItemWrapper(item, item.Firetime); trackWrapper.AddItem(item, itemWrapper); } trackWrapper.HasChanged = true; } else { if (GUIUtility.hotControl == 0) { if (itemWrapper.GetType() == (typeof(CinemaClipCurveWrapper))) { CinemaClipCurve clip = item as CinemaClipCurve; CinemaClipCurveWrapper clipWrapper = itemWrapper as CinemaClipCurveWrapper; clipWrapper.Firetime = clip.Firetime; clipWrapper.Duration = clip.Duration; } else if (itemWrapper.GetType() == (typeof(CinemaTweenWrapper))) { } else if (itemWrapper.GetType() == (typeof(CinemaActionFixedWrapper))) { TimelineActionFixed actionFixed = item as TimelineActionFixed; CinemaActionFixedWrapper actionFixedWrapper = itemWrapper as CinemaActionFixedWrapper; actionFixedWrapper.Firetime = actionFixed.Firetime; actionFixedWrapper.Duration = actionFixed.Duration; actionFixedWrapper.InTime = actionFixed.InTime; actionFixedWrapper.OutTime = actionFixed.OutTime; actionFixedWrapper.ItemLength = actionFixed.ItemLength; } else if (itemWrapper.GetType() == (typeof(CinemaActionWrapper))) { TimelineAction action = item as TimelineAction; CinemaActionWrapper actionWrapper = itemWrapper as CinemaActionWrapper; actionWrapper.Firetime = action.Firetime; actionWrapper.Duration = action.Duration; } else { itemWrapper.Firetime = item.Firetime; } } } } // Remove missing track items List<Behaviour> itemRemovals = new List<Behaviour>(); foreach (Behaviour behaviour in trackWrapper.Behaviours) { bool found = false; foreach (TimelineItem item in track.GetTimelineItems()) { if (behaviour.Equals(item)) { found = true; break; } } if (!found || behaviour == null) { itemRemovals.Add(behaviour); } } foreach (Behaviour item in itemRemovals) { trackWrapper.HasChanged = true; trackWrapper.RemoveItem(item); } } // Remove missing tracks List<Behaviour> removals = new List<Behaviour>(); foreach (Behaviour behaviour in tgWrapper.Behaviours) { bool found = false; foreach (TimelineTrack track in tg.GetTracks()) { if (behaviour.Equals(track)) { found = true; break; } } if (!found || behaviour == null) { removals.Add(behaviour); } } foreach (Behaviour track in removals) { tgWrapper.HasChanged = true; tgWrapper.RemoveTrack(track); } } } return wrapper; }
private void bindTrackGroupControls(CutsceneWrapper cutscene, List <SidebarControl> newSidebarControls, List <SidebarControl> removedSidebarControls, List <TrackItemControl> newTimelineControls, List <TrackItemControl> removedTimelineControls) { if (cutscene.HasChanged) { foreach (TrackGroupWrapper wrapper in cutscene.TrackGroups) { TrackGroupControl control = null; if (!this.trackGroupBinding.TryGetValue(wrapper, out control)) { Type type = typeof(TrackGroupControl); int num2 = 0x7fffffff; foreach (Type type2 in DirectorControlHelper.GetAllSubTypes(typeof(TrackGroupControl))) { Type c = null; foreach (CutsceneTrackGroupAttribute attribute in type2.GetCustomAttributes(typeof(CutsceneTrackGroupAttribute), true)) { if (attribute != null) { c = attribute.TrackGroupType; } } if (c == wrapper.Behaviour.GetType()) { type = type2; num2 = 0; break; } if (wrapper.Behaviour.GetType().IsSubclassOf(c)) { Type baseType = wrapper.Behaviour.GetType(); int num5 = 0; while ((baseType != null) && (baseType != c)) { baseType = baseType.BaseType; num5++; } if (num5 <= num2) { num2 = num5; type = type2; } } } control = (TrackGroupControl)Activator.CreateInstance(type); control.TrackGroup = wrapper; control.DirectorControl = this; control.Initialize(); control.SetExpandedFromEditorPrefs(); newSidebarControls.Add(control); this.trackGroupBinding.Add(wrapper, control); } } List <TrackGroupWrapper> list = new List <TrackGroupWrapper>(); foreach (TrackGroupWrapper wrapper2 in this.trackGroupBinding.Keys) { bool flag = false; foreach (TrackGroupWrapper wrapper3 in cutscene.TrackGroups) { if (wrapper2.Equals(wrapper3)) { flag = true; break; } } if (!flag) { removedSidebarControls.Add(this.trackGroupBinding[wrapper2]); list.Add(wrapper2); } } foreach (TrackGroupWrapper wrapper4 in list) { this.trackGroupBinding.Remove(wrapper4); } SortedDictionary <int, TrackGroupWrapper> dictionary = new SortedDictionary <int, TrackGroupWrapper>(); List <TrackGroupWrapper> list2 = new List <TrackGroupWrapper>(); foreach (TrackGroupWrapper wrapper5 in this.trackGroupBinding.Keys) { if ((wrapper5.Ordinal >= 0) && !dictionary.ContainsKey(wrapper5.Ordinal)) { dictionary.Add(wrapper5.Ordinal, wrapper5); } else { list2.Add(wrapper5); } } int num = 0; using (SortedDictionary <int, TrackGroupWrapper> .ValueCollection.Enumerator enumerator4 = dictionary.Values.GetEnumerator()) { while (enumerator4.MoveNext()) { enumerator4.Current.Ordinal = num; num++; } } using (List <TrackGroupWrapper> .Enumerator enumerator3 = list2.GetEnumerator()) { while (enumerator3.MoveNext()) { enumerator3.Current.Ordinal = num; num++; } } cutscene.HasChanged = false; } foreach (TrackGroupWrapper wrapper6 in this.trackGroupBinding.Keys) { this.trackGroupBinding[wrapper6].BindTrackControls(wrapper6, newSidebarControls, removedSidebarControls, newTimelineControls, removedTimelineControls); } }
public static CutsceneWrapper CreateWrapper(Cutscene cutscene) { CutsceneWrapper wrapper = new CutsceneWrapper(cutscene); if (cutscene != null) { wrapper.RunningTime = cutscene.RunningTime; wrapper.Duration = cutscene.Duration; wrapper.IsPlaying = cutscene.State == Cutscene.CutsceneState.PreviewPlaying || cutscene.State == Cutscene.CutsceneState.Playing; foreach (TrackGroup tg in cutscene.TrackGroups) { TrackGroupWrapper tgWrapper = new TrackGroupWrapper(tg); tgWrapper.Ordinal = tg.Ordinal; wrapper.AddTrackGroup(tg, tgWrapper); foreach (TimelineTrack track in tg.GetTracks()) { TimelineTrackWrapper trackWrapper = new TimelineTrackWrapper(track); trackWrapper.Ordinal = track.Ordinal; tgWrapper.AddTrack(track, trackWrapper); foreach (TimelineItem item in track.GetTimelineItems()) { if (item.GetType().IsSubclassOf(typeof(CinemaClipCurve))) { CinemaClipCurve clip = item as CinemaClipCurve; CinemaClipCurveWrapper clipWrapper = new CinemaClipCurveWrapper(clip, clip.Firetime, clip.Duration); trackWrapper.AddItem(clip, clipWrapper); } else if (item.GetType().IsSubclassOf(typeof(CinemaTween))) { } else if (item.GetType().IsSubclassOf(typeof(TimelineActionFixed))) { TimelineActionFixed actionFixed = item as TimelineActionFixed; CinemaActionFixedWrapper actionFixedWrapper = new CinemaActionFixedWrapper(actionFixed, actionFixed.Firetime, actionFixed.Duration, actionFixed.InTime, actionFixed.OutTime, actionFixed.ItemLength); trackWrapper.AddItem(actionFixed, actionFixedWrapper); } else if (item.GetType().IsSubclassOf(typeof(TimelineAction))) { TimelineAction action = item as TimelineAction; CinemaActionWrapper itemWrapper = new CinemaActionWrapper(action, action.Firetime, action.Duration); trackWrapper.AddItem(action, itemWrapper); } else { TimelineItemWrapper itemWrapper = new TimelineItemWrapper(item, item.Firetime); trackWrapper.AddItem(item, itemWrapper); } } } } } return wrapper; }