Beispiel #1
0
        public async Task UpdateSpriteAsync(string spriteFileName, bool isBuild = false)
        {
            if (!spriteFileName.EndsWith(".sprite", StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            try
            {
                SpriteDocument doc = await SpriteDocument.FromFile(spriteFileName);

                if (doc == null)
                {
                    throw new Exception();
                }

                if (!isBuild || doc.RunOnBuild)
                {
                    await GenerateAsync(doc, true);
                }
            }
            catch (FileNotFoundException ex)
            {
                Logger.Log(ex.Message);
                Logger.Log("The file '" + Path.GetFileName(ex.Message) + "' does not exist");
                _dte.StatusBar.Text = "Sprite was not created";
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
                Logger.Log("Error generating the sprite. See output window for details");
            }
        }
Beispiel #2
0
 private async Task UpdateSpriteAsync()
 {
     try
     {
         await Task.WhenAll(_sprites.Select(async file =>
         {
             SpriteDocument doc = SpriteDocument.FromFile(file);
             await GenerateAsync(doc);
         }));
     }
     catch (FileNotFoundException ex)
     {
         Logger.Log(ex.Message);
         MessageBox.Show("The file '" + Path.GetFileName(ex.Message) + "' does not exist");
         _dte.StatusBar.Text = "Sprite was not created";
     }
     catch (Exception ex)
     {
         Logger.Log(ex);
         MessageBox.Show("Error generating the sprite. See output window for details");
     }
 }
 public async Task <IBundleDocument> LoadFromFile(string fileName)
 {
     return(await SpriteDocument.FromFile(fileName));
 }