mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2025-02-20 23:47:16 -05:00
Lots of minor code cleanup.
This commit is contained in:
parent
ebfcf5cf26
commit
bd6c5a7e0f
OpenDiablo2.Common/Models
OpenDiablo2.Core
OpenDiablo2.SDL2
CS-SDL
SDL2CharacterRenderer.csSDL2Extensions.csSDL2Font.csSDL2Label.csSDL2MouseCursor.csSDL2MusicPlayer.csSDL2RenderWindow.csSDL2Sprite.csSDL2Texture.csOpenDiablo2.Scenes
OpenDiablo2.ServiceBus
@ -8,7 +8,7 @@ namespace OpenDiablo2.Common.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal class BitStream
|
internal class BitStream
|
||||||
{
|
{
|
||||||
private Stream _baseStream;
|
private readonly Stream _baseStream;
|
||||||
private int _current;
|
private int _current;
|
||||||
private int _bitCount;
|
private int _bitCount;
|
||||||
|
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
using OpenDiablo2.Common.Enums;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using OpenDiablo2.Common.Enums;
|
||||||
|
|
||||||
namespace OpenDiablo2.Common.Models
|
namespace OpenDiablo2.Common.Models
|
||||||
{
|
{
|
||||||
public sealed class MPQ : IDisposable
|
public sealed class MPQ : IDisposable
|
||||||
{
|
{
|
||||||
private const string HEADER_SIGNATURE = "MPQ\x1A";
|
private const string HEADER_SIGNATURE = "MPQ\x1A";
|
||||||
private const string USERDATA_SIGNATURE = "MPQ\x1B";
|
//private const string USERDATA_SIGNATURE = "MPQ\x1B";
|
||||||
private const string LISTFILE_NAME = "(listfile)";
|
private const string LISTFILE_NAME = "(listfile)";
|
||||||
private const int MPQ_HASH_FILE_KEY = 3;
|
private const int MPQ_HASH_FILE_KEY = 3;
|
||||||
private const int MPQ_HASH_TABLE_OFFSET = 0;
|
private const int MPQ_HASH_TABLE_OFFSET = 0;
|
||||||
@ -34,7 +33,9 @@ namespace OpenDiablo2.Common.Models
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
|
#pragma warning disable IDE1006 // Naming Styles
|
||||||
internal enum eBlockRecordFlags : UInt32
|
internal enum eBlockRecordFlags : UInt32
|
||||||
|
#pragma warning restore IDE1006 // Naming Styles
|
||||||
{
|
{
|
||||||
IsFile = 0x80000000, // Block is a file, and follows the file data format; otherwise, block is free space or unused. If the block is not a file, all other flags should be cleared, and FileSize should be 0.
|
IsFile = 0x80000000, // Block is a file, and follows the file data format; otherwise, block is free space or unused. If the block is not a file, all other flags should be cleared, and FileSize should be 0.
|
||||||
SingleUnit = 0x01000000, // File is stored as a single unit, rather than split into sectors.
|
SingleUnit = 0x01000000, // File is stored as a single unit, rather than split into sectors.
|
||||||
@ -72,8 +73,8 @@ namespace OpenDiablo2.Common.Models
|
|||||||
|
|
||||||
internal static UInt32[] cryptTable = new UInt32[0x500];
|
internal static UInt32[] cryptTable = new UInt32[0x500];
|
||||||
internal HeaderRecord Header;
|
internal HeaderRecord Header;
|
||||||
private List<BlockRecord> blockTable = new List<BlockRecord>();
|
private readonly List<BlockRecord> blockTable = new List<BlockRecord>();
|
||||||
private List<HashRecord> hashTable = new List<HashRecord>();
|
private readonly List<HashRecord> hashTable = new List<HashRecord>();
|
||||||
internal Stream fileStream;
|
internal Stream fileStream;
|
||||||
|
|
||||||
public UInt16 LanguageId = 0;
|
public UInt16 LanguageId = 0;
|
||||||
@ -85,7 +86,7 @@ namespace OpenDiablo2.Common.Models
|
|||||||
|
|
||||||
private List<string> GetFilePaths()
|
private List<string> GetFilePaths()
|
||||||
{
|
{
|
||||||
using (var stream = OpenFile("(listfile)"))
|
using (var stream = OpenFile(LISTFILE_NAME))
|
||||||
{
|
{
|
||||||
if (stream == null)
|
if (stream == null)
|
||||||
{
|
{
|
||||||
@ -346,13 +347,10 @@ namespace OpenDiablo2.Common.Models
|
|||||||
|
|
||||||
public MPQStream OpenFile(string filename)
|
public MPQStream OpenFile(string filename)
|
||||||
{
|
{
|
||||||
HashRecord hash;
|
if (!GetHashRecord(filename, out HashRecord hash))
|
||||||
BlockRecord block;
|
|
||||||
|
|
||||||
if (!GetHashRecord(filename, out hash))
|
|
||||||
throw new FileNotFoundException("File not found: " + filename);
|
throw new FileNotFoundException("File not found: " + filename);
|
||||||
|
|
||||||
block = blockTable[(int)hash.FileBlockIndex];
|
BlockRecord block = blockTable[(int)hash.FileBlockIndex];
|
||||||
block.FileName = filename.ToLower();
|
block.FileName = filename.ToLower();
|
||||||
block.EncryptionSeed = CalculateEncryptionSeed(block);
|
block.EncryptionSeed = CalculateEncryptionSeed(block);
|
||||||
return new MPQStream(this, block);
|
return new MPQStream(this, block);
|
||||||
|
@ -55,10 +55,12 @@ namespace OpenDiablo2.Common.Models
|
|||||||
var layers = new List<COFLayer>();
|
var layers = new List<COFLayer>();
|
||||||
for (var layerIdx = 0; layerIdx < numLayers; layerIdx++)
|
for (var layerIdx = 0; layerIdx < numLayers; layerIdx++)
|
||||||
{
|
{
|
||||||
var layer = new COFLayer();
|
var layer = new COFLayer
|
||||||
layer.COF = result;
|
{
|
||||||
layer.CompositType = (eCompositType)br.ReadByte();
|
COF = result,
|
||||||
layer.Shadow = br.ReadByte();
|
CompositType = (eCompositType)br.ReadByte(),
|
||||||
|
Shadow = br.ReadByte()
|
||||||
|
};
|
||||||
br.ReadByte(); // Unknown
|
br.ReadByte(); // Unknown
|
||||||
layer.IsTransparent = br.ReadByte() != 0;
|
layer.IsTransparent = br.ReadByte() != 0;
|
||||||
layer.DrawEffect = (eDrawEffect)br.ReadByte();
|
layer.DrawEffect = (eDrawEffect)br.ReadByte();
|
||||||
|
@ -45,7 +45,7 @@ namespace OpenDiablo2.Common.Models
|
|||||||
public Int32 X2 { get; private set; }
|
public Int32 X2 { get; private set; }
|
||||||
public Int32 NumberOfTiles { get; private set; }
|
public Int32 NumberOfTiles { get; private set; }
|
||||||
public MPQDT1Tile[] Tiles { get; private set; }
|
public MPQDT1Tile[] Tiles { get; private set; }
|
||||||
private Int32 tileHeaderOffset;
|
private readonly Int32 tileHeaderOffset;
|
||||||
|
|
||||||
public MPQDT1(Stream stream)
|
public MPQDT1(Stream stream)
|
||||||
{
|
{
|
||||||
|
@ -297,8 +297,10 @@ namespace OpenDiablo2.Common.Models
|
|||||||
LinkedNode child1 = current.Prev;
|
LinkedNode child1 = current.Prev;
|
||||||
if (child1 == null) break;
|
if (child1 == null) break;
|
||||||
|
|
||||||
LinkedNode parent = new LinkedNode(0, child0.Weight + child1.Weight);
|
LinkedNode parent = new LinkedNode(0, child0.Weight + child1.Weight)
|
||||||
parent.Child0 = child0;
|
{
|
||||||
|
Child0 = child0
|
||||||
|
};
|
||||||
child0.Parent = parent;
|
child0.Parent = parent;
|
||||||
child1.Parent = parent;
|
child1.Parent = parent;
|
||||||
|
|
||||||
@ -313,11 +315,15 @@ namespace OpenDiablo2.Common.Models
|
|||||||
LinkedNode parent = tail;
|
LinkedNode parent = tail;
|
||||||
LinkedNode result = tail.Prev; // This will be the new tail after the tree is updated
|
LinkedNode result = tail.Prev; // This will be the new tail after the tree is updated
|
||||||
|
|
||||||
LinkedNode temp = new LinkedNode(parent.DecompressedValue, parent.Weight);
|
LinkedNode temp = new LinkedNode(parent.DecompressedValue, parent.Weight)
|
||||||
temp.Parent = parent;
|
{
|
||||||
|
Parent = parent
|
||||||
|
};
|
||||||
|
|
||||||
LinkedNode newnode = new LinkedNode(decomp, 0);
|
LinkedNode newnode = new LinkedNode(decomp, 0)
|
||||||
newnode.Parent = parent;
|
{
|
||||||
|
Parent = parent
|
||||||
|
};
|
||||||
|
|
||||||
parent.Child0 = newnode;
|
parent.Child0 = newnode;
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ namespace OpenDiablo2.Common.Models
|
|||||||
private long position;
|
private long position;
|
||||||
private byte[] _currentData;
|
private byte[] _currentData;
|
||||||
private int _currentBlockIndex = -1;
|
private int _currentBlockIndex = -1;
|
||||||
private int blockSize;
|
private readonly int blockSize;
|
||||||
|
|
||||||
internal MPQStream(MPQ mpq, BlockRecord blockRecord)
|
internal MPQStream(MPQ mpq, BlockRecord blockRecord)
|
||||||
{
|
{
|
||||||
|
@ -10,7 +10,7 @@ namespace OpenDiablo2.Common.Models.Mobs
|
|||||||
{
|
{
|
||||||
public class LevelExperienceConfig : ILevelExperienceConfig
|
public class LevelExperienceConfig : ILevelExperienceConfig
|
||||||
{
|
{
|
||||||
private List<long> ExperiencePerLevel = new List<long>();
|
private readonly List<long> ExperiencePerLevel = new List<long>();
|
||||||
|
|
||||||
public LevelExperienceConfig(List<long> expperlevel)
|
public LevelExperienceConfig(List<long> expperlevel)
|
||||||
{
|
{
|
||||||
@ -42,8 +42,7 @@ namespace OpenDiablo2.Common.Models.Mobs
|
|||||||
// i starts at 1 because we want to skip the first column
|
// i starts at 1 because we want to skip the first column
|
||||||
// the first column is just the row titles
|
// the first column is just the row titles
|
||||||
string heroname = data[i][0]; // first row is the hero name
|
string heroname = data[i][0]; // first row is the hero name
|
||||||
eHero herotype = default(eHero);
|
if (!Enum.TryParse<eHero>(heroname, out eHero herotype))
|
||||||
if(!Enum.TryParse<eHero>(heroname, out herotype))
|
|
||||||
{
|
{
|
||||||
continue; // skip this hero if we can't parse the name into a valid hero type
|
continue; // skip this hero if we can't parse the name into a valid hero type
|
||||||
}
|
}
|
||||||
@ -56,8 +55,7 @@ namespace OpenDiablo2.Common.Models.Mobs
|
|||||||
List<long> expperlevel = new List<long>();
|
List<long> expperlevel = new List<long>();
|
||||||
for (int o = 2; o < data.Length && (o-2 < maxlevel || maxlevel == -1); o++)
|
for (int o = 2; o < data.Length && (o-2 < maxlevel || maxlevel == -1); o++)
|
||||||
{
|
{
|
||||||
long exp = 0;
|
if (!long.TryParse(data[o][i], out long exp))
|
||||||
if(!long.TryParse(data[o][i], out exp))
|
|
||||||
{
|
{
|
||||||
throw new Exception("Could not parse experience number '" + data[o][i] + "'.");
|
throw new Exception("Could not parse experience number '" + data[o][i] + "'.");
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,8 @@ namespace OpenDiablo2.Common.Models.Mobs
|
|||||||
{
|
{
|
||||||
public Guid UID { get; protected set; } = Guid.NewGuid();
|
public Guid UID { get; protected set; } = Guid.NewGuid();
|
||||||
public eHero HeroType { get; protected set; }
|
public eHero HeroType { get; protected set; }
|
||||||
private IHeroTypeConfig HeroTypeConfig;
|
private readonly IHeroTypeConfig HeroTypeConfig;
|
||||||
private ILevelExperienceConfig ExperienceConfig;
|
private readonly ILevelExperienceConfig ExperienceConfig;
|
||||||
public int ClientHash { get; protected set; }
|
public int ClientHash { get; protected set; }
|
||||||
public byte MovementDirection { get; set; } = 0;
|
public byte MovementDirection { get; set; } = 0;
|
||||||
public eMovementType MovementType { get; set; } = eMovementType.Stopped; // TODO: This needs to mess with MobMode somehow
|
public eMovementType MovementType { get; set; } = eMovementType.Stopped; // TODO: This needs to mess with MobMode somehow
|
||||||
|
@ -41,12 +41,12 @@ namespace OpenDiablo2.Common.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class PKLibDecompress
|
public class PKLibDecompress
|
||||||
{
|
{
|
||||||
private BitStream _bitstream;
|
private readonly BitStream _bitstream;
|
||||||
private CompressionType _compressionType;
|
private readonly CompressionType _compressionType;
|
||||||
private int _dictSizeBits; // Dictionary size in bits
|
private readonly int _dictSizeBits; // Dictionary size in bits
|
||||||
|
|
||||||
private static byte[] sPosition1;
|
private static readonly byte[] sPosition1;
|
||||||
private static byte[] sPosition2;
|
private static readonly byte[] sPosition2;
|
||||||
|
|
||||||
private static readonly byte[] sLenBits =
|
private static readonly byte[] sLenBits =
|
||||||
{
|
{
|
||||||
|
@ -33,11 +33,13 @@ namespace OpenDiablo2.Common.Models
|
|||||||
|
|
||||||
public static PlayerInfo FromBytes(byte[] data, int offset = 0)
|
public static PlayerInfo FromBytes(byte[] data, int offset = 0)
|
||||||
{
|
{
|
||||||
var result = new PlayerInfo();
|
var result = new PlayerInfo
|
||||||
result.Hero = (eHero)data[offset];
|
{
|
||||||
result.WeaponClass= (eWeaponClass)data[offset + 1];
|
Hero = (eHero)data[offset],
|
||||||
result.ArmorType = (eArmorType)data[offset + 2];
|
WeaponClass = (eWeaponClass)data[offset + 1],
|
||||||
result.MobMode = (eMobMode)data[offset + 3];
|
ArmorType = (eArmorType)data[offset + 2],
|
||||||
|
MobMode = (eMobMode)data[offset + 3]
|
||||||
|
};
|
||||||
var nameLength = BitConverter.ToInt32(data, offset + 4);
|
var nameLength = BitConverter.ToInt32(data, offset + 4);
|
||||||
result.Name = Encoding.UTF8.GetString(data, offset + 8, nameLength);
|
result.Name = Encoding.UTF8.GetString(data, offset + 8, nameLength);
|
||||||
result.LocationDetails = PlayerLocationDetails.FromBytes(data, offset + 8 + nameLength);
|
result.LocationDetails = PlayerLocationDetails.FromBytes(data, offset + 8 + nameLength);
|
||||||
|
@ -14,7 +14,6 @@ namespace OpenDiablo2.Core
|
|||||||
{
|
{
|
||||||
static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
private readonly GlobalConfiguration globalConfig;
|
|
||||||
private readonly IMPQProvider mpqProvider;
|
private readonly IMPQProvider mpqProvider;
|
||||||
private readonly Func<IRenderWindow> getRenderWindow;
|
private readonly Func<IRenderWindow> getRenderWindow;
|
||||||
private readonly Func<eSceneType, IScene> getScene;
|
private readonly Func<eSceneType, IScene> getScene;
|
||||||
@ -27,11 +26,10 @@ namespace OpenDiablo2.Core
|
|||||||
|
|
||||||
private readonly MPQ[] MPQs;
|
private readonly MPQ[] MPQs;
|
||||||
|
|
||||||
private Dictionary<string, SoundEntry> soundTable = new Dictionary<string, SoundEntry>();
|
private readonly Dictionary<string, SoundEntry> soundTable = new Dictionary<string, SoundEntry>();
|
||||||
public Dictionary<string, Palette> PaletteTable { get; private set; } = new Dictionary<string, Palette>();
|
public Dictionary<string, Palette> PaletteTable { get; private set; } = new Dictionary<string, Palette>();
|
||||||
|
|
||||||
public GameEngine(
|
public GameEngine(
|
||||||
GlobalConfiguration globalConfig,
|
|
||||||
IMPQProvider mpqProvider,
|
IMPQProvider mpqProvider,
|
||||||
Func<IRenderWindow> getRenderWindow,
|
Func<IRenderWindow> getRenderWindow,
|
||||||
Func<eSceneType, IScene> getScene,
|
Func<eSceneType, IScene> getScene,
|
||||||
@ -39,7 +37,6 @@ namespace OpenDiablo2.Core
|
|||||||
Func<IGameState> getGameState
|
Func<IGameState> getGameState
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.globalConfig = globalConfig;
|
|
||||||
this.mpqProvider = mpqProvider;
|
this.mpqProvider = mpqProvider;
|
||||||
this.getRenderWindow = getRenderWindow;
|
this.getRenderWindow = getRenderWindow;
|
||||||
this.getScene = getScene;
|
this.getScene = getScene;
|
||||||
|
@ -24,7 +24,7 @@ namespace OpenDiablo2.Core.GameState_
|
|||||||
|
|
||||||
private float animationTime = 0f;
|
private float animationTime = 0f;
|
||||||
private List<MapInfo> mapInfo;
|
private List<MapInfo> mapInfo;
|
||||||
private List<MapCellInfo> mapDataLookup = new List<MapCellInfo>();
|
private readonly List<MapCellInfo> mapDataLookup = new List<MapCellInfo>();
|
||||||
private ISessionManager sessionManager;
|
private ISessionManager sessionManager;
|
||||||
|
|
||||||
public int Act { get; private set; }
|
public int Act { get; private set; }
|
||||||
|
@ -15,7 +15,7 @@ namespace OpenDiablo2.Core.GameState_
|
|||||||
IEnumerable<PlayerState> IMobManager.Players => Players;
|
IEnumerable<PlayerState> IMobManager.Players => Players;
|
||||||
IEnumerable<EnemyState> IMobManager.Enemies => Enemies;
|
IEnumerable<EnemyState> IMobManager.Enemies => Enemies;
|
||||||
|
|
||||||
private HashSet<int> IdsUsed = new HashSet<int>();
|
private readonly HashSet<int> IdsUsed = new HashSet<int>();
|
||||||
|
|
||||||
#region Player Controls
|
#region Player Controls
|
||||||
public void AddPlayer(PlayerState player)
|
public void AddPlayer(PlayerState player)
|
||||||
|
@ -11,7 +11,7 @@ namespace OpenDiablo2.Core
|
|||||||
{
|
{
|
||||||
public sealed class ItemManager : IItemManager
|
public sealed class ItemManager : IItemManager
|
||||||
{
|
{
|
||||||
private IEngineDataManager engineDataManager;
|
private readonly IEngineDataManager engineDataManager;
|
||||||
|
|
||||||
public ItemManager(IEngineDataManager engineDataManager)
|
public ItemManager(IEngineDataManager engineDataManager)
|
||||||
{
|
{
|
||||||
|
@ -11,18 +11,13 @@ namespace OpenDiablo2.Core
|
|||||||
{
|
{
|
||||||
public sealed class MPQProvider : IMPQProvider
|
public sealed class MPQProvider : IMPQProvider
|
||||||
{
|
{
|
||||||
private readonly GlobalConfiguration globalConfiguration;
|
|
||||||
private readonly MPQ[] mpqs;
|
private readonly MPQ[] mpqs;
|
||||||
private Dictionary<string, int> mpqLookup = new Dictionary<string, int>();
|
private readonly Dictionary<string, int> mpqLookup = new Dictionary<string, int>();
|
||||||
|
|
||||||
public MPQProvider(GlobalConfiguration globalConfiguration)
|
public MPQProvider(GlobalConfiguration globalConfiguration)
|
||||||
{
|
{
|
||||||
this.globalConfiguration = globalConfiguration;
|
|
||||||
// TODO: Make this less dumb. We need to an external file to configure mpq load order.
|
// TODO: Make this less dumb. We need to an external file to configure mpq load order.
|
||||||
var mpqsToLoad = new string[]
|
|
||||||
{
|
|
||||||
|
|
||||||
};
|
|
||||||
this.mpqs = Directory
|
this.mpqs = Directory
|
||||||
.EnumerateFiles(globalConfiguration.BaseDataPath, "*.mpq")
|
.EnumerateFiles(globalConfiguration.BaseDataPath, "*.mpq")
|
||||||
.Where(x => !Path.GetFileName(x).StartsWith("patch"))
|
.Where(x => !Path.GetFileName(x).StartsWith("patch"))
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenDiablo2.Common;
|
|
||||||
using OpenDiablo2.Common.Enums;
|
using OpenDiablo2.Common.Enums;
|
||||||
using OpenDiablo2.Common.Interfaces;
|
using OpenDiablo2.Common.Interfaces;
|
||||||
using OpenDiablo2.Common.Interfaces.Drawing;
|
using OpenDiablo2.Common.Interfaces.Drawing;
|
||||||
@ -14,10 +13,8 @@ namespace OpenDiablo2.Core.Map_Engine
|
|||||||
{
|
{
|
||||||
private readonly IGameState gameState;
|
private readonly IGameState gameState;
|
||||||
private readonly IRenderWindow renderWindow;
|
private readonly IRenderWindow renderWindow;
|
||||||
private readonly IResourceManager resourceManager;
|
|
||||||
private readonly ISessionManager sessionManager;
|
|
||||||
|
|
||||||
private List<ICharacterRenderer> characterRenderers = new List<ICharacterRenderer>();
|
private readonly List<ICharacterRenderer> characterRenderers = new List<ICharacterRenderer>();
|
||||||
|
|
||||||
public int FocusedPlayerId { get; set; } = 0;
|
public int FocusedPlayerId { get; set; } = 0;
|
||||||
|
|
||||||
@ -31,33 +28,24 @@ namespace OpenDiablo2.Core.Map_Engine
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
cameraLocation = value;
|
cameraLocation = value;
|
||||||
cOffX = (int)((cameraLocation.X - cameraLocation.Y) * (cellSizeX / 2));
|
//cOffX = (int)((cameraLocation.X - cameraLocation.Y) * (cellSizeX / 2));
|
||||||
cOffY = (int)((cameraLocation.X + cameraLocation.Y) * (cellSizeY / 2));
|
//cOffY = (int)((cameraLocation.X + cameraLocation.Y) * (cellSizeY / 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ISprite loadingSprite;
|
|
||||||
private int cOffX, cOffY;
|
|
||||||
|
|
||||||
private const int
|
private const int
|
||||||
cellSizeX = 160,
|
cellSizeX = 160,
|
||||||
cellSizeY = 80,
|
cellSizeY = 80;
|
||||||
renderCellsX = (800 / cellSizeX),
|
|
||||||
renderCellsY = (600 / cellSizeY);
|
|
||||||
|
|
||||||
public MapEngine(
|
public MapEngine(
|
||||||
IGameState gameState,
|
IGameState gameState,
|
||||||
IRenderWindow renderWindow,
|
IRenderWindow renderWindow,
|
||||||
IResourceManager resourceManager,
|
|
||||||
ISessionManager sessionManager
|
ISessionManager sessionManager
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.gameState = gameState;
|
this.gameState = gameState;
|
||||||
this.renderWindow = renderWindow;
|
this.renderWindow = renderWindow;
|
||||||
this.resourceManager = resourceManager;
|
|
||||||
this.sessionManager = sessionManager;
|
|
||||||
|
|
||||||
loadingSprite = renderWindow.LoadSprite(ResourcePaths.LoadingScreen, Palettes.Loading, new Point(300, 400));
|
|
||||||
sessionManager.OnPlayerInfo += OnPlayerInfo;
|
sessionManager.OnPlayerInfo += OnPlayerInfo;
|
||||||
sessionManager.OnLocatePlayers += OnLocatePlayers;
|
sessionManager.OnLocatePlayers += OnLocatePlayers;
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,11 @@ namespace OpenDiablo2.Core
|
|||||||
private readonly IMPQProvider mpqProvider;
|
private readonly IMPQProvider mpqProvider;
|
||||||
private readonly IEngineDataManager engineDataManager;
|
private readonly IEngineDataManager engineDataManager;
|
||||||
|
|
||||||
private Dictionary<string, ImageSet> ImageSets = new Dictionary<string, ImageSet>();
|
private readonly Dictionary<string, ImageSet> ImageSets = new Dictionary<string, ImageSet>();
|
||||||
private Dictionary<string, MPQFont> MPQFonts = new Dictionary<string, MPQFont>();
|
private readonly Dictionary<string, MPQFont> MPQFonts = new Dictionary<string, MPQFont>();
|
||||||
private Dictionary<string, Palette> Palettes = new Dictionary<string, Palette>();
|
private readonly Dictionary<string, Palette> Palettes = new Dictionary<string, Palette>();
|
||||||
private Dictionary<string, MPQDT1> DTs = new Dictionary<string, MPQDT1>();
|
private readonly Dictionary<string, MPQDT1> DTs = new Dictionary<string, MPQDT1>();
|
||||||
private Dictionary<string, MPQCOF> PlayerCOFs = new Dictionary<string, MPQCOF>();
|
private readonly Dictionary<string, MPQCOF> PlayerCOFs = new Dictionary<string, MPQCOF>();
|
||||||
|
|
||||||
public Dictionary<string, List<AnimationData>> Animations { get; private set; } = new Dictionary<string, List<AnimationData>>();
|
public Dictionary<string, List<AnimationData>> Animations { get; private set; } = new Dictionary<string, List<AnimationData>>();
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ namespace OpenDiablo2.Core
|
|||||||
{
|
{
|
||||||
private readonly IMPQProvider mpqProvider;
|
private readonly IMPQProvider mpqProvider;
|
||||||
|
|
||||||
private Dictionary<string, string> lookupTable = new Dictionary<string, string>();
|
private readonly Dictionary<string, string> lookupTable = new Dictionary<string, string>();
|
||||||
|
|
||||||
public TextDictionary(IMPQProvider mpqProvider)
|
public TextDictionary(IMPQProvider mpqProvider)
|
||||||
{
|
{
|
||||||
|
@ -32,10 +32,11 @@ namespace OpenDiablo2.Core.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int buttonWidth, buttonHeight;
|
private readonly int buttonWidth;
|
||||||
private ISprite sprite;
|
private readonly int buttonHeight;
|
||||||
private IFont font;
|
private readonly ISprite sprite;
|
||||||
private ILabel label;
|
private readonly IFont font;
|
||||||
|
private readonly ILabel label;
|
||||||
private bool pressed = false;
|
private bool pressed = false;
|
||||||
private bool active = false; // When true, button is actively being focus pressed
|
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
|
private bool activeLock = false; // When true, we have locked the mouse from everything else
|
||||||
|
@ -9,7 +9,7 @@ namespace OpenDiablo2.Core.UI
|
|||||||
public sealed class CharacterPanel : ICharacterPanel
|
public sealed class CharacterPanel : ICharacterPanel
|
||||||
{
|
{
|
||||||
private readonly IRenderWindow renderWindow;
|
private readonly IRenderWindow renderWindow;
|
||||||
private ISprite sprite;
|
private readonly ISprite sprite;
|
||||||
|
|
||||||
public Point Location { get; set; }
|
public Point Location { get; set; }
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ namespace OpenDiablo2.Core.UI
|
|||||||
public sealed class InventoryPanel : IInventoryPanel
|
public sealed class InventoryPanel : IInventoryPanel
|
||||||
{
|
{
|
||||||
private readonly IRenderWindow renderWindow;
|
private readonly IRenderWindow renderWindow;
|
||||||
private ISprite sprite;
|
private readonly ISprite sprite;
|
||||||
private Point location;
|
private Point location;
|
||||||
|
|
||||||
public Point Location {
|
public Point Location {
|
||||||
@ -30,9 +30,9 @@ namespace OpenDiablo2.Core.UI
|
|||||||
// Test vars
|
// Test vars
|
||||||
public IItemContainer helmContainer, armorContainer, weaponLeftContainer, weaponRightContainer, beltContainer, gloveContainer, bootsContainer;
|
public IItemContainer helmContainer, armorContainer, weaponLeftContainer, weaponRightContainer, beltContainer, gloveContainer, bootsContainer;
|
||||||
private Point previouslyContainedItem;
|
private Point previouslyContainedItem;
|
||||||
private IItemContainer ringtLeftContainer;
|
private readonly IItemContainer ringtLeftContainer;
|
||||||
private IItemContainer ringtRightContainer;
|
private readonly IItemContainer ringtRightContainer;
|
||||||
private IItemContainer amuletContainer;
|
private readonly IItemContainer amuletContainer;
|
||||||
|
|
||||||
public InventoryPanel(IRenderWindow renderWindow, IItemManager itemManager, Func<eItemContainerType, IItemContainer> createItemContainer)
|
public InventoryPanel(IRenderWindow renderWindow, IItemManager itemManager, Func<eItemContainerType, IItemContainer> createItemContainer)
|
||||||
{
|
{
|
||||||
|
@ -1,115 +1,114 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
using System.Drawing;
|
||||||
using System.Drawing;
|
using OpenDiablo2.Common;
|
||||||
using OpenDiablo2.Common;
|
using OpenDiablo2.Common.Enums;
|
||||||
using OpenDiablo2.Common.Enums;
|
using OpenDiablo2.Common.Interfaces;
|
||||||
using OpenDiablo2.Common.Interfaces;
|
using OpenDiablo2.Common.Models;
|
||||||
using OpenDiablo2.Common.Models;
|
|
||||||
|
namespace OpenDiablo2.Core.UI
|
||||||
namespace OpenDiablo2.Core.UI
|
{
|
||||||
{
|
// TODO: Self-align when side panels are open
|
||||||
// TODO: Self-align when side panels are open
|
public sealed class ItemContainer : IItemContainer
|
||||||
public sealed class ItemContainer : IItemContainer
|
{
|
||||||
{
|
private readonly IRenderWindow renderWindow;
|
||||||
private readonly IRenderWindow renderWindow;
|
private readonly IGameState gameState;
|
||||||
private readonly IGameState gameState;
|
private ISprite sprite;
|
||||||
private ISprite sprite;
|
|
||||||
|
private readonly ItemContainerLayout itemContainerLayout;
|
||||||
private ItemContainerLayout itemContainerLayout;
|
private readonly IMouseInfoProvider mouseInfoProvider;
|
||||||
private IMouseInfoProvider mouseInfoProvider;
|
|
||||||
|
public Item ContainedItem { get; internal set; }
|
||||||
public Item ContainedItem { get; internal set; }
|
|
||||||
|
private readonly Dictionary<eItemContainerType, ISprite> sprites = new Dictionary<eItemContainerType, ISprite>();
|
||||||
private Dictionary<eItemContainerType, ISprite> sprites = new Dictionary<eItemContainerType, ISprite>();
|
|
||||||
|
private Point location = new Point();
|
||||||
private Point location = new Point();
|
|
||||||
|
public Point Location
|
||||||
public Point Location
|
{
|
||||||
{
|
get => location;
|
||||||
get => location;
|
set
|
||||||
set
|
{
|
||||||
{
|
if (location == value)
|
||||||
if (location == value)
|
return;
|
||||||
return;
|
location = value;
|
||||||
location = value;
|
|
||||||
|
placeholderSprite.Location = new Point(value.X, value.Y + placeholderSprite.LocalFrameSize.Height);
|
||||||
placeholderSprite.Location = new Point(value.X, value.Y + placeholderSprite.LocalFrameSize.Height);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
private readonly ISprite placeholderSprite;
|
||||||
private ISprite placeholderSprite;
|
|
||||||
|
public Size Size { get; internal set; }
|
||||||
public Size Size { get; internal set; }
|
|
||||||
|
public ItemContainer(IRenderWindow renderWindow, IGameState gameState, ItemContainerLayout itemContainerLayout, IMouseInfoProvider mouseInfoProvider)
|
||||||
public ItemContainer(IRenderWindow renderWindow, IGameState gameState, ItemContainerLayout itemContainerLayout, IMouseInfoProvider mouseInfoProvider)
|
{
|
||||||
{
|
this.renderWindow = renderWindow;
|
||||||
this.renderWindow = renderWindow;
|
this.gameState = gameState;
|
||||||
this.gameState = gameState;
|
this.itemContainerLayout = itemContainerLayout;
|
||||||
this.itemContainerLayout = itemContainerLayout;
|
this.mouseInfoProvider = mouseInfoProvider;
|
||||||
this.mouseInfoProvider = mouseInfoProvider;
|
|
||||||
|
placeholderSprite = renderWindow.LoadSprite(itemContainerLayout.ResourceName, itemContainerLayout.PaletteName);
|
||||||
placeholderSprite = renderWindow.LoadSprite(itemContainerLayout.ResourceName, itemContainerLayout.PaletteName);
|
placeholderSprite.Location = new Point(location.X, location.Y + placeholderSprite.LocalFrameSize.Height);
|
||||||
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.
|
||||||
this.Size = placeholderSprite.FrameSize; // For all but generic size is equal to the placeholder size. Source: me.
|
}
|
||||||
}
|
|
||||||
|
public void SetContainedItem(Item containedItem)
|
||||||
public void SetContainedItem(Item containedItem)
|
{
|
||||||
{
|
ContainedItem = containedItem;
|
||||||
ContainedItem = containedItem;
|
|
||||||
|
if (ContainedItem != null)
|
||||||
if (ContainedItem != null)
|
{
|
||||||
{
|
sprite = renderWindow.LoadSprite(ResourcePaths.GeneratePathForItem(this.ContainedItem.InvFile), Palettes.Units);
|
||||||
sprite = renderWindow.LoadSprite(ResourcePaths.GeneratePathForItem(this.ContainedItem.InvFile), Palettes.Units);
|
sprite.Location = new Point(location.X, location.Y + sprite.LocalFrameSize.Height);
|
||||||
sprite.Location = new Point(location.X, location.Y + sprite.LocalFrameSize.Height);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public void Update()
|
||||||
public void Update()
|
{
|
||||||
{
|
|
||||||
var hovered = (mouseInfoProvider.MouseX >= location.X && mouseInfoProvider.MouseX < (location.X + this.Size.Width))
|
var hovered = (mouseInfoProvider.MouseX >= location.X && mouseInfoProvider.MouseX < (location.X + this.Size.Width))
|
||||||
&& (mouseInfoProvider.MouseY >= location.Y && mouseInfoProvider.MouseY < (location.Y + this.Size.Height));
|
&& (mouseInfoProvider.MouseY >= location.Y && mouseInfoProvider.MouseY < (location.Y + this.Size.Height));
|
||||||
|
|
||||||
if (hovered && mouseInfoProvider.LeftMousePressed)
|
if (hovered && mouseInfoProvider.LeftMousePressed)
|
||||||
{
|
{
|
||||||
// If there is an item contained, remove from container and send to mouse
|
// If there is an item contained, remove from container and send to mouse
|
||||||
if (this.ContainedItem != null)
|
if (this.ContainedItem != null)
|
||||||
{
|
{
|
||||||
if (this.gameState.SelectedItem != null)
|
if (this.gameState.SelectedItem != null)
|
||||||
{
|
{
|
||||||
var switchItem = this.gameState.SelectedItem;
|
var switchItem = this.gameState.SelectedItem;
|
||||||
|
|
||||||
this.gameState.SelectItem(this.ContainedItem);
|
this.gameState.SelectItem(this.ContainedItem);
|
||||||
this.SetContainedItem(switchItem);
|
this.SetContainedItem(switchItem);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
this.gameState.SelectItem(this.ContainedItem);
|
this.gameState.SelectItem(this.ContainedItem);
|
||||||
this.SetContainedItem(null);
|
this.SetContainedItem(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (this.gameState.SelectedItem != null)
|
else if (this.gameState.SelectedItem != null)
|
||||||
{
|
{
|
||||||
this.SetContainedItem(this.gameState.SelectedItem);
|
this.SetContainedItem(this.gameState.SelectedItem);
|
||||||
this.gameState.SelectItem(null);
|
this.gameState.SelectItem(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Render()
|
public void Render()
|
||||||
{
|
{
|
||||||
if (this.ContainedItem == null)
|
if (this.ContainedItem == null)
|
||||||
{
|
{
|
||||||
renderWindow.Draw(placeholderSprite, this.itemContainerLayout.BaseFrame);
|
renderWindow.Draw(placeholderSprite, this.itemContainerLayout.BaseFrame);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
renderWindow.Draw(sprite);
|
renderWindow.Draw(sprite);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
sprite.Dispose();
|
sprite.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,8 @@ namespace OpenDiablo2.Core.UI
|
|||||||
public sealed class PanelFrame : IPanelFrame
|
public sealed class PanelFrame : IPanelFrame
|
||||||
{
|
{
|
||||||
private readonly IRenderWindow renderWindow;
|
private readonly IRenderWindow renderWindow;
|
||||||
private ISprite sprite;
|
private readonly ISprite sprite;
|
||||||
private ePanelFrameType panelFrameType;
|
private readonly ePanelFrameType panelFrameType;
|
||||||
|
|
||||||
public Point Location { get; set; }
|
public Point Location { get; set; }
|
||||||
|
|
||||||
|
@ -12,9 +12,9 @@ namespace OpenDiablo2.Core.UI
|
|||||||
public sealed class TextBox : ITextBox
|
public sealed class TextBox : ITextBox
|
||||||
{
|
{
|
||||||
private readonly IRenderWindow renderWindow;
|
private readonly IRenderWindow renderWindow;
|
||||||
private ISprite sprite;
|
private readonly ISprite sprite;
|
||||||
private IFont font;
|
private readonly IFont font;
|
||||||
private ILabel label, linebar;
|
private readonly ILabel label, linebar;
|
||||||
private float frameTime = 0f;
|
private float frameTime = 0f;
|
||||||
|
|
||||||
private Point location = new Point();
|
private Point location = new Point();
|
||||||
|
@ -3665,9 +3665,9 @@ namespace SDL2
|
|||||||
public UInt32 timestamp;
|
public UInt32 timestamp;
|
||||||
public UInt32 display;
|
public UInt32 display;
|
||||||
public SDL_DisplayEventID displayEvent; // event, lolC#
|
public SDL_DisplayEventID displayEvent; // event, lolC#
|
||||||
private byte padding1;
|
private readonly byte padding1;
|
||||||
private byte padding2;
|
private readonly byte padding2;
|
||||||
private byte padding3;
|
private readonly byte padding3;
|
||||||
public Int32 data1;
|
public Int32 data1;
|
||||||
}
|
}
|
||||||
#pragma warning restore 0169
|
#pragma warning restore 0169
|
||||||
@ -3682,9 +3682,9 @@ namespace SDL2
|
|||||||
public UInt32 timestamp;
|
public UInt32 timestamp;
|
||||||
public UInt32 windowID;
|
public UInt32 windowID;
|
||||||
public SDL_WindowEventID windowEvent; // event, lolC#
|
public SDL_WindowEventID windowEvent; // event, lolC#
|
||||||
private byte padding1;
|
private readonly byte padding1;
|
||||||
private byte padding2;
|
private readonly byte padding2;
|
||||||
private byte padding3;
|
private readonly byte padding3;
|
||||||
public Int32 data1;
|
public Int32 data1;
|
||||||
public Int32 data2;
|
public Int32 data2;
|
||||||
}
|
}
|
||||||
@ -3701,8 +3701,8 @@ namespace SDL2
|
|||||||
public UInt32 windowID;
|
public UInt32 windowID;
|
||||||
public byte state;
|
public byte state;
|
||||||
public byte repeat; /* non-zero if this is a repeat */
|
public byte repeat; /* non-zero if this is a repeat */
|
||||||
private byte padding2;
|
private readonly byte padding2;
|
||||||
private byte padding3;
|
private readonly byte padding3;
|
||||||
public SDL_Keysym keysym;
|
public SDL_Keysym keysym;
|
||||||
}
|
}
|
||||||
#pragma warning restore 0169
|
#pragma warning restore 0169
|
||||||
@ -3738,9 +3738,9 @@ namespace SDL2
|
|||||||
public UInt32 windowID;
|
public UInt32 windowID;
|
||||||
public UInt32 which;
|
public UInt32 which;
|
||||||
public byte state; /* bitmask of buttons */
|
public byte state; /* bitmask of buttons */
|
||||||
private byte padding1;
|
private readonly byte padding1;
|
||||||
private byte padding2;
|
private readonly byte padding2;
|
||||||
private byte padding3;
|
private readonly byte padding3;
|
||||||
public Int32 x;
|
public Int32 x;
|
||||||
public Int32 y;
|
public Int32 y;
|
||||||
public Int32 xrel;
|
public Int32 xrel;
|
||||||
@ -3761,7 +3761,7 @@ namespace SDL2
|
|||||||
public byte button; /* button id */
|
public byte button; /* button id */
|
||||||
public byte state; /* SDL_PRESSED or SDL_RELEASED */
|
public byte state; /* SDL_PRESSED or SDL_RELEASED */
|
||||||
public byte clicks; /* 1 for single-click, 2 for double-click, etc. */
|
public byte clicks; /* 1 for single-click, 2 for double-click, etc. */
|
||||||
private byte padding1;
|
private readonly byte padding1;
|
||||||
public Int32 x;
|
public Int32 x;
|
||||||
public Int32 y;
|
public Int32 y;
|
||||||
}
|
}
|
||||||
@ -3790,9 +3790,9 @@ namespace SDL2
|
|||||||
public UInt32 timestamp;
|
public UInt32 timestamp;
|
||||||
public Int32 which; /* SDL_JoystickID */
|
public Int32 which; /* SDL_JoystickID */
|
||||||
public byte axis;
|
public byte axis;
|
||||||
private byte padding1;
|
private readonly byte padding1;
|
||||||
private byte padding2;
|
private readonly byte padding2;
|
||||||
private byte padding3;
|
private readonly byte padding3;
|
||||||
public Int16 axisValue; /* value, lolC# */
|
public Int16 axisValue; /* value, lolC# */
|
||||||
public UInt16 padding4;
|
public UInt16 padding4;
|
||||||
}
|
}
|
||||||
@ -3808,9 +3808,9 @@ namespace SDL2
|
|||||||
public UInt32 timestamp;
|
public UInt32 timestamp;
|
||||||
public Int32 which; /* SDL_JoystickID */
|
public Int32 which; /* SDL_JoystickID */
|
||||||
public byte ball;
|
public byte ball;
|
||||||
private byte padding1;
|
private readonly byte padding1;
|
||||||
private byte padding2;
|
private readonly byte padding2;
|
||||||
private byte padding3;
|
private readonly byte padding3;
|
||||||
public Int16 xrel;
|
public Int16 xrel;
|
||||||
public Int16 yrel;
|
public Int16 yrel;
|
||||||
}
|
}
|
||||||
@ -3827,8 +3827,8 @@ namespace SDL2
|
|||||||
public Int32 which; /* SDL_JoystickID */
|
public Int32 which; /* SDL_JoystickID */
|
||||||
public byte hat; /* index of the hat */
|
public byte hat; /* index of the hat */
|
||||||
public byte hatValue; /* value, lolC# */
|
public byte hatValue; /* value, lolC# */
|
||||||
private byte padding1;
|
private readonly byte padding1;
|
||||||
private byte padding2;
|
private readonly byte padding2;
|
||||||
}
|
}
|
||||||
#pragma warning restore 0169
|
#pragma warning restore 0169
|
||||||
|
|
||||||
@ -3843,8 +3843,8 @@ namespace SDL2
|
|||||||
public Int32 which; /* SDL_JoystickID */
|
public Int32 which; /* SDL_JoystickID */
|
||||||
public byte button;
|
public byte button;
|
||||||
public byte state; /* SDL_PRESSED or SDL_RELEASED */
|
public byte state; /* SDL_PRESSED or SDL_RELEASED */
|
||||||
private byte padding1;
|
private readonly byte padding1;
|
||||||
private byte padding2;
|
private readonly byte padding2;
|
||||||
}
|
}
|
||||||
#pragma warning restore 0169
|
#pragma warning restore 0169
|
||||||
|
|
||||||
@ -3867,11 +3867,11 @@ namespace SDL2
|
|||||||
public UInt32 timestamp;
|
public UInt32 timestamp;
|
||||||
public Int32 which; /* SDL_JoystickID */
|
public Int32 which; /* SDL_JoystickID */
|
||||||
public byte axis;
|
public byte axis;
|
||||||
private byte padding1;
|
private readonly byte padding1;
|
||||||
private byte padding2;
|
private readonly byte padding2;
|
||||||
private byte padding3;
|
private readonly byte padding3;
|
||||||
public Int16 axisValue; /* value, lolC# */
|
public Int16 axisValue; /* value, lolC# */
|
||||||
private UInt16 padding4;
|
private readonly UInt16 padding4;
|
||||||
}
|
}
|
||||||
#pragma warning restore 0169
|
#pragma warning restore 0169
|
||||||
|
|
||||||
@ -3886,8 +3886,8 @@ namespace SDL2
|
|||||||
public Int32 which; /* SDL_JoystickID */
|
public Int32 which; /* SDL_JoystickID */
|
||||||
public byte button;
|
public byte button;
|
||||||
public byte state;
|
public byte state;
|
||||||
private byte padding1;
|
private readonly byte padding1;
|
||||||
private byte padding2;
|
private readonly byte padding2;
|
||||||
}
|
}
|
||||||
#pragma warning restore 0169
|
#pragma warning restore 0169
|
||||||
|
|
||||||
@ -3912,9 +3912,9 @@ namespace SDL2
|
|||||||
public UInt32 timestamp;
|
public UInt32 timestamp;
|
||||||
public UInt32 which;
|
public UInt32 which;
|
||||||
public byte iscapture;
|
public byte iscapture;
|
||||||
private byte padding1;
|
private readonly byte padding1;
|
||||||
private byte padding2;
|
private readonly byte padding2;
|
||||||
private byte padding3;
|
private readonly byte padding3;
|
||||||
}
|
}
|
||||||
#pragma warning restore 0169
|
#pragma warning restore 0169
|
||||||
|
|
||||||
@ -5626,9 +5626,11 @@ namespace SDL2
|
|||||||
gamecontroller,
|
gamecontroller,
|
||||||
axis
|
axis
|
||||||
);
|
);
|
||||||
SDL_GameControllerButtonBind result = new SDL_GameControllerButtonBind();
|
SDL_GameControllerButtonBind result = new SDL_GameControllerButtonBind
|
||||||
result.bindType = (SDL_GameControllerBindType) dumb.bindType;
|
{
|
||||||
result.value.hat.hat = dumb.unionVal0;
|
bindType = (SDL_GameControllerBindType)dumb.bindType
|
||||||
|
};
|
||||||
|
result.value.hat.hat = dumb.unionVal0;
|
||||||
result.value.hat.hat_mask = dumb.unionVal1;
|
result.value.hat.hat_mask = dumb.unionVal1;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -5679,9 +5681,11 @@ namespace SDL2
|
|||||||
gamecontroller,
|
gamecontroller,
|
||||||
button
|
button
|
||||||
);
|
);
|
||||||
SDL_GameControllerButtonBind result = new SDL_GameControllerButtonBind();
|
SDL_GameControllerButtonBind result = new SDL_GameControllerButtonBind
|
||||||
result.bindType = (SDL_GameControllerBindType) dumb.bindType;
|
{
|
||||||
result.value.hat.hat = dumb.unionVal0;
|
bindType = (SDL_GameControllerBindType)dumb.bindType
|
||||||
|
};
|
||||||
|
result.value.hat.hat = dumb.unionVal0;
|
||||||
result.value.hat.hat_mask = dumb.unionVal1;
|
result.value.hat.hat_mask = dumb.unionVal1;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,21 @@
|
|||||||
using System;
|
/* 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;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenDiablo2.Common;
|
using OpenDiablo2.Common;
|
||||||
using OpenDiablo2.Common.Enums;
|
using OpenDiablo2.Common.Enums;
|
||||||
@ -34,9 +49,9 @@ namespace OpenDiablo2.SDL2_
|
|||||||
public eArmorType ArmorType { get; set; }
|
public eArmorType ArmorType { get; set; }
|
||||||
public eMobMode MobMode { get; set; }
|
public eMobMode MobMode { get; set; }
|
||||||
|
|
||||||
private IntPtr renderer;
|
private readonly IntPtr renderer;
|
||||||
|
|
||||||
private List<DirectionCacheItem> directionCache = new List<DirectionCacheItem>();
|
private readonly List<DirectionCacheItem> directionCache = new List<DirectionCacheItem>();
|
||||||
DirectionCacheItem currentDirectionCache;
|
DirectionCacheItem currentDirectionCache;
|
||||||
private float seconds;
|
private float seconds;
|
||||||
|
|
||||||
@ -172,10 +187,8 @@ namespace OpenDiablo2.SDL2_
|
|||||||
for (var frameIndex = 0; frameIndex < cache.FramesToAnimate; frameIndex++)
|
for (var frameIndex = 0; frameIndex < cache.FramesToAnimate; frameIndex++)
|
||||||
{
|
{
|
||||||
var texture = SDL.SDL_CreateTexture(renderer, SDL.SDL_PIXELFORMAT_ARGB8888, (int)SDL.SDL_TextureAccess.SDL_TEXTUREACCESS_STREAMING, frameW, frameH);
|
var texture = SDL.SDL_CreateTexture(renderer, SDL.SDL_PIXELFORMAT_ARGB8888, (int)SDL.SDL_TextureAccess.SDL_TEXTUREACCESS_STREAMING, frameW, frameH);
|
||||||
IntPtr pixels;
|
|
||||||
int pitch;
|
|
||||||
|
|
||||||
SDL.SDL_LockTexture(texture, IntPtr.Zero, out pixels, out pitch);
|
SDL.SDL_LockTexture(texture, IntPtr.Zero, out IntPtr pixels, out int pitch);
|
||||||
UInt32* data = (UInt32*)pixels;
|
UInt32* data = (UInt32*)pixels;
|
||||||
|
|
||||||
foreach (var layer in layerData)
|
foreach (var layer in layerData)
|
||||||
|
@ -1,4 +1,20 @@
|
|||||||
using System.Drawing;
|
/* 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.Drawing;
|
||||||
using SDL2;
|
using SDL2;
|
||||||
|
|
||||||
namespace OpenDiablo2.SDL2_
|
namespace OpenDiablo2.SDL2_
|
||||||
|
@ -1,11 +1,23 @@
|
|||||||
using OpenDiablo2.Common.Interfaces;
|
/* OpenDiablo 2 - An open source re-implementation of Diablo 2 in C#
|
||||||
using OpenDiablo2.Common.Models;
|
*
|
||||||
|
* 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;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using OpenDiablo2.Common.Interfaces;
|
||||||
using System.Text;
|
using OpenDiablo2.Common.Models;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace OpenDiablo2.SDL2_
|
namespace OpenDiablo2.SDL2_
|
||||||
{
|
{
|
||||||
|
@ -1,13 +1,26 @@
|
|||||||
using OpenDiablo2.Common.Enums;
|
/* OpenDiablo 2 - An open source re-implementation of Diablo 2 in C#
|
||||||
using OpenDiablo2.Common.Interfaces;
|
*
|
||||||
using SDL2;
|
* 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;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using OpenDiablo2.Common.Enums;
|
||||||
using System.Text;
|
using OpenDiablo2.Common.Interfaces;
|
||||||
using System.Threading.Tasks;
|
using SDL2;
|
||||||
|
|
||||||
namespace OpenDiablo2.SDL2_
|
namespace OpenDiablo2.SDL2_
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,22 @@
|
|||||||
using System;
|
/* 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;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using OpenDiablo2.Common.Interfaces;
|
using OpenDiablo2.Common.Interfaces;
|
||||||
using SDL2;
|
|
||||||
|
|
||||||
namespace OpenDiablo2.SDL2_
|
namespace OpenDiablo2.SDL2_
|
||||||
{
|
{
|
||||||
|
@ -1,12 +1,23 @@
|
|||||||
using OpenDiablo2.Common.Interfaces;
|
/* OpenDiablo 2 - An open source re-implementation of Diablo 2 in C#
|
||||||
using SDL2;
|
*
|
||||||
|
* 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;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using OpenDiablo2.Common.Interfaces;
|
||||||
using System.Runtime.InteropServices;
|
using SDL2;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace OpenDiablo2.SDL2_
|
namespace OpenDiablo2.SDL2_
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,20 @@
|
|||||||
using System;
|
/* 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;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
@ -13,8 +29,8 @@ namespace OpenDiablo2.SDL2_
|
|||||||
{
|
{
|
||||||
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
private IntPtr window, renderer;
|
private readonly IntPtr window, renderer;
|
||||||
private bool fullscreen;
|
private readonly bool fullscreen;
|
||||||
|
|
||||||
public bool IsRunning { get; private set; }
|
public bool IsRunning { get; private set; }
|
||||||
|
|
||||||
@ -97,8 +113,7 @@ namespace OpenDiablo2.SDL2_
|
|||||||
|
|
||||||
public unsafe bool KeyIsPressed(int scancode)
|
public unsafe bool KeyIsPressed(int scancode)
|
||||||
{
|
{
|
||||||
int numKeys;
|
byte* keys = (byte*)SDL.SDL_GetKeyboardState(out int numKeys);
|
||||||
byte* keys = (byte*)SDL.SDL_GetKeyboardState(out numKeys);
|
|
||||||
return keys[scancode] > 0;
|
return keys[scancode] > 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,22 @@
|
|||||||
using System;
|
/* 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;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using OpenDiablo2.Common.Enums;
|
|
||||||
using OpenDiablo2.Common.Interfaces;
|
using OpenDiablo2.Common.Interfaces;
|
||||||
using OpenDiablo2.Common.Models;
|
using OpenDiablo2.Common.Models;
|
||||||
using SDL2;
|
using SDL2;
|
||||||
@ -108,13 +122,10 @@ namespace OpenDiablo2.SDL2_
|
|||||||
private unsafe void LoadFrame(int index)
|
private unsafe void LoadFrame(int index)
|
||||||
{
|
{
|
||||||
var frame = source.Frames[index];
|
var frame = source.Frames[index];
|
||||||
|
|
||||||
IntPtr pixels;
|
|
||||||
int pitch;
|
|
||||||
var fullRect = new SDL.SDL_Rect { x = 0, y = 0, w = FrameSize.Width, h = FrameSize.Height };
|
var fullRect = new SDL.SDL_Rect { x = 0, y = 0, w = FrameSize.Width, h = FrameSize.Height };
|
||||||
SDL.SDL_SetTextureBlendMode(texture, blend ? SDL.SDL_BlendMode.SDL_BLENDMODE_ADD : SDL.SDL_BlendMode.SDL_BLENDMODE_BLEND);
|
SDL.SDL_SetTextureBlendMode(texture, blend ? SDL.SDL_BlendMode.SDL_BLENDMODE_ADD : SDL.SDL_BlendMode.SDL_BLENDMODE_BLEND);
|
||||||
|
|
||||||
SDL.SDL_LockTexture(texture, IntPtr.Zero, out pixels, out pitch);
|
SDL.SDL_LockTexture(texture, IntPtr.Zero, out IntPtr pixels, out int pitch);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
UInt32* data = (UInt32*)pixels;
|
UInt32* data = (UInt32*)pixels;
|
||||||
|
@ -1,4 +1,20 @@
|
|||||||
using System;
|
/* 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;
|
||||||
using OpenDiablo2.Common.Interfaces;
|
using OpenDiablo2.Common.Interfaces;
|
||||||
|
|
||||||
namespace OpenDiablo2.SDL2_
|
namespace OpenDiablo2.SDL2_
|
||||||
|
@ -10,11 +10,7 @@ namespace OpenDiablo2.Scenes
|
|||||||
[Scene(eSceneType.SelectCharacter)]
|
[Scene(eSceneType.SelectCharacter)]
|
||||||
public sealed class CharacterSelection : IScene
|
public sealed class CharacterSelection : IScene
|
||||||
{
|
{
|
||||||
static readonly log4net.ILog log =
|
|
||||||
log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
private readonly IRenderWindow renderWindow;
|
private readonly IRenderWindow renderWindow;
|
||||||
|
|
||||||
private readonly ISprite backgroundSprite;
|
private readonly ISprite backgroundSprite;
|
||||||
private readonly IButton createNewCharacterButton, deleteCharacterButton, exitButton, okButton;
|
private readonly IButton createNewCharacterButton, deleteCharacterButton, exitButton, okButton;
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ namespace OpenDiablo2.Scenes
|
|||||||
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
private readonly IRenderWindow renderWindow;
|
private readonly IRenderWindow renderWindow;
|
||||||
private readonly IResourceManager resourceManager;
|
|
||||||
private readonly IMapEngine mapEngine;
|
private readonly IMapEngine mapEngine;
|
||||||
private readonly IMouseInfoProvider mouseInfoProvider;
|
private readonly IMouseInfoProvider mouseInfoProvider;
|
||||||
private readonly IGameState gameState;
|
private readonly IGameState gameState;
|
||||||
@ -22,11 +21,11 @@ namespace OpenDiablo2.Scenes
|
|||||||
|
|
||||||
//private ISprite[] testSprite;
|
//private ISprite[] testSprite;
|
||||||
|
|
||||||
private ISprite panelSprite, healthManaSprite, gameGlobeOverlapSprite;
|
private readonly ISprite panelSprite, healthManaSprite, gameGlobeOverlapSprite;
|
||||||
|
|
||||||
private readonly IMiniPanel minipanel;
|
private readonly IMiniPanel minipanel;
|
||||||
|
|
||||||
private IButton runButton, menuButton;
|
private readonly IButton runButton, menuButton;
|
||||||
private eMovementType lastMovementType = eMovementType.Stopped;
|
private eMovementType lastMovementType = eMovementType.Stopped;
|
||||||
private byte lastDirection = 255;
|
private byte lastDirection = 255;
|
||||||
|
|
||||||
@ -34,7 +33,6 @@ namespace OpenDiablo2.Scenes
|
|||||||
|
|
||||||
public Game(
|
public Game(
|
||||||
IRenderWindow renderWindow,
|
IRenderWindow renderWindow,
|
||||||
IResourceManager resourceManager,
|
|
||||||
IMapEngine mapEngine,
|
IMapEngine mapEngine,
|
||||||
IGameState gameState,
|
IGameState gameState,
|
||||||
IMouseInfoProvider mouseInfoProvider,
|
IMouseInfoProvider mouseInfoProvider,
|
||||||
@ -46,7 +44,6 @@ namespace OpenDiablo2.Scenes
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.renderWindow = renderWindow;
|
this.renderWindow = renderWindow;
|
||||||
this.resourceManager = resourceManager;
|
|
||||||
this.mapEngine = mapEngine;
|
this.mapEngine = mapEngine;
|
||||||
this.gameState = gameState;
|
this.gameState = gameState;
|
||||||
this.mouseInfoProvider = mouseInfoProvider;
|
this.mouseInfoProvider = mouseInfoProvider;
|
||||||
@ -69,10 +66,7 @@ namespace OpenDiablo2.Scenes
|
|||||||
menuButton.Location = new Point(393, 561);
|
menuButton.Location = new Point(393, 561);
|
||||||
menuButton.OnToggle = minipanel.OnMenuToggle;
|
menuButton.OnToggle = minipanel.OnMenuToggle;
|
||||||
|
|
||||||
/*var item = itemManager.getItem("hdm");
|
//var item = itemManager.getItem("hdm");
|
||||||
var cursorsprite = renderWindow.LoadSprite(ResourcePaths.GeneratePathForItem(item.InvFile), Palettes.Units);
|
|
||||||
|
|
||||||
renderWindow.MouseCursor = renderWindow.LoadCursor(cursorsprite, 0, new Point(cursorsprite.FrameSize.Width/2, cursorsprite.FrameSize.Height / 2));*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnRunToggle(bool isToggled)
|
private void OnRunToggle(bool isToggled)
|
||||||
|
@ -11,27 +11,17 @@ namespace OpenDiablo2.Scenes
|
|||||||
[Scene(eSceneType.MainMenu)]
|
[Scene(eSceneType.MainMenu)]
|
||||||
public class MainMenu : IScene
|
public class MainMenu : IScene
|
||||||
{
|
{
|
||||||
static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
private readonly IRenderWindow renderWindow;
|
private readonly IRenderWindow renderWindow;
|
||||||
private readonly IPaletteProvider paletteProvider;
|
|
||||||
private readonly IMPQProvider mpqProvider;
|
|
||||||
private readonly IMouseInfoProvider mouseInfoProvider;
|
|
||||||
//private readonly IMusicProvider musicProvider;
|
|
||||||
private readonly ISceneManager sceneManager;
|
private readonly ISceneManager sceneManager;
|
||||||
|
|
||||||
private float logoFrame;
|
private float logoFrame;
|
||||||
private ISprite backgroundSprite, diabloLogoLeft, diabloLogoRight, diabloLogoLeftBlack, diabloLogoRightBlack;
|
private readonly ISprite backgroundSprite, diabloLogoLeft, diabloLogoRight, diabloLogoLeftBlack, diabloLogoRightBlack;
|
||||||
private IFont labelFont;
|
private readonly IFont labelFont;
|
||||||
private ILabel versionLabel, urlLabel;
|
private readonly ILabel versionLabel, urlLabel;
|
||||||
private IButton btnSinglePlayer, btnExit, btnWebsite;
|
private readonly IButton btnSinglePlayer, btnExit, btnWebsite;
|
||||||
|
|
||||||
public MainMenu(
|
public MainMenu(
|
||||||
IRenderWindow renderWindow,
|
IRenderWindow renderWindow,
|
||||||
IPaletteProvider paletteProvider,
|
|
||||||
IMPQProvider mpqProvider,
|
|
||||||
IMouseInfoProvider mouseInfoProvider,
|
|
||||||
//IMusicProvider musicProvider,
|
|
||||||
ISceneManager sceneManager,
|
ISceneManager sceneManager,
|
||||||
IResourceManager resourceManager,
|
IResourceManager resourceManager,
|
||||||
Func<eButtonType, IButton> createButton,
|
Func<eButtonType, IButton> createButton,
|
||||||
@ -39,10 +29,6 @@ namespace OpenDiablo2.Scenes
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.renderWindow = renderWindow;
|
this.renderWindow = renderWindow;
|
||||||
this.paletteProvider = paletteProvider;
|
|
||||||
this.mpqProvider = mpqProvider;
|
|
||||||
this.mouseInfoProvider = mouseInfoProvider;
|
|
||||||
this.sceneManager = sceneManager;
|
|
||||||
|
|
||||||
backgroundSprite = renderWindow.LoadSprite(ResourcePaths.GameSelectScreen, Palettes.Sky);
|
backgroundSprite = renderWindow.LoadSprite(ResourcePaths.GameSelectScreen, Palettes.Sky);
|
||||||
diabloLogoLeft = renderWindow.LoadSprite(ResourcePaths.Diablo2LogoFireLeft, Palettes.Units, new Point(400, 120));
|
diabloLogoLeft = renderWindow.LoadSprite(ResourcePaths.Diablo2LogoFireLeft, Palettes.Units, new Point(400, 120));
|
||||||
|
@ -31,11 +31,7 @@ namespace OpenDiablo2.Scenes
|
|||||||
[Scene(eSceneType.SelectHeroClass)]
|
[Scene(eSceneType.SelectHeroClass)]
|
||||||
public sealed class SelectHeroClass : IScene
|
public sealed class SelectHeroClass : IScene
|
||||||
{
|
{
|
||||||
static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
private readonly IRenderWindow renderWindow;
|
private readonly IRenderWindow renderWindow;
|
||||||
private readonly IPaletteProvider paletteProvider;
|
|
||||||
private readonly IMPQProvider mpqProvider;
|
|
||||||
private readonly IMouseInfoProvider mouseInfoProvider;
|
private readonly IMouseInfoProvider mouseInfoProvider;
|
||||||
private readonly ISceneManager sceneManager;
|
private readonly ISceneManager sceneManager;
|
||||||
private readonly ITextDictionary textDictionary;
|
private readonly ITextDictionary textDictionary;
|
||||||
@ -45,17 +41,17 @@ namespace OpenDiablo2.Scenes
|
|||||||
private bool showEntryUi = false;
|
private bool showEntryUi = false;
|
||||||
private eHero? selectedHero = null;
|
private eHero? selectedHero = null;
|
||||||
private float secondTimer;
|
private float secondTimer;
|
||||||
private ISprite backgroundSprite, campfireSprite;
|
private readonly ISprite backgroundSprite, campfireSprite;
|
||||||
private IFont headingFont, heroDescFont, uiFont;
|
private readonly IFont headingFont;
|
||||||
private ILabel headingLabel, heroClassLabel, heroDesc1Label, heroDesc2Label, heroDesc3Label, characterNameLabel;
|
private readonly IFont heroDescFont;
|
||||||
private IButton exitButton, okButton;
|
private readonly IFont uiFont;
|
||||||
private ITextBox characterNameTextBox;
|
private readonly ILabel headingLabel, heroClassLabel, heroDesc1Label, heroDesc2Label, heroDesc3Label, characterNameLabel;
|
||||||
private Dictionary<eHero, HeroRenderInfo> heroRenderInfo = new Dictionary<eHero, HeroRenderInfo>();
|
private readonly IButton exitButton, okButton;
|
||||||
|
private readonly ITextBox characterNameTextBox;
|
||||||
|
private readonly Dictionary<eHero, HeroRenderInfo> heroRenderInfo = new Dictionary<eHero, HeroRenderInfo>();
|
||||||
|
|
||||||
public SelectHeroClass(
|
public SelectHeroClass(
|
||||||
IRenderWindow renderWindow,
|
IRenderWindow renderWindow,
|
||||||
IPaletteProvider paletteProvider,
|
|
||||||
IMPQProvider mpqProvider,
|
|
||||||
IMouseInfoProvider mouseInfoProvider,
|
IMouseInfoProvider mouseInfoProvider,
|
||||||
ISceneManager sceneManager,
|
ISceneManager sceneManager,
|
||||||
Func<eButtonType, IButton> createButton,
|
Func<eButtonType, IButton> createButton,
|
||||||
@ -66,8 +62,6 @@ namespace OpenDiablo2.Scenes
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.renderWindow = renderWindow;
|
this.renderWindow = renderWindow;
|
||||||
this.paletteProvider = paletteProvider;
|
|
||||||
this.mpqProvider = mpqProvider;
|
|
||||||
this.mouseInfoProvider = mouseInfoProvider;
|
this.mouseInfoProvider = mouseInfoProvider;
|
||||||
this.sceneManager = sceneManager;
|
this.sceneManager = sceneManager;
|
||||||
this.textDictionary = textDictionary;
|
this.textDictionary = textDictionary;
|
||||||
@ -452,7 +446,7 @@ namespace OpenDiablo2.Scenes
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDescLabels(string descKey)
|
private void SetDescLabels(string descKey)
|
||||||
{
|
{
|
||||||
var heroDesc = textDictionary.Translate(descKey);
|
var heroDesc = textDictionary.Translate(descKey);
|
||||||
var parts = StringUtils.SplitIntoLinesWithMaxWidth(heroDesc, 37);
|
var parts = StringUtils.SplitIntoLinesWithMaxWidth(heroDesc, 37);
|
||||||
@ -470,15 +464,15 @@ namespace OpenDiablo2.Scenes
|
|||||||
{
|
{
|
||||||
case eHero.Barbarian:
|
case eHero.Barbarian:
|
||||||
heroClassLabel.Text = textDictionary.Translate("strBarbarian");
|
heroClassLabel.Text = textDictionary.Translate("strBarbarian");
|
||||||
setDescLabels("strBarbDesc");
|
SetDescLabels("strBarbDesc");
|
||||||
break;
|
break;
|
||||||
case eHero.Necromancer:
|
case eHero.Necromancer:
|
||||||
heroClassLabel.Text = textDictionary.Translate("strNecromancer");
|
heroClassLabel.Text = textDictionary.Translate("strNecromancer");
|
||||||
setDescLabels("strNecroDesc");
|
SetDescLabels("strNecroDesc");
|
||||||
break;
|
break;
|
||||||
case eHero.Paladin:
|
case eHero.Paladin:
|
||||||
heroClassLabel.Text = textDictionary.Translate("strPaladin");
|
heroClassLabel.Text = textDictionary.Translate("strPaladin");
|
||||||
setDescLabels("strPalDesc");
|
SetDescLabels("strPalDesc");
|
||||||
break;
|
break;
|
||||||
case eHero.Assassin:
|
case eHero.Assassin:
|
||||||
heroClassLabel.Text = textDictionary.Translate("strAssassin");
|
heroClassLabel.Text = textDictionary.Translate("strAssassin");
|
||||||
@ -488,11 +482,11 @@ namespace OpenDiablo2.Scenes
|
|||||||
break;
|
break;
|
||||||
case eHero.Sorceress:
|
case eHero.Sorceress:
|
||||||
heroClassLabel.Text = textDictionary.Translate("strSorceress");
|
heroClassLabel.Text = textDictionary.Translate("strSorceress");
|
||||||
setDescLabels("strSorcDesc");
|
SetDescLabels("strSorcDesc");
|
||||||
break;
|
break;
|
||||||
case eHero.Amazon:
|
case eHero.Amazon:
|
||||||
heroClassLabel.Text = textDictionary.Translate("strAmazon");
|
heroClassLabel.Text = textDictionary.Translate("strAmazon");
|
||||||
setDescLabels("strAmazonDesc");
|
SetDescLabels("strAmazonDesc");
|
||||||
break;
|
break;
|
||||||
case eHero.Druid:
|
case eHero.Druid:
|
||||||
heroClassLabel.Text = textDictionary.Translate("strDruid");
|
heroClassLabel.Text = textDictionary.Translate("strDruid");
|
||||||
|
@ -38,7 +38,7 @@ namespace OpenDiablo2.ServiceBus
|
|||||||
private readonly Func<IGameState> getGameState;
|
private readonly Func<IGameState> getGameState;
|
||||||
|
|
||||||
private RequestSocket requestSocket;
|
private RequestSocket requestSocket;
|
||||||
private AutoResetEvent resetEvent = new AutoResetEvent(false);
|
private readonly AutoResetEvent resetEvent = new AutoResetEvent(false);
|
||||||
private ISessionServer sessionServer;
|
private ISessionServer sessionServer;
|
||||||
private bool running = false;
|
private bool running = false;
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ namespace OpenDiablo2.ServiceBus
|
|||||||
private readonly IGameServer gameServer;
|
private readonly IGameServer gameServer;
|
||||||
private readonly Func<eMessageFrameType, IMessageFrame> getMessageFrame;
|
private readonly Func<eMessageFrameType, IMessageFrame> getMessageFrame;
|
||||||
|
|
||||||
private AutoResetEvent resetEvent = new AutoResetEvent(false);
|
private readonly AutoResetEvent resetEvent = new AutoResetEvent(false);
|
||||||
public AutoResetEvent WaitServerStartEvent { get; set; } = new AutoResetEvent(false);
|
public AutoResetEvent WaitServerStartEvent { get; set; } = new AutoResetEvent(false);
|
||||||
private bool running = false;
|
private bool running = false;
|
||||||
private ResponseSocket responseSocket;
|
private ResponseSocket responseSocket;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user