diff --git a/OpenDiablo2.Common/Enums/eButtonType.cs b/OpenDiablo2.Common/Enums/eButtonType.cs
index b0788235..2b212b0c 100644
--- a/OpenDiablo2.Common/Enums/eButtonType.cs
+++ b/OpenDiablo2.Common/Enums/eButtonType.cs
@@ -8,6 +8,7 @@
Cancel,
Tall,
// Game UI
+ Skill,
Run,
Menu,
GoldCoin,
diff --git a/OpenDiablo2.Common/Enums/ePanelType.cs b/OpenDiablo2.Common/Enums/ePanelType.cs
new file mode 100644
index 00000000..fc7e3321
--- /dev/null
+++ b/OpenDiablo2.Common/Enums/ePanelType.cs
@@ -0,0 +1,14 @@
+namespace OpenDiablo2.Common.Enums
+{
+ public enum ePanelType
+ {
+ None,
+ Character,
+ Inventory,
+ Skill,
+ Automap,
+ Message,
+ Quest,
+ Menu
+ }
+}
diff --git a/OpenDiablo2.Common/Extensions/EnumExtensions.cs b/OpenDiablo2.Common/Extensions/EnumExtensions.cs
index 982c1723..4ee7085c 100644
--- a/OpenDiablo2.Common/Extensions/EnumExtensions.cs
+++ b/OpenDiablo2.Common/Extensions/EnumExtensions.cs
@@ -38,5 +38,28 @@ namespace OpenDiablo2.Common.Extensions
log.Warn($"Unknown panel positon, {value}");
return default(Point);
}
+
+ public static ePanelType GetPanelType(this eButtonType value)
+ {
+ switch(value)
+ {
+ case eButtonType.MinipanelAutomap:
+ return ePanelType.Automap;
+ case eButtonType.MinipanelCharacter:
+ return ePanelType.Character;
+ case eButtonType.MinipanelInventory:
+ return ePanelType.Inventory;
+ case eButtonType.MinipanelMenu:
+ return ePanelType.Menu;
+ case eButtonType.MinipanelMessage:
+ return ePanelType.Message;
+ case eButtonType.MinipanelQuest:
+ return ePanelType.Quest;
+ case eButtonType.MinipanelSkill:
+ return ePanelType.Skill;
+ default:
+ return ePanelType.None;
+ }
+ }
}
}
diff --git a/OpenDiablo2.Common/Interfaces/UI/IGameHUD.cs b/OpenDiablo2.Common/Interfaces/UI/IGameHUD.cs
index a027818e..f5a13d4d 100644
--- a/OpenDiablo2.Common/Interfaces/UI/IGameHUD.cs
+++ b/OpenDiablo2.Common/Interfaces/UI/IGameHUD.cs
@@ -14,6 +14,8 @@
* along with this program. If not, see .
*/
+using OpenDiablo2.Common.Enums;
+
namespace OpenDiablo2.Common.Interfaces
{
public interface IGameHUD
@@ -23,6 +25,7 @@ namespace OpenDiablo2.Common.Interfaces
bool IsRightPanelVisible { get; }
bool IsMouseOver();
+ void TogglePanel(ePanelType panelType);
void TogglePanel(IPanel panel);
void OpenPanels(IPanel leftPanel, IPanel rightPanel);
void ClosePanels();
diff --git a/OpenDiablo2.Common/Interfaces/UI/IMiniPanel.cs b/OpenDiablo2.Common/Interfaces/UI/IMiniPanel.cs
index 874e483c..4d88db51 100644
--- a/OpenDiablo2.Common/Interfaces/UI/IMiniPanel.cs
+++ b/OpenDiablo2.Common/Interfaces/UI/IMiniPanel.cs
@@ -1,4 +1,5 @@
-using System;
+using OpenDiablo2.Common.Enums;
+using System;
namespace OpenDiablo2.Common.Interfaces
{
@@ -8,6 +9,7 @@ namespace OpenDiablo2.Common.Interfaces
{
event OnPanelToggledEvent OnPanelToggled;
+ IPanel GetPanel(ePanelType panelType);
bool IsMouseOver();
void UpdatePanelLocation();
void OnMenuToggle(bool isToggled);
diff --git a/OpenDiablo2.Common/Interfaces/UI/IPanel.cs b/OpenDiablo2.Common/Interfaces/UI/IPanel.cs
index f893ca96..8821460d 100644
--- a/OpenDiablo2.Common/Interfaces/UI/IPanel.cs
+++ b/OpenDiablo2.Common/Interfaces/UI/IPanel.cs
@@ -25,7 +25,7 @@ namespace OpenDiablo2.Common.Interfaces
{
event OnPanelClosedEvent OnPanelClosed;
- eButtonType PanelType { get; }
+ ePanelType PanelType { get; }
ePanelFrameType FrameType { get; }
void Render();
void Update();
diff --git a/OpenDiablo2.Common/Models/ButtonLayout.cs b/OpenDiablo2.Common/Models/ButtonLayout.cs
index cf47f04e..7a3b3d05 100644
--- a/OpenDiablo2.Common/Models/ButtonLayout.cs
+++ b/OpenDiablo2.Common/Models/ButtonLayout.cs
@@ -12,6 +12,9 @@ namespace OpenDiablo2.Common.Models
public string PaletteName { get; internal set; }
public bool Toggleable { get; internal set; } = false;
public int BaseFrame { get; internal set; } = 0;
+ public int DisabledFrame { get; internal set; } = -1;
+
+ public bool IsDarkenedWhenDisabled => DisabledFrame == -1;
public static ImmutableDictionary Values { get; } = new Dictionary
{
@@ -34,6 +37,7 @@ namespace OpenDiablo2.Common.Models
{eButtonType.Menu, new ButtonLayout {XSegments = 1, ResourceName = ResourcePaths.MenuButton,PaletteName = Palettes.Units, Toggleable = true } },
{eButtonType.GoldCoin, new ButtonLayout {XSegments = 1, ResourceName = ResourcePaths.GoldCoinButton,PaletteName = Palettes.Units } },
{eButtonType.Close, new ButtonLayout {XSegments = 1, ResourceName = ResourcePaths.SquareButton,PaletteName = Palettes.Units, BaseFrame = 10 } },
+ {eButtonType.Skill, new ButtonLayout {XSegments = 1, ResourceName = ResourcePaths.AddSkillButton, PaletteName = Palettes.Units, DisabledFrame = 2 } },
}.ToImmutableDictionary();
}
diff --git a/OpenDiablo2.Common/OpenDiablo2.Common.csproj b/OpenDiablo2.Common/OpenDiablo2.Common.csproj
index b639eb84..aa4f6d24 100644
--- a/OpenDiablo2.Common/OpenDiablo2.Common.csproj
+++ b/OpenDiablo2.Common/OpenDiablo2.Common.csproj
@@ -75,6 +75,7 @@
+
diff --git a/OpenDiablo2.Common/ResourcePaths.cs b/OpenDiablo2.Common/ResourcePaths.cs
index 97a18d83..ade91550 100644
--- a/OpenDiablo2.Common/ResourcePaths.cs
+++ b/OpenDiablo2.Common/ResourcePaths.cs
@@ -95,6 +95,7 @@ namespace OpenDiablo2.Common
public const string HealthMana = @"data\global\ui\PANEL\hlthmana.DC6";
public const string GameSmallMenuButton = @"data\global\ui\PANEL\menubutton.DC6"; // TODO: Used for inventory popout
public const string SkillIcon = @"data\global\ui\PANEL\Skillicon.DC6"; // TODO: Used for skill icon button
+ public const string AddSkillButton = @"data\global\ui\PANEL\level.DC6";
// --- Mouse Pointers ---
public const string CursorDefault = @"data\global\ui\CURSOR\ohand.DC6";
diff --git a/OpenDiablo2.Core/UI/Button.cs b/OpenDiablo2.Core/UI/Button.cs
index d5f07495..7d1a7e52 100644
--- a/OpenDiablo2.Core/UI/Button.cs
+++ b/OpenDiablo2.Core/UI/Button.cs
@@ -53,7 +53,8 @@ namespace OpenDiablo2.Core.UI
return;
enabled = value;
- sprite.Darken = !enabled;
+ if(buttonLayout.IsDarkenedWhenDisabled)
+ sprite.Darken = !enabled;
}
}
@@ -186,7 +187,11 @@ namespace OpenDiablo2.Core.UI
if (AllowFrameChange)
{
- if (Toggled && pressed)
+ if(!Enabled && buttonLayout.DisabledFrame >= 0)
+ {
+ frame = buttonLayout.DisabledFrame;
+ }
+ else if (Toggled && pressed)
{
frame = buttonLayout.BaseFrame + 3;
}
diff --git a/OpenDiablo2.Core/UI/CharacterPanel.cs b/OpenDiablo2.Core/UI/CharacterPanel.cs
index 2ca53585..69f26419 100644
--- a/OpenDiablo2.Core/UI/CharacterPanel.cs
+++ b/OpenDiablo2.Core/UI/CharacterPanel.cs
@@ -45,7 +45,7 @@ namespace OpenDiablo2.Core.UI
closeButton.OnActivate = () => OnPanelClosed?.Invoke(this);
}
- public eButtonType PanelType => eButtonType.MinipanelCharacter;
+ public ePanelType PanelType => ePanelType.Character;
public ePanelFrameType FrameType => ePanelFrameType.Left;
public void Update()
diff --git a/OpenDiablo2.Core/UI/GameHUD.cs b/OpenDiablo2.Core/UI/GameHUD.cs
index 1472c18d..9a539c4f 100644
--- a/OpenDiablo2.Core/UI/GameHUD.cs
+++ b/OpenDiablo2.Core/UI/GameHUD.cs
@@ -32,10 +32,14 @@ namespace OpenDiablo2.Core.UI
private readonly IMouseInfoProvider mouseInfoProvider;
private readonly IMiniPanel minipanel;
- private readonly IButton runButton, menuButton;
+ private readonly IButton runButton, menuButton, addStatButton, addSkillButton;
private readonly ISprite panelSprite, healthManaSprite, gameGlobeOverlapSprite;
private readonly IPanelFrame leftPanelFrame, rightPanelFrame;
+ // Test fields
+ private bool addNewAttribute = true;
+ private bool addNewSkill = false;
+
public GameHUD(
IRenderWindow renderWindow,
IGameState gameState,
@@ -62,6 +66,15 @@ namespace OpenDiablo2.Core.UI
menuButton.OnToggle = minipanel.OnMenuToggle;
menuButton.Toggle();
+ addStatButton = createButton(eButtonType.Skill);
+ addStatButton.Location = new Point(207, 562);
+ addStatButton.Enabled = addNewAttribute;
+ addStatButton.OnActivate = () => TogglePanel(ePanelType.Character);
+
+ addSkillButton = createButton(eButtonType.Skill);
+ addSkillButton.Location = new Point(564, 562);
+ addSkillButton.Enabled = addNewSkill;
+
panelSprite = renderWindow.LoadSprite(ResourcePaths.GamePanels, Palettes.Act1, true);
healthManaSprite = renderWindow.LoadSprite(ResourcePaths.HealthMana, Palettes.Act1, true);
gameGlobeOverlapSprite = renderWindow.LoadSprite(ResourcePaths.GameGlobeOverlap, Palettes.Act1, true);
@@ -75,6 +88,11 @@ namespace OpenDiablo2.Core.UI
public bool IsRightPanelVisible => RightPanel != null;
public bool IsRunningEnabled => runButton.Toggled;
+ public void TogglePanel(ePanelType panelType)
+ {
+ TogglePanel(minipanel.GetPanel(panelType));
+ }
+
public void TogglePanel(IPanel panel)
{
switch (panel.FrameType)
@@ -168,12 +186,16 @@ namespace OpenDiablo2.Core.UI
runButton.Render();
menuButton.Render();
+ addStatButton.Render();
+ addSkillButton.Render();
}
public void Update()
{
runButton.Update();
menuButton.Update();
+ addStatButton.Update();
+ addSkillButton.Update();
if (IsLeftPanelVisible)
{
diff --git a/OpenDiablo2.Core/UI/InventoryPanel.cs b/OpenDiablo2.Core/UI/InventoryPanel.cs
index 64ecd8f1..0ffd12f9 100644
--- a/OpenDiablo2.Core/UI/InventoryPanel.cs
+++ b/OpenDiablo2.Core/UI/InventoryPanel.cs
@@ -105,7 +105,7 @@ namespace OpenDiablo2.Core.UI
bootsContainer.Location = panelSprite.Location + new Size(251, 178);
}
- public eButtonType PanelType => eButtonType.MinipanelInventory;
+ public ePanelType PanelType => ePanelType.Inventory;
public ePanelFrameType FrameType => ePanelFrameType.Right;
public bool IsSecondaryEquipped { get; private set; }
diff --git a/OpenDiablo2.Core/UI/MiniPanel.cs b/OpenDiablo2.Core/UI/MiniPanel.cs
index 59a29d7c..b0981097 100644
--- a/OpenDiablo2.Core/UI/MiniPanel.cs
+++ b/OpenDiablo2.Core/UI/MiniPanel.cs
@@ -1,5 +1,22 @@
-using OpenDiablo2.Common;
+/* OpenDiablo 2 - An open source re-implementation of Diablo 2 in C#
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+using OpenDiablo2.Common;
using OpenDiablo2.Common.Enums;
+using OpenDiablo2.Common.Extensions;
using OpenDiablo2.Common.Interfaces;
using System;
using System.Collections.Generic;
@@ -40,7 +57,7 @@ namespace OpenDiablo2.Core.UI
buttons = panelButtons.Select((x, i) =>
{
var newBtn = createButton(x);
- var panel = panels.SingleOrDefault(o => o.PanelType == x);
+ var panel = panels.SingleOrDefault(o => o.PanelType == x.GetPanelType());
if (panel != null)
{
@@ -55,6 +72,11 @@ namespace OpenDiablo2.Core.UI
public void OnMenuToggle(bool isToggled) => isPanelVisible = isToggled;
+ public IPanel GetPanel(ePanelType panelType)
+ {
+ return panels.SingleOrDefault(o => o.PanelType == panelType);
+ }
+
public bool IsMouseOver()
{
int xDiff = mouseInfoProvider.MouseX - sprite.Location.X;