Arrange F10 horizontally instead

This commit is contained in:
UnknownShadow200 2018-06-03 14:25:29 +10:00
parent e6a044ce22
commit d623a22121

View File

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