Example #1
0
 /// <summary>
 /// Deserialize the species data from the project directory.
 /// </summary>
 /// <param name="deserializer"></param>
 protected override void deserialize(ProjectDeserializer deserializer)
 {
     deserializer.deserializeFile((stream) => {
         if (StructBodyDeserializer.Element.tryDeserializeBracketString(stream.ReadLine(), out string speciesEnum, out string speciesName))
         {
             enumToSpecies.Add(speciesEnum, new PokemonSpecies()
             {
                 Identifier = speciesEnum,
                 Name       = speciesName
             });
         }
     }, "src", "data", "text", "species_names.h");
 }
Example #2
0
 protected override void deserialize(ProjectDeserializer deserializer)
 {
     deserializer.deserializeFile((reader) => {
         if (!StructBodyDeserializer.Element.tryDeserializeBracketString(reader.ReadLine(), out string moveEnum, out string moveName))
         {
             return;
         }
         idToMove.Add(moveEnum, new Move()
         {
             Identifier = moveEnum,
             Name       = moveName
         });
     }, "src", "data", "text", "move_names.h");
 }
Example #3
0
        /// <summary>
        /// Load this database from the project directory.
        /// </summary>
        public void load(ProjectDeserializer deserializer)
        {
            if (PropertyChangedHandler == null)
            {
                PropertyChanged += (sender, e) => IsDirty = !Project.Instance.IsLoading;
            }
            IsLoading = true;
            reset();

            // Check to see if this database needs to be upgraded.
            if (needsUpgrade())
            {
                MessageBoxResult result = MessageBox.Show($"This project contains an unsupported format for the {Name}, " +
                                                          "would you like to try and auto-upgrade?\n" +
                                                          "Note: On failure this may leave the project in an inconsistent state.",
                                                          "Upgrade Project", MessageBoxButton.YesNo);
                if (result == MessageBoxResult.No)
                {
                    throw new System.Exception($"'{Name}' has an unsupported format and the auto-upgrade was rejected.");
                }

                // Try to upgrade the project.
                try {
                    Project.Logger.Info("Upgrading {Database}", Name);
                    upgrade(deserializer, new ProjectSerializer(deserializer.project));
                } catch (Exception e) {
                    Project.Logger.Error(e, "Failed to upgrade {Database} to its expected format", Name);
                    throw e;
                }
            }
            else
            {
                Project.Logger.Info("Loading {Database}", Name);
                deserialize(deserializer);
            }

            IsDirty   = false;
            IsLoading = false;
        }
Example #4
0
 /// <summary>
 /// Upgrade the current format of the project to the new format. This
 /// is called on databases that returned true for `needsUpgrade`.
 /// </summary>
 protected virtual void upgrade(ProjectDeserializer deserializer, ProjectSerializer serializer)
 {
     Debug.Fail("Databases must override 'upgrade' if 'needsUpgrade' returns true");
 }
Example #5
0
 /// <summary>
 /// Deserialize the project data into this database.
 /// </summary>
 protected abstract void deserialize(ProjectDeserializer deserializer);
 /// <summary>
 /// Deserialize the encounter music from within the project directory.
 /// </summary>
 /// <param name="serializer"></param>
 protected override void deserialize(ProjectDeserializer serializer)
 {
     encounterMusic = serializer.parseDefineNames(
         "TRAINER_ENCOUNTER_MUSIC_", "include", "constants", "trainers.h");
 }
Example #7
0
 /// <summary>
 /// Deserialize the battle AI scripts from the project directory.
 /// </summary>
 /// <param name="serializer"></param>
 protected override void deserialize(ProjectDeserializer serializer) => aiScripts = serializer.parseDefineNames("AI_SCRIPT_", "include", "constants", "battle_ai.h");