From c0d114531ea0f086321a788c90e58c1e8297af81 Mon Sep 17 00:00:00 2001 From: Ethan Moffat Date: Thu, 15 Sep 2022 12:53:19 -0700 Subject: [PATCH] First-pass implementation of trade dialog. TODO: - Wire up to open on trade requests - Inventory space validator implementation - Drag+drop from inventory to add items - Testing --- EndlessClient/Dialogs/ListDialogItem.cs | 2 + EndlessClient/Dialogs/Old/EODialogBase.cs | 106 ----- .../Dialogs/Old/OldListDialogItem.cs | 321 ------------- EndlessClient/Dialogs/Old/TradeDialog.cs | 445 ------------------ EndlessClient/Dialogs/TradeDialog.cs | 175 ++++++- .../HUD/Inventory/InventorySpaceValidator.cs | 9 +- EndlessClient/Old/OldWorld.cs | 1 - .../Rendering/Map/MapItemGraphicProvider.cs | 2 +- EndlessClient/Rendering/OldNPCRenderer.cs | 1 - 9 files changed, 167 insertions(+), 895 deletions(-) delete mode 100644 EndlessClient/Dialogs/Old/EODialogBase.cs delete mode 100644 EndlessClient/Dialogs/Old/OldListDialogItem.cs delete mode 100644 EndlessClient/Dialogs/Old/TradeDialog.cs diff --git a/EndlessClient/Dialogs/ListDialogItem.cs b/EndlessClient/Dialogs/ListDialogItem.cs index 4b3d28502..e159e34c8 100644 --- a/EndlessClient/Dialogs/ListDialogItem.cs +++ b/EndlessClient/Dialogs/ListDialogItem.cs @@ -95,6 +95,8 @@ public string SubText public bool ShowIconBackGround { get; set; } + public object Data { get; set; } + public event EventHandler RightClick; public event EventHandler LeftClick; diff --git a/EndlessClient/Dialogs/Old/EODialogBase.cs b/EndlessClient/Dialogs/Old/EODialogBase.cs deleted file mode 100644 index 2bb90b3eb..000000000 --- a/EndlessClient/Dialogs/Old/EODialogBase.cs +++ /dev/null @@ -1,106 +0,0 @@ -using EndlessClient.Dialogs.Services; -using EndlessClient.GameExecution; -using EndlessClient.Old; -using EOLib.Graphics; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using XNAControls.Old; - -namespace EndlessClient.Dialogs.Old -{ - public abstract class EODialogBase : XNADialog - { - protected readonly Texture2D smallButtonSheet; - - protected EODialogBase(INativeGraphicsManager nativeGraphicsManager) - { - smallButtonSheet = nativeGraphicsManager.TextureFromResource(GFXTypes.PreLoginUI, 15, true); - } - - protected void endConstructor(bool centerDialog = true) - { - //center dialog based on txtSize of background texture - if (centerDialog) - { - Center(Game.GraphicsDevice); - if (EOGame.Instance.State == GameStates.PlayingTheGame) - { - DrawLocation = new Vector2(DrawLocation.X, (330 - DrawArea.Height) / 2f); - } - } - _fixDrawOrder(); - DrawOrder += 100; - Dialogs.Push(this); - - Game.Components.Add(this); - } - - //todo: usage of this should eventually be refactored out if possible - protected void CenterAndFixDrawOrder(IGraphicsDeviceProvider graphicsDeviceProvider, - IGameStateProvider gameStateProvider, - bool shouldCenter = true) - { - if (shouldCenter) - { - Center(graphicsDeviceProvider.GraphicsDevice); - - if (gameStateProvider.CurrentState == GameStates.PlayingTheGame) - DrawLocation = new Vector2(DrawLocation.X, (330 - DrawArea.Height)/2f); - } - - _fixDrawOrder(); - DrawOrder += 100; - - Dialogs.Push(this); - Game.Components.Add(this); - } - - protected Rectangle _getSmallButtonOut(SmallButton whichOne) - { - int widthDelta = smallButtonSheet.Width / 2; - int heightDelta = smallButtonSheet.Height / (int)SmallButton.NUM_BUTTONS; - return new Rectangle(0, heightDelta * (int)whichOne, widthDelta, heightDelta); - } - - protected Rectangle _getSmallButtonOver(SmallButton whichOne) - { - int widthDelta = smallButtonSheet.Width / 2; - int heightDelta = smallButtonSheet.Height / (int)SmallButton.NUM_BUTTONS; - return new Rectangle(widthDelta, heightDelta * (int)whichOne, widthDelta, heightDelta); - } - - protected enum ListIcon - { - Buy = 0, - Sell, - BankDeposit, - BankWithdraw, - Craft, - BankLockerUpgrade, - - Learn = 20, - Forget = 21, - } - protected Texture2D _getDlgIcon(ListIcon whichOne) - { - const int NUM_PER_ROW = 9; - const int ICON_SIZE = 31; - - Texture2D weirdSheet = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 27); - Color[] dat = new Color[ICON_SIZE * ICON_SIZE]; - - Rectangle src = new Rectangle(((int)whichOne % NUM_PER_ROW) * ICON_SIZE, 291 + ((int)whichOne / NUM_PER_ROW) * ICON_SIZE, ICON_SIZE, ICON_SIZE); - weirdSheet.GetData(0, src, dat, 0, dat.Length); - - Texture2D ret = new Texture2D(EOGame.Instance.GraphicsDevice, ICON_SIZE, ICON_SIZE); - ret.SetData(dat); - return ret; - } - - /// - /// This is a no-op to hide Resharper warnings. It may eventually do something. - /// It would be nice to trigger adding all controls to Components by calling this. - /// - public virtual void Show() { } - } -} diff --git a/EndlessClient/Dialogs/Old/OldListDialogItem.cs b/EndlessClient/Dialogs/Old/OldListDialogItem.cs deleted file mode 100644 index 6c4006c59..000000000 --- a/EndlessClient/Dialogs/Old/OldListDialogItem.cs +++ /dev/null @@ -1,321 +0,0 @@ -using System; -using EndlessClient.Old; -using EOLib; -using EOLib.Graphics; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Microsoft.Xna.Framework.Input; -using XNAControls.Old; - -namespace EndlessClient.Dialogs.Old -{ - public class OldListDialogItem : XNAControl - { - private static readonly object disposingLock = new object(); - private bool m_disposing; - - /// - /// Optional item ID to use for this List Item Record - /// - public short ID { get; set; } - /// - /// Optional item amount to use for this List Item Record - /// - public int Amount { get; set; } - - private int m_index; - /// - /// Get or Set the index within the parent control. - /// - public int Index - { - get { return m_index; } - set - { - m_index = value; - DrawLocation = new Vector2(DrawLocation.X, OffsetY + (m_index * (Style == ListItemStyle.Large ? 36 : 16))); - } - } - - private int m_xOffset, m_yOffset; - - public int OffsetX - { - get - { - return m_xOffset; - } - set - { - int oldOff = m_xOffset; - m_xOffset = value; - DrawLocation = DrawLocation + new Vector2(m_xOffset - oldOff, 0); - } - } - - /// - /// Starting Y Offset to draw list item controls - /// - public int OffsetY - { - get - { - return m_yOffset; - } - set - { - int oldOff = m_yOffset; - m_yOffset = value; - DrawLocation = DrawLocation + new Vector2(0, m_yOffset - oldOff); - } - } - - /// - /// Style of the control - either small (single text row) or large (graphic w/two rows of text) - /// - public ListItemStyle Style { get; set; } - - /// - /// For Large style control, sets whether or not the item graphic has a background image (ie red pad thing) - /// - public bool ShowItemBackGround { get; set; } - - /// - /// Get or set the primary text - /// - public string Text - { - get { return m_primaryText.Text; } - set - { - m_primaryText.Text = value; - m_primaryText.ResizeBasedOnText(); - } - } - - /// - /// Get or set the secondary text - /// - public string SubText - { - get { return m_secondaryText.Text; } - set - { - m_secondaryText.Text = value; - m_secondaryText.ResizeBasedOnText(); - } - } - - public Texture2D IconGraphic - { - get { return m_gfxItem; } - set { m_gfxItem = value; } - } - - public event EventHandler OnRightClick; - public event EventHandler OnLeftClick; - - protected XNALabel m_primaryText; - protected XNALabel m_secondaryText; - - private readonly Texture2D m_gfxPadThing; - private Texture2D m_gfxItem; - private readonly Texture2D m_backgroundColor; - private bool m_drawBackground; - private bool m_rightClicked; - - public enum ListItemStyle - { - Small, - Large - } - - public OldListDialogItem(EODialogBase parent, ListItemStyle style, int listIndex = -1) - { - DrawLocation = new Vector2(17, DrawLocation.Y); //the base X coordinate is 17 - this can be adjusted with OffsetX property - - Style = style; - if (listIndex >= 0) - Index = listIndex; - - _setSize(232, Style == ListItemStyle.Large ? 36 : 13); - - int colorFactor = Style == ListItemStyle.Large ? 0xc8 : 0xb4; - - m_primaryText = new XNALabel(new Rectangle(Style == ListItemStyle.Large ? 56 : 2, Style == ListItemStyle.Large ? 5 : 0, 1, 1), Constants.FontSize08pt5) - { - AutoSize = false, - BackColor = Color.Transparent, - ForeColor = Color.FromNonPremultiplied(colorFactor, colorFactor, colorFactor, 0xff), - TextAlign = LabelAlignment.TopLeft, - Text = " " - }; - m_primaryText.ResizeBasedOnText(); - - if (Style == ListItemStyle.Large) - { - m_secondaryText = new XNALabel(new Rectangle(56, 20, 1, 1), Constants.FontSize08pt5) - { - AutoSize = true, - BackColor = m_primaryText.BackColor, - ForeColor = m_primaryText.ForeColor, - Text = " " - }; - m_secondaryText.ResizeBasedOnText(); - - m_gfxPadThing = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.MapTiles, 0, true); - ShowItemBackGround = true; - } - m_backgroundColor = new Texture2D(Game.GraphicsDevice, 1, 1); - m_backgroundColor.SetData(new[] { Color.FromNonPremultiplied(0xff, 0xff, 0xff, 64) }); - - SetParent(parent); - m_primaryText.SetParent(this); - if (Style == ListItemStyle.Large) - { - m_secondaryText.SetParent(this); - } - OffsetY = Style == ListItemStyle.Large ? 25 : 45; - } - - /// - /// turns the primary text into a link that performs the specified action. When Style is Small, the entire item becomes clickable. - /// - /// The action to perform - public void SetPrimaryTextLink(Action onClickAction) - { - if (m_primaryText == null) - return; - XNALabel oldText = m_primaryText; - m_primaryText = new XNAHyperLink(oldText.DrawArea, Constants.FontSize08pt5) - { - AutoSize = false, - BackColor = oldText.BackColor, - ForeColor = oldText.ForeColor, - HighlightColor = oldText.ForeColor, - Text = oldText.Text, - Underline = true - }; - m_primaryText.ResizeBasedOnText(); - ((XNAHyperLink)m_primaryText).OnClick += (o, e) => onClickAction(); - m_primaryText.SetParent(this); - oldText.Close(); - - if (Style == ListItemStyle.Small) - OnLeftClick += (o, e) => onClickAction(); - } - - //turns the subtext into a link that performs the specified action - public void SetSubtextLink(Action onClickAction) - { - if (m_secondaryText == null || Style == ListItemStyle.Small) - return; - XNALabel oldText = m_secondaryText; - m_secondaryText = new XNAHyperLink(oldText.DrawArea, Constants.FontSize08pt5) - { - AutoSize = false, - BackColor = oldText.BackColor, - ForeColor = oldText.ForeColor, - HighlightColor = oldText.ForeColor, - Text = oldText.Text, - Underline = true - }; - m_secondaryText.ResizeBasedOnText(); - ((XNAHyperLink)m_secondaryText).OnClick += (o, e) => onClickAction(); - m_secondaryText.SetParent(this); - oldText.Close(); - } - - public override void Update(GameTime gameTime) - { - if (!Visible || !Game.IsActive) return; - - lock (disposingLock) - { - if (m_disposing) return; - - MouseState ms = Mouse.GetState(); - - if (MouseOver && MouseOverPreviously) - { - m_drawBackground = true; - if (ms.RightButton == ButtonState.Pressed) - { - m_rightClicked = true; - } - - if (m_rightClicked && ms.RightButton == ButtonState.Released && OnRightClick != null) - { - OnRightClick(this, null); - m_rightClicked = false; - } - else if (PreviousMouseState.LeftButton == ButtonState.Pressed && ms.LeftButton == ButtonState.Released && - OnLeftClick != null) - { - //If the sub text is a hyperlink and the mouse is over it do the click event for the sub text and not for this item - if (m_secondaryText is XNAHyperLink && m_secondaryText.MouseOver) - ((XNAHyperLink)m_secondaryText).Click(); - else - OnLeftClick(this, null); - } - } - else - { - m_drawBackground = false; - } - - base.Update(gameTime); - } - } - - public override void Draw(GameTime gameTime) - { - if (!Visible) return; - - lock (disposingLock) - { - if (m_disposing) - return; - SpriteBatch.Begin(); - if (m_drawBackground) - { - //Rectangle backgroundRect = new Rectangle(DrawAreaWithOffset.X + OffsetX, DrawAreaWithOffset.Y + OffsetY, DrawAreaWithOffset.Width, DrawAreaWithOffset.Height); - SpriteBatch.Draw(m_backgroundColor, DrawAreaWithOffset, Color.White); - } - if (Style == ListItemStyle.Large) - { - //The area for showing these is 64x36px: center the icon and background accordingly - Vector2 offset = new Vector2(xOff + OffsetX + 14/*not sure of the significance of this offset*/, yOff + OffsetY + 36 * Index); - if (ShowItemBackGround) - SpriteBatch.Draw(m_gfxPadThing, new Vector2(offset.X + ((64 - m_gfxPadThing.Width) / 2f), offset.Y + (36 - m_gfxPadThing.Height) / 2f), Color.White); - if (m_gfxItem != null) - SpriteBatch.Draw(m_gfxItem, - new Vector2((float)Math.Round(offset.X + ((64 - m_gfxItem.Width) / 2f)), - (float)Math.Round(offset.Y + (36 - m_gfxItem.Height) / 2f)), - Color.White); - } - SpriteBatch.End(); - base.Draw(gameTime); - } - } - - public void SetActive() - { - m_primaryText.ForeColor = Color.FromNonPremultiplied(0xf0, 0xf0, 0xf0, 0xff); - } - - protected override void Dispose(bool disposing) - { - lock (disposingLock) - { - m_disposing = true; - if (disposing) - { - m_backgroundColor.Dispose(); - } - } - - base.Dispose(disposing); - } - } -} diff --git a/EndlessClient/Dialogs/Old/TradeDialog.cs b/EndlessClient/Dialogs/Old/TradeDialog.cs deleted file mode 100644 index a5e25f154..000000000 --- a/EndlessClient/Dialogs/Old/TradeDialog.cs +++ /dev/null @@ -1,445 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using EndlessClient.Dialogs.Services; -using EndlessClient.Old; -using EndlessClient.UIControls; -using EOLib; -using EOLib.Domain.Character; -using EOLib.Graphics; -using EOLib.IO; -using EOLib.Localization; -using EOLib.Net.API; -using Microsoft.Xna.Framework; -using XNAControls.Old; - -namespace EndlessClient.Dialogs.Old -{ - public class TradeDialog : EODialogBase - { - //dialog has: - // - 2 lists of items on each side - // - 2 scroll bars (1 each side) - // - 2 name labels (1 each side) - // - 2 agree/trading labels (1 each side) - // - Ok/cancel buttons - - private short m_leftPlayerID, m_rightPlayerID; - private string m_leftNameStr, m_rightNameStr; - private readonly XNALabel m_leftPlayerName, m_rightPlayerName; - private readonly XNALabel m_leftPlayerStatus, m_rightPlayerStatus; - private readonly OldScrollBar m_leftScroll, m_rightScroll; - private bool m_leftAgrees, m_rightAgrees; - private readonly List m_leftItems, m_rightItems; - - private readonly OldCharacter m_main; //local reference - - private int m_recentPartnerRemoves; - - public static TradeDialog Instance { get; private set; } - - public bool MainPlayerAgrees => (m_main.ID == m_leftPlayerID && m_leftAgrees) || - (m_main.ID == m_rightPlayerID && m_rightAgrees); - - public TradeDialog(/*PacketAPI apiHandle*/) - : base(null) - { - bgTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 50); - _setSize(bgTexture.Width, bgTexture.Height); - - Instance = this; - DialogClosing += (sender, args) => Instance = null; - m_main = OldWorld.Instance.MainPlayer.ActiveCharacter; - - m_leftItems = new List(); - m_rightItems = new List(); - - m_leftPlayerID = 0; - m_rightPlayerID = 0; - - m_leftPlayerName = new XNALabel(new Rectangle(20, 14, 166, 20), Constants.FontSize08pt5) - { - AutoSize = false, - TextAlign = LabelAlignment.MiddleLeft, - ForeColor = ColorConstants.LightGrayText - }; - m_leftPlayerName.SetParent(this); - m_rightPlayerName = new XNALabel(new Rectangle(285, 14, 166, 20), Constants.FontSize08pt5) - { - AutoSize = false, - TextAlign = LabelAlignment.MiddleLeft, - ForeColor = ColorConstants.LightGrayText - }; - m_rightPlayerName.SetParent(this); - m_leftPlayerStatus = new XNALabel(new Rectangle(195, 14, 79, 20), Constants.FontSize08pt5) - { - AutoSize = false, - TextAlign = LabelAlignment.MiddleLeft, - Text = OldWorld.GetString(EOResourceID.DIALOG_TRADE_WORD_TRADING), - ForeColor = ColorConstants.LightGrayText - }; - m_leftPlayerStatus.SetParent(this); - m_rightPlayerStatus = new XNALabel(new Rectangle(462, 14, 79, 20), Constants.FontSize08pt5) - { - AutoSize = false, - TextAlign = LabelAlignment.MiddleLeft, - Text = OldWorld.GetString(EOResourceID.DIALOG_TRADE_WORD_TRADING), - ForeColor = ColorConstants.LightGrayText - }; - m_rightPlayerStatus.SetParent(this); - - m_leftScroll = new OldScrollBar(this, new Vector2(252, 44), new Vector2(16, 199), ScrollBarColors.LightOnMed) { LinesToRender = 5 }; - m_rightScroll = new OldScrollBar(this, new Vector2(518, 44), new Vector2(16, 199), ScrollBarColors.LightOnMed) { LinesToRender = 5 }; - - //BUTTONSSSS - XNAButton ok = new XNAButton(smallButtonSheet, new Vector2(356, 252), _getSmallButtonOut(SmallButton.Ok), - _getSmallButtonOver(SmallButton.Ok)); - ok.OnClick += _buttonOkClicked; - ok.SetParent(this); - dlgButtons.Add(ok); - XNAButton cancel = new XNAButton(smallButtonSheet, new Vector2(449, 252), _getSmallButtonOut(SmallButton.Cancel), - _getSmallButtonOver(SmallButton.Cancel)); - cancel.OnClick += _buttonCancelClicked; - cancel.SetParent(this); - dlgButtons.Add(cancel); - - Timer localTimer = new Timer(state => - { - if (m_recentPartnerRemoves > 0) - m_recentPartnerRemoves--; - }, null, 0, 5000); - - DialogClosing += (o, e) => - { - if (e.Result == XNADialogResult.Cancel) - { - //if (!m_api.TradeClose()) - // ((EOGame)Game).DoShowLostConnectionDialogAndReturnToMainMenu(); - //((EOGame)Game).Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_ACTION, EOResourceID.STATUS_LABEL_TRADE_ABORTED); - } - - localTimer.Dispose(); - }; - - Center(Game.GraphicsDevice); - DrawLocation = new Vector2(DrawLocation.X, 30); - endConstructor(false); - } - - public void InitPlayerInfo(short player1, string player1Name, short player2, string player2Name) - { - m_leftPlayerID = player1; - m_rightPlayerID = player2; - m_leftNameStr = m_leftPlayerName.Text = char.ToUpper(player1Name[0]) + player1Name.Substring(1); - m_rightNameStr = m_rightPlayerName.Text = char.ToUpper(player2Name[0]) + player2Name.Substring(1); - } - - public void SetPlayerItems(short playerID, List items) - { - int xOffset; - List collectionRef; - OldScrollBar scrollRef; - - if (playerID == m_leftPlayerID) - { - collectionRef = m_leftItems; - scrollRef = m_leftScroll; - xOffset = -3; - m_leftPlayerName.Text = $"{m_leftNameStr} {(items.Count > 0 ? "[" + items.Count + "]" : "")}"; - - if (m_leftAgrees) - { - m_leftAgrees = false; - m_leftPlayerStatus.Text = OldWorld.GetString(EOResourceID.DIALOG_TRADE_WORD_TRADING); - } - - //left player is NOT main, and right player (ie main) agrees, and the item count is different for left player - //cancel the offer for the main player since the other player changed the offer - if (m_main.ID != playerID && m_rightAgrees && collectionRef.Count != items.Count) - { - m_rightAgrees = false; - m_rightPlayerStatus.Text = OldWorld.GetString(EOResourceID.DIALOG_TRADE_WORD_TRADING); - EOMessageBox.Show(DialogResourceID.TRADE_ABORTED_OFFER_CHANGED, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader); - //((EOGame)Game).Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_WARNING, EOResourceID.STATUS_LABEL_TRADE_OTHER_PLAYER_CHANGED_OFFER); - } - } - else if (playerID == m_rightPlayerID) - { - collectionRef = m_rightItems; - scrollRef = m_rightScroll; - xOffset = 263; - m_rightPlayerName.Text = $"{m_rightNameStr} {(items.Count > 0 ? "[" + items.Count + "]" : "")}"; - - if (m_rightAgrees) - { - m_rightAgrees = false; - m_rightPlayerStatus.Text = OldWorld.GetString(EOResourceID.DIALOG_TRADE_WORD_TRADING); - } - - //right player is NOT main, and left player (ie main) agrees, and the item count is different for right player - //cancel the offer for the main player since the other player changed the offer - if (m_main.ID != playerID && m_leftAgrees && collectionRef.Count != items.Count) - { - m_leftAgrees = false; - m_leftPlayerStatus.Text = OldWorld.GetString(EOResourceID.DIALOG_TRADE_WORD_TRADING); - EOMessageBox.Show(DialogResourceID.TRADE_ABORTED_OFFER_CHANGED, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader); - //((EOGame)Game).Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_WARNING, EOResourceID.STATUS_LABEL_TRADE_OTHER_PLAYER_CHANGED_OFFER); - } - } - else - throw new ArgumentException("Invalid Player ID for trade session!", nameof(playerID)); - - if (m_main.ID != playerID && collectionRef.Count > items.Count) - m_recentPartnerRemoves++; - if (m_recentPartnerRemoves == 3) - { - EOMessageBox.Show(DialogResourceID.TRADE_OTHER_PLAYER_TRICK_YOU, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader); - m_recentPartnerRemoves = -1000; //this will prevent the message from showing more than once (I'm too lazy to find something more elegant) - } - - foreach (var oldItem in collectionRef) oldItem.Close(); - collectionRef.Clear(); - - int index = 0; - foreach (InventoryItem item in items) - { - int localID = item.ItemID; - - var rec = OldWorld.Instance.EIF[item.ItemID]; - string secondary = - $"x {item.Amount} {(rec.Type == ItemType.Armor ? "(" + (rec.Gender == 0 ? OldWorld.GetString(EOResourceID.FEMALE) : OldWorld.GetString(EOResourceID.MALE)) + ")" : "")}"; - - int gfxNum = item.ItemID == 1 - ? 269 + 2 * (item.Amount >= 100000 ? 4 : (item.Amount >= 10000 ? 3 : (item.Amount >= 100 ? 2 : (item.Amount >= 2 ? 1 : 0)))) - : 2 * rec.Graphic - 1; - - var nextItem = new OldListDialogItem(this, OldListDialogItem.ListItemStyle.Large, index++) - { - Text = rec.Name, - SubText = secondary, - IconGraphic = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.Items, gfxNum, true), - ID = item.ItemID, - Amount = item.Amount, - OffsetX = xOffset, - OffsetY = 46 - }; - if (playerID == m_main.ID) - nextItem.OnRightClick += (sender, args) => _removeItem(localID); - collectionRef.Add(nextItem); - } - - scrollRef.UpdateDimensions(collectionRef.Count); - } - - public void SetPlayerAgree(bool isMain, bool agrees) - { - short playerID = isMain ? (short)m_main.ID : (m_leftPlayerID == m_main.ID ? m_rightPlayerID : m_leftPlayerID); - if (playerID == m_leftPlayerID) - { - //if (agrees && !m_leftAgrees) - // ((EOGame)Game).Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_ACTION, - // isMain ? EOResourceID.STATUS_LABEL_TRADE_YOU_ACCEPT : EOResourceID.STATUS_LABEL_TRADE_OTHER_ACCEPT); - //else if (!agrees && m_leftAgrees) - // ((EOGame)Game).Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_ACTION, - // isMain ? EOResourceID.STATUS_LABEL_TRADE_YOU_CANCEL : EOResourceID.STATUS_LABEL_TRADE_OTHER_CANCEL); - - m_leftAgrees = agrees; - m_leftPlayerStatus.Text = - OldWorld.GetString(agrees ? EOResourceID.DIALOG_TRADE_WORD_AGREE : EOResourceID.DIALOG_TRADE_WORD_TRADING); - } - else if (playerID == m_rightPlayerID) - { - //if (agrees && !m_rightAgrees) - // ((EOGame)Game).Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_ACTION, - // isMain ? EOResourceID.STATUS_LABEL_TRADE_YOU_ACCEPT : EOResourceID.STATUS_LABEL_TRADE_OTHER_ACCEPT); - //else if (!agrees && m_rightAgrees) - // ((EOGame)Game).Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_ACTION, - // isMain ? EOResourceID.STATUS_LABEL_TRADE_YOU_CANCEL : EOResourceID.STATUS_LABEL_TRADE_OTHER_CANCEL); - - m_rightAgrees = agrees; - m_rightPlayerStatus.Text = - OldWorld.GetString(agrees ? EOResourceID.DIALOG_TRADE_WORD_AGREE : EOResourceID.DIALOG_TRADE_WORD_TRADING); - } - else - throw new ArgumentException("Invalid Player ID for trade session!"); - } - - public void CompleteTrade(short p1, List p1items, short p2, List p2items) - { - List mainCollection, otherCollection; - if (p1 == m_main.ID) - { - mainCollection = p1items; - otherCollection = p2items; - } - else if (p2 == m_main.ID) - { - mainCollection = p2items; - otherCollection = p1items; - } - else - throw new ArgumentException("Invalid player ID for trade session!"); - - int weightDelta = 0; - //foreach (var item in mainCollection) - //{ - // m_main.UpdateInventoryItem(item.ItemID, -item.Amount, true); - // weightDelta -= OldWorld.Instance.EIF[item.ItemID].Weight * item.Amount; - //} - //foreach (var item in otherCollection) - //{ - // m_main.UpdateInventoryItem(item.ItemID, item.Amount, true); - // weightDelta += OldWorld.Instance.EIF[item.ItemID].Weight * item.Amount; - //} - m_main.Weight += (byte)weightDelta; - //((EOGame)Game).Hud.RefreshStats(); - - Close(null, XNADialogResult.NO_BUTTON_PRESSED); - EOMessageBox.Show(DialogResourceID.TRADE_SUCCESS, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader); - } - - private void _buttonOkClicked(object sender, EventArgs e) - { - if (m_leftPlayerID == m_main.ID) - { - if (m_leftAgrees) return; //main already agrees - } - else if (m_rightPlayerID == m_main.ID) - { - if (m_rightAgrees) return; //main already agrees - } - else - throw new InvalidOperationException("Invalid Player ID for trade session!"); - - if (m_leftItems.Count == 0 || m_rightItems.Count == 0) - { - EOMessageBox.Show(OldWorld.GetString(EOResourceID.DIALOG_TRADE_BOTH_PLAYERS_OFFER_ONE_ITEM), - OldWorld.GetString(EOResourceID.STATUS_LABEL_TYPE_WARNING), EODialogButtons.Ok, - EOMessageBoxStyle.SmallDialogSmallHeader); - //((EOGame)Game).Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_WARNING, EOResourceID.DIALOG_TRADE_BOTH_PLAYERS_OFFER_ONE_ITEM); - return; - } - - List mainCollection = m_main.ID == m_leftPlayerID ? m_leftItems : m_rightItems; - List otherCollection = m_main.ID == m_leftPlayerID ? m_rightItems : m_leftItems; - - //make sure that the items will fit! - //if (!((EOGame)Game).Hud.ItemsFit( - // otherCollection.Select(_item => new InventoryItem(_item.ID, _item.Amount)).ToList(), - // mainCollection.Select(_item => new InventoryItem(_item.ID, _item.Amount)).ToList())) - //{ - // EOMessageBox.Show(OldWorld.GetString(EOResourceID.DIALOG_TRANSFER_NOT_ENOUGH_SPACE), - // OldWorld.GetString(EOResourceID.STATUS_LABEL_TYPE_WARNING), EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader); - // return; - //} - - //make sure the change in weight + existing weight is not greater than the max weight! - int weightDelta = otherCollection.Sum(itemRef => OldWorld.Instance.EIF[itemRef.ID].Weight * itemRef.Amount); - weightDelta = mainCollection.Aggregate(weightDelta, (current, itemRef) => current - OldWorld.Instance.EIF[itemRef.ID].Weight * itemRef.Amount); - if (weightDelta + m_main.Weight > m_main.MaxWeight) - { - EOMessageBox.Show(OldWorld.GetString(EOResourceID.DIALOG_TRANSFER_NOT_ENOUGH_WEIGHT), - OldWorld.GetString(EOResourceID.STATUS_LABEL_TYPE_WARNING), EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader); - return; - } - - EOMessageBox.Show(DialogResourceID.TRADE_DO_YOU_AGREE, EODialogButtons.OkCancel, EOMessageBoxStyle.SmallDialogSmallHeader, - (o, dlgArgs) => - { - //if (dlgArgs.Result == XNADialogResult.OK && !m_api.TradeAgree(true)) - //{ - // Close(null, XNADialogResult.NO_BUTTON_PRESSED); - // ((EOGame)Game).DoShowLostConnectionDialogAndReturnToMainMenu(); - //} - }); - } - - private void _buttonCancelClicked(object sender, EventArgs e) - { - if (m_main.ID == m_leftPlayerID) - { - if (!m_leftAgrees) //just quit - Close(dlgButtons[1], XNADialogResult.Cancel); - //else if (!m_api.TradeAgree(false)) //cancel agreement - // ((EOGame)Game).DoShowLostConnectionDialogAndReturnToMainMenu(); - } - else if (m_main.ID == m_rightPlayerID) - { - if (!m_rightAgrees) //just quit - Close(dlgButtons[1], XNADialogResult.Cancel); - //else if (!m_api.TradeAgree(false)) - // ((EOGame)Game).DoShowLostConnectionDialogAndReturnToMainMenu(); - } - else - throw new InvalidOperationException("Invalid player ID for trade session!"); - } - - //item right-click event handler - private void _removeItem(int id) - { - //if (!m_api.TradeRemoveItem((short)id)) - //{ - // Close(null, XNADialogResult.NO_BUTTON_PRESSED); - // ((EOGame)Game).DoShowLostConnectionDialogAndReturnToMainMenu(); - //} - } - - public override void Update(GameTime gt) - { - //if (EOGame.Instance.Hud.IsInventoryDragging()) - //{ - // shouldClickDrag = false; - // SuppressParentClickDrag(true); - //} - //else - //{ - // shouldClickDrag = true; - // SuppressParentClickDrag(false); - //} - - //do the hiding logic for both sides - List scrollBars = new List { m_leftScroll, m_rightScroll }; - List> lists = new List> { m_leftItems, m_rightItems }; - for (int ndx = 0; ndx < 2; ++ndx) - { - var list = lists[ndx]; - var scroll = scrollBars[ndx]; - - //which items should we render? - if (list.Count > scroll.LinesToRender) - { - for (int i = 0; i < list.Count; ++i) - { - OldListDialogItem curr = list[i]; - if (i < scroll.ScrollOffset) - { - curr.Visible = false; - continue; - } - - if (i < scroll.LinesToRender + scroll.ScrollOffset) - { - curr.Visible = true; - curr.Index = i - scroll.ScrollOffset; - } - else - { - curr.Visible = false; - } - } - } - else if (list.Any(_item => !_item.Visible)) - list.ForEach(_item => _item.Visible = true); //all items visible if less than # lines to render - } - - base.Update(gt); - } - - public void Close(XNADialogResult result) - { - Close(null, result); - Close(); - } - } -} diff --git a/EndlessClient/Dialogs/TradeDialog.cs b/EndlessClient/Dialogs/TradeDialog.cs index 682b5c6c5..c47c969b8 100644 --- a/EndlessClient/Dialogs/TradeDialog.cs +++ b/EndlessClient/Dialogs/TradeDialog.cs @@ -1,12 +1,19 @@ -using EndlessClient.Content; +using EndlessClient.Dialogs.Factories; using EndlessClient.Dialogs.Services; +using EndlessClient.HUD; +using EndlessClient.HUD.Inventory; +using EndlessClient.HUD.Panels; +using EndlessClient.Rendering.Map; using EndlessClient.UIControls; using EOLib; using EOLib.Domain.Character; using EOLib.Domain.Trade; using EOLib.Graphics; +using EOLib.IO; +using EOLib.IO.Repositories; using EOLib.Localization; using Microsoft.Xna.Framework; +using Optional.Collections; using System; using System.Collections.Generic; using System.Diagnostics; @@ -17,9 +24,16 @@ namespace EndlessClient.Dialogs { public class TradeDialog : BaseEODialog { + private readonly ITradeActions _tradeActions; private readonly ILocalizedStringFinder _localizedStringFinder; + private readonly IEOMessageBoxFactory _messageBoxFactory; + private readonly IStatusLabelSetter _statusLabelSetter; + private readonly IInventorySpaceValidator _inventorySpaceValidator; private readonly ITradeProvider _tradeProvider; private readonly ICharacterProvider _characterProvider; + private readonly IEIFFileProvider _eifFileProvider; + private readonly IMapItemGraphicProvider _mapItemGraphicProvider; + private readonly InventoryPanel _inventoryPanel; private readonly IXNALabel _leftPlayerName, _rightPlayerName; private readonly IXNALabel _leftPlayerStatus, _rightPlayerStatus; @@ -39,16 +53,29 @@ public class TradeDialog : BaseEODialog private Stopwatch _partnerItemChangeTick; public TradeDialog(INativeGraphicsManager nativeGraphicsManager, + ITradeActions tradeActions, ILocalizedStringFinder localizedStringFinder, IEODialogButtonService dialogButtonService, + IEOMessageBoxFactory messageBoxFactory, + IStatusLabelSetter statusLabelSetter, + IInventorySpaceValidator inventorySpaceValidator, ITradeProvider tradeProvider, - ICharacterProvider characterProvider) + ICharacterProvider characterProvider, + IEIFFileProvider eifFileProvider, + IMapItemGraphicProvider mapItemGraphicProvider, + InventoryPanel inventoryPanel) : base(nativeGraphicsManager, isInGame: true) { + _tradeActions = tradeActions; _localizedStringFinder = localizedStringFinder; + _messageBoxFactory = messageBoxFactory; + _statusLabelSetter = statusLabelSetter; + _inventorySpaceValidator = inventorySpaceValidator; _tradeProvider = tradeProvider; _characterProvider = characterProvider; - + _eifFileProvider = eifFileProvider; + _mapItemGraphicProvider = mapItemGraphicProvider; + _inventoryPanel = inventoryPanel; BackgroundTexture = GraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 50); _leftPlayerName = new XNALabel(Constants.FontSize08pt5) @@ -131,11 +158,14 @@ public override void Initialize() protected override void OnUpdateControl(GameTime gameTime) { + var updateItemVisibility = false; + if (_tradeProvider.PlayerOneOffer != null && !_tradeProvider.PlayerOneOffer.Equals(_leftOffer)) { UpdateOffer(_tradeProvider.PlayerOneOffer, _leftOffer, _leftPlayerName, _leftPlayerStatus, _leftItems, -3); _leftOffer = _tradeProvider.PlayerOneOffer; _leftScroll.UpdateDimensions(_leftOffer.Items.Count); + updateItemVisibility = true; } if (_tradeProvider.PlayerTwoOffer != null && !_tradeProvider.PlayerTwoOffer.Equals(_rightOffer)) @@ -143,17 +173,18 @@ protected override void OnUpdateControl(GameTime gameTime) UpdateOffer(_tradeProvider.PlayerTwoOffer, _rightOffer, _rightPlayerName, _rightPlayerStatus, _rightItems, 263); _rightOffer = _tradeProvider.PlayerTwoOffer; _rightScroll.UpdateDimensions(_rightOffer.Items.Count); + updateItemVisibility = true; } - if (_leftScrollOffset != _leftScroll.ScrollOffset) + if (updateItemVisibility || _leftScrollOffset != _leftScroll.ScrollOffset) { - // todo: update left list item display + UpdateItemScrollIndexes(_leftScroll, _leftItems); _leftScrollOffset = _leftScroll.ScrollOffset; } - if (_rightScrollOffset != _rightScroll.ScrollOffset) + if (updateItemVisibility || _rightScrollOffset != _rightScroll.ScrollOffset) { - // todo: update right list item display + UpdateItemScrollIndexes(_rightScroll, _rightItems); _rightScrollOffset = _rightScroll.ScrollOffset; } @@ -163,6 +194,8 @@ protected override void OnUpdateControl(GameTime gameTime) _partnerItemChangeTick = Stopwatch.StartNew(); } + SuppressClickDragEvent(!_inventoryPanel.NoItemsDragging()); + base.OnUpdateControl(gameTime); } @@ -183,12 +216,20 @@ private void UpdateOffer(TradeOffer actualOffer, TradeOffer cachedOffer, ? _localizedStringFinder.GetString(EOResourceID.DIALOG_TRADE_WORD_AGREE) : _localizedStringFinder.GetString(EOResourceID.DIALOG_TRADE_WORD_TRADING); - //if (agrees && !m_leftAgrees) - // ((EOGame)Game).Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_ACTION, - // isMain ? EOResourceID.STATUS_LABEL_TRADE_YOU_ACCEPT : EOResourceID.STATUS_LABEL_TRADE_OTHER_ACCEPT); - //else if (!agrees && m_leftAgrees) - // ((EOGame)Game).Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_ACTION, - // isMain ? EOResourceID.STATUS_LABEL_TRADE_YOU_CANCEL : EOResourceID.STATUS_LABEL_TRADE_OTHER_CANCEL); + if (actualOffer.Agrees) + { + _statusLabelSetter.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_ACTION, + actualOffer.PlayerID == _characterProvider.MainCharacter.ID + ? EOResourceID.STATUS_LABEL_TRADE_YOU_ACCEPT + : EOResourceID.STATUS_LABEL_TRADE_OTHER_ACCEPT); + } + else + { + _statusLabelSetter.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_ACTION, + actualOffer.PlayerID == _characterProvider.MainCharacter.ID + ? EOResourceID.STATUS_LABEL_TRADE_YOU_CANCEL + : EOResourceID.STATUS_LABEL_TRADE_OTHER_CANCEL); + } } if (!actualOffer.Items.ToHashSet().SetEquals(cachedOffer.Items)) @@ -198,12 +239,34 @@ private void UpdateOffer(TradeOffer actualOffer, TradeOffer cachedOffer, foreach (var addedItem in added) { - //var newListItem = new ListDialogItem(this, ) + var itemRec = _eifFileProvider.EIFFile[addedItem.ItemID]; + var subText = $"x {addedItem.Amount} {(itemRec.Type == ItemType.Armor ? $"({_localizedStringFinder.GetString(itemRec.Gender == 0 ? EOResourceID.FEMALE : EOResourceID.MALE)})" : string.Empty)}"; + + var newListItem = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large) + { + Data = addedItem, + PrimaryText = itemRec.Name, + SubText = subText, + IconGraphic = _mapItemGraphicProvider.GetItemGraphic(addedItem.ItemID, addedItem.Amount), + OffsetX = listitemOffset, + OffsetY = 46 + }; + + if (actualOffer.PlayerID == _characterProvider.MainCharacter.ID) + newListItem.RightClick += (_, _) => _tradeActions.RemoveItemFromOffer((short)itemRec.ID); + + newListItem.SetParentControl(this); + listItems.Add(newListItem); } foreach (var removedItem in removed) { - + listItems.SingleOrNone(y => ((InventoryItem)y.Data).ItemID == removedItem.ItemID) + .MatchSome(listItem => + { + listItems.Remove(listItem); + listItem.Dispose(); + }); } if (actualOffer.PlayerID != _characterProvider.MainCharacter.ID) @@ -213,24 +276,98 @@ private void UpdateOffer(TradeOffer actualOffer, TradeOffer cachedOffer, if (_recentPartnerItemChanges == 3) { - //EOMessageBox.Show(DialogResourceID.TRADE_OTHER_PLAYER_TRICK_YOU, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader); - //m_recentPartnerRemoves = -1000; //this will prevent the message from showing more than once (I'm too lazy to find something more elegant) + var dlg = _messageBoxFactory.CreateMessageBox(DialogResourceID.TRADE_OTHER_PLAYER_TRICK_YOU); + dlg.ShowDialog(); + + // this will prevent the message from showing more than once per trade (I'm too lazy to find something more elegant) + _recentPartnerItemChanges = -1000; } else { - //EOMessageBox.Show(DialogResourceID.TRADE_ABORTED_OFFER_CHANGED, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader); - //((EOGame)Game).Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_WARNING, EOResourceID.STATUS_LABEL_TRADE_OTHER_PLAYER_CHANGED_OFFER); + var dlg = _messageBoxFactory.CreateMessageBox(DialogResourceID.TRADE_ABORTED_OFFER_CHANGED); + dlg.ShowDialog(); + + _statusLabelSetter.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_WARNING, EOResourceID.STATUS_LABEL_TRADE_OTHER_PLAYER_CHANGED_OFFER); } } } } + private void UpdateItemScrollIndexes(ScrollBar scrollBar, List items) + { + var scrollOffset = items.Count > scrollBar.LinesToRender ? scrollBar.ScrollOffset : 0; + + for (int i = 0; i < items.Count; i++) + { + items[i].Visible = i >= scrollOffset && i <= scrollBar.LinesToRender + scrollOffset; + items[i].Index = i - scrollOffset; + } + } + private void OkButtonClicked(object sender, EventArgs e) { + var (offer, partnerOffer) = _leftOffer.PlayerID == _characterProvider.MainCharacter.ID + ? (_leftOffer, _rightOffer) + : (_rightOffer, _leftOffer); + + if (offer.Agrees) + return; + + if (_leftOffer.Items.Count == 0 || _rightOffer.Items.Count == 0) + { + var dlg = _messageBoxFactory.CreateMessageBox(EOResourceID.DIALOG_TRADE_BOTH_PLAYERS_OFFER_ONE_ITEM, EOResourceID.STATUS_LABEL_TYPE_WARNING); + dlg.ShowDialog(); + return; + } + + if (!_inventorySpaceValidator.ItemsFit(offer.Items, partnerOffer.Items)) + { + var dlg = _messageBoxFactory.CreateMessageBox(EOResourceID.DIALOG_TRANSFER_NOT_ENOUGH_SPACE, EOResourceID.STATUS_LABEL_TYPE_WARNING); + dlg.ShowDialog(); + return; + } + + var partnerItemWeight = partnerOffer.Items + .Select(x => _eifFileProvider.EIFFile[x.ItemID].Weight * x.Amount) + .Aggregate((a, b) => a + b); + var offerItemWeight = offer.Items + .Select(x => _eifFileProvider.EIFFile[x.ItemID].Weight * x.Amount) + .Aggregate((a, b) => a + b); + + var stats = _characterProvider.MainCharacter.Stats; + if (stats[CharacterStat.Weight] - offerItemWeight + partnerItemWeight > stats[CharacterStat.MaxWeight]) + { + var dlg = _messageBoxFactory.CreateMessageBox(EOResourceID.DIALOG_TRANSFER_NOT_ENOUGH_WEIGHT, EOResourceID.STATUS_LABEL_TYPE_WARNING); + dlg.ShowDialog(); + return; + } + + var finalCheckDlg = _messageBoxFactory.CreateMessageBox(DialogResourceID.TRADE_DO_YOU_AGREE, EODialogButtons.OkCancel); + finalCheckDlg.DialogClosing += (o, e) => + { + if (e.Result == XNADialogResult.OK) + { + _tradeActions.AgreeToTrade(true); + } + }; + finalCheckDlg.ShowDialog(); } private void CancelButtonClicked(object sender, EventArgs e) { + var offer = _leftOffer.PlayerID == _characterProvider.MainCharacter.ID + ? _leftOffer + : _rightOffer; + + if (!offer.Agrees) + { + _tradeActions.CancelTrade(); + Close(XNADialogResult.Cancel); + } + else + { + _tradeActions.AgreeToTrade(false); + } } } } diff --git a/EndlessClient/HUD/Inventory/InventorySpaceValidator.cs b/EndlessClient/HUD/Inventory/InventorySpaceValidator.cs index 42a30ad6f..54766b72c 100644 --- a/EndlessClient/HUD/Inventory/InventorySpaceValidator.cs +++ b/EndlessClient/HUD/Inventory/InventorySpaceValidator.cs @@ -5,7 +5,9 @@ using EOLib.IO.Map; using EOLib.IO.Repositories; using Optional; +using System.Collections.Generic; using System.Linq; +using System.Windows.Documents; namespace EndlessClient.HUD.Inventory { @@ -38,6 +40,11 @@ public bool ItemFits(int itemId) return _characterInventoryProvider.ItemInventory.Any(x => x.ItemID == itemId) || ItemFits(_eifFileProvider.EIFFile[itemId].Size); } + public bool ItemsFit(IReadOnlyList outItems, IReadOnlyList inItems) + { + return true; + } + private bool ItemFits(ItemSize itemSize) { return _inventoryService @@ -52,6 +59,6 @@ public interface IInventorySpaceValidator bool ItemFits(int itemId); - // todo: need "ItemsFit" method for trading + bool ItemsFit(IReadOnlyList outItems, IReadOnlyList inItems); } } diff --git a/EndlessClient/Old/OldWorld.cs b/EndlessClient/Old/OldWorld.cs index 2267d76bd..05ff2597b 100644 --- a/EndlessClient/Old/OldWorld.cs +++ b/EndlessClient/Old/OldWorld.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using EndlessClient.Dialogs; -using EndlessClient.Dialogs.Old; using EndlessClient.GameExecution; using EndlessClient.Rendering; using EOLib.Config; diff --git a/EndlessClient/Rendering/Map/MapItemGraphicProvider.cs b/EndlessClient/Rendering/Map/MapItemGraphicProvider.cs index 4bdf33e6a..62a0ec038 100644 --- a/EndlessClient/Rendering/Map/MapItemGraphicProvider.cs +++ b/EndlessClient/Rendering/Map/MapItemGraphicProvider.cs @@ -6,7 +6,7 @@ namespace EndlessClient.Rendering.Map { - [MappedType(BaseType = typeof(IMapItemGraphicProvider), IsSingleton = true)] + [AutoMappedType] public class MapItemGraphicProvider : IMapItemGraphicProvider { private readonly INativeGraphicsManager _nativeGraphicsManager; diff --git a/EndlessClient/Rendering/OldNPCRenderer.cs b/EndlessClient/Rendering/OldNPCRenderer.cs index 9f5d4e9ea..088461b3b 100644 --- a/EndlessClient/Rendering/OldNPCRenderer.cs +++ b/EndlessClient/Rendering/OldNPCRenderer.cs @@ -1,6 +1,5 @@ using System; using System.Linq; -using EndlessClient.Dialogs.Old; using EndlessClient.Old; using EndlessClient.Rendering.Sprites; using EOLib;