1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-07-06 21:34:17 -04:00
OpenDiablo2/OpenDiablo2.Core/UI/MiniPanel.cs
nicholasdechiara 55f8f3ef34 Mob and Playerstate (#31)
* Filled out eLevelId enum
- Added OpenDiablo2.Core.UT unit test project
- Added ELevelIdHelper class which contains code that generates the enum from the mpq data
- Added a unit test that verifies EngineDataManager works
- Added a unit test that runs the ELevelIdHelper generate function
- Renamed some enum values for constistency (e.g. Act1_Town -> Act1_Town1, as it is in the mpq)
* Retargeted OpenDiablo2.Core.UT to .net Framework 4.6.1
* Added TestConsole
TestConsole currently only supports writing the elevelids enum to a file
Also, removed elevelids generation unit test
* PlayerState and MobState
2018-11-29 21:20:29 -05:00

102 lines
3.3 KiB
C#

using System;
using System.Drawing;
using OpenDiablo2.Common;
using OpenDiablo2.Common.Enums;
using OpenDiablo2.Common.Interfaces;
namespace OpenDiablo2.Core.UI
{
// TODO: Self-align when side panels are open
public sealed class MiniPanel : IMiniPanel
{
private readonly IRenderWindow renderWindow;
private ISprite sprite;
private IButton characterBtn, inventoryBtn, skillBtn, automapBtn, messageBtn, questBtn, menuBtn;
private Point location = new Point();
public Point Location
{
get => location;
set
{
if (location == value)
return;
location = value;
sprite.Location = new Point(value.X, value.Y + sprite.LocalFrameSize.Height);
}
}
public MiniPanel(IRenderWindow renderWindow, IGameState gameState, Func<eButtonType, IButton> createButton)
{
this.renderWindow = renderWindow;
sprite = renderWindow.LoadSprite(ResourcePaths.MinipanelSmall, Palettes.Units);
Location = new Point(800/2-sprite.LocalFrameSize.Width/2, 526);
characterBtn = createButton(eButtonType.MinipanelCharacter);
characterBtn.Location = new Point(3 + Location.X, 3 + Location.Y);
characterBtn.OnActivate = () => gameState.ToggleShowCharacterPanel();
inventoryBtn = createButton(eButtonType.MinipanelInventory);
inventoryBtn.Location = new Point(24 + Location.X, 3 + Location.Y);
inventoryBtn.OnActivate = () => gameState.ToggleShowInventoryPanel();
skillBtn = createButton(eButtonType.MinipanelSkill);
skillBtn.Location = new Point(45 + Location.X, 3 + Location.Y);
automapBtn = createButton(eButtonType.MinipanelAutomap);
automapBtn.Location = new Point(66 + Location.X, 3 + Location.Y);
messageBtn = createButton(eButtonType.MinipanelMessage);
messageBtn.Location = new Point(87 + Location.X, 3 + Location.Y);
questBtn = createButton(eButtonType.MinipanelQuest);
questBtn.Location = new Point(108 + Location.X, 3 + Location.Y);
menuBtn = createButton(eButtonType.MinipanelMenu);
menuBtn.Location = new Point(129 + Location.X, 3 + Location.Y);
}
public void Update()
{
characterBtn.Update();
inventoryBtn.Update();
skillBtn.Update();
automapBtn.Update();
messageBtn.Update();
questBtn.Update();
menuBtn.Update();
}
public void Render()
{
renderWindow.Draw(sprite);
characterBtn.Render();
inventoryBtn.Render();
skillBtn.Render();
automapBtn.Render();
messageBtn.Render();
questBtn.Render();
menuBtn.Render();
}
public void Dispose()
{
characterBtn.Dispose();
inventoryBtn.Dispose();
skillBtn.Dispose();
automapBtn.Dispose();
messageBtn.Dispose();
questBtn.Dispose();
menuBtn.Dispose();
sprite.Dispose();
}
}
}