diff --git a/ClassicalSharp/2D/Screens/WarningScreen.cs b/ClassicalSharp/2D/Screens/WarningScreen.cs
index ced10ab67..561c4929f 100644
--- a/ClassicalSharp/2D/Screens/WarningScreen.cs
+++ b/ClassicalSharp/2D/Screens/WarningScreen.cs
@@ -26,10 +26,14 @@ namespace ClassicalSharp {
regularFont = new Font( "Arial", 14, FontStyle.Regular );
buttons = new ButtonWidget[] {
- ButtonWidget.Create( game, -60, 30, 60, 25, "Yes", Anchor.Centre,
+ ButtonWidget.Create( game, -110, 30, 160, 35, "Yes", Anchor.Centre,
Anchor.Centre, titleFont, OnYesClick ),
- ButtonWidget.Create( game, 60, 30, 60, 25, "No", Anchor.Centre,
+ 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 ),
};
SetText( title, body );
}
@@ -68,6 +72,20 @@ namespace ClassicalSharp {
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 );
if( game.WarningScreens.Count > 0 ) {
diff --git a/ClassicalSharp/ClassicalSharp.csproj b/ClassicalSharp/ClassicalSharp.csproj
index 57b0500ba..faff75da4 100644
--- a/ClassicalSharp/ClassicalSharp.csproj
+++ b/ClassicalSharp/ClassicalSharp.csproj
@@ -244,7 +244,7 @@
-
+
diff --git a/ClassicalSharp/Game/Game.Properties.cs b/ClassicalSharp/Game/Game.Properties.cs
index 34c6ccdb1..562b32b8d 100644
--- a/ClassicalSharp/Game/Game.Properties.cs
+++ b/ClassicalSharp/Game/Game.Properties.cs
@@ -137,7 +137,7 @@ namespace ClassicalSharp {
internal int CloudsTexId, RainTexId, SnowTexId, GuiTexId;
internal bool screenshotRequested;
internal List WarningScreens = new List();
- internal AcceptedUrls AcceptedUrls = new AcceptedUrls();
+ internal UrlsList AcceptedUrls = new UrlsList( "acceptedurls.txt" ), DeniedUrls = new UrlsList( "deniedurls.txt" );
/// Calculates the amount that 2D widgets should be scaled by when rendered.
/// Affected by both the current resolution of the window, as well as the
diff --git a/ClassicalSharp/Game/Game.cs b/ClassicalSharp/Game/Game.cs
index 16cee6436..67e9d7031 100644
--- a/ClassicalSharp/Game/Game.cs
+++ b/ClassicalSharp/Game/Game.cs
@@ -42,7 +42,7 @@ namespace ClassicalSharp {
Players = new EntityList( this );
Options.Load();
- AcceptedUrls.Load();
+ AcceptedUrls.Load(); DeniedUrls.Load();
ViewDistance = Options.GetInt( OptionsKey.ViewDist, 16, 4096, 512 );
UserViewDistance = ViewDistance;
CameraClipping = Options.GetBool( OptionsKey.CameraClipping, true );
diff --git a/ClassicalSharp/Network/NetworkProcessor.CPE.cs b/ClassicalSharp/Network/NetworkProcessor.CPE.cs
index ce03a2dbc..e8dbbc8b2 100644
--- a/ClassicalSharp/Network/NetworkProcessor.CPE.cs
+++ b/ClassicalSharp/Network/NetworkProcessor.CPE.cs
@@ -308,7 +308,7 @@ namespace ClassicalSharp {
TexturePackExtractor extractor = new TexturePackExtractor();
extractor.Extract( game.DefaultTexturePack, game );
} else if( Utils.IsUrlPrefix( url ) ) {
- if( !game.AcceptedUrls.HasAccepted( url ) ) {
+ 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?",
@@ -335,10 +335,9 @@ namespace ClassicalSharp {
}
void DownloadTexturePack( string url ) {
+ if( game.DeniedUrls.HasUrl( url ) ) return;
game.Animations.Dispose();
DateTime lastModified = TextureCache.GetLastModifiedFromCache( url );
- if( !game.AcceptedUrls.HasAccepted( url ) )
- game.AcceptedUrls.AddAccepted( url );
if( url.EndsWith( ".zip" ) )
game.AsyncDownloader.DownloadData( url, true, "texturePack", lastModified );
diff --git a/ClassicalSharp/TexturePack/AcceptedUrls.cs b/ClassicalSharp/TexturePack/UrlsList.cs
similarity index 69%
rename from ClassicalSharp/TexturePack/AcceptedUrls.cs
rename to ClassicalSharp/TexturePack/UrlsList.cs
index fbd1f8810..0daf0dd3c 100644
--- a/ClassicalSharp/TexturePack/AcceptedUrls.cs
+++ b/ClassicalSharp/TexturePack/UrlsList.cs
@@ -4,18 +4,23 @@ using System.IO;
namespace ClassicalSharp {
- public sealed class AcceptedUrls {
+ public sealed class UrlsList {
- List acceptedUrls = new List();
- const string folder = "texturecache", file = "acceptedurls.txt";
+ List urls = new List();
+ const string folder = "texturecache";
+ string file;
- public void AddAccepted( string url ) {
- acceptedUrls.Add( url );
+ public UrlsList( string file ) {
+ this.file = file;
+ }
+
+ public void AddUrl( string url ) {
+ urls.Add( url );
Save();
}
- public bool HasAccepted( string url ) {
- return acceptedUrls.Contains( url );
+ public bool HasUrl( string url ) {
+ return urls.Contains( url );
}
public bool Load() {
@@ -31,12 +36,12 @@ namespace ClassicalSharp {
string line;
while( (line = reader.ReadLine()) != null ) {
if( line.Length == 0 && line[0] == '#' ) continue;
- acceptedUrls.Add( line );
+ urls.Add( line );
}
}
return true;
} catch( IOException ex ) {
- ErrorHandler.LogError( "loading accepted urls", ex );
+ ErrorHandler.LogError( "loading urls list", ex );
return false;
}
}
@@ -50,7 +55,7 @@ namespace ClassicalSharp {
using( Stream fs = File.Create( Path.Combine( path, file ) ) )
using( StreamWriter writer = new StreamWriter( fs ) )
{
- foreach( string value in acceptedUrls )
+ foreach( string value in urls )
writer.WriteLine( value );
}
return true;