Beispiel #1
0
        public GameVM(AmfFile file, GameVM previousVM)
            : base(file)
        {
            SetCharacterOptions();
            setCharacter("PC");
            SaveFile = new AmfObjectVM(file);

            var flagsObject = FlagsObject;

            _flags = new GeneralObjectVM(flagsObject);
            if (null != previousVM)
            {
                _searchText = previousVM._searchText;
            }

            // Flags
            foreach (var xmlFlag in XmlData.Current.Flags)
            {
                if (!_allFlags.ContainsKey(xmlFlag.Name))
                {
                    _allFlags[xmlFlag.Name] = new FlagVM(this, ref flagsObject, xmlFlag);
                }
            }
            foreach (var flag in flagsObject)
            {
                string flagName = flag.ToString();
                if (!_allFlags.ContainsKey(flagName))
                {
                    XmlEnum data = new XmlEnum();
                    data.Name           = flagName;
                    _allFlags[flagName] = new FlagVM(this, ref flagsObject, data);
                }
            }
            Flags = new UpdatableCollection <FlagVM>(_allFlags.Values.ToList().Where(x => x.Match(SearchText)));
        }
Beispiel #2
0
        /// <summary>
        /// Returns the flag with the specified name (even if not set in the save) AND registers a dependency between the caller property and this flag.
        /// That way, anytime the flag value is changed, OnPropertyChanged will be raised for the caller property.
        /// </summary>
        public FlagVM GetFlag(string name, string propertyName = null)
        {
            FlagVM flag = null;

            if (_allFlags.ContainsKey(name))
            {
                flag = _allFlags[name];
                flag.GameVMProperties.Add(propertyName);
            }
            return(flag);
        }
Beispiel #3
0
 public void RemoveFlag(FlagVM flag)
 {
     if (null != flag)
     {
         var flagName = flag.Name;
         // remove flag
         if (null != FlagsObject && !String.IsNullOrEmpty(flagName))
         {
             if (null != FlagsObject[flagName])
             {
                 flag.Value            = null;
                 FlagsObject[flagName] = null;
                 OnFlagChanged(flagName);
                 var search = SearchText;
                 SearchText = @"\u200B"; // setting to Unicode zero-width space
                 SearchText = search;
             }
         }
     }
 }
Beispiel #4
0
        public GameVM(AmfFile file, GameVM previousVM)
            : base(file)
        {
            SetCharacterOptions();
            setCharacter("PC");

            var flagsObject = FlagsObject;

            _flags = new GeneralObjectVM(flagsObject);
            if (null != previousVM)
            {
                _perkSearchText    = previousVM._perkSearchText;
                _keyItemSearchText = previousVM._keyItemSearchText;
                _rawDataSearchText = previousVM._rawDataSearchText;
            }

            // Perks
            var charPerks        = Character.PerksArray;
            var xmlPerks         = XmlData.Current.PerkGroups.SelectMany(x => x.Perks).ToArray();
            var unknownPerkGroup = XmlData.Current.PerkGroups.Last();

            ImportMissingNamedVectors(charPerks, xmlPerks, "storageName", x => x.GetString("tooltip"), unknownPerkGroup.Perks);

            Character.PerkGroups = new List <PerkGroupVM>();
            foreach (var xmlGroup in XmlData.Current.PerkGroups)
            {
                var perksVM = xmlGroup.Perks.OrderBy(x => x.Name).Select(x => new PerkVM(this, charPerks, x)).ToArray();
                _allPerks.AddRange(perksVM);

                var groupVM = new PerkGroupVM(this, xmlGroup.Name, perksVM);
                Character.PerkGroups.Add(groupVM);
            }
            //Character.Perks = new UpdatableCollection<PerkVM>(_allPerks.Where(x => x.Match(PerkSearchText)));

            // KeyItems
            var keyItems = Character.KeyItemsArray;
            var xmlKeys  = XmlData.Current.KeyItems;

            ImportMissingNamedVectors(keyItems, xmlKeys, "storageName", x => x.GetString("tooltip"));
            _allKeyItems       = XmlData.Current.KeyItems.OrderBy(x => x.Name).Select(x => new KeyItemVM(this, keyItems, x)).ToArray();
            Character.KeyItems = new UpdatableCollection <KeyItemVM>(_allKeyItems.Where(x => x.Match(KeyItemSearchText)));

            // Statuses
            var statuses    = Character.StatusEffectsArray;
            var xmlStatuses = XmlData.Current.Statuses;

            ImportMissingNamedVectors(statuses, xmlStatuses, "storageName", x => x.GetString("tooltip"));
            _allStatuses            = XmlData.Current.Statuses.OrderBy(x => x.Name).Select(x => new StatusEffectVM(this, statuses, x)).ToArray();
            Character.StatusEffects = new UpdatableCollection <StatusEffectVM>(_allStatuses.Where(x => x.Match(RawDataSearchText)));

            // Flags
            foreach (var xmlFlag in XmlData.Current.Flags)
            {
                if (!_allFlags.ContainsKey(xmlFlag.Name))
                {
                    _allFlags[xmlFlag.Name] = new FlagVM(this, ref flagsObject, xmlFlag);
                }
            }
            foreach (var flag in flagsObject)
            {
                string flagName = flag.ToString();
                if (!_allFlags.ContainsKey(flagName))
                {
                    XmlEnum data = new XmlEnum();
                    data.Name           = flagName;
                    _allFlags[flagName] = new FlagVM(this, ref flagsObject, data);
                }
            }
            Flags = new UpdatableCollection <FlagVM>(_allFlags.Values.ToList().Where(x => x.Match(RawDataSearchText)));
        }
