| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598 |
- using Client.MirGraphics;
- using Client.MirNetwork;
- using Client.MirScenes;
- using Client.MirSounds;
- using C = ClientPackets;
- namespace Client.MirControls
- {
- public sealed class GameShopCell : MirImageControl
- {
- public MirLabel nameLabel, typeLabel, goldLabel, gpLabel, stockLabel, StockLabel, countLabel;
- public GameShopItem Item;
- public UserItem ShowItem;
- Rectangle ItemDisplayArea;
- public MirButton BuyItem, PreviewItem;
- public MirImageControl ViewerBackground;
- public byte Quantity = 1;
- public MirButton quantityUp, quantityDown;
- public MirLabel quantity;
- public GameShopViewer Viewer;
- public GameShopCell()
- {
- Size = new Size(125, 146);
- Index = 750;
- Library = Libraries.Title;
- MouseLeave += (o, e) =>
- {
- GameScene.Scene.DisposeItemLabel();
- GameScene.HoverItem = null;
- ShowItem = null;
- };
- nameLabel = new MirLabel
- {
- Size = new Size(125, 15),
- DrawFormat = TextFormatFlags.HorizontalCenter,
- Location = new Point(0, 13),
- Parent = this,
- NotControl = true,
- Font = new Font(Settings.FontName, 8F),
- };
- goldLabel = new MirLabel
- {
- Size = new Size(95, 20),
- DrawFormat = TextFormatFlags.RightToLeft | TextFormatFlags.Right,
- Location = new Point(2, 102),
- Parent = this,
- NotControl = true,
- Font = new Font(Settings.FontName, 8F)
- };
- gpLabel = new MirLabel
- {
- Size = new Size(95, 20),
- DrawFormat = TextFormatFlags.RightToLeft | TextFormatFlags.Right,
- Location = new Point(2, 81),
- Parent = this,
- NotControl = true,
- Font = new Font(Settings.FontName, 8F)
- };
- StockLabel = new MirLabel
- {
- Size = new Size(40, 20),
- Location = new Point(53, 37),
- Parent = this,
- NotControl = true,
- ForeColour = Color.Gray,
- Font = new Font(Settings.FontName, 7F),
- Text = "STOCK:"
- };
- stockLabel = new MirLabel
- {
- Size = new Size(20, 20),
- DrawFormat = TextFormatFlags.HorizontalCenter,
- Location = new Point(93, 37),
- Parent = this,
- NotControl = true,
- Font = new Font(Settings.FontName, 7F),
- };
- countLabel = new MirLabel
- {
- Size = new Size(30, 20),
- DrawFormat = TextFormatFlags.Right,
- Location = new Point(16, 60),
- Parent = this,
- NotControl = true,
- Font = new Font(Settings.FontName, 7F),
- };
- BuyItem = new MirButton
- {
- Index = 778,
- HoverIndex = 779,
- PressedIndex = 780,
- Location = new Point(42, 122),
- Library = Libraries.Title,
- Parent = this,
- Sound = SoundList.ButtonA,
- };
- BuyItem.Click += (o, e) =>
- {
- BuyProduct();
- };
- PreviewItem = new MirButton
- {
- Index = 781,
- HoverIndex = 782,
- PressedIndex = 783,
- Location = new Point(8, 122),
- Library = Libraries.Title,
- Parent = this,
- Sound = SoundList.ButtonA,
- Visible = false,
- };
- PreviewItem.Click += (o, e) =>
- {
- GameScene.Scene.GameShopDialog.Viewer.Dispose();
- GameScene.Scene.GameShopDialog.Viewer = new GameShopViewer
- {
- Parent = GameScene.Scene.GameShopDialog,
- Visible = true,
- Location = this.Location.X < 350 ? new Point(416, 115) : new Point(151, 115),
- };
- GameScene.Scene.GameShopDialog.Viewer.ViewerItem = Item;
- GameScene.Scene.GameShopDialog.Viewer.UpdateViewer();
- };
- quantityUp = new MirButton
- {
- Index = 243,
- HoverIndex = 244,
- PressedIndex = 245,
- Library = Libraries.Prguse2,
- Parent = this,
- Location = new Point(97, 56),
- Sound = SoundList.ButtonA,
- };
- quantityUp.Click += (o, e) =>
- {
- if (CMain.Shift) Quantity += 10;
- else Quantity++;
- if (((decimal)(Quantity * Item.Count) / Item.Info.StackSize) > 5) Quantity = ((5 * Item.Info.StackSize) / Item.Count) > 99 ? Quantity = 99 : Quantity = (byte)((5 * Item.Info.StackSize) / Item.Count);
- if (Quantity >= 99) Quantity = 99;
- if (Item.Stock != 0 && Quantity > Item.Stock) Quantity = (byte)Item.Stock;
- };
- quantityDown = new MirButton
- {
- Index = 240,
- HoverIndex = 241,
- PressedIndex = 242,
- Library = Libraries.Prguse2,
- Parent = this,
- Location = new Point(55, 56),
- Sound = SoundList.ButtonA,
- };
- quantityDown.Click += (o, e) =>
- {
- if (CMain.Shift) Quantity -= 10;
- else Quantity--;
- if (Quantity <= 1 || Quantity > 99) Quantity = 1;
- };
- quantity = new MirLabel
- {
- Size = new Size(20, 13),
- DrawFormat = TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter,
- Location = new Point(74, 56),
- Parent = this,
- NotControl = true,
- Font = new Font(Settings.FontName, 8F),
- };
- }
- public void BuyProduct()
- {
- uint CreditCost;
- uint GoldCost;
- MirMessageBox messageBox;
- int pType = -1;
- if (GameScene.Scene.GameShopDialog.PaymentTypeCredit.Checked && Item.CanBuyCredit)
- {
- pType = 0;
- }
- else if (GameScene.Scene.GameShopDialog.PaymentTypeGold.Checked && Item.CanBuyGold)
- {
- pType = 1;
- }
- if (pType == -1)
- {
- GameScene.Scene.ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.YouMustSelectPaymentType), ChatType.System);
- return;
- }
- switch (pType)
- {
- case 0: // Credit
- if (Item.CreditPrice * Quantity <= GameScene.Credit)
- {
- CreditCost = Item.CreditPrice * Quantity;
- messageBox = new MirMessageBox(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.ConfirmBuyItemCredits), Item.Info.FriendlyName, Quantity, CreditCost, Item.Count), MirMessageBoxButtons.YesNo);
- messageBox.YesButton.Click += (o, e) => Network.Enqueue(new C.GameshopBuy { GIndex = Item.GIndex, Quantity = Quantity, PType = pType });
- messageBox.NoButton.Click += (o, e) => { };
- messageBox.Show();
- }
- else
- GameScene.Scene.ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.YouCantAffordSelectedItem), ChatType.System);
- break;
- case 1: // Gold
- if (Item.GoldPrice * Quantity <= GameScene.Gold)
- {
- GoldCost = Item.GoldPrice * Quantity;
- messageBox = new MirMessageBox(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.ConfirmPurchaseItemGold), Item.Info.FriendlyName, Quantity, GoldCost, Item.Count), MirMessageBoxButtons.YesNo);
- messageBox.YesButton.Click += (o, e) => Network.Enqueue(new C.GameshopBuy { GIndex = Item.GIndex, Quantity = Quantity, PType = pType });
- messageBox.NoButton.Click += (o, e) => { };
- messageBox.Show();
- }
- else
- GameScene.Scene.ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.YouCantAffordSelectedItem), ChatType.System);
- break;
- default:
- return;
- }
- }
- public override void OnMouseMove(MouseEventArgs e)
- {
- base.OnMouseMove(e);
- if (GameScene.HoverItem != null && (Item.Info.Index != GameScene.HoverItem.Info.Index))
- {
- GameScene.Scene.DisposeItemLabel();
- GameScene.HoverItem = null;
- ShowItem = null;
- }
- if (ShowItem == null && ItemDisplayArea.Contains(CMain.MPoint))
- {
- ShowItem = new UserItem(Item.Info) { MaxDura = Item.Info.Durability, CurrentDura = Item.Info.Durability, Count = Item.Count };
- GameScene.Scene.CreateItemLabel(ShowItem);
- }
- else if (ShowItem != null && !ItemDisplayArea.Contains(CMain.MPoint))
- {
- GameScene.Scene.DisposeItemLabel();
- GameScene.HoverItem = null;
- ShowItem = null;
- }
- }
- public void UpdateText()
- {
- nameLabel.Text = Item.Info.FriendlyName;
- nameLabel.Text = nameLabel.Text.Length > 17 ? nameLabel.Text.Substring(0, 17) : nameLabel.Text;
- nameLabel.ForeColour = GameScene.Scene.GradeNameColor(Item.Info.Grade);
- if (Item.CanBuyGold)
- goldLabel.Text = (Item.GoldPrice * Quantity).ToString("###,###,##0");
- if (Item.CanBuyCredit)
- gpLabel.Text = (Item.CreditPrice * Quantity).ToString("###,###,##0");
- if (Item.Stock >= 99) stockLabel.Text = "99+";
- if (Item.Stock == 0) stockLabel.Text = "∞";
- else stockLabel.Text = Item.Stock.ToString();
- countLabel.Text = Item.Count.ToString();
- if (Item.Info.Type == ItemType.Mount || Item.Info.Type == ItemType.Weapon || Item.Info.Type == ItemType.Armour || Item.Info.Type == ItemType.Transform)
- {
- PreviewItem.Visible = true;
- BuyItem.Location = new Point(75, 122);
- }
- }
- protected internal override void DrawControl()
- {
-
- base.DrawControl();
- if (Item == null) return;
- UpdateText();
- Size size = Libraries.Items.GetTrueSize(Item.Info.Image);
- Point offSet = new Point((32 - size.Width) / 2, (32 - size.Height) / 2);
- Libraries.Items.Draw(Item.Info.Image, offSet.X + DisplayLocation.X + 12, offSet.Y + DisplayLocation.Y + 40);
- ItemDisplayArea = new Rectangle(new Point(offSet.X + DisplayLocation.X + 12, offSet.Y + DisplayLocation.Y + 40), size);
- }
- protected override void Dispose(bool disposing)
- {
- base.Dispose(disposing);
- Item = null;
- GameScene.HoverItem = null;
- ShowItem = null;
- }
- }
- public sealed class GameShopViewer : MirImageControl
- {
- public MirAnimatedControl PreviewImage, WeaponImage, WeaponImage2, MountImage;
- public int StartIndex = 0;
- public int Direction = 6;
- public GameShopItem ViewerItem;
- public MirButton RightDirection, LeftDirection, CloseButton;
- public GameShopViewer()
- {
- Index = 785;// 314;
- Library = Libraries.Title;// Libraries.Prguse2;
- Location = new Point(405, 108);
- BeforeDraw += GameShopViewer_BeforeDraw;
- //Click += (o, e) =>
- //{
- //Visible = false;
- //};
- CloseButton = new MirButton
- {
- HoverIndex = 362,
- Index = 361,
- Location = new Point(230, 8),
- Library = Libraries.Prguse,
- Parent = this,
- PressedIndex = 363,
- Sound = SoundList.ButtonA,
- };
- CloseButton.Click += (o, e) =>
- {
- Visible = false;
- };
- WeaponImage = new MirAnimatedControl
- {
- Animated = false,
- Location = new Point(105, 160),
- AnimationCount = 6,
- AnimationDelay = 150,
- Index = 0,
- Library = Libraries.Prguse,
- Loop = true,
- Parent = this,
- UseOffSet = true,
- NotControl = true,
- };
- WeaponImage2 = new MirAnimatedControl
- {
- Animated = false,
- Location = new Point(105, 160),
- AnimationCount = 6,
- AnimationDelay = 150,
- Index = 0,
- Library = Libraries.Prguse,
- Loop = true,
- Parent = this,
- UseOffSet = true,
- NotControl = true,
- };
- MountImage = new MirAnimatedControl
- {
- Animated = false,
- Location = new Point(105, 160),
- AnimationCount = 8,
- AnimationDelay = 150,
- Index = 0,
- Library = Libraries.Prguse,
- Loop = true,
- Parent = this,
- UseOffSet = true,
- NotControl = true,
- };
- PreviewImage = new MirAnimatedControl
- {
- Animated = false,
- Location = new Point(105, 160),
- AnimationCount = 6,
- AnimationDelay = 150,
- Index = 0,
- Library = Libraries.Prguse,
- Loop = true,
- Parent = this,
- UseOffSet = true,
- NotControl = true,
- };
- RightDirection = new MirButton
- {
- Index = 243,
- HoverIndex = 244,
- PressedIndex = 245,
- Library = Libraries.Prguse2,
- Parent = this,
- Location = new Point(160, 282),
- Sound = SoundList.ButtonA,
- };
- RightDirection.Click += (o, e) =>
- {
- Direction++;
- if (Direction > 8) Direction = 1;
- UpdateViewer();
- };
- LeftDirection = new MirButton
- {
- Index = 240,
- HoverIndex = 241,
- PressedIndex = 242,
- Library = Libraries.Prguse2,
- Parent = this,
- Location = new Point(81, 282),
- Sound = SoundList.ButtonA,
- };
- LeftDirection.Click += (o, e) =>
- {
- Direction--;
- if (Direction == 0) Direction = 8;
- UpdateViewer();
- };
- }
- public void UpdateViewer()
- {
- this.Visible = true;
- if (ViewerItem.Info.Type == ItemType.Weapon) DrawWeapon();
- if (ViewerItem.Info.Type == ItemType.Armour) DrawArmour();
- if (ViewerItem.Info.Type == ItemType.Mount) DrawMount();
- if (ViewerItem.Info.Type == ItemType.Transform) DrawTransform();
- }
- private void GameShopViewer_BeforeDraw(object sender, EventArgs e)
- {
- BringToFront();
- }
- private void DrawMount()
- {
- WeaponImage.Visible = false;
- WeaponImage2.Visible = false;
- if (GameScene.User.Equipment[(int)EquipmentSlot.Armour] != null)
- PreviewImage.Library = Libraries.CArmours[GameScene.User.Equipment[(int)EquipmentSlot.Armour].Info.Shape];
- else
- PreviewImage.Library = Libraries.CArmours[0];
- if (GameScene.User.Gender == MirGender.Male)
- PreviewImage.Index = 448 + (8 * (Direction - 1));
- else
- PreviewImage.Index = 1256 + (8 * (Direction - 1));
- PreviewImage.AnimationCount = 8;
-
- MountImage.Library = Libraries.Mounts[ViewerItem.Info.Shape];
- MountImage.Index = 32 + (8 * (Direction - 1));
- PreviewImage.Animated = true;
- MountImage.Animated = true;
- MountImage.Visible = true;
- }
- private void DrawWeapon()
- {
- MountImage.Visible = false;
- if (GameScene.User.Equipment[(int)EquipmentSlot.Armour] != null)
- PreviewImage.Library = Libraries.CArmours[GameScene.User.Equipment[(int)EquipmentSlot.Armour].Info.Shape];
- else
- PreviewImage.Library = Libraries.CArmours[0];
- if (GameScene.User.Gender == MirGender.Male)
- PreviewImage.Index = 32 + (6 * (Direction - 1));
- else
- PreviewImage.Index = 840 + (6 * (Direction - 1));
- if (Direction > 1 && Direction < 5)
- WeaponImage.BringToFront();
- else
- PreviewImage.BringToFront();
- if (ViewerItem.Info.Shape >= 100 && ViewerItem.Info.Shape <= 199)
- {
- WeaponImage.Library = Libraries.AWeaponsR[ViewerItem.Info.Shape - 100];
- WeaponImage2.Library = Libraries.AWeaponsL[ViewerItem.Info.Shape - 100];
- WeaponImage2.Visible = true;
- WeaponImage2.Index = 32 + (6 * (Direction - 1));
- if (Direction >= 2 && Direction <= 3)
- {
- WeaponImage2.BringToFront();
- PreviewImage.BringToFront();
- WeaponImage.BringToFront();
- }
- else if (Direction == 8 || Direction == 7)
- {
- WeaponImage.BringToFront();
- PreviewImage.BringToFront();
- WeaponImage2.BringToFront();
- }
- else
- {
- WeaponImage.BringToFront();
- PreviewImage.BringToFront();
- }
- }
- else
- {
- WeaponImage2.Visible = false;
- }
- if (ViewerItem.Info.Shape >= 200)
- {
- WeaponImage.Library = Libraries.ARWeapons[ViewerItem.Info.Shape - 200];
- if (Direction >= 6 && Direction <= 8)
- {
- PreviewImage.BringToFront();
- WeaponImage.BringToFront();
- }
-
- }
-
- if (ViewerItem.Info.Shape < 100) WeaponImage.Library = Libraries.CWeapons[ViewerItem.Info.Shape];
- WeaponImage.Index = 32 + (6 * (Direction - 1));
- PreviewImage.AnimationCount = 6;
- PreviewImage.Animated = true;
- WeaponImage2.Animated = true;
- WeaponImage.Animated = true;
- WeaponImage.Visible = true;
- }
- private void DrawArmour()
- {
- WeaponImage.Visible = false;
- WeaponImage2.Visible = false;
- MountImage.Visible = false;
- if (ViewerItem.Info.RequiredGender == RequiredGender.Male)
- PreviewImage.Index = 32 + (6 * (Direction - 1));
- else
- PreviewImage.Index = 840 + (6 * (Direction - 1));
- PreviewImage.Library = Libraries.CArmours[ViewerItem.Info.Shape];
- PreviewImage.AnimationCount = 6;
- PreviewImage.Animated = true;
-
- }
- private void DrawTransform()
- {
- WeaponImage.Visible = false;
- WeaponImage2.Visible = false;
- MountImage.Visible = false;
- PreviewImage.Index = 32 + (6 * (Direction - 1));
- PreviewImage.Library = Libraries.Transform[ViewerItem.Info.Shape];
- PreviewImage.AnimationCount = 6;
- PreviewImage.Animated = true;
- }
- private void DrawMask()
- {
- }
- }
- }
|