Ejemplo n.º 1
0
Archivo: Macros.cs Proyecto: zBart/Ares
 public TagCommand(System.Xml.XmlReader reader)
     : base(reader)
 {
     m_CategoryId = reader.GetIntegerAttribute("categoryId");
     m_TagId      = reader.GetIntegerAttribute("tagId");
     m_AddTag     = reader.GetBooleanAttribute("addTag");
     ReadToEndOfElement(reader);
 }
Ejemplo n.º 2
0
        internal MusicByTags(System.Xml.XmlReader reader)
            : base(reader)
        {
            m_Tags = new Dictionary <int, HashSet <int> >();
            bool isOperatorAnd          = reader.GetBooleanAttributeOrDefault("IsOperatorAnd", true);
            int  tagCategoryCombination = reader.GetIntegerAttributeOrDefault("TagCategoryCombination", -1);

            if (tagCategoryCombination >= (int)Data.TagCategoryCombination.UseAnyTag && tagCategoryCombination <= (int)Data.TagCategoryCombination.UseAllTags)
            {
                TagCategoryCombination = (Data.TagCategoryCombination)tagCategoryCombination;
            }
            else
            {
                TagCategoryCombination = isOperatorAnd ? Data.TagCategoryCombination.UseOneTagOfEachCategory : Data.TagCategoryCombination.UseAnyTag;
            }
            FadeTime = reader.GetIntegerAttributeOrDefault("FadeTime", 0);
            if (reader.IsEmptyElement)
            {
                XmlHelpers.ThrowException(StringResources.ExpectedContent, reader);
            }
            reader.Read();
            while (reader.IsStartElement())
            {
                if (reader.IsStartElement("Tags") && !reader.IsEmptyElement)
                {
                    reader.Read();
                    while (reader.IsStartElement())
                    {
                        if (reader.IsStartElement("Tag"))
                        {
                            int category = reader.GetIntegerAttribute("Category");
                            int tag      = reader.GetIntegerAttribute("Tag");
                            AddTag(category, tag);
                            reader.ReadOuterXml();
                        }
                        else
                        {
                            reader.ReadOuterXml();
                        }
                    }
                    reader.ReadEndElement();
                }
                else
                {
                    reader.ReadOuterXml();
                }
            }
            reader.ReadEndElement();
        }
Ejemplo n.º 3
0
 public ReferenceHolder(System.Xml.XmlReader reader, String name)
 {
     ReferencedId = reader.GetIntegerAttribute(name);
     if (DataModule.TheElementRepository.Redirector != null)
     {
         DataModule.TheElementRepository.Redirector.AddReferenceHolder(this);
     }
 }
Ejemplo n.º 4
0
 public ChoiceElement(System.Xml.XmlReader reader)
 {
     if (reader.IsEmptyElement)
     {
         XmlHelpers.ThrowException(StringResources.ExpectedContent, reader);
     }
     RandomChance = reader.GetIntegerAttribute("chance");
     reader.Read();
     DoReadFromXml(reader);
     reader.ReadEndElement();
 }
Ejemplo n.º 5
0
 protected Trigger(System.Xml.XmlReader reader)
 {
     StopMusic       = reader.GetBooleanAttribute("stopMusic");
     StopSounds      = reader.GetBooleanAttribute("stopSounds");
     TargetElementId = reader.GetIntegerAttribute("targetId");
     CrossFadeMusic  = reader.GetBooleanAttributeOrDefault("crossFadeMusic", false);
     FadeMusic       = reader.GetBooleanAttributeOrDefault("fadeMusic", false);
     FadeMusicTime   = reader.GetIntegerAttributeOrDefault("crossFadeMusicTime", 0);
     FadeSounds      = reader.GetBooleanAttributeOrDefault("fadeSounds", false);
     FadeSoundTime   = reader.GetIntegerAttributeOrDefault("fadeSoundTime", 0);
 }
Ejemplo n.º 6
0
        internal static AdditionalChoiceData ReadAdditionalData(System.Xml.XmlReader reader)
        {
            AdditionalChoiceData data = new AdditionalChoiceData();

            data.FixedStartDelay                = TimeSpan.FromMilliseconds(reader.GetIntegerAttribute("FixedStartDelay"));
            data.MaximumRandomStartDelay        = TimeSpan.FromMilliseconds(reader.GetIntegerAttribute("RandomStartDelay"));
            data.FixedIntermediateDelay         = TimeSpan.FromMilliseconds(reader.GetIntegerAttribute("FixedInterDelay"));
            data.MaximumRandomIntermediateDelay = TimeSpan.FromMilliseconds(reader.GetIntegerAttribute("RandomInterDelay"));
            data.RepeatCount = reader.GetIntegerAttribute("RepeatCount");
            if (reader.IsEmptyElement)
            {
                reader.Read();
            }
            else
            {
                reader.Read();
                reader.ReadInnerXml();
                reader.ReadEndElement();
            }
            return(data);
        }
