예제 #1
0
        private void AddLayer(int bodyID, int hue, bool asMount = false)
        {
            int   facing    = MirrorFacingForDraw(Facing);
            int   animation = 0;
            float frame     = 0;

            if (Entity is Mobile)
            {
                animation = (Entity as Mobile).Animation.ActionIndex;
                if (asMount)
                {
                    animation = patchMountAction(animation);
                }
                frame = (Entity as Mobile).Animation.AnimationFrame;
            }
            else if (Entity is Corpse)
            {
                animation = ActionTranslator.GetActionIndex(Entity, MobileAction.Death);
                frame     = (Entity as Corpse).Frame * BodyConverter.DeathAnimationFrameCount(Body);
            }

            int             frameCount;
            IAnimationFrame animframe = getFrame(bodyID, ref hue, facing, animation, frame, out frameCount);

            m_MobileLayers[m_LayerCount++] = new MobileViewLayer(bodyID, hue, animframe);
            m_FrameCount = frameCount;
        }
예제 #2
0
 private void onLoad(object sender, EventArgs e)
 {
     Options.LoadedUltimaClass["AnimationEdit"] = true;
     treeView1.BeginUpdate();
     treeView1.Nodes.Clear();
     if (FileType != 0)
     {
         int             count = Animations.GetAnimCount(FileType);
         List <TreeNode> nodes = new List <TreeNode>();
         for (int i = 0; i < count; ++i)
         {
             int      animlength = Animations.GetAnimLength(i, FileType);
             string   type       = animlength == 22 ? "H" : animlength == 13 ? "L" : "P";
             TreeNode node       = new TreeNode();
             node.Tag  = i;
             node.Text = String.Format("{0}: {1} ({2})", type, i, BodyConverter.GetTrueBody(FileType, i));
             bool valid = false;
             for (int j = 0; j < animlength; ++j)
             {
                 TreeNode subnode = new TreeNode();
                 subnode.Tag  = j;
                 subnode.Text = j.ToString();
                 if (Ultima.AnimationEdit.IsActionDefinied(FileType, i, j))
                 {
                     valid = true;
                 }
                 else
                 {
                     subnode.ForeColor = Color.Red;
                 }
                 node.Nodes.Add(subnode);
             }
             if (!valid)
             {
                 if (ShowOnlyValid)
                 {
                     continue;
                 }
                 node.ForeColor = Color.Red;
             }
             nodes.Add(node);
         }
         treeView1.Nodes.AddRange(nodes.ToArray());
     }
     treeView1.EndUpdate();
     if (treeView1.Nodes.Count > 0)
     {
         treeView1.SelectedNode = treeView1.Nodes[0];
     }
     if (!Loaded)
     {
         FiddlerControls.Events.FilePathChangeEvent += new FiddlerControls.Events.FilePathChangeHandler(OnFilePathChangeEvent);
     }
     Loaded = true;
 }
예제 #3
0
        private void InternalSetupLayers()
        {
            ClearLayers();

            if (Body.IsHumanoid)
            {
                int[] drawLayers    = DrawLayerOrder;
                bool  hasOuterTorso = Equipment[(int)EquipLayer.OuterTorso] != null && Equipment[(int)EquipLayer.OuterTorso].ItemData.AnimID != 0;

                for (int i = 0; i < drawLayers.Length; i++)
                {
                    // when wearing something on the outer torso the other torso equipment is not drawn in the world.
                    if (hasOuterTorso && (drawLayers[i] == (int)EquipLayer.InnerTorso || drawLayers[i] == (int)EquipLayer.MiddleTorso))
                    {
                        continue;
                    }

                    if (drawLayers[i] == (int)EquipLayer.Body)
                    {
                        AddLayer(Body, Entity.Hue);
                    }

                    else if (Equipment[drawLayers[i]] != null)
                    {
                        // special handling for mounts.
                        if (drawLayers[i] == (int)EquipLayer.Mount)
                        {
                            int body = Equipment[drawLayers[i]].ItemID;
                            if (BodyConverter.CheckIfItemIsMount(ref body))
                            {
                                AddLayer(body, Equipment[drawLayers[i]].Hue, true);
                            }
                        }
                        else
                        {
                            if (Equipment[drawLayers[i]].ItemData.AnimID != 0)
                            {
                                // skip hair/facial hair for ghosts
                                if (((Entity is Mobile) && !(Entity as Mobile).IsAlive) &&
                                    (drawLayers[i] == (int)EquipLayer.Hair || drawLayers[i] == (int)EquipLayer.FacialHair))
                                {
                                    continue;
                                }
                                AddLayer(Equipment[drawLayers[i]].ItemData.AnimID, Equipment[drawLayers[i]].Hue);
                            }
                        }
                    }
                }
            }
            else
            {
                AddLayer(Body, Entity.Hue);
            }
        }
