示例#1
0
 public Clip(BitmapImage thumb, ClipEvent clipEvent, ClipType clipType, IReadOnlyCollection <Video> videos)
 {
     Thumb  = thumb;
     _event = clipEvent;
     Type   = clipType;
     Videos = videos;
 }
        public async Task HandleAsync(ClipEvent message, CancellationToken cancellationToken)
        {
            switch (message.EventType)
            {
            case ClipEvent.ClipEventType.Created:
                if (!IsAllowedAddClipsFromKeyboard(message))
                {
                    return;
                }

                ClipViewModel createdClip = vmFactory.CreateClip(message.Source);
                Items.Insert(0, createdClip);
                await ActivateItemAsync(createdClip, cancellationToken);

                OnKeyboardClipAdded(createdClip);
                break;

            case ClipEvent.ClipEventType.Remove:
                ClipViewModel clipToRemove = Items.FirstOrDefault(vm => vm.Model.Id == message.Source.Id);
                if (clipToRemove != null)
                {
                    await Task.Run(() => dataRepository.DeleteClip(clipToRemove.Model.Id), cancellationToken);

                    await clipToRemove.TryCloseAsync();

                    vmFactory.Release(clipToRemove);
                }
                break;
            }
        }
示例#3
0
文件: lwf_movie.cs 项目: nask0/lwf
 public void PlayAnimation(ClipEvent clipEvent)
 {
     Format.MovieClipEvent[] clipEvents = m_lwf.data.movieClipEvents;
     for (int i = 0; i < m_data.clipEvents; ++i)
     {
         Format.MovieClipEvent c = clipEvents[m_data.clipEventId + i];
         if ((c.clipEvent & (int)clipEvent) != 0)
         {
             m_lwf.PlayAnimation(c.animationId, this);
         }
     }
 }
示例#4
0
    //保存是更新值
    protected override void OnSave()
    {
        if (Target == null)
        {
            return;
        }
        var animatorListClips = Target.animator.listClips;

        animatorListClips.Clear();

        foreach (var clip in this.ListClip)
        {
            AnimatorClip aclip = new AnimatorClip();
            aclip.name       = clip.name;
            aclip.clipName   = clip.GetParam("clipName");
            aclip.param      = clip.GetParam("param");
            aclip.length     = clip.GetParamFloat("length");
            aclip.speed      = clip.GetParamFloat("speed");
            aclip.fadeFactor = clip.GetParamFloat("fadeFactor");

            aclip.UF_SetWrapMode(clip.GetParam("wrapMode", WrapMode.Once.ToString()));
            aclip.UF_SetCrossMode(clip.GetParam("crossMode", AnimatorClip.CrossMode.Direct.ToString()));

            foreach (var clipevent in clip.ListClipEvent)
            {
                ClipEvent ace = new ClipEvent();
                ace.name    = string.IsNullOrEmpty(clipevent.name) ? AvatarClipEventType.Null.ToString() : clipevent.name;
                ace.param   = clipevent.GetParam("param");
                ace.trigger = clipevent.triggerTime;
                aclip.clipEvents.Add(ace);
            }
            // 必须按照trigger 时间进行列表排序
            aclip.clipEvents.Sort((a, b) => { return(a.trigger < b.trigger ? -1:1); });

            animatorListClips.Add(aclip);
        }

        // 保存Avatar
        EditorTools.SetDirty(Target);
        EditorTools.RegisterUndo("AvatarController Action Change", Target);
    }
