private async Task <CharacterFile?> Save(bool useAdvancedSave)
        {
            if (this.Actor == null)
            {
                return(null);
            }

            CharacterFile.SaveModes mode = CharacterFile.SaveModes.All;

            if (useAdvancedSave)
            {
                mode = await ViewService.ShowDialog <AppearanceModeSelectorDialog, CharacterFile.SaveModes>("Save Character...");
            }

            CharacterFile file = new CharacterFile();

            if (mode == CharacterFile.SaveModes.None)
            {
                return(null);
            }

            file.WriteToFile(this.Actor, mode);

            return(file);
        }
Beispiel #2
0
        public override void Modify(CharacterViewModel model)
        {
            OpenFileDialog opfd = new OpenFileDialog
            {
                Filter           = "PNG Files (*.png)|*.png",
                CheckFileExists  = true,
                InitialDirectory = Core.EditSaveDir,
                Multiselect      = false,
            };

            opfd.CustomPlaces.Add(new FileDialogCustomPlace(Core.EditSaveDir));
            if (!opfd.ShowDialog()
                .Value)
            {
                return;
            }
            CharacterFile inC;

            using (Stream s = File.OpenRead(opfd.FileName))
                inC = CharacterFile.Load(s);
            if (inC == null)
            {
                return;
            }

            ImportWindow iWnd = new ImportWindow
            {
                Imported = inC,
                Target   = model.Character
            };

            iWnd.ShowDialog();
        }
Beispiel #3
0
    public void PlayCharacter(CharacterFile characterFile)
    {
        Debug.Log($"Playing Character {characterFile.Name}...");

        if (!GameManager.GM.isPlaytest)
        {
            if (!hasFocus)
            {
                return;
            }

            if (!currentPage)
            {
                return;
            }
        }

        if (isPlaying)
        {
            currentPage.StopAndPlayCharacter(characterFile);
            return;
        }

        currentPage.PlayCharacter(characterFile);
    }
        private async Task Save(bool advanced)
        {
            if (this.Actor == null)
            {
                return;
            }

            CharacterFile.SaveModes mode = CharacterFile.SaveModes.All;

            if (advanced)
            {
                CharacterFile.SaveModes newMode = await ViewService.ShowDialog <AppearanceModeSelectorDialog, CharacterFile.SaveModes>("Save Character...", lastSaveMode);

                if (newMode == CharacterFile.SaveModes.None)
                {
                    return;
                }

                mode = newMode;
            }

            CharacterFile file = new CharacterFile();

            file.WriteToFile(this.Actor, mode);

            await FileService.Save(file);
        }
        private ClothFile CreateClothFile()
        {
            string[]      targets = { "UNIFORM", "SWIMSUIT", "SPORT", "CLUB" };
            int           suit    = (int)ClothesViewModel.Kind;
            CharacterFile @char   = ClothesViewModel.CharacterViewModel.Character;
            var           attribs = @char.CharAttributes.Where(pair => pair.Key.StartsWith(targets[suit]))
                                    .Select(pair => pair.Value);
            ClothFile cf = new ClothFile
            {
                RawData = new byte[92],
            };

            cf.Attributes["CLOTH_GENDER"].Value = ClothesViewModel.CharacterViewModel.Profile.Gender.Value;
            foreach (DataBlockWrapper wrapperChar in attribs)
            {
                string tgtKey = wrapperChar.Key.Replace(targets[suit], "CLOTH");
                if (!cf.Attributes.ContainsKey(tgtKey))
                {
                    continue;
                }
                DataBlockWrapper wrapperCloth = cf.Attributes[tgtKey];
                wrapperCloth.Value = wrapperChar.Value;
            }
            return(cf);
        }
