mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-12-27 20:46:32 -05:00
Finally fixed broken map load logic. Made palletes less dumb.
This commit is contained in:
parent
78ee66bdfb
commit
60b453c033
@ -32,9 +32,7 @@ namespace OpenDiablo2.Common.Models
|
|||||||
if (index == -1)
|
if (index == -1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
var color = palette.Colors[index];
|
return palette.Colors[index];
|
||||||
|
|
||||||
return ((UInt32)255 << 24) + ((UInt32)color.R << 16) + ((UInt32)color.G << 8) + (UInt32)color.B;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,15 +154,12 @@ namespace OpenDiablo2.Common.Models
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// RLE block
|
// RLE block
|
||||||
/*
|
|
||||||
var length = block.Length;
|
var length = block.Length;
|
||||||
byte b1;
|
byte b1;
|
||||||
byte b2;
|
byte b2;
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int y = 0;
|
int y = 0;
|
||||||
int width = (block.Format >> 8);
|
block.PixelData = new Int16[32 * 32];
|
||||||
int height = (block.Format & 0xFF);
|
|
||||||
block.PixelData = new Int16[256 * 256];
|
|
||||||
while (length > 0)
|
while (length > 0)
|
||||||
{
|
{
|
||||||
b1 = br.ReadByte();
|
b1 = br.ReadByte();
|
||||||
@ -180,12 +177,10 @@ namespace OpenDiablo2.Common.Models
|
|||||||
while (b2 > 0)
|
while (b2 > 0)
|
||||||
{
|
{
|
||||||
block.PixelData[x + (y * 32)] = br.ReadByte();
|
block.PixelData[x + (y * 32)] = br.ReadByte();
|
||||||
br.ReadByte();
|
|
||||||
x++;
|
x++;
|
||||||
b2--;
|
b2--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,34 +7,27 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace OpenDiablo2.Common.Models
|
namespace OpenDiablo2.Common.Models
|
||||||
{
|
{
|
||||||
public struct PaletteEntry
|
|
||||||
{
|
|
||||||
public int R;
|
|
||||||
public int G;
|
|
||||||
public int B;
|
|
||||||
}
|
|
||||||
|
|
||||||
public struct Palette
|
public struct Palette
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public PaletteEntry[] Colors;
|
public UInt32[] Colors;
|
||||||
|
|
||||||
public static Palette LoadFromStream(Stream stream, string paletteName)
|
public static Palette LoadFromStream(Stream stream, string paletteName)
|
||||||
{
|
{
|
||||||
var result = new Palette
|
var result = new Palette
|
||||||
{
|
{
|
||||||
Name = paletteName,
|
Name = paletteName,
|
||||||
Colors = new PaletteEntry[256]
|
Colors = new UInt32[256]
|
||||||
};
|
};
|
||||||
|
|
||||||
var br = new BinaryReader(stream);
|
var br = new BinaryReader(stream);
|
||||||
for (var i = 0; i <= 255; i++)
|
for (var i = 0; i <= 255; i++)
|
||||||
result.Colors[i] = new PaletteEntry
|
|
||||||
{
|
{
|
||||||
B = br.ReadByte(),
|
var b = br.ReadByte();
|
||||||
G = br.ReadByte(),
|
var g = br.ReadByte();
|
||||||
R = br.ReadByte()
|
var r = br.ReadByte();
|
||||||
};
|
result.Colors[i] = ((UInt32)255 << 24) + ((UInt32)r << 16) + ((UInt32)g << 8) + (UInt32)b;
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -118,12 +118,17 @@ namespace OpenDiablo2.SDL2_
|
|||||||
for (var i = 0; i < FrameSize.Width * FrameSize.Height; i++)
|
for (var i = 0; i < FrameSize.Width * FrameSize.Height; i++)
|
||||||
data[i] = 0;
|
data[i] = 0;
|
||||||
|
|
||||||
for (var subtileX = 0; subtileX < 5; subtileX++)
|
|
||||||
{
|
|
||||||
for (var subtileY = 0; subtileY < 5; subtileY++)
|
|
||||||
{
|
|
||||||
var subtileFlags = tile.SubTileFlags[subtileX + (subtileY * 5)];
|
|
||||||
|
|
||||||
|
foreach (var block in tile.Blocks)
|
||||||
|
{
|
||||||
|
var px = block.PositionX;
|
||||||
|
var py = FrameSize.Height + block.PositionY;
|
||||||
|
for (int yy = 0; yy < 32; yy++)
|
||||||
|
{
|
||||||
|
for (int xx = 0; xx < 32; xx++)
|
||||||
|
{
|
||||||
|
data[px + xx + ((py + yy) * pitch / 4)] = palette.Colors[block.PixelData[xx + (yy * 32)]];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,8 +50,6 @@ namespace OpenDiablo2.Scenes
|
|||||||
this.mouseInfoProvider = mouseInfoProvider;
|
this.mouseInfoProvider = mouseInfoProvider;
|
||||||
this.sceneManager = sceneManager;
|
this.sceneManager = sceneManager;
|
||||||
|
|
||||||
resourceManager.GetMPQDS1(ResourcePaths.MapAct1TownE1, -1, 1);
|
|
||||||
|
|
||||||
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));
|
||||||
diabloLogoLeft.Blend = true;
|
diabloLogoLeft.Blend = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user