public void doOpenPack(bool initialClick) { if (!this.openingPack) { bool flag = false; CustomSelfDrawPanel.UICardPack clickedControl = (CustomSelfDrawPanel.UICardPack) base.ClickedControl; if (initialClick && Program.mySettings.OpenMultipleCardPacks) { GameEngine.Instance.playInterfaceSound("BuyCardsPanel_open_pack_open_confirmation"); base.PanelActive = false; this.waitingResponse = false; InterfaceMgr.Instance.openConfirmOpenPackPopup(clickedControl, new ConfirmOpenPackPanel.CardClickPlayDelegate(this.doOpenPack)); } else { if (initialClick) { GameEngine.Instance.playInterfaceSound("BuyCardsPanel_open_pack"); InterfaceMgr.Instance.OpenPackMultiple = 0; } this.openingPack = true; this.extendedMultiOpen = false; this.extendedMultiOpenLeft = 0; this.extendedMultiOpened = 0; foreach (CardTypes.UserCardPack pack2 in GameEngine.Instance.World.ProfileUserCardPacks.Values) { if ((pack2.PackID == clickedControl.PackIDs[0]) && (pack2.Count > 0)) { this.openedPackID = pack2.PackID; this.lastpack = clickedControl; XmlRpcCardsProvider provider = XmlRpcCardsProvider.CreateForEndpoint(URLs.ProfileProtocol, URLs.ProfileServerAddressCards, URLs.ProfileServerPort, URLs.ProfileCardPath); int num = GameEngine.Instance.World.getRank() + 1; XmlRpcCardsRequest req = new XmlRpcCardsRequest(RemoteServices.Instance.UserGuid.ToString().Replace("-", ""), num.ToString(), pack2.PackID.ToString(), RemoteServices.Instance.ProfileWorldID.ToString()) { Multiple = new int?(InterfaceMgr.Instance.OpenPackMultiple) }; if ((InterfaceMgr.Instance.OpenPackMultiple > 0) && (pack2.Count < InterfaceMgr.Instance.OpenPackMultiple)) { this.extendedMultiOpen = true; this.extendedMultiOpenLeft = InterfaceMgr.Instance.OpenPackMultiple - pack2.Count; this.extendedPackClicked = clickedControl; req.Multiple = new int?(pack2.Count); this.extendedMultiOpened = pack2.Count; } provider.openCardPack(req, new CardsEndResponseDelegate(this.PackOpened), this); flag = true; break; } } if (!flag) { MyMessageBox.Show(SK.Text("BuyCardsPanel_No_More_Available", "You have no more packs of that type available."), SK.Text("GENERIC_Error", "Error")); this.openingPack = false; } } } }
private bool doExtendedMultiOpen() { string category = GameEngine.Instance.World.ProfileCardOffers[this.extendedPackClicked.PackIDs[0]].Category; foreach (CardTypes.UserCardPack pack in GameEngine.Instance.World.ProfileUserCardPacks.Values) { if ((GameEngine.Instance.World.ProfileCardOffers[pack.PackID].Category == category) && (pack.Count > 0)) { this.openedPackID = pack.PackID; XmlRpcCardsProvider provider = XmlRpcCardsProvider.CreateForEndpoint(URLs.ProfileProtocol, URLs.ProfileServerAddressCards, URLs.ProfileServerPort, URLs.ProfileCardPath); int num = GameEngine.Instance.World.getRank() + 1; XmlRpcCardsRequest req = new XmlRpcCardsRequest(RemoteServices.Instance.UserGuid.ToString().Replace("-", ""), num.ToString(), pack.PackID.ToString(), RemoteServices.Instance.ProfileWorldID.ToString()) { Multiple = new int?(this.extendedMultiOpenLeft) }; if (pack.Count < this.extendedMultiOpenLeft) { this.extendedMultiOpen = true; this.extendedMultiOpenLeft -= pack.Count; req.Multiple = new int?(pack.Count); this.extendedMultiOpened = pack.Count; } else { this.extendedMultiOpened = this.extendedMultiOpenLeft; this.extendedMultiOpen = false; this.extendedPackClicked = null; } provider.openCardPack(req, new CardsEndResponseDelegate(this.PackOpened), this); return true; } } return false; }
public void init(CustomSelfDrawPanel.UICardPack pack, CardClickPlayDelegate callback) { this.m_callback = callback; base.clearControls(); this.background.Size = base.Size; this.background.Position = new Point(0, 0); base.addControl(this.background); this.background.Create((Image)GFXLibrary.cardpanel_grey_9slice_left_top, (Image)GFXLibrary.cardpanel_grey_9slice_middle_top, (Image)GFXLibrary.cardpanel_grey_9slice_right_top, (Image)GFXLibrary.cardpanel_grey_9slice_left_middle, (Image)GFXLibrary.cardpanel_grey_9slice_middle_middle, (Image)GFXLibrary.cardpanel_grey_9slice_right_middle, (Image)GFXLibrary.cardpanel_grey_9slice_left_bottom, (Image)GFXLibrary.cardpanel_grey_9slice_middle_bottom, (Image)GFXLibrary.cardpanel_grey_9slice_right_bottom); this.topLeftImage.Image = (Image)GFXLibrary.cardpanel_grey_9slice_gradation_top_left; this.topLeftImage.Position = new Point(0, 0); this.background.addControl(this.topLeftImage); this.bottomRightImage.Image = (Image)GFXLibrary.cardpanel_grey_9slice_gradation_bottom; this.bottomRightImage.Position = new Point(this.background.Width - this.bottomRightImage.Image.Width, this.background.Height - this.bottomRightImage.Image.Height); this.background.addControl(this.bottomRightImage); string category = GameEngine.Instance.World.ProfileCardOffers[pack.PackIDs[0]].Category; int num = 0; foreach (CardTypes.UserCardPack pack2 in GameEngine.Instance.World.ProfileUserCardPacks.Values) { if (GameEngine.Instance.World.ProfileCardOffers[pack2.PackID].Category == category) { num += pack2.Count; } } if (num > 10) { num = 10; } int num2 = num; this.numMultiple = new NumericUpDown(); base.Controls.Add(this.numMultiple); this.numMultiple.Minimum = 1M; this.numMultiple.Maximum = num2; this.numMultiple.Increment = 1M; this.numMultiple.Left = (base.Width / 2) - (this.numMultiple.Width / 2); this.numMultiple.Top = ((base.Height / 2) - (this.numMultiple.Height / 2)) - 20; this.numMultiple.DecimalPlaces = 0; this.numMultiple.KeyUp += new KeyEventHandler(this.numMultiple_KeyUp); this.confirmLabel.Text = SK.Text("ConfirmOpenPack_HowMany", "How many packs of this type would you like to open?"); this.confirmLabel.Color = ARGBColors.Black; this.confirmLabel.Position = new Point(20, 10); this.confirmLabel.Font = FontManager.GetFont("Arial", 14f, FontStyle.Regular); this.confirmLabel.Size = new Size(this.background.Width - 40, 80); this.confirmLabel.Alignment = CustomSelfDrawPanel.CSD_Text_Alignment.TOP_CENTER; this.background.addControl(this.confirmLabel); this.packTypeLabel.Text = pack.nameText; this.packTypeLabel.Color = ARGBColors.Black; this.packTypeLabel.Position = new Point(20, 80); this.packTypeLabel.Font = FontManager.GetFont("Arial", 14f, FontStyle.Regular); this.packTypeLabel.Size = new Size(this.background.Width - 40, 80); this.packTypeLabel.Alignment = CustomSelfDrawPanel.CSD_Text_Alignment.TOP_CENTER; this.background.addControl(this.packTypeLabel); this.confirmButton.ImageNorm = (Image)GFXLibrary.cardpanel_button_blue_normal; this.confirmButton.ImageOver = (Image)GFXLibrary.cardpanel_button_blue_over; this.confirmButton.ImageClick = (Image)GFXLibrary.cardpanel_button_blue_pressed; this.confirmButton.Position = new Point(230, 190); this.confirmButton.Text.Text = SK.Text("ConfirmOpenPack_OpenPacks", "Open Packs"); this.confirmButton.TextYOffset = -2; this.confirmButton.Text.Color = ARGBColors.Black; this.confirmButton.Text.Font = FontManager.GetFont("Arial", 12f, FontStyle.Bold); this.confirmButton.setClickDelegate(new CustomSelfDrawPanel.CSDControl.CSD_ClickDelegate(this.playCard), "ConfirmOpenPackPanel_confirm_open_pack"); this.background.addControl(this.confirmButton); this.minButton.ImageNorm = (Image)GFXLibrary.building_icon_circle; this.minButton.ImageOver = (Image)GFXLibrary.building_icon_circle; this.minButton.ImageClick = (Image)GFXLibrary.building_icon_circle; this.minButton.Position = new Point(this.numMultiple.Left, 0x87); this.minButton.Text.Text = this.numMultiple.Minimum.ToString(); this.minButton.TextYOffset = -1; this.minButton.Text.Color = ARGBColors.Black; this.minButton.Text.Font = FontManager.GetFont("Arial", 12f, FontStyle.Bold); this.minButton.setClickDelegate(new CustomSelfDrawPanel.CSDControl.CSD_ClickDelegate(this.minAmount), "SetOpenPackAmount_Minimum"); this.background.addControl(this.minButton); this.middleButton.ImageNorm = (Image)GFXLibrary.building_icon_circle; this.middleButton.ImageOver = (Image)GFXLibrary.building_icon_circle; this.middleButton.ImageClick = (Image)GFXLibrary.building_icon_circle; this.middleButton.Position = new Point((this.numMultiple.Left + (this.numMultiple.Width / 2)) - (this.middleButton.Width / 2), 0x87); this.middleButton.TextYOffset = -1; this.middleButton.Text.Text = (((int)(this.numMultiple.Minimum + this.numMultiple.Maximum)) / 2).ToString(); this.middleButton.Text.Color = ARGBColors.Black; this.middleButton.Text.Font = FontManager.GetFont("Arial", 12f, FontStyle.Bold); this.middleButton.setClickDelegate(new CustomSelfDrawPanel.CSDControl.CSD_ClickDelegate(this.middleAmount), "SetOpenPackAmount_Middle"); this.background.addControl(this.middleButton); this.maxButton.ImageNorm = (Image)GFXLibrary.building_icon_circle; this.maxButton.ImageOver = (Image)GFXLibrary.building_icon_circle; this.maxButton.ImageClick = (Image)GFXLibrary.building_icon_circle; this.maxButton.Position = new Point((this.numMultiple.Left + this.numMultiple.Width) - this.maxButton.Width, 0x87); this.maxButton.TextYOffset = -1; this.maxButton.Text.Text = this.numMultiple.Maximum.ToString(); this.maxButton.Text.Color = ARGBColors.Black; this.maxButton.Text.Font = FontManager.GetFont("Arial", 12f, FontStyle.Bold); this.maxButton.setClickDelegate(new CustomSelfDrawPanel.CSDControl.CSD_ClickDelegate(this.maxAmount), "SetOpenPackAmount_Maximum"); this.background.addControl(this.maxButton); this.left.Position = new Point(this.numMultiple.Left - 5, this.numMultiple.Top - 5); this.left.Height = ((this.minButton.Position.Y + this.minButton.Height) - this.left.Position.Y) + 5; this.left.LineColor = ARGBColors.Black; this.left.Width = 0; this.background.addControl(this.left); this.right.Position = new Point(this.numMultiple.Right + 5, this.numMultiple.Top - 5); this.right.Height = ((this.minButton.Position.Y + this.minButton.Height) - this.right.Position.Y) + 5; this.right.LineColor = ARGBColors.Black; this.right.Width = 0; this.background.addControl(this.right); this.top.Position = new Point(this.numMultiple.Left - 5, this.numMultiple.Top - 5); this.top.Width = this.right.Position.X - this.left.Position.X; this.top.LineColor = ARGBColors.Black; this.top.Height = 0; this.background.addControl(this.top); this.bottom.Position = new Point(this.numMultiple.Left - 5, (this.minButton.Position.Y + this.minButton.Height) + 5); this.bottom.Width = this.right.Position.X - this.left.Position.X; this.bottom.LineColor = ARGBColors.Black; this.bottom.Height = 0; this.background.addControl(this.bottom); this.cancelButton.ImageNorm = (Image)GFXLibrary.cardpanel_button_blue_normal; this.cancelButton.ImageOver = (Image)GFXLibrary.cardpanel_button_blue_over; this.cancelButton.ImageClick = (Image)GFXLibrary.cardpanel_button_blue_pressed; this.cancelButton.Position = new Point(30, 190); this.cancelButton.Text.Text = SK.Text("GENERIC_Cancel", "Cancel"); this.cancelButton.TextYOffset = -2; this.cancelButton.Text.Color = ARGBColors.Black; this.cancelButton.Text.Font = FontManager.GetFont("Arial", 12f, FontStyle.Bold); this.cancelButton.setClickDelegate(new CustomSelfDrawPanel.CSDControl.CSD_ClickDelegate(this.closeClick), "ConfirmOpenPackPanel_cancel"); this.background.addControl(this.cancelButton); this.confirmCheck.CheckedImage = (Image)GFXLibrary.reports_checkbox_checked; this.confirmCheck.UncheckedImage = (Image)GFXLibrary.reports_checkbox_empty; this.confirmCheck.Position = new Point(20, 240); this.confirmCheck.Checked = true; this.confirmCheck.CBLabel.Text = SK.Text("ConfirmOpenPack_AlwaysAsk", "Always ask to open multiple packs?"); this.confirmCheck.CBLabel.Color = ARGBColors.Black; this.confirmCheck.CBLabel.Position = new Point(20, -1); this.confirmCheck.CBLabel.Size = new Size(360, 0x23); this.confirmCheck.CBLabel.Font = FontManager.GetFont("Arial", 10f, FontStyle.Regular); this.background.addControl(this.confirmCheck); }
public void UpdatePacks() { if (packimage == null) { packimage = new Bitmap(this.packWidth, 0x88); using (Graphics graphics = Graphics.FromImage(packimage)) { graphics.FillRectangle(Brushes.Green, 0, 0, packimage.Width, packimage.Height); } } foreach (CustomSelfDrawPanel.UICardPack pack in this.packControls.Values) { this.mainBackgroundImage.removeControl(pack); } this.packControls.Clear(); this.AvailablePanelContent.invalidate(); int packWidth = this.packWidth; int num2 = 0; foreach (CardTypes.UserCardPack pack2 in GameEngine.Instance.World.ProfileUserCardPacks.Values) { if (!this.packControls.ContainsKey(GameEngine.Instance.World.ProfileCardOffers[pack2.PackID].Category) && (pack2.Count > 0)) { num2++; } } if (num2 >= 8) { packWidth = 0x4b; } foreach (CardTypes.UserCardPack pack3 in GameEngine.Instance.World.ProfileUserCardPacks.Values) { if (!this.packControls.ContainsKey(GameEngine.Instance.World.ProfileCardOffers[pack3.PackID].Category) && (pack3.Count > 0)) { CustomSelfDrawPanel.UICardPack packControl = new CustomSelfDrawPanel.UICardPack { baseImage = new CustomSelfDrawPanel.CSDImage() }; packControl.baseImage.Image = packimage; packControl.baseImage.Size = packimage.Size; string str = string.Empty; string str2 = string.Empty; string iD = string.Empty; int num3 = -1; switch (GameEngine.Instance.World.ProfileCardOffers[pack3.PackID].Category) { case "FARMING": str2 = "card_pack_food_standard_normal"; str = "card_pack_food_standard_over"; num3 = 0x283d; iD = "CARD_OFFERS_Food_Pack"; break; case "CASTLE": str2 = "card_pack_castle_standard_normal"; str = "card_pack_castle_standard_over"; num3 = 0x283e; iD = "CARD_OFFERS_Castle_Pack"; break; case "DEFENSE": case "DEFENCE": str2 = "card_pack_defence_standard_normal"; str = "card_pack_defence_standard_over"; num3 = 0x283f; iD = "CARD_OFFERS_Defense_Pack"; break; case "ARMY": str2 = "card_pack_army_standard_normal"; str = "card_pack_army_standard_over"; num3 = 0x2840; iD = "CARD_OFFERS_Army_Pack"; break; case "RANDOM": str2 = "card_pack_random_standard_normal"; str = "card_pack_random_standard_over"; num3 = 0x2841; iD = "CARD_OFFERS_Random_Pack"; break; case "INDUSTRY": str2 = "card_pack_Industry_standard_normal"; str = "card_pack_Industry_standard_over"; num3 = 0x2842; iD = "CARD_OFFERS_Industry_Pack"; break; case "EXCLUSIVE": str2 = "card_pack_exclusive_silver_normal"; str = "card_pack_exclusive_silver_over"; num3 = 0x2844; iD = "CARD_OFFERS_Exclusive_Pack"; break; case "RESEARCH": str2 = "card_pack_research_silver_normal"; str = "card_pack_research_silver_over"; num3 = 0x2843; iD = "CARD_OFFERS_Research_Pack"; break; case "SUPERFARMING": str2 = "card_pack_food_silver_normal"; str = "card_pack_food_silver_over"; iD = "CARD_OFFERS_Super_Food_Pack"; num3 = 0x2845; break; case "SUPERDEFENSE": case "SUPERDEFENCE": str2 = "card_pack_defence_silver_normal"; str = "card_pack_defence_silver_over"; iD = "CARD_OFFERS_Super_Defense_Pack"; num3 = 0x2846; break; case "SUPERRANDOM": str2 = "card_pack_random_silver_normal"; str = "card_pack_random_silver_over"; iD = "CARD_OFFERS_Super_Random_Pack"; num3 = 0x2848; break; case "SUPERINDUSTRY": str2 = "card_pack_Industry_silver_normal"; str = "card_pack_Industry_silver_over"; iD = "CARD_OFFERS_Super_Industry_Pack"; num3 = 0x2849; break; case "SUPERARMY": str2 = "card_pack_army_silver_normal"; str = "card_pack_army_silver_over"; iD = "CARD_OFFERS_Super_Army_Pack"; num3 = 0x2847; break; case "ULTIMATEFARMING": str2 = "card_pack_food_gold_normal"; str = "card_pack_food_gold_over"; iD = "CARD_OFFERS_Ultimate_Food_Pack"; num3 = 0x284a; break; case "ULTIMATEDEFENSE": case "ULTIMATEDEFENCE": str2 = "card_pack_defence_gold_normal"; str = "card_pack_defence_gold_over"; iD = "CARD_OFFERS_Ultimate_Defense_Pack"; num3 = 0x284b; break; case "ULTIMATERANDOM": str2 = "card_pack_random_gold_normal"; str = "card_pack_random_gold_over"; iD = "CARD_OFFERS_Ultimate_Random_Pack"; num3 = 0x284d; break; case "ULTIMATEINDUSTRY": str2 = "card_pack_Industry_gold_normal"; str = "card_pack_Industry_gold_over"; iD = "CARD_OFFERS_Ultimate_Industry_Pack"; num3 = 0x284e; break; case "ULTIMATEARMY": str2 = "card_pack_army_gold_normal"; str = "card_pack_army_gold_over"; iD = "CARD_OFFERS_Ultimate_Army_Pack"; num3 = 0x284c; break; case "PLATINUM": str2 = "card_pack_army_gold_normal"; str = "card_pack_army_gold_over"; iD = "CARD_OFFERS_Platinum_Pack"; num3 = 0x2851; break; default: str2 = "card_pack_Industry_standard_normal"; str = "card_pack_Industry_standard_over"; iD = "CARD_OFFERS_Industry_Pack"; break; } packControl.nameText = SK.Text(iD); try { packControl.baseImage.Image = GFXLibrary.CardPackImages[str2]; } catch (Exception) { packControl.baseImage.Image = GFXLibrary.CardPackImages["card_pack_open_Industry-Pack"]; } try { packControl.overImage.Image = GFXLibrary.CardPackImages[str]; } catch (Exception) { packControl.overImage.Image = GFXLibrary.CardPackImages["card_pack_open_Industry-Pack_over"]; } packControl.addControl(packControl.baseImage); packControl.addControl(packControl.overImage); packControl.baseImage.Visible = true; packControl.overImage.Visible = false; packControl.CustomTooltipID = num3; packControl.setMouseOverDelegate(delegate { packControl.baseImage.Visible = false; packControl.overImage.Visible = true; }, delegate { packControl.baseImage.Visible = true; packControl.overImage.Visible = false; }); packControl.Size = packControl.baseImage.Size; if (this.packControls.Count > 0) { packControl.Position = new Point(this.AvailablePanel.X + ((packWidth + 4) * this.packControls.Count), (base.Height - 4) - packControl.Height); } else { packControl.Position = new Point(this.AvailablePanel.X, (base.Height - 4) - packControl.Height); } packControl.ClickArea = new Rectangle(8, 0, 0x4b, packControl.Height); packControl.PackIDs.Add(pack3.PackID); this.packControls.Add(GameEngine.Instance.World.ProfileCardOffers[pack3.PackID].Category, packControl); continue; } if (pack3.Count > 0) { this.packControls[GameEngine.Instance.World.ProfileCardOffers[pack3.PackID].Category].PackIDs.Add(pack3.PackID); } } foreach (CustomSelfDrawPanel.UICardPack pack4 in this.packControls.Values) { CustomSelfDrawPanel.CSDImage image; image = new CustomSelfDrawPanel.CSDImage { Image = (Image) GFXLibrary.cardpanel_pack_open_circle, Size = ((Image)GFXLibrary.cardpanel_pack_open_circle).Size, Position = new Point((pack4.Width - ((Image)GFXLibrary.cardpanel_pack_open_circle).Width) - 4, (pack4.Height - ((Image)GFXLibrary.cardpanel_pack_open_circle).Height) - (((Image)GFXLibrary.cardpanel_pack_open_circle).Height / 2)) }; pack4.addControl(image); pack4.nameLabel = new CustomSelfDrawPanel.CSDLabel(); int num4 = 0; foreach (CardTypes.UserCardPack pack5 in GameEngine.Instance.World.ProfileUserCardPacks.Values) { if (pack4.PackIDs.Contains(pack5.PackID)) { num4 += pack5.Count; } } pack4.nameLabel.Text = num4.ToString(); pack4.nameLabel.Position = new Point((image.X - 2) - 50, image.Y - 2); pack4.nameLabel.Size = new Size(image.Size.Width + 100, image.Size.Height); pack4.nameLabel.Alignment = CustomSelfDrawPanel.CSD_Text_Alignment.CENTER_CENTER; pack4.nameLabel.Font = FontManager.GetFont("Arial", 12f, FontStyle.Bold); pack4.nameLabel.Color = ARGBColors.Black; pack4.addControl(pack4.nameLabel); if (pack4.PackIDs.Count > 0) { pack4.setClickDelegate(new CustomSelfDrawPanel.CSDControl.CSD_ClickDelegate(this.OpenPack)); this.mainBackgroundImage.addControl(pack4); } } this.mainBackgroundImage.invalidate(); }
public void init(CustomSelfDrawPanel.UICardPack pack, ConfirmOpenPackPanel.CardClickPlayDelegate callback) { this.confirmPanel.init(pack, callback); }