mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 18:45:23 -04:00
Fix bug with tab list when help down from map change (Thanks 123DMWM), don't show sides/edge block if it is air, add basis for new colours/emotes gui.
This commit is contained in:
parent
48c8035094
commit
c5a1f5a27e
@ -279,6 +279,11 @@ namespace ClassicalSharp {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool HandlesMouseClick( int mouseX, int mouseY, MouseButton button ) {
|
||||||
|
if( !HandlesAllInput ) return false;
|
||||||
|
return textInput.HandlesMouseClick( mouseX, mouseY, button );
|
||||||
|
}
|
||||||
|
|
||||||
void ResetIndex() {
|
void ResetIndex() {
|
||||||
int maxIndex = game.Chat.Log.Count - chatLines;
|
int maxIndex = game.Chat.Log.Count - chatLines;
|
||||||
int minIndex = Math.Min( 0, maxIndex );
|
int minIndex = Math.Min( 0, maxIndex );
|
||||||
|
@ -94,6 +94,13 @@ namespace ClassicalSharp {
|
|||||||
chat.Init();
|
chat.Init();
|
||||||
hotbar = new BlockHotbarWidget( game );
|
hotbar = new BlockHotbarWidget( game );
|
||||||
hotbar.Init();
|
hotbar.Init();
|
||||||
|
game.Events.OnNewMap += OnNewMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnNewMap( object sender, EventArgs e ) {
|
||||||
|
if( playerList != null )
|
||||||
|
playerList.Dispose();
|
||||||
|
playerList = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool HandlesAllInput {
|
public override bool HandlesAllInput {
|
||||||
@ -142,10 +149,11 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override bool HandlesMouseClick( int mouseX, int mouseY, MouseButton button ) {
|
public override bool HandlesMouseClick( int mouseX, int mouseY, MouseButton button ) {
|
||||||
if( button != MouseButton.Left || playerList == null || !HandlesAllInput ) return false;
|
if( button != MouseButton.Left || !HandlesAllInput ) return false;
|
||||||
|
|
||||||
string name = playerList.GetNameUnder( mouseX, mouseY );
|
string name;
|
||||||
if( name == null ) return false;
|
if( playerList == null || (name = playerList.GetNameUnder( mouseX, mouseY )) == null )
|
||||||
|
return chat.HandlesMouseClick( mouseX, mouseY, button );
|
||||||
chat.AppendTextToInput( name + " " );
|
chat.AppendTextToInput( name + " " );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
75
ClassicalSharp/2D/Widgets/Chat/AltTextInputWidget.cs
Normal file
75
ClassicalSharp/2D/Widgets/Chat/AltTextInputWidget.cs
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
using OpenTK.Input;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace ClassicalSharp {
|
||||||
|
|
||||||
|
public sealed partial class AltTextInputWidget : Widget {
|
||||||
|
|
||||||
|
public AltTextInputWidget( Game game, Font font, Font boldFont, TextInputWidget parent ) : base( game ) {
|
||||||
|
HorizontalAnchor = Anchor.LeftOrTop;
|
||||||
|
VerticalAnchor = Anchor.LeftOrTop;
|
||||||
|
this.font = font;
|
||||||
|
this.boldFont = boldFont;
|
||||||
|
this.parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
Texture chatInputTexture;
|
||||||
|
readonly Font font, boldFont;
|
||||||
|
TextInputWidget parent;
|
||||||
|
Size partSize;
|
||||||
|
|
||||||
|
public override void Render( double delta ) {
|
||||||
|
chatInputTexture.Render( graphicsApi );
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Init() {
|
||||||
|
X = 5; Y = 45;
|
||||||
|
DrawString();
|
||||||
|
}
|
||||||
|
|
||||||
|
static FastColour backColour = new FastColour( 60, 60, 60, 200 );
|
||||||
|
void DrawString() {
|
||||||
|
DrawTextArgs args = new DrawTextArgs( "Text ", font, false );
|
||||||
|
partSize = game.Drawer2D.MeasureChatSize( ref args );
|
||||||
|
Size size = new Size( partSize.Width * 6, partSize.Height * 3 );
|
||||||
|
|
||||||
|
using( Bitmap bmp = IDrawer2D.CreatePow2Bitmap( size ) ) {
|
||||||
|
using( IDrawer2D drawer = game.Drawer2D ) {
|
||||||
|
drawer.SetBitmap( bmp );
|
||||||
|
drawer.Clear( backColour, 0, 0, size.Width, size.Height );
|
||||||
|
for( int code = 0; code <= 15; code++ ) {
|
||||||
|
int c = code < 10 ? '0' + code : 'a' + (code - 10);
|
||||||
|
args.Text = "&" + (char)c + "Text";
|
||||||
|
|
||||||
|
int x = (code % 6);
|
||||||
|
int y = (code / 6);
|
||||||
|
drawer.DrawChatText( ref args, x * partSize.Width, y * partSize.Height );
|
||||||
|
}
|
||||||
|
chatInputTexture = drawer.Make2DTexture( bmp, size, X, Y );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Height = size.Height;
|
||||||
|
Width = size.Width;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool HandlesMouseClick( int mouseX, int mouseY, MouseButton button ) {
|
||||||
|
mouseX -= X; mouseY -= Y;
|
||||||
|
mouseX /= partSize.Width; mouseY /= partSize.Height;
|
||||||
|
game.Chat.Add( "CLICKY CLICK" + mouseX + "," + mouseY );
|
||||||
|
|
||||||
|
int code = mouseY * 6 + mouseX;
|
||||||
|
if( code <= 15 ) {
|
||||||
|
int c = code < 10 ? '0' + code : 'a' + (code - 10);
|
||||||
|
string text = "&" + (char)c;
|
||||||
|
parent.AppendText( text );
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Dispose() {
|
||||||
|
graphicsApi.DeleteTexture( ref chatInputTexture );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -36,6 +36,12 @@ namespace ClassicalSharp {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool HandlesMouseClick( int mouseX, int mouseY, MouseButton button ) {
|
||||||
|
//if( altText.Bounds.Contains( mouseX, mouseY ) )
|
||||||
|
// altText.HandlesMouseClick( mouseX, mouseY, button );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void BackspaceKey() {
|
void BackspaceKey() {
|
||||||
if( !chatInputText.Empty && caretPos != 0 ) {
|
if( !chatInputText.Empty && caretPos != 0 ) {
|
||||||
if( caretPos == -1 ) {
|
if( caretPos == -1 ) {
|
||||||
|
@ -9,6 +9,7 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
const int len = 64 * 3;
|
const int len = 64 * 3;
|
||||||
const int lines = 3;
|
const int lines = 3;
|
||||||
|
//AltTextInputWidget altText;
|
||||||
public TextInputWidget( Game game, Font font, Font boldFont ) : base( game ) {
|
public TextInputWidget( Game game, Font font, Font boldFont ) : base( game ) {
|
||||||
HorizontalAnchor = Anchor.LeftOrTop;
|
HorizontalAnchor = Anchor.LeftOrTop;
|
||||||
VerticalAnchor = Anchor.BottomOrRight;
|
VerticalAnchor = Anchor.BottomOrRight;
|
||||||
@ -35,6 +36,7 @@ namespace ClassicalSharp {
|
|||||||
public override void Render( double delta ) {
|
public override void Render( double delta ) {
|
||||||
chatInputTexture.Render( graphicsApi );
|
chatInputTexture.Render( graphicsApi );
|
||||||
caretTexture.Render( graphicsApi, caretCol );
|
caretTexture.Render( graphicsApi, caretCol );
|
||||||
|
//altText.Render( delta );
|
||||||
}
|
}
|
||||||
|
|
||||||
string[] parts = new string[lines];
|
string[] parts = new string[lines];
|
||||||
@ -43,6 +45,8 @@ namespace ClassicalSharp {
|
|||||||
int maxWidth = 0;
|
int maxWidth = 0;
|
||||||
|
|
||||||
public override void Init() {
|
public override void Init() {
|
||||||
|
//altText = new AltTextInputWidget( game, font, boldFont, this );
|
||||||
|
//altText.Init();
|
||||||
X = 5;
|
X = 5;
|
||||||
DrawTextArgs args = new DrawTextArgs( "_", boldFont, false );
|
DrawTextArgs args = new DrawTextArgs( "_", boldFont, false );
|
||||||
caretTexture = game.Drawer2D.UseBitmappedChat ?
|
caretTexture = game.Drawer2D.UseBitmappedChat ?
|
||||||
@ -133,6 +137,7 @@ namespace ClassicalSharp {
|
|||||||
public override void Dispose() {
|
public override void Dispose() {
|
||||||
graphicsApi.DeleteTexture( ref caretTexture );
|
graphicsApi.DeleteTexture( ref caretTexture );
|
||||||
graphicsApi.DeleteTexture( ref chatInputTexture );
|
graphicsApi.DeleteTexture( ref chatInputTexture );
|
||||||
|
//altText.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void MoveTo( int newX, int newY ) {
|
public override void MoveTo( int newX, int newY ) {
|
||||||
|
@ -106,6 +106,7 @@
|
|||||||
<Compile Include="2D\Texture.cs" />
|
<Compile Include="2D\Texture.cs" />
|
||||||
<Compile Include="2D\Widgets\BlockHotbarWidget.cs" />
|
<Compile Include="2D\Widgets\BlockHotbarWidget.cs" />
|
||||||
<Compile Include="2D\Widgets\Chat\ChatTextWidget.cs" />
|
<Compile Include="2D\Widgets\Chat\ChatTextWidget.cs" />
|
||||||
|
<Compile Include="2D\Widgets\Chat\AltTextInputWidget.cs" />
|
||||||
<Compile Include="2D\Widgets\Chat\TextGroupWidget.cs" />
|
<Compile Include="2D\Widgets\Chat\TextGroupWidget.cs" />
|
||||||
<Compile Include="2D\Widgets\Chat\TextInputWidget.cs" />
|
<Compile Include="2D\Widgets\Chat\TextInputWidget.cs" />
|
||||||
<Compile Include="2D\Widgets\Chat\TextInputWidget.Handlers.cs" />
|
<Compile Include="2D\Widgets\Chat\TextInputWidget.Handlers.cs" />
|
||||||
@ -198,7 +199,7 @@
|
|||||||
<Compile Include="Rendering\MapRenderer.Rendering.cs" />
|
<Compile Include="Rendering\MapRenderer.Rendering.cs" />
|
||||||
<Compile Include="Rendering\MinimalEnvRenderer.cs" />
|
<Compile Include="Rendering\MinimalEnvRenderer.cs" />
|
||||||
<Compile Include="Rendering\FrustumCulling.cs" />
|
<Compile Include="Rendering\FrustumCulling.cs" />
|
||||||
<Compile Include="Rendering\MapEnvRenderer.cs" />
|
<Compile Include="Rendering\MapBordersRenderer.cs" />
|
||||||
<Compile Include="Rendering\MapRenderer.cs" />
|
<Compile Include="Rendering\MapRenderer.cs" />
|
||||||
<Compile Include="Rendering\PickingRenderer.cs" />
|
<Compile Include="Rendering\PickingRenderer.cs" />
|
||||||
<Compile Include="Rendering\StandardEnvRenderer.cs" />
|
<Compile Include="Rendering\StandardEnvRenderer.cs" />
|
||||||
|
@ -152,7 +152,7 @@ namespace ClassicalSharp.Commands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SetNewRenderType( bool legacy, bool minimal ) {
|
void SetNewRenderType( bool legacy, bool minimal ) {
|
||||||
game.MapEnvRenderer.SetUseLegacyMode( legacy );
|
game.MapBordersRenderer.SetUseLegacyMode( legacy );
|
||||||
if( minimal ) {
|
if( minimal ) {
|
||||||
game.EnvRenderer.Dispose();
|
game.EnvRenderer.Dispose();
|
||||||
game.EnvRenderer = new MinimalEnvRenderer( game );
|
game.EnvRenderer = new MinimalEnvRenderer( game );
|
||||||
|
@ -48,7 +48,7 @@ namespace ClassicalSharp {
|
|||||||
public virtual BoundingBox CollisionBounds {
|
public virtual BoundingBox CollisionBounds {
|
||||||
get {
|
get {
|
||||||
Vector3 pos = Position;
|
Vector3 pos = Position;
|
||||||
Vector3 size = Model.CollisionSize;
|
Vector3 size = CollisionSize;
|
||||||
return new BoundingBox( pos.X - size.X / 2, pos.Y, pos.Z - size.Z / 2,
|
return new BoundingBox( pos.X - size.X / 2, pos.Y, pos.Z - size.Z / 2,
|
||||||
pos.X + size.X / 2, pos.Y + size.Y, pos.Z + size.Z / 2 );
|
pos.X + size.X / 2, pos.Y + size.Y, pos.Z + size.Z / 2 );
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ namespace ClassicalSharp {
|
|||||||
public int ChunkUpdates;
|
public int ChunkUpdates;
|
||||||
|
|
||||||
public MapRenderer MapRenderer;
|
public MapRenderer MapRenderer;
|
||||||
public MapEnvRenderer MapEnvRenderer;
|
public MapBordersRenderer MapBordersRenderer;
|
||||||
public EnvRenderer EnvRenderer;
|
public EnvRenderer EnvRenderer;
|
||||||
public WeatherRenderer WeatherRenderer;
|
public WeatherRenderer WeatherRenderer;
|
||||||
public Inventory Inventory;
|
public Inventory Inventory;
|
||||||
@ -141,7 +141,7 @@ namespace ClassicalSharp {
|
|||||||
width = Width;
|
width = Width;
|
||||||
height = Height;
|
height = Height;
|
||||||
MapRenderer = new MapRenderer( this );
|
MapRenderer = new MapRenderer( this );
|
||||||
MapEnvRenderer = new MapEnvRenderer( this );
|
MapBordersRenderer = new MapBordersRenderer( this );
|
||||||
EnvRenderer = new StandardEnvRenderer( this );
|
EnvRenderer = new StandardEnvRenderer( this );
|
||||||
if( IPAddress == null ) {
|
if( IPAddress == null ) {
|
||||||
Network = new Singleplayer.SinglePlayerServer( this );
|
Network = new Singleplayer.SinglePlayerServer( this );
|
||||||
@ -174,7 +174,7 @@ namespace ClassicalSharp {
|
|||||||
hudScreen.Init();
|
hudScreen.Init();
|
||||||
Culling = new FrustumCulling();
|
Culling = new FrustumCulling();
|
||||||
EnvRenderer.Init();
|
EnvRenderer.Init();
|
||||||
MapEnvRenderer.Init();
|
MapBordersRenderer.Init();
|
||||||
Picking = new PickingRenderer( this );
|
Picking = new PickingRenderer( this );
|
||||||
|
|
||||||
string connectString = "Connecting to " + IPAddress + ":" + Port + "..";
|
string connectString = "Connecting to " + IPAddress + ":" + Port + "..";
|
||||||
@ -376,7 +376,7 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
public override void Dispose() {
|
public override void Dispose() {
|
||||||
MapRenderer.Dispose();
|
MapRenderer.Dispose();
|
||||||
MapEnvRenderer.Dispose();
|
MapBordersRenderer.Dispose();
|
||||||
EnvRenderer.Dispose();
|
EnvRenderer.Dispose();
|
||||||
WeatherRenderer.Dispose();
|
WeatherRenderer.Dispose();
|
||||||
SetNewScreen( null );
|
SetNewScreen( null );
|
||||||
|
@ -6,13 +6,13 @@ using OpenTK;
|
|||||||
|
|
||||||
namespace ClassicalSharp {
|
namespace ClassicalSharp {
|
||||||
|
|
||||||
public unsafe sealed class MapEnvRenderer : IDisposable {
|
public unsafe sealed class MapBordersRenderer : IDisposable {
|
||||||
|
|
||||||
Map map;
|
Map map;
|
||||||
Game game;
|
Game game;
|
||||||
IGraphicsApi graphics;
|
IGraphicsApi graphics;
|
||||||
|
|
||||||
public MapEnvRenderer( Game game ) {
|
public MapBordersRenderer( Game game ) {
|
||||||
this.game = game;
|
this.game = game;
|
||||||
map = game.Map;
|
map = game.Map;
|
||||||
graphics = game.Graphics;
|
graphics = game.Graphics;
|
||||||
@ -47,8 +47,10 @@ namespace ClassicalSharp {
|
|||||||
graphics.AlphaTest = true;
|
graphics.AlphaTest = true;
|
||||||
graphics.BindTexture( sideTexId );
|
graphics.BindTexture( sideTexId );
|
||||||
graphics.SetBatchFormat( VertexFormat.Pos3fTex2fCol4b );
|
graphics.SetBatchFormat( VertexFormat.Pos3fTex2fCol4b );
|
||||||
graphics.BindVb( sidesVb );
|
if( game.Map.SidesBlock != Block.Air ) {
|
||||||
graphics.DrawIndexedVb_TrisT2fC4b( sidesVertices * 6 / 4, 0 );
|
graphics.BindVb( sidesVb );
|
||||||
|
graphics.DrawIndexedVb_TrisT2fC4b( sidesVertices * 6 / 4, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
graphics.AlphaBlending = true;
|
graphics.AlphaBlending = true;
|
||||||
graphics.BindTexture( edgeTexId );
|
graphics.BindTexture( edgeTexId );
|
||||||
@ -58,10 +60,12 @@ namespace ClassicalSharp {
|
|||||||
// Fixes some 'depth bleeding through' issues with 16 bit depth buffers on large maps.
|
// Fixes some 'depth bleeding through' issues with 16 bit depth buffers on large maps.
|
||||||
Vector3 eyePos = game.LocalPlayer.EyePosition;
|
Vector3 eyePos = game.LocalPlayer.EyePosition;
|
||||||
float yVisible = Math.Min( 0, map.SidesHeight );
|
float yVisible = Math.Min( 0, map.SidesHeight );
|
||||||
if( game.Camera.GetCameraPos( eyePos ).Y >= yVisible ) {
|
if( game.Map.EdgeBlock != Block.Air ) {
|
||||||
graphics.DrawIndexedVb_TrisT2fC4b( edgesVertices * 6 / 4, 0 );
|
if( game.Camera.GetCameraPos( eyePos ).Y >= yVisible ) {
|
||||||
} else {
|
graphics.DrawIndexedVb_TrisT2fC4b( edgesVertices * 6 / 4, 0 );
|
||||||
graphics.DrawIndexedVb_TrisT2fC4b( edgesVerVertices * 6 / 4, edgesBaseVertices * 6 / 4 );
|
} else {
|
||||||
|
graphics.DrawIndexedVb_TrisT2fC4b( edgesVerVertices * 6 / 4, edgesBaseVertices * 6 / 4 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
graphics.AlphaBlending = false;
|
graphics.AlphaBlending = false;
|
||||||
graphics.Texturing = false;
|
graphics.Texturing = false;
|
@ -218,7 +218,7 @@ namespace ClassicalSharp {
|
|||||||
UpdateChunks( deltaTime );
|
UpdateChunks( deltaTime );
|
||||||
|
|
||||||
RenderNormal();
|
RenderNormal();
|
||||||
game.MapEnvRenderer.Render( deltaTime );
|
game.MapBordersRenderer.Render( deltaTime );
|
||||||
RenderTranslucent();
|
RenderTranslucent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user