Beispiel #6
0
    public void PrepareMainSpell(Spell spell, int rank)
    {
        int number = CharacterFile.GetNumberOfSpellsPerDay_Modifier_Level(mModifier, rank);

        if (mCClass == CharClassEnum.Cleric)
        {
            number += CharacterFile.GetNumberOfSpellsPerDay_CLERIC_Level(mLevel, rank);
        }
        else if (mCClass == CharClassEnum.Wizard)
        {
            number += CharacterFile.GetNumberOfSpellsPerDay_WIZARD_Level(mLevel, rank);
        }
        if (mMainSpells[rank].Count >= number)
        {
            int index = -1;
            for (int i = 0; i < mainSpells[rank].Count; ++i)
            {
                if (mainSpells[rank][i].Value)
                {
                    index = i;
                    break;
                }
            }
            if (index == -1)
            {
                mMainSpells[rank] = new List <KeyValuePair <Spell, bool> >();
            }
            else
            {
                mainSpells[rank].RemoveAt(index);
            }
        }
        mMainSpells[rank].Add(new KeyValuePair <Spell, bool>(spell, false));
    }
Beispiel #7
0
        private IndexItem BuildIndexItem(Item item, CharacterFile character)
        {
            if (string.IsNullOrEmpty(item.baseName))
            {
                return(null);
            }

            var itemDef = _itemCache.GetItem(item.baseName);

            if (itemDef == null)
            {
                return(null);
            }

            //itemStatDef is the item definition that is used for stats (relevant in case of blueprints, where the item itself doesn't have stats, but the crafted item does)
            var itemStatDefIdentifier = ItemHelper.GetItemStatSource(itemDef);

            ItemRaw itemStatDef = itemDef;

            if (itemStatDefIdentifier != null)
            {
                itemStatDef = _itemCache.GetItem(itemStatDefIdentifier);
                // Some items are defined slightly differently - where the target item actually refers to a loot table instead of the item itself.
                if (itemStatDef != null && itemStatDef.StringParametersRaw.ContainsKey("Class") && itemStatDef.StringParametersRaw["Class"] == "LootItemTable_DynWeight")
                {
                    var lootName1 = itemStatDef.StringParametersRaw.ContainsKey("lootName1") ? itemStatDef.StringParametersRaw["lootName1"] : null;
                    if (lootName1 == null)
                    {
                        itemStatDef = null;
                    }
                    else
                    {
                        itemStatDef = _itemCache.GetItem(lootName1);
                    }
                }
            }

            if (itemStatDef == null)
            {
                itemStatDef = itemDef;
            }

            var indexItem = new IndexItem();

            indexItem.ItemName = ItemHelper.GetFullItemName(item, itemDef);
            indexItem.Owner    = character.Header.Name;
            if (itemStatDef.NumericalParametersRaw.ContainsKey("levelRequirement"))
            {
                indexItem.LevelRequirement = (int)itemStatDef.NumericalParametersRaw["levelRequirement"];
            }

            indexItem.Rarity         = ItemHelper.GetItemRarity(itemDef);
            indexItem.ItemType       = ItemHelper.GetItemType(itemStatDef);
            indexItem.Source         = itemDef;
            indexItem.SourceInstance = item;
            indexItem.ItemStats      = ItemHelper.GetStats(item, itemStatDef).Select(x => x.Replace("{^E}", "").Replace("{%+.0f0}", "").Replace("{%t0}", "").Trim()).ToList();
            indexItem.Searchable     = BuildSearchableString(character, item, itemDef, indexItem.ItemStats);

            return(indexItem);
        }
        private void CopyCommand_Execute(object sender, RoutedEventArgs e)
        {
            e.Handled = true;

            CharacterFile @char = ClothesViewModel.CharacterViewModel.Character;
            string        tgt   = ClipboardHelper.GetSuitPrefix(ClothesViewModel.Kind);

            var       clothBytes = new byte[92];
            ClothFile cf         = ClothFile.Load(clothBytes);

            var attribs = cf.Attributes.Keys.Select
                              (s =>
            {
                string tgtKey = s.Replace("CLOTH", tgt);
                if (@char.CharAttributes.ContainsKey(tgtKey))
                {
                    return(@char.CharAttributes[tgtKey]);
                }
                return(null);
            })
                          .Where(wrapper => wrapper != null);
            String str = ClipboardHelper.GetAttributesString(attribs, ClipboardHelper.REIAA2_SUITFLAG);

            //[WXP] Replaced Lambda to new Func/Action
            Dispatcher.Invoke
                (new Action
                    (() =>
            {
                string clothesPrefix = ClipboardHelper.GetSuitPrefix(ClothesViewModel.Kind);
                Clipboard.SetText(str.Replace(clothesPrefix, "CLOTH"));
            }));
        }
