diff --git a/ClassicalSharp/2D/Screens/Overlays/TexIdsOverlay.cs b/ClassicalSharp/2D/Screens/Overlays/TexIdsOverlay.cs index 960a73e9a..1e7245732 100644 --- a/ClassicalSharp/2D/Screens/Overlays/TexIdsOverlay.cs +++ b/ClassicalSharp/2D/Screens/Overlays/TexIdsOverlay.cs @@ -15,7 +15,7 @@ namespace ClassicalSharp.Gui.Screens { const int verticesCount = Atlas2D.TilesPerRow * Atlas2D.MaxRowsCount * 4; static VertexP3fT2fC4b[] vertices; int dynamicVb; - int xOffset, yOffset, tileSize; + int xOffset, yOffset, tileSize, baseTexLoc; public override void Init() { textFont = new Font(game.FontName, 8); @@ -30,8 +30,19 @@ namespace ClassicalSharp.Gui.Screens { game.Graphics.Texturing = true; game.Graphics.SetBatchFormat(VertexFormat.P3fT2fC4b); RenderWidgets(widgets, delta); - RenderTerrain(); - RenderTextOverlay(); + + int rows = Atlas2D.RowsCount, origXOffset = xOffset; + while (rows > 0) { + RenderTerrain(); + RenderText(); + rows -= Atlas2D.TilesPerRow; + + xOffset += tileSize * Atlas2D.TilesPerRow; + baseTexLoc += Atlas2D.TilesPerRow * Atlas2D.TilesPerRow; + } + + baseTexLoc = 0; + xOffset = origXOffset; game.Graphics.Texturing = false; } @@ -46,24 +57,23 @@ namespace ClassicalSharp.Gui.Screens { idAtlas = new TextAtlas(game, 16); idAtlas.Pack("0123456789", textFont, "f"); - tileSize = game.Height / Atlas2D.RowsCount; + tileSize = game.Height / Atlas2D.TilesPerRow; tileSize = (tileSize / 8) * 8; Utils.Clamp(ref tileSize, 8, 40); - xOffset = CalcPos(Anchor.Centre, 0, tileSize * Atlas2D.TilesPerRow, game.Width); - yOffset = CalcPos(Anchor.Centre, 0, tileSize * Atlas2D.RowsCount, game.Height); + xOffset = CalcPos(Anchor.Centre, 0, tileSize * Atlas2D.RowsCount, game.Width); + yOffset = CalcPos(Anchor.Centre, 0, tileSize * Atlas2D.TilesPerRow, game.Height); widgets[0] = TextWidget.Create(game, "Texture ID reference sheet", titleFont) .SetLocation(Anchor.Centre, Anchor.Min, 0, yOffset - 30); } void RenderTerrain() { - int elementsPerAtlas = Atlas1D.TilesPerAtlas; - for (int i = 0; i < Atlas2D.TilesPerRow * Atlas2D.RowsCount;) { - int index = 0, texIdx = i / elementsPerAtlas, ignored; + for (int i = 0; i < Atlas2D.TilesPerRow * Atlas2D.TilesPerRow;) { + int index = 0, texIdx = 0; - for (int j = 0; j < elementsPerAtlas; j++) { - TextureRec rec = Atlas1D.GetTexRec(i + j, 1, out ignored); + for (int j = 0; j < Atlas1D.TilesPerAtlas; j++) { + TextureRec rec = Atlas1D.GetTexRec((i + j) + baseTexLoc, 1, out texIdx); int x = (i + j) % Atlas2D.TilesPerRow; int y = (i + j) / Atlas2D.TilesPerRow; @@ -71,7 +81,7 @@ namespace ClassicalSharp.Gui.Screens { tileSize, tileSize, rec); IGraphicsApi.Make2DQuad(ref tex, FastColour.WhitePacked, vertices, ref index); } - i += elementsPerAtlas; + i += Atlas1D.TilesPerAtlas; game.Graphics.BindTexture(Atlas1D.TexIds[texIdx]); game.Graphics.UpdateDynamicVb_IndexedTris(dynamicVb, vertices, index); @@ -79,15 +89,15 @@ namespace ClassicalSharp.Gui.Screens { } const int textOffset = 3; - void RenderTextOverlay() { + void RenderText() { int index = 0; idAtlas.tex.Y = (short)(yOffset + (tileSize - idAtlas.tex.Height)); - for (int y = 0; y < Atlas2D.RowsCount; y++) { + for (int y = 0; y < Atlas2D.TilesPerRow; y++) { for (int x = 0; x < Atlas2D.TilesPerRow; x++) { idAtlas.curX = xOffset + tileSize * x + textOffset; int id = x + y * Atlas2D.TilesPerRow; - idAtlas.AddInt(id, vertices, ref index); + idAtlas.AddInt(id + baseTexLoc, vertices, ref index); } idAtlas.tex.Y += (short)tileSize;