1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-07-05 20:55:23 +00:00

Fixed menu rendering

This commit is contained in:
Tim Sarbin 2018-11-22 12:19:38 -05:00
parent 03dc82f874
commit 77c4621295
5 changed files with 18 additions and 10 deletions

View File

@ -8,6 +8,7 @@ namespace OpenDiablo2.Common.Interfaces
{ {
Point Location { get; set; } Point Location { get; set; }
Size FrameSize { get; set; } Size FrameSize { get; set; }
Size LocalFrameSize { get; }
int Frame { get; set; } int Frame { get; set; }
int TotalFrames { get; } int TotalFrames { get; }
Palette CurrentPalette { get; set; } Palette CurrentPalette { get; set; }

View File

@ -67,7 +67,7 @@ namespace OpenDiablo2.Common.Models
{ {
stream.Seek(result.framePointers[i], SeekOrigin.Begin); stream.Seek(result.framePointers[i], SeekOrigin.Begin);
var frame = new ImageFrame result.Frames[i] = new ImageFrame
{ {
Flip = br.ReadUInt32(), Flip = br.ReadUInt32(),
Width = br.ReadUInt32(), Width = br.ReadUInt32(),
@ -79,14 +79,14 @@ namespace OpenDiablo2.Common.Models
Length = br.ReadUInt32() Length = br.ReadUInt32()
}; };
frame.ImageData = new Int16[frame.Width, frame.Height]; result.Frames[i].ImageData = new Int16[result.Frames[i].Width, result.Frames[i].Height];
for (int ty = 0; ty < frame.Height; ty++) for (int ty = 0; ty < result.Frames[i].Height; ty++)
for (int tx = 0; tx < frame.Width; tx++) for (int tx = 0; tx < result.Frames[i].Width; tx++)
frame.ImageData[tx, ty] = -1; result.Frames[i].ImageData[tx, ty] = -1;
int x = 0; int x = 0;
int y = (int)frame.Height - 1; int y = (int)result.Frames[i].Height - 1;
while (true) while (true)
{ {
var b = br.ReadByte(); var b = br.ReadByte();
@ -105,7 +105,7 @@ namespace OpenDiablo2.Common.Models
var transparentPixelsToWrite = b & 0x7F; var transparentPixelsToWrite = b & 0x7F;
for (int p = 0; p < transparentPixelsToWrite; p++) for (int p = 0; p < transparentPixelsToWrite; p++)
{ {
frame.ImageData[x++, y] = -1; result.Frames[i].ImageData[x++, y] = -1;
} }
continue; continue;
} }
@ -113,11 +113,10 @@ namespace OpenDiablo2.Common.Models
for (int p = 0; p < b; p++) for (int p = 0; p < b; p++)
{ {
frame.ImageData[x++, y] = br.ReadByte(); result.Frames[i].ImageData[x++, y] = br.ReadByte();
} }
} }
result.Frames[i] = frame;
} }

View File

@ -86,5 +86,8 @@
<ItemGroup> <ItemGroup>
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Content Include="Properties\MPQEditor.exe" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>

View File

@ -50,6 +50,8 @@ namespace OpenDiablo2.SDL2_
(Location.Y - FrameSize.Height) + source.Frames[Frame].OffsetY (Location.Y - FrameSize.Height) + source.Frames[Frame].OffsetY
); );
public Size LocalFrameSize => new Size((int)source.Frames[Frame].Width, (int)source.Frames[Frame].Height);
private void UpdateTextureData() private void UpdateTextureData()
{ {
foreach (var texture in textures) foreach (var texture in textures)

View File

@ -97,13 +97,16 @@ namespace OpenDiablo2.Scenes
renderWindow.Clear(); renderWindow.Clear();
for (int y = 0; y < 3; y++) for (int y = 0; y < 3; y++)
{
for (int x = 0; x < 4; x++) for (int x = 0; x < 4; x++)
{ {
backgroundSprite.Frame = x + (y * 4); backgroundSprite.Frame = x + (y * 4);
backgroundSprite.Location = new Point(x * backgroundSprite.FrameSize.Width, (y + 1) * backgroundSprite.FrameSize.Height); backgroundSprite.Location = new Point(x * 256, ((y+1) * 256) - (backgroundSprite.FrameSize.Height - backgroundSprite.LocalFrameSize.Height));
renderWindow.Draw(backgroundSprite); renderWindow.Draw(backgroundSprite);
} }
}
diabloLogoLeftBlack.Frame = (int)((float)diabloLogoLeftBlack.TotalFrames * logoFrame); diabloLogoLeftBlack.Frame = (int)((float)diabloLogoLeftBlack.TotalFrames * logoFrame);
renderWindow.Draw(diabloLogoLeftBlack); renderWindow.Draw(diabloLogoLeftBlack);
diabloLogoRightBlack.Frame = (int)((float)diabloLogoRightBlack.TotalFrames * logoFrame); diabloLogoRightBlack.Frame = (int)((float)diabloLogoRightBlack.TotalFrames * logoFrame);