1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-09-28 22:26:30 -04:00

Merge branch 'master' of github.com:essial/OpenDiablo2

This commit is contained in:
Tim Sarbin 2018-12-13 22:34:28 -05:00
commit f56273a4a2

View File

@ -15,11 +15,14 @@
*/ */
using System; using System;
using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Linq;
using OpenDiablo2.Common; using OpenDiablo2.Common;
using OpenDiablo2.Common.Enums; using OpenDiablo2.Common.Enums;
using OpenDiablo2.Common.Extensions; using OpenDiablo2.Common.Extensions;
using OpenDiablo2.Common.Interfaces; using OpenDiablo2.Common.Interfaces;
using OpenDiablo2.Common.Models;
namespace OpenDiablo2.Core.UI namespace OpenDiablo2.Core.UI
{ {
@ -29,11 +32,12 @@ namespace OpenDiablo2.Core.UI
public sealed class InventoryPanel : IInventoryPanel public sealed class InventoryPanel : IInventoryPanel
{ {
private readonly IRenderWindow renderWindow; private readonly IRenderWindow renderWindow;
private readonly IMapEngine mapEngine;
private readonly ISprite panelSprite; private readonly ISprite panelSprite;
public IItemContainer helmContainer, armorContainer, beltContainer, gloveContainer, bootsContainer, public IItemContainer headContainer, torsoContainer, beltContainer, gloveContainer, bootsContainer,
leftHandContainer, rightHandContainer, secondaryLeftHandContainer, secondaryRightHandContainer, leftHandContainer, rightHandContainer, secondaryLeftHandContainer, secondaryRightHandContainer,
ringtLeftContainer, ringtRightContainer, amuletContainer; ringLeftContainer, ringRightContainer, neckContainer;
private readonly IButton closeButton, secondaryLeftButton, secondaryRightButton, goldButton; private readonly IButton closeButton, secondaryLeftButton, secondaryRightButton, goldButton;
@ -41,10 +45,15 @@ namespace OpenDiablo2.Core.UI
public InventoryPanel(IRenderWindow renderWindow, public InventoryPanel(IRenderWindow renderWindow,
IItemManager itemManager, IItemManager itemManager,
IMapEngine mapEngine,
ISessionManager sessionManager,
Func<eItemContainerType, IItemContainer> createItemContainer, Func<eItemContainerType, IItemContainer> createItemContainer,
Func<eButtonType, IButton> createButton) Func<eButtonType, IButton> createButton)
{ {
this.renderWindow = renderWindow; this.renderWindow = renderWindow;
this.mapEngine = mapEngine;
sessionManager.OnPlayerInfo += OnPlayerInfo;
panelSprite = renderWindow.LoadSprite(ResourcePaths.InventoryCharacterPanel, Palettes.Units, FrameType.GetOffset(), true); panelSprite = renderWindow.LoadSprite(ResourcePaths.InventoryCharacterPanel, Palettes.Units, FrameType.GetOffset(), true);
@ -64,20 +73,20 @@ namespace OpenDiablo2.Core.UI
goldButton.Location = panelSprite.Location + new Size(84, 391); goldButton.Location = panelSprite.Location + new Size(84, 391);
goldButton.OnActivate = OpenGoldDrop; goldButton.OnActivate = OpenGoldDrop;
helmContainer = createItemContainer(eItemContainerType.Helm); headContainer = createItemContainer(eItemContainerType.Helm);
helmContainer.Location = panelSprite.Location + new Size(135, 5); headContainer.Location = panelSprite.Location + new Size(135, 5);
amuletContainer = createItemContainer(eItemContainerType.Amulet); neckContainer = createItemContainer(eItemContainerType.Amulet);
amuletContainer.Location = panelSprite.Location + new Size(209, 34); neckContainer.Location = panelSprite.Location + new Size(209, 34);
armorContainer = createItemContainer(eItemContainerType.Armor); torsoContainer = createItemContainer(eItemContainerType.Armor);
armorContainer.Location = panelSprite.Location + new Size(135, 75); torsoContainer.Location = panelSprite.Location + new Size(135, 75);
leftHandContainer = createItemContainer(eItemContainerType.Weapon);
leftHandContainer.Location = panelSprite.Location + new Size(20, 47);
rightHandContainer = createItemContainer(eItemContainerType.Weapon); rightHandContainer = createItemContainer(eItemContainerType.Weapon);
rightHandContainer.Location = panelSprite.Location + new Size(253, 47); rightHandContainer.Location = panelSprite.Location + new Size(20, 47);
leftHandContainer = createItemContainer(eItemContainerType.Weapon);
leftHandContainer.Location = panelSprite.Location + new Size(253, 47);
secondaryLeftHandContainer = createItemContainer(eItemContainerType.Weapon); secondaryLeftHandContainer = createItemContainer(eItemContainerType.Weapon);
secondaryLeftHandContainer.Location = panelSprite.Location + new Size(24, 45); secondaryLeftHandContainer.Location = panelSprite.Location + new Size(24, 45);
@ -88,11 +97,11 @@ namespace OpenDiablo2.Core.UI
beltContainer = createItemContainer(eItemContainerType.Belt); beltContainer = createItemContainer(eItemContainerType.Belt);
beltContainer.Location = panelSprite.Location + new Size(136, 178); beltContainer.Location = panelSprite.Location + new Size(136, 178);
ringtLeftContainer = createItemContainer(eItemContainerType.Ring); ringLeftContainer = createItemContainer(eItemContainerType.Ring);
ringtLeftContainer.Location = panelSprite.Location + new Size(95, 179); ringLeftContainer.Location = panelSprite.Location + new Size(95, 179);
ringtRightContainer = createItemContainer(eItemContainerType.Ring); ringRightContainer = createItemContainer(eItemContainerType.Ring);
ringtRightContainer.Location = panelSprite.Location + new Size(209, 179); ringRightContainer.Location = panelSprite.Location + new Size(209, 179);
gloveContainer = createItemContainer(eItemContainerType.Glove); gloveContainer = createItemContainer(eItemContainerType.Glove);
gloveContainer.Location = panelSprite.Location + new Size(20, 179); gloveContainer.Location = panelSprite.Location + new Size(20, 179);
@ -106,6 +115,23 @@ namespace OpenDiablo2.Core.UI
public bool IsSecondaryEquipped { get; private set; } public bool IsSecondaryEquipped { get; private set; }
public void OnPlayerInfo(int clientHash, IEnumerable<PlayerInfo> playerInfos)
{
// TODO: Ugly hack. Update when we can look up by GUID
var currentPLayer = playerInfos.ToArray()[mapEngine.FocusedPlayerId];
leftHandContainer.SetContainedItem(currentPLayer.Equipment.LeftArm);
rightHandContainer.SetContainedItem(currentPLayer.Equipment.RightArm);
torsoContainer.SetContainedItem(currentPLayer.Equipment.Torso);
headContainer.SetContainedItem(currentPLayer.Equipment.Head);
ringLeftContainer.SetContainedItem(currentPLayer.Equipment.LeftRing);
ringRightContainer.SetContainedItem(currentPLayer.Equipment.RightRing);
beltContainer.SetContainedItem(currentPLayer.Equipment.Belt);
neckContainer.SetContainedItem(currentPLayer.Equipment.Neck);
gloveContainer.SetContainedItem(currentPLayer.Equipment.Gloves);
}
public void Update() public void Update()
{ {
if (IsSecondaryEquipped) if (IsSecondaryEquipped)
@ -125,12 +151,12 @@ namespace OpenDiablo2.Core.UI
closeButton.Update(); closeButton.Update();
goldButton.Update(); goldButton.Update();
helmContainer.Update(); headContainer.Update();
amuletContainer.Update(); neckContainer.Update();
armorContainer.Update(); torsoContainer.Update();
beltContainer.Update(); beltContainer.Update();
ringtLeftContainer.Update(); ringLeftContainer.Update();
ringtRightContainer.Update(); ringRightContainer.Update();
gloveContainer.Update(); gloveContainer.Update();
bootsContainer.Update(); bootsContainer.Update();
} }
@ -155,12 +181,12 @@ namespace OpenDiablo2.Core.UI
closeButton.Render(); closeButton.Render();
goldButton.Render(); goldButton.Render();
helmContainer.Render(); headContainer.Render();
amuletContainer.Render(); neckContainer.Render();
armorContainer.Render(); torsoContainer.Render();
beltContainer.Render(); beltContainer.Render();
ringtLeftContainer.Render(); ringLeftContainer.Render();
ringtRightContainer.Render(); ringRightContainer.Render();
gloveContainer.Render(); gloveContainer.Render();
bootsContainer.Render(); bootsContainer.Render();
} }