Also include block id in BlockSelectScreen, add invert mouse opition (Thanks Cecil)

This commit is contained in:
UnknownShadow200 2015-12-21 21:10:15 +11:00
parent 851f430a40
commit 35e0f8cab5
6 changed files with 41 additions and 27 deletions

View File

@ -18,7 +18,7 @@ namespace ClassicalSharp {
int startX, startY, blockSize;
float selBlockExpand;
readonly Font font;
StringBuffer buffer = new StringBuffer( 96 );
StringBuffer buffer = new StringBuffer( 128 );
int TableX { get { return startX - 5 - 10; } }
int TableY { get { return startY - 5 - 30; } }
@ -116,7 +116,7 @@ namespace ClassicalSharp {
if( selIndex >= blocksTable.Length )
selIndex = blocksTable.Length - 1;
UpdateScrollY();
RecreateBlockInfoTexture();
RecreateBlockInfoTexture();
}
static string[] normalNames = null;
@ -127,19 +127,17 @@ namespace ClassicalSharp {
int index = 0;
buffer.Clear();
buffer.Append( ref index, "&f" );
if( block == Block.TNT ) {
buffer.Append( ref index, "TNT" );
string value = game.BlockInfo.Name[(byte)block];
if( (byte)block < BlockInfo.CpeBlocksCount && value == "Invalid" ) {
buffer.Append( ref index, normalNames[(byte)block] );
} else {
string value = game.BlockInfo.Name[(byte)block];
if( (byte)block < BlockInfo.CpeBlocksCount && value == "Invalid" ) {
buffer.Append( ref index, normalNames[(byte)block] );
} else {
buffer.Append( ref index, value );
}
buffer.Append( ref index, value );
}
buffer.Append( ref index, " (can place: " );
buffer.Append( ref index, " (ID: " );
buffer.AppendNum( ref index, (byte)block );
buffer.Append( ref index, ", place: " );
buffer.Append( ref index, game.Inventory.CanPlace[(int)block] ? "&aYes" : "&cNo" );
buffer.Append( ref index, "&f, can delete: " );
buffer.Append( ref index, "&f, delete: " );
buffer.Append( ref index, game.Inventory.CanDelete[(int)block] ? "&aYes" : "&cNo" );
buffer.Append( ref index, "&f)" );
}
@ -150,6 +148,10 @@ namespace ClassicalSharp {
string origName = Enum.GetName( typeof(Block), (byte)i );
buffer.Clear();
if( origName == "TNT") {
normalNames[i] = "TNT";
continue;
}
int index = 0;
SplitUppercase( origName, ref index );
normalNames[i] = buffer.ToString();

View File

@ -14,18 +14,18 @@ namespace ClassicalSharp {
INetworkProcessor network = game.Network;
buttons = new ButtonWidget[] {
// Column 1
Make( -140, -150, "Simple arms anim", OnWidgetClick,
g => g.SimpleArmsAnim? "yes" : "no",
(g, v) => { g.SimpleArmsAnim = v == "yes";
Options.Set( OptionsKey.SimpleArmsAnim, v == "yes" ); }),
Make( -140, -100, "Use sound", OnWidgetClick,
// Column 1
Make( -140, -150, "Use sound", 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, -100, "Simple arms anim", OnWidgetClick,
g => g.SimpleArmsAnim? "yes" : "no",
(g, v) => { g.SimpleArmsAnim = v == "yes";
Options.Set( OptionsKey.SimpleArmsAnim, v == "yes" ); }),
Make( -140, -50, "Names mode", OnWidgetClick,
g => g.Players.NamesMode.ToString(),
(g, v) => { object raw = Enum.Parse( typeof(NameMode), v );
@ -44,35 +44,40 @@ namespace ClassicalSharp {
// Column 2
!network.IsSinglePlayer ? null :
Make( 140, -150, "Block physics", OnWidgetClick,
Make( 140, -200, "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", OnWidgetClick,
Make( 140, -150, "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", OnWidgetClick,
Make( 140, -100, "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", OnWidgetClick,
Make( 140, -50, "Auto close launcher", OnWidgetClick,
g => Options.GetBool( OptionsKey.AutoCloseLauncher, false ) ? "yes" : "no",
(g, v) => Options.Set( OptionsKey.AutoCloseLauncher, v == "yes" ) ),
Make( 140, 0, "Invert mouse", OnWidgetClick,
g => g.InvertMouse ? "yes" : "no",
(g, v) => { g.InvertMouse = v == "yes";
Options.Set( OptionsKey.InvertMouse, v == "yes" ); }),
Make( 140, 50, "Mouse sensitivity", OnWidgetClick,
g => g.MouseSensitivity.ToString(),
(g, v) => { g.MouseSensitivity = Int32.Parse( v );
Options.Set( OptionsKey.Sensitivity, v ); } ),
MakeBack( false, titleFont,
(g, w) => g.SetNewScreen( new PauseScreen( g ) ) ),
(g, w) => g.SetNewScreen( new PauseScreen( g ) ) ),
null,
};
buttons[2].Metadata = typeof(NameMode);
@ -89,6 +94,7 @@ namespace ClassicalSharp {
new BooleanValidator(),
new BooleanValidator(),
new BooleanValidator(),
new BooleanValidator(),
new IntegerValidator( 1, 100 ),
};
okayIndex = buttons.Length - 1;
@ -96,7 +102,7 @@ namespace ClassicalSharp {
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,
ButtonWidget widget = ButtonWidget.Create( game, x, y, 240, 35, text, Anchor.Centre,
Anchor.Centre, titleFont, onClick );
widget.GetValue = getter;
widget.SetValue = setter;

View File

@ -104,7 +104,10 @@ namespace ClassicalSharp {
public bool ShowAxisLines;
/// <summary> Whether players should animate using simple swinging parallel to their bodies. </summary>
public bool SimpleArmsAnim = false;
public bool SimpleArmsAnim;
/// <summary> Whether mouse rotation on the y axis should be inverted. </summary>
public bool InvertMouse;
public long Vertices;
public FrustumCulling Culling;

View File

@ -62,6 +62,7 @@ namespace ClassicalSharp {
Drawer2D.UseBitmappedChat = !Options.GetBool( OptionsKey.ArialChatFont, false );
ViewBobbing = Options.GetBool( OptionsKey.ViewBobbing, false );
ShowBlockInHand = Options.GetBool( OptionsKey.ShowBlockInHand, true );
InvertMouse = Options.GetBool( OptionsKey.InvertMouse, false );
TerrainAtlas1D = new TerrainAtlas1D( Graphics );
TerrainAtlas = new TerrainAtlas2D( Graphics, Drawer2D );

View File

@ -87,7 +87,8 @@ namespace ClassicalSharp {
private void UpdateMouseRotation() {
float sensitivity = sensiFactor * game.MouseSensitivity;
float yaw = player.nextYaw + delta.X * sensitivity;
float pitch = player.nextPitch + delta.Y * sensitivity;
float yAdj = game.InvertMouse ? -delta.Y * sensitivity : delta.Y * sensitivity;
float pitch = player.nextPitch + yAdj;
LocationUpdate update = LocationUpdate.MakeOri( yaw, pitch );
// Need to make sure we don't cross the vertical axes, because that gets weird.

View File

@ -33,6 +33,7 @@ namespace ClassicalSharp {
public const string FieldOfView = "fov";
public const string LiquidsBreakable = "liquidsbreakable";
public const string PushbackPlacing = "pushbackplacing";
public const string InvertMouse = "invertmouse";
}
// TODO: implement this