diff --git a/OpenDiablo2.Common/Enums/eItemContainerType.cs b/OpenDiablo2.Common/Enums/eItemContainerType.cs new file mode 100644 index 00000000..e27fbae6 --- /dev/null +++ b/OpenDiablo2.Common/Enums/eItemContainerType.cs @@ -0,0 +1,15 @@ +namespace OpenDiablo2.Common.Enums +{ + public enum eItemContainerType + { + Helm, + Glove, + Armor, + Belt, + Boots, + Weapon, + Amulet, + Ring, + Generic + } +} diff --git a/OpenDiablo2.Common/Interfaces/ICharacterPanel.cs b/OpenDiablo2.Common/Interfaces/ICharacterPanel.cs new file mode 100644 index 00000000..3199519d --- /dev/null +++ b/OpenDiablo2.Common/Interfaces/ICharacterPanel.cs @@ -0,0 +1,10 @@ +using System; + +namespace OpenDiablo2.Common.Interfaces +{ + public interface ICharacterPanel : IDisposable + { + void Render(); + void Update(); + } +} diff --git a/OpenDiablo2.Common/Interfaces/IEngineDataManager.cs b/OpenDiablo2.Common/Interfaces/IEngineDataManager.cs index 1378cb9b..f8e58892 100644 --- a/OpenDiablo2.Common/Interfaces/IEngineDataManager.cs +++ b/OpenDiablo2.Common/Interfaces/IEngineDataManager.cs @@ -8,5 +8,6 @@ namespace OpenDiablo2.Common.Interfaces List LevelPresets { get; } List LevelTypes { get; } List LevelDetails { get; } + List Items { get; } } } diff --git a/OpenDiablo2.Common/Interfaces/IGameState.cs b/OpenDiablo2.Common/Interfaces/IGameState.cs index 934d8831..6cc3c677 100644 --- a/OpenDiablo2.Common/Interfaces/IGameState.cs +++ b/OpenDiablo2.Common/Interfaces/IGameState.cs @@ -22,6 +22,9 @@ namespace OpenDiablo2.Common.Interfaces bool ToggleShowCharacterPanel(); bool ShowCharacterPanel { get; set; } + Item SelectedItem { get; } + void SelectItem(Item item); + void Initialize(string text, eHero value, eSessionType sessionType); void Update(long ms); IEnumerable GetMapCellInfo(int cellX, int cellY, eRenderCellType renderCellType); diff --git a/OpenDiablo2.Common/Interfaces/IInventoryPanel.cs b/OpenDiablo2.Common/Interfaces/IInventoryPanel.cs new file mode 100644 index 00000000..50f842a2 --- /dev/null +++ b/OpenDiablo2.Common/Interfaces/IInventoryPanel.cs @@ -0,0 +1,10 @@ +using System; + +namespace OpenDiablo2.Common.Interfaces +{ + public interface IInventoryPanel : IDisposable + { + void Render(); + void Update(); + } +} diff --git a/OpenDiablo2.Common/Interfaces/IItem.cs b/OpenDiablo2.Common/Interfaces/IItem.cs new file mode 100644 index 00000000..3d23e2e5 --- /dev/null +++ b/OpenDiablo2.Common/Interfaces/IItem.cs @@ -0,0 +1,10 @@ +using System; + +namespace OpenDiablo2.Common.Interfaces +{ + public interface IItem + { + string Name { get; set; } + string Code { get; set; } + } +} diff --git a/OpenDiablo2.Common/Interfaces/IItemManager.cs b/OpenDiablo2.Common/Interfaces/IItemManager.cs new file mode 100644 index 00000000..1d91c3e9 --- /dev/null +++ b/OpenDiablo2.Common/Interfaces/IItemManager.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; +using OpenDiablo2.Common.Models; + +namespace OpenDiablo2.Common.Interfaces +{ + public interface IItemManager + { + Item getItem(string code); + } +} diff --git a/OpenDiablo2.Common/Interfaces/IPanelFrame.cs b/OpenDiablo2.Common/Interfaces/IPanelFrame.cs new file mode 100644 index 00000000..799eaede --- /dev/null +++ b/OpenDiablo2.Common/Interfaces/IPanelFrame.cs @@ -0,0 +1,11 @@ +using OpenDiablo2.Common.Enums; +using System; + +namespace OpenDiablo2.Common.Interfaces +{ + public interface IPanelFrame : IDisposable + { + void Render(); + void Update(); + } +} diff --git a/OpenDiablo2.Common/Interfaces/System/IMouseInfoProvider.cs b/OpenDiablo2.Common/Interfaces/System/IMouseInfoProvider.cs index ea259720..f674495b 100644 --- a/OpenDiablo2.Common/Interfaces/System/IMouseInfoProvider.cs +++ b/OpenDiablo2.Common/Interfaces/System/IMouseInfoProvider.cs @@ -5,6 +5,7 @@ int MouseX { get; } int MouseY { get; } bool LeftMouseDown { get; } + bool LeftMousePressed { get; } bool RightMouseDown { get; } bool ReserveMouse { get; set; } } diff --git a/OpenDiablo2.Common/Interfaces/UI/IItemContainer.cs b/OpenDiablo2.Common/Interfaces/UI/IItemContainer.cs new file mode 100644 index 00000000..fb233f05 --- /dev/null +++ b/OpenDiablo2.Common/Interfaces/UI/IItemContainer.cs @@ -0,0 +1,16 @@ +using OpenDiablo2.Common.Models; +using System; +using System.Drawing; + +namespace OpenDiablo2.Common.Interfaces +{ + public interface IItemContainer : IDisposable + { + Item ContainedItem { get; } + Point Location { get; set; } + + void SetContainedItem(Item containedItem); + void Render(); + void Update(); + } +} diff --git a/OpenDiablo2.Common/Models/Item/Armor.cs b/OpenDiablo2.Common/Models/Item/Armor.cs new file mode 100644 index 00000000..8b6fe19a --- /dev/null +++ b/OpenDiablo2.Common/Models/Item/Armor.cs @@ -0,0 +1,25 @@ +using OpenDiablo2.Common.Interfaces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OpenDiablo2.Common.Models +{ + public sealed class Armor : Item + { + + } + + public static class ArmorHelper + { + public static Armor ToArmor(this string[] row) + => new Armor + { + Name = row[0], + Code = row[17], + InvFile = row[33] + }; + } +} diff --git a/OpenDiablo2.Common/Models/Item/Item.cs b/OpenDiablo2.Common/Models/Item/Item.cs new file mode 100644 index 00000000..128b920c --- /dev/null +++ b/OpenDiablo2.Common/Models/Item/Item.cs @@ -0,0 +1,19 @@ +using OpenDiablo2.Common.Interfaces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OpenDiablo2.Common.Models +{ + /** + * Base Item class, contains common attributes for all item types. + **/ + public abstract class Item + { + public string Code { get; internal set; } // Internal code + public string Name { get; internal set; } // Item name + public string InvFile { get; internal set; } // Sprite used for the inventory and mouse cursor + } +} diff --git a/OpenDiablo2.Common/Models/Item/Misc.cs b/OpenDiablo2.Common/Models/Item/Misc.cs new file mode 100644 index 00000000..6c55470f --- /dev/null +++ b/OpenDiablo2.Common/Models/Item/Misc.cs @@ -0,0 +1,25 @@ +using OpenDiablo2.Common.Interfaces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OpenDiablo2.Common.Models +{ + public sealed class Misc : Item + { + + } + + public static class MiscHelper + { + public static Misc ToMisc(this string[] row) + => new Misc + { + Name = row[0], + Code = row[12], + InvFile = row[21] + }; + } +} diff --git a/OpenDiablo2.Common/Models/Item/Weapon.cs b/OpenDiablo2.Common/Models/Item/Weapon.cs new file mode 100644 index 00000000..6e1d595b --- /dev/null +++ b/OpenDiablo2.Common/Models/Item/Weapon.cs @@ -0,0 +1,25 @@ +using OpenDiablo2.Common.Interfaces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OpenDiablo2.Common.Models +{ + public sealed class Weapon : Item + { + + } + + public static class WeaponHelper + { + public static Weapon ToWeapon(this string[] row) + => new Weapon + { + Name = row[0], + Code = row[2], + InvFile = row[45] + }; + } +} diff --git a/OpenDiablo2.Common/Models/ItemContainerLayout.cs b/OpenDiablo2.Common/Models/ItemContainerLayout.cs new file mode 100644 index 00000000..bd0701b8 --- /dev/null +++ b/OpenDiablo2.Common/Models/ItemContainerLayout.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using OpenDiablo2.Common.Enums; + +namespace OpenDiablo2.Common.Models +{ + public class ItemContainerLayout + { + public string ResourceName { get; internal set; } + public string PaletteName { get; internal set; } = Palettes.Units; + public int BaseFrame { get; internal set; } = 0; + + public static Dictionary Values = new Dictionary + { + {eItemContainerType.Helm, new ItemContainerLayout { ResourceName = ResourcePaths.HelmGlovePlaceholder, BaseFrame = 1 } }, + {eItemContainerType.Amulet, new ItemContainerLayout{ ResourceName = ResourcePaths.RingAmuletPlaceholder } }, + {eItemContainerType.Armor, new ItemContainerLayout { ResourceName = ResourcePaths.ArmorPlaceholder } }, + {eItemContainerType.Weapon, new ItemContainerLayout { ResourceName = ResourcePaths.WeaponsPlaceholder } }, + {eItemContainerType.Belt, new ItemContainerLayout { ResourceName = ResourcePaths.BeltPlaceholder } }, + {eItemContainerType.Ring, new ItemContainerLayout { ResourceName = ResourcePaths.RingAmuletPlaceholder, BaseFrame = 1 } }, + {eItemContainerType.Glove, new ItemContainerLayout { ResourceName = ResourcePaths.HelmGlovePlaceholder } }, + {eItemContainerType.Boots, new ItemContainerLayout { ResourceName = ResourcePaths.BootsPlaceholder } }, + }; + } + +} diff --git a/OpenDiablo2.Common/OpenDiablo2.Common.csproj b/OpenDiablo2.Common/OpenDiablo2.Common.csproj index 334ddb8f..f911eda2 100644 --- a/OpenDiablo2.Common/OpenDiablo2.Common.csproj +++ b/OpenDiablo2.Common/OpenDiablo2.Common.csproj @@ -55,6 +55,7 @@ + @@ -70,15 +71,18 @@ + + + @@ -111,6 +115,10 @@ + + + + diff --git a/OpenDiablo2.Common/ResourcePaths.cs b/OpenDiablo2.Common/ResourcePaths.cs index 33e40c5f..16a965ef 100644 --- a/OpenDiablo2.Common/ResourcePaths.cs +++ b/OpenDiablo2.Common/ResourcePaths.cs @@ -117,6 +117,13 @@ namespace OpenDiablo2.Common public static string RunButton = "data\\global\\ui\\PANEL\\runbutton.dc6"; public static string MenuButton = "data\\global\\ui\\PANEL\\menubutton.DC6"; + public static string ArmorPlaceholder = "data\\global\\ui\\PANEL\\inv_armor.DC6"; + public static string BeltPlaceholder = "data\\global\\ui\\PANEL\\inv_belt.DC6"; + public static string BootsPlaceholder = "data\\global\\ui\\PANEL\\inv_boots.DC6"; + public static string HelmGlovePlaceholder = "data\\global\\ui\\PANEL\\inv_helm_glove.DC6"; + public static string RingAmuletPlaceholder = "data\\global\\ui\\PANEL\\inv_ring_amulet.DC6"; + public static string WeaponsPlaceholder = "data\\global\\ui\\PANEL\\inv_weapons.DC6"; + // --- Data --- // TODO: Doesn't sound right :) public static string EnglishTable = "data\\local\\lng\\eng\\English.txt"; @@ -125,6 +132,14 @@ namespace OpenDiablo2.Common public static string LevelType = "data\\global\\excel\\LvlTypes.txt"; public static string LevelDetails = "data\\global\\excel\\Levels.txt"; + // --- Inventory Data --- + public static string Weapons = "data\\global\\excel\\weapons.txt"; + public static string Armor = "data\\global\\excel\\armor.txt"; + public static string Misc = "data\\global\\excel\\misc.txt"; + public static string GeneratePathForItem(string spriteName) + { + return $"data\\global\\items\\{spriteName}.dc6"; + } } } diff --git a/OpenDiablo2.Core/AutofacModule.cs b/OpenDiablo2.Core/AutofacModule.cs index 3c4889aa..1a12d811 100644 --- a/OpenDiablo2.Core/AutofacModule.cs +++ b/OpenDiablo2.Core/AutofacModule.cs @@ -17,6 +17,7 @@ namespace OpenDiablo2.Core builder.RegisterType