public ShopGiftInterface(GiftType gift, GraphicsDevice graphics, SpriteFont font, int x, int y, int width, int height, int cost, Action <GiftType, int> buy) { this.font = font; this.GiftType = gift; this.cost = cost; bgImg = new Texture2D(graphics, width, height); bgImg = DrawHelper.AddBorder(bgImg, 3, Color.Gray, Color.LightGray); bgRect = new Rectangle(x, y, width, height); name = Language.Translate(gift.ToString().AddSpaces()) + " " + Language.Translate("Gift"); namePos = new Vector2(bgRect.X + bgRect.Width / 2 - font.MeasureString(name).X / 2, bgRect.Y + SPACING); giftImg = Utilities.GiftImg; giftRect = new Rectangle(bgRect.X + bgRect.Width / 2 - GIFT_SIZE / 2, (int)namePos.Y + SPACING * 3 + (int)font.MeasureString(name).Y, GIFT_SIZE, GIFT_SIZE); giftColor = Gift.GetColor(gift); buyButton = new MenuButton(new System.Action(() => buy?.Invoke(this.GiftType, this.cost)), Language.Translate("Buy") + " (" + cost.ToString() + "c)", 0, 0, true, font, graphics); buyButton.X = bgRect.X + bgRect.Width / 2 - buyButton.Width / 2; buyButton.Y = bgRect.Bottom - buyButton.Height - SPACING; }
public void LangChanged() { buyButton.Text = Language.Translate("Buy") + " (" + cost.ToString() + "c)"; buyButton.X = bgRect.X + bgRect.Width / 2 - buyButton.Width / 2; name = Language.Translate(GiftType.ToString().AddSpaces()) + " " + Language.Translate("Gift"); namePos.X = bgRect.X + bgRect.Width / 2 - font.MeasureString(name).X / 2; }
public GiftInterface(GiftType giftType, GraphicsDevice graphics, int x, int y, int width, int height, SpriteFont font) { this.font = font; bgImg = new Texture2D(graphics, width, height); bgImg = DrawHelper.AddBorder(bgImg, 3, Color.Gray, Color.LightGray); bgRect = new Rectangle(x, y, width, height); openButton = new MenuButton(new System.Action(() => open?.Invoke(Gift)), Language.Translate("Open"), 0, 0, true, font, graphics); openButton.X = bgRect.X + bgRect.Width / 2 - openButton.Width / 2; openButton.Y = bgRect.Bottom - openButton.Height - SPACING; Gift = giftType; giftImg = Utilities.GiftImg; giftRect = new Rectangle(bgRect.X + bgRect.Width / 2 - GIFT_SIZE / 2, bgRect.Y + SPACING, GIFT_SIZE, GIFT_SIZE); giftColor = OneCannonOneArmy.Gift.GetColor(giftType); name = Language.Translate(giftType.ToString()) + " " + Language.Translate("Gift"); namePos = new Vector2(bgRect.X + bgRect.Width / 2 - font.MeasureString(name).X / 2, giftRect.Y + SPACING); }