Exemplo n.º 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)));
        }
Exemplo n.º 2
0
        public CharacterVM(GameVM game, AmfObject obj)
            : base(obj)
        {
            Game = game;

            Breasts = new BreastArrayVM(game, GetObj("breastRows"));
            Vaginas = new VaginaArrayVM(game, GetObj("vaginas"));
            Cocks   = new CockArrayVM(game, GetObj("cocks"));
            Ass     = new VaginaVM(game, GetObj("ass"));

            List <String> types = new List <String>();

            foreach (XmlItemType type in XmlData.Current.ItemTypes)
            {
                types.Add(type.Name);
            }

            var containers = new List <ItemContainerVM>();

            _inventory = new ItemContainerVM(this, "Inventory", types);
            containers.Add(_inventory);
            UpdateInventory();

            // Complete slots creation
            ItemContainers = new UpdatableCollection <ItemContainerVM>(containers);
        }
Exemplo n.º 3
0
        public CreatureVM(GameVM game, AmfObject obj)
            : base(obj)
        {
            Game = game;

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

            GameVM.ImportUnknownStorageClassEntries(PerksArray, xmlPerks, unknownPerkGroup.Perks);
            UpdatePerks();

            // KeyItems
            var xmlKeys             = XmlData.Current.KeyItemGroups.SelectMany(x => x.KeyItems).ToArray();
            var unknownKeyItemGroup = XmlData.Current.KeyItemGroups.Last();

            GameVM.ImportUnknownStorageClassEntries(KeyItemsArray, xmlKeys, unknownKeyItemGroup.KeyItems);
            UpdateKeyItems();

            // Statuses
            var xmlStatusEffects          = XmlData.Current.StatusEffectGroups.SelectMany(x => x.StatusEffects).ToArray();
            var unknownStatusEffectsGroup = XmlData.Current.StatusEffectGroups.Last();

            GameVM.ImportUnknownStorageClassEntries(StatusEffectsArray, xmlStatusEffects, unknownStatusEffectsGroup.StatusEffects);
            UpdateStatusEffects();
        }
Exemplo n.º 4
0
        public GameVM(AmfFile file, GameVM previousVM)
            : base(file)
        {
            SetCharacterOptions();
            setCharacter("PC");

            _flags = new GeneralObjectVM(GetObj("flags"));

            // Perks
            var charPerks = Character.GetObj("perks");

            if (null == charPerks)
            {
                charPerks = new Model.AmfObject(AmfTypes.Array);
            }
            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);

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

                var groupVM = new PerkGroupVM(this, xmlGroup.Name, perksVM);
                PerkGroups.Add(groupVM);
            }
            ;
        }
Exemplo n.º 5
0
        public ShipVM(GameVM game, AmfObject obj)
            : base(game, obj)
        {
            // Perks
            var xmlPerks         = XmlData.Current.PerkGroups.SelectMany(x => x.Perks).ToArray();
            var unknownPerkGroup = XmlData.Current.PerkGroups.Last();

            GameVM.ImportUnknownStorageClassEntries(PerksArray, xmlPerks, unknownPerkGroup.Perks);
            UpdatePerks();
        }
Exemplo n.º 6
0
        public FlagVM(GameVM game, ref AmfObject flags, XmlEnum data)
        {
            _game        = game;
            _name        = data != null ? data.Name : "";
            _description = data != null ? data.Description : "";

            _flagsObject = flags;
            _flags       = new GeneralObjectVM(flags);
            bool hasFlag = _flags.HasValue(_name);

            if (hasFlag)
            {
                _flagValue = _flagsObject[_name];
            }
            GameVMProperties = new HashSet <string>();
        }
Exemplo n.º 7
0
        public CharacterVM(GameVM game, AmfObject obj)
            : base(obj)
        {
            Game = game;

            Breasts = new BreastArrayVM(game, GetObj("breastRows"));
            Vaginas = new VaginaArrayVM(game, GetObj("vaginas"));
            Cocks   = new CockArrayVM(game, GetObj("cocks"));
            Ass     = new VaginaVM(game, GetObj("ass"));

            var containers = new List <ItemContainerVM>();

            _inventory = new ItemContainerVM(this, "Inventory", ItemCategories.All);
            containers.Add(_inventory);
            UpdateInventory();

            // Complete slots creation
            ItemContainers = new UpdatableCollection <ItemContainerVM>(containers);
        }
Exemplo n.º 8
0
 public VaginaArrayVM(GameVM game, AmfObject obj)
     : base(obj, x => new VaginaVM(game, x))
 {
 }
Exemplo n.º 9
0
 public VaginaVM(GameVM game, AmfObject obj)
     : base(obj)
 {
     _game = game;
 }
Exemplo n.º 10
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)));
        }
Exemplo n.º 11
0
 public KeyItemVM(GameVM game, AmfObject keyItems, XmlStorageClass xml)
     : base(game, keyItems, xml)
 {
 }
Exemplo n.º 12
0
 public PerkVectorVM(GameVM game, AmfObject perksArray, XmlNamedVector4 xml)
     : base(game, perksArray, xml)
 {
 }
Exemplo n.º 13
0
 public BreastsVM(GameVM game, AmfObject obj)
     : base(obj)
 {
     _game = game;
 }