예제 #4
0
        public override bool Draw(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOverList, Map map)
        {
            int facing     = MirrorFacingForDraw(Entity.Facing);
            int frameIndex = (int)(Entity.Frame * BodyConverter.DeathAnimationFrameCount(Entity.Body));

            IAnimationFrame animationFrame = getFrame(Entity.Body, facing, frameIndex, Entity.Hue);

            DrawTexture = animationFrame.Texture;
            DrawArea    = new Rectangle(0, 0, DrawTexture.Width, DrawTexture.Height);
            DrawFlip    = false;

            return(base.Draw(spriteBatch, drawPosition, mouseOverList, map));
        }
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            foreach (FileIndexBase fileIndex in _fileIndices)
            {
                fileIndex.Close();
            }

            _fileIndices   = null;
            _bodyConverter = null;
            _table         = null;
            _bodyTable     = null;
            _hues          = null;
        }
예제 #6
0
        private IAnimationFrame getFrame(Body body, int facing, int frameIndex, int hue)
        {
            // get the resource provider
            IResourceProvider provider = ServiceRegistry.GetService <IResourceProvider>();

            IAnimationFrame[] frames = provider.GetAnimation(body, BodyConverter.DeathAnimationIndex(body), facing, hue);
            if (frames == null)
            {
                return(null);
            }
            if (frames[frameIndex].Texture == null)
            {
                return(null);
            }
            return(frames[frameIndex]);
        }
        public override void Initialize()
        {
            base.Initialize();

            InstallLocation install = Install;

            _fileIndices = new[]
            {
                install.CreateFileIndex("anim.idx", "anim.mul"), install.CreateFileIndex("anim2.idx", "anim2.mul"),
                install.CreateFileIndex("anim3.idx", "anim3.mul"), install.CreateFileIndex("anim4.idx", "anim4.mul"),
                install.CreateFileIndex("anim5.idx", "anim5.mul")
            };

            _bodyTable     = new BodyTable(install.GetPath("body.def"));
            _bodyConverter = new BodyConverter(install.GetPath("bodyconv.def"));
            _hues          = new Hues(install);
        }
예제 #8
0
        public override bool Draw(SpriteBatch3D spriteBatch, Vector3 drawPosition, MouseOverList mouseOverList, Map map)
        {
            int facing     = MirrorFacingForDraw(Entity.Facing);
            int frameIndex = (int)(Entity.Frame * BodyConverter.DeathAnimationFrameCount(Entity.Body));

            IAnimationFrame animationFrame = getFrame(Entity.Body, facing, frameIndex, Entity.Hue);

            DrawFlip = (MirrorFacingForDraw(Entity.Facing) > 4) ? true : false;

            DrawTexture = animationFrame.Texture;

            DrawArea = new Rectangle(
                animationFrame.Center.X - IsometricRenderer.TILE_SIZE_INTEGER_HALF,
                DrawTexture.Height - IsometricRenderer.TILE_SIZE_INTEGER_HALF + (Entity.Z * 4) + animationFrame.Center.Y, DrawTexture.Width, DrawTexture.Height);
            // DrawArea = new Rectangle(0, 0, DrawTexture.Width, DrawTexture.Height);

            return(base.Draw(spriteBatch, drawPosition, mouseOverList, map));
        }
예제 #9
0
        private void OnClickExportToVD(object sender, EventArgs e)
        {
            if (FileType != 0)
            {
                string path       = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
                int    animlength = Animations.GetAnimLength(CurrBody, FileType);
                string type       = animlength == 22 ? "H " : animlength == 13 ? "L " : "P ";
                string FileName   = Path.Combine(path, String.Format("{0}{1:D4} (anim{2}_{3}).vd", type, BodyConverter.GetTrueBody(FileType, CurrBody), FileType, CurrBody));

                Ultima.AnimationEdit.ExportToVD(FileType, CurrBody, FileName);
                MessageBox.Show(
                    String.Format("Анимация сохранена в {0}", AppDomain.CurrentDomain.SetupInformation.ApplicationBase),
                    "Экспорт",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information,
                    MessageBoxDefaultButton.Button1);
            }
        }
예제 #10
0
 private void OnClickExportAllToVD(object sender, EventArgs e)
 {
     if (FileType != 0)
     {
         using (FolderBrowserDialog dialog = new FolderBrowserDialog())
         {
             dialog.Description         = "Выбирите директорию";
             dialog.ShowNewFolderButton = true;
             if (dialog.ShowDialog() == DialogResult.OK)
             {
                 for (int i = 0; i < treeView1.Nodes.Count; ++i)
                 {
                     int index = (int)treeView1.Nodes[i].Tag;
                     if (index >= 0 && treeView1.Nodes[i].Parent == null && treeView1.Nodes[i].ForeColor != Color.Red)
                     {
                         int    animlength = Animations.GetAnimLength(index, FileType);
                         string type       = animlength == 22 ? "H " : animlength == 13 ? "L " : "P ";
                         string FileName   = Path.Combine(dialog.SelectedPath, String.Format("{0}{1:D4} (anim{2}_{3}).vd", type, BodyConverter.GetTrueBody(FileType, index), FileType, index));
                         Ultima.AnimationEdit.ExportToVD(FileType, index, FileName);
                     }
                 }
                 MessageBox.Show(String.Format("Вся анимация сохранена в {0}", dialog.SelectedPath.ToString()),
                                 "Экспорт", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
             }
         }
     }
 }