コード例 #1
0
 uint loadHash(xElement element)
 {
     if (element != null)
     {
         if (element.Attribute("hash"))
         {
             return(parseU32(element.Attribute("element")));
         }
         else if (element.Attribute("name") != null)
         {
             return(hash.calculate(element.Attribute("name")));
         }
     }
     return(0u);
 }
コード例 #2
0
ファイル: whap.cs プロジェクト: impiaaa/flaaffy
        WaveGroup LoadWaveGroup(xElement xwavegroup)
        {
            var waveGroup = new WaveGroup();

            var xarchive = xwavegroup.Attribute(cWaveArchive);

            if (xarchive == null)
            {
                mareep.WriteWarning("XML: line #{0}: missing archive attribute\n", xwavegroup.LineNumber);
                return(null);
            }

            waveGroup.ArchiveFileName = xarchive.Value;

            foreach (var xwave in xwavegroup.Elements(cWave))
            {
                var wave = LoadWave(xwave);

                if (wave != null)
                {
                    waveGroup.Add(wave);
                }
            }

            return(waveGroup);
        }
コード例 #3
0
ファイル: whap.cs プロジェクト: impiaaa/flaaffy
        WaveBank LoadWaveBank(xElement xwavebank)
        {
            var waveBank = new WaveBank();

            var xname = xwavebank.Attribute("name");

            if (xname == null)
            {
                waveBank.Name = mName;
            }
            else
            {
                waveBank.Name = xname.Value;
            }

            foreach (var xwavegroup in xwavebank.Elements(cWaveGroup))
            {
                var waveGroup = LoadWaveGroup(xwavegroup);

                if (waveGroup != null)
                {
                    waveBank.Add(waveGroup);
                }
            }

            return(waveBank);
        }
コード例 #4
0
        protected virtual void loadXml(xElement element)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            mName = convertStringToName(element.Attribute("id") | "");
            setConnectParent(element.Attribute("connect") | false);
            mVisible = (element.Attribute("visible") | true);
            mRect    = bloXml.loadRectangle(element.Element("rectangle"));
            mAngle   = ((element.Element("angle") | 0) % 360);
            if (!Enum.TryParse <bloAnchor>(element.Element("anchor"), true, out mAnchor))
            {
                mAnchor = bloAnchor.TopLeft;
            }
            if (!Enum.TryParse <gxCullMode>(element.Element("cull-mode"), true, out mCullMode))
            {
                mCullMode = gxCullMode.None;
            }
            mAlpha        = (byte)bloMath.clamp((element.Element("alpha") | 255), 0, 255);
            mInheritAlpha = (element.Element("alpha").Attribute("inherit") | true);
        }
コード例 #5
0
ファイル: resource.cs プロジェクト: luigimansion1/blojob
        public T find <T>(xElement element, string directory, out bloResourceType type)
            where T : bloResource, new()
        {
            type = bloResourceType.None;
            if (element == null)
            {
                return(null);
            }
            var attr = element.Attribute("scope");

            if (attr == null || !Enum.TryParse <bloResourceType>(attr, true, out type))
            {
                type = bloResourceType.LocalDirectory;
            }
            string name     = element.Value;
            T      resource = find <T>(type, name, directory);

            if (resource == null && type != bloResourceType.None)
            {
                Console.WriteLine(">>> FAILED: could not find {0} resource '{1}'", type, name);
            }
            return(resource);
        }
コード例 #6
0
ファイル: whap.cs プロジェクト: impiaaa/flaaffy
        Wave LoadWave(xElement xwave)
        {
            xAttribute attribute;

            var wave = new Wave();

            attribute = xwave.Attribute(cWaveId);

            if (attribute == null)
            {
                mareep.WriteWarning("XML: line #{0}: missing wave id\n", xwave.LineNumber);
                return(null);
            }

            var waveid = (attribute | -1);

            if (waveid < 0)
            {
                mareep.WriteWarning("XML: line #{0}: bad wave id '{1}'\n", attribute.LineNumber, attribute.Value);
                return(null);
            }

            wave.WaveId = waveid;

            attribute = xwave.Attribute(cWaveFile);

            if (attribute == null)
            {
                mareep.WriteWarning("XML: line #{0}: missing file\n", xwave.LineNumber);
                return(null);
            }

            wave.FileName = attribute.Value;

            attribute = xwave.Attribute(cWaveFormat);

            if (attribute == null)
            {
                mareep.WriteWarning("XML: line #{0}: missing format\n", xwave.LineNumber);
                return(null);
            }

            var format = attribute.AsEnum((WaveFormat)(-1));

            if (!format.IsDefined())
            {
                mareep.WriteWarning("XML: line #{0}: bad wave format '{1}'\n", attribute.LineNumber, attribute.Value);
                return(null);
            }

            wave.Format = format;

            attribute = xwave.Attribute(cWaveRate);

            if (attribute != null)
            {
                var samplerate = (attribute | -1.0f);

                if (samplerate < 0.0f)
                {
                    mareep.WriteWarning("XML: line #{0}: bad sample rate '{1:F1}'.\n", attribute.LineNumber, attribute.Value);
                    return(null);
                }

                wave.SampleRate = samplerate;
            }

            attribute = xwave.Attribute(cWaveKey);

            var keynumber = 60;

            if (attribute != null)
            {
                keynumber = attribute.AsKeyNumber();

                if (keynumber < 0 || keynumber > 127)
                {
                    mareep.WriteWarning("XML: line #{0}: bad root key '{1}'\n", attribute.LineNumber, attribute.Value);
                    return(null);
                }
            }

            wave.RootKey = keynumber;

            var xloopstart = xwave.Attribute(cWaveLoopStart);
            var xloopend   = xwave.Attribute(cWaveLoopEnd);

            if (xloopstart != null && xloopend != null)
            {
                var loopstart = (xloopstart | -1);
                var loopend   = (xloopend | -1);

                if (loopstart < 0)
                {
                    mareep.WriteWarning("XML: line #{0}: bad loop start '{0}'\n", xloopstart.LineNumber, xloopstart.Value);
                    return(null);
                }
                else if (loopend < 0)
                {
                    mareep.WriteWarning("XML: line #{0}: bad loop end '{0}'\n", xloopend.LineNumber, xloopend.Value);
                    return(null);
                }

                wave.Loop      = true;
                wave.LoopStart = loopstart;
                wave.LoopEnd   = loopend;
            }
            else if ((xloopstart == null) != (xloopend == null))
            {
                mareep.WriteWarning("XML: line #{0}: only one loop specified.\n", (xloopstart ?? xloopend).LineNumber);
                return(null);
            }

            return(wave);
        }