mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 10:35:11 -04:00
Add additional entity name rendering modes - no names, hovered see through only.
This commit is contained in:
parent
5f1ee54faf
commit
f55f073b38
@ -13,24 +13,24 @@ namespace ClassicalSharp {
|
||||
|
||||
buttons = new ButtonWidget[] {
|
||||
// Column 1
|
||||
Make( -140, -150, "Block in hand", Anchor.Centre, OnWidgetClick,
|
||||
Make( -140, -150, "Block in hand", OnWidgetClick,
|
||||
g => g.ShowBlockInHand ? "yes" : "no",
|
||||
(g, v) => { g.ShowBlockInHand = v == "yes";
|
||||
Options.Set( OptionsKey.ShowBlockInHand, v == "yes" );
|
||||
} ),
|
||||
|
||||
Make( -140, -100, "Field of view", Anchor.Centre, OnWidgetClick,
|
||||
Make( -140, -100, "Field of view", OnWidgetClick,
|
||||
g => g.FieldOfView.ToString(),
|
||||
(g, v) => { g.FieldOfView = Int32.Parse( v );
|
||||
Options.Set( OptionsKey.FieldOfView, v );
|
||||
g.UpdateProjection();
|
||||
} ),
|
||||
|
||||
Make( -140, -50, "Show FPS", Anchor.Centre, OnWidgetClick,
|
||||
Make( -140, -50, "Show FPS", OnWidgetClick,
|
||||
g => g.ShowFPS ? "yes" : "no",
|
||||
(g, v) => g.ShowFPS = v == "yes" ),
|
||||
|
||||
Make( -140, 0, "Hud scale", Anchor.Centre, OnWidgetClick,
|
||||
Make( -140, 0, "Hud scale", OnWidgetClick,
|
||||
g => g.HudScale.ToString(),
|
||||
(g, v) => { g.HudScale = Single.Parse( v );
|
||||
Options.Set( OptionsKey.HudScale, v );
|
||||
@ -38,27 +38,27 @@ namespace ClassicalSharp {
|
||||
} ),
|
||||
|
||||
// Column 2
|
||||
Make( 140, -150, "Clickable chat", Anchor.Centre, OnWidgetClick,
|
||||
Make( 140, -150, "Clickable chat", OnWidgetClick,
|
||||
g => g.ClickableChat ? "yes" : "no",
|
||||
(g, v) => { g.ClickableChat = v == "yes";
|
||||
Options.Set( OptionsKey.ClickableChat, v == "yes" );
|
||||
} ),
|
||||
|
||||
Make( 140, -100, "Chat scale", Anchor.Centre, OnWidgetClick,
|
||||
Make( 140, -100, "Chat scale", OnWidgetClick,
|
||||
g => g.ChatScale.ToString(),
|
||||
(g, v) => { g.ChatScale = Single.Parse( v );
|
||||
Options.Set( OptionsKey.ChatScale, v );
|
||||
g.RefreshHud();
|
||||
} ),
|
||||
|
||||
Make( 140, -50, "Chat lines", Anchor.Centre, OnWidgetClick,
|
||||
Make( 140, -50, "Chat lines", OnWidgetClick,
|
||||
g => g.ChatLines.ToString(),
|
||||
(g, v) => { g.ChatLines = Int32.Parse( v );
|
||||
Options.Set( OptionsKey.ChatLines, v );
|
||||
g.RefreshHud();
|
||||
} ),
|
||||
|
||||
Make( 140, 0, "Arial chat font", Anchor.Centre, OnWidgetClick,
|
||||
Make( 140, 0, "Arial chat font", OnWidgetClick,
|
||||
g => g.Drawer2D.UseBitmappedChat ? "no" : "yes",
|
||||
(g, v) => {
|
||||
g.Drawer2D.UseBitmappedChat = v == "no";
|
||||
@ -87,10 +87,10 @@ namespace ClassicalSharp {
|
||||
okayIndex = buttons.Length - 1;
|
||||
}
|
||||
|
||||
ButtonWidget Make( int x, int y, string text, Anchor vDocking, Action<Game, Widget> onClick,
|
||||
ButtonWidget Make( int x, int y, string text, Action<Game, Widget> onClick,
|
||||
Func<Game, string> getter, Action<Game, string> setter ) {
|
||||
ButtonWidget widget = ButtonWidget.Create( game, x, y, 240, 35, text,
|
||||
Anchor.Centre, vDocking, titleFont, onClick );
|
||||
ButtonWidget widget = ButtonWidget.Create( game, x, y, 240, 35, text, Anchor.Centre,
|
||||
Anchor.Centre, titleFont, onClick );
|
||||
widget.GetValue = getter;
|
||||
widget.SetValue = setter;
|
||||
return widget;
|
||||
|
@ -15,25 +15,25 @@ namespace ClassicalSharp {
|
||||
|
||||
buttons = new ButtonWidget[] {
|
||||
// Column 1
|
||||
Make( -140, -100, "Hacks enabled", Anchor.Centre, OnWidgetClick,
|
||||
Make( -140, -100, "Hacks enabled", OnWidgetClick,
|
||||
g => g.LocalPlayer.HacksEnabled ? "yes" : "no",
|
||||
(g, v) => { g.LocalPlayer.HacksEnabled = v == "yes";
|
||||
Options.Set( OptionsKey.HacksEnabled, v == "yes" );
|
||||
g.LocalPlayer.CheckHacksConsistency();
|
||||
} ),
|
||||
|
||||
Make( -140, -50, "Speed multiplier", Anchor.Centre, OnWidgetClick,
|
||||
Make( -140, -50, "Speed multiplier", OnWidgetClick,
|
||||
g => g.LocalPlayer.SpeedMultiplier.ToString(),
|
||||
(g, v) => { g.LocalPlayer.SpeedMultiplier = Single.Parse( v );
|
||||
Options.Set( OptionsKey.Speed, v ); } ),
|
||||
|
||||
// Column 2
|
||||
Make( 140, -100, "Liquids breakable", Anchor.Centre, OnWidgetClick,
|
||||
Make( 140, -100, "Liquids breakable", OnWidgetClick,
|
||||
g => g.LiquidsBreakable ? "yes" : "no",
|
||||
(g, v) => { g.LiquidsBreakable = v == "yes";
|
||||
Options.Set( OptionsKey.LiquidsBreakable, v == "yes" ); } ),
|
||||
|
||||
Make( 140, -50, "Pushback placing", Anchor.Centre, OnWidgetClick,
|
||||
Make( 140, -50, "Pushback placing", OnWidgetClick,
|
||||
g => g.LocalPlayer.PushbackPlacing
|
||||
&& g.LocalPlayer.CanPushbackBlocks ? "yes" : "no",
|
||||
(g, v) => {
|
||||
@ -58,10 +58,10 @@ namespace ClassicalSharp {
|
||||
okayIndex = buttons.Length - 1;
|
||||
}
|
||||
|
||||
ButtonWidget Make( int x, int y, string text, Anchor vDocking, Action<Game, Widget> onClick,
|
||||
ButtonWidget Make( int x, int y, string text, Action<Game, Widget> onClick,
|
||||
Func<Game, string> getter, Action<Game, string> setter ) {
|
||||
ButtonWidget widget = ButtonWidget.Create( game, x, y, 240, 35, text,
|
||||
Anchor.Centre, vDocking, titleFont, onClick );
|
||||
ButtonWidget widget = ButtonWidget.Create( game, x, y, 240, 35, text, Anchor.Centre,
|
||||
Anchor.Centre, titleFont, onClick );
|
||||
widget.GetValue = getter;
|
||||
widget.SetValue = setter;
|
||||
return widget;
|
||||
|
@ -16,52 +16,53 @@ namespace ClassicalSharp {
|
||||
buttons = new ButtonWidget[] {
|
||||
// Column 1
|
||||
|
||||
Make( -140, -100, "Use sound (WIP)", Anchor.Centre, OnWidgetClick,
|
||||
Make( -140, -100, "Use sound (WIP)", OnWidgetClick,
|
||||
g => g.UseSound ? "yes" : "no",
|
||||
(g, v) => { g.UseSound = v == "yes";
|
||||
g.AudioPlayer.SetSound( g.UseSound );
|
||||
Options.Set( OptionsKey.UseSound, v == "yes" ); }),
|
||||
|
||||
Make( -140, -50, "Show hover names", Anchor.Centre, OnWidgetClick,
|
||||
g => g.Players.ShowHoveredNames ? "yes" : "no",
|
||||
(g, v) => { g.Players.ShowHoveredNames = v == "yes";
|
||||
Options.Set( OptionsKey.ShowHoveredNames, v == "yes" ); }),
|
||||
Make( -140, -50, "Names mode", OnWidgetClick,
|
||||
g => g.Players.NamesMode.ToString(),
|
||||
(g, v) => { object raw = Enum.Parse( typeof(NameMode), v );
|
||||
g.Players.NamesMode = (NameMode)raw;
|
||||
Options.Set( OptionsKey.NamesMode, v ); } ),
|
||||
|
||||
Make( -140, 0, "FPS limit", Anchor.Centre, OnWidgetClick,
|
||||
Make( -140, 0, "FPS limit", OnWidgetClick,
|
||||
g => g.FpsLimit.ToString(),
|
||||
(g, v) => { object raw = Enum.Parse( typeof(FpsLimitMethod), v );
|
||||
g.SetFpsLimitMethod( (FpsLimitMethod)raw );
|
||||
Options.Set( OptionsKey.FpsLimit, v ); } ),
|
||||
|
||||
Make( -140, 50, "View distance", Anchor.Centre, OnWidgetClick,
|
||||
Make( -140, 50, "View distance", OnWidgetClick,
|
||||
g => g.ViewDistance.ToString(),
|
||||
(g, v) => g.SetViewDistance( Int32.Parse( v ) ) ),
|
||||
|
||||
// Column 2
|
||||
!network.IsSinglePlayer ? null :
|
||||
Make( 140, -150, "Block physics", Anchor.Centre, OnWidgetClick,
|
||||
Make( 140, -150, "Block physics", OnWidgetClick,
|
||||
g => ((SinglePlayerServer)network).physics.Enabled ? "yes" : "no",
|
||||
(g, v) => {
|
||||
((SinglePlayerServer)network).physics.Enabled = v == "yes";
|
||||
Options.Set( OptionsKey.SingleplayerPhysics, v == "yes" );
|
||||
}),
|
||||
|
||||
Make( 140, -100, "Use music", Anchor.Centre, OnWidgetClick,
|
||||
Make( 140, -100, "Use music", OnWidgetClick,
|
||||
g => g.UseMusic ? "yes" : "no",
|
||||
(g, v) => { g.UseMusic = v == "yes";
|
||||
g.AudioPlayer.SetMusic( g.UseMusic );
|
||||
Options.Set( OptionsKey.UseMusic, v == "yes" ); }),
|
||||
|
||||
Make( 140, -50, "View bobbing", Anchor.Centre, OnWidgetClick,
|
||||
Make( 140, -50, "View bobbing", OnWidgetClick,
|
||||
g => g.ViewBobbing ? "yes" : "no",
|
||||
(g, v) => { g.ViewBobbing = v == "yes";
|
||||
Options.Set( OptionsKey.ViewBobbing, v == "yes" ); }),
|
||||
|
||||
Make( 140, 0, "Auto close launcher", Anchor.Centre, OnWidgetClick,
|
||||
Make( 140, 0, "Auto close launcher", OnWidgetClick,
|
||||
g => Options.GetBool( OptionsKey.AutoCloseLauncher, false ) ? "yes" : "no",
|
||||
(g, v) => Options.Set( OptionsKey.AutoCloseLauncher, v == "yes" ) ),
|
||||
|
||||
Make( 140, 50, "Mouse sensitivity", Anchor.Centre, OnWidgetClick,
|
||||
Make( 140, 50, "Mouse sensitivity", OnWidgetClick,
|
||||
g => g.MouseSensitivity.ToString(),
|
||||
(g, v) => { g.MouseSensitivity = Int32.Parse( v );
|
||||
Options.Set( OptionsKey.Sensitivity, v ); } ),
|
||||
@ -70,11 +71,12 @@ namespace ClassicalSharp {
|
||||
(g, w) => g.SetNewScreen( new PauseScreen( g ) ) ),
|
||||
null,
|
||||
};
|
||||
buttons[1].Metadata = typeof(NameMode);
|
||||
buttons[2].Metadata = typeof(FpsLimitMethod);
|
||||
|
||||
validators = new MenuInputValidator[] {
|
||||
new BooleanValidator(),
|
||||
new BooleanValidator(),
|
||||
new EnumValidator(),
|
||||
new EnumValidator(),
|
||||
new IntegerValidator( 16, 4096 ),
|
||||
|
||||
@ -87,10 +89,10 @@ namespace ClassicalSharp {
|
||||
okayIndex = buttons.Length - 1;
|
||||
}
|
||||
|
||||
ButtonWidget Make( int x, int y, string text, Anchor vDocking, Action<Game, Widget> onClick,
|
||||
ButtonWidget Make( int x, int y, string text, Action<Game, Widget> onClick,
|
||||
Func<Game, string> getter, Action<Game, string> setter ) {
|
||||
ButtonWidget widget = ButtonWidget.Create( game, x, y, 240, 35, text,
|
||||
Anchor.Centre, vDocking, titleFont, onClick );
|
||||
ButtonWidget widget = ButtonWidget.Create( game, x, y, 240, 35, text, Anchor.Centre,
|
||||
Anchor.Centre, titleFont, onClick );
|
||||
widget.GetValue = getter;
|
||||
widget.SetValue = setter;
|
||||
return widget;
|
||||
|
@ -4,6 +4,13 @@ using ClassicalSharp.GraphicsAPI;
|
||||
|
||||
namespace ClassicalSharp {
|
||||
|
||||
public enum NameMode {
|
||||
NoNames,
|
||||
HoveredOnly,
|
||||
AllNames,
|
||||
AllNamesAndHovered,
|
||||
}
|
||||
|
||||
public class EntityList : IDisposable {
|
||||
|
||||
public const int MaxCount = 256;
|
||||
@ -11,13 +18,14 @@ namespace ClassicalSharp {
|
||||
public Game game;
|
||||
byte closestId;
|
||||
|
||||
/// <summary> Whether the names of entities that the player is looking at
|
||||
/// should be rendered through everything else without depth testing. </summary>
|
||||
public bool ShowHoveredNames;
|
||||
/// <summary> Mode of how names of hovered entities are rendered (with or without depth testing),
|
||||
/// and how other entity names are rendered. </summary>
|
||||
public NameMode NamesMode = NameMode.AllNames;
|
||||
|
||||
public EntityList( Game game ) {
|
||||
this.game = game;
|
||||
game.Events.ChatFontChanged += ChatFontChanged;
|
||||
NamesMode = Options.GetEnum( OptionsKey.NamesMode, NameMode.AllNamesAndHovered );
|
||||
}
|
||||
|
||||
/// <summary> Performs a tick call for all player entities contained in this list. </summary>
|
||||
@ -44,17 +52,23 @@ namespace ClassicalSharp {
|
||||
/// If ShowHoveredNames is false, this method only renders names of entities that are
|
||||
/// not currently being looked at by the user. </summary>
|
||||
public void RenderNames( IGraphicsApi api, double delta, float t ) {
|
||||
if( NamesMode == NameMode.NoNames )
|
||||
return;
|
||||
api.Texturing = true;
|
||||
api.AlphaTest = true;
|
||||
LocalPlayer localP = game.LocalPlayer;
|
||||
Vector3 eyePos = localP.EyePosition;
|
||||
Vector3 dir = Utils.GetDirVector( localP.YawRadians, localP.PitchRadians );
|
||||
if( ShowHoveredNames )
|
||||
closestId = 255;
|
||||
|
||||
if( NamesMode != NameMode.AllNames )
|
||||
closestId = GetClosetPlayer( game.LocalPlayer );
|
||||
if( NamesMode == NameMode.HoveredOnly )
|
||||
return;
|
||||
|
||||
for( int i = 0; i < Players.Length; i++ ) {
|
||||
if( Players[i] == null ) continue;
|
||||
if( !ShowHoveredNames || (i != closestId || i == 255) )
|
||||
if( i != closestId || i == 255 )
|
||||
Players[i].RenderName();
|
||||
}
|
||||
api.Texturing = false;
|
||||
@ -62,7 +76,8 @@ namespace ClassicalSharp {
|
||||
}
|
||||
|
||||
public void RenderHoveredNames( IGraphicsApi api, double delta, float t ) {
|
||||
if( !ShowHoveredNames ) return;
|
||||
if( NamesMode == NameMode.NoNames || NamesMode == NameMode.AllNames )
|
||||
return;
|
||||
api.Texturing = true;
|
||||
api.AlphaTest = true;
|
||||
api.DepthTest = false;
|
||||
|
@ -43,7 +43,6 @@ namespace ClassicalSharp {
|
||||
|
||||
Options.Load();
|
||||
AcceptedUrls.Load();
|
||||
Players.ShowHoveredNames = Options.GetBool( OptionsKey.ShowHoveredNames, true );
|
||||
ViewDistance = Options.GetInt( OptionsKey.ViewDist, 16, 4096, 512 );
|
||||
InputHandler = new InputHandler( this );
|
||||
Chat = new ChatLog( this );
|
||||
|
@ -17,11 +17,11 @@ namespace ClassicalSharp {
|
||||
public const string ArialChatFont = "arialchatfont";
|
||||
public const string DefaultTexturePack = "defaulttexpack";
|
||||
public const string SingleplayerPhysics = "singleplayerphysics";
|
||||
public const string ShowHoveredNames = "showhoverednames";
|
||||
public const string ShowBlockInHand = "blockinhand";
|
||||
public const string UseMusic = "usemusic";
|
||||
public const string UseSound = "usesound";
|
||||
public const string HacksEnabled = "hacksenabled";
|
||||
public const string NamesMode = "namesmode";
|
||||
|
||||
public const string MouseLeft = "mouseleft";
|
||||
public const string MouseMiddle = "mousemiddle";
|
||||
|
Loading…
x
Reference in New Issue
Block a user