| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639 |
- using Client.MirControls;
- using Client.MirGraphics;
- using Client.MirNetwork;
- using Client.MirSounds;
- using System.Globalization;
- using System.Linq;
- using System.Text.RegularExpressions;
- using C = ClientPackets;
- namespace Client.MirScenes.Dialogs
- {
- public sealed class TrustMerchantDialog : MirImageControl
- {
- public static bool UserMode = false;
- public static MarketPanelType MarketType;
- public uint Amount = 0,
- MinConsignAmount = Globals.MinConsignment, MaxConsignAmount = Globals.MaxConsignment,
- MinBidAmount = Globals.MinStartingBid, MaxBidAmount = Globals.MaxStartingBid;
- public static long SearchTime, MarketTime;
- public MirTextBox SearchTextBox, PriceTextBox;
- public MirButton FindButton, RefreshButton, MailButton, BuyButton, SellNowButton, CollectSoldButton, CloseButton, NextButton, BackButton;
- public MirImageControl TitleLabel;
- public MirLabel ItemLabel, PriceLabel, SellerLabel, PageLabel;
- public MirLabel DateLabel, ExpireLabel;
- public MirLabel NameLabel, TotalPriceLabel, SplitPriceLabel;
- public MirLabel HelpLabel;
- public MirLabel TitleSalePriceLabel, TitleSellLabel, TitleItemLabel, TitlePriceLabel, TitleExpiryLabel;
- public MirItemCell ItemCell, tempCell;
- public static UserItem SellItemSlot;
- public MirButton SellItemButton;
- public List<ClientAuction> Listings = new List<ClientAuction>();
- public List<ClientAuction> GameShopListings = new List<ClientAuction>();
- public int Page, PageCount;
- public static AuctionRow Selected;
- public AuctionRow[] Rows = new AuctionRow[10];
- public MirButton UpButton, DownButton, PositionBar;
- public MirButton MarketButton, ConsignmentButton, AuctionButton, GameShopButton;
- public MirImageControl FilterBox, FilterBackground;
- private MarketPriceFilter PriceFilter = MarketPriceFilter.Normal;
- private MirImageControl PriceFilterIcon;
- private readonly string consignmentText = string.Format(
- GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ConsignmentRules),
- Globals.ConsignmentCost,
- Globals.ConsignmentLength,
- Globals.MinConsignment,
- Globals.MaxConsignment
- );
- private readonly string auctionText = string.Format(
- GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.AuctionRules),
- Globals.AuctionCost,
- Globals.MaxStartingBid,
- Globals.ConsignmentLength
- );
- private MirLabel TotalGold;
- public List<Filter> Filters = new List<Filter>();
- List<MirButton> FilterButtons = new List<MirButton>();
- List<MirLabel> FilterLabels = new List<MirLabel>();
- private int Skip = 0;
- private int MaxLines = 19;
- private int SelectedIndex = -1;
- private int SelectedSubIndex = -1;
- private int PossibleTotal = 0;
- private int PosX, PosMinY, PosMaxY;
- NumberFormatInfo nfi = new NumberFormatInfo
- {
- NumberGroupSeparator = ",",
- NumberGroupSizes = new[] { 3 },
- NumberDecimalDigits = 0
- };
- public TrustMerchantDialog()
- {
- Index = 786;
- Library = Libraries.Title;
- Sort = true;
- Movable = true;
- Size = new Size(492, 478);
- #region TrustMerchant Buttons
- MarketButton = new MirButton
- {
- Index = 789,
- PressedIndex = 788,
- Library = Libraries.Title,
- Location = new Point(9, 35),
- Parent = this,
- };
- MarketButton.Click += (o, e) =>
- {
- TMerchantDialog(MarketPanelType.Market);
- if (tempCell != null)
- {
- tempCell.Locked = false;
- SellItemSlot = null;
- tempCell = null;
- }
- };
- ConsignmentButton = new MirButton
- {
- Index = 791,
- PressedIndex = 790,
- Library = Libraries.Title,
- Location = new Point(104, 35),
- Parent = this,
- Visible = true,
- };
- ConsignmentButton.Click += (o, e) =>
- {
- TMerchantDialog(MarketPanelType.Consign);
- };
- AuctionButton = new MirButton
- {
- Index = 817,
- PressedIndex = 816,
- Library = Libraries.Title,
- Location = new Point(199, 35),
- Parent = this,
- Visible = true,
- };
- AuctionButton.Click += (o, e) =>
- {
- TMerchantDialog(MarketPanelType.Auction);
- };
- GameShopButton = new MirButton
- {
- Index = 819,
- PressedIndex = 818,
- Library = Libraries.Title,
- Location = new Point(389, 35),
- Parent = this,
- Visible = true,
- };
- GameShopButton.Click += (o, e) =>
- {
- TMerchantDialog(MarketPanelType.GameShop);
- };
- CloseButton = new MirButton
- {
- Index = 360,
- HoverIndex = 361,
- PressedIndex = 362,
- Location = new Point(465, 3),
- Library = Libraries.Prguse2,
- Sound = SoundList.ButtonA,
- Parent = this,
- };
- CloseButton.Click += (o, e) => Hide();
- #region Page Buttons & Label
- HelpLabel = new MirLabel
- {
- Text = consignmentText,
- Parent = this,
- Size = new Size(115, 205),
- Location = new Point(8, 237),
- Font = new Font(Settings.FontName, Settings.FontSize - 1),
- ForeColour = Color.White,
- Visible = false
- };
- BackButton = new MirButton
- {
- Index = 240,
- HoverIndex = 241,
- PressedIndex = 242,
- Library = Libraries.Prguse2,
- Location = new Point(251, 419),
- Sound = SoundList.ButtonA,
- Parent = this,
- };
- BackButton.Click += (o, e) =>
- {
- if (Page <= 0) return;
- Page--;
- UpdateInterface();
- };
- NextButton = new MirButton
- {
- Index = 243,
- HoverIndex = 244,
- PressedIndex = 245,
- Library = Libraries.Prguse2,
- Location = new Point(320, 419),
- Sound = SoundList.ButtonA,
- Parent = this,
- };
- NextButton.Click += (o, e) =>
- {
- if (Page >= PageCount - 1) return;
- if (Page < (Listings.Count - 1) / 10)
- {
- Page++;
- UpdateInterface();
- return;
- }
- Network.Enqueue(new C.MarketPage { Page = Page + 1 });
- };
- PageLabel = new MirLabel
- {
- Size = new Size(70, 18),
- Location = new Point(260, 419),
- DrawFormat = TextFormatFlags.HorizontalCenter,
- Text = "0/0",
- NotControl = true,
- Parent = this,
- };
- UpButton = new MirButton
- {
- Index = 197,
- HoverIndex = 198,
- PressedIndex = 199,
- Library = Libraries.Prguse2,
- Parent = this,
- Size = new Size(16, 14),
- Location = new Point(108, 60),
- Sound = SoundList.ButtonA,
- Visible = true
- };
- UpButton.Click += (o, e) =>
- {
- if (Skip <= 0) return;
- Skip--;
- UpdatePositionBar();
- DrawFilters(SelectedIndex, SelectedSubIndex);
- };
- DownButton = new MirButton
- {
- Index = 207,
- HoverIndex = 208,
- Library = Libraries.Prguse2,
- PressedIndex = 209,
- Parent = this,
- Size = new Size(16, 14),
- Location = new Point(108, 429),
- Sound = SoundList.ButtonA,
- Visible = true
- };
- DownButton.Click += (o, e) =>
- {
- if (Skip + MaxLines >= PossibleTotal) return;
- Skip++;
- UpdatePositionBar();
- DrawFilters(SelectedIndex, SelectedSubIndex);
- };
- PositionBar = new MirButton
- {
- Index = 205,
- HoverIndex = 206,
- PressedIndex = 206,
- Library = Libraries.Prguse2,
- Location = new Point(108, 73),
- Parent = this,
- Movable = true,
- Sound = SoundList.None,
- Visible = false
- };
- PosX = PositionBar.Location.X;
- PosMinY = UpButton.Location.Y + 13;
- PosMaxY = DownButton.Location.Y - 19;
- PositionBar.OnMoving += PositionBar_OnMoving;
- #endregion
- #endregion
- SetupFilters();
- #region Market Buttons
- MailButton = new MirButton
- {
- Index = 437,
- HoverIndex = 438,
- PressedIndex = 439,
- Library = Libraries.Prguse,
- Location = new Point(350, 448),
- Sound = SoundList.ButtonA,
- Parent = this,
- };
- MailButton.Click += (o, e) =>
- {
- if (Selected == null || CMain.Time < MarketTime) return;
- string message = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.InterestedInPurchase), Selected.Listing.Item.FriendlyName, Selected.Listing.Price);
- GameScene.Scene.MailComposeLetterDialog.ComposeMail(Selected.Listing.Seller, message);
- };
- RefreshButton = new MirButton
- {
- Index = 663,
- HoverIndex = 664,
- PressedIndex = 665,
- Library = Libraries.Prguse,
- Location = new Point(320, 448),
- Sound = SoundList.ButtonA,
- Parent = this,
- };
- RefreshButton.Click += (o, e) =>
- {
- if (CMain.Time < SearchTime)
- {
- GameScene.Scene.ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.YouCanSearchAgain), Math.Ceiling((SearchTime - CMain.Time) / 1000D)), ChatType.System);
- return;
- }
- SearchTime = CMain.Time + Globals.SearchDelay;
- SearchTextBox.Text = string.Empty;
- Network.Enqueue(new C.MarketRefresh());
- };
- BuyButton = new MirButton
- {
- Index = 703,
- HoverIndex = 704,
- PressedIndex = 705,
- Library = Libraries.Title,
- Location = new Point(380, 448),
- Sound = SoundList.ButtonA,
- Parent = this,
- };
- BuyButton.Click += (o, e) =>
- {
- if (Selected == null || CMain.Time < MarketTime) return;
- if (UserMode)
- {
- if (Selected.Listing.ItemType == MarketItemType.Consign)
- {
- if (Selected.Listing.Seller == "For Sale")
- {
- MirMessageBox box = new MirMessageBox(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.ItemNotSoldGetBack), Selected.Listing.Item.FriendlyName), MirMessageBoxButtons.YesNo);
- box.YesButton.Click += (o1, e2) =>
- {
- MarketTime = CMain.Time + 3000;
- Network.Enqueue(new C.MarketGetBack { AuctionID = Selected.Listing.AuctionID });
- };
- box.Show();
- }
- else
- {
- MarketTime = CMain.Time + 3000;
- Network.Enqueue(new C.MarketGetBack { AuctionID = Selected.Listing.AuctionID });
- }
- }
- else if (Selected.Listing.ItemType == MarketItemType.Auction)
- {
- if (Selected.Listing.Seller == "No Bid")
- {
- MirMessageBox box = new MirMessageBox(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.ItemNotSoldConfirmRetrieve), Selected.Listing.Item.FriendlyName), MirMessageBoxButtons.YesNo);
- box.YesButton.Click += (o1, e2) =>
- {
- MarketTime = CMain.Time + 3000;
- Network.Enqueue(new C.MarketGetBack { AuctionID = Selected.Listing.AuctionID });
- };
- box.Show();
- }
- else
- {
- MarketTime = CMain.Time + 3000;
- Network.Enqueue(new C.MarketGetBack { AuctionID = Selected.Listing.AuctionID });
- }
- }
- }
- else
- {
- switch (Selected.Listing.ItemType)
- {
- case MarketItemType.Consign:
- case MarketItemType.GameShop:
- {
- MirMessageBox box = new MirMessageBox(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.ConfirmBuyItemWithPrice), Selected.Listing.Item.FriendlyName, Selected.Listing.Price, MarketType == MarketPanelType.GameShop ? GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Credits) : GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Gold)), MirMessageBoxButtons.YesNo);
- box.YesButton.Click += (o1, e2) =>
- {
- MarketTime = CMain.Time + 3000;
- Network.Enqueue(new C.MarketBuy { AuctionID = Selected.Listing.AuctionID });
- };
- box.Show();
- }
- break;
- case MarketItemType.Auction:
- {
- MirAmountBox bidAmount = new MirAmountBox(GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.BidAmount), Selected.Listing.Item.Info.Image, uint.MaxValue, Selected.Listing.Price + 1, Selected.Listing.Price + 1);
- bidAmount.OKButton.Click += (o1, e1) =>
- {
- MirMessageBox box = new MirMessageBox(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.ConfirmBidGoldForItem), bidAmount.Amount, Selected.Listing.Item.FriendlyName), MirMessageBoxButtons.YesNo);
- box.YesButton.Click += (o2, e2) =>
- {
- MarketTime = CMain.Time + 3000;
- Network.Enqueue(new C.MarketBuy { AuctionID = Selected.Listing.AuctionID, BidPrice = bidAmount.Amount });
- };
- box.Show();
- };
- bidAmount.Show();
- }
- break;
- }
- }
- };
- SellNowButton = new MirButton
- {
- Index = 700,
- HoverIndex = 701,
- PressedIndex = 702,
- Library = Libraries.Title,
- Location = new Point(324, 448),
- Sound = SoundList.ButtonA,
- Parent = this,
- };
- SellNowButton.Click += (o, e) =>
- {
- if (Selected == null || CMain.Time < MarketTime) return;
- MarketTime = CMain.Time + 3000;
- Network.Enqueue(new C.MarketSellNow { AuctionID = Selected.Listing.AuctionID });
- };
- CollectSoldButton = new MirButton
- {
- Index = 680,
- HoverIndex = 681,
- PressedIndex = 682,
- Library = Libraries.Title,
- Location = new Point(300, 448),
- Sound = SoundList.ButtonA,
- Parent = this,
- };
- CollectSoldButton.Click += (o, e) =>
- {
- if (CMain.Time < MarketTime) return;
- if (UserMode)
- {
- MarketTime = CMain.Time + 3000;
- Network.Enqueue(new C.MarketGetBack { Mode = MarketCollectionMode.Sold, AuctionID = 0 });
- Network.Enqueue(new C.MarketRefresh());
- }
- };
- #endregion
- #region Search
- SearchTextBox = new MirTextBox
- {
- //Location = new Point(174, 452),
- //Location = new Point(240, 451),
- Location = new Point(11, 452),
- Size = new Size(110, 18),
- MaxLength = 20,
- Parent = this,
- CanLoseFocus = true,
- };
- SearchTextBox.TextBox.KeyPress += SearchTextBox_KeyPress;
- SearchTextBox.TextBox.KeyUp += SearchTextBox_KeyUp;
- SearchTextBox.TextBox.KeyDown += SearchTextBox_KeyDown;
- FindButton = new MirButton
- {
- Index = 480,
- HoverIndex = 481,
- PressedIndex = 482,
- Library = Libraries.Title,
- Location = new Point(124, 448),
- Sound = SoundList.ButtonA,
- Parent = this,
- };
- FindButton.Click += (o, e) =>
- {
- if (String.IsNullOrEmpty(SearchTextBox.Text)) return;
- if (CMain.Time < SearchTime)
- {
- GameScene.Scene.ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.SearchAgainAfterSeconds), Math.Ceiling((SearchTime - CMain.Time) / 1000D)), ChatType.System);
- return;
- }
- SearchTime = CMain.Time + Globals.SearchDelay;
- Network.Enqueue(new C.MarketSearch
- {
- Match = SearchTextBox.Text,
- MarketType = MarketType
- });
- };
- #endregion
- #region Gold Label
- TotalGold = new MirLabel
- {
- Size = new Size(120, 16),
- DrawFormat = TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter,
- Location = new Point(6, 451),
- Parent = this,
- NotControl = true,
- Font = new Font(Settings.FontName, Settings.FontSize),
- Visible = false
- };
- #endregion
- #region ItemCell
- ItemCell = new MirItemCell
- {
- BorderColour = Color.Lime,
- GridType = MirGridType.TrustMerchant,
- Library = Libraries.Items,
- Parent = this,
- Location = new Point(47, 104),
- ItemSlot = 0,
- Visible = false
- };
- ItemCell.Click += (o, e) => ItemCell_Click();
- PriceTextBox = new MirTextBox
- {
- Location = new Point(15, 165),
- Size = new Size(100, 18),
- MaxLength = 20,
- Parent = this,
- CanLoseFocus = true,
- Visible = false,
- };
- PriceTextBox.TextBox.TextChanged += TextBox_TextChanged;
- PriceTextBox.TextBox.KeyPress += MirInputBox_KeyPress;
- SellItemButton = new MirButton
- {
- Index = 700,
- PressedIndex = 702,
- HoverIndex = 701,
- Library = Libraries.Title,
- Sound = SoundList.ButtonA,
- Location = new Point(39, 188),
- Parent = this,
- Visible = false,
- Enabled = false
- };
- SellItemButton.Click += (o, e) =>
- {
- Network.Enqueue(new C.ConsignItem { UniqueID = SellItemSlot.UniqueID, Price = Amount, Type = MarketType });
- SellItemSlot = null;
- PriceTextBox.Text = null;
- SellItemButton.Enabled = false;
- TMerchantDialog(MarketType);
- };
- #endregion
- #region Auction Rows
- for (int i = 0; i < Rows.Length; i++)
- {
- Rows[i] = new AuctionRow
- {
- Location = new Point(127, 82 + i * 33),
- Parent = this
- };
- Rows[i].Click += (o, e) =>
- {
- Selected = (AuctionRow)o;
- UpdateInterface();
- };
- }
- #endregion
- #region Labels
- TitleSalePriceLabel = new MirLabel
- {
- Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.SalePrice),
- Parent = this,
- Font = new Font(Settings.FontName, Settings.FontSize - 1, FontStyle.Italic),
- DrawFormat = TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter,
- Size = new Size(100, 21),
- Location = new Point(15, 142)
- };
- TitleSellLabel = new MirLabel
- {
- Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.SellItem),
- Parent = this,
- Font = new Font(Settings.FontName, Settings.FontSize - 1, FontStyle.Italic),
- DrawFormat = TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter,
- Size = new Size(110, 21),
- Location = new Point(10, 60)
- };
- TitleItemLabel = new MirLabel
- {
- Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Item),
- Parent = this,
- Font = new Font(Settings.FontName, Settings.FontSize - 1, FontStyle.Italic),
- DrawFormat = TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter,
- Size = new Size(166, 21),
- Location = new Point(127, 60)
- };
- TitlePriceLabel = new MirLabel
- {
- Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Price),
- Parent = this,
- Font = new Font(Settings.FontName, Settings.FontSize - 1, FontStyle.Italic),
- DrawFormat = TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter,
- Size = new Size(88, 21),
- Location = new Point(295, 60)
- };
- TitlePriceLabel.Click += (o, e) => CyclePriceFilter();
- PriceFilterIcon = new MirImageControl
- {
- Library = Libraries.Prguse2,
- Index = 926,
- Location = new Point(TitlePriceLabel.Location.X + TitlePriceLabel.Size.Width - 12, TitlePriceLabel.Location.Y + (TitlePriceLabel.Size.Height - 14) / 2 + 2),
- Parent = this,
- Visible = false
- };
- PriceFilterIcon.Click += (o, e) => CyclePriceFilter();
- TitleExpiryLabel = new MirLabel
- {
- Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Expiry),
- Parent = this,
- Font = new Font(Settings.FontName, Settings.FontSize - 1, FontStyle.Italic),
- DrawFormat = TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter,
- Size = new Size(98, 21),
- Location = new Point(384, 60)
- };
- #endregion
- UpdatePriceFilterIcon();
- }
- private void SetupFilters()
- {
- var all = new Filter { Index = 0, Title = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ShowAllItems), Type = ItemType.Nothing };
- var weapon = new Filter { Index = 1, Title = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.WeaponItems), Type = ItemType.Weapon };
- var drapery = new Filter { Index = 2, Title = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.DraperyItems), Type = null };
- var accessory = new Filter { Index = 3, Title = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.AccessoryItems), Type = null };
- var consumable = new Filter { Index = 4, Title = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ConsumableItems), Type = null };
- var enhancement = new Filter { Index = 5, Title = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Enhancement), Type = null };
- var book = new Filter { Index = 6, Title = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Books), Type = null };
- var crafting = new Filter { Index = 7, Title = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.CraftItems), Type = null };
- Filters.Add(all);
- Filters.Add(weapon);
- Filters.Add(drapery);
- Filters.Add(accessory);
- Filters.Add(consumable);
- Filters.Add(enhancement);
- Filters.Add(book);
- Filters.Add(crafting);
- drapery.SubFilters.Add(new Filter { Index = 201, Title = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Armour), Type = ItemType.Armour });
- drapery.SubFilters.Add(new Filter { Index = 202, Title = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Helmet), Type = ItemType.Helmet });
- drapery.SubFilters.Add(new Filter { Index = 203, Title = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Belt), Type = ItemType.Belt });
- drapery.SubFilters.Add(new Filter { Index = 204, Title = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Boots), Type = ItemType.Boots });
- drapery.SubFilters.Add(new Filter { Index = 205, Title = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Stone), Type = ItemType.Stone });
- accessory.SubFilters.Add(new Filter { Index = 301, Title = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Necklaces), Type = ItemType.Necklace });
- accessory.SubFilters.Add(new Filter { Index = 302, Title = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Bracelets), Type = ItemType.Bracelet });
- accessory.SubFilters.Add(new Filter { Index = 303, Title = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Rings), Type = ItemType.Ring });
- consumable.SubFilters.Add(new Filter { Index = 401, Title = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.RecoveryPots), Type = ItemType.Potion, MaxShape = 2 });
- consumable.SubFilters.Add(new Filter { Index = 402, Title = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.BuffPots), Type = ItemType.Potion, MinShape = 3, MaxShape = 4 });
- consumable.SubFilters.Add(new Filter { Index = 403, Title = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ScrollsOils), Type = ItemType.Scroll });
- consumable.SubFilters.Add(new Filter { Index = 404, Title = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.MiscItems), Type = ItemType.Script });
- enhancement.SubFilters.Add(new Filter { Index = 501, Title = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Gems), Type = ItemType.Potion, MinShape = 3, MaxShape = 3 });
- enhancement.SubFilters.Add(new Filter { Index = 502, Title = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Orbs), Type = ItemType.Potion, MinShape = 4, MaxShape = 4 });
- book.SubFilters.Add(new Filter { Index = 601, Title = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Warrior), Type = ItemType.Book, MaxShape = 30 });
- book.SubFilters.Add(new Filter { Index = 602, Title = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Wizard), Type = ItemType.Book, MinShape = 31, MaxShape = 60 });
- book.SubFilters.Add(new Filter { Index = 603, Title = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Taoist), Type = ItemType.Book, MinShape = 61, MaxShape = 90 });
- book.SubFilters.Add(new Filter { Index = 604, Title = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Assassin), Type = ItemType.Book, MinShape = 91, MaxShape = 120 });
- book.SubFilters.Add(new Filter { Index = 605, Title = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Archer), Type = ItemType.Book, MinShape = 121, MaxShape = 150 });
- crafting.SubFilters.Add(new Filter { Index = 701, Title = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Materials), Type = ItemType.CraftingMaterial });
- crafting.SubFilters.Add(new Filter { Index = 703, Title = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Meat), Type = ItemType.Meat });
- crafting.SubFilters.Add(new Filter { Index = 704, Title = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Ore), Type = ItemType.Ore });
- }
- private void DrawFilters(int index, int subIndex)
- {
- SelectedIndex = index;
- SelectedSubIndex = subIndex;
- int btnx = 7;
- int btny = 60;
- int current = 0;
- int skipped = Skip;
- //Dispose all buttons and labels
- foreach (var item in FilterButtons)
- item.Dispose();
- foreach (var item in FilterLabels)
- item.Dispose();
- FilterButtons.Clear();
- FilterLabels.Clear();
- PossibleTotal = Filters.Count;
- foreach (var item in Filters)
- {
- if (skipped > 0)
- {
- skipped--;
- continue;
- }
- if (current >= MaxLines)
- {
- break;
- }
- current++;
- var btn = new MirButton
- {
- Index = 920,
- PressedIndex = 921,
- HoverIndex = 921,
- Library = Libraries.Prguse2,
- Sound = SoundList.ButtonA,
- Location = new Point(btnx, btny),
- Parent = this,
- };
- btn.Click += (o, e) =>
- {
- if (item.SubFilters.Any())
- {
- DrawFilters(item.Index, -1);
- }
- else
- {
- DrawFilters(item.Index, -1);
- if (item.Type.HasValue)
- {
- Network.Enqueue(new C.MarketSearch { Match = SearchTextBox.Text, Type = item.Type.Value, Usermode = false, MinShape = item.MinShape, MaxShape = item.MaxShape, MarketType = MarketType });
- }
- }
- };
- var lbl = new MirLabel
- {
- Size = new Size(99, 18),
- Location = new Point(2, 1),
- Parent = btn,
- Text = item.Title,
- NotControl = true,
- };
- btny += 20;
- FilterButtons.Add(btn);
- FilterLabels.Add(lbl);
- if (item.Index == index)
- {
- PossibleTotal += item.SubFilters.Count;
- btn.Index = 921;
- //btny += 2;
- if (item.SubFilters.Any())
- {
- btny += 2;
- }
- foreach (var subItem in item.SubFilters)
- {
- if (skipped > 0)
- {
- skipped--;
- continue;
- }
- if (current >= MaxLines)
- {
- break;
- }
- current++;
- var subBtn = new MirButton
- {
- Index = 922,
- PressedIndex = 923,
- HoverIndex = 923,
- Library = Libraries.Prguse2,
- Sound = SoundList.ButtonA,
- Location = new Point(btnx, btny),
- Parent = this,
- };
- subBtn.Click += (o, e) =>
- {
- DrawFilters(item.Index, subItem.Index);
- if (subItem.Type.HasValue)
- {
- Network.Enqueue(new C.MarketSearch { Match = SearchTextBox.Text, Type = subItem.Type.Value, Usermode = false, MinShape = subItem.MinShape, MaxShape = subItem.MaxShape, MarketType = MarketType });
- }
- };
- var sublbl = new MirLabel
- {
- Size = new Size(99, 18),
- Location = new Point(10, 1),
- Parent = subBtn,
- Text = subItem.Title,
- NotControl = true,
- };
- if (subItem.Index == subIndex)
- {
- subBtn.Index = 923;
- }
- FilterButtons.Add(subBtn);
- FilterLabels.Add(sublbl);
- btny += 21;
- }
- }
- }
- UpdatePositionBar();
- }
- private void PositionBar_OnMoving(object sender, MouseEventArgs e)
- {
- int x = PosX;
- int y = PositionBar.Location.Y;
- if (y >= PosMaxY) y = PosMaxY;
- if (y <= PosMinY) y = PosMinY;
- int location = y - PosMinY;
- int interval = (PosMaxY - PosMinY) / (PossibleTotal - MaxLines);
- double yPoint = (double)location / interval;
- Skip = Convert.ToInt16(Math.Floor(yPoint));
- PositionBar.Location = new Point(x, y);
- DrawFilters(SelectedIndex, SelectedSubIndex);
- }
- private void UpdatePositionBar()
- {
- if (PossibleTotal <= MaxLines)
- {
- PositionBar.Visible = false;
- return;
- }
- PositionBar.Visible = true;
- int interval = (PosMaxY - PosMinY) / (PossibleTotal - MaxLines);
- int x = PosX;
- int y = PosMinY + (Skip * interval);
- if (y >= PosMaxY) y = PosMaxY;
- if (y <= PosMinY) y = PosMinY;
- PositionBar.Location = new Point(x, y);
- }
- private void UpdatePriceFilterIcon()
- {
- if (PriceFilterIcon == null) return;
- switch (PriceFilter)
- {
- case MarketPriceFilter.High:
- PriceFilterIcon.Index = 926;
- PriceFilterIcon.Visible = true;
- break;
- case MarketPriceFilter.Low:
- PriceFilterIcon.Index = 925;
- PriceFilterIcon.Visible = true;
- break;
- default:
- PriceFilterIcon.Visible = false;
- break;
- }
- }
- private void CyclePriceFilter()
- {
- switch (PriceFilter)
- {
- case MarketPriceFilter.Normal:
- PriceFilter = MarketPriceFilter.Low;
- break;
- case MarketPriceFilter.Low:
- PriceFilter = MarketPriceFilter.High;
- break;
- default:
- PriceFilter = MarketPriceFilter.Normal;
- break;
- }
- UpdatePriceFilterIcon();
- UpdateInterface();
- }
- private List<ClientAuction> GetOrderedListings()
- {
- switch (PriceFilter)
- {
- case MarketPriceFilter.High:
- return Listings.OrderByDescending(x => x?.Price ?? 0).ToList();
- case MarketPriceFilter.Low:
- return Listings.OrderBy(x => x?.Price ?? 0).ToList();
- default:
- return Listings;
- }
- }
- public void UpdateInterface()
- {
- var orderedListings = GetOrderedListings();
- PageLabel.Text = string.Format("{0}/{1}", Page + 1, PageCount);
- TotalGold.Text = MarketType == MarketPanelType.GameShop ? GameScene.Credit.ToString("###,###,##0") : GameScene.Gold.ToString("###,###,##0");
- for (int i = 0; i < 10; i++)
- {
- if (i + Page * 10 >= orderedListings.Count)
- {
- Rows[i].Clear();
- if (Rows[i] == Selected) Selected = null;
- }
- else
- {
- if (Rows[i] == Selected && Selected.Listing != orderedListings[i + Page * 10])
- {
- Selected.Border = false;
- Selected = null;
- }
- Rows[i].Update(orderedListings[i + Page * 10]);
- }
- }
- for (int i = 0; i < Rows.Length; i++)
- {
- Rows[i].Border = Rows[i] == Selected;
- }
- if (Selected != null)
- {
- BuyButton.Enabled = true;
- BuyButton.GrayScale = false;
- CollectSoldButton.Enabled = false;
- CollectSoldButton.GrayScale = true;
- MailButton.Enabled = true;
- MailButton.GrayScale = false;
- }
- else
- {
- BuyButton.Enabled = false;
- BuyButton.GrayScale = true;
- CollectSoldButton.Enabled = true;
- CollectSoldButton.GrayScale = false;
- MailButton.Enabled = false;
- MailButton.GrayScale = true;
- }
- if (Selected != null && Selected.Listing.Seller == "Bid Met")
- {
- SellNowButton.Enabled = true;
- SellNowButton.GrayScale = false;
- }
- else
- {
- SellNowButton.Enabled = false;
- SellNowButton.GrayScale = true;
- }
- }
- private void SearchTextBox_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (CMain.Time < SearchTime)
- {
- GameScene.Scene.ChatDialog.ReceiveChat(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.YouCanSearchAfterSeconds), Math.Ceiling((SearchTime - CMain.Time) / 1000D)), ChatType.System);
- return;
- }
- switch (e.KeyChar)
- {
- case (char)Keys.Enter:
- e.Handled = true;
- if (string.IsNullOrEmpty(SearchTextBox.Text)) return;
- SearchTime = CMain.Time + Globals.SearchDelay;
- Network.Enqueue(new C.MarketSearch
- {
- Match = SearchTextBox.Text,
- MarketType = MarketType
- });
- Program.Form.ActiveControl = null;
- break;
- case (char)Keys.Escape:
- e.Handled = true;
- break;
- }
- }
- private void SearchTextBox_KeyUp(object sender, KeyEventArgs e)
- {
- CMain.Shift = e.Shift;
- CMain.Alt = e.Alt;
- CMain.Ctrl = e.Control;
- switch (e.KeyCode)
- {
- case Keys.F1:
- case Keys.F2:
- case Keys.F3:
- case Keys.F4:
- case Keys.F5:
- case Keys.F6:
- case Keys.F7:
- case Keys.F8:
- case Keys.F9:
- case Keys.F10:
- case Keys.F11:
- case Keys.F12:
- case Keys.Tab:
- case Keys.Escape:
- CMain.CMain_KeyUp(sender, e);
- break;
- }
- }
- private void SearchTextBox_KeyDown(object sender, KeyEventArgs e)
- {
- CMain.Shift = e.Shift;
- CMain.Alt = e.Alt;
- CMain.Ctrl = e.Control;
- switch (e.KeyCode)
- {
- case Keys.F1:
- case Keys.F2:
- case Keys.F3:
- case Keys.F4:
- case Keys.F5:
- case Keys.F6:
- case Keys.F7:
- case Keys.F8:
- case Keys.F9:
- case Keys.F10:
- case Keys.F11:
- case Keys.F12:
- case Keys.Tab:
- case Keys.Escape:
- CMain.CMain_KeyDown(sender, e);
- break;
- }
- }
- public void TMerchantDialog(MarketPanelType type)
- {
- MarketButton.Index = 789;
- ConsignmentButton.Index = 791;
- AuctionButton.Index = 817;
- GameShopButton.Index = 819;
- switch (type)
- {
- case MarketPanelType.Market:
- Index = 786;
- MarketButton.Index = 788;
- BuyButton.Index = 703;
- BuyButton.HoverIndex = 704;
- BuyButton.PressedIndex = 705;
- SellNowButton.Visible = false;
- CollectSoldButton.Visible = false;
- UpButton.Visible = true;
- DownButton.Visible = true;
- PositionBar.Visible = true;
- DrawFilters(0, -1);
- TitleSalePriceLabel.Visible = false;
- TitleSellLabel.Visible = false;
- TitleItemLabel.Visible = true;
- TitlePriceLabel.Visible = true;
- TitleExpiryLabel.Visible = true;
- TitleSalePriceLabel.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.SalePrice);
- TitleSellLabel.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.SellItem);
- TitleItemLabel.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Item);
- TitlePriceLabel.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.PriceBid);
- TitleExpiryLabel.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.SellerExpiry);
- //TotalGold.Visible = true;
- PriceTextBox.Visible = false;
- ItemCell.Visible = false;
- MailButton.Visible = true;
- FindButton.Visible = true;
- SellItemButton.Visible = false;
- SearchTextBox.Visible = true;
- RefreshButton.Visible = true;
- HelpLabel.Visible = false;
- MarketType = MarketPanelType.Market;
- Network.Enqueue(new C.MarketSearch
- {
- Match = "",
- Type = ItemType.Nothing,
- Usermode = false,
- MarketType = MarketType
- });
- break;
- case MarketPanelType.Consign:
- Index = 787;
- ConsignmentButton.Index = 790;
- MailButton.Visible = false;
- BuyButton.Index = 706;
- BuyButton.HoverIndex = 707;
- BuyButton.PressedIndex = 708;
- SellNowButton.Visible = false;
- CollectSoldButton.Visible = true;
- UpButton.Visible = false;
- DownButton.Visible = false;
- PositionBar.Visible = false;
- //TotalGold.Visible = false;
- PriceTextBox.Visible = true;
- PriceTextBox.Text = null;
- ItemCell.Visible = true;
- SellItemButton.Visible = true;
- SellItemButton.Enabled = false;
- FindButton.Visible = false;
- SearchTextBox.Visible = false;
- RefreshButton.Visible = false;
- HelpLabel.Visible = true;
- HelpLabel.Text = consignmentText;
- TitleSalePriceLabel.Visible = true;
- TitleSellLabel.Visible = true;
- TitleItemLabel.Visible = true;
- TitlePriceLabel.Visible = true;
- TitleExpiryLabel.Visible = true;
- TitleSalePriceLabel.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.SalePrice);
- TitleSellLabel.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.SellItem);
- TitleItemLabel.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Item);
- TitlePriceLabel.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Price);
- TitleExpiryLabel.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Expiry);
- foreach (var item in FilterButtons)
- {
- item.Visible = false;
- }
- MarketType = MarketPanelType.Consign;
- Network.Enqueue(new C.MarketSearch
- {
- Match = "",
- Type = ItemType.Nothing,
- Usermode = true,
- MarketType = MarketType
- });
- break;
- case MarketPanelType.Auction:
- Index = 787;
- AuctionButton.Index = 816;
- MailButton.Visible = false;
- BuyButton.Index = 706;
- BuyButton.HoverIndex = 707;
- BuyButton.PressedIndex = 708;
- SellNowButton.Visible = true;
- CollectSoldButton.Visible = false;
- UpButton.Visible = false;
- DownButton.Visible = false;
- PositionBar.Visible = false;
- //TotalGold.Visible = false;
- PriceTextBox.Visible = true;
- PriceTextBox.Text = null;
- ItemCell.Visible = true;
- SellItemButton.Visible = true;
- SellItemButton.Enabled = false;
- FindButton.Visible = false;
- SearchTextBox.Visible = false;
- RefreshButton.Visible = false;
- HelpLabel.Visible = true;
- HelpLabel.Text = auctionText;
- TitleSalePriceLabel.Visible = true;
- TitleSellLabel.Visible = true;
- TitleItemLabel.Visible = true;
- TitlePriceLabel.Visible = true;
- TitleExpiryLabel.Visible = true;
- TitleSalePriceLabel.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.StartingBid);
- TitleSellLabel.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.SellItem);
- TitleItemLabel.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Item);
- TitlePriceLabel.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.HighestBid);
- TitleExpiryLabel.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.EndDate);
- foreach (var item in FilterButtons)
- {
- item.Visible = false;
- }
- MarketType = MarketPanelType.Auction;
- Network.Enqueue(new C.MarketSearch
- {
- Match = "",
- Type = ItemType.Nothing,
- Usermode = true,
- MarketType = MarketType
- });
- break;
- case MarketPanelType.GameShop:
- Index = 786;
- GameShopButton.Index = 818;
- BuyButton.Index = 703;
- BuyButton.HoverIndex = 704;
- BuyButton.PressedIndex = 705;
- SellNowButton.Visible = false;
- CollectSoldButton.Visible = false;
- UpButton.Visible = true;
- DownButton.Visible = true;
- PositionBar.Visible = true;
- DrawFilters(0, -1);
- //TotalGold.Visible = true;
- PriceTextBox.Visible = false;
- ItemCell.Visible = false;
- MailButton.Visible = false;
- FindButton.Visible = true;
- SellItemButton.Visible = false;
- SearchTextBox.Visible = true;
- RefreshButton.Visible = false;
- HelpLabel.Visible = false;
- TitleSalePriceLabel.Visible = false;
- TitleSellLabel.Visible = false;
- TitleItemLabel.Visible = true;
- TitlePriceLabel.Visible = true;
- TitleExpiryLabel.Visible = true;
- TitleSalePriceLabel.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.SalePrice);
- TitleSellLabel.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.SellItem);
- TitleItemLabel.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Item);
- TitlePriceLabel.Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Price);
- TitleExpiryLabel.Text = "";
- MarketType = MarketPanelType.GameShop;
- Network.Enqueue(new C.MarketSearch
- {
- Match = "",
- Type = ItemType.Nothing,
- Usermode = false,
- MarketType = MarketType
- });
- break;
- }
- UpdateInterface();
- }
- private void TextBox_TextChanged(object sender, EventArgs e)
- {
- string price = Regex.Replace(PriceTextBox.TextBox.Text, @"[^\d]", "");
- if (uint.TryParse(price, NumberStyles.AllowThousands, nfi, out Amount))
- {
- if (MarketType == MarketPanelType.Consign)
- {
- if (Amount >= MinConsignAmount)
- {
- if (Amount > MaxConsignAmount)
- {
- Amount = MaxConsignAmount;
- }
- SellItemButton.Enabled = true;
- PriceTextBox.BorderColour = (Amount == MaxConsignAmount) ? Color.Orange : Color.Lime;
- }
- else
- {
- PriceTextBox.BorderColour = Color.Red;
- SellItemButton.Enabled = false;
- }
- }
- else if (MarketType == MarketPanelType.Auction)
- {
- if (Amount >= MinBidAmount)
- {
- PriceTextBox.BorderColour = Color.Lime;
- if (Amount > MaxBidAmount)
- {
- Amount = MaxBidAmount;
- }
- SellItemButton.Enabled = true;
- if (Amount == MaxBidAmount)
- PriceTextBox.BorderColour = Color.Orange;
- }
- else
- {
- PriceTextBox.BorderColour = Color.Red;
- SellItemButton.Enabled = false;
- }
- }
- PriceTextBox.Text = string.Format(nfi, "{0:N0}", Amount);
- PriceTextBox.TextBox.SelectionStart = PriceTextBox.Text.Length;
- }
- }
- private void MirInputBox_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (!char.IsControl(e.KeyChar)
- && !char.IsDigit(e.KeyChar))
- {
- e.Handled = true;
- }
- }
- private void ItemCell_Click()
- {
- if (tempCell != null)
- {
- tempCell.Locked = false;
- SellItemSlot = null;
- tempCell = null;
- }
- if (GameScene.SelectedCell == null || GameScene.SelectedCell.GridType != MirGridType.Inventory ||
- GameScene.SelectedCell.Item != null && GameScene.SelectedCell.Item.Info.Durability < 0)
- return;
- SellItemSlot = GameScene.SelectedCell.Item;
- tempCell = GameScene.SelectedCell;
- tempCell.Locked = true;
- GameScene.SelectedCell = null;
- PriceTextBox.SetFocus();
- }
- public override void Hide()
- {
- if (!Visible) return;
- Visible = false;
- Listings.Clear();
- if (tempCell != null)
- {
- tempCell.Locked = false;
- SellItemSlot = null;
- tempCell = null;
- }
- GameScene.Scene.InventoryDialog.Location = new Point(0, 0);
- }
- public void Show(bool gameshop = false)
- {
- if (Visible) return;
- Visible = true;
- if (gameshop)
- {
- MarketButton.Visible = false;
- ConsignmentButton.Visible = false;
- AuctionButton.Visible = false;
- GameShopButton.Visible = true;
- TMerchantDialog(MarketPanelType.GameShop);
- }
- else
- {
- MarketButton.Visible = true;
- ConsignmentButton.Visible = true;
- AuctionButton.Visible = true;
- GameShopButton.Visible = false;
- TMerchantDialog(MarketPanelType.Market);
- }
- GameScene.Scene.InventoryDialog.Location = new Point(Size.Width + 5, Location.Y);
- GameScene.Scene.InventoryDialog.Show();
- }
- #region AuctionRow
- public sealed class AuctionRow : MirControl
- {
- public ClientAuction Listing = null;
- public MirLabel NameLabel, PriceLabel, SellerLabel, ExpireLabel;
- public MirImageControl IconImage, SelectedImage;
- public bool Selected = false;
- Size IconArea = new Size(34, 32);
- public AuctionRow()
- {
- Size = new Size(354, 32);
- Sound = SoundList.ButtonA;
- BorderColour = Color.FromArgb(255, 200, 100, 0);
- BeforeDraw += AuctionRow_BeforeDraw;
- NameLabel = new MirLabel
- {
- AutoSize = true,
- Size = new Size(140, 20),
- Location = new Point(38, 8),
- DrawFormat = TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter,
- NotControl = true,
- Parent = this,
- };
- PriceLabel = new MirLabel
- {
- AutoSize = true,
- Size = new Size(178, 20),
- Location = new Point(170, 8),
- DrawFormat = TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter,
- NotControl = true,
- Parent = this,
- };
- SellerLabel = new MirLabel
- {
- AutoSize = true,
- Size = new Size(148, 20),
- Location = new Point(256, 0),
- DrawFormat = TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter,
- NotControl = true,
- Parent = this,
- };
- IconImage = new MirImageControl
- {
- Index = 0,
- Library = Libraries.Prguse,
- Location = new Point(0, 0),
- Parent = this,
- };
- SelectedImage = new MirImageControl
- {
- Index = 545,
- Library = Libraries.Prguse,
- Location = new Point(-5, -3),
- Parent = this,
- Visible = false,
- NotControl = true
- };
- ExpireLabel = new MirLabel
- {
- AutoSize = true,
- Location = new Point(256, 14),
- Size = new Size(110, 22),
- DrawFormat = TextFormatFlags.Left | TextFormatFlags.VerticalCenter,
- Parent = this,
- NotControl = true,
- };
- UpdateInterface();
- }
- private void AuctionRow_BeforeDraw(object sender, EventArgs e)
- {
- UpdateInterface();
- }
- public void UpdateInterface()
- {
- if (Listing == null) return;
- IconImage.Visible = true;
- if (Listing.Item.Count > 0)
- {
- IconImage.Index = Listing.Item.Info.Image;
- IconImage.Library = Libraries.Items;
- }
- else
- {
- IconImage.Index = 540;
- IconImage.Library = Libraries.Prguse;
- }
- IconImage.Location = new Point((IconArea.Width - IconImage.Size.Width) / 2, (IconArea.Height - IconImage.Size.Height) / 2);
- SellerLabel.Visible = Listing.ItemType == MarketItemType.Consign || Listing.ItemType == MarketItemType.Auction;
- ExpireLabel.Visible = Listing != null && (Listing.ItemType == MarketItemType.Consign || Listing.ItemType == MarketItemType.Auction);
- if (Listing == null) return;
- ExpireLabel.Text = string.Format("{0:dd/MM/yy HH:mm:ss}", Listing.ConsignmentDate.AddDays(Globals.ConsignmentLength));
- }
- protected override void Dispose(bool disposing)
- {
- base.Dispose(disposing);
- SelectedImage = null;
- IconImage = null;
- Selected = false;
- }
- public void Clear()
- {
- Visible = false;
- NameLabel.Text = string.Empty;
- PriceLabel.Text = string.Empty;
- SellerLabel.Text = string.Empty;
- }
- public void Update(ClientAuction listing)
- {
- Listing = listing;
- NameLabel.Text = Listing.Item.FriendlyName;
- PriceLabel.Text = String.Format("{0:###,###,##0} {1}", Listing.Price, listing.ItemType == MarketItemType.Auction ? GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Bid) : "");
- NameLabel.ForeColour = GameScene.Scene.GradeNameColor(Listing.Item.Info.Grade);
- if (NameLabel.ForeColour == Color.Yellow)
- NameLabel.ForeColour = Color.White;
- if (Listing.Price > 10000000) //10Mil
- PriceLabel.ForeColour = Color.Red;
- else if (listing.Price > 1000000) //1Million
- PriceLabel.ForeColour = Color.Orange;
- else if (listing.Price > 100000) //1Million
- PriceLabel.ForeColour = Color.LawnGreen;
- else if (listing.Price > 10000) //1Million
- PriceLabel.ForeColour = Color.DeepSkyBlue;
- else
- PriceLabel.ForeColour = Color.White;
- SellerLabel.Text = Listing.Seller;
- SellerLabel.ForeColour = Color.White;
- if (UserMode)
- {
- switch (Listing.Seller)
- {
- case "Sold":
- SellerLabel.ForeColour = Color.Gold;
- break;
- case "Expired":
- SellerLabel.ForeColour = Color.Red;
- break;
- case "Bid Met":
- SellerLabel.ForeColour = Color.LawnGreen;
- break;
- default:
- SellerLabel.ForeColour = Color.White;
- break;
- }
- }
- Visible = true;
- }
- protected override void OnMouseEnter()
- {
- if (Listing == null) return;
- base.OnMouseEnter();
- GameScene.Scene.CreateItemLabel(Listing.Item);
- }
- protected override void OnMouseLeave()
- {
- if (Listing == null) return;
- base.OnMouseLeave();
- GameScene.Scene.DisposeItemLabel();
- GameScene.HoverItem = null;
- }
- }
- #endregion
- public class Filter
- {
- public int Index { get; set; } = -1;
- public string Title { get; set; } = "";
- public ItemType? Type { get; set; } = ItemType.Nothing;
- public short MinShape { get; set; } = 0;
- public short MaxShape { get; set; } = short.MaxValue;
- public List<Filter> SubFilters = new List<Filter>();
- }
- }
- }
|