mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 02:56:09 -04:00
Add an 'always yes/always no' option to texture pack warning screen.
This commit is contained in:
parent
d2bd5f148e
commit
36115c7b80
@ -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 ) {
|
||||
|
@ -244,7 +244,7 @@
|
||||
<Compile Include="Selections\SelectionManager.cs" />
|
||||
<Compile Include="Singleplayer\Physics.cs" />
|
||||
<Compile Include="Singleplayer\Server.cs" />
|
||||
<Compile Include="TexturePack\AcceptedUrls.cs" />
|
||||
<Compile Include="TexturePack\UrlsList.cs" />
|
||||
<Compile Include="TexturePack\Animations.cs" />
|
||||
<Compile Include="TexturePack\TextureCache.cs" />
|
||||
<Compile Include="TexturePack\TerrainAtlas1D.cs" />
|
||||
|
@ -137,7 +137,7 @@ namespace ClassicalSharp {
|
||||
internal int CloudsTexId, RainTexId, SnowTexId, GuiTexId;
|
||||
internal bool screenshotRequested;
|
||||
internal List<WarningScreen> WarningScreens = new List<WarningScreen>();
|
||||
internal AcceptedUrls AcceptedUrls = new AcceptedUrls();
|
||||
internal UrlsList AcceptedUrls = new UrlsList( "acceptedurls.txt" ), DeniedUrls = new UrlsList( "deniedurls.txt" );
|
||||
|
||||
/// <summary> Calculates the amount that 2D widgets should be scaled by when rendered. </summary>
|
||||
/// <remarks> Affected by both the current resolution of the window, as well as the
|
||||
|
@ -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 );
|
||||
|
@ -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 );
|
||||
|
@ -4,18 +4,23 @@ using System.IO;
|
||||
|
||||
namespace ClassicalSharp {
|
||||
|
||||
public sealed class AcceptedUrls {
|
||||
public sealed class UrlsList {
|
||||
|
||||
List<string> acceptedUrls = new List<string>();
|
||||
const string folder = "texturecache", file = "acceptedurls.txt";
|
||||
List<string> urls = new List<string>();
|
||||
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;
|
Loading…
x
Reference in New Issue
Block a user