mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-12-25 19:46:50 -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)
|
||||
return 0;
|
||||
|
||||
var color = palette.Colors[index];
|
||||
|
||||
return ((UInt32)255 << 24) + ((UInt32)color.R << 16) + ((UInt32)color.G << 8) + (UInt32)color.B;
|
||||
return palette.Colors[index];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,15 +154,12 @@ namespace OpenDiablo2.Common.Models
|
||||
else
|
||||
{
|
||||
// RLE block
|
||||
/*
|
||||
var length = block.Length;
|
||||
byte b1;
|
||||
byte b2;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int width = (block.Format >> 8);
|
||||
int height = (block.Format & 0xFF);
|
||||
block.PixelData = new Int16[256 * 256];
|
||||
block.PixelData = new Int16[32 * 32];
|
||||
while (length > 0)
|
||||
{
|
||||
b1 = br.ReadByte();
|
||||
@ -180,12 +177,10 @@ namespace OpenDiablo2.Common.Models
|
||||
while (b2 > 0)
|
||||
{
|
||||
block.PixelData[x + (y * 32)] = br.ReadByte();
|
||||
br.ReadByte();
|
||||
x++;
|
||||
b2--;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,34 +7,27 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace OpenDiablo2.Common.Models
|
||||
{
|
||||
public struct PaletteEntry
|
||||
{
|
||||
public int R;
|
||||
public int G;
|
||||
public int B;
|
||||
}
|
||||
|
||||
public struct Palette
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public PaletteEntry[] Colors;
|
||||
public UInt32[] Colors;
|
||||
|
||||
public static Palette LoadFromStream(Stream stream, string paletteName)
|
||||
{
|
||||
var result = new Palette
|
||||
{
|
||||
Name = paletteName,
|
||||
Colors = new PaletteEntry[256]
|
||||
Colors = new UInt32[256]
|
||||
};
|
||||
|
||||
var br = new BinaryReader(stream);
|
||||
for (var i = 0; i <= 255; i++)
|
||||
result.Colors[i] = new PaletteEntry
|
||||
{
|
||||
B = br.ReadByte(),
|
||||
G = br.ReadByte(),
|
||||
R = br.ReadByte()
|
||||
};
|
||||
{
|
||||
var b = br.ReadByte();
|
||||
var g = br.ReadByte();
|
||||
var r = br.ReadByte();
|
||||
result.Colors[i] = ((UInt32)255 << 24) + ((UInt32)r << 16) + ((UInt32)g << 8) + (UInt32)b;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -118,12 +118,17 @@ namespace OpenDiablo2.SDL2_
|
||||
for (var i = 0; i < FrameSize.Width * FrameSize.Height; i++)
|
||||
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)]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,9 +49,7 @@ namespace OpenDiablo2.Scenes
|
||||
this.mpqProvider = mpqProvider;
|
||||
this.mouseInfoProvider = mouseInfoProvider;
|
||||
this.sceneManager = sceneManager;
|
||||
|
||||
resourceManager.GetMPQDS1(ResourcePaths.MapAct1TownE1, -1, 1);
|
||||
|
||||
|
||||
backgroundSprite = renderWindow.LoadSprite(ResourcePaths.GameSelectScreen, Palettes.Sky);
|
||||
diabloLogoLeft = renderWindow.LoadSprite(ResourcePaths.Diablo2LogoFireLeft, Palettes.Units, new Point(400, 120));
|
||||
diabloLogoLeft.Blend = true;
|
||||
|
Loading…
Reference in New Issue
Block a user