mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-22 17:12:25 -05:00
Implement proper scrollbar for the block inventory, partially addresses #141.
This commit is contained in:
parent
2ab0bba083
commit
32697c43ca
31 changed files with 132 additions and 116 deletions
|
@ -14,14 +14,14 @@ namespace ClassicalSharp.Gui {
|
|||
public abstract class GuiElement : IDisposable {
|
||||
|
||||
protected Game game;
|
||||
protected IGraphicsApi graphicsApi;
|
||||
protected IGraphicsApi api;
|
||||
|
||||
/// <summary> Object that represents any form of metadata attached to this widget. </summary>
|
||||
public object Metadata = null;
|
||||
|
||||
public GuiElement( Game game ) {
|
||||
this.game = game;
|
||||
graphicsApi = game.Graphics;
|
||||
api = game.Graphics;
|
||||
}
|
||||
|
||||
public abstract void Init();
|
||||
|
|
|
@ -9,17 +9,22 @@ namespace ClassicalSharp.Gui {
|
|||
const int scrollbarWidth = 10;
|
||||
static FastColour scrollCol = new FastColour( 10, 10, 10, 220 );
|
||||
static FastColour scrollUsedCol = new FastColour( 100, 100, 100, 220 );
|
||||
float ScrollbarScale { get { return TableHeight / (float)rows; } }
|
||||
|
||||
void DrawScrollbar() {
|
||||
graphicsApi.Draw2DQuad( TableX, TableY, scrollbarWidth,
|
||||
TableHeight, scrollCol );
|
||||
float scale = TableHeight / (float)rows;
|
||||
int yOffset = (int)Math.Ceiling( scrollY * scale );
|
||||
int height = (int)Math.Ceiling( maxRows * scale );
|
||||
api.Draw2DQuad( TableX, TableY, scrollbarWidth, TableHeight, scrollCol );
|
||||
int y, height;
|
||||
GetScrollbarCoords( out y, out height );
|
||||
api.Draw2DQuad( TableX, TableY + y, scrollbarWidth, height, scrollUsedCol );
|
||||
}
|
||||
|
||||
void GetScrollbarCoords( out int y, out int height ) {
|
||||
float scale = ScrollbarScale;
|
||||
y = (int)Math.Ceiling( scrollY * scale );
|
||||
height = (int)Math.Ceiling( maxRows * scale );
|
||||
|
||||
if( yOffset + height > TableHeight )
|
||||
height = TableHeight - yOffset;
|
||||
graphicsApi.Draw2DQuad( TableX, TableY + yOffset, scrollbarWidth,
|
||||
height, scrollUsedCol );
|
||||
if( y + height > TableHeight )
|
||||
height = TableHeight - y;
|
||||
}
|
||||
|
||||
public override bool HandlesMouseScroll( int delta ) {
|
||||
|
@ -49,15 +54,26 @@ namespace ClassicalSharp.Gui {
|
|||
|
||||
void ScrollbarClick( int mouseY ) {
|
||||
mouseY -= TableY;
|
||||
float scale = TableHeight / (float)rows;
|
||||
scrollY = (int)(mouseY / scale);
|
||||
int y, height;
|
||||
GetScrollbarCoords( out y, out height );
|
||||
|
||||
if( mouseY < y ) {
|
||||
scrollY -= maxRows;
|
||||
} else if( mouseY >= y + height ) {
|
||||
scrollY += maxRows;
|
||||
} else {
|
||||
draggingMouse = true;
|
||||
mouseOffset = mouseY - y;
|
||||
}
|
||||
ClampScrollY();
|
||||
}
|
||||
|
||||
bool draggingMouse = false;
|
||||
int mouseOffset = 0;
|
||||
|
||||
public override bool HandlesMouseUp( int mouseX, int mouseY, MouseButton button ) {
|
||||
draggingMouse = false;
|
||||
mouseOffset = 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,17 +28,16 @@ namespace ClassicalSharp.Gui {
|
|||
|
||||
static FastColour backCol = new FastColour( 30, 30, 30, 200 );
|
||||
public override void Render( double delta ) {
|
||||
graphicsApi.Draw2DQuad( TableX, TableY, TableWidth, TableHeight, backCol );
|
||||
api.Draw2DQuad( TableX, TableY, TableWidth, TableHeight, backCol );
|
||||
if( rows > maxRows )
|
||||
DrawScrollbar();
|
||||
graphicsApi.Texturing = true;
|
||||
graphicsApi.SetBatchFormat( VertexFormat.Pos3fTex2fCol4b );
|
||||
api.Texturing = true;
|
||||
api.SetBatchFormat( VertexFormat.Pos3fTex2fCol4b );
|
||||
|
||||
IsometricBlockDrawer.lastTexId = -1;
|
||||
for( int i = 0; i < blocksTable.Length; i++ ) {
|
||||
int x, y;
|
||||
if( !GetCoords( i, out x, out y ) )
|
||||
continue;
|
||||
if( !GetCoords( i, out x, out y ) ) continue;
|
||||
|
||||
// We want to always draw the selected block on top of others
|
||||
if( i == selIndex ) continue;
|
||||
|
@ -55,9 +54,9 @@ namespace ClassicalSharp.Gui {
|
|||
}
|
||||
|
||||
if( blockInfoTexture.IsValid )
|
||||
blockInfoTexture.Render( graphicsApi );
|
||||
blockInfoTexture.Render( api );
|
||||
game.hudScreen.RenderHotbar( delta );
|
||||
graphicsApi.Texturing = false;
|
||||
api.Texturing = false;
|
||||
}
|
||||
|
||||
bool GetCoords( int i, out int x, out int y ) {
|
||||
|
@ -72,7 +71,7 @@ namespace ClassicalSharp.Gui {
|
|||
|
||||
public override void Dispose() {
|
||||
font.Dispose();
|
||||
graphicsApi.DeleteTexture( ref blockInfoTexture );
|
||||
api.DeleteTexture( ref blockInfoTexture );
|
||||
game.Events.BlockPermissionsChanged -= BlockPermissionsChanged;
|
||||
game.Keyboard.KeyRepeat = false;
|
||||
}
|
||||
|
@ -181,7 +180,7 @@ namespace ClassicalSharp.Gui {
|
|||
if( selIndex == lastCreatedIndex ) return;
|
||||
lastCreatedIndex = selIndex;
|
||||
|
||||
graphicsApi.DeleteTexture( ref blockInfoTexture );
|
||||
api.DeleteTexture( ref blockInfoTexture );
|
||||
if( selIndex == -1 ) return;
|
||||
|
||||
Block block = blocksTable[selIndex];
|
||||
|
@ -226,7 +225,9 @@ namespace ClassicalSharp.Gui {
|
|||
|
||||
public override bool HandlesMouseMove( int mouseX, int mouseY ) {
|
||||
if( draggingMouse ) {
|
||||
ScrollbarClick( mouseY );
|
||||
mouseY -= TableY;
|
||||
scrollY = (int)((mouseY - mouseOffset) / ScrollbarScale);
|
||||
ClampScrollY();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -252,7 +253,6 @@ namespace ClassicalSharp.Gui {
|
|||
return true;
|
||||
if( button == MouseButton.Left && mouseX >= TableX && mouseX < TableX + scrollbarWidth ) {
|
||||
ScrollbarClick( mouseY );
|
||||
draggingMouse = true;
|
||||
} else if( button == MouseButton.Left ) {
|
||||
if( selIndex != -1 )
|
||||
game.Inventory.HeldBlock = blocksTable[selIndex];
|
||||
|
|
|
@ -166,7 +166,7 @@ namespace ClassicalSharp.Gui {
|
|||
|
||||
DateTime received = game.Chat.Log[metadata[i]].Received;
|
||||
if( (now - received).TotalSeconds <= 10 )
|
||||
texture.Render( graphicsApi );
|
||||
texture.Render( api );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,7 @@ namespace ClassicalSharp.Gui {
|
|||
|
||||
y -= texture.Height;
|
||||
texture.Y1 = y;
|
||||
texture.Render( graphicsApi );
|
||||
texture.Render( api );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@ namespace ClassicalSharp.Gui {
|
|||
|
||||
int boxHeight = height + clientStatus.GetUsedHeight();
|
||||
if( boxHeight > 0 )
|
||||
graphicsApi.Draw2DQuad( x, y, width, boxHeight + 10, backColour );
|
||||
api.Draw2DQuad( x, y, width, boxHeight + 10, backColour );
|
||||
}
|
||||
|
||||
int inputOldHeight = -1;
|
||||
|
|
|
@ -21,10 +21,10 @@ namespace ClassicalSharp.Gui {
|
|||
|
||||
public override void Render( double delta ) {
|
||||
UpdateReconnectState();
|
||||
graphicsApi.Texturing = true;
|
||||
api.Texturing = true;
|
||||
for( int i = 0; i < widgets.Length; i++ )
|
||||
widgets[i].Render( delta );
|
||||
graphicsApi.Texturing = false;
|
||||
api.Texturing = false;
|
||||
}
|
||||
|
||||
int lastSecsLeft;
|
||||
|
@ -42,7 +42,7 @@ namespace ClassicalSharp.Gui {
|
|||
}
|
||||
|
||||
public override void Init() {
|
||||
graphicsApi.ClearColour( new FastColour( 65, 31, 31 ) );
|
||||
api.ClearColour( new FastColour( 65, 31, 31 ) );
|
||||
widgets = new Widget[] {
|
||||
ChatTextWidget.Create( game, 0, -30, title, Anchor.Centre, Anchor.Centre, titleFont ),
|
||||
ChatTextWidget.Create( game, 0, 10, message, Anchor.Centre, Anchor.Centre, messageFont ),
|
||||
|
|
|
@ -104,12 +104,12 @@ namespace ClassicalSharp.Gui {
|
|||
}
|
||||
|
||||
public override void Render( double delta ) {
|
||||
graphicsApi.Draw2DQuad( 0, 0, game.Width, game.Height, new FastColour( 60, 60, 60, 160 ) );
|
||||
graphicsApi.Texturing = true;
|
||||
api.Draw2DQuad( 0, 0, game.Width, game.Height, new FastColour( 60, 60, 60, 160 ) );
|
||||
api.Texturing = true;
|
||||
title.Render( delta );
|
||||
for( int i = 0; i < buttons.Length; i++ )
|
||||
buttons[i].Render( delta );
|
||||
graphicsApi.Texturing = false;
|
||||
api.Texturing = false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,14 +21,14 @@ namespace ClassicalSharp.Gui {
|
|||
UpdateFPS( delta );
|
||||
if( game.HideGui || !game.ShowFPS ) return;
|
||||
|
||||
graphicsApi.Texturing = true;
|
||||
api.Texturing = true;
|
||||
fpsTextWidget.Render( delta );
|
||||
if( !game.ClassicMode && game.activeScreen == null ) {
|
||||
UpdateHackState( false );
|
||||
DrawPosition();
|
||||
hackStatesWidget.Render( delta );
|
||||
}
|
||||
graphicsApi.Texturing = false;
|
||||
api.Texturing = false;
|
||||
}
|
||||
|
||||
double accumulator, maxDelta;
|
||||
|
@ -106,7 +106,7 @@ namespace ClassicalSharp.Gui {
|
|||
font.Dispose();
|
||||
posFont.Dispose();
|
||||
fpsTextWidget.Dispose();
|
||||
graphicsApi.DeleteTexture( ref posTexture );
|
||||
api.DeleteTexture( ref posTexture );
|
||||
game.Events.ChatFontChanged -= ChatFontChanged;
|
||||
}
|
||||
|
||||
|
@ -129,8 +129,8 @@ namespace ClassicalSharp.Gui {
|
|||
AddInt( pos.Z, ref index, false );
|
||||
AddChar( 14, ref index );
|
||||
|
||||
graphicsApi.BindTexture( posTexture.ID );
|
||||
graphicsApi.UpdateDynamicIndexedVb( DrawMode.Triangles,
|
||||
api.BindTexture( posTexture.ID );
|
||||
api.UpdateDynamicIndexedVb( DrawMode.Triangles,
|
||||
game.ModelCache.vb, game.ModelCache.vertices, index, index * 6 / 4 );
|
||||
}
|
||||
|
||||
|
|
|
@ -17,14 +17,14 @@ namespace ClassicalSharp.Gui {
|
|||
Font arrowFont, textFont;
|
||||
public override void Render( double delta ) {
|
||||
RenderMenuBounds();
|
||||
graphicsApi.Texturing = true;
|
||||
api.Texturing = true;
|
||||
RenderMenuWidgets( delta );
|
||||
|
||||
if( currentAction != null ) {
|
||||
currentAction.Render( delta );
|
||||
currentMoreInputLabel.Render( delta );
|
||||
}
|
||||
graphicsApi.Texturing = false;
|
||||
api.Texturing = false;
|
||||
}
|
||||
|
||||
public override bool HandlesMouseMove( int mouseX, int mouseY ) {
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace ClassicalSharp.Gui {
|
|||
bool showMinimal = game.GetActiveScreen != this;
|
||||
if( chat.HandlesAllInput )
|
||||
chat.RenderBackground();
|
||||
graphicsApi.Texturing = true;
|
||||
api.Texturing = true;
|
||||
chat.Render( delta );
|
||||
if( !showMinimal )
|
||||
RenderHotbar( delta );
|
||||
|
@ -39,7 +39,7 @@ namespace ClassicalSharp.Gui {
|
|||
}
|
||||
}
|
||||
|
||||
graphicsApi.Texturing = false;
|
||||
api.Texturing = false;
|
||||
if( playerList == null && !showMinimal )
|
||||
DrawCrosshairs();
|
||||
}
|
||||
|
@ -51,9 +51,9 @@ namespace ClassicalSharp.Gui {
|
|||
int curCol = 150 + (int)( 50 * Math.Abs( Math.Sin( game.accumulator ) ) );
|
||||
FastColour col = new FastColour( curCol, curCol, curCol );
|
||||
float centreX = game.Width / 2, centreY = game.Height / 2;
|
||||
graphicsApi.Draw2DQuad( centreX - crosshairExtent, centreY - crosshairWeight,
|
||||
api.Draw2DQuad( centreX - crosshairExtent, centreY - crosshairWeight,
|
||||
crosshairExtent * 2, crosshairWeight * 2, col );
|
||||
graphicsApi.Draw2DQuad( centreX - crosshairWeight, centreY - crosshairExtent,
|
||||
api.Draw2DQuad( centreX - crosshairWeight, centreY - crosshairExtent,
|
||||
crosshairWeight * 2, crosshairExtent * 2, col );
|
||||
}
|
||||
|
||||
|
|
|
@ -26,16 +26,16 @@ namespace ClassicalSharp.Gui {
|
|||
readonly FastColour progressCol = new FastColour( 128, 255, 128 );
|
||||
|
||||
public override void Render( double delta ) {
|
||||
graphicsApi.Texturing = true;
|
||||
api.Texturing = true;
|
||||
DrawBackground();
|
||||
titleWidget.Render( delta );
|
||||
messageWidget.Render( delta );
|
||||
graphicsApi.Texturing = false;
|
||||
api.Texturing = false;
|
||||
|
||||
int progX = game.Width / 2 - progWidth / 2;
|
||||
int progY = game.Height / 2 - progHeight / 2;
|
||||
graphicsApi.Draw2DQuad( progX, progY, progWidth, progHeight, backCol );
|
||||
graphicsApi.Draw2DQuad( progX, progY, progWidth * progress, progHeight, progressCol );
|
||||
api.Draw2DQuad( progX, progY, progWidth, progHeight, backCol );
|
||||
api.Draw2DQuad( progX, progY, progWidth * progress, progHeight, progressCol );
|
||||
}
|
||||
|
||||
void DrawBackground() {
|
||||
|
@ -75,17 +75,17 @@ namespace ClassicalSharp.Gui {
|
|||
if( index == 0 ) return;
|
||||
if( !bound ) {
|
||||
bound = true;
|
||||
graphicsApi.BindTexture( game.TerrainAtlas1D.TexIds[atlasIndex] );
|
||||
api.BindTexture( game.TerrainAtlas1D.TexIds[atlasIndex] );
|
||||
}
|
||||
|
||||
ModelCache cache = game.ModelCache;
|
||||
graphicsApi.SetBatchFormat( VertexFormat.Pos3fTex2fCol4b );
|
||||
graphicsApi.UpdateDynamicIndexedVb( DrawMode.Triangles, cache.vb, cache.vertices, index, index * 6 / 4 );
|
||||
api.SetBatchFormat( VertexFormat.Pos3fTex2fCol4b );
|
||||
api.UpdateDynamicIndexedVb( DrawMode.Triangles, cache.vb, cache.vertices, index, index * 6 / 4 );
|
||||
index = 0;
|
||||
}
|
||||
|
||||
public override void Init() {
|
||||
graphicsApi.Fog = false;
|
||||
api.Fog = false;
|
||||
SetTitle( serverName );
|
||||
SetMessage( serverMotd );
|
||||
game.WorldEvents.MapLoading += MapLoading;
|
||||
|
|
|
@ -20,13 +20,13 @@ namespace ClassicalSharp.Gui {
|
|||
|
||||
public override void Render( double delta ) {
|
||||
RenderMenuBounds();
|
||||
graphicsApi.Texturing = true;
|
||||
api.Texturing = true;
|
||||
RenderMenuWidgets( delta );
|
||||
for( int i = 0; i < inputs.Length; i++ )
|
||||
inputs[i].Render( delta );
|
||||
for( int i = 0; i < labels.Length; i++ )
|
||||
labels[i].Render( delta );
|
||||
graphicsApi.Texturing = false;
|
||||
api.Texturing = false;
|
||||
}
|
||||
|
||||
public override bool HandlesMouseClick( int mouseX, int mouseY, MouseButton button ) {
|
||||
|
@ -72,9 +72,9 @@ namespace ClassicalSharp.Gui {
|
|||
TextWidget.Create( game, 0, -130, "Generate new level", Anchor.Centre, Anchor.Centre, titleFont ),
|
||||
};
|
||||
widgets = new [] {
|
||||
ButtonWidget.Create( game, -90, 100, 120, 35, "Flatgrass", Anchor.Centre,
|
||||
ButtonWidget.Create( game, -90, 100, 130, 35, "Flatgrass", Anchor.Centre,
|
||||
Anchor.Centre, titleFont, GenFlatgrassClick ),
|
||||
ButtonWidget.Create( game, 90, 100, 120, 35, "Vanilla", Anchor.Centre,
|
||||
ButtonWidget.Create( game, 90, 100, 130, 35, "Vanilla", Anchor.Centre,
|
||||
Anchor.Centre, titleFont, GenNotchyClick ),
|
||||
MakeBack( false, titleFont,
|
||||
(g, w) => g.SetNewScreen( new PauseScreen( g ) ) ),
|
||||
|
|
|
@ -11,10 +11,10 @@ namespace ClassicalSharp.Gui {
|
|||
|
||||
public override void Render( double delta ) {
|
||||
RenderMenuBounds();
|
||||
graphicsApi.Texturing = true;
|
||||
api.Texturing = true;
|
||||
RenderMenuWidgets( delta );
|
||||
statusWidget.Render( delta );
|
||||
graphicsApi.Texturing = false;
|
||||
api.Texturing = false;
|
||||
}
|
||||
|
||||
Font keyFont;
|
||||
|
|
|
@ -22,10 +22,10 @@ namespace ClassicalSharp.Gui {
|
|||
if( extendedHelp != null && extEndY <= widgets[widgets.Length - 3].Y ) {
|
||||
int x = game.Width / 2 - tableWidth / 2 - 5;
|
||||
int y = game.Height / 2 + extHelpY - 5;
|
||||
graphicsApi.Draw2DQuad( x, y, tableWidth + 10, tableHeight + 10, tableCol );
|
||||
api.Draw2DQuad( x, y, tableWidth + 10, tableHeight + 10, tableCol );
|
||||
}
|
||||
|
||||
graphicsApi.Texturing = true;
|
||||
api.Texturing = true;
|
||||
RenderMenuWidgets( delta );
|
||||
if( inputWidget != null )
|
||||
inputWidget.Render( delta );
|
||||
|
@ -34,7 +34,7 @@ namespace ClassicalSharp.Gui {
|
|||
for( int i = 0; i < extendedHelp.Length; i++ )
|
||||
extendedHelp[i].Render( delta );
|
||||
}
|
||||
graphicsApi.Texturing = false;
|
||||
api.Texturing = false;
|
||||
}
|
||||
|
||||
public override void Init() {
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace ClassicalSharp.Gui {
|
|||
protected Font titleFont, regularFont;
|
||||
|
||||
protected void RenderMenuBounds() {
|
||||
graphicsApi.Draw2DQuad( 0, 0, game.Width, game.Height, new FastColour( 60, 60, 60, 160 ) );
|
||||
api.Draw2DQuad( 0, 0, game.Width, game.Height, new FastColour( 60, 60, 60, 160 ) );
|
||||
}
|
||||
|
||||
protected void RenderMenuWidgets( double delta ) {
|
||||
|
|
|
@ -59,9 +59,9 @@ namespace ClassicalSharp.Gui {
|
|||
|
||||
public override void Render( double delta ) {
|
||||
base.Render( delta );
|
||||
graphicsApi.Texturing = true;
|
||||
api.Texturing = true;
|
||||
infoWidget.Render( delta );
|
||||
graphicsApi.Texturing = false;
|
||||
api.Texturing = false;
|
||||
}
|
||||
|
||||
public override void Dispose() {
|
||||
|
|
|
@ -14,11 +14,11 @@ namespace ClassicalSharp.Gui {
|
|||
|
||||
public override void Render( double delta ) {
|
||||
RenderMenuBounds();
|
||||
graphicsApi.Texturing = true;
|
||||
api.Texturing = true;
|
||||
RenderMenuWidgets( delta );
|
||||
if( descWidget != null )
|
||||
descWidget.Render( delta );
|
||||
graphicsApi.Texturing = false;
|
||||
api.Texturing = false;
|
||||
}
|
||||
|
||||
public override void Init() {
|
||||
|
|
|
@ -12,9 +12,9 @@ namespace ClassicalSharp.Gui {
|
|||
|
||||
public override void Render( double delta ) {
|
||||
RenderMenuBounds();
|
||||
graphicsApi.Texturing = true;
|
||||
api.Texturing = true;
|
||||
RenderMenuWidgets( delta );
|
||||
graphicsApi.Texturing = false;
|
||||
api.Texturing = false;
|
||||
}
|
||||
|
||||
public override void Init() {
|
||||
|
|
|
@ -17,12 +17,12 @@ namespace ClassicalSharp.Gui {
|
|||
|
||||
public override void Render( double delta ) {
|
||||
RenderMenuBounds();
|
||||
graphicsApi.Texturing = true;
|
||||
api.Texturing = true;
|
||||
RenderMenuWidgets( delta );
|
||||
inputWidget.Render( delta );
|
||||
if( descWidget != null )
|
||||
descWidget.Render( delta );
|
||||
graphicsApi.Texturing = false;
|
||||
api.Texturing = false;
|
||||
|
||||
if( textPath != null ) {
|
||||
SaveMap( textPath );
|
||||
|
|
|
@ -78,11 +78,11 @@ namespace ClassicalSharp.Gui {
|
|||
|
||||
public override void Render( double delta ) {
|
||||
RenderMenuBounds();
|
||||
graphicsApi.Texturing = true;
|
||||
api.Texturing = true;
|
||||
RenderMenuWidgets( delta );
|
||||
for( int i = 0; i < labels.Length; i++ )
|
||||
labels[i].Render( delta );
|
||||
graphicsApi.Texturing = false;
|
||||
api.Texturing = false;
|
||||
|
||||
if( renderFrame != null )
|
||||
renderFrame( this );
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace ClassicalSharp.Gui {
|
|||
}
|
||||
|
||||
public override void Render( double delta ) {
|
||||
graphicsApi.Texturing = true;
|
||||
api.Texturing = true;
|
||||
RenderHotbar();
|
||||
IsometricBlockDrawer.lastTexId = -1;
|
||||
|
||||
|
@ -49,20 +49,20 @@ namespace ClassicalSharp.Gui {
|
|||
float scale = (elemSize * 13.5f/16f) / 2f;
|
||||
IsometricBlockDrawer.Draw( game, block, scale, x, y );
|
||||
}
|
||||
graphicsApi.Texturing = false;
|
||||
api.Texturing = false;
|
||||
}
|
||||
|
||||
void RenderHotbar() {
|
||||
int texId = game.UseClassicGui ? game.GuiClassicTexId : game.GuiTexId;
|
||||
backTex.ID = texId;
|
||||
backTex.Render( graphicsApi );
|
||||
backTex.Render( api );
|
||||
|
||||
int i = game.Inventory.HeldBlockIndex;
|
||||
int x = (int)(X + barXOffset + (elemSize + borderSize) * i + elemSize / 2);
|
||||
|
||||
selTex.ID = texId;
|
||||
selTex.X1 = (int)(x - selBlockSize / 2);
|
||||
graphicsApi.Draw2DTexture( ref selTex );
|
||||
api.Draw2DTexture( ref selTex );
|
||||
}
|
||||
|
||||
public override void Dispose() { }
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace ClassicalSharp.Gui {
|
|||
new TextureRec( 0, 46/256f, 200/256f, 20/256f ) );
|
||||
public string Text;
|
||||
public void SetText( string text ) {
|
||||
graphicsApi.DeleteTexture( ref texture );
|
||||
api.DeleteTexture( ref texture );
|
||||
Text = text;
|
||||
if( String.IsNullOrEmpty( text ) ) {
|
||||
texture = new Texture();
|
||||
|
@ -71,14 +71,14 @@ namespace ClassicalSharp.Gui {
|
|||
backTex.X1 = X; backTex.Y1 = Y;
|
||||
backTex.Width = Width; backTex.Height = Height;
|
||||
|
||||
backTex.Render( graphicsApi );
|
||||
backTex.Render( api );
|
||||
FastColour col = Active ? FastColour.White : new FastColour( 200, 200, 200 );
|
||||
if( Disabled ) col = new FastColour( 150, 150, 150 );
|
||||
texture.Render( graphicsApi, col );
|
||||
texture.Render( api, col );
|
||||
}
|
||||
|
||||
public override void Dispose() {
|
||||
graphicsApi.DeleteTexture( ref texture );
|
||||
api.DeleteTexture( ref texture );
|
||||
}
|
||||
|
||||
public override void MoveTo( int newX, int newY ) {
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace ClassicalSharp.Gui {
|
|||
}
|
||||
|
||||
public override void Render( double delta ) {
|
||||
texture.Render( graphicsApi );
|
||||
texture.Render( api );
|
||||
}
|
||||
|
||||
public override void Init() {
|
||||
|
@ -111,7 +111,7 @@ namespace ClassicalSharp.Gui {
|
|||
}
|
||||
|
||||
public override void Dispose() {
|
||||
graphicsApi.DeleteTexture( ref texture );
|
||||
api.DeleteTexture( ref texture );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -27,7 +27,7 @@ namespace ClassicalSharp.Gui {
|
|||
}
|
||||
|
||||
public override void SetText( string text ) {
|
||||
graphicsApi.DeleteTexture( ref texture );
|
||||
api.DeleteTexture( ref texture );
|
||||
if( String.IsNullOrEmpty( text ) ) {
|
||||
texture = new Texture();
|
||||
Height = defaultHeight;
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace ClassicalSharp.Gui {
|
|||
public sealed partial class TextGroupWidget : Widget {
|
||||
|
||||
public void SetText( int index, string text ) {
|
||||
graphicsApi.DeleteTexture( ref Textures[index] );
|
||||
api.DeleteTexture( ref Textures[index] );
|
||||
DrawTextArgs args = new DrawTextArgs( text, font, true );
|
||||
linkData[index] = default(LinkData);
|
||||
LinkFlags prevFlags = index > 0 ? linkData[index - 1].flags : 0;
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace ClassicalSharp.Gui {
|
|||
|
||||
public void PushUpAndReplaceLast( string text ) {
|
||||
int y = Y;
|
||||
graphicsApi.DeleteTexture( ref Textures[0] );
|
||||
api.DeleteTexture( ref Textures[0] );
|
||||
for( int i = 0; i < Textures.Length - 1; i++ ) {
|
||||
Textures[i] = Textures[i + 1];
|
||||
lines[i] = lines[i + 1];
|
||||
|
@ -115,13 +115,13 @@ namespace ClassicalSharp.Gui {
|
|||
for( int i = 0; i < Textures.Length; i++ ) {
|
||||
Texture texture = Textures[i];
|
||||
if( texture.IsValid )
|
||||
texture.Render( graphicsApi );
|
||||
texture.Render( api );
|
||||
}
|
||||
}
|
||||
|
||||
public override void Dispose() {
|
||||
for( int i = 0; i < Textures.Length; i++ )
|
||||
graphicsApi.DeleteTexture( ref Textures[i] );
|
||||
api.DeleteTexture( ref Textures[i] );
|
||||
}
|
||||
|
||||
public override void MoveTo( int newX, int newY ) {
|
||||
|
|
|
@ -40,20 +40,20 @@ namespace ClassicalSharp.Gui {
|
|||
FastColour caretCol;
|
||||
static FastColour backColour = new FastColour( 60, 60, 60, 200 );
|
||||
public override void Render( double delta ) {
|
||||
graphicsApi.Texturing = false;
|
||||
api.Texturing = false;
|
||||
int y = Y, x = X;
|
||||
for( int i = 0; i < sizes.Length; i++ ) {
|
||||
bool caretAtEnd = caretTex.Y1 == y && (indexX == LineLength || caretPos == -1);
|
||||
int offset = caretAtEnd ? defaultWidth : 0;
|
||||
graphicsApi.Draw2DQuad( x + 5, y, sizes[i].Width + offset, sizes[i].Height, backColour );
|
||||
api.Draw2DQuad( x + 5, y, sizes[i].Width + offset, sizes[i].Height, backColour );
|
||||
y += sizes[i].Height;
|
||||
}
|
||||
if( sizes.Length == 0 || sizes[0] == Size.Empty )
|
||||
graphicsApi.Draw2DQuad( x + 5, y, defaultWidth, defaultHeight, backColour );
|
||||
graphicsApi.Texturing = true;
|
||||
api.Draw2DQuad( x + 5, y, defaultWidth, defaultHeight, backColour );
|
||||
api.Texturing = true;
|
||||
|
||||
inputTex.Render( graphicsApi );
|
||||
caretTex.Render( graphicsApi, caretCol );
|
||||
inputTex.Render( api );
|
||||
caretTex.Render( api, caretCol );
|
||||
if( altText.Active )
|
||||
altText.Render( delta );
|
||||
}
|
||||
|
@ -169,12 +169,12 @@ namespace ClassicalSharp.Gui {
|
|||
}
|
||||
|
||||
public override void Dispose() {
|
||||
graphicsApi.DeleteTexture( ref inputTex );
|
||||
api.DeleteTexture( ref inputTex );
|
||||
}
|
||||
|
||||
public void DisposeFully() {
|
||||
Dispose();
|
||||
graphicsApi.DeleteTexture( ref caretTex );
|
||||
api.DeleteTexture( ref caretTex );
|
||||
}
|
||||
|
||||
public override void MoveTo( int newX, int newY ) {
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace ClassicalSharp.Gui {
|
|||
|
||||
double accumulator;
|
||||
public override void Render( double delta ) {
|
||||
chatInputTexture.Render( graphicsApi );
|
||||
chatInputTexture.Render( api );
|
||||
//if( (accumulator % 1) < 0.5 && Active ) {
|
||||
// chatCaretTexture.Y1 = chatInputTexture.Y1 + yOffset;
|
||||
// chatCaretTexture.Render( graphicsApi );
|
||||
|
@ -101,8 +101,8 @@ namespace ClassicalSharp.Gui {
|
|||
}
|
||||
|
||||
public override void Dispose() {
|
||||
graphicsApi.DeleteTexture( ref chatCaretTexture );
|
||||
graphicsApi.DeleteTexture( ref chatInputTexture );
|
||||
api.DeleteTexture( ref chatCaretTexture );
|
||||
api.DeleteTexture( ref chatInputTexture );
|
||||
}
|
||||
|
||||
public override void MoveTo( int newX, int newY ) {
|
||||
|
@ -129,7 +129,7 @@ namespace ClassicalSharp.Gui {
|
|||
chatInputText.DeleteAt( chatInputText.Length - 1 );
|
||||
return true;
|
||||
}
|
||||
graphicsApi.DeleteTexture( ref chatInputTexture );
|
||||
api.DeleteTexture( ref chatInputTexture );
|
||||
SetText( chatInputText.ToString() );
|
||||
}
|
||||
return true;
|
||||
|
@ -138,7 +138,7 @@ namespace ClassicalSharp.Gui {
|
|||
public override bool HandlesKeyDown( Key key ) {
|
||||
if( key == Key.BackSpace && !chatInputText.Empty ) {
|
||||
chatInputText.DeleteAt( chatInputText.Length - 1 );
|
||||
graphicsApi.DeleteTexture( ref chatInputTexture );
|
||||
api.DeleteTexture( ref chatInputTexture );
|
||||
SetText( chatInputText.ToString() );
|
||||
}
|
||||
return key < Key.F1 || key > Key.F35;
|
||||
|
|
|
@ -63,12 +63,12 @@ namespace ClassicalSharp.Gui {
|
|||
}
|
||||
|
||||
public override void Render( double delta ) {
|
||||
graphicsApi.Texturing = false;
|
||||
api.Texturing = false;
|
||||
int offset = overview.Height;
|
||||
int height = namesPerColumn * (elemHeight + 1) + boundsSize * 2 + offset;
|
||||
graphicsApi.Draw2DQuad( X, Y - offset, Width, height, lightTableCol );
|
||||
api.Draw2DQuad( X, Y - offset, Width, height, lightTableCol );
|
||||
|
||||
graphicsApi.Texturing = true;
|
||||
api.Texturing = true;
|
||||
overview.MoveTo( game.Width / 2 - overview.Width / 2,
|
||||
Y - offset + boundsSize / 2 );
|
||||
overview.Render( delta );
|
||||
|
@ -76,7 +76,7 @@ namespace ClassicalSharp.Gui {
|
|||
for( int i = 0; i < namesCount; i++ ) {
|
||||
Texture texture = textures[i];
|
||||
if( texture.IsValid )
|
||||
texture.Render( graphicsApi );
|
||||
texture.Render( api );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ namespace ClassicalSharp.Gui {
|
|||
if( pInfo.Id != e.Id ) continue;
|
||||
|
||||
Texture tex = textures[i];
|
||||
graphicsApi.DeleteTexture( ref tex );
|
||||
api.DeleteTexture( ref tex );
|
||||
AddPlayerInfo( new PlayerInfo( game.CpePlayersList[e.Id] ), i );
|
||||
SortPlayerInfo();
|
||||
return;
|
||||
|
|
|
@ -73,7 +73,7 @@ namespace ClassicalSharp.Gui {
|
|||
PlayerInfo pInfo = info[i];
|
||||
if( !pInfo.IsGroup && pInfo.NameId == e.Id ) {
|
||||
Texture tex = textures[i];
|
||||
graphicsApi.DeleteTexture( ref tex );
|
||||
api.DeleteTexture( ref tex );
|
||||
AddPlayerInfo( game.CpePlayersList[e.Id], i );
|
||||
SortPlayerInfo();
|
||||
return;
|
||||
|
@ -151,7 +151,7 @@ namespace ClassicalSharp.Gui {
|
|||
}
|
||||
|
||||
void DeleteGroup( ref int i ) {
|
||||
graphicsApi.DeleteTexture( ref textures[i] );
|
||||
api.DeleteTexture( ref textures[i] );
|
||||
RemoveItemAt( info, i );
|
||||
RemoveItemAt( textures, i );
|
||||
|
||||
|
|
|
@ -30,13 +30,13 @@ namespace ClassicalSharp.Gui {
|
|||
public abstract string GetNameUnder( int mouseX, int mouseY );
|
||||
|
||||
public override void Render( double delta ) {
|
||||
graphicsApi.Texturing = false;
|
||||
graphicsApi.Draw2DQuad( X, Y, Width, Height, tableCol );
|
||||
graphicsApi.Texturing = true;
|
||||
api.Texturing = false;
|
||||
api.Draw2DQuad( X, Y, Width, Height, tableCol );
|
||||
api.Texturing = true;
|
||||
for( int i = 0; i < namesCount; i++ ) {
|
||||
Texture texture = textures[i];
|
||||
if( texture.IsValid ) {
|
||||
texture.Render( graphicsApi );
|
||||
texture.Render( api );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ namespace ClassicalSharp.Gui {
|
|||
public override void Dispose() {
|
||||
for( int i = 0; i < namesCount; i++ ) {
|
||||
Texture tex = textures[i];
|
||||
graphicsApi.DeleteTexture( ref tex );
|
||||
api.DeleteTexture( ref tex );
|
||||
textures[i] = tex;
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ namespace ClassicalSharp.Gui {
|
|||
|
||||
protected void RemoveInfoAt<T>( T[] info, int i ) {
|
||||
Texture tex = textures[i];
|
||||
graphicsApi.DeleteTexture( ref tex );
|
||||
api.DeleteTexture( ref tex );
|
||||
RemoveItemAt( info, i );
|
||||
RemoveItemAt( textures, i );
|
||||
namesCount--;
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace ClassicalSharp.Gui {
|
|||
}
|
||||
|
||||
public virtual void SetText( string text ) {
|
||||
graphicsApi.DeleteTexture( ref texture );
|
||||
api.DeleteTexture( ref texture );
|
||||
if( String.IsNullOrEmpty( text ) ) {
|
||||
texture = new Texture();
|
||||
Height = defaultHeight;
|
||||
|
@ -51,11 +51,11 @@ namespace ClassicalSharp.Gui {
|
|||
|
||||
public override void Render( double delta ) {
|
||||
if( texture.IsValid )
|
||||
texture.Render( graphicsApi );
|
||||
texture.Render( api );
|
||||
}
|
||||
|
||||
public override void Dispose() {
|
||||
graphicsApi.DeleteTexture( ref texture );
|
||||
api.DeleteTexture( ref texture );
|
||||
}
|
||||
|
||||
public override void MoveTo( int newX, int newY ) {
|
||||
|
|
Loading…
Reference in a new issue