Ejemplo n.º 7
0
Archivo: Macros.cs Proyecto: zBart/Ares
 public MacroCondition(System.Xml.XmlReader reader, String name)
 {
     ConditionType = (MacroConditionType)reader.GetIntegerAttribute(name + "ConditionType");
     if (reader.GetAttribute(name + "ConditionElement") != null)
     {
         m_Reference = new ReferenceHolder(reader, name + "ConditionElement");
     }
     else
     {
         m_Reference = null;
     }
 }
Ejemplo n.º 8
0
        internal BackgroundSounds(System.Xml.XmlReader reader)
            : base(reader)
        {
            m_Elements = new List <IBackgroundSoundChoice>();
            int id = reader.GetIntegerAttribute("ContainerId");

            m_Container = DataModule.TheElementFactory.CreateParallelContainer(Title + "_Parallel", id);

            if (reader.IsEmptyElement)
            {
                XmlHelpers.ThrowException(StringResources.ExpectedContent, reader);
            }
            reader.Read();
            while (reader.IsStartElement())
            {
                if (reader.IsStartElement("SubElements") && !reader.IsEmptyElement)
                {
                    reader.Read();
                    while (reader.IsStartElement())
                    {
                        if (reader.IsStartElement("BackgroundSoundChoice"))
                        {
                            BackgroundSoundChoice choice          = new BackgroundSoundChoice(reader);
                            IParallelElement      parallelElement = m_Container.AddElement(choice);
                            parallelElement.RepeatCount = -1;
                            choice.ParallelElement      = parallelElement;
                            if (reader.IsStartElement("ParallelElementData"))
                            {
                                AdditionalChoiceData data = ReadAdditionalData(reader);
                                parallelElement.FixedStartDelay                = data.FixedStartDelay;
                                parallelElement.MaximumRandomStartDelay        = data.MaximumRandomStartDelay;
                                parallelElement.FixedIntermediateDelay         = data.FixedIntermediateDelay;
                                parallelElement.MaximumRandomIntermediateDelay = data.MaximumRandomIntermediateDelay;
                                parallelElement.RepeatCount = data.RepeatCount;
                            }
                            m_Elements.Add(choice);
                        }
                        else
                        {
                            reader.ReadOuterXml();
                        }
                    }
                    reader.ReadEndElement();
                }
                else
                {
                    reader.ReadOuterXml();
                }
            }

            reader.ReadEndElement();
        }
Ejemplo n.º 9
0
        public ParallelElement(System.Xml.XmlReader reader)
        {
            if (reader.IsEmptyElement)
            {
                XmlHelpers.ThrowException(StringResources.ExpectedContent, reader);
            }
            FixedStartDelay                = reader.GetTimeSpanAttribute("fixedDelay");
            MaximumRandomStartDelay        = reader.GetTimeSpanAttribute("maxDelay");
            RepeatCount                    = reader.GetIntegerAttribute("repeatCount");
            FixedIntermediateDelay         = reader.GetTimeSpanAttribute("fixedIntermediateDelay");
            MaximumRandomIntermediateDelay = reader.GetTimeSpanAttribute("maxIntermediateDelay");

            reader.Read();
            DoReadFromXml(reader);
            reader.ReadEndElement();
        }
Ejemplo n.º 10
0
        protected ElementBase(System.Xml.XmlReader reader)
        {
            m_ID            = reader.GetIntegerAttribute("Id");
            Title           = reader.GetNonEmptyAttribute("Title");
            SetsMusicVolume = reader.GetBooleanAttributeOrDefault("SetsMusicVolume", false);
            SetsSoundVolume = reader.GetBooleanAttributeOrDefault("SetsSoundVolume", false);
            MusicVolume     = reader.GetIntegerAttributeOrDefault("MusicVolume", 100);
            if (MusicVolume < 0 || MusicVolume > 100)
            {
                XmlHelpers.ThrowException(StringResources.InvalidVolume, reader);
            }
            SoundVolume = reader.GetIntegerAttributeOrDefault("SoundVolume", 100);
            if (SoundVolume < 0 || SoundVolume > 100)
            {
                XmlHelpers.ThrowException(StringResources.InvalidVolume, reader);
            }

            DataModule.TheElementRepository.AddElement(ref m_ID, this);
            DataModule.TheElementFactory.UpdateNextID(m_ID);
        }