Beispiel #9
0
    public void LoseFocus()
    {
        hasFocus         = false;
        currentPage      = null;
        currentCharacter = null;

        GameManager.GM.AudioManager.StopCharacterVoice();
    }
Beispiel #10
0
        private async Task Save()
        {
            if (this.Actor == null)
            {
                return;
            }

            lastSaveMode = await CharacterFile.Save(this.Actor, lastSaveMode);
        }
Beispiel #11
0
    public void StopAndPlayCharacter(CharacterFile characterFile)
    {
        for (int c = 0; c < characters.Count; c++)
        {
            characters[c].gameObject.SetActive(false);
        }

        PlayCharacter(characterFile);
    }
Beispiel #12
0
        private string BuildSearchableString(CharacterFile character, Item item, ItemRaw itemDef, List <string> itemStats)
        {
            List <string> searchableStrings = new List <string>();

            searchableStrings.Add(ItemHelper.GetFullItemName(item, itemDef).ToLower());
            searchableStrings.AddRange(itemStats);
            searchableStrings.Add(character.Header.Name);

            return(string.Join(" ", searchableStrings).ToLower());
        }
        private async void ApplyNpc(INpcBase?npc)
        {
            if (this.Actor == null || npc == null)
            {
                return;
            }

            CharacterFile apFile = npc.ToFile();
            await apFile.Apply(this.Actor, CharacterFile.SaveModes.All);
        }
        private void ReloadViewModel(CharacterViewModel model)
        {
            string        filePath = (string)model.Metadata;
            CharacterFile cf       = CharacterFile.Load(filePath);

            if (cf == null)
            {
                return;
            }
            CharacterViewModel newViewModel = new CharacterViewModel(cf, filePath);

            OnCharacterUpdated(new CharacterViewModelProviderEventArgs(newViewModel, filePath));
        }
        private CharacterViewModel CreateViewModel(CharacterFile cf, string file)
        {
            CharacterViewModel cvm = new CharacterViewModel(cf, file);

            if (File.Exists(file))
            {
                DateTime lastWriteTime = new FileInfo(file).LastWriteTime;
                cvm.ExtraData.Add("FILE_MOD", lastWriteTime);
            }
            cvm.SaveCommand   = new RelayCommand(() => SaveViewModel(cvm), () => SaveViewModelCanExecute(cvm));
            cvm.ReloadCommand = new RelayCommand(() => ReloadViewModel(cvm));
            return(cvm);
        }