Exemplo n.º 14
0
        public void Load(string path, SerializationFormat expectedFormat, bool createBackup)
        {
            FileManager.TryRegisterExternalFile(path);
            var file        = new AmfFile(path);
            var dataVersion = file.GetString("version");

            if (file.Error != null)
            {
                var box = new ExceptionBox();
                box.Title            = "Could not read file.";
                box.Message          = "TiTsEd could not read this file correctly. Maybe it was corrupted or generated by an old version of Flash. Continuing may make TiTsEd unstable or cause it to corrupt the file. It is strongly advised that you cancel this operation.";
                box.Path             = file.FilePath;
                box.ExceptionMessage = file.Error.Mesg;
                box.IsWarning        = true;
                var result = box.ShowDialog(ExceptionBoxButtons.Continue, ExceptionBoxButtons.Cancel);

                Logger.Error(file.Error.Mesg);
                if (result != ExceptionBoxResult.Continue)
                {
                    return;
                }
            }
            else if (String.IsNullOrEmpty(dataVersion))
            {
                var box = new ExceptionBox();
                box.Title     = "File version too old.";
                box.Message   = "TiTsEd may not be able to read this file correctly as it was generated by an older version of T**s. Continuing may make TiTsEd unstable or cause it to corrupt the file. It is strongly advised that you cancel this operation.";
                box.IsWarning = true;
                var result = box.ShowDialog(ExceptionBoxButtons.Continue, ExceptionBoxButtons.Cancel);

                Logger.Error(String.Format("{0} T**s data version: {1}.", box.Title, dataVersion));
                if (result != ExceptionBoxResult.Continue)
                {
                    return;
                }
            }

            // I would like to test dataVersion here some day to ensure that it's not too old of a version,
            // however, as long as Fen keeps occasionally pushing crappy version strings (e.g. 0.8.4.8d),
            // that can't happen.  Ideally, I'd like to see them switch to a segmented version system.

            // Sanity checks: see if the save can be re-saved as-is OR if any of the top-level property names are invalid as identifiers.
            if (!file.CanBeSaved(SerializationFormat.Slot) || HasBadPropertyNames(file))
            {
                var box = new ExceptionBox();
                box.Title     = "File could not be read correctly.";
                box.Message   = "TiTsEd could not read this file correctly, it is likely corrupted. Cancelling this operation.";
                box.IsWarning = true;
                box.ShowDialog(ExceptionBoxButtons.OK);

                Logger.Error(String.Format("{0} T**s data version: {1}.", box.Title, dataVersion));
                return;
            }

            // Sanity check: ensure the actual format matches the expected format (just a warning to the user about mixing up the formats).
            if (file.Format != expectedFormat)
            {
                var box = new ExceptionBox();
                box.Title     = "File format different from expected format.";
                box.Message   = "The file is actually a " + (file.Format == SerializationFormat.Slot ? "\"Slot\"" : "\"Save to File\"") + " format save, but it was loaded as though it were a " + (expectedFormat == SerializationFormat.Slot ? "\"Slot\"" : "\"Save to File\"") + " format save.\n\nThe two formats are not compatible, so care should be taken to ensure you do not confuse the two, since T**s can only load each format in a specific way.  Attempting to load a \"Slot\" save as though it were a \"Save to File\" save, or vice versa, will cause T**s to think the save is corrupt, at best, or see the save deleted, at worse. Do not mix them up.";
                box.IsWarning = true;
                box.ShowDialog(ExceptionBoxButtons.OK);
            }

            if (createBackup)
            {
                FileManager.CreateBackup(path);
            }
            _currentFile = file;

            XmlData.Select(XmlData.Files.T**s);
            Data = XmlData.Current;
            Game = new GameVM(_currentFile, Game);

            OnPropertyChanged("Data");
            OnPropertyChanged("Game");
            OnPropertyChanged("HasData");
            UpdateAppTitle();
            VM.Instance.NotifySaveRequiredChanged(false);
            if (FileOpened != null)
            {
                FileOpened(null, null);
            }
        }
Exemplo n.º 15
0
 public PerkVM(GameVM game, AmfObject perksArray, XmlStorageClass xml)
     : base(game, perksArray, xml)
 {
 }
Exemplo n.º 16
0
 public PerkGroupVM(GameVM game, string name, PerkVM[] perks)
 {
     _game = game;
     Name  = name;
     Perks = new UpdatableCollection <PerkVM>(perks.Where(x => x.Match(_game.PerkSearchText)));
 }
Exemplo n.º 17
0
 public CockArrayVM(GameVM game, AmfObject obj)
     : base(obj, x => new CockVM(game, x))
 {
 }
Exemplo n.º 18
0
 public CockVM(GameVM game, AmfObject obj)
     : base(obj)
 {
     _game = game;
 }
Exemplo n.º 19
0
 public StatusEffectVM(GameVM game, AmfObject statuses, XmlStorageClass xml)
     : base(game, statuses, xml)
 {
 }
Exemplo n.º 20
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");
        }
Exemplo n.º 21
0
 public ShipArrayVM(GameVM game, AmfObject obj)
     : base(obj, x => new ShipVM(game, x))
 {
 }
Exemplo n.º 22
0
 public CodexEntryVM(GameVM game, XmlCodexEntry data)
 {
     _name            = data.Name;
     Game             = game;
     GameVMProperties = new HashSet <string>();
 }
Exemplo n.º 23
0
 protected NamedVector4VM(GameVM game, AmfObject items, XmlNamedVector4 xml)
 {
     _xml   = xml;
     _game  = game;
     _items = items;
 }
Exemplo n.º 24
0
 protected StorageClassVM(GameVM game, AmfObject items, XmlStorageClass xml)
 {
     _xml   = xml;
     _game  = game;
     _items = items;
 }
Exemplo n.º 25
0
 public BreastArrayVM(GameVM game, AmfObject obj)
     : base(obj, x => new BreastsVM(game, x))
 {
 }
Exemplo n.º 26
0
 public PerkArrayVM(GameVM game, AmfObject obj)
     : base(obj, x => new PerkVM(game, x))
 {
 }