Ejemplo n.º 11
0
        public ReferenceElement(System.Xml.XmlReader reader)
            : base(reader)
        {
            ReferencedId = reader.GetIntegerAttribute("ReferencedId");
            if (DataModule.TheElementRepository.Redirector != null)
            {
                DataModule.TheElementRepository.Redirector.AddReferenceHolder(this);
            }

            if (!reader.IsEmptyElement)
            {
                reader.Read();
                reader.ReadInnerXml();
                reader.ReadEndElement();
            }
            else
            {
                reader.Read();
            }
        }
Ejemplo n.º 12
0
 internal Mode(System.Xml.XmlReader reader)
 {
     m_Elements = new List <IModeElement>();
     Title      = reader.GetNonEmptyAttribute("Title");
     KeyCode    = reader.GetIntegerAttribute("Key");
     if (!reader.IsEmptyElement)
     {
         reader.Read();
         while (reader.IsStartElement())
         {
             if (reader.IsStartElement("Elements") && !reader.IsEmptyElement)
             {
                 reader.Read();
                 while (reader.IsStartElement())
                 {
                     if (reader.IsStartElement("ModeElement"))
                     {
                         ModeElement element = new ModeElement(reader);
                         if (element.StartElement != null)
                         {
                             m_Elements.Add(element);
                         }
                     }
                     else
                     {
                         reader.ReadOuterXml();
                     }
                 }
                 reader.ReadEndElement();
             }
             else
             {
                 reader.ReadOuterXml();
             }
         }
         reader.ReadEndElement();
     }
 }
Ejemplo n.º 13
0
        internal Project(System.Xml.XmlReader reader, String fileName)
        {
            m_Modes = new List <IMode>();

            if (!reader.IsStartElement("Project"))
            {
                XmlHelpers.ThrowException(String.Format(StringResources.ExpectedElement, "Project"), reader);
            }
            Title         = reader.GetNonEmptyAttribute("Title");
            TagLanguageId = reader.GetIntegerAttributeOrDefault("LanguageId", -1);
            if (!reader.IsEmptyElement)
            {
                reader.Read();
                while (reader.IsStartElement())
                {
                    if (reader.IsStartElement("Modes") && !reader.IsEmptyElement)
                    {
                        reader.Read();
                        while (reader.IsStartElement())
                        {
                            if (reader.IsStartElement("Mode"))
                            {
                                m_Modes.Add(new Mode(reader));
                            }
                            else
                            {
                                reader.ReadOuterXml();
                            }
                        }
                        reader.ReadEndElement();
                    }
                    else if (reader.IsStartElement("HiddenTagCategories") && !reader.IsEmptyElement)
                    {
                        reader.Read();
                        while (reader.IsStartElement())
                        {
                            if (reader.IsStartElement("TagCategory"))
                            {
                                int id = reader.GetIntegerAttribute("id");
                                m_HiddenTagCategories.Add(id);
                            }
                            reader.ReadOuterXml();
                        }
                        reader.ReadEndElement();
                    }
                    else if (reader.IsStartElement("HiddenTags") && !reader.IsEmptyElement)
                    {
                        reader.Read();
                        while (reader.IsStartElement())
                        {
                            if (reader.IsStartElement("Tag"))
                            {
                                int id = reader.GetIntegerAttribute("id");
                                m_HiddenTags.Add(id);
                            }
                            reader.ReadOuterXml();
                        }
                        reader.ReadEndElement();
                    }
                    else
                    {
                        reader.ReadOuterXml();
                    }
                }
                reader.ReadEndElement();
            }
            else
            {
                reader.Read();
            }
            FileName = fileName;
            Changed  = false;
        }
Ejemplo n.º 14
0
Archivo: Macros.cs Proyecto: zBart/Ares
 public WaitTimeCommand(System.Xml.XmlReader reader)
     : base(reader)
 {
     TimeInMillis = reader.GetIntegerAttribute("TimeMs");
     ReadToEndOfElement(reader);
 }
Ejemplo n.º 15
0
 internal ElementFinishTrigger(System.Xml.XmlReader reader)
     : base(reader)
 {
     ElementId = reader.GetIntegerAttribute("elementId");
     reader.ReadOuterXml();
 }
Ejemplo n.º 16
0
 internal KeyTrigger(System.Xml.XmlReader reader)
     : base(reader)
 {
     KeyCode = reader.GetIntegerAttribute("Key");
     reader.ReadOuterXml();
 }