Beispiel #16
0
        public static CharacterFile ToFile(this INpcBase npc)
        {
            CharacterFile file = new CharacterFile();

            file.SaveMode           = CharacterFile.SaveModes.All;
            file.ModelType          = npc.ModelType;
            file.Race               = npc.Race.Race;
            file.Tribe              = npc.Tribe.Tribe;
            file.Gender             = (Appearance.Genders)npc.Gender;
            file.Age                = (Appearance.Ages)npc.BodyType;
            file.Height             = (byte)npc.Height;
            file.Head               = (byte)npc.Face;
            file.Hair               = (byte)npc.HairStyle;
            file.EnableHighlights   = npc.HairHighlightColor > 1;
            file.Skintone           = (byte)npc.SkinColor;
            file.REyeColor          = (byte)npc.EyeColor;
            file.LEyeColor          = (byte)npc.EyeHeterochromia;
            file.HairTone           = (byte)npc.HairColor;
            file.Highlights         = (byte)npc.HairHighlightColor;
            file.FacialFeatures     = (Appearance.FacialFeature)npc.FacialFeature;
            file.LimbalEyes         = 0;     // TODO: Can npc's have limbal rings?
            file.Eyebrows           = (byte)npc.Eyebrows;
            file.Eyes               = (byte)npc.EyeShape;
            file.Nose               = (byte)npc.Nose;
            file.Jaw                = (byte)npc.Jaw;
            file.Mouth              = (byte)npc.Mouth;
            file.LipsToneFurPattern = (byte)npc.LipColor;
            file.EarMuscleTailSize  = (byte)npc.ExtraFeature1;
            file.TailEarsType       = (byte)npc.ExtraFeature2OrBust;
            file.Bust               = (byte)npc.ExtraFeature2OrBust;
            file.FacePaint          = (byte)npc.FacePaint;
            file.FacePaintColor     = (byte)npc.FacePaintColor;

            file.MainHand = WeaponFromItem(npc.NpcEquip.MainHand, npc.NpcEquip.DyeMainHand);
            file.OffHand  = WeaponFromItem(npc.NpcEquip.OffHand, npc.NpcEquip.DyeOffHand);

            file.HeadGear  = GearFromItem(npc.NpcEquip.Head, npc.NpcEquip.DyeHead);
            file.Body      = GearFromItem(npc.NpcEquip.Body, npc.NpcEquip.DyeBody);
            file.Hands     = GearFromItem(npc.NpcEquip.Hands, npc.NpcEquip.DyeHands);
            file.Legs      = GearFromItem(npc.NpcEquip.Legs, npc.NpcEquip.DyeLegs);
            file.Feet      = GearFromItem(npc.NpcEquip.Feet, npc.NpcEquip.DyeFeet);
            file.Ears      = GearFromItem(npc.NpcEquip.Ears, npc.NpcEquip.DyeEars);
            file.Neck      = GearFromItem(npc.NpcEquip.Neck, npc.NpcEquip.DyeNeck);
            file.Wrists    = GearFromItem(npc.NpcEquip.Wrists, npc.NpcEquip.DyeWrists);
            file.LeftRing  = GearFromItem(npc.NpcEquip.LeftRing, npc.NpcEquip.DyeLeftRing);
            file.RightRing = GearFromItem(npc.NpcEquip.RightRing, npc.NpcEquip.DyeRightRing);

            return(file);
        }
Beispiel #17
0
        private async void ApplyNpc(INpcResident?npc)
        {
            if (this.Actor == null || npc == null)
            {
                return;
            }

            if (npc.Appearance == null)
            {
                return;
            }

            CharacterFile apFile = npc.Appearance.ToFile();
            await apFile.Apply(this.Actor, CharacterFile.SaveModes.All);
        }
Beispiel #18
0
        private void LoadAllCharacters(string grimDawnSavesDirectory, Action <string> stateChangeCallback)
        {
            stateChangeCallback("Clearing index");
            _characters.Clear();

            var charactersDirectory = Path.Combine(grimDawnSavesDirectory, "main");

            if (!Directory.Exists(charactersDirectory))
            {
                throw new InvalidOperationException("Saves directory not found: " + charactersDirectory);
            }

            var directories = Directory.EnumerateDirectories(charactersDirectory, "*", SearchOption.TopDirectoryOnly);

            foreach (var d in directories)
            {
                //Skip backup characters
                if (Path.GetFileName(d).StartsWith("__"))
                {
                    continue;
                }

                var characterFile = Path.Combine(d, "player.gdc");
                if (!File.Exists(characterFile))
                {
                    continue;
                }

                stateChangeCallback("Loading " + characterFile);

                var character = new CharacterFile();
                try
                {
                    using (var s = File.OpenRead(characterFile))
                    {
                        character.Read(s);
                    }
                    _characters.Add(character);
                }
                catch (Exception ex)
                {
                    Trace.TraceError(ex.ToString());
                }
            }

            LoadTransferStashAsCharacter(grimDawnSavesDirectory, stateChangeCallback);
            LoadBlueprintsAsCharacter(grimDawnSavesDirectory, stateChangeCallback);
        }
