private void LoadItem()
        {
            SlotItem item = _listView.SelectedItem as SlotItem;

            if (item == null)
            {
                return;
            }

            M2SceneNode node = ModelSceneService.Instance.MainM2SceneNode;

            if (node != null && node.Type == M2Type.MT_CHARACTER && !node.IsNpc)
            {
                M2Appearance appearance = node.M2Appearance;
                if (appearance == null)
                {
                    return;
                }
                appearance.TakeItem(item.ItemId);

                ModelEditorService.Instance.ShowModelPart(node);
                ModelEditorService.Instance.ShowEditPart(node);
                ModelEditorService.Instance.SetWireFrame(node);
                ModelEditorService.Instance.SheathM2NodeWeapon(node);

                int slot = node.M2Instance.GetItemSlot(item.ItemId);

                if (node.M2Instance.SlotHasModel((E_CHAR_SLOTS)slot))
                {
                    if (slot == (int)E_CHAR_SLOTS.CS_HEAD)
                    {
                        node.BuildVisibleGeosets();
                    }
                    else if (slot == (int)E_CHAR_SLOTS.CS_BELT)
                    {
                        node.UpdateCharacter();
                    }
                }
                else
                {
                    node.UpdateCharacter();
                }

                //update property
                ShellService.Instance.PropertyContent.UpdateCharacterNode(node);

                if (ShellService.Instance.EquipmentsWindow.IsVisible)
                {
                    ShellService.Instance.EquipmentsWindow.Update();
                }
            }
        }
Beispiel #2
0
        private void ResetClothesAllExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            M2SceneNode node = ModelSceneService.Instance.MainM2SceneNode;

            node.ResetSlot(E_CHAR_SLOTS.CS_HEAD);
            node.ResetSlot(E_CHAR_SLOTS.CS_SHOULDER);
            node.ResetSlot(E_CHAR_SLOTS.CS_SHIRT);
            node.ResetSlot(E_CHAR_SLOTS.CS_CHEST);
            node.ResetSlot(E_CHAR_SLOTS.CS_BELT);
            node.ResetSlot(E_CHAR_SLOTS.CS_PANTS);
            node.ResetSlot(E_CHAR_SLOTS.CS_BOOTS);
            node.ResetSlot(E_CHAR_SLOTS.CS_BRACERS);
            node.ResetSlot(E_CHAR_SLOTS.CS_GLOVES);
            node.ResetSlot(E_CHAR_SLOTS.CS_CAPE);
            node.ResetSlot(E_CHAR_SLOTS.CS_TABARD);

            node.UpdateCharacter();

            //update property
            ShellService.Instance.PropertyContent.UpdateCharacterNode(node);

            if (ShellService.Instance.EquipmentsWindow.IsVisible)
            {
                ShellService.Instance.EquipmentsWindow.Update();
            }

            if (ShellService.Instance.EquipmentSelectWindow.IsVisible)
            {
                ShellService.Instance.EquipmentSelectWindow.Update();
            }
        }
Beispiel #3
0
        void _setSelect_Set_Selected(object sender, Set set)
        {
            M2SceneNode node = ModelSceneService.Instance.MainM2SceneNode;

            if (node != null && node.Type == M2Type.MT_CHARACTER && !node.IsNpc)
            {
                M2Appearance appearance = node.M2Appearance;
                if (appearance == null)
                {
                    return;
                }

                appearance.LoadSet(set.Id);

                ModelEditorService.Instance.ShowModelPart(node);
                ModelEditorService.Instance.ShowEditPart(node);
                ModelEditorService.Instance.SetWireFrame(node);
                ModelEditorService.Instance.SheathM2NodeWeapon(node);

                node.UpdateCharacter();

                //update property
                ShellService.Instance.PropertyContent.UpdateCharacterNode(node);

                if (ShellService.Instance.EquipmentsWindow.IsVisible)
                {
                    ShellService.Instance.EquipmentsWindow.Update();
                }

                if (ShellService.Instance.EquipmentSelectWindow.IsVisible)
                {
                    ShellService.Instance.EquipmentSelectWindow.Update();
                }
            }
        }
Beispiel #4
0
        private void ItemContent_ItemSelected(object sender, Item item)
        {
            int         slot = 0;
            M2SceneNode node = ModelSceneService.Instance.MainM2SceneNode;

            if (node != null && node.Type == M2Type.MT_CHARACTER && !node.IsNpc)
            {
                node.TakeItem(item.Id, out slot);

                ModelEditorService.Instance.ShowModelPart(node);
                ModelEditorService.Instance.ShowEditPart(node);
                ModelEditorService.Instance.SetWireFrame(node);

                if (node.SlotHasModel((E_CHAR_SLOTS)slot))
                {
                    if (slot == (int)E_CHAR_SLOTS.CS_HEAD)
                    {
                        node.BuildVisibleGeosets();
                    }
                }
                else
                {
                    node.UpdateCharacter();
                }

                //update property
                ShellService.Instance.PropertyContent.UpdateCharacterNode(node);
                ShellService.Instance.EquipmentsWindow.Update();
            }
        }
