mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 18:45:23 -04:00
Update entity names when default.png changes.
This commit is contained in:
parent
078b7b2747
commit
d05fdd1aa0
@ -164,6 +164,7 @@ namespace ClassicalSharp {
|
||||
}
|
||||
|
||||
void ChatFontChanged( object sender, EventArgs e ) {
|
||||
if( !game.Drawer2D.UseBitmappedChat ) return;
|
||||
Dispose();
|
||||
Init();
|
||||
}
|
||||
|
@ -83,6 +83,7 @@ namespace ClassicalSharp {
|
||||
}
|
||||
|
||||
void ChatFontChanged( object sender, EventArgs e ) {
|
||||
if( !game.Drawer2D.UseBitmappedChat ) return;
|
||||
Dispose();
|
||||
Init();
|
||||
}
|
||||
|
@ -8,6 +8,12 @@ namespace ClassicalSharp {
|
||||
|
||||
public const int MaxCount = 256;
|
||||
public Player[] Players = new Player[MaxCount];
|
||||
public Game game;
|
||||
|
||||
public EntityList( Game game ) {
|
||||
this.game = game;
|
||||
game.Events.ChatFontChanged += ChatFontChanged;
|
||||
}
|
||||
|
||||
/// <summary> Performs a tick call for all player entities contained in this list. </summary>
|
||||
public void Tick( double delta ) {
|
||||
@ -42,6 +48,13 @@ namespace ClassicalSharp {
|
||||
api.AlphaTest = false;
|
||||
}
|
||||
|
||||
void ChatFontChanged( object sender, EventArgs e ) {
|
||||
for( int i = 0; i < Players.Length; i++ ) {
|
||||
if( Players[i] != null )
|
||||
Players[i].UpdateNameFont();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Disposes of all player entities contained in this list. </summary>
|
||||
public void Dispose() {
|
||||
for( int i = 0; i < Players.Length; i++ ) {
|
||||
@ -49,6 +62,7 @@ namespace ClassicalSharp {
|
||||
Players[i].Despawn();
|
||||
}
|
||||
}
|
||||
game.Events.ChatFontChanged -= ChatFontChanged;
|
||||
}
|
||||
|
||||
public byte GetClosetPlayer( LocalPlayer localP ) {
|
||||
|
@ -7,27 +7,29 @@ namespace ClassicalSharp {
|
||||
|
||||
partial class Player {
|
||||
|
||||
protected IGraphicsApi api;
|
||||
protected Texture nameTex;
|
||||
protected internal int PlayerTextureId = -1, MobTextureId = -1;
|
||||
internal bool RenderHat = true;
|
||||
|
||||
public override void Despawn() {
|
||||
if( api == null ) return;
|
||||
api.DeleteTexture( ref PlayerTextureId );
|
||||
api.DeleteTexture( ref nameTex.ID );
|
||||
game.Graphics.DeleteTexture( ref PlayerTextureId );
|
||||
game.Graphics.DeleteTexture( ref nameTex.ID );
|
||||
}
|
||||
|
||||
protected void InitRenderingData() {
|
||||
api = game.Graphics;
|
||||
|
||||
using( Font font = new Font( "Arial", 14 ) ) {
|
||||
DrawTextArgs args = new DrawTextArgs( DisplayName, font, true );
|
||||
nameTex = game.Drawer2D.MakeBitmappedTextTexture( ref args, 0, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateNameFont() {
|
||||
game.Graphics.DeleteTexture( ref nameTex );
|
||||
InitRenderingData();
|
||||
}
|
||||
|
||||
protected void DrawName() {
|
||||
IGraphicsApi api = game.Graphics;
|
||||
api.BindTexture( nameTex.ID );
|
||||
|
||||
float x1 = -nameTex.Width * 0.5f / 50f, y1 = nameTex.Height / 50f;
|
||||
|
@ -22,7 +22,7 @@ namespace ClassicalSharp {
|
||||
public Map Map;
|
||||
public INetworkProcessor Network;
|
||||
|
||||
public EntityList Players = new EntityList();
|
||||
public EntityList Players;
|
||||
public CpeListInfo[] CpePlayersList = new CpeListInfo[256];
|
||||
public LocalPlayer LocalPlayer;
|
||||
public Camera Camera;
|
||||
@ -106,6 +106,7 @@ namespace ClassicalSharp {
|
||||
Graphics = new Direct3D9Api( this );
|
||||
#endif
|
||||
Graphics.MakeGraphicsInfo();
|
||||
Players = new EntityList( this );
|
||||
|
||||
Options.Load();
|
||||
ViewDistance = Options.GetInt( OptionsKey.ViewDist, 16, 4096, 512 );
|
||||
|
@ -87,8 +87,6 @@ namespace ClassicalSharp.TexturePack {
|
||||
void SetFontBitmap( Game game, Stream stream ) {
|
||||
game.FontBitmap = new Bitmap( stream );
|
||||
game.Drawer2D.SetFontBitmap( game.FontBitmap );
|
||||
|
||||
if( game.Drawer2D.UseBitmappedChat )
|
||||
game.Events.RaiseChatFontChanged();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user