Beispiel #19
0
        public HeroEditor(CharacterFile characterFile, FileManager fileManager)
        {
            _characterFile = characterFile;
            _heroUnit = characterFile.Character;
            _fileManager = fileManager;
            //_panel = new CompletePanelControl();
            //_statsTable = _excelTables.GetTable("stats") as Stats;

            //_itemFunctions = new UnitHelpFunctions(_dataSet);
            _itemFunctions.LoadCharacterValues(_heroUnit);
            //_itemFunctions.GenerateUnitNameStrings();
            //_itemFunctions.PopulateItems(ref _heroUnit);
            //_wrapper = new UnitWrapper(_dataSet, heroFile);

            InitializeComponent();
        }
Beispiel #20
0
    public void PlayCharacter(CharacterFile characterFile)
    {
        Debug.Log($"Finding Character {characterFile.Name} in Page {Number}...");

        foreach (CharacterAnimation characterAnimation in characters)
        {
            if (characterAnimation.gameObject.name == characterFile.Name)
            {
                characterAnimation.gameObject.SetActive(true);
                characterAnimation.StartAnimation();

                GameManager.GM.ARSceneManager.SetActiveCharacter(characterFile);
                return;
            }
        }
    }
Beispiel #21
0
        private static Layer GenerateTextLayer(CharacterFile characterFile)
        {
            string personality = characterFile.GetEnumValue(KEY_PERSONALITY);
            int    indexOfPar  = personality.IndexOf('(');

            if (indexOfPar != -1)
            {
                personality = personality.Remove(indexOfPar - 1);
            }
            string familyName = characterFile.GetAttribute <string>(KEY_FAMILY_NAME);
            string firstName  = characterFile.GetAttribute <string>(KEY_FIRST_NAME);

            Bitmap   bmp = new Bitmap(CARD_WIDTH, CARD_HEIGHT);
            Graphics g   = Graphics.FromImage(bmp);

            g.TextRenderingHint = TextRenderingHint.AntiAlias;

            StringFormat sf = new StringFormat
            {
                Trimming    = StringTrimming.Character,
                FormatFlags = StringFormatFlags.NoWrap
            };

            Font nameFont = new Font("Tahoma", 50, FontStyle.Bold, GraphicsUnit.Pixel);
            Font persFont = new Font("Tahoma", 32, FontStyle.Bold, GraphicsUnit.Pixel);

            sf.Alignment = StringAlignment.Near;
            RectangleF textBounds = new RectangleF(30, 30, 340, 540);

            g.DrawString(personality, persFont, Brushes.White, textBounds, sf);
            g.TranslateTransform(0, 450);
            g.RotateTransform(-10);
            sf.Alignment = StringAlignment.Near;
            g.DrawString(familyName, nameFont, Brushes.White, textBounds, sf);
            g.RotateTransform(10);
            g.TranslateTransform(0, 50);
            g.RotateTransform(-10);
            sf.Alignment = StringAlignment.Far;
            g.DrawString(firstName, nameFont, Brushes.White, textBounds, sf);
            g.Flush();

            Layer textLayer = (Layer)bmp;

            g.Dispose();
            bmp.Dispose();
            return(textLayer);
        }
        private void SuitOnPropertyChanged(object sender, PropertyChangedEventArgs args)
        {
            if (args.PropertyName != "Value")
            {
                return;
            }
            string[] data  = { "IS_ONEPIECE", "IS_UNDERWEAR", "IS_SKIRT" };
            bool[][] bData =
            {
                //Uniform
                new[] { false, true,  true  },
                //Sport
                new[] { false, true,  false },
                //Swimsuit
                new[] { true,  false, false },
                //Formal
                new[] { false, true,  true  },
                //Blazer
                new[] { false, true,  true  },
                //Naked
                new[] { false, false, false },
                //Undies
                new[] { false, true,  false }
            };
            DataBlockWrapper wrapper   = (DataBlockWrapper)sender;
            string           srcSuit   = wrapper.Key.Remove(wrapper.Key.IndexOf('_'));
            int           srcSuitValue = (int)wrapper.Value;
            CharacterFile @char        = CharacterViewModel.Character;

            for (int prop = 0; prop < 3; prop++)
            {
                string targetKey = String.Format("{0}_{1}", srcSuit, data[prop]);
                bool   targetValue;
                try
                {
                    targetValue = bData[srcSuitValue][prop];
                }
                catch
                {
                    targetValue = false;
                }
                if (@char.CharAttributes.ContainsKey(targetKey))
                {
                    @char.CharAttributes[targetKey].Value = targetValue;
                }
            }
        }
