mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-24 10:02:08 -05:00
Slightly reduce own player bobbing to be less noticable (Thanks Cecil), add a confirmation dialog when selecting 'no/always no' to a texture pack (Thanks goodlyay), move arial chat font back to its more logical place in gui options. (Thanks FabTheZen)
This commit is contained in:
parent
c057114de2
commit
f6d083f280
9 changed files with 124 additions and 80 deletions
|
@ -330,7 +330,7 @@ namespace ClassicalSharp {
|
|||
|
||||
if( Utils.IsUrlPrefix( text ) ) {
|
||||
game.ShowWarning( new WarningScreen(
|
||||
game, text, "Are you sure you want to go to this url?",
|
||||
game, text, false, "Are you sure you want to go to this url?",
|
||||
OpenUrl, AppendUrl, null, text,
|
||||
"Be careful - urls from strangers may link to websites that",
|
||||
" may have viruses, or things you may not want to open/see."
|
||||
|
|
|
@ -110,7 +110,7 @@ namespace ClassicalSharp {
|
|||
|
||||
public override bool HandlesKeyDown( Key key ) {
|
||||
Key playerListKey = game.Mapping( KeyBinding.PlayerList );
|
||||
bool handles = playerListKey != Key.Tab || !game.TabAutocomplete;
|
||||
bool handles = playerListKey != Key.Tab || !game.TabAutocomplete || !chat.HandlesAllInput;
|
||||
if( key == playerListKey && handles ) {
|
||||
if( playerList == null )
|
||||
CreatePlayerListWidget();
|
||||
|
|
|
@ -63,6 +63,10 @@ namespace ClassicalSharp {
|
|||
g.RefreshHud();
|
||||
} ),
|
||||
|
||||
Make( 140, 50, "Arial chat font", OnWidgetClick,
|
||||
g => g.Drawer2D.UseBitmappedChat ? "no" : "yes",
|
||||
HandleArialChatFont ),
|
||||
|
||||
MakeBack( false, titleFont,
|
||||
(g, w) => g.SetNewScreen( new PauseScreen( g ) ) ),
|
||||
null,
|
||||
|
@ -77,6 +81,7 @@ namespace ClassicalSharp {
|
|||
new BooleanValidator(),
|
||||
new RealValidator( 0.25f, 5f ),
|
||||
new IntegerValidator( 1, 30 ),
|
||||
new BooleanValidator(),
|
||||
};
|
||||
okayIndex = buttons.Length - 1;
|
||||
}
|
||||
|
@ -89,5 +94,21 @@ namespace ClassicalSharp {
|
|||
widget.SetValue = setter;
|
||||
return widget;
|
||||
}
|
||||
|
||||
void HandleArialChatFont( Game g, string v ) {
|
||||
g.Drawer2D.UseBitmappedChat = v == "no";
|
||||
Options.Set( OptionsKey.ArialChatFont, v == "yes" );
|
||||
game.Events.RaiseChatFontChanged();
|
||||
|
||||
if( inputWidget != null ) {
|
||||
inputWidget.Dispose(); inputWidget = null;
|
||||
}
|
||||
if( descWidget != null ) {
|
||||
descWidget.Dispose(); descWidget = null;
|
||||
}
|
||||
|
||||
g.RefreshHud();
|
||||
Recreate();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -32,24 +32,6 @@ namespace ClassicalSharp {
|
|||
Options.Set( OptionsKey.UseClassicTabList, v == "yes" );
|
||||
} ),
|
||||
|
||||
Make( -140, 50, "Arial chat font", OnWidgetClick,
|
||||
g => g.Drawer2D.UseBitmappedChat ? "no" : "yes",
|
||||
(g, v) => {
|
||||
g.Drawer2D.UseBitmappedChat = v == "no";
|
||||
Options.Set( OptionsKey.ArialChatFont, v == "yes" );
|
||||
game.Events.RaiseChatFontChanged();
|
||||
|
||||
if( inputWidget != null ) {
|
||||
inputWidget.Dispose(); inputWidget = null;
|
||||
}
|
||||
if( descWidget != null ) {
|
||||
descWidget.Dispose(); descWidget = null;
|
||||
}
|
||||
|
||||
g.RefreshHud();
|
||||
Recreate();
|
||||
} ),
|
||||
|
||||
// Column 2
|
||||
Make( 140, -100, "Allow custom blocks", OnWidgetClick,
|
||||
g => g.AllowCustomBlocks ? "yes" : "no",
|
||||
|
@ -78,7 +60,6 @@ namespace ClassicalSharp {
|
|||
new BooleanValidator(),
|
||||
new BooleanValidator(),
|
||||
new BooleanValidator(),
|
||||
new BooleanValidator(),
|
||||
|
||||
new BooleanValidator(),
|
||||
new BooleanValidator(),
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace ClassicalSharp {
|
|||
|
||||
public sealed class WarningScreen : MenuScreen {
|
||||
|
||||
public WarningScreen( Game game, object metadata, string title,
|
||||
public WarningScreen( Game game, object metadata, bool confirmNo, string title,
|
||||
Action<WarningScreen> yesClick, Action<WarningScreen> noClick,
|
||||
Action<WarningScreen> renderFrame, params string[] body ) : base( game ) {
|
||||
this.Metadata = metadata;
|
||||
|
@ -15,37 +15,42 @@ namespace ClassicalSharp {
|
|||
this.renderFrame = renderFrame;
|
||||
this.title = title;
|
||||
this.body = body;
|
||||
this.confirmNo = confirmNo;
|
||||
}
|
||||
|
||||
internal Screen lastScreen;
|
||||
internal bool wasCursorVisible;
|
||||
string title;
|
||||
string[] body;
|
||||
string title, lastTitle;
|
||||
string[] body, lastBody;
|
||||
bool confirmNo, confirmMode;
|
||||
|
||||
public override void Init() {
|
||||
titleFont = new Font( "Arial", 16, FontStyle.Bold );
|
||||
regularFont = new Font( "Arial", 14, FontStyle.Regular );
|
||||
|
||||
buttons = new ButtonWidget[] {
|
||||
ButtonWidget.Create( game, -110, 30, 160, 35, "Yes", Anchor.Centre,
|
||||
Anchor.Centre, titleFont, OnYesClick ),
|
||||
ButtonWidget.Create( game, 110, 30, 160, 35, "No", Anchor.Centre,
|
||||
Anchor.Centre, titleFont, OnNoClick ),
|
||||
ButtonWidget.Create( game, -110, 80, 160, 35, "Always yes", Anchor.Centre,
|
||||
Anchor.Centre, titleFont, OnYesAlwaysClick ),
|
||||
ButtonWidget.Create( game, 110, 80, 160, 35, "Always no", Anchor.Centre,
|
||||
Anchor.Centre, titleFont, OnNoAlwaysClick ),
|
||||
};
|
||||
InitStandardButtons();
|
||||
SetText( title, body );
|
||||
}
|
||||
|
||||
public void SetText( string title, params string[] body) {
|
||||
public void SetText( string title, params string[] body ) {
|
||||
lastTitle = title;
|
||||
lastBody = body;
|
||||
|
||||
if( confirmMode ) {
|
||||
SetTextImpl( "&eYou might be missing out.",
|
||||
"Texture packs can play a vital role in the look and feel of maps.",
|
||||
"", "Sure you don't want to download the texture pack?" );
|
||||
} else {
|
||||
SetTextImpl( title, body );
|
||||
}
|
||||
}
|
||||
|
||||
void SetTextImpl( string title, params string[] body) {
|
||||
if( labels != null ) {
|
||||
for( int i = 0; i < labels.Length; i++ )
|
||||
labels[i].Dispose();
|
||||
}
|
||||
this.title = title;
|
||||
this.body = body;
|
||||
|
||||
this.body = body;
|
||||
|
||||
labels = new TextWidget[body.Length + 1];
|
||||
labels[0] = TextWidget.Create( game, 0, -120, title,
|
||||
|
@ -56,35 +61,6 @@ namespace ClassicalSharp {
|
|||
}
|
||||
}
|
||||
TextWidget[] labels;
|
||||
Action<WarningScreen> yesClick, noClick, renderFrame;
|
||||
|
||||
void OnYesClick( Game g, Widget w ) {
|
||||
if( yesClick != null )
|
||||
yesClick( this );
|
||||
Dispose();
|
||||
CloseScreen();
|
||||
}
|
||||
|
||||
void OnNoClick( Game g, Widget w ) {
|
||||
if( noClick != null )
|
||||
noClick( this );
|
||||
Dispose();
|
||||
CloseScreen();
|
||||
}
|
||||
|
||||
void OnYesAlwaysClick( Game g, Widget w ) {
|
||||
OnYesClick( g, w );
|
||||
string url = ((string)Metadata).Substring( 3 );
|
||||
if( !game.AcceptedUrls.HasUrl( url ) )
|
||||
game.AcceptedUrls.AddUrl( url );
|
||||
}
|
||||
|
||||
void OnNoAlwaysClick( Game g, Widget w ) {
|
||||
OnNoClick( g, w );
|
||||
string url = ((string)Metadata).Substring( 3 );
|
||||
if( !game.DeniedUrls.HasUrl( url ) )
|
||||
game.DeniedUrls.AddUrl( url );
|
||||
}
|
||||
|
||||
void CloseScreen() {
|
||||
game.WarningScreens.RemoveAt( 0 );
|
||||
|
@ -122,5 +98,75 @@ namespace ClassicalSharp {
|
|||
for( int i = 0; i < labels.Length; i++ )
|
||||
labels[i].Dispose();
|
||||
}
|
||||
|
||||
void InitStandardButtons() {
|
||||
buttons = new ButtonWidget[] {
|
||||
ButtonWidget.Create( game, -110, 30, 160, 35, "Yes", Anchor.Centre,
|
||||
Anchor.Centre, titleFont, OnYesClick ),
|
||||
ButtonWidget.Create( game, 110, 30, 160, 35, "No", Anchor.Centre,
|
||||
Anchor.Centre, titleFont, OnNoClick ),
|
||||
ButtonWidget.Create( game, -110, 80, 160, 35, "Always yes", Anchor.Centre,
|
||||
Anchor.Centre, titleFont, OnYesAlwaysClick ),
|
||||
ButtonWidget.Create( game, 110, 80, 160, 35, "Always no", Anchor.Centre,
|
||||
Anchor.Centre, titleFont, OnNoAlwaysClick ),
|
||||
};
|
||||
}
|
||||
|
||||
Action<WarningScreen> yesClick, noClick, renderFrame;
|
||||
void OnYesClick( Game g, Widget w ) {
|
||||
if( yesClick != null )
|
||||
yesClick( this );
|
||||
Dispose();
|
||||
CloseScreen();
|
||||
}
|
||||
|
||||
void OnNoClick( Game g, Widget w ) {
|
||||
if( confirmNo && !confirmMode ) {
|
||||
InitConfirmButtons( false ); return;
|
||||
}
|
||||
|
||||
if( noClick != null )
|
||||
noClick( this );
|
||||
Dispose();
|
||||
CloseScreen();
|
||||
}
|
||||
|
||||
void OnYesAlwaysClick( Game g, Widget w ) {
|
||||
OnYesClick( g, w );
|
||||
string url = ((string)Metadata).Substring( 3 );
|
||||
if( !game.AcceptedUrls.HasUrl( url ) )
|
||||
game.AcceptedUrls.AddUrl( url );
|
||||
}
|
||||
|
||||
void OnNoAlwaysClick( Game g, Widget w ) {
|
||||
if( confirmNo && !confirmMode ) {
|
||||
InitConfirmButtons( true ); return;
|
||||
}
|
||||
|
||||
OnNoClick( g, w );
|
||||
string url = ((string)Metadata).Substring( 3 );
|
||||
if( !game.DeniedUrls.HasUrl( url ) )
|
||||
game.DeniedUrls.AddUrl( url );
|
||||
}
|
||||
|
||||
|
||||
void InitConfirmButtons( bool always ) {
|
||||
Action<Game, Widget> noHandler = always ? (Action<Game, Widget>)OnNoAlwaysClick
|
||||
: (Action<Game, Widget>)OnNoClick;
|
||||
buttons = new ButtonWidget[] {
|
||||
ButtonWidget.Create( game, -110, 30, 160, 35, "I'm sure", Anchor.Centre,
|
||||
Anchor.Centre, titleFont, noHandler ),
|
||||
ButtonWidget.Create( game, 110, 30, 160, 35, "Go back", Anchor.Centre,
|
||||
Anchor.Centre, titleFont, GoBackClick ),
|
||||
};
|
||||
confirmMode = true;
|
||||
SetText( lastTitle, lastBody );
|
||||
}
|
||||
|
||||
void GoBackClick( Game g, Widget w ) {
|
||||
InitStandardButtons();
|
||||
confirmMode = false;
|
||||
SetText( lastTitle, lastBody );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -133,7 +133,7 @@ namespace ClassicalSharp {
|
|||
|
||||
public int ChatLines = 12;
|
||||
public bool ClickableChat = false, HideGui = false, ShowFPS = true;
|
||||
internal float HotbarScale = 1.0f, ChatScale = 1.0f, InventoryScale = 1.0f;
|
||||
internal float HotbarScale = 1, ChatScale = 1, InventoryScale = 1;
|
||||
public bool ViewBobbing, ShowBlockInHand;
|
||||
public bool UseSound, UseMusic, LiquidsBreakable;
|
||||
|
||||
|
|
|
@ -318,10 +318,10 @@ namespace ClassicalSharp {
|
|||
if( !game.AcceptedUrls.HasUrl( url ) && !game.DeniedUrls.HasUrl( url ) ) {
|
||||
game.AsyncDownloader.RetrieveContentLength( url, true, "CL_" + url );
|
||||
game.ShowWarning( new WarningScreen(
|
||||
game, "CL_" + url, "Do you want to download the server's terrain image?",
|
||||
game, "CL_" + url, true, "Do you want to download the server's texture pack?",
|
||||
DownloadTexturePack, null, WarningScreenTick,
|
||||
"The terrain image is located at:", url,
|
||||
"Terrain image size: Determining..." ) );
|
||||
"Texture pack url:", url,
|
||||
"Download size: Determining..." ) );
|
||||
} else {
|
||||
DownloadTexturePack( url );
|
||||
}
|
||||
|
@ -362,9 +362,9 @@ namespace ClassicalSharp {
|
|||
string url = identifier.Substring( 3 );
|
||||
|
||||
float contentLengthMB = (contentLength / 1024f / 1024f );
|
||||
screen.SetText( "Do you want to download the server's terrain image?",
|
||||
"The terrain image is located at:", url,
|
||||
"Terrain image size: " + contentLengthMB.ToString( "F3" ) + " MB" );
|
||||
screen.SetText( "Do you want to download the server's texture pack?",
|
||||
"Texture pack url:", url,
|
||||
"Download size: " + contentLengthMB.ToString( "F3" ) + " MB" );
|
||||
}
|
||||
|
||||
void HandleCpeEnvWeatherType() {
|
||||
|
|
|
@ -111,7 +111,7 @@ namespace ClassicalSharp {
|
|||
|
||||
public override void Tick( double delta ) {
|
||||
if( Disconnected ) return;
|
||||
if( (DateTime.UtcNow - lastPing).TotalSeconds >= 5 )
|
||||
if( (DateTime.UtcNow - lastPing).TotalSeconds >= 10 )
|
||||
CheckDisconnection( delta );
|
||||
if( Disconnected ) return;
|
||||
|
||||
|
|
|
@ -112,10 +112,6 @@ namespace ClassicalSharp {
|
|||
UpdateMouseRotation();
|
||||
}
|
||||
|
||||
bool zero( float value ) {
|
||||
return Math.Abs( value ) < 0.001f;
|
||||
}
|
||||
|
||||
float HorLength( Vector3 v ) {
|
||||
return (float)Math.Sqrt( v.X * v.X + v.Z * v.Z );
|
||||
}
|
||||
|
@ -129,7 +125,7 @@ namespace ClassicalSharp {
|
|||
bobYOffset = 0;
|
||||
} else {
|
||||
tiltMatrix = Matrix4.RotateZ( game.LocalPlayer.tilt );
|
||||
bobYOffset = game.LocalPlayer.bobYOffset;
|
||||
bobYOffset = game.LocalPlayer.bobYOffset * (2.0f/2.5f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue