Exemplo n.º 1
0
        private void LoadSde(Stream stream)
        {
            ZipArchive zip = new ZipArchive(stream, ZipArchiveMode.Read);

            _descJson = JObject.Parse(EntryToString(zip.GetEntry(SDEConstants.DESCRIPTOR_FILENAME)));

            foreach (ZipArchiveEntry entry in zip.Entries)
            {
                if (SDEConstants.IsEmitterXmlName(entry.Name))
                {
                    string         emitterId = SDEConstants.GetEmitterId(entry.Name);
                    RawEmitterData rawData   = new RawEmitterData();
                    rawData.EmitterId     = emitterId;
                    rawData.EmitterString = EntryToString(entry);
                    // + parse snapshot
                    var snapshot = zip.GetEntry(SDEConstants.GetParticleSnapshotName(emitterId));
                    if (snapshot != null)
                    {
                        rawData.Snapshot = snapshot.Open();
                    }
                    _rawEmitterDatas.Add(rawData);
                }
            }
            // texture atlas
            var    atlasZipEntry  = zip.GetEntry(SDEConstants.ATLAS_XML_NAME);
            string atlasXmlString = EntryToString(atlasZipEntry);

            var     atlasImageEntry = zip.GetEntry(SDEConstants.ATLAS_IMAGE_NAME);
            Texture tex             = SimpleTextureLoader.LoadImageFromStream(atlasImageEntry.Open());

            _atlas = new TextureAtlas(atlasXmlString, tex);

            _projectLoaded = true;
        }
Exemplo n.º 2
0
        public Benchmark()
        {
            // NOTE: Removing this breaks the app on some Nvidia cards!
            SparrowSharp.EnableErrorChecking();

            EmbeddedResourceLoader loader = new EmbeddedResourceLoader("SparrowSamples");

            textures = new[] { SimpleTextureLoader.LoadImageFromStream(loader.GetEmbeddedResourceStream("bigstar.png")),
                               SimpleTextureLoader.LoadImageFromStream(loader.GetEmbeddedResourceStream("benchmark_object.png")),
                               SimpleTextureLoader.LoadImageFromStream(loader.GetEmbeddedResourceStream("scaleGridTest.png")) };

            // the container will hold all test objects
            _container = new Sprite();
            AddChild(_container);

            EnterFrame   += EnterFrameHandler;
            AddedToStage += AddedToStageHandler;
            //SparrowSharp.SkipUnchangedFrames = true;
            SparrowSharp.Stage.Color = 0x432323;
        }
Exemplo n.º 3
0
        private void ParseFontData(Stream fontTextureData, Stream fontXmlData)
        {
            if (fontTextureData == null || fontXmlData == null)
            {
                throw new InvalidOperationException("Font parsing requires texture and font XML to be set");
            }

            Name       = "unknown";
            LineHeight = Size = Baseline = 14;
            OffsetX    = OffsetY = Padding = 0.0f;

            _texture     = SimpleTextureLoader.LoadImageFromStream(fontTextureData);
            _chars       = new Dictionary <int, BitmapChar>();
            _helperImage = new Image(_texture);

            XmlDocument xml = new XmlDocument();

            xml.Load(fontXmlData);

            ParseFontXml(xml);
        }