Beispiel #23
0
    public bool SetButtonInteractable(CharacterFile character, bool isInteractable = true)
    {
        foreach (var characterButton in characterButtons)
        {
            if (characterButton.CharacterFile == character)
            {
                if (characterButton.Button)
                {
                    characterButton.Button.interactable = isInteractable;
                }

                return(true);
            }
        }

        return(false);
    }
Beispiel #24
0
        private void Correct_OnExecute(object sender, ExecutedRoutedEventArgs e)
        {
            int    suitVal = (int)ClothesViewModel.Suit.Value;
            string suitStr = ClipboardHelper.GetSuitPrefix(ClothesViewModel.Kind);

            string[] kData = { "IS_ONEPIECE", "IS_UNDERWEAR", "IS_SKIRT" };
            bool[][] bData =
            {
                //Uniform
                new[] { false, true,  true  },
                //Sport
                new[] { false, true,  false },
                //Swimsuit
                new[] { true,  false, false },
                //Formal
                new[] { false, true,  true  },
                //Blazer
                new[] { false, true,  true  },
                //Naked
                new[] { false, false, false },
                //Undies
                new[] { false, true,  false },
                //Uniform2
                new[] { false, true,  true  }
            };

            CharacterFile @char = ClothesViewModel.CharacterViewModel.Character;

            for (int i = 0; i < 3; i++)
            {
                string targetKey = String.Format("{0}_{1}", suitStr, kData[i]);
                bool   targetValue;
                try
                {
                    targetValue = bData[suitVal][i];
                }
                catch
                {
                    targetValue = false;
                }
                if (@char.CharAttributes.ContainsKey(targetKey))
                {
                    @char.CharAttributes[targetKey].Value = targetValue;
                }
            }
        }
