mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 19:15:14 -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 );
|
regularFont = new Font( "Arial", 14, FontStyle.Regular );
|
||||||
|
|
||||||
buttons = new ButtonWidget[] {
|
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 ),
|
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 ),
|
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 );
|
SetText( title, body );
|
||||||
}
|
}
|
||||||
@ -68,6 +72,20 @@ namespace ClassicalSharp {
|
|||||||
CloseScreen();
|
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() {
|
void CloseScreen() {
|
||||||
game.WarningScreens.RemoveAt( 0 );
|
game.WarningScreens.RemoveAt( 0 );
|
||||||
if( game.WarningScreens.Count > 0 ) {
|
if( game.WarningScreens.Count > 0 ) {
|
||||||
|
@ -244,7 +244,7 @@
|
|||||||
<Compile Include="Selections\SelectionManager.cs" />
|
<Compile Include="Selections\SelectionManager.cs" />
|
||||||
<Compile Include="Singleplayer\Physics.cs" />
|
<Compile Include="Singleplayer\Physics.cs" />
|
||||||
<Compile Include="Singleplayer\Server.cs" />
|
<Compile Include="Singleplayer\Server.cs" />
|
||||||
<Compile Include="TexturePack\AcceptedUrls.cs" />
|
<Compile Include="TexturePack\UrlsList.cs" />
|
||||||
<Compile Include="TexturePack\Animations.cs" />
|
<Compile Include="TexturePack\Animations.cs" />
|
||||||
<Compile Include="TexturePack\TextureCache.cs" />
|
<Compile Include="TexturePack\TextureCache.cs" />
|
||||||
<Compile Include="TexturePack\TerrainAtlas1D.cs" />
|
<Compile Include="TexturePack\TerrainAtlas1D.cs" />
|
||||||
|
@ -137,7 +137,7 @@ namespace ClassicalSharp {
|
|||||||
internal int CloudsTexId, RainTexId, SnowTexId, GuiTexId;
|
internal int CloudsTexId, RainTexId, SnowTexId, GuiTexId;
|
||||||
internal bool screenshotRequested;
|
internal bool screenshotRequested;
|
||||||
internal List<WarningScreen> WarningScreens = new List<WarningScreen>();
|
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>
|
/// <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
|
/// <remarks> Affected by both the current resolution of the window, as well as the
|
||||||
|
@ -42,7 +42,7 @@ namespace ClassicalSharp {
|
|||||||
Players = new EntityList( this );
|
Players = new EntityList( this );
|
||||||
|
|
||||||
Options.Load();
|
Options.Load();
|
||||||
AcceptedUrls.Load();
|
AcceptedUrls.Load(); DeniedUrls.Load();
|
||||||
ViewDistance = Options.GetInt( OptionsKey.ViewDist, 16, 4096, 512 );
|
ViewDistance = Options.GetInt( OptionsKey.ViewDist, 16, 4096, 512 );
|
||||||
UserViewDistance = ViewDistance;
|
UserViewDistance = ViewDistance;
|
||||||
CameraClipping = Options.GetBool( OptionsKey.CameraClipping, true );
|
CameraClipping = Options.GetBool( OptionsKey.CameraClipping, true );
|
||||||
|
@ -308,7 +308,7 @@ namespace ClassicalSharp {
|
|||||||
TexturePackExtractor extractor = new TexturePackExtractor();
|
TexturePackExtractor extractor = new TexturePackExtractor();
|
||||||
extractor.Extract( game.DefaultTexturePack, game );
|
extractor.Extract( game.DefaultTexturePack, game );
|
||||||
} else if( Utils.IsUrlPrefix( url ) ) {
|
} 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.AsyncDownloader.RetrieveContentLength( url, true, "CL_" + url );
|
||||||
game.ShowWarning( new WarningScreen(
|
game.ShowWarning( new WarningScreen(
|
||||||
game, "CL_" + url, "Do you want to download the server's terrain image?",
|
game, "CL_" + url, "Do you want to download the server's terrain image?",
|
||||||
@ -335,10 +335,9 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DownloadTexturePack( string url ) {
|
void DownloadTexturePack( string url ) {
|
||||||
|
if( game.DeniedUrls.HasUrl( url ) ) return;
|
||||||
game.Animations.Dispose();
|
game.Animations.Dispose();
|
||||||
DateTime lastModified = TextureCache.GetLastModifiedFromCache( url );
|
DateTime lastModified = TextureCache.GetLastModifiedFromCache( url );
|
||||||
if( !game.AcceptedUrls.HasAccepted( url ) )
|
|
||||||
game.AcceptedUrls.AddAccepted( url );
|
|
||||||
|
|
||||||
if( url.EndsWith( ".zip" ) )
|
if( url.EndsWith( ".zip" ) )
|
||||||
game.AsyncDownloader.DownloadData( url, true, "texturePack", lastModified );
|
game.AsyncDownloader.DownloadData( url, true, "texturePack", lastModified );
|
||||||
|
@ -4,18 +4,23 @@ using System.IO;
|
|||||||
|
|
||||||
namespace ClassicalSharp {
|
namespace ClassicalSharp {
|
||||||
|
|
||||||
public sealed class AcceptedUrls {
|
public sealed class UrlsList {
|
||||||
|
|
||||||
List<string> acceptedUrls = new List<string>();
|
List<string> urls = new List<string>();
|
||||||
const string folder = "texturecache", file = "acceptedurls.txt";
|
const string folder = "texturecache";
|
||||||
|
string file;
|
||||||
|
|
||||||
public void AddAccepted( string url ) {
|
public UrlsList( string file ) {
|
||||||
acceptedUrls.Add( url );
|
this.file = file;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddUrl( string url ) {
|
||||||
|
urls.Add( url );
|
||||||
Save();
|
Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HasAccepted( string url ) {
|
public bool HasUrl( string url ) {
|
||||||
return acceptedUrls.Contains( url );
|
return urls.Contains( url );
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Load() {
|
public bool Load() {
|
||||||
@ -31,12 +36,12 @@ namespace ClassicalSharp {
|
|||||||
string line;
|
string line;
|
||||||
while( (line = reader.ReadLine()) != null ) {
|
while( (line = reader.ReadLine()) != null ) {
|
||||||
if( line.Length == 0 && line[0] == '#' ) continue;
|
if( line.Length == 0 && line[0] == '#' ) continue;
|
||||||
acceptedUrls.Add( line );
|
urls.Add( line );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch( IOException ex ) {
|
} catch( IOException ex ) {
|
||||||
ErrorHandler.LogError( "loading accepted urls", ex );
|
ErrorHandler.LogError( "loading urls list", ex );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -50,7 +55,7 @@ namespace ClassicalSharp {
|
|||||||
using( Stream fs = File.Create( Path.Combine( path, file ) ) )
|
using( Stream fs = File.Create( Path.Combine( path, file ) ) )
|
||||||
using( StreamWriter writer = new StreamWriter( fs ) )
|
using( StreamWriter writer = new StreamWriter( fs ) )
|
||||||
{
|
{
|
||||||
foreach( string value in acceptedUrls )
|
foreach( string value in urls )
|
||||||
writer.WriteLine( value );
|
writer.WriteLine( value );
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
Loading…
x
Reference in New Issue
Block a user