private void PrepareFontImageSheets() { ImageSheet outlineMonoCharSheet = new ImageSheet(settings.MaxImageSheetWidth, settings.MaxImageSheetHeight, 2, 1); ImageSheet normalMonoCharSheet = new ImageSheet(settings.MaxImageSheetWidth, settings.MaxImageSheetHeight, 0, 0); outlineMonoCharSheet.ClearColor = Color.Black; outlineMonoCharSheet.MakeTransparent = true; normalMonoCharSheet.ClearColor = Color.Black; normalMonoCharSheet.MakeTransparent = true; fonts = GetFonts(); foreach (AgsFont font in fonts) { foreach (AgsFontChar c in font.Chars) { if (c == null || c.Width == 0 || c.Height == 0) { continue; } if (font.font.OutlineStyle == AGS.Types.FontOutlineStyle.Automatic) { outlineMonoCharSheet.AddEntry(c); } else { normalMonoCharSheet.AddEntry(c); } } } if (!normalMonoCharSheet.IsEmpty) { if (!normalMonoCharSheet.Pack()) { throw new Exception("Cannot pack normal fonts!"); } GameImageSheets.Add(normalMonoCharSheet); } if (!outlineMonoCharSheet.IsEmpty) { if (!outlineMonoCharSheet.Pack()) { throw new Exception("Cannot pack outline fonts!"); } GameImageSheets.Add(outlineMonoCharSheet); } }
private void ExportSpriteFolder( AGS.Types.ISpriteFolder folder, ImageSheet toMaskSheet, List<ImageSheet> completeImageSheets, bool alpha, bool topLevel) { if (toMaskSheet == null) { toMaskSheet = new ImageSheet(settings.MaxImageSheetWidth, settings.MaxImageSheetHeight, 0, 0); if (!alpha) { toMaskSheet.ClearColor = HacksAndKludges.GetTransparencyColor(); toMaskSheet.MakeTransparent = true; } foreach (AGS.Types.Sprite sprite in folder.Sprites) { if ((alpha && !sprite.AlphaChannel) || (!alpha && sprite.AlphaChannel)) { continue; } if (sprite.Width > settings.MaxImageSheetWidth || sprite.Height > settings.MaxImageSheetHeight) { throw new Exception("Sprite #" + sprite.Number + " is bigger than the maximum image sheet size"); } SpriteImageSheetEntry entry; if (alpha) { entry = new SpriteImageSheetEntry(editor, sprite, Color.Transparent); } else { entry = new SpriteImageSheetEntry(editor, sprite, HacksAndKludges.GetTransparencyColor()); } if (!toMaskSheet.AddEntry(entry)) { if (!toMaskSheet.IsEmpty) { completeImageSheets.Add(toMaskSheet); } toMaskSheet = new ImageSheet(settings.MaxImageSheetWidth, settings.MaxImageSheetHeight, 0, 0); } } } else { object maskSnapshot = toMaskSheet.Snapshot(); foreach (AGS.Types.Sprite sprite in folder.Sprites) { if ((alpha && !sprite.AlphaChannel) || (!alpha && sprite.AlphaChannel)) { continue; } if (sprite.Width > settings.MaxImageSheetWidth || sprite.Height > settings.MaxImageSheetHeight) { throw new Exception("Sprite #" + sprite.Number + " is bigger than the maximum image sheet size"); } SpriteImageSheetEntry entry; if (alpha) { entry = new SpriteImageSheetEntry(editor, sprite, Color.Transparent); } else { entry = new SpriteImageSheetEntry(editor, sprite, HacksAndKludges.GetTransparencyColor()); } if (!toMaskSheet.AddEntry(entry)) { toMaskSheet.RestoreSnapshot(maskSnapshot); ExportSpriteFolder(folder, null, completeImageSheets, alpha, true); return; } } } int insert = completeImageSheets.Count; foreach (AGS.Types.SpriteFolder subfolder in folder.SubFolders) { ExportSpriteFolder(subfolder, toMaskSheet, completeImageSheets, alpha, false); } if (topLevel && !toMaskSheet.IsEmpty) { completeImageSheets.Insert(insert, toMaskSheet); } }