示例#5
0
    //保存是更新值
    protected override void OnSave()
    {
        if (Target == null)
        {
            return;
        }
        Target.listClips.Clear();
        foreach (var clip in this.ListClip)
        {
            PerformActionClip aclip = new PerformActionClip();
            aclip.name       = clip.name;
            aclip.detialName = clip.GetParam("detialName");
            aclip.param      = clip.GetParam("param");
            aclip.length     = clip.GetParamFloat("length");
            aclip.loop       = clip.GetParamBool("loop");

            foreach (var clipevent in clip.ListClipEvent)
            {
                ClipEvent ace = new ClipEvent();
                ace.name    = string.IsNullOrEmpty(clipevent.name) ? PerformActionClipEventType.Null.ToString() : clipevent.name;
                ace.param   = clipevent.GetParam("param");
                ace.rate    = clipevent.GetParamInt("rate");
                ace.trigger = clipevent.triggerTime;
                aclip.clipEvents.Add(ace);
            }
            // 必须按照trigger 时间进行列表排序
            aclip.clipEvents.Sort((a, b) => { return(a.trigger < b.trigger ? -1 : 1); });
            Target.listClips.Add(aclip);
        }

        // 保存Avatar

        EditorTools.SetDirty(Target);
        EditorTools.RegisterUndo("Perform Package Change", Target);
        AssetDatabase.SaveAssets();
    }
        private void Import(Stream Source)
        {

            // Format from http://simswiki.info/wiki.php?title=Sims_3:0x6B20C4F3
            // Read Main Header


            //Stream F = File.Create(@"C:\temp\clips\test.clip");
            //Source.CopyTo(F);
            //F.Close();

            //Source.Position = 0;


            BinaryReader Reader = new BinaryReader(Source);

            UInt32 TID = Reader.ReadUInt32();
            if (TID != 0x6b20c4f3)
                throw new InvalidDataException();

            UInt32 Offset = Reader.ReadUInt32();
            UInt32 ClipSize = Reader.ReadUInt32();
            UInt32 ClipOffset = (UInt32)Reader.BaseStream.Position + Reader.ReadUInt32();
            UInt32 SlotOffset = (UInt32)Reader.BaseStream.Position + Reader.ReadUInt32();
            UInt32 ActorOffset = (UInt32)Reader.BaseStream.Position + Reader.ReadUInt32();
            UInt32 EventOffset = (UInt32)Reader.BaseStream.Position + Reader.ReadUInt32();

            Unknown1 = Reader.ReadUInt32();
            Unknown2 = Reader.ReadUInt32();

            UInt32 EndOffset = Reader.ReadUInt32();
            byte[] Buffer = Reader.ReadBytes(16);

            // get the end buffer values
            Reader.BaseStream.Position = EndOffset;
            EndData = new Single[4];
            EndData[0] = Reader.ReadSingle();
            EndData[1] = Reader.ReadSingle();
            EndData[2] = Reader.ReadSingle();
            EndData[3] = Reader.ReadSingle();

            // Get Clip
            Stream ClipStream = new SubStream(Source, ClipOffset, ClipSize);
            ImportClip(ClipStream);

            // Get Slot Table
            Stream SlotStream = new SubStream(Source, SlotOffset, ActorOffset - SlotOffset);
            ImportSlotTable(SlotStream);


            // Get Actor Name            
            Reader.BaseStream.Position = ActorOffset;
            

            int actorlen = (int)(EventOffset - ActorOffset);
            ActorName = ReadNullASCIIString(Reader, actorlen);

            // Get Event Table       
            Reader.BaseStream.Position = EventOffset;
            string ceSIG = Encoding.ASCII.GetString(Reader.ReadBytes(4));
            if (ceSIG != "=CE=")
                throw new InvalidDataException();

            UInt32 ceVersion = Reader.ReadUInt32();
            if (ceVersion != 0x0103)
                throw new InvalidDataException();

            UInt32 ceCount = Reader.ReadUInt32();
            UInt32 ceSize = Reader.ReadUInt32();
            UInt32 ceOffset = Reader.ReadUInt32();


            ClipTable = new ClipEvent[ceCount];

            for (int ceI = 0; ceI < ceCount; ceI++)
            {
                UInt16 ceType = Reader.ReadUInt16();

                ClipEvent Event;

                switch (ceType)
                {
                    case 1: Event = new ClipEventAttach(); break;
                    case 2: Event = new ClipEventUnParent(); break;
                    case 3: Event = new ClipEventPlaySound(); break;
                    case 4: Event = new ClipEventSACS(); break;
                    case 5: Event = new ClipEventPlayEffect(); break;
                    case 6: Event = new ClipEventVisibility(); break;
                    case 9: Event = new ClipEventDestroyProp(); break;
                    case 10: Event = new ClipEventStopEffect(); break;
                    default: throw new InvalidDataException();
                }

                ClipTable[ceI] = Event;

                Event.Import(Reader);               
                //Console.WriteLine(Event.ToString());                
            }


            Source.Close();
        }
 protected abstract bool IsAllowedAddClipsFromKeyboard(ClipEvent message);
示例#8
0
	public void PlayAnimation(ClipEvent clipEvent)
	{
		Format.MovieClipEvent[] clipEvents = m_lwf.data.movieClipEvents;
		for (int i = 0; i < m_data.clipEvents; ++i) {
			Format.MovieClipEvent c = clipEvents[m_data.clipEventId + i];
			if ((c.clipEvent & (int)clipEvent) != 0)
				m_lwf.PlayAnimation(c.animationId, this);
		}
	}
示例#9
0
        public static void WriteInAllocatedMemoryImpl(BinaryWriter writer, MemoryPool memory, ClipEvent clipEvent)
        {
            writer.WriteUInt24((UInt32)clipEvent.Flags);
            writer.Write((Byte)clipEvent.KeyCode);
            writer.Write((UInt32)0); // offsetToNext?

            var clipActionsAddress = DataWriter.Write(memory, clipEvent.Instructions);

            writer.Write((UInt32)clipActionsAddress);
        }
示例#10
0
 public static uint GetElementSizeImpl(ClipEvent clipEvent) => Constants.IntPtrSize * 3;
 protected override bool IsAllowedAddClipsFromKeyboard(ClipEvent message)
 {
     return(false);
 }