public Image GetSprite() { return(Sprites.GetSprite(X, Y)); }
public Flower(string id, string color, string background, bool pure, string source) { if (id == "-" || id == "!") { throw new InputException("Flower ID cannot be \"-\" or \"!\""); } ID = id; Color = color; Background = background; Purebred = pure; Source = source; if (!init) { Init(); } string background1 = Background; string background2 = null; if (background1.IndexOf('-') >= 0) { int index = background1.IndexOf('-'); background1 = background.Substring(0, index); background2 = background.Substring(index + 1); } if (!backgrounds.ContainsKey(background1)) { throw new InputException("Unknown background color: " + background1); } if (background2 != null && !backgrounds.ContainsKey(background2)) { throw new InputException("Unknown background color: " + background2); } if (source != null && !sources.ContainsKey(Source)) { throw new InputException("Unknown flower source: " + Source); } Icon = new Bitmap(IconSize, IconSize); Graphics graphics = Graphics.FromImage(Icon); graphics.FillEllipse(borderBrush, 0, 0, IconSize, IconSize); Brush fillBrush; if (background2 == null) { fillBrush = new SolidBrush(backgrounds[background1]); } else { fillBrush = new LinearGradientBrush(new Point(BorderWidth, IconSize / 2), new Point(IconSize - BorderWidth, IconSize / 2), backgrounds[background1], backgrounds[background2]); } graphics.FillEllipse(fillBrush, BorderWidth, BorderWidth, IconSize - 2 * BorderWidth, IconSize - 2 * BorderWidth); fillBrush.Dispose(); Data.GetFlowerColor(Color).DrawSprite(graphics, (IconSize - Sprites.SpriteSize) / 2, (IconSize - Sprites.SpriteSize) / 2); if (source != null) { Sprites.DrawSprite(graphics, 0, IconSize - Sprites.SpriteSize / 2, 0.5f, sources[Source]); } if (pure) { Sprites.DrawSprite(graphics, IconSize - Sprites.SpriteSize / 2, IconSize - Sprites.SpriteSize / 2, 0.5f, Star); } graphics.Dispose(); }
public void DrawSprite(Graphics graphics, int drawX, int drawY) { Sprites.DrawSprite(graphics, drawX, drawY, X, Y); }
public static void Write(string path) { string title = Data.GetName() + " Purebreeding"; string star = "Purebreeding"; string seed = "Purchased Seeds"; string ticket = "Hybrid Mystery Island"; string genes = "Different Backgrounds = Different Genes"; List <BreedingPairSection> sections = new List <BreedingPairSection>(Data.GetBreedingPairSections()); List <Image> sectionPanels = new List <Image>(sections.Select((section) => section.CreateImage())); List <Image>[] columns = SplitToColumns(sectionPanels); int[] columnWidths = new int[columns.Length]; int width = -PanelMargin; int height = 0; for (int k = 0; k < columns.Length; k++) { List <Image> column = columns[k]; int columnWidth = 0; int columnHeight = -PanelMargin; foreach (Image panel in column) { if (panel.Width > columnWidth) { columnWidth = panel.Width; } columnHeight += panel.Height + PanelMargin; } columnWidths[k] = columnWidth; width += columnWidth + PanelMargin; if (columnHeight > height) { height = columnHeight; } } Image content = new Bitmap(width, height); Graphics graphics = Graphics.FromImage(content); int x = 0; int y = 0; int index = 0; for (int k = 0; k < columns.Length; k++) { List <Image> column = columns[k]; int columnWidth = columnWidths[k]; y = 0; foreach (Image panel in column) { if (panel.Width < columnWidth) { graphics.DrawImage(sections[index].CreateImage(columnWidth), x, y); } else { graphics.DrawImage(panel, x, y); } y += panel.Height + PanelMargin; index++; } x += columnWidth + PanelMargin; } SizeF titleSize = graphics.MeasureString(title, TitleFont); SizeF starSize = graphics.MeasureString(star, LegendFont); SizeF seedSize = graphics.MeasureString(seed, LegendFont); SizeF ticketSize = graphics.MeasureString(ticket, LegendFont); SizeF genesSize = graphics.MeasureString(genes, LegendFont); graphics.Dispose(); width = 4 * PanelMargin + Math.Max(content.Width, (int)titleSize.Width); height = 9 * PanelMargin + (int)titleSize.Height + (int)starSize.Height + (int)seedSize.Height + (int)ticketSize.Height + (int)genesSize.Height + content.Height; Image image = new Bitmap(width, height); graphics = Graphics.FromImage(image); graphics.Clear(Background); Brush brush = new SolidBrush(TextColor); Brush borderBrush = new SolidBrush(Color.White); x = (image.Width - (int)titleSize.Width) / 2; y = 2 * PanelMargin; DrawUtils.DrawStringWithBorder(graphics, title, TitleFont, brush, borderBrush, x, y, 8); x = image.Width / 4; y += (int)titleSize.Height + PanelMargin; Sprites.DrawSprite(graphics, x - Sprites.SpriteSize - PanelMargin / 2, y + ((int)starSize.Height - Sprites.SpriteSize) / 2, Flower.Star); DrawUtils.DrawStringWithBorder(graphics, star, LegendFont, brush, borderBrush, x + PanelMargin / 2, y, 4); y += (int)starSize.Height + PanelMargin; Sprites.DrawSprite(graphics, x - Sprites.SpriteSize - PanelMargin / 2, y + ((int)seedSize.Height - Sprites.SpriteSize) / 2, Flower.GetSource("seedred")); DrawUtils.DrawStringWithBorder(graphics, seed, LegendFont, brush, borderBrush, x + PanelMargin / 2, y, 4); y += (int)seedSize.Height + PanelMargin; Sprites.DrawSprite(graphics, x - Sprites.SpriteSize - PanelMargin / 2, y + ((int)ticketSize.Height - Sprites.SpriteSize) / 2, Flower.GetSource("island")); DrawUtils.DrawStringWithBorder(graphics, ticket, LegendFont, brush, borderBrush, x + PanelMargin / 2, y, 4); y += (int)ticketSize.Height + PanelMargin; x = (image.Width - (int)genesSize.Width) / 2; DrawUtils.DrawStringWithBorder(graphics, genes, LegendFont, brush, borderBrush, x, y, 4); y += (int)genesSize.Height + PanelMargin; brush.Dispose(); borderBrush.Dispose(); graphics.DrawImage(content, (image.Width - content.Width) / 2, y); graphics.Dispose(); image.Save(path + ".png", ImageFormat.Png); }