Exemplo n.º 1
0
        void DecodeSaveVariant(KBlam.RuntimeData.Variants.GameEngineVariant gev, string xmlFilename,
                               MegaloModel.MegaloScriptModelTagElementStreamFlags modelStreamFlags, bool ignoreWritePredicates)
        {
            var megalo_variant = gev.TryGetMegaloVariant();

            if (megalo_variant != null)
            {
                megalo_variant.TagElementStreamSerializeFlags =
                    KBlam.RuntimeData.Variants.GameEngineMegaloVariantTagElementStreamFlags.UseStringTableNames |
                    KBlam.RuntimeData.Variants.GameEngineMegaloVariantTagElementStreamFlags.UseUserOptionNames;
                megalo_variant.EngineDefinition.TagElementStreamSerializeFlags =
                    modelStreamFlags;
            }

            using (var xml = IO.XmlElementStream.CreateForWrite("GameVariant"))
            {
                xml.StreamMode            = FileAccess.Write;
                xml.IgnoreWritePredicates = ignoreWritePredicates;

                gev.Serialize(xml);

                using (var sw = new System.IO.StreamWriter(xmlFilename, false, System.Text.Encoding.UTF8))
                    xml.Document.Save(sw);
            }
        }
Exemplo n.º 2
0
        internal static bool EmbedObjects(this MegaloModel.MegaloScriptModelTagElementStreamFlags flags)
        {
            const MegaloModel.MegaloScriptModelTagElementStreamFlags k_mask =
                MegaloModel.MegaloScriptModelTagElementStreamFlags.EmbedObjects;

            return((flags & k_mask) == k_mask);
        }
Exemplo n.º 3
0
        internal static bool HasParamFlags(this MegaloModel.MegaloScriptModelTagElementStreamFlags flags)
        {
            const MegaloModel.MegaloScriptModelTagElementStreamFlags k_mask =
                MegaloModel.MegaloScriptModelTagElementStreamFlags.kParamsMask;

            return((flags & k_mask) != 0);
        }
Exemplo n.º 4
0
        internal static bool UseActionTypeNames(this MegaloModel.MegaloScriptModelTagElementStreamFlags flags)
        {
            const MegaloModel.MegaloScriptModelTagElementStreamFlags k_mask =
                MegaloModel.MegaloScriptModelTagElementStreamFlags.UseActionTypeNames;

            return((flags & k_mask) == k_mask);
        }
Exemplo n.º 5
0
        void DecodeParseSwitches(string switches,
                                 out MegaloModel.MegaloScriptModelTagElementStreamFlags modelStreamFlags,
                                 ref bool ignoreWritePredicates)
        {
            modelStreamFlags =
                MegaloModel.MegaloScriptModelTagElementStreamFlags.EmbedObjects |
                MegaloModel.MegaloScriptModelTagElementStreamFlags.UseEnumNames |
                MegaloModel.MegaloScriptModelTagElementStreamFlags.UseIndexNames |
                MegaloModel.MegaloScriptModelTagElementStreamFlags.WriteConditionTypeNames |
                MegaloModel.MegaloScriptModelTagElementStreamFlags.WriteActionTypeNames |

                MegaloModel.MegaloScriptModelTagElementStreamFlags.EmbedObjectsWriteSansIds
            ;
            if (switches == null)
            {
                switches = "";
            }
            const string k_switches_ctxt = "GameVariant:Decode";

            bool using_op_names = false;

            if (SwitchIsOn(switches, 0, k_switches_ctxt + ":Megalo", "Use operation names (instead of DBIDs)"))
            {
                EnumFlags.Add(ref modelStreamFlags,
                              MegaloModel.MegaloScriptModelTagElementStreamFlags.UseConditionTypeNames |
                              MegaloModel.MegaloScriptModelTagElementStreamFlags.UseActionTypeNames);

                EnumFlags.Remove(ref modelStreamFlags,
                                 MegaloModel.MegaloScriptModelTagElementStreamFlags.WriteConditionTypeNames |
                                 MegaloModel.MegaloScriptModelTagElementStreamFlags.WriteActionTypeNames);

                using_op_names = true;
            }
            if (SwitchIsOn(switches, 1, k_switches_ctxt + ":Megalo", "Write operation parameter names"))
            {
                EnumFlags.Add(ref modelStreamFlags,
                              MegaloModel.MegaloScriptModelTagElementStreamFlags.WriteParamNames);
            }
            if (SwitchIsOn(switches, 2, k_switches_ctxt + ":Megalo", "Write operation parameter contexts"))
            {
                EnumFlags.Add(ref modelStreamFlags,
                              MegaloModel.MegaloScriptModelTagElementStreamFlags.WriteParamKinds);
            }
            if (mGameBuildAndTarget.Build.IsWithinSameBranch(KBlam.Engine.EngineRegistry.EngineBranchHaloReach) &&
                SwitchIsOn(switches, 3, k_switches_ctxt + ":Megalo", "Try to port Reach operations to H4"))
            {
                if (using_op_names)
                {
                    Console.WriteLine("\tIgnoring switch since you have me writing operation names");
                }
                else
                {
                    EnumFlags.Add(ref modelStreamFlags,
                                  MegaloModel.MegaloScriptModelTagElementStreamFlags.TryToPort);
                }
            }
            if (SwitchIsOn(switches, 4, k_switches_ctxt + ":Megalo", "Don't use enum/index names"))
            {
                EnumFlags.Remove(ref modelStreamFlags,
                                 MegaloModel.MegaloScriptModelTagElementStreamFlags.UseEnumNames |
                                 MegaloModel.MegaloScriptModelTagElementStreamFlags.UseIndexNames);
            }
            if (SwitchIsOn(switches, 5, k_switches_ctxt + ":Megalo", "Serialize with object IDs"))
            {
                EnumFlags.Remove(ref modelStreamFlags,
                                 MegaloModel.MegaloScriptModelTagElementStreamFlags.EmbedObjectsWriteSansIds);
            }
            if (SwitchIsOn(switches, 6, k_switches_ctxt + ":Megalo", "Don't embed objects"))
            {
                EnumFlags.Remove(ref modelStreamFlags,
                                 MegaloModel.MegaloScriptModelTagElementStreamFlags.EmbedObjects |
                                 MegaloModel.MegaloScriptModelTagElementStreamFlags.EmbedObjectsWriteSansIds);
            }
            if (SwitchIsOn(switches, 7, k_switches_ctxt + ":Megalo", "Always write 'default' data"))
            {
                ignoreWritePredicates = true;
            }
        }