Beispiel #5
0
        public GameVM(AmfFile file, GameVM previousVM)
            : base(file)
        {
            SetCharacterOptions();
            CharacterSelection = "PC";

            var shittyShips = GetObj("shittyShips") ?? new AmfObject(AmfTypes.Array);

            Ships = new ShipArrayVM(this, shittyShips);

            var flagsObject = FlagsObject;

            _flags = new GeneralObjectVM(flagsObject);

            // Flags
            var flagNames = AllFlags.Keys.ToList();

            foreach (var flagName in flagNames)
            {
                XmlEnum data = new XmlEnum();
                data.Name          = flagName;
                AllFlags[flagName] = new FlagVM(this, ref flagsObject, data);
            }

            foreach (var xmlFlag in XmlData.Current.Flags)
            {
                if (!AllFlags.ContainsKey(xmlFlag.Name))
                {
                    AllFlags[xmlFlag.Name] = new FlagVM(this, ref flagsObject, xmlFlag);
                }
            }

            foreach (var flag in flagsObject)
            {
                string flagName = flag.ToString();
                if (!AllFlags.ContainsKey(flagName))
                {
                    XmlEnum data = new XmlEnum();
                    data.Name          = flagName;
                    AllFlags[flagName] = new FlagVM(this, ref flagsObject, data);
                }
            }

            if (null != previousVM)
            {
                foreach (var flag in previousVM.AllFlags)
                {
                    string flagName = flag.Key.ToString();
                    if (!AllFlags.ContainsKey(flagName))
                    {
                        XmlEnum data = new XmlEnum();
                        data.Name          = flagName;
                        AllFlags[flagName] = new FlagVM(this, ref flagsObject, data);
                    }
                }
            }

            Flags = new UpdatableCollection <FlagVM>(AllFlags.Values.ToList().Where(x => x.Match(SearchText)));
            OnPropertyChanged("Flags");

            // Codex
            var codexEntries = AllCodexEntries.Keys.ToList();

            foreach (var codexName in codexEntries)
            {
                XmlCodexEntry data = new XmlCodexEntry();
                data.Name = codexName;
                AllCodexEntries[codexName] = new CodexEntryVM(this, data);
            }

            foreach (var xmlCodex in XmlData.Current.CodexEntries)
            {
                if (!AllCodexEntries.ContainsKey(xmlCodex.Name))
                {
                    AllCodexEntries[xmlCodex.Name] = new CodexEntryVM(this, xmlCodex);
                }
            }

            foreach (var codexEntry in CodexUnlockedEntriesObj)
            {
                string codexName = codexEntry.Value.ToString();
                if (!AllCodexEntries.ContainsKey(codexName))
                {
                    XmlCodexEntry data = new XmlCodexEntry(codexName);
                    AllCodexEntries[codexName] = new CodexEntryVM(this, data);
                }
            }

            foreach (var codexEntry in CodexViewedEntriesObj)
            {
                string codexName = codexEntry.Value.ToString();
                if (!AllCodexEntries.ContainsKey(codexName))
                {
                    XmlCodexEntry data = new XmlCodexEntry(codexName);
                    AllCodexEntries[codexName] = new CodexEntryVM(this, data);
                }
            }

            if (null != previousVM)
            {
                foreach (var codexEntry in previousVM.AllCodexEntries)
                {
                    string codexName = codexEntry.Value.ToString();
                    if (!AllCodexEntries.ContainsKey(codexName))
                    {
                        XmlCodexEntry data = new XmlCodexEntry(codexName);
                        AllCodexEntries[codexName] = new CodexEntryVM(this, data);
                    }
                }
            }

            CodexEntries = new UpdatableCollection <CodexEntryVM>(AllCodexEntries.Values.ToList().Where(x => x.Match(SearchText)));
            OnPropertyChanged("CodexEntries");
        }