mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-12-25 11:36:26 -05:00
Normalize line endings (#49)
* Introduce end of line normalization * Normalize line endings
This commit is contained in:
parent
a79040cc20
commit
21666ed4f4
5
.gitattributes
vendored
Normal file
5
.gitattributes
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
# Auto detect text files and perform LF normalization
|
||||
# http://davidlaing.com/2012/09/19/customise-your-gitattributes-to-become-a-git-ninja/
|
||||
* text=auto
|
||||
|
||||
*.cs diff=csharp
|
@ -1,25 +1,25 @@
|
||||
namespace OpenDiablo2.Common.Enums
|
||||
{
|
||||
public enum eButtonType
|
||||
{
|
||||
Wide,
|
||||
Medium,
|
||||
Narrow,
|
||||
Cancel,
|
||||
Tall,
|
||||
// Game UI
|
||||
Skill,
|
||||
Run,
|
||||
Menu,
|
||||
GoldCoin,
|
||||
Close,
|
||||
SecondaryInvHand,
|
||||
MinipanelCharacter,
|
||||
MinipanelInventory,
|
||||
MinipanelSkill,
|
||||
MinipanelAutomap,
|
||||
MinipanelMessage,
|
||||
MinipanelQuest,
|
||||
MinipanelMenu
|
||||
}
|
||||
}
|
||||
namespace OpenDiablo2.Common.Enums
|
||||
{
|
||||
public enum eButtonType
|
||||
{
|
||||
Wide,
|
||||
Medium,
|
||||
Narrow,
|
||||
Cancel,
|
||||
Tall,
|
||||
// Game UI
|
||||
Skill,
|
||||
Run,
|
||||
Menu,
|
||||
GoldCoin,
|
||||
Close,
|
||||
SecondaryInvHand,
|
||||
MinipanelCharacter,
|
||||
MinipanelInventory,
|
||||
MinipanelSkill,
|
||||
MinipanelAutomap,
|
||||
MinipanelMessage,
|
||||
MinipanelQuest,
|
||||
MinipanelMenu
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OpenDiablo2.Common.Enums
|
||||
{
|
||||
public enum eItemContainerType
|
||||
|
@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using OpenDiablo2.Common.Enums;
|
||||
using OpenDiablo2.Common.Models;
|
||||
using OpenDiablo2.Common.Models.Mobs;
|
||||
|
||||
using OpenDiablo2.Common.Models.Mobs;
|
||||
|
||||
namespace OpenDiablo2.Common.Interfaces.Drawing
|
||||
{
|
||||
public interface ICharacterRenderer : IDisposable
|
||||
@ -11,8 +11,7 @@ namespace OpenDiablo2.Common.Interfaces.Drawing
|
||||
PlayerLocationDetails LocationDetails { get; set; }
|
||||
eHero Hero { get; set; }
|
||||
PlayerEquipment Equipment { get; set; }
|
||||
eMobMode MobMode { get; set; }
|
||||
|
||||
eMobMode MobMode { get; set; }
|
||||
void Update(long ms);
|
||||
void Render(int pixelOffsetX, int pixelOffsetY);
|
||||
void ResetAnimationData();
|
||||
|
@ -14,7 +14,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using OpenDiablo2.Common.Models;
|
||||
using OpenDiablo2.Common.Models;
|
||||
|
||||
namespace OpenDiablo2.Common.Interfaces
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
using OpenDiablo2.Common.Enums;
|
||||
using OpenDiablo2.Common.Enums;
|
||||
using System;
|
||||
|
||||
namespace OpenDiablo2.Common.Interfaces
|
||||
|
@ -1,4 +1,4 @@
|
||||
using OpenDiablo2.Common.Models.Mobs;
|
||||
using OpenDiablo2.Common.Models.Mobs;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -1,4 +1,4 @@
|
||||
using OpenDiablo2.Common.Models;
|
||||
using OpenDiablo2.Common.Models;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
|
@ -1,44 +1,44 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Drawing;
|
||||
using OpenDiablo2.Common.Enums;
|
||||
|
||||
namespace OpenDiablo2.Common.Models
|
||||
{
|
||||
public class ButtonLayout
|
||||
{
|
||||
public int XSegments { get; internal set; }
|
||||
public string ResourceName { get; internal set; }
|
||||
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<eButtonType, ButtonLayout> Values { get; } = new Dictionary<eButtonType, ButtonLayout>
|
||||
{
|
||||
{eButtonType.Wide, new ButtonLayout { XSegments = 2, ResourceName = ResourcePaths.WideButtonBlank, PaletteName = Palettes.Units } },
|
||||
{eButtonType.Medium, new ButtonLayout{ XSegments = 1, ResourceName=ResourcePaths.MediumButtonBlank, PaletteName = Palettes.Units } },
|
||||
{eButtonType.Narrow, new ButtonLayout {XSegments = 1, ResourceName = ResourcePaths.NarrowButtonBlank,PaletteName = Palettes.Units } },
|
||||
{eButtonType.Tall, new ButtonLayout {XSegments = 1, ResourceName = ResourcePaths.TallButtonBlank, PaletteName = Palettes.Units } },
|
||||
{eButtonType.Cancel, new ButtonLayout {XSegments = 1, ResourceName = ResourcePaths.CancelButton,PaletteName = Palettes.Units } },
|
||||
// Minipanel
|
||||
{eButtonType.MinipanelCharacter, new ButtonLayout {XSegments = 1, ResourceName = ResourcePaths.MinipanelButton,PaletteName = Palettes.Units, BaseFrame = 0 } },
|
||||
{eButtonType.MinipanelInventory, new ButtonLayout {XSegments = 1, ResourceName = ResourcePaths.MinipanelButton,PaletteName = Palettes.Units, BaseFrame = 2 } },
|
||||
{eButtonType.MinipanelSkill, new ButtonLayout {XSegments = 1, ResourceName = ResourcePaths.MinipanelButton,PaletteName = Palettes.Units, BaseFrame = 4 } },
|
||||
{eButtonType.MinipanelAutomap, new ButtonLayout {XSegments = 1, ResourceName = ResourcePaths.MinipanelButton,PaletteName = Palettes.Units, BaseFrame = 8 } },
|
||||
{eButtonType.MinipanelMessage, new ButtonLayout {XSegments = 1, ResourceName = ResourcePaths.MinipanelButton,PaletteName = Palettes.Units, BaseFrame = 10 } },
|
||||
{eButtonType.MinipanelQuest, new ButtonLayout {XSegments = 1, ResourceName = ResourcePaths.MinipanelButton,PaletteName = Palettes.Units, BaseFrame = 12 } },
|
||||
{eButtonType.MinipanelMenu, new ButtonLayout {XSegments = 1, ResourceName = ResourcePaths.MinipanelButton,PaletteName = Palettes.Units, BaseFrame = 14 } },
|
||||
|
||||
{eButtonType.SecondaryInvHand, new ButtonLayout {XSegments = 1, ResourceName = ResourcePaths.InventoryWeaponsTab, PaletteName = Palettes.Units } },
|
||||
{eButtonType.Run, new ButtonLayout {XSegments = 1, ResourceName = ResourcePaths.RunButton,PaletteName = Palettes.Units, Toggleable = true } },
|
||||
{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();
|
||||
}
|
||||
|
||||
}
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Drawing;
|
||||
using OpenDiablo2.Common.Enums;
|
||||
|
||||
namespace OpenDiablo2.Common.Models
|
||||
{
|
||||
public class ButtonLayout
|
||||
{
|
||||
public int XSegments { get; internal set; }
|
||||
public string ResourceName { get; internal set; }
|
||||
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<eButtonType, ButtonLayout> Values { get; } = new Dictionary<eButtonType, ButtonLayout>
|
||||
{
|
||||
{eButtonType.Wide, new ButtonLayout { XSegments = 2, ResourceName = ResourcePaths.WideButtonBlank, PaletteName = Palettes.Units } },
|
||||
{eButtonType.Medium, new ButtonLayout{ XSegments = 1, ResourceName=ResourcePaths.MediumButtonBlank, PaletteName = Palettes.Units } },
|
||||
{eButtonType.Narrow, new ButtonLayout {XSegments = 1, ResourceName = ResourcePaths.NarrowButtonBlank,PaletteName = Palettes.Units } },
|
||||
{eButtonType.Tall, new ButtonLayout {XSegments = 1, ResourceName = ResourcePaths.TallButtonBlank, PaletteName = Palettes.Units } },
|
||||
{eButtonType.Cancel, new ButtonLayout {XSegments = 1, ResourceName = ResourcePaths.CancelButton,PaletteName = Palettes.Units } },
|
||||
// Minipanel
|
||||
{eButtonType.MinipanelCharacter, new ButtonLayout {XSegments = 1, ResourceName = ResourcePaths.MinipanelButton,PaletteName = Palettes.Units, BaseFrame = 0 } },
|
||||
{eButtonType.MinipanelInventory, new ButtonLayout {XSegments = 1, ResourceName = ResourcePaths.MinipanelButton,PaletteName = Palettes.Units, BaseFrame = 2 } },
|
||||
{eButtonType.MinipanelSkill, new ButtonLayout {XSegments = 1, ResourceName = ResourcePaths.MinipanelButton,PaletteName = Palettes.Units, BaseFrame = 4 } },
|
||||
{eButtonType.MinipanelAutomap, new ButtonLayout {XSegments = 1, ResourceName = ResourcePaths.MinipanelButton,PaletteName = Palettes.Units, BaseFrame = 8 } },
|
||||
{eButtonType.MinipanelMessage, new ButtonLayout {XSegments = 1, ResourceName = ResourcePaths.MinipanelButton,PaletteName = Palettes.Units, BaseFrame = 10 } },
|
||||
{eButtonType.MinipanelQuest, new ButtonLayout {XSegments = 1, ResourceName = ResourcePaths.MinipanelButton,PaletteName = Palettes.Units, BaseFrame = 12 } },
|
||||
{eButtonType.MinipanelMenu, new ButtonLayout {XSegments = 1, ResourceName = ResourcePaths.MinipanelButton,PaletteName = Palettes.Units, BaseFrame = 14 } },
|
||||
|
||||
{eButtonType.SecondaryInvHand, new ButtonLayout {XSegments = 1, ResourceName = ResourcePaths.InventoryWeaponsTab, PaletteName = Palettes.Units } },
|
||||
{eButtonType.Run, new ButtonLayout {XSegments = 1, ResourceName = ResourcePaths.RunButton,PaletteName = Palettes.Units, Toggleable = true } },
|
||||
{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();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
using OpenDiablo2.Common.Enums;
|
||||
using OpenDiablo2.Common.Enums;
|
||||
using OpenDiablo2.Common.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -1,8 +1,8 @@
|
||||
using OpenDiablo2.Common.Exceptions;
|
||||
using OpenDiablo2.Common.Exceptions;
|
||||
using OpenDiablo2.Common.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -14,79 +14,79 @@ namespace OpenDiablo2.Common.Models
|
||||
**/
|
||||
public class ItemInstance : IItemInstance
|
||||
{
|
||||
public Item Item { get; internal set; }
|
||||
public Item Item { get; internal set; }
|
||||
public string Name { get; internal set; }
|
||||
public int Level { get; internal set; }
|
||||
public bool Identified { get; internal set; }
|
||||
|
||||
public ItemInstance(Item item)
|
||||
{
|
||||
Item = item;
|
||||
Name = item.Name;
|
||||
public ItemInstance(Item item)
|
||||
{
|
||||
Item = item;
|
||||
Name = item.Name;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ItemInstanceHelper
|
||||
{
|
||||
public static void Write(this BinaryWriter br, ItemInstance itemInstance)
|
||||
{
|
||||
if (itemInstance == null)
|
||||
{
|
||||
br.Write(false);
|
||||
return;
|
||||
}
|
||||
|
||||
br.Write(true);
|
||||
|
||||
if (itemInstance.Item is Weapon)
|
||||
{
|
||||
br.Write((byte)0);
|
||||
br.Write((Weapon)itemInstance.Item);
|
||||
}
|
||||
else if (itemInstance.Item is Armor)
|
||||
{
|
||||
br.Write((byte)1);
|
||||
br.Write((Armor)itemInstance.Item);
|
||||
}
|
||||
else if (itemInstance.Item is Misc)
|
||||
{
|
||||
br.Write((byte)2);
|
||||
br.Write((Misc)itemInstance.Item);
|
||||
}
|
||||
else throw new OpenDiablo2Exception("Unknown item type.");
|
||||
|
||||
br.Write(itemInstance.Name);
|
||||
br.Write((Int16)itemInstance.Level);
|
||||
br.Write(itemInstance.Identified);
|
||||
public static void Write(this BinaryWriter br, ItemInstance itemInstance)
|
||||
{
|
||||
if (itemInstance == null)
|
||||
{
|
||||
br.Write(false);
|
||||
return;
|
||||
}
|
||||
|
||||
br.Write(true);
|
||||
|
||||
if (itemInstance.Item is Weapon)
|
||||
{
|
||||
br.Write((byte)0);
|
||||
br.Write((Weapon)itemInstance.Item);
|
||||
}
|
||||
else if (itemInstance.Item is Armor)
|
||||
{
|
||||
br.Write((byte)1);
|
||||
br.Write((Armor)itemInstance.Item);
|
||||
}
|
||||
else if (itemInstance.Item is Misc)
|
||||
{
|
||||
br.Write((byte)2);
|
||||
br.Write((Misc)itemInstance.Item);
|
||||
}
|
||||
else throw new OpenDiablo2Exception("Unknown item type.");
|
||||
|
||||
br.Write(itemInstance.Name);
|
||||
br.Write((Int16)itemInstance.Level);
|
||||
br.Write(itemInstance.Identified);
|
||||
}
|
||||
|
||||
public static ItemInstance ReadItemInstance(this BinaryReader binaryReader)
|
||||
{
|
||||
if (!binaryReader.ReadBoolean())
|
||||
return null;
|
||||
|
||||
Item item;
|
||||
switch(binaryReader.ReadByte())
|
||||
{
|
||||
case 0:
|
||||
item = binaryReader.ReadItemWeapon();
|
||||
break;
|
||||
case 1:
|
||||
item = binaryReader.ReadItemArmor();
|
||||
break;
|
||||
case 2:
|
||||
item = binaryReader.ReadItemMisc();
|
||||
break;
|
||||
default:
|
||||
throw new OpenDiablo2Exception("Unknown item type.");
|
||||
}
|
||||
|
||||
return new ItemInstance(item)
|
||||
{
|
||||
Name = binaryReader.ReadString(),
|
||||
Level = binaryReader.ReadInt16(),
|
||||
Identified = binaryReader.ReadBoolean()
|
||||
};
|
||||
public static ItemInstance ReadItemInstance(this BinaryReader binaryReader)
|
||||
{
|
||||
if (!binaryReader.ReadBoolean())
|
||||
return null;
|
||||
|
||||
Item item;
|
||||
switch(binaryReader.ReadByte())
|
||||
{
|
||||
case 0:
|
||||
item = binaryReader.ReadItemWeapon();
|
||||
break;
|
||||
case 1:
|
||||
item = binaryReader.ReadItemArmor();
|
||||
break;
|
||||
case 2:
|
||||
item = binaryReader.ReadItemMisc();
|
||||
break;
|
||||
default:
|
||||
throw new OpenDiablo2Exception("Unknown item type.");
|
||||
}
|
||||
|
||||
return new ItemInstance(item)
|
||||
{
|
||||
Name = binaryReader.ReadString(),
|
||||
Level = binaryReader.ReadInt16(),
|
||||
Identified = binaryReader.ReadBoolean()
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,42 +1,42 @@
|
||||
/* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
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 ImmutableDictionary<eItemContainerType, ItemContainerLayout> Values { get; } = new Dictionary<eItemContainerType, ItemContainerLayout>
|
||||
{
|
||||
{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 } },
|
||||
}.ToImmutableDictionary();
|
||||
}
|
||||
|
||||
}
|
||||
/* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
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 ImmutableDictionary<eItemContainerType, ItemContainerLayout> Values { get; } = new Dictionary<eItemContainerType, ItemContainerLayout>
|
||||
{
|
||||
{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 } },
|
||||
}.ToImmutableDictionary();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OpenDiablo2.Common.Enums;
|
||||
using OpenDiablo2.Common.Models.Mobs;
|
||||
|
||||
using OpenDiablo2.Common.Models.Mobs;
|
||||
|
||||
namespace OpenDiablo2.Common.Models
|
||||
{
|
||||
public sealed class MPQCOF
|
||||
@ -28,9 +28,9 @@ namespace OpenDiablo2.Common.Models
|
||||
public COFLayer[] Layers { get; private set; }
|
||||
public Dictionary<eCompositType, int> CompositLayers { get; private set; }
|
||||
public IEnumerable<eAnimationFrame> AnimationFrames { get; private set; }
|
||||
public eCompositType[] Priority { get; private set; }
|
||||
public int NumberOfDirections { get; internal set; }
|
||||
public int FramesPerDirection { get; internal set; }
|
||||
public eCompositType[] Priority { get; private set; }
|
||||
public int NumberOfDirections { get; internal set; }
|
||||
public int FramesPerDirection { get; internal set; }
|
||||
public int NumberOfLayers { get; internal set; }
|
||||
|
||||
public static MPQCOF Load(Stream stream, Dictionary<string, List<AnimationData>> animations, eHero hero, eMobMode mobMode, PlayerEquipment equipment)
|
||||
|
@ -99,11 +99,11 @@ namespace OpenDiablo2.Common.Models.Mobs
|
||||
}
|
||||
}
|
||||
|
||||
public struct InitialEquipment
|
||||
{
|
||||
public string name;
|
||||
public string location;
|
||||
public int count;
|
||||
public struct InitialEquipment
|
||||
{
|
||||
public string name;
|
||||
public string location;
|
||||
public int count;
|
||||
};
|
||||
|
||||
public static class HeroTypeConfigHelper
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using OpenDiablo2.Common.Enums;
|
||||
using OpenDiablo2.Common.Enums.Mobs;
|
||||
using OpenDiablo2.Common.Interfaces.Mobs;
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using OpenDiablo2.Common.Enums;
|
||||
using OpenDiablo2.Common.Models.Mobs;
|
||||
@ -34,42 +34,42 @@ namespace OpenDiablo2.Common.Models
|
||||
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
using (var stream = new MemoryStream())
|
||||
using (var writer = new BinaryWriter(stream))
|
||||
{
|
||||
writer.Write((byte)Hero);
|
||||
writer.Write((byte)MobMode);
|
||||
writer.Write(Name);
|
||||
writer.Write(Equipment);
|
||||
writer.Write(LocationDetails.GetBytes());
|
||||
writer.Write(UID.ToByteArray());
|
||||
|
||||
return stream.ToArray();
|
||||
using (var stream = new MemoryStream())
|
||||
using (var writer = new BinaryWriter(stream))
|
||||
{
|
||||
writer.Write((byte)Hero);
|
||||
writer.Write((byte)MobMode);
|
||||
writer.Write(Name);
|
||||
writer.Write(Equipment);
|
||||
writer.Write(LocationDetails.GetBytes());
|
||||
writer.Write(UID.ToByteArray());
|
||||
|
||||
return stream.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public static PlayerInfo FromBytes(byte[] data, int offset = 0)
|
||||
{
|
||||
using (var stream = new MemoryStream(data))
|
||||
using (var reader = new BinaryReader(stream))
|
||||
{
|
||||
reader.ReadBytes(offset); // Skip
|
||||
|
||||
var result = new PlayerInfo
|
||||
{
|
||||
Hero = (eHero)reader.ReadByte(),
|
||||
MobMode = (eMobMode)reader.ReadByte(),
|
||||
Name = reader.ReadString(),
|
||||
Equipment = reader.ReadPlayerEquipment(),
|
||||
LocationDetails = PlayerLocationDetails.FromBytes(reader.ReadBytes(PlayerLocationDetails.SizeInBytes)),
|
||||
UID = new Guid(reader.ReadBytes(16))
|
||||
};
|
||||
|
||||
return result;
|
||||
using (var stream = new MemoryStream(data))
|
||||
using (var reader = new BinaryReader(stream))
|
||||
{
|
||||
reader.ReadBytes(offset); // Skip
|
||||
|
||||
var result = new PlayerInfo
|
||||
{
|
||||
Hero = (eHero)reader.ReadByte(),
|
||||
MobMode = (eMobMode)reader.ReadByte(),
|
||||
Name = reader.ReadString(),
|
||||
Equipment = reader.ReadPlayerEquipment(),
|
||||
LocationDetails = PlayerLocationDetails.FromBytes(reader.ReadBytes(PlayerLocationDetails.SizeInBytes)),
|
||||
UID = new Guid(reader.ReadBytes(16))
|
||||
};
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public int SizeInBytes => 8 + Encoding.UTF8.GetByteCount(Name) + PlayerLocationDetails.SizeInBytes + 16;
|
||||
public int SizeInBytes => 8 + Encoding.UTF8.GetByteCount(Name) + PlayerLocationDetails.SizeInBytes + 16;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,306 +1,306 @@
|
||||
/* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using OpenDiablo2.Common.Enums;
|
||||
|
||||
namespace OpenDiablo2.Common
|
||||
{
|
||||
public static class ResourcePaths
|
||||
{
|
||||
// --- Loading Screen ---
|
||||
public const string LoadingScreen = @"data\global\ui\Loading\loadingscreen.dc6";
|
||||
|
||||
// --- Main Menu ---
|
||||
public const string GameSelectScreen = @"data\global\ui\FrontEnd\gameselectscreenEXP.dc6";
|
||||
public const string Diablo2LogoFireLeft = @"data\global\ui\FrontEnd\D2logoFireLeft.DC6";
|
||||
public const string Diablo2LogoFireRight = @"data\global\ui\FrontEnd\D2logoFireRight.DC6";
|
||||
public const string Diablo2LogoBlackLeft = @"data\global\ui\FrontEnd\D2logoBlackLeft.DC6";
|
||||
public const string Diablo2LogoBlackRight = @"data\global\ui\FrontEnd\D2logoBlackRight.DC6";
|
||||
|
||||
// --- Character Select Screen ---
|
||||
public const string CharacterSelectBackground = @"data\global\ui\FrontEnd\charactercreationscreenEXP.dc6";
|
||||
public const string CharacterSelectCampfire = @"data\global\ui\FrontEnd\fire.DC6";
|
||||
|
||||
public const string CharacterSelectBarbarianUnselected = @"data\global\ui\FrontEnd\barbarian\banu1.DC6";
|
||||
public const string CharacterSelectBarbarianUnselectedH = @"data\global\ui\FrontEnd\barbarian\banu2.DC6";
|
||||
public const string CharacterSelectBarbarianSelected = @"data\global\ui\FrontEnd\barbarian\banu3.DC6";
|
||||
public const string CharacterSelectBarbarianForwardWalk = @"data\global\ui\FrontEnd\barbarian\bafw.DC6";
|
||||
public const string CharacterSelectBarbarianForwardWalkOverlay = @"data\global\ui\FrontEnd\barbarian\BAFWs.DC6";
|
||||
public const string CharacterSelectBarbarianBackWalk = @"data\global\ui\FrontEnd\barbarian\babw.DC6";
|
||||
|
||||
public const string CharacterSelecSorceressUnselected = @"data\global\ui\FrontEnd\sorceress\SONU1.DC6";
|
||||
public const string CharacterSelecSorceressUnselectedH = @"data\global\ui\FrontEnd\sorceress\SONU2.DC6";
|
||||
public const string CharacterSelecSorceressSelected = @"data\global\ui\FrontEnd\sorceress\SONU3.DC6";
|
||||
public const string CharacterSelecSorceressSelectedOverlay = @"data\global\ui\FrontEnd\sorceress\SONU3s.DC6";
|
||||
public const string CharacterSelecSorceressForwardWalk = @"data\global\ui\FrontEnd\sorceress\SOFW.DC6";
|
||||
public const string CharacterSelecSorceressForwardWalkOverlay = @"data\global\ui\FrontEnd\sorceress\SOFWs.DC6";
|
||||
public const string CharacterSelecSorceressBackWalk = @"data\global\ui\FrontEnd\sorceress\SOBW.DC6";
|
||||
public const string CharacterSelecSorceressBackWalkOverlay = @"data\global\ui\FrontEnd\sorceress\SOBWs.DC6";
|
||||
|
||||
public const string CharacterSelectNecromancerUnselected = @"data\global\ui\FrontEnd\necromancer\NENU1.DC6";
|
||||
public const string CharacterSelectNecromancerUnselectedH = @"data\global\ui\FrontEnd\necromancer\NENU2.DC6";
|
||||
public const string CharacterSelecNecromancerSelected = @"data\global\ui\FrontEnd\necromancer\NENU3.DC6";
|
||||
public const string CharacterSelecNecromancerSelectedOverlay = @"data\global\ui\FrontEnd\necromancer\NENU3s.DC6";
|
||||
public const string CharacterSelecNecromancerForwardWalk = @"data\global\ui\FrontEnd\necromancer\NEFW.DC6";
|
||||
public const string CharacterSelecNecromancerForwardWalkOverlay = @"data\global\ui\FrontEnd\necromancer\NEFWs.DC6";
|
||||
public const string CharacterSelecNecromancerBackWalk = @"data\global\ui\FrontEnd\necromancer\NEBW.DC6";
|
||||
public const string CharacterSelecNecromancerBackWalkOverlay = @"data\global\ui\FrontEnd\necromancer\NEBWs.DC6";
|
||||
|
||||
public const string CharacterSelectPaladinUnselected = @"data\global\ui\FrontEnd\paladin\PANU1.DC6";
|
||||
public const string CharacterSelectPaladinUnselectedH = @"data\global\ui\FrontEnd\paladin\PANU2.DC6";
|
||||
public const string CharacterSelecPaladinSelected = @"data\global\ui\FrontEnd\paladin\PANU3.DC6";
|
||||
public const string CharacterSelecPaladinForwardWalk = @"data\global\ui\FrontEnd\paladin\PAFW.DC6";
|
||||
public const string CharacterSelecPaladinForwardWalkOverlay = @"data\global\ui\FrontEnd\paladin\PAFWs.DC6";
|
||||
public const string CharacterSelecPaladinBackWalk = @"data\global\ui\FrontEnd\paladin\PABW.DC6";
|
||||
|
||||
|
||||
public const string CharacterSelectAmazonUnselected = @"data\global\ui\FrontEnd\amazon\AMNU1.DC6";
|
||||
public const string CharacterSelectAmazonUnselectedH = @"data\global\ui\FrontEnd\amazon\AMNU2.DC6";
|
||||
public const string CharacterSelecAmazonSelected = @"data\global\ui\FrontEnd\amazon\AMNU3.DC6";
|
||||
public const string CharacterSelecAmazonForwardWalk = @"data\global\ui\FrontEnd\amazon\AMFW.DC6";
|
||||
public const string CharacterSelecAmazonForwardWalkOverlay = @"data\global\ui\FrontEnd\amazon\AMFWs.DC6";
|
||||
public const string CharacterSelecAmazonBackWalk = @"data\global\ui\FrontEnd\amazon\AMBW.DC6";
|
||||
|
||||
public const string CharacterSelectAssassinUnselected = @"data\global\ui\FrontEnd\assassin\ASNU1.DC6";
|
||||
public const string CharacterSelectAssassinUnselectedH = @"data\global\ui\FrontEnd\assassin\ASNU2.DC6";
|
||||
public const string CharacterSelectAssassinSelected = @"data\global\ui\FrontEnd\assassin\ASNU3.DC6";
|
||||
public const string CharacterSelectAssassinForwardWalk = @"data\global\ui\FrontEnd\assassin\ASFW.DC6";
|
||||
public const string CharacterSelectAssassinBackWalk = @"data\global\ui\FrontEnd\assassin\ASBW.DC6";
|
||||
|
||||
public const string CharacterSelectDruidUnselected = @"data\global\ui\FrontEnd\druid\DZNU1.dc6";
|
||||
public const string CharacterSelectDruidUnselectedH = @"data\global\ui\FrontEnd\druid\DZNU2.dc6";
|
||||
public const string CharacterSelectDruidSelected = @"data\global\ui\FrontEnd\druid\DZNU3.DC6";
|
||||
public const string CharacterSelectDruidForwardWalk = @"data\global\ui\FrontEnd\druid\DZFW.DC6";
|
||||
public const string CharacterSelectDruidBackWalk = @"data\global\ui\FrontEnd\druid\DZBW.DC6";
|
||||
|
||||
// -- Character Selection
|
||||
public const string CharacterSelectionBackground = @"data\global\ui\CharSelect\characterselectscreenEXP.dc6";
|
||||
|
||||
// --- Game ---
|
||||
public const string GamePanels = @"data\global\ui\PANEL\800ctrlpnl7.dc6";
|
||||
public const string GameGlobeOverlap = @"data\global\ui\PANEL\overlap.DC6";
|
||||
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";
|
||||
|
||||
// --- Fonts ---
|
||||
public const string Font6 = @"data\local\font\latin\font6";
|
||||
public const string Font8 = @"data\local\font\latin\font8";
|
||||
public const string Font16 = @"data\local\font\latin\font16";
|
||||
public const string Font24 = @"data\local\font\latin\font24";
|
||||
public const string Font30 = @"data\local\font\latin\font30";
|
||||
public const string FontFormal12 = @"data\local\font\latin\fontformal12";
|
||||
public const string FontFormal11 = @"data\local\font\latin\fontformal11";
|
||||
public const string FontFormal10 = @"data\local\font\latin\fontformal10";
|
||||
public const string FontExocet10 = @"data\local\font\latin\fontexocet10";
|
||||
public const string FontExocet8 = @"data\local\font\latin\fontexocet8";
|
||||
|
||||
// --- UI ---
|
||||
public const string WideButtonBlank = @"data\global\ui\FrontEnd\WideButtonBlank.dc6";
|
||||
public const string MediumButtonBlank = @"data\global\ui\FrontEnd\MediumButtonBlank.dc6";
|
||||
public const string CancelButton = @"data\global\ui\FrontEnd\CancelButtonBlank.dc6";
|
||||
public const string NarrowButtonBlank = @"data\global\ui\FrontEnd\NarrowButtonBlank.dc6";
|
||||
public const string TextBox2 = @"data\global\ui\FrontEnd\textbox2.dc6";
|
||||
public const string TallButtonBlank = @"data\global\ui\CharSelect\TallButtonBlank.dc6";
|
||||
|
||||
// --- GAME UI ---
|
||||
public const string MinipanelSmall = @"data\global\ui\PANEL\minipanel_s.dc6";
|
||||
public const string MinipanelButton = @"data\global\ui\PANEL\minipanelbtn.DC6";
|
||||
|
||||
public const string Frame = @"data\global\ui\PANEL\800borderframe.dc6";
|
||||
public const string InventoryCharacterPanel = @"data\global\ui\PANEL\invchar6.DC6";
|
||||
public const string InventoryWeaponsTab = @"data\global\ui\PANEL\invchar6Tab.DC6";
|
||||
|
||||
public const string RunButton = @"data\global\ui\PANEL\runbutton.dc6";
|
||||
public const string MenuButton = @"data\global\ui\PANEL\menubutton.DC6";
|
||||
public const string GoldCoinButton = @"data\global\ui\panel\goldcoinbtn.dc6";
|
||||
public const string SquareButton = @"data\global\ui\panel\buysellbtn.dc6";
|
||||
|
||||
public const string ArmorPlaceholder = @"data\global\ui\PANEL\inv_armor.DC6";
|
||||
public const string BeltPlaceholder = @"data\global\ui\PANEL\inv_belt.DC6";
|
||||
public const string BootsPlaceholder = @"data\global\ui\PANEL\inv_boots.DC6";
|
||||
public const string HelmGlovePlaceholder = @"data\global\ui\PANEL\inv_helm_glove.DC6";
|
||||
public const string RingAmuletPlaceholder = @"data\global\ui\PANEL\inv_ring_amulet.DC6";
|
||||
public const string WeaponsPlaceholder = @"data\global\ui\PANEL\inv_weapons.DC6";
|
||||
|
||||
// --- Data ---
|
||||
// TODO: Doesn't sound right :)
|
||||
public const string EnglishTable = @"data\local\lng\eng\English.txt";
|
||||
public const string ExpansionStringTable = @"data\local\lng\eng\expansionstring.tbl";
|
||||
public const string LevelPreset = @"data\global\excel\LvlPrest.txt";
|
||||
public const string LevelType = @"data\global\excel\LvlTypes.txt";
|
||||
public const string LevelDetails = @"data\global\excel\Levels.txt";
|
||||
|
||||
// --- Animations ---
|
||||
public const string ObjectData = @"data\global\objects";
|
||||
public const string AnimationData = @"data\global\animdata.d2";
|
||||
public const string PlayerAnimationBase = @"data\global\CHARS";
|
||||
|
||||
// --- Inventory Data ---
|
||||
public const string Weapons = @"data\global\excel\weapons.txt";
|
||||
public const string Armor = @"data\global\excel\armor.txt";
|
||||
public const string Misc = @"data\global\excel\misc.txt";
|
||||
|
||||
// --- Character Data ---
|
||||
public const string Experience = @"data\global\excel\experience.txt";
|
||||
public const string CharStats = @"data\global\excel\charstats.txt";
|
||||
|
||||
// --- Music ---
|
||||
public const string BGMTitle = @"data\global\music\introedit.wav";
|
||||
public const string BGMOptions = @"data\global\music\Common\options.wav";
|
||||
public const string BGMAct1AndarielAction = @"data\global\music\Act1\andarielaction.wav";
|
||||
public const string BGMAct1BloodRavenResolution = @"data\global\music\Act1\bloodravenresolution.wav";
|
||||
public const string BGMAct1Caves = @"data\global\music\Act1\caves.wav";
|
||||
public const string BGMAct1Crypt = @"data\global\music\Act1\crypt.wav";
|
||||
public const string BGMAct1DenOfEvilAction = @"data\global\music\Act1\denofevilaction.wav";
|
||||
public const string BGMAct1Monastery = @"data\global\music\Act1\monastery.wav";
|
||||
public const string BGMAct1Town1 = @"data\global\music\Act1\town1.wav";
|
||||
public const string BGMAct1Tristram = @"data\global\music\Act1\tristram.wav";
|
||||
public const string BGMAct1Wild = @"data\global\music\Act1\wild.wav";
|
||||
public const string BGMAct2Desert = @"data\global\music\Act2\desert.wav";
|
||||
public const string BGMAct2Harem = @"data\global\music\Act2\harem.wav";
|
||||
public const string BGMAct2HoradricAction = @"data\global\music\Act2\horadricaction.wav";
|
||||
public const string BGMAct2Lair = @"data\global\music\Act2\lair.wav";
|
||||
public const string BGMAct2RadamentResolution = @"data\global\music\Act2\radamentresolution.wav";
|
||||
public const string BGMAct2Sanctuary = @"data\global\music\Act2\sanctuary.wav";
|
||||
public const string BGMAct2Sewer = @"data\global\music\Act2\sewer.wav";
|
||||
public const string BGMAct2TaintedSunAction = @"data\global\music\Act2\taintedsunaction.wav";
|
||||
public const string BGMAct2Tombs = @"data\global\music\Act2\tombs.wav";
|
||||
public const string BGMAct2Town2 = @"data\global\music\Act2\town2.wav";
|
||||
public const string BGMAct2Valley = @"data\global\music\Act2\valley.wav";
|
||||
public const string BGMAct3Jungle = @"data\global\music\Act3\jungle.wav";
|
||||
public const string BGMAct3Kurast = @"data\global\music\Act3\kurast.wav";
|
||||
public const string BGMAct3KurastSewer = @"data\global\music\Act3\kurastsewer.wav";
|
||||
public const string BGMAct3MefDeathAction = @"data\global\music\Act3\mefdeathaction.wav";
|
||||
public const string BGMAct3OrbAction = @"data\global\music\Act3\orbaction.wav";
|
||||
public const string BGMAct3Spider = @"data\global\music\Act3\spider.wav";
|
||||
public const string BGMAct3Town3 = @"data\global\music\Act3\town3.wav";
|
||||
public const string BGMAct4Diablo = @"data\global\music\Act4\diablo.wav";
|
||||
public const string BGMAct4DiabloAction = @"data\global\music\Act4\diabloaction.wav";
|
||||
public const string BGMAct4ForgeAction = @"data\global\music\Act4\forgeaction.wav";
|
||||
public const string BGMAct4IzualAction = @"data\global\music\Act4\izualaction.wav";
|
||||
public const string BGMAct4Mesa = @"data\global\music\Act4\mesa.wav";
|
||||
public const string BGMAct4Town4 = @"data\global\music\Act4\town4.wav";
|
||||
public const string BGMAct5Baal = @"data\global\music\Act5\baal.wav";
|
||||
public const string BGMAct5XTown = @"data\global\music\Act5\xtown.wav";
|
||||
|
||||
|
||||
// --- Sound Effects ---
|
||||
public const string SFXButtonClick = @"data\global\sfx\Cursor\button.wav";
|
||||
public const string SFXAmazonDeselect = @"data\global\sfx\Cursor\intro\amazon deselect.wav";
|
||||
public const string SFXAmazonSelect = @"data\global\sfx\Cursor\intro\amazon select.wav";
|
||||
public const string SFXAssassinDeselect = @"data\global\sfx\Cursor\intro\assassin deselect.wav";
|
||||
public const string SFXAssassinSelect = @"data\global\sfx\Cursor\intro\assassin select.wav";
|
||||
public const string SFXBarbarianDeselect = @"data\global\sfx\Cursor\intro\barbarian deselect.wav";
|
||||
public const string SFXBarbarianSelect = @"data\global\sfx\Cursor\intro\barbarian select.wav";
|
||||
public const string SFXDruidDeselect = @"data\global\sfx\Cursor\intro\druid deselect.wav";
|
||||
public const string SFXDruidSelect = @"data\global\sfx\Cursor\intro\druid select.wav";
|
||||
public const string SFXNecromancerDeselect = @"data\global\sfx\Cursor\intro\necromancer deselect.wav";
|
||||
public const string SFXNecromancerSelect = @"data\global\sfx\Cursor\intro\necromancer select.wav";
|
||||
public const string SFXPaladinDeselect = @"data\global\sfx\Cursor\intro\paladin deselect.wav";
|
||||
public const string SFXPaladinSelect = @"data\global\sfx\Cursor\intro\paladin select.wav";
|
||||
public const string SFXSorceressDeselect = @"data\global\sfx\Cursor\intro\sorceress deselect.wav";
|
||||
public const string SFXSorceressSelect = @"data\global\sfx\Cursor\intro\sorceress select.wav";
|
||||
|
||||
public static string GeneratePathForItem(string spriteName)
|
||||
{
|
||||
return $@"data\global\items\{spriteName}.dc6";
|
||||
}
|
||||
|
||||
public static string GetMusicPathForLevel(eLevelId levelId)
|
||||
{
|
||||
switch (levelId)
|
||||
{
|
||||
case eLevelId.None:
|
||||
return string.Empty;
|
||||
case eLevelId.Act1_Town1:
|
||||
return BGMAct1Town1;
|
||||
case eLevelId.Act1_CaveTreasure2:
|
||||
return BGMAct1Caves;
|
||||
case eLevelId.Act1_CaveTreasure3:
|
||||
return BGMAct1Caves;
|
||||
case eLevelId.Act1_CaveTreasure4:
|
||||
return BGMAct1Caves;
|
||||
case eLevelId.Act1_CaveTreasure5:
|
||||
return BGMAct1Caves;
|
||||
case eLevelId.Act1_CryptCountessX:
|
||||
return BGMAct1BloodRavenResolution; // TODO: Verify
|
||||
case eLevelId.Act1_Tower2:
|
||||
return BGMAct1Caves; // TODO: Verify
|
||||
case eLevelId.Act1_MonFront:
|
||||
return BGMAct1DenOfEvilAction; // TODO: Verify
|
||||
case eLevelId.Act1_Courtyard1:
|
||||
return BGMAct1Monastery; // TODO: Verify
|
||||
case eLevelId.Act1_Courtyard2:
|
||||
return BGMAct1Monastery; // TODO: Verify
|
||||
case eLevelId.Act1_Cathedral:
|
||||
return BGMAct1Monastery; // TODO: Verify
|
||||
case eLevelId.Act1_Andariel:
|
||||
return BGMAct1AndarielAction;
|
||||
case eLevelId.Act1_Tristram:
|
||||
return BGMAct1Tristram;
|
||||
case eLevelId.Act2_Town:
|
||||
return BGMAct2Town2;
|
||||
case eLevelId.Act2_Harem:
|
||||
return BGMAct2Harem;
|
||||
case eLevelId.Act2_DurielsLair:
|
||||
return BGMAct2Lair;
|
||||
case eLevelId.Act3_Town:
|
||||
return BGMAct3Town3;
|
||||
case eLevelId.Act3_DungeonTreasure1:
|
||||
return BGMAct3Kurast; // TODO: Verify
|
||||
case eLevelId.Act3_DungeonTreasure2:
|
||||
return BGMAct3Kurast; // TODO: Verify
|
||||
case eLevelId.Act3_SewerTreasureX:
|
||||
return BGMAct3KurastSewer; // TODO: Verify
|
||||
case eLevelId.Act3_Temple1:
|
||||
return BGMAct3Kurast; // TODO: Verify
|
||||
case eLevelId.Act3_Temple2:
|
||||
return BGMAct3Kurast; // TODO: Verify
|
||||
case eLevelId.Act3_Temple3:
|
||||
return BGMAct3Kurast; // TODO: Verify
|
||||
case eLevelId.Act3_Temple4:
|
||||
return BGMAct3Kurast; // TODO: Verify
|
||||
case eLevelId.Act3_Temple5:
|
||||
return BGMAct3Kurast; // TODO: Verify
|
||||
case eLevelId.Act3_Temple6:
|
||||
return BGMAct3Kurast; // TODO: Verify
|
||||
case eLevelId.Act3_MephistoComplex:
|
||||
return BGMAct3MefDeathAction; // TODO: Verify
|
||||
case eLevelId.Act4_Fortress:
|
||||
return BGMAct4Mesa; // TODO: Verify
|
||||
case eLevelId.Act5_Town:
|
||||
return BGMAct5XTown;
|
||||
case eLevelId.Act5_TempleFinalRoom:
|
||||
return BGMAct2Sanctuary; // TODO: Verify
|
||||
case eLevelId.Act5_ThroneRoom:
|
||||
return BGMAct2Sanctuary; // TODO: Verify
|
||||
case eLevelId.Act5_WorldStone:
|
||||
return BGMAct4ForgeAction; // TODO: Verify
|
||||
case eLevelId.Act5_TempleEntrance:
|
||||
return BGMAct5Baal; // TODO: Verify
|
||||
case eLevelId.Act5_BaalEntrance:
|
||||
return BGMAct5Baal; // TODO: Verify
|
||||
default:
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using OpenDiablo2.Common.Enums;
|
||||
|
||||
namespace OpenDiablo2.Common
|
||||
{
|
||||
public static class ResourcePaths
|
||||
{
|
||||
// --- Loading Screen ---
|
||||
public const string LoadingScreen = @"data\global\ui\Loading\loadingscreen.dc6";
|
||||
|
||||
// --- Main Menu ---
|
||||
public const string GameSelectScreen = @"data\global\ui\FrontEnd\gameselectscreenEXP.dc6";
|
||||
public const string Diablo2LogoFireLeft = @"data\global\ui\FrontEnd\D2logoFireLeft.DC6";
|
||||
public const string Diablo2LogoFireRight = @"data\global\ui\FrontEnd\D2logoFireRight.DC6";
|
||||
public const string Diablo2LogoBlackLeft = @"data\global\ui\FrontEnd\D2logoBlackLeft.DC6";
|
||||
public const string Diablo2LogoBlackRight = @"data\global\ui\FrontEnd\D2logoBlackRight.DC6";
|
||||
|
||||
// --- Character Select Screen ---
|
||||
public const string CharacterSelectBackground = @"data\global\ui\FrontEnd\charactercreationscreenEXP.dc6";
|
||||
public const string CharacterSelectCampfire = @"data\global\ui\FrontEnd\fire.DC6";
|
||||
|
||||
public const string CharacterSelectBarbarianUnselected = @"data\global\ui\FrontEnd\barbarian\banu1.DC6";
|
||||
public const string CharacterSelectBarbarianUnselectedH = @"data\global\ui\FrontEnd\barbarian\banu2.DC6";
|
||||
public const string CharacterSelectBarbarianSelected = @"data\global\ui\FrontEnd\barbarian\banu3.DC6";
|
||||
public const string CharacterSelectBarbarianForwardWalk = @"data\global\ui\FrontEnd\barbarian\bafw.DC6";
|
||||
public const string CharacterSelectBarbarianForwardWalkOverlay = @"data\global\ui\FrontEnd\barbarian\BAFWs.DC6";
|
||||
public const string CharacterSelectBarbarianBackWalk = @"data\global\ui\FrontEnd\barbarian\babw.DC6";
|
||||
|
||||
public const string CharacterSelecSorceressUnselected = @"data\global\ui\FrontEnd\sorceress\SONU1.DC6";
|
||||
public const string CharacterSelecSorceressUnselectedH = @"data\global\ui\FrontEnd\sorceress\SONU2.DC6";
|
||||
public const string CharacterSelecSorceressSelected = @"data\global\ui\FrontEnd\sorceress\SONU3.DC6";
|
||||
public const string CharacterSelecSorceressSelectedOverlay = @"data\global\ui\FrontEnd\sorceress\SONU3s.DC6";
|
||||
public const string CharacterSelecSorceressForwardWalk = @"data\global\ui\FrontEnd\sorceress\SOFW.DC6";
|
||||
public const string CharacterSelecSorceressForwardWalkOverlay = @"data\global\ui\FrontEnd\sorceress\SOFWs.DC6";
|
||||
public const string CharacterSelecSorceressBackWalk = @"data\global\ui\FrontEnd\sorceress\SOBW.DC6";
|
||||
public const string CharacterSelecSorceressBackWalkOverlay = @"data\global\ui\FrontEnd\sorceress\SOBWs.DC6";
|
||||
|
||||
public const string CharacterSelectNecromancerUnselected = @"data\global\ui\FrontEnd\necromancer\NENU1.DC6";
|
||||
public const string CharacterSelectNecromancerUnselectedH = @"data\global\ui\FrontEnd\necromancer\NENU2.DC6";
|
||||
public const string CharacterSelecNecromancerSelected = @"data\global\ui\FrontEnd\necromancer\NENU3.DC6";
|
||||
public const string CharacterSelecNecromancerSelectedOverlay = @"data\global\ui\FrontEnd\necromancer\NENU3s.DC6";
|
||||
public const string CharacterSelecNecromancerForwardWalk = @"data\global\ui\FrontEnd\necromancer\NEFW.DC6";
|
||||
public const string CharacterSelecNecromancerForwardWalkOverlay = @"data\global\ui\FrontEnd\necromancer\NEFWs.DC6";
|
||||
public const string CharacterSelecNecromancerBackWalk = @"data\global\ui\FrontEnd\necromancer\NEBW.DC6";
|
||||
public const string CharacterSelecNecromancerBackWalkOverlay = @"data\global\ui\FrontEnd\necromancer\NEBWs.DC6";
|
||||
|
||||
public const string CharacterSelectPaladinUnselected = @"data\global\ui\FrontEnd\paladin\PANU1.DC6";
|
||||
public const string CharacterSelectPaladinUnselectedH = @"data\global\ui\FrontEnd\paladin\PANU2.DC6";
|
||||
public const string CharacterSelecPaladinSelected = @"data\global\ui\FrontEnd\paladin\PANU3.DC6";
|
||||
public const string CharacterSelecPaladinForwardWalk = @"data\global\ui\FrontEnd\paladin\PAFW.DC6";
|
||||
public const string CharacterSelecPaladinForwardWalkOverlay = @"data\global\ui\FrontEnd\paladin\PAFWs.DC6";
|
||||
public const string CharacterSelecPaladinBackWalk = @"data\global\ui\FrontEnd\paladin\PABW.DC6";
|
||||
|
||||
|
||||
public const string CharacterSelectAmazonUnselected = @"data\global\ui\FrontEnd\amazon\AMNU1.DC6";
|
||||
public const string CharacterSelectAmazonUnselectedH = @"data\global\ui\FrontEnd\amazon\AMNU2.DC6";
|
||||
public const string CharacterSelecAmazonSelected = @"data\global\ui\FrontEnd\amazon\AMNU3.DC6";
|
||||
public const string CharacterSelecAmazonForwardWalk = @"data\global\ui\FrontEnd\amazon\AMFW.DC6";
|
||||
public const string CharacterSelecAmazonForwardWalkOverlay = @"data\global\ui\FrontEnd\amazon\AMFWs.DC6";
|
||||
public const string CharacterSelecAmazonBackWalk = @"data\global\ui\FrontEnd\amazon\AMBW.DC6";
|
||||
|
||||
public const string CharacterSelectAssassinUnselected = @"data\global\ui\FrontEnd\assassin\ASNU1.DC6";
|
||||
public const string CharacterSelectAssassinUnselectedH = @"data\global\ui\FrontEnd\assassin\ASNU2.DC6";
|
||||
public const string CharacterSelectAssassinSelected = @"data\global\ui\FrontEnd\assassin\ASNU3.DC6";
|
||||
public const string CharacterSelectAssassinForwardWalk = @"data\global\ui\FrontEnd\assassin\ASFW.DC6";
|
||||
public const string CharacterSelectAssassinBackWalk = @"data\global\ui\FrontEnd\assassin\ASBW.DC6";
|
||||
|
||||
public const string CharacterSelectDruidUnselected = @"data\global\ui\FrontEnd\druid\DZNU1.dc6";
|
||||
public const string CharacterSelectDruidUnselectedH = @"data\global\ui\FrontEnd\druid\DZNU2.dc6";
|
||||
public const string CharacterSelectDruidSelected = @"data\global\ui\FrontEnd\druid\DZNU3.DC6";
|
||||
public const string CharacterSelectDruidForwardWalk = @"data\global\ui\FrontEnd\druid\DZFW.DC6";
|
||||
public const string CharacterSelectDruidBackWalk = @"data\global\ui\FrontEnd\druid\DZBW.DC6";
|
||||
|
||||
// -- Character Selection
|
||||
public const string CharacterSelectionBackground = @"data\global\ui\CharSelect\characterselectscreenEXP.dc6";
|
||||
|
||||
// --- Game ---
|
||||
public const string GamePanels = @"data\global\ui\PANEL\800ctrlpnl7.dc6";
|
||||
public const string GameGlobeOverlap = @"data\global\ui\PANEL\overlap.DC6";
|
||||
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";
|
||||
|
||||
// --- Fonts ---
|
||||
public const string Font6 = @"data\local\font\latin\font6";
|
||||
public const string Font8 = @"data\local\font\latin\font8";
|
||||
public const string Font16 = @"data\local\font\latin\font16";
|
||||
public const string Font24 = @"data\local\font\latin\font24";
|
||||
public const string Font30 = @"data\local\font\latin\font30";
|
||||
public const string FontFormal12 = @"data\local\font\latin\fontformal12";
|
||||
public const string FontFormal11 = @"data\local\font\latin\fontformal11";
|
||||
public const string FontFormal10 = @"data\local\font\latin\fontformal10";
|
||||
public const string FontExocet10 = @"data\local\font\latin\fontexocet10";
|
||||
public const string FontExocet8 = @"data\local\font\latin\fontexocet8";
|
||||
|
||||
// --- UI ---
|
||||
public const string WideButtonBlank = @"data\global\ui\FrontEnd\WideButtonBlank.dc6";
|
||||
public const string MediumButtonBlank = @"data\global\ui\FrontEnd\MediumButtonBlank.dc6";
|
||||
public const string CancelButton = @"data\global\ui\FrontEnd\CancelButtonBlank.dc6";
|
||||
public const string NarrowButtonBlank = @"data\global\ui\FrontEnd\NarrowButtonBlank.dc6";
|
||||
public const string TextBox2 = @"data\global\ui\FrontEnd\textbox2.dc6";
|
||||
public const string TallButtonBlank = @"data\global\ui\CharSelect\TallButtonBlank.dc6";
|
||||
|
||||
// --- GAME UI ---
|
||||
public const string MinipanelSmall = @"data\global\ui\PANEL\minipanel_s.dc6";
|
||||
public const string MinipanelButton = @"data\global\ui\PANEL\minipanelbtn.DC6";
|
||||
|
||||
public const string Frame = @"data\global\ui\PANEL\800borderframe.dc6";
|
||||
public const string InventoryCharacterPanel = @"data\global\ui\PANEL\invchar6.DC6";
|
||||
public const string InventoryWeaponsTab = @"data\global\ui\PANEL\invchar6Tab.DC6";
|
||||
|
||||
public const string RunButton = @"data\global\ui\PANEL\runbutton.dc6";
|
||||
public const string MenuButton = @"data\global\ui\PANEL\menubutton.DC6";
|
||||
public const string GoldCoinButton = @"data\global\ui\panel\goldcoinbtn.dc6";
|
||||
public const string SquareButton = @"data\global\ui\panel\buysellbtn.dc6";
|
||||
|
||||
public const string ArmorPlaceholder = @"data\global\ui\PANEL\inv_armor.DC6";
|
||||
public const string BeltPlaceholder = @"data\global\ui\PANEL\inv_belt.DC6";
|
||||
public const string BootsPlaceholder = @"data\global\ui\PANEL\inv_boots.DC6";
|
||||
public const string HelmGlovePlaceholder = @"data\global\ui\PANEL\inv_helm_glove.DC6";
|
||||
public const string RingAmuletPlaceholder = @"data\global\ui\PANEL\inv_ring_amulet.DC6";
|
||||
public const string WeaponsPlaceholder = @"data\global\ui\PANEL\inv_weapons.DC6";
|
||||
|
||||
// --- Data ---
|
||||
// TODO: Doesn't sound right :)
|
||||
public const string EnglishTable = @"data\local\lng\eng\English.txt";
|
||||
public const string ExpansionStringTable = @"data\local\lng\eng\expansionstring.tbl";
|
||||
public const string LevelPreset = @"data\global\excel\LvlPrest.txt";
|
||||
public const string LevelType = @"data\global\excel\LvlTypes.txt";
|
||||
public const string LevelDetails = @"data\global\excel\Levels.txt";
|
||||
|
||||
// --- Animations ---
|
||||
public const string ObjectData = @"data\global\objects";
|
||||
public const string AnimationData = @"data\global\animdata.d2";
|
||||
public const string PlayerAnimationBase = @"data\global\CHARS";
|
||||
|
||||
// --- Inventory Data ---
|
||||
public const string Weapons = @"data\global\excel\weapons.txt";
|
||||
public const string Armor = @"data\global\excel\armor.txt";
|
||||
public const string Misc = @"data\global\excel\misc.txt";
|
||||
|
||||
// --- Character Data ---
|
||||
public const string Experience = @"data\global\excel\experience.txt";
|
||||
public const string CharStats = @"data\global\excel\charstats.txt";
|
||||
|
||||
// --- Music ---
|
||||
public const string BGMTitle = @"data\global\music\introedit.wav";
|
||||
public const string BGMOptions = @"data\global\music\Common\options.wav";
|
||||
public const string BGMAct1AndarielAction = @"data\global\music\Act1\andarielaction.wav";
|
||||
public const string BGMAct1BloodRavenResolution = @"data\global\music\Act1\bloodravenresolution.wav";
|
||||
public const string BGMAct1Caves = @"data\global\music\Act1\caves.wav";
|
||||
public const string BGMAct1Crypt = @"data\global\music\Act1\crypt.wav";
|
||||
public const string BGMAct1DenOfEvilAction = @"data\global\music\Act1\denofevilaction.wav";
|
||||
public const string BGMAct1Monastery = @"data\global\music\Act1\monastery.wav";
|
||||
public const string BGMAct1Town1 = @"data\global\music\Act1\town1.wav";
|
||||
public const string BGMAct1Tristram = @"data\global\music\Act1\tristram.wav";
|
||||
public const string BGMAct1Wild = @"data\global\music\Act1\wild.wav";
|
||||
public const string BGMAct2Desert = @"data\global\music\Act2\desert.wav";
|
||||
public const string BGMAct2Harem = @"data\global\music\Act2\harem.wav";
|
||||
public const string BGMAct2HoradricAction = @"data\global\music\Act2\horadricaction.wav";
|
||||
public const string BGMAct2Lair = @"data\global\music\Act2\lair.wav";
|
||||
public const string BGMAct2RadamentResolution = @"data\global\music\Act2\radamentresolution.wav";
|
||||
public const string BGMAct2Sanctuary = @"data\global\music\Act2\sanctuary.wav";
|
||||
public const string BGMAct2Sewer = @"data\global\music\Act2\sewer.wav";
|
||||
public const string BGMAct2TaintedSunAction = @"data\global\music\Act2\taintedsunaction.wav";
|
||||
public const string BGMAct2Tombs = @"data\global\music\Act2\tombs.wav";
|
||||
public const string BGMAct2Town2 = @"data\global\music\Act2\town2.wav";
|
||||
public const string BGMAct2Valley = @"data\global\music\Act2\valley.wav";
|
||||
public const string BGMAct3Jungle = @"data\global\music\Act3\jungle.wav";
|
||||
public const string BGMAct3Kurast = @"data\global\music\Act3\kurast.wav";
|
||||
public const string BGMAct3KurastSewer = @"data\global\music\Act3\kurastsewer.wav";
|
||||
public const string BGMAct3MefDeathAction = @"data\global\music\Act3\mefdeathaction.wav";
|
||||
public const string BGMAct3OrbAction = @"data\global\music\Act3\orbaction.wav";
|
||||
public const string BGMAct3Spider = @"data\global\music\Act3\spider.wav";
|
||||
public const string BGMAct3Town3 = @"data\global\music\Act3\town3.wav";
|
||||
public const string BGMAct4Diablo = @"data\global\music\Act4\diablo.wav";
|
||||
public const string BGMAct4DiabloAction = @"data\global\music\Act4\diabloaction.wav";
|
||||
public const string BGMAct4ForgeAction = @"data\global\music\Act4\forgeaction.wav";
|
||||
public const string BGMAct4IzualAction = @"data\global\music\Act4\izualaction.wav";
|
||||
public const string BGMAct4Mesa = @"data\global\music\Act4\mesa.wav";
|
||||
public const string BGMAct4Town4 = @"data\global\music\Act4\town4.wav";
|
||||
public const string BGMAct5Baal = @"data\global\music\Act5\baal.wav";
|
||||
public const string BGMAct5XTown = @"data\global\music\Act5\xtown.wav";
|
||||
|
||||
|
||||
// --- Sound Effects ---
|
||||
public const string SFXButtonClick = @"data\global\sfx\Cursor\button.wav";
|
||||
public const string SFXAmazonDeselect = @"data\global\sfx\Cursor\intro\amazon deselect.wav";
|
||||
public const string SFXAmazonSelect = @"data\global\sfx\Cursor\intro\amazon select.wav";
|
||||
public const string SFXAssassinDeselect = @"data\global\sfx\Cursor\intro\assassin deselect.wav";
|
||||
public const string SFXAssassinSelect = @"data\global\sfx\Cursor\intro\assassin select.wav";
|
||||
public const string SFXBarbarianDeselect = @"data\global\sfx\Cursor\intro\barbarian deselect.wav";
|
||||
public const string SFXBarbarianSelect = @"data\global\sfx\Cursor\intro\barbarian select.wav";
|
||||
public const string SFXDruidDeselect = @"data\global\sfx\Cursor\intro\druid deselect.wav";
|
||||
public const string SFXDruidSelect = @"data\global\sfx\Cursor\intro\druid select.wav";
|
||||
public const string SFXNecromancerDeselect = @"data\global\sfx\Cursor\intro\necromancer deselect.wav";
|
||||
public const string SFXNecromancerSelect = @"data\global\sfx\Cursor\intro\necromancer select.wav";
|
||||
public const string SFXPaladinDeselect = @"data\global\sfx\Cursor\intro\paladin deselect.wav";
|
||||
public const string SFXPaladinSelect = @"data\global\sfx\Cursor\intro\paladin select.wav";
|
||||
public const string SFXSorceressDeselect = @"data\global\sfx\Cursor\intro\sorceress deselect.wav";
|
||||
public const string SFXSorceressSelect = @"data\global\sfx\Cursor\intro\sorceress select.wav";
|
||||
|
||||
public static string GeneratePathForItem(string spriteName)
|
||||
{
|
||||
return $@"data\global\items\{spriteName}.dc6";
|
||||
}
|
||||
|
||||
public static string GetMusicPathForLevel(eLevelId levelId)
|
||||
{
|
||||
switch (levelId)
|
||||
{
|
||||
case eLevelId.None:
|
||||
return string.Empty;
|
||||
case eLevelId.Act1_Town1:
|
||||
return BGMAct1Town1;
|
||||
case eLevelId.Act1_CaveTreasure2:
|
||||
return BGMAct1Caves;
|
||||
case eLevelId.Act1_CaveTreasure3:
|
||||
return BGMAct1Caves;
|
||||
case eLevelId.Act1_CaveTreasure4:
|
||||
return BGMAct1Caves;
|
||||
case eLevelId.Act1_CaveTreasure5:
|
||||
return BGMAct1Caves;
|
||||
case eLevelId.Act1_CryptCountessX:
|
||||
return BGMAct1BloodRavenResolution; // TODO: Verify
|
||||
case eLevelId.Act1_Tower2:
|
||||
return BGMAct1Caves; // TODO: Verify
|
||||
case eLevelId.Act1_MonFront:
|
||||
return BGMAct1DenOfEvilAction; // TODO: Verify
|
||||
case eLevelId.Act1_Courtyard1:
|
||||
return BGMAct1Monastery; // TODO: Verify
|
||||
case eLevelId.Act1_Courtyard2:
|
||||
return BGMAct1Monastery; // TODO: Verify
|
||||
case eLevelId.Act1_Cathedral:
|
||||
return BGMAct1Monastery; // TODO: Verify
|
||||
case eLevelId.Act1_Andariel:
|
||||
return BGMAct1AndarielAction;
|
||||
case eLevelId.Act1_Tristram:
|
||||
return BGMAct1Tristram;
|
||||
case eLevelId.Act2_Town:
|
||||
return BGMAct2Town2;
|
||||
case eLevelId.Act2_Harem:
|
||||
return BGMAct2Harem;
|
||||
case eLevelId.Act2_DurielsLair:
|
||||
return BGMAct2Lair;
|
||||
case eLevelId.Act3_Town:
|
||||
return BGMAct3Town3;
|
||||
case eLevelId.Act3_DungeonTreasure1:
|
||||
return BGMAct3Kurast; // TODO: Verify
|
||||
case eLevelId.Act3_DungeonTreasure2:
|
||||
return BGMAct3Kurast; // TODO: Verify
|
||||
case eLevelId.Act3_SewerTreasureX:
|
||||
return BGMAct3KurastSewer; // TODO: Verify
|
||||
case eLevelId.Act3_Temple1:
|
||||
return BGMAct3Kurast; // TODO: Verify
|
||||
case eLevelId.Act3_Temple2:
|
||||
return BGMAct3Kurast; // TODO: Verify
|
||||
case eLevelId.Act3_Temple3:
|
||||
return BGMAct3Kurast; // TODO: Verify
|
||||
case eLevelId.Act3_Temple4:
|
||||
return BGMAct3Kurast; // TODO: Verify
|
||||
case eLevelId.Act3_Temple5:
|
||||
return BGMAct3Kurast; // TODO: Verify
|
||||
case eLevelId.Act3_Temple6:
|
||||
return BGMAct3Kurast; // TODO: Verify
|
||||
case eLevelId.Act3_MephistoComplex:
|
||||
return BGMAct3MefDeathAction; // TODO: Verify
|
||||
case eLevelId.Act4_Fortress:
|
||||
return BGMAct4Mesa; // TODO: Verify
|
||||
case eLevelId.Act5_Town:
|
||||
return BGMAct5XTown;
|
||||
case eLevelId.Act5_TempleFinalRoom:
|
||||
return BGMAct2Sanctuary; // TODO: Verify
|
||||
case eLevelId.Act5_ThroneRoom:
|
||||
return BGMAct2Sanctuary; // TODO: Verify
|
||||
case eLevelId.Act5_WorldStone:
|
||||
return BGMAct4ForgeAction; // TODO: Verify
|
||||
case eLevelId.Act5_TempleEntrance:
|
||||
return BGMAct5Baal; // TODO: Verify
|
||||
case eLevelId.Act5_BaalEntrance:
|
||||
return BGMAct5Baal; // TODO: Verify
|
||||
default:
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,232 +1,232 @@
|
||||
using OpenDiablo2.Common;
|
||||
using OpenDiablo2.Common.Interfaces;
|
||||
using OpenDiablo2.Common.Models;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
namespace OpenDiablo2.Core.UI
|
||||
{
|
||||
public sealed class Button : IButton
|
||||
{
|
||||
private readonly IMouseInfoProvider mouseInfoProvider;
|
||||
private readonly IRenderWindow renderWindow;
|
||||
private readonly ISoundProvider musicProvider;
|
||||
private readonly ButtonLayout buttonLayout;
|
||||
private readonly byte[] sfxButtonClick;
|
||||
|
||||
public OnActivateDelegate OnActivate { get; set; }
|
||||
public OnToggleDelegate OnToggle { get; set; }
|
||||
|
||||
private Point location = new Point();
|
||||
public Point Location
|
||||
{
|
||||
get => location;
|
||||
set
|
||||
{
|
||||
location = value;
|
||||
sprite.Location = value;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly int buttonWidth;
|
||||
private readonly int buttonHeight;
|
||||
private readonly ISprite sprite;
|
||||
private readonly IFont font;
|
||||
private readonly ILabel label;
|
||||
private bool pressed = false;
|
||||
private bool active = false; // When true, button is actively being focus pressed
|
||||
private bool activeLock = false; // When true, we have locked the mouse from everything else
|
||||
public bool Toggled { get; private set; } = false;
|
||||
|
||||
private Point labelOffset = new Point();
|
||||
|
||||
public Size ClickableRect { get; set; }
|
||||
public bool AllowFrameChange { get; set; } = true;
|
||||
|
||||
private bool enabled = true;
|
||||
public bool Enabled
|
||||
{
|
||||
get => enabled;
|
||||
set
|
||||
{
|
||||
if (value == enabled)
|
||||
return;
|
||||
enabled = value;
|
||||
|
||||
if(buttonLayout.IsDarkenedWhenDisabled)
|
||||
sprite.Darken = !enabled;
|
||||
}
|
||||
}
|
||||
|
||||
private string text;
|
||||
public string Text
|
||||
{
|
||||
get => text;
|
||||
set
|
||||
{
|
||||
text = value;
|
||||
UpdateText();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Button(
|
||||
ButtonLayout buttonLayout,
|
||||
IRenderWindow renderWindow,
|
||||
IMouseInfoProvider mouseInfoProvider,
|
||||
ISoundProvider soundProvider,
|
||||
IMPQProvider mpqProvider
|
||||
)
|
||||
{
|
||||
this.buttonLayout = buttonLayout;
|
||||
this.renderWindow = renderWindow;
|
||||
this.mouseInfoProvider = mouseInfoProvider;
|
||||
this.musicProvider = soundProvider;
|
||||
|
||||
font = renderWindow.LoadFont(ResourcePaths.FontExocet10, Palettes.Units);
|
||||
label = renderWindow.CreateLabel(font);
|
||||
|
||||
sprite = renderWindow.LoadSprite(buttonLayout.ResourceName, buttonLayout.PaletteName, true);
|
||||
|
||||
// TODO: Less stupid way of doing this would be nice
|
||||
buttonWidth = 0;
|
||||
buttonHeight = 0;
|
||||
for (int i = 0; i < buttonLayout.XSegments; i++)
|
||||
{
|
||||
sprite.Frame = i;
|
||||
buttonWidth += sprite.LocalFrameSize.Width;
|
||||
buttonHeight = Math.Max(buttonHeight, sprite.LocalFrameSize.Height);
|
||||
}
|
||||
|
||||
label.MaxWidth = buttonWidth - 8;
|
||||
label.Alignment = Common.Enums.eTextAlign.Centered;
|
||||
|
||||
sfxButtonClick = mpqProvider.GetBytes(ResourcePaths.SFXButtonClick);
|
||||
}
|
||||
|
||||
public bool Toggle()
|
||||
{
|
||||
Toggled = !Toggled;
|
||||
|
||||
OnToggle?.Invoke(Toggled);
|
||||
|
||||
return Toggled;
|
||||
}
|
||||
|
||||
public bool Toggle(bool isToggled)
|
||||
{
|
||||
if(Toggled != isToggled)
|
||||
{
|
||||
OnToggle?.Invoke(isToggled);
|
||||
|
||||
Toggled = isToggled;
|
||||
}
|
||||
|
||||
return isToggled;
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (!enabled)
|
||||
{
|
||||
// Prevent sticky locks
|
||||
if (activeLock && mouseInfoProvider.ReserveMouse)
|
||||
{
|
||||
activeLock = false;
|
||||
mouseInfoProvider.ReserveMouse = false;
|
||||
}
|
||||
|
||||
active = false;
|
||||
return;
|
||||
}
|
||||
|
||||
int clickWidth = ClickableRect.Width > 0 ? ClickableRect.Width : buttonWidth;
|
||||
int clickHeight = ClickableRect.Height > 0 ? ClickableRect.Height : buttonHeight;
|
||||
var hovered = mouseInfoProvider.MouseX >= location.X && mouseInfoProvider.MouseX < (location.X + clickWidth)
|
||||
&& mouseInfoProvider.MouseY >= location.Y && mouseInfoProvider.MouseY < (location.Y + clickHeight);
|
||||
|
||||
|
||||
if (!activeLock && hovered && mouseInfoProvider.LeftMouseDown && !mouseInfoProvider.ReserveMouse)
|
||||
{
|
||||
// The button is being pressed down
|
||||
mouseInfoProvider.ReserveMouse = true;
|
||||
active = true;
|
||||
musicProvider.PlaySfx(sfxButtonClick);
|
||||
}
|
||||
else if (active && !mouseInfoProvider.LeftMouseDown)
|
||||
{
|
||||
mouseInfoProvider.ReserveMouse = false;
|
||||
active = false;
|
||||
|
||||
if (hovered)
|
||||
{
|
||||
OnActivate?.Invoke();
|
||||
|
||||
if (buttonLayout.Toggleable)
|
||||
{
|
||||
Toggle();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (!active && mouseInfoProvider.LeftMouseDown)
|
||||
{
|
||||
activeLock = true;
|
||||
}
|
||||
else if (activeLock && !mouseInfoProvider.LeftMouseDown)
|
||||
{
|
||||
activeLock = false;
|
||||
}
|
||||
|
||||
pressed = hovered && mouseInfoProvider.LeftMouseDown && active;
|
||||
}
|
||||
|
||||
public void Render()
|
||||
{
|
||||
var frame = buttonLayout.BaseFrame;
|
||||
|
||||
if (AllowFrameChange)
|
||||
{
|
||||
if(!Enabled && buttonLayout.DisabledFrame >= 0)
|
||||
{
|
||||
frame = buttonLayout.DisabledFrame;
|
||||
}
|
||||
else if (Toggled && pressed)
|
||||
{
|
||||
frame = buttonLayout.BaseFrame + 3;
|
||||
}
|
||||
else if (pressed)
|
||||
{
|
||||
frame = buttonLayout.BaseFrame + 1;
|
||||
}
|
||||
else if (Toggled)
|
||||
{
|
||||
frame = buttonLayout.BaseFrame + 2;
|
||||
}
|
||||
}
|
||||
|
||||
renderWindow.Draw(sprite, buttonLayout.XSegments, 1, frame);
|
||||
var offset = pressed ? -2 : 0;
|
||||
|
||||
label.Location = new Point(location.X + offset + labelOffset.X, location.Y - offset + labelOffset.Y);
|
||||
renderWindow.Draw(label);
|
||||
}
|
||||
|
||||
private void UpdateText()
|
||||
{
|
||||
label.Text = text;
|
||||
label.TextColor = Color.FromArgb(75, 75, 75);
|
||||
|
||||
var offsetX = (buttonWidth / 2) - (label.TextArea.Width / 2);
|
||||
var offsetY = (buttonHeight / 2) - (label.TextArea.Height / 2);
|
||||
labelOffset = new Point(offsetX, offsetY - 5);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
sprite.Dispose();
|
||||
font.Dispose();
|
||||
label.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
using OpenDiablo2.Common;
|
||||
using OpenDiablo2.Common.Interfaces;
|
||||
using OpenDiablo2.Common.Models;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
namespace OpenDiablo2.Core.UI
|
||||
{
|
||||
public sealed class Button : IButton
|
||||
{
|
||||
private readonly IMouseInfoProvider mouseInfoProvider;
|
||||
private readonly IRenderWindow renderWindow;
|
||||
private readonly ISoundProvider musicProvider;
|
||||
private readonly ButtonLayout buttonLayout;
|
||||
private readonly byte[] sfxButtonClick;
|
||||
|
||||
public OnActivateDelegate OnActivate { get; set; }
|
||||
public OnToggleDelegate OnToggle { get; set; }
|
||||
|
||||
private Point location = new Point();
|
||||
public Point Location
|
||||
{
|
||||
get => location;
|
||||
set
|
||||
{
|
||||
location = value;
|
||||
sprite.Location = value;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly int buttonWidth;
|
||||
private readonly int buttonHeight;
|
||||
private readonly ISprite sprite;
|
||||
private readonly IFont font;
|
||||
private readonly ILabel label;
|
||||
private bool pressed = false;
|
||||
private bool active = false; // When true, button is actively being focus pressed
|
||||
private bool activeLock = false; // When true, we have locked the mouse from everything else
|
||||
public bool Toggled { get; private set; } = false;
|
||||
|
||||
private Point labelOffset = new Point();
|
||||
|
||||
public Size ClickableRect { get; set; }
|
||||
public bool AllowFrameChange { get; set; } = true;
|
||||
|
||||
private bool enabled = true;
|
||||
public bool Enabled
|
||||
{
|
||||
get => enabled;
|
||||
set
|
||||
{
|
||||
if (value == enabled)
|
||||
return;
|
||||
enabled = value;
|
||||
|
||||
if(buttonLayout.IsDarkenedWhenDisabled)
|
||||
sprite.Darken = !enabled;
|
||||
}
|
||||
}
|
||||
|
||||
private string text;
|
||||
public string Text
|
||||
{
|
||||
get => text;
|
||||
set
|
||||
{
|
||||
text = value;
|
||||
UpdateText();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Button(
|
||||
ButtonLayout buttonLayout,
|
||||
IRenderWindow renderWindow,
|
||||
IMouseInfoProvider mouseInfoProvider,
|
||||
ISoundProvider soundProvider,
|
||||
IMPQProvider mpqProvider
|
||||
)
|
||||
{
|
||||
this.buttonLayout = buttonLayout;
|
||||
this.renderWindow = renderWindow;
|
||||
this.mouseInfoProvider = mouseInfoProvider;
|
||||
this.musicProvider = soundProvider;
|
||||
|
||||
font = renderWindow.LoadFont(ResourcePaths.FontExocet10, Palettes.Units);
|
||||
label = renderWindow.CreateLabel(font);
|
||||
|
||||
sprite = renderWindow.LoadSprite(buttonLayout.ResourceName, buttonLayout.PaletteName, true);
|
||||
|
||||
// TODO: Less stupid way of doing this would be nice
|
||||
buttonWidth = 0;
|
||||
buttonHeight = 0;
|
||||
for (int i = 0; i < buttonLayout.XSegments; i++)
|
||||
{
|
||||
sprite.Frame = i;
|
||||
buttonWidth += sprite.LocalFrameSize.Width;
|
||||
buttonHeight = Math.Max(buttonHeight, sprite.LocalFrameSize.Height);
|
||||
}
|
||||
|
||||
label.MaxWidth = buttonWidth - 8;
|
||||
label.Alignment = Common.Enums.eTextAlign.Centered;
|
||||
|
||||
sfxButtonClick = mpqProvider.GetBytes(ResourcePaths.SFXButtonClick);
|
||||
}
|
||||
|
||||
public bool Toggle()
|
||||
{
|
||||
Toggled = !Toggled;
|
||||
|
||||
OnToggle?.Invoke(Toggled);
|
||||
|
||||
return Toggled;
|
||||
}
|
||||
|
||||
public bool Toggle(bool isToggled)
|
||||
{
|
||||
if(Toggled != isToggled)
|
||||
{
|
||||
OnToggle?.Invoke(isToggled);
|
||||
|
||||
Toggled = isToggled;
|
||||
}
|
||||
|
||||
return isToggled;
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (!enabled)
|
||||
{
|
||||
// Prevent sticky locks
|
||||
if (activeLock && mouseInfoProvider.ReserveMouse)
|
||||
{
|
||||
activeLock = false;
|
||||
mouseInfoProvider.ReserveMouse = false;
|
||||
}
|
||||
|
||||
active = false;
|
||||
return;
|
||||
}
|
||||
|
||||
int clickWidth = ClickableRect.Width > 0 ? ClickableRect.Width : buttonWidth;
|
||||
int clickHeight = ClickableRect.Height > 0 ? ClickableRect.Height : buttonHeight;
|
||||
var hovered = mouseInfoProvider.MouseX >= location.X && mouseInfoProvider.MouseX < (location.X + clickWidth)
|
||||
&& mouseInfoProvider.MouseY >= location.Y && mouseInfoProvider.MouseY < (location.Y + clickHeight);
|
||||
|
||||
|
||||
if (!activeLock && hovered && mouseInfoProvider.LeftMouseDown && !mouseInfoProvider.ReserveMouse)
|
||||
{
|
||||
// The button is being pressed down
|
||||
mouseInfoProvider.ReserveMouse = true;
|
||||
active = true;
|
||||
musicProvider.PlaySfx(sfxButtonClick);
|
||||
}
|
||||
else if (active && !mouseInfoProvider.LeftMouseDown)
|
||||
{
|
||||
mouseInfoProvider.ReserveMouse = false;
|
||||
active = false;
|
||||
|
||||
if (hovered)
|
||||
{
|
||||
OnActivate?.Invoke();
|
||||
|
||||
if (buttonLayout.Toggleable)
|
||||
{
|
||||
Toggle();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (!active && mouseInfoProvider.LeftMouseDown)
|
||||
{
|
||||
activeLock = true;
|
||||
}
|
||||
else if (activeLock && !mouseInfoProvider.LeftMouseDown)
|
||||
{
|
||||
activeLock = false;
|
||||
}
|
||||
|
||||
pressed = hovered && mouseInfoProvider.LeftMouseDown && active;
|
||||
}
|
||||
|
||||
public void Render()
|
||||
{
|
||||
var frame = buttonLayout.BaseFrame;
|
||||
|
||||
if (AllowFrameChange)
|
||||
{
|
||||
if(!Enabled && buttonLayout.DisabledFrame >= 0)
|
||||
{
|
||||
frame = buttonLayout.DisabledFrame;
|
||||
}
|
||||
else if (Toggled && pressed)
|
||||
{
|
||||
frame = buttonLayout.BaseFrame + 3;
|
||||
}
|
||||
else if (pressed)
|
||||
{
|
||||
frame = buttonLayout.BaseFrame + 1;
|
||||
}
|
||||
else if (Toggled)
|
||||
{
|
||||
frame = buttonLayout.BaseFrame + 2;
|
||||
}
|
||||
}
|
||||
|
||||
renderWindow.Draw(sprite, buttonLayout.XSegments, 1, frame);
|
||||
var offset = pressed ? -2 : 0;
|
||||
|
||||
label.Location = new Point(location.X + offset + labelOffset.X, location.Y - offset + labelOffset.Y);
|
||||
renderWindow.Draw(label);
|
||||
}
|
||||
|
||||
private void UpdateText()
|
||||
{
|
||||
label.Text = text;
|
||||
label.TextColor = Color.FromArgb(75, 75, 75);
|
||||
|
||||
var offsetX = (buttonWidth / 2) - (label.TextArea.Width / 2);
|
||||
var offsetY = (buttonHeight / 2) - (label.TextArea.Height / 2);
|
||||
labelOffset = new Point(offsetX, offsetY - 5);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
sprite.Dispose();
|
||||
font.Dispose();
|
||||
label.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,117 +1,117 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using OpenDiablo2.Common;
|
||||
using OpenDiablo2.Common.Enums;
|
||||
using OpenDiablo2.Common.Interfaces;
|
||||
using OpenDiablo2.Common.Models;
|
||||
|
||||
namespace OpenDiablo2.Core.UI
|
||||
{
|
||||
// TODO: Self-align when side panels are open
|
||||
public sealed class ItemContainer : IItemContainer
|
||||
{
|
||||
private readonly IRenderWindow renderWindow;
|
||||
private readonly IGameState gameState;
|
||||
private ISprite sprite;
|
||||
|
||||
private readonly ItemContainerLayout itemContainerLayout;
|
||||
private readonly IMouseInfoProvider mouseInfoProvider;
|
||||
|
||||
public ItemInstance ContainedItem { get; internal set; }
|
||||
|
||||
private readonly Dictionary<eItemContainerType, ISprite> sprites = new Dictionary<eItemContainerType, ISprite>();
|
||||
|
||||
private Point location = new Point();
|
||||
|
||||
public Point Location
|
||||
{
|
||||
get => location;
|
||||
set
|
||||
{
|
||||
if (location == value)
|
||||
return;
|
||||
location = value;
|
||||
|
||||
placeholderSprite.Location = new Point(value.X, value.Y + placeholderSprite.LocalFrameSize.Height);
|
||||
}
|
||||
}
|
||||
|
||||
private readonly ISprite placeholderSprite;
|
||||
|
||||
public Size Size { get; internal set; }
|
||||
|
||||
public ItemContainer(IRenderWindow renderWindow, IGameState gameState, ItemContainerLayout itemContainerLayout, IMouseInfoProvider mouseInfoProvider)
|
||||
{
|
||||
this.renderWindow = renderWindow;
|
||||
this.gameState = gameState;
|
||||
this.itemContainerLayout = itemContainerLayout;
|
||||
this.mouseInfoProvider = mouseInfoProvider;
|
||||
|
||||
placeholderSprite = renderWindow.LoadSprite(itemContainerLayout.ResourceName, itemContainerLayout.PaletteName, true);
|
||||
placeholderSprite.Location = new Point(location.X, location.Y + placeholderSprite.LocalFrameSize.Height);
|
||||
this.Size = placeholderSprite.FrameSize; // For all but generic size is equal to the placeholder size. Source: me.
|
||||
}
|
||||
|
||||
public void SetContainedItem(ItemInstance containedItem)
|
||||
{
|
||||
ContainedItem = containedItem;
|
||||
|
||||
if (ContainedItem != null)
|
||||
{
|
||||
sprite = renderWindow.LoadSprite(ResourcePaths.GeneratePathForItem(this.ContainedItem.Item.InvFile), Palettes.Units, true);
|
||||
sprite.Location = new Point(location.X, location.Y + sprite.LocalFrameSize.Height);
|
||||
}
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
var hovered = mouseInfoProvider.MouseX >= location.X && mouseInfoProvider.MouseX < (location.X + this.Size.Width)
|
||||
&& mouseInfoProvider.MouseY >= location.Y && mouseInfoProvider.MouseY < (location.Y + this.Size.Height);
|
||||
|
||||
if (hovered && mouseInfoProvider.LeftMousePressed)
|
||||
{
|
||||
// If there is an item contained, remove from container and send to mouse
|
||||
if (this.ContainedItem != null)
|
||||
{
|
||||
if (this.gameState.SelectedItem != null)
|
||||
{
|
||||
var switchItem = this.gameState.SelectedItem;
|
||||
|
||||
this.gameState.SelectItem(this.ContainedItem);
|
||||
this.SetContainedItem(switchItem);
|
||||
} else
|
||||
{
|
||||
this.gameState.SelectItem(this.ContainedItem);
|
||||
this.SetContainedItem(null);
|
||||
}
|
||||
|
||||
}
|
||||
else if (this.gameState.SelectedItem != null)
|
||||
{
|
||||
this.SetContainedItem(this.gameState.SelectedItem);
|
||||
this.gameState.SelectItem(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Render()
|
||||
{
|
||||
if (this.ContainedItem == null)
|
||||
{
|
||||
renderWindow.Draw(placeholderSprite, this.itemContainerLayout.BaseFrame);
|
||||
}
|
||||
else
|
||||
{
|
||||
renderWindow.Draw(sprite);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if(sprite != null)
|
||||
{
|
||||
sprite.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using OpenDiablo2.Common;
|
||||
using OpenDiablo2.Common.Enums;
|
||||
using OpenDiablo2.Common.Interfaces;
|
||||
using OpenDiablo2.Common.Models;
|
||||
|
||||
namespace OpenDiablo2.Core.UI
|
||||
{
|
||||
// TODO: Self-align when side panels are open
|
||||
public sealed class ItemContainer : IItemContainer
|
||||
{
|
||||
private readonly IRenderWindow renderWindow;
|
||||
private readonly IGameState gameState;
|
||||
private ISprite sprite;
|
||||
|
||||
private readonly ItemContainerLayout itemContainerLayout;
|
||||
private readonly IMouseInfoProvider mouseInfoProvider;
|
||||
|
||||
public ItemInstance ContainedItem { get; internal set; }
|
||||
|
||||
private readonly Dictionary<eItemContainerType, ISprite> sprites = new Dictionary<eItemContainerType, ISprite>();
|
||||
|
||||
private Point location = new Point();
|
||||
|
||||
public Point Location
|
||||
{
|
||||
get => location;
|
||||
set
|
||||
{
|
||||
if (location == value)
|
||||
return;
|
||||
location = value;
|
||||
|
||||
placeholderSprite.Location = new Point(value.X, value.Y + placeholderSprite.LocalFrameSize.Height);
|
||||
}
|
||||
}
|
||||
|
||||
private readonly ISprite placeholderSprite;
|
||||
|
||||
public Size Size { get; internal set; }
|
||||
|
||||
public ItemContainer(IRenderWindow renderWindow, IGameState gameState, ItemContainerLayout itemContainerLayout, IMouseInfoProvider mouseInfoProvider)
|
||||
{
|
||||
this.renderWindow = renderWindow;
|
||||
this.gameState = gameState;
|
||||
this.itemContainerLayout = itemContainerLayout;
|
||||
this.mouseInfoProvider = mouseInfoProvider;
|
||||
|
||||
placeholderSprite = renderWindow.LoadSprite(itemContainerLayout.ResourceName, itemContainerLayout.PaletteName, true);
|
||||
placeholderSprite.Location = new Point(location.X, location.Y + placeholderSprite.LocalFrameSize.Height);
|
||||
this.Size = placeholderSprite.FrameSize; // For all but generic size is equal to the placeholder size. Source: me.
|
||||
}
|
||||
|
||||
public void SetContainedItem(ItemInstance containedItem)
|
||||
{
|
||||
ContainedItem = containedItem;
|
||||
|
||||
if (ContainedItem != null)
|
||||
{
|
||||
sprite = renderWindow.LoadSprite(ResourcePaths.GeneratePathForItem(this.ContainedItem.Item.InvFile), Palettes.Units, true);
|
||||
sprite.Location = new Point(location.X, location.Y + sprite.LocalFrameSize.Height);
|
||||
}
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
var hovered = mouseInfoProvider.MouseX >= location.X && mouseInfoProvider.MouseX < (location.X + this.Size.Width)
|
||||
&& mouseInfoProvider.MouseY >= location.Y && mouseInfoProvider.MouseY < (location.Y + this.Size.Height);
|
||||
|
||||
if (hovered && mouseInfoProvider.LeftMousePressed)
|
||||
{
|
||||
// If there is an item contained, remove from container and send to mouse
|
||||
if (this.ContainedItem != null)
|
||||
{
|
||||
if (this.gameState.SelectedItem != null)
|
||||
{
|
||||
var switchItem = this.gameState.SelectedItem;
|
||||
|
||||
this.gameState.SelectItem(this.ContainedItem);
|
||||
this.SetContainedItem(switchItem);
|
||||
} else
|
||||
{
|
||||
this.gameState.SelectItem(this.ContainedItem);
|
||||
this.SetContainedItem(null);
|
||||
}
|
||||
|
||||
}
|
||||
else if (this.gameState.SelectedItem != null)
|
||||
{
|
||||
this.SetContainedItem(this.gameState.SelectedItem);
|
||||
this.gameState.SelectItem(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Render()
|
||||
{
|
||||
if (this.ContainedItem == null)
|
||||
{
|
||||
renderWindow.Draw(placeholderSprite, this.itemContainerLayout.BaseFrame);
|
||||
}
|
||||
else
|
||||
{
|
||||
renderWindow.Draw(sprite);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if(sprite != null)
|
||||
{
|
||||
sprite.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,9 +12,9 @@ namespace OpenDiablo2.GameServer_
|
||||
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private readonly IMobManager mobManager;
|
||||
private readonly IEngineDataManager engineDataManager;
|
||||
private readonly IItemManager itemManager;
|
||||
|
||||
private readonly IEngineDataManager engineDataManager;
|
||||
private readonly IItemManager itemManager;
|
||||
|
||||
public int Seed { get; private set; }
|
||||
public IEnumerable<PlayerState> Players => mobManager.Players;
|
||||
|
||||
@ -68,12 +68,12 @@ namespace OpenDiablo2.GameServer_
|
||||
|
||||
// This is probably not the right place to do this.
|
||||
// Only add items with a location set, the other ones go into the inventory - that we do not support yet
|
||||
foreach (var item in heroConfig.InitialEquipment)
|
||||
{
|
||||
if (item.location.Length > 0)
|
||||
{
|
||||
newPlayer.UpdateEquipment(item.location, itemManager.getItemInstance(item.name));
|
||||
}
|
||||
foreach (var item in heroConfig.InitialEquipment)
|
||||
{
|
||||
if (item.location.Length > 0)
|
||||
{
|
||||
newPlayer.UpdateEquipment(item.location, itemManager.getItemInstance(item.name));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,117 +1,117 @@
|
||||
/* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using OpenDiablo2.Common;
|
||||
using OpenDiablo2.Common.Attributes;
|
||||
using OpenDiablo2.Common.Enums;
|
||||
using OpenDiablo2.Common.Interfaces;
|
||||
using System;
|
||||
|
||||
namespace OpenDiablo2.Scenes
|
||||
{
|
||||
[Scene(eSceneType.Game)]
|
||||
public sealed class Game : IScene
|
||||
{
|
||||
private readonly IRenderWindow renderWindow;
|
||||
private readonly IMapEngine mapEngine;
|
||||
private readonly IMouseInfoProvider mouseInfoProvider;
|
||||
private readonly IGameState gameState;
|
||||
private readonly ISessionManager sessionManager;
|
||||
private readonly IGameHUD gameHUD;
|
||||
|
||||
private eMovementType lastMovementType = eMovementType.Stopped;
|
||||
private byte lastDirection = 255;
|
||||
|
||||
const double Rad2Deg = 180.0 / Math.PI;
|
||||
|
||||
public Game(
|
||||
IRenderWindow renderWindow,
|
||||
IMapEngine mapEngine,
|
||||
IGameState gameState,
|
||||
IMouseInfoProvider mouseInfoProvider,
|
||||
IItemManager itemManager,
|
||||
ISessionManager sessionManager,
|
||||
ISoundProvider soundProvider,
|
||||
IMPQProvider mpqProvider,
|
||||
IGameHUD gameHUD
|
||||
)
|
||||
{
|
||||
this.renderWindow = renderWindow;
|
||||
this.mapEngine = mapEngine;
|
||||
this.gameState = gameState;
|
||||
this.mouseInfoProvider = mouseInfoProvider;
|
||||
this.sessionManager = sessionManager;
|
||||
this.gameHUD = gameHUD;
|
||||
|
||||
//var item = itemManager.getItem("hdm");
|
||||
}
|
||||
|
||||
public void Render()
|
||||
{
|
||||
// TODO: Maybe show some sort of connecting/loading message?
|
||||
if (mapEngine.FocusedPlayerId == 0)
|
||||
return;
|
||||
|
||||
mapEngine.Render();
|
||||
gameHUD.Render();
|
||||
}
|
||||
|
||||
public void Update(long ms)
|
||||
{
|
||||
HandleMovement();
|
||||
|
||||
mapEngine.Update(ms);
|
||||
gameHUD.Update();
|
||||
}
|
||||
|
||||
private void HandleMovement()
|
||||
{
|
||||
// todo; if clicked on hud, then we don't move. But when clicked on map and move cursor over hud, then it's fine
|
||||
if (gameHUD.IsMouseOver())
|
||||
return;
|
||||
|
||||
var mx = mouseInfoProvider.MouseX - 400 - gameState.CameraOffset;
|
||||
var my = mouseInfoProvider.MouseY - 300;
|
||||
|
||||
var tx = (mx / 60f + my / 40f) / 2f;
|
||||
var ty = (my / 40f - (mx / 60f)) / 2f;
|
||||
var cursorDirection = (int)Math.Round(Math.Atan2(ty, tx) * Rad2Deg);
|
||||
if (cursorDirection < 0)
|
||||
cursorDirection += 360;
|
||||
var actualDirection = (byte)(cursorDirection / 22);
|
||||
if (actualDirection >= 16)
|
||||
actualDirection -= 16;
|
||||
|
||||
if (mouseInfoProvider.LeftMouseDown && (lastMovementType == eMovementType.Stopped || lastDirection != actualDirection))
|
||||
{
|
||||
lastDirection = actualDirection;
|
||||
lastMovementType = gameHUD.IsRunningEnabled ? eMovementType.Running : eMovementType.Walking;
|
||||
sessionManager.MoveRequest(actualDirection, lastMovementType);
|
||||
}
|
||||
else if (!mouseInfoProvider.LeftMouseDown && lastMovementType != eMovementType.Stopped)
|
||||
{
|
||||
lastDirection = actualDirection;
|
||||
lastMovementType = eMovementType.Stopped;
|
||||
sessionManager.MoveRequest(actualDirection, lastMovementType);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
/* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using OpenDiablo2.Common;
|
||||
using OpenDiablo2.Common.Attributes;
|
||||
using OpenDiablo2.Common.Enums;
|
||||
using OpenDiablo2.Common.Interfaces;
|
||||
using System;
|
||||
|
||||
namespace OpenDiablo2.Scenes
|
||||
{
|
||||
[Scene(eSceneType.Game)]
|
||||
public sealed class Game : IScene
|
||||
{
|
||||
private readonly IRenderWindow renderWindow;
|
||||
private readonly IMapEngine mapEngine;
|
||||
private readonly IMouseInfoProvider mouseInfoProvider;
|
||||
private readonly IGameState gameState;
|
||||
private readonly ISessionManager sessionManager;
|
||||
private readonly IGameHUD gameHUD;
|
||||
|
||||
private eMovementType lastMovementType = eMovementType.Stopped;
|
||||
private byte lastDirection = 255;
|
||||
|
||||
const double Rad2Deg = 180.0 / Math.PI;
|
||||
|
||||
public Game(
|
||||
IRenderWindow renderWindow,
|
||||
IMapEngine mapEngine,
|
||||
IGameState gameState,
|
||||
IMouseInfoProvider mouseInfoProvider,
|
||||
IItemManager itemManager,
|
||||
ISessionManager sessionManager,
|
||||
ISoundProvider soundProvider,
|
||||
IMPQProvider mpqProvider,
|
||||
IGameHUD gameHUD
|
||||
)
|
||||
{
|
||||
this.renderWindow = renderWindow;
|
||||
this.mapEngine = mapEngine;
|
||||
this.gameState = gameState;
|
||||
this.mouseInfoProvider = mouseInfoProvider;
|
||||
this.sessionManager = sessionManager;
|
||||
this.gameHUD = gameHUD;
|
||||
|
||||
//var item = itemManager.getItem("hdm");
|
||||
}
|
||||
|
||||
public void Render()
|
||||
{
|
||||
// TODO: Maybe show some sort of connecting/loading message?
|
||||
if (mapEngine.FocusedPlayerId == 0)
|
||||
return;
|
||||
|
||||
mapEngine.Render();
|
||||
gameHUD.Render();
|
||||
}
|
||||
|
||||
public void Update(long ms)
|
||||
{
|
||||
HandleMovement();
|
||||
|
||||
mapEngine.Update(ms);
|
||||
gameHUD.Update();
|
||||
}
|
||||
|
||||
private void HandleMovement()
|
||||
{
|
||||
// todo; if clicked on hud, then we don't move. But when clicked on map and move cursor over hud, then it's fine
|
||||
if (gameHUD.IsMouseOver())
|
||||
return;
|
||||
|
||||
var mx = mouseInfoProvider.MouseX - 400 - gameState.CameraOffset;
|
||||
var my = mouseInfoProvider.MouseY - 300;
|
||||
|
||||
var tx = (mx / 60f + my / 40f) / 2f;
|
||||
var ty = (my / 40f - (mx / 60f)) / 2f;
|
||||
var cursorDirection = (int)Math.Round(Math.Atan2(ty, tx) * Rad2Deg);
|
||||
if (cursorDirection < 0)
|
||||
cursorDirection += 360;
|
||||
var actualDirection = (byte)(cursorDirection / 22);
|
||||
if (actualDirection >= 16)
|
||||
actualDirection -= 16;
|
||||
|
||||
if (mouseInfoProvider.LeftMouseDown && (lastMovementType == eMovementType.Stopped || lastDirection != actualDirection))
|
||||
{
|
||||
lastDirection = actualDirection;
|
||||
lastMovementType = gameHUD.IsRunningEnabled ? eMovementType.Running : eMovementType.Walking;
|
||||
sessionManager.MoveRequest(actualDirection, lastMovementType);
|
||||
}
|
||||
else if (!mouseInfoProvider.LeftMouseDown && lastMovementType != eMovementType.Stopped)
|
||||
{
|
||||
lastDirection = actualDirection;
|
||||
lastMovementType = eMovementType.Stopped;
|
||||
sessionManager.MoveRequest(actualDirection, lastMovementType);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.Text;
|
||||
using OpenDiablo2.Common.Attributes;
|
||||
using OpenDiablo2.Common.Enums;
|
||||
@ -19,24 +19,24 @@ namespace OpenDiablo2.ServiceBus.Message_Frames.Client
|
||||
|
||||
public byte[] Data
|
||||
{
|
||||
get
|
||||
{
|
||||
using (var stream = new MemoryStream())
|
||||
using (var writer = new BinaryWriter(stream)) {
|
||||
writer.Write((byte)HeroType);
|
||||
writer.Write(PlayerName);
|
||||
|
||||
return stream.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
get
|
||||
{
|
||||
using (var stream = new MemoryStream())
|
||||
using (var writer = new BinaryWriter(stream)) {
|
||||
writer.Write((byte)HeroType);
|
||||
writer.Write(PlayerName);
|
||||
|
||||
return stream.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
using(var stream = new MemoryStream(value))
|
||||
using(var reader = new BinaryReader(stream))
|
||||
{
|
||||
HeroType = (eHero)reader.ReadByte();
|
||||
PlayerName = reader.ReadString();
|
||||
using(var reader = new BinaryReader(stream))
|
||||
{
|
||||
HeroType = (eHero)reader.ReadByte();
|
||||
PlayerName = reader.ReadString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user