Beispiel #5
0
        void _listView_PreviewDrop(object sender, DragEventArgs args)
        {
            args.Handled = true;

            string fileName = IsSingleFile(args);

            if (fileName == null)
            {
                return;
            }

            M2SceneNode node = ModelSceneService.Instance.MainM2SceneNode;

            if (node == null)
            {
                return;
            }

            StreamReader reader = new StreamReader(fileName);

            while (!reader.EndOfStream)
            {
                string txt = reader.ReadLine();
                int    id;
                if (Int32.TryParse(txt, out id))
                {
                    int slot;
                    node.TakeItem(id, out slot);
                }
            }

            reader.Dispose();
            node.UpdateCharacter();
            SlotItems.GetAllSlotItems(node);
        }
        private void ResetClothesSlotExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            E_CHAR_SLOTS?slot = e.Parameter as E_CHAR_SLOTS?;
            M2SceneNode  node = ModelSceneService.Instance.MainM2SceneNode;

            if (slot != null)
            {
                node.ResetSlot(slot.Value);
                if (node.SlotHasModel(slot.Value))
                {
                    if (slot.Value == E_CHAR_SLOTS.CS_HEAD)
                    {
                        node.BuildVisibleGeosets();
                    }
                }
                else
                {
                    node.UpdateCharacter();
                }
            }

            //update property
            ShellService.Instance.PropertyContent.UpdateCharacterNode(node);
            ShellService.Instance.EquipmentsWindow.Update();
        }
Beispiel #7
0
        public void UseStartOutfit(string shortname)
        {
            M2SceneNode node = ModelSceneService.Instance.MainM2SceneNode;

            if (node != null && node.Type == M2Type.MT_CHARACTER && !node.IsNpc)
            {
                M2Appearance appearance = node.M2Appearance;
                if (appearance == null)
                {
                    return;
                }

                int startOutfitId = GetStartOutfitId(shortname);
                appearance.LoadStartOutfitId(startOutfitId, shortname == "DEATHKNIGHT");

                ModelEditorService.Instance.ShowModelPart(node);
                ModelEditorService.Instance.ShowEditPart(node);
                ModelEditorService.Instance.SetWireFrame(node);
                ModelEditorService.Instance.SheathM2NodeWeapon(node);

                node.UpdateCharacter();

                if (StartOutfitUpdated != null)
                {
                    StartOutfitUpdated.Invoke(this, node);
                }
            }
        }
Beispiel #8
0
        private void btImport_Click(object sender, RoutedEventArgs e)
        {
            M2SceneNode node = ModelSceneService.Instance.MainM2SceneNode;

            if (node == null || node.Type != M2Type.MT_CHARACTER || node.IsNpc)
            {
                return;
            }

            M2Appearance appearance = node.M2Appearance;

            if (appearance == null)
            {
                return;
            }

            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter           = "text|*.txt|All Files|*.*";
            dlg.InitialDirectory = Engine.Instance.GetBaseDirectory();
            bool?ret = dlg.ShowDialog(ShellService.Instance.MainWindow);

            if (ret.HasValue && ret.Value)
            {
                StreamReader reader = new StreamReader(dlg.FileName);

                while (!reader.EndOfStream)
                {
                    string txt = reader.ReadLine();
                    int    id;
                    if (Int32.TryParse(txt, out id))
                    {
                        appearance.TakeItem(id);
                    }
                }

                reader.Dispose();

                ModelEditorService.Instance.ShowModelPart(node);
                ModelEditorService.Instance.ShowEditPart(node);
                ModelEditorService.Instance.SetWireFrame(node);
                ModelEditorService.Instance.SheathM2NodeWeapon(node);

                node.UpdateCharacter();

                //update property
                ShellService.Instance.PropertyContent.UpdateCharacterNode(node);
                Update();
            }
        }
Beispiel #9
0
        void _setSelect_Set_Selected(object sender, Set set)
        {
            M2SceneNode node = ModelSceneService.Instance.MainM2SceneNode;

            if (node != null && node.Type == M2Type.MT_CHARACTER && !node.IsNpc)
            {
                node.LoadSet(set.Id);

                ModelEditorService.Instance.ShowModelPart(node);
                ModelEditorService.Instance.ShowEditPart(node);
                ModelEditorService.Instance.SetWireFrame(node);

                node.UpdateCharacter();

                //update property
                ShellService.Instance.PropertyContent.UpdateCharacterNode(node);
                ShellService.Instance.EquipmentsWindow.Update();
            }
        }
        private void UseStartOutfit()
        {
            M2SceneNode node = ModelSceneService.Instance.MainM2SceneNode;

            if (node != null && node.Type == M2Type.MT_CHARACTER && !node.IsNpc)
            {
                node.LoadStartOutfitId(startOutfitId, startOutfitName == "死亡骑士" || startOutfitName == "DeathKnight");

                ModelEditorService.Instance.ShowModelPart(node);
                ModelEditorService.Instance.ShowEditPart(node);
                ModelEditorService.Instance.SetWireFrame(node);

                node.UpdateCharacter();

                if (StartOutfitUpdated != null)
                {
                    StartOutfitUpdated.Invoke(this, node);
                }
            }
        }
        void CurrentCharFeature_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            M2SceneNode node = ModelSceneService.Instance.MainM2SceneNode;

            if (node != null && node.Type == M2Type.MT_CHARACTER && !node.IsNpc)
            {
                SCharFeature schar = new SCharFeature();
                schar.skinColor  = CurrentCharFeature.SkinColor;
                schar.faceType   = CurrentCharFeature.FaceType;
                schar.hairStyle  = CurrentCharFeature.HairStyle;
                schar.hairColor  = CurrentCharFeature.HairColor;
                schar.facialHair = CurrentCharFeature.FacialHair;

                node.CharFeature = schar;

                ModelEditorService.Instance.ShowModelPart(node);
                ModelEditorService.Instance.ShowEditPart(node);
                ModelEditorService.Instance.SetWireFrame(node);

                node.UpdateCharacter();
            }
        }