Beispiel #25
0
        public static CharacterFile OpenCharacterFile(string fileName)
        {
            CharacterFile characterFile = new CharacterFile(fileName);

            try
            {
                byte[] fileBytes = File.ReadAllBytes(fileName);
                characterFile.ParseFileBytes(fileBytes);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to open file: " + fileName + "\n\n" + ex, "OpenCharacterFile", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }

            return(characterFile);
        }
        private static async Task RunInternal(string inputFilePath)
        {
            try
            {
                await MainWin.LockUi("Exporting Anamnesis Character", "....", LockObj);

                MainWin.LockProgress.Report("Loading chara file...");

                name = Path.GetFileNameWithoutExtension(inputFilePath);

                // read chara file
                string json = File.ReadAllText(inputFilePath);
                character = JsonConvert.DeserializeObject <CharacterFile>(json);
                XivRace race = character.GetXivRace();

                // load all items we can
                MainWin.LockProgress.Report("Loading items...");
                allItems = await XivCache.GetFullItemList();

                // Body
                await Export("Face", GetFaceModel(race, character.Head, character.Eyebrows, character.Eyes, character.Nose, character.Jaw, character.Mouth), race);
                await Export("EarsTail", GetEarsTailModel(race, character.TailEarsType), race);
                await Export("Hair", GetHairModel(race, character.Hair), race);
                await Export("Head", GetItemModel(character.HeadGear, "Head"), race);
                await Export("Body", GetItemModel(character.Body, "Body"), race);
                await Export("Hands", GetItemModel(character.Hands, "Hands"), race);
                await Export("Legs", GetItemModel(character.Legs, "Legs"), race);
                await Export("Feet", GetItemModel(character.Feet, "Feet"), race);
                await Export("Earring", GetItemModel(character.Ears, "Earring"), race);
                await Export("Neck", GetItemModel(character.Neck, "Neck"), race);
                await Export("Wrists", GetItemModel(character.Wrists, "Wrists"), race);
                await Export("L Ring", GetItemModel(character.LeftRing, "Rings"), race);
                await Export("R ring", GetItemModel(character.RightRing, "Rings"), race);
                await Export("Weapon Main", GetWeaponModel(character.MainHand, true), race);
                await Export("Weapon Off", GetWeaponModel(character.OffHand, false), race);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error running export");
            }
            finally
            {
                await MainWin.UnlockUi(LockObj);
            }
        }
Beispiel #27
0
        private void BuildUnequippedIndexItems(CharacterFile c, Item[] items, IndexSummary summary, string bagName)
        {
            foreach (var e in items)
            {
                if (e == null)
                {
                    continue;
                }

                var item = BuildIndexItem(e, c);
                if (item != null)
                {
                    item.Bag = bagName;
                }

                AddIndexItem(item, summary);
            }
        }
        private void FSWatcher_Changed(object sender, FileSystemEventArgs e)
        {
            CharacterFile cf = CharacterFile.Load(e.FullPath);

            if (cf == null)
            {
                return;
            }
            CharacterViewModel viewmodel = CreateViewModel(cf, e.FullPath);

            if (_lastCreated != null && e.FullPath.Equals(_lastCreated))
            {
                _lastCreated = null;
                OnCharacterAdded(new CharacterViewModelProviderEventArgs(viewmodel));
                return;
            }
            OnCharacterUpdated(new CharacterViewModelProviderEventArgs(viewmodel, e.FullPath));
        }
Beispiel #29
0
        private static void PropertyChangedCallback(
            DependencyObject dependencyObject,
            DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
        {
            ContentControl control = dependencyObject as ContentControl;

            if (control == null)
            {
                return;
            }
            DataTemplate  overrideTemplate = GetDataTemplate(control);
            CharacterFile cf = GetCharacter(control);
            string        at = GetAttribute(control);

            if (cf == null || string.IsNullOrEmpty(at) || !cf.CharAttributes.ContainsKey(at))
            {
                return;
            }
            DataBlockWrapper attribute = cf.CharAttributes[at];

            control.SetBinding(ContentControl.ContentProperty,
                               new Binding
            {
                Source = attribute,
            });
            BindingOperations.ClearBinding(control, ContentControl.ContentTemplateSelectorProperty);
            BindingOperations.ClearBinding(control, ContentControl.ContentTemplateProperty);
            if (overrideTemplate == null)
            {
                control.SetBinding(ContentControl.ContentTemplateSelectorProperty,
                                   new Binding
                {
                    Source = TemplateSelector
                });
            }
            else
            {
                control.SetBinding(ContentControl.ContentTemplateProperty,
                                   new Binding
                {
                    Source = overrideTemplate
                });
            }
        }
Beispiel #30
0
        private void BuildEquippedIndexItems(CharacterFile c, Item[] equipment, IndexSummary summary)
        {
            foreach (var e in equipment)
            {
                if (e == null)
                {
                    continue;
                }

                var item = BuildIndexItem(e, c);
                if (item != null)
                {
                    item.Bag        = "Equipped";
                    item.IsEquipped = true;
                }

                AddIndexItem(item, summary);
            }
        }
Beispiel #31
0
        public void TestLoadMethod()
        {
            Stream stream = File.OpenRead(TEST_FILE);

            stream.Seek(0, SeekOrigin.End);
            long fileSize = stream.Position;

            stream.Seek(0, SeekOrigin.Begin);

            CharacterFile characterFile = new CharacterFile();

            characterFile.Load(stream);

            long streamPosition = stream.Position;

            stream.Close();

            Assert.AreEqual(fileSize, streamPosition, "Not all of the file was read");
        }
Beispiel #32
0
        public static CharacterFile OpenCharacterFile(string fileName)
        {
            CharacterFile characterFile = new CharacterFile(fileName);

            try
            {
                byte[] fileBytes = File.ReadAllBytes(fileName);
                characterFile.ParseFileBytes(fileBytes);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to open file: " + fileName + "\n\n" + ex, "OpenCharacterFile", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return null;
            }

            return characterFile;
        }