mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-19 12:35:52 -04:00
Make bottom right text group same location as normal chat group, reduce code duplication.
This commit is contained in:
parent
f533e99418
commit
11f2695771
@ -58,7 +58,7 @@ namespace ClassicalSharp.Gui {
|
|||||||
status.SetUsePlaceHolder( 1, false );
|
status.SetUsePlaceHolder( 1, false );
|
||||||
bottomRight = new TextGroupWidget( game, 3, chatFont, chatUrlFont,
|
bottomRight = new TextGroupWidget( game, 3, chatFont, chatUrlFont,
|
||||||
Anchor.BottomOrRight, Anchor.BottomOrRight );
|
Anchor.BottomOrRight, Anchor.BottomOrRight );
|
||||||
bottomRight.YOffset = blockSize * 3 / 2;
|
bottomRight.YOffset = blockSize + 15;
|
||||||
bottomRight.Init();
|
bottomRight.Init();
|
||||||
normalChat = new TextGroupWidget( game, chatLines, chatFont, chatUrlFont,
|
normalChat = new TextGroupWidget( game, chatLines, chatFont, chatUrlFont,
|
||||||
Anchor.LeftOrTop, Anchor.BottomOrRight );
|
Anchor.LeftOrTop, Anchor.BottomOrRight );
|
||||||
|
@ -134,9 +134,9 @@ namespace ClassicalSharp.Gui {
|
|||||||
|
|
||||||
void DrawPosition() {
|
void DrawPosition() {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
TextureRec xy = new TextureRec( 2, posTex.Y1, baseWidth, posTex.Height );
|
Texture tex = posTex;
|
||||||
TextureRec uv = new TextureRec( 0, posTex.V1, posTex.U2, posTex.V2 );
|
tex.X1 = 2; tex.Width = baseWidth;
|
||||||
IGraphicsApi.Make2DQuad( xy, uv, game.ModelCache.vertices, ref index );
|
IGraphicsApi.Make2DQuad( ref tex, FastColour.White, game.ModelCache.vertices, ref index );
|
||||||
|
|
||||||
Vector3I pos = Vector3I.Floor( game.LocalPlayer.Position );
|
Vector3I pos = Vector3I.Floor( game.LocalPlayer.Position );
|
||||||
curX = baseWidth + 2;
|
curX = baseWidth + 2;
|
||||||
@ -214,12 +214,12 @@ namespace ClassicalSharp.Gui {
|
|||||||
|
|
||||||
void AddChar( int charIndex, ref int index ) {
|
void AddChar( int charIndex, ref int index ) {
|
||||||
int width = widths[charIndex];
|
int width = widths[charIndex];
|
||||||
TextureRec xy = new TextureRec( curX, posTex.Y1, width, posTex.Height );
|
Texture tex = posTex;
|
||||||
TextureRec uv = new TextureRec( (baseWidth + charIndex * 16) / texWidth,
|
tex.X1 = curX; tex.Width = width;
|
||||||
posTex.V1, width / texWidth, posTex.V2 );
|
tex.U1 = (baseWidth + charIndex * 16) / texWidth;
|
||||||
|
tex.U2 = tex.U1 + width / texWidth;
|
||||||
curX += width;
|
curX += width;
|
||||||
IGraphicsApi.Make2DQuad( xy, uv, game.ModelCache.vertices, ref index );
|
IGraphicsApi.Make2DQuad( ref tex, FastColour.White, game.ModelCache.vertices, ref index );
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddInt( int value, ref int index, bool more ) {
|
void AddInt( int value, ref int index, bool more ) {
|
||||||
|
@ -46,24 +46,14 @@ namespace ClassicalSharp.Gui {
|
|||||||
|
|
||||||
int texLoc = game.BlockInfo.GetTextureLoc( Block.Dirt, Side.Top );
|
int texLoc = game.BlockInfo.GetTextureLoc( Block.Dirt, Side.Top );
|
||||||
TerrainAtlas1D atlas = game.TerrainAtlas1D;
|
TerrainAtlas1D atlas = game.TerrainAtlas1D;
|
||||||
TextureRec tex = atlas.GetTexRec( texLoc, 1, out atlasIndex );
|
Texture tex = new Texture( 0, 0, 0, game.Width, 64,
|
||||||
|
atlas.GetTexRec( texLoc, 1, out atlasIndex ) );
|
||||||
tex.U2 = (float)game.Width / 64;
|
tex.U2 = (float)game.Width / 64;
|
||||||
bool bound = false;
|
bool bound = false;
|
||||||
|
|
||||||
while( drawnY < height ) {
|
while( drawnY < height ) {
|
||||||
float x1 = 0, x2 = game.Width;
|
tex.Y1 = drawnY;
|
||||||
float y1 = drawnY, y2 = drawnY + 64;
|
IGraphicsApi.Make2DQuad( ref tex, col, vertices, ref index );
|
||||||
#if USE_DX
|
|
||||||
// NOTE: see "https://msdn.microsoft.com/en-us/library/windows/desktop/bb219690(v=vs.85).aspx",
|
|
||||||
// i.e. the msdn article called "Directly Mapping Texels to Pixels (Direct3D 9)" for why we have to do this.
|
|
||||||
x1 -= 0.5f; x2 -= 0.5f;
|
|
||||||
y1 -= 0.5f; y2 -= 0.5f;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
vertices[index++] = new VertexP3fT2fC4b( x1, y1, 0, tex.U1, tex.V1, col );
|
|
||||||
vertices[index++] = new VertexP3fT2fC4b( x2, y1, 0, tex.U2, tex.V1, col );
|
|
||||||
vertices[index++] = new VertexP3fT2fC4b( x2, y2, 0, tex.U2, tex.V2, col );
|
|
||||||
vertices[index++] = new VertexP3fT2fC4b( x1, y2, 0, tex.U1, tex.V2, col );
|
|
||||||
if( index >= vertices.Length )
|
if( index >= vertices.Length )
|
||||||
DrawBackgroundVertices( ref index, atlasIndex, ref bound );
|
DrawBackgroundVertices( ref index, atlasIndex, ref bound );
|
||||||
drawnY += 64;
|
drawnY += 64;
|
||||||
|
@ -276,6 +276,14 @@ namespace ClassicalSharp.GraphicsAPI {
|
|||||||
internal VertexP3fT2fC4b[] texVerts = new VertexP3fT2fC4b[4];
|
internal VertexP3fT2fC4b[] texVerts = new VertexP3fT2fC4b[4];
|
||||||
internal int texVb;
|
internal int texVb;
|
||||||
public virtual void Draw2DTexture( ref Texture tex, FastColour col ) {
|
public virtual void Draw2DTexture( ref Texture tex, FastColour col ) {
|
||||||
|
int index = 0;
|
||||||
|
Make2DQuad( ref tex, col, texVerts, ref index );
|
||||||
|
SetBatchFormat( VertexFormat.P3fT2fC4b );
|
||||||
|
UpdateDynamicIndexedVb( DrawMode.Triangles, texVb, texVerts, 4, 6 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Make2DQuad( ref Texture tex, FastColour col,
|
||||||
|
VertexP3fT2fC4b[] vertices, ref int index ) {
|
||||||
float x1 = tex.X1, y1 = tex.Y1, x2 = tex.X2, y2 = tex.Y2;
|
float x1 = tex.X1, y1 = tex.Y1, x2 = tex.X2, y2 = tex.Y2;
|
||||||
#if USE_DX
|
#if USE_DX
|
||||||
// NOTE: see "https://msdn.microsoft.com/en-us/library/windows/desktop/bb219690(v=vs.85).aspx",
|
// NOTE: see "https://msdn.microsoft.com/en-us/library/windows/desktop/bb219690(v=vs.85).aspx",
|
||||||
@ -283,25 +291,10 @@ namespace ClassicalSharp.GraphicsAPI {
|
|||||||
x1 -= 0.5f; x2 -= 0.5f;
|
x1 -= 0.5f; x2 -= 0.5f;
|
||||||
y1 -= 0.5f; y2 -= 0.5f;
|
y1 -= 0.5f; y2 -= 0.5f;
|
||||||
#endif
|
#endif
|
||||||
texVerts[0] = new VertexP3fT2fC4b( x1, y1, 0, tex.U1, tex.V1, col );
|
vertices[index++] = new VertexP3fT2fC4b( x1, y1, 0, tex.U1, tex.V1, col );
|
||||||
texVerts[1] = new VertexP3fT2fC4b( x2, y1, 0, tex.U2, tex.V1, col );
|
vertices[index++] = new VertexP3fT2fC4b( x2, y1, 0, tex.U2, tex.V1, col );
|
||||||
texVerts[2] = new VertexP3fT2fC4b( x2, y2, 0, tex.U2, tex.V2, col );
|
vertices[index++] = new VertexP3fT2fC4b( x2, y2, 0, tex.U2, tex.V2, col );
|
||||||
texVerts[3] = new VertexP3fT2fC4b( x1, y2, 0, tex.U1, tex.V2, col );
|
vertices[index++] = new VertexP3fT2fC4b( x1, y2, 0, tex.U1, tex.V2, col );
|
||||||
SetBatchFormat( VertexFormat.P3fT2fC4b );
|
|
||||||
UpdateDynamicIndexedVb( DrawMode.Triangles, texVb, texVerts, 4, 6 );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Make2DQuad( TextureRec xy, TextureRec uv,
|
|
||||||
VertexP3fT2fC4b[] vertices, ref int index ) {
|
|
||||||
float x1 = xy.U1, y1 = xy.V1, x2 = xy.U2, y2 = xy.V2;
|
|
||||||
#if USE_DX
|
|
||||||
x1 -= 0.5f; x2 -= 0.5f;
|
|
||||||
y1 -= 0.5f; y2 -= 0.5f;
|
|
||||||
#endif
|
|
||||||
vertices[index++] = new VertexP3fT2fC4b( x1, y1, 0, uv.U1, uv.V1, FastColour.White );
|
|
||||||
vertices[index++] = new VertexP3fT2fC4b( x2, y1, 0, uv.U2, uv.V1, FastColour.White );
|
|
||||||
vertices[index++] = new VertexP3fT2fC4b( x2, y2, 0, uv.U2, uv.V2, FastColour.White );
|
|
||||||
vertices[index++] = new VertexP3fT2fC4b( x1, y2, 0, uv.U1, uv.V2, FastColour.White );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Updates the various matrix stacks and properties so that the graphics API state
|
/// <summary> Updates the various matrix stacks and properties so that the graphics API state
|
||||||
|
Loading…
x
Reference in New Issue
Block a user