Beispiel #12
0
        private void btImport_Click(object sender, RoutedEventArgs e)
        {
            M2SceneNode node = ModelSceneService.Instance.MainM2SceneNode;

            if (node == null)
            {
                return;
            }

            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter           = "text|*.txt|All Files|*.*";
            dlg.InitialDirectory = Environment.CurrentDirectory;
            bool?ret = dlg.ShowDialog(ShellService.Instance.MainWindow);

            if (ret.HasValue && ret.Value)
            {
                StreamReader reader = new StreamReader(dlg.FileName);

                while (!reader.EndOfStream)
                {
                    string txt = reader.ReadLine();
                    int    id;
                    if (Int32.TryParse(txt, out id))
                    {
                        int slot;
                        node.TakeItem(id, out slot);
                    }
                }

                reader.Dispose();

                node.UpdateCharacter();
                SlotItems.GetAllSlotItems(node);
            }
        }
        private bool LoadCharacter()
        {
            string      shortname    = Engine.Instance.WowDatabase.GetRaceName(charInfo.Race);
            WowDatabase _wowDatabase = Engine.Instance.WowDatabase;
            string      path         = _wowDatabase.GetCharacterPath(shortname, charInfo.Gender != 0, true);
            M2SceneNode node         = ModelSceneService.Instance.SetMainM2SceneNode(path, false);

            if (node == null)
            {
                path = _wowDatabase.GetCharacterPath(shortname, charInfo.Gender != 0, false);
                node = ModelSceneService.Instance.SetMainM2SceneNode(path, false);
            }

            if (node != null)
            {
                SCharFeature charFeature = new SCharFeature();
                charFeature.skinColor  = charInfo.SkinColor;
                charFeature.hairColor  = charInfo.HairColor;
                charFeature.hairStyle  = charInfo.HairStyle;
                charFeature.faceType   = charInfo.FaceType;
                charFeature.facialHair = charInfo.FacialHair;

                node.M2Instance.CharFeature = charFeature;
            }

            //items
            if (node != null)
            {
                M2Appearance appearance = node.M2Appearance;
                if (appearance != null)
                {
                    appearance.TakeItem(charInfo.Head);
                    appearance.TakeItem(charInfo.Shoulder);
                    appearance.TakeItem(charInfo.Boots);
                    appearance.TakeItem(charInfo.Belt);
                    appearance.TakeItem(charInfo.Shirt);
                    appearance.TakeItem(charInfo.Pants);
                    appearance.TakeItem(charInfo.Chest);
                    appearance.TakeItem(charInfo.Bracers);
                    appearance.TakeItem(charInfo.Gloves);
                    appearance.TakeItem(charInfo.HandRight);
                    appearance.TakeItem(charInfo.HandLeft);
                    appearance.TakeItem(charInfo.Cape);
                    appearance.TakeItem(charInfo.Tabard);
                }

                ModelEditorService.Instance.ShowModelPart(node);
                ModelEditorService.Instance.ShowEditPart(node);
                ModelEditorService.Instance.SetWireFrame(node);
                ModelEditorService.Instance.SheathM2NodeWeapon(node);

                node.UpdateCharacter();

                //update property
                ShellService.Instance.PropertyContent.UpdateCharacterNode(node);

                if (ShellService.Instance.EquipmentsWindow.IsVisible)
                {
                    ShellService.Instance.EquipmentsWindow.Update();
                }

                if (ShellService.Instance.EquipmentSelectWindow.IsVisible)
                {
                    ShellService.Instance.EquipmentSelectWindow.Update();
                }
            }

            Player player = Client.Instance.GetPlayer();

            if (EngineService.Instance.IsGameMode && node != null &&
                (node.Type == M2Type.MT_CHARACTER || node.Type == M2Type.MT_CREATRUE))
            {
                player.SetM2AsTarget(node, 15, (float)(Math.PI / 6.0f));
            }
            else
            {
                player.SetM2AsTarget(null, 15, (float)(Math.PI / 6.0f));
            }

            return(node != null);
        }