Fix inconsistent location of .truecraft
This commit is contained in:
parent
cf4632786f
commit
bbb457af87
@ -96,7 +96,7 @@ namespace TrueCraft.Client.Rendering
|
||||
// they're unimportant as we can just use default textures.
|
||||
try
|
||||
{
|
||||
var archive = new ZipFile(Path.Combine(TexturePack.TexturePackPath, texturePack.Name));
|
||||
var archive = new ZipFile(Path.Combine(Paths.TexturePacks, texturePack.Name));
|
||||
foreach (var entry in archive.Entries)
|
||||
{
|
||||
var key = entry.FileName;
|
||||
|
@ -208,7 +208,8 @@ namespace TrueCraft.Client
|
||||
// Load any custom textures if needed.
|
||||
TextureMapper = new TextureMapper(GraphicsDevice);
|
||||
if (UserSettings.Local.SelectedTexturePack != TexturePack.Default.Name)
|
||||
TextureMapper.AddTexturePack(TexturePack.FromArchive(Path.Combine(TexturePack.TexturePackPath, UserSettings.Local.SelectedTexturePack)));
|
||||
TextureMapper.AddTexturePack(TexturePack.FromArchive(Path.Combine(Paths.TexturePacks,
|
||||
UserSettings.Local.SelectedTexturePack)));
|
||||
|
||||
Pixel = new FontRenderer(
|
||||
new Font(Content, "Fonts/Pixel"),
|
||||
|
@ -61,5 +61,13 @@ namespace TrueCraft.Core
|
||||
return Path.Combine(Base, "screenshots");
|
||||
}
|
||||
}
|
||||
|
||||
public static string TexturePacks
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.Combine(Base, "texturepacks");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -9,38 +9,16 @@ namespace TrueCraft.Core
|
||||
/// </summary>
|
||||
public class TexturePack
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static readonly TexturePack Unknown = new TexturePack(
|
||||
"?",
|
||||
File.OpenRead(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Content/default-pack.png")),
|
||||
File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Content/default-pack.txt")));
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static readonly TexturePack Default = new TexturePack(
|
||||
"Default",
|
||||
File.OpenRead(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Content/pack.png")),
|
||||
File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Content/pack.txt")));
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static string TexturePackPath
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
|
||||
".truecraft/texturepacks/");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
public static TexturePack FromArchive(string path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
@ -82,27 +60,12 @@ namespace TrueCraft.Core
|
||||
return new TexturePack(name, image, description);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Name { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public Stream Image { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Description { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="image"></param>
|
||||
/// <param name="description"></param>
|
||||
public TexturePack(string name, Stream image, string description)
|
||||
{
|
||||
Name = name;
|
||||
|
@ -118,7 +118,7 @@ namespace TrueCraft.Launcher.Views
|
||||
|
||||
OpenFolderButton.Clicked += (sender, e) =>
|
||||
{
|
||||
var dir = new DirectoryInfo(TexturePack.TexturePackPath);
|
||||
var dir = new DirectoryInfo(Paths.TexturePacks);
|
||||
Process.Start(dir.FullName);
|
||||
};
|
||||
|
||||
@ -188,11 +188,12 @@ namespace TrueCraft.Launcher.Views
|
||||
CopyBetweenZips("terrain.png", jar, zip);
|
||||
CopyBetweenZips("particles.png", jar, zip);
|
||||
|
||||
zip.Save(Path.Combine(TexturePack.TexturePackPath, "Minecraft.zip"));
|
||||
zip.Save(Path.Combine(Paths.TexturePacks, "Minecraft.zip"));
|
||||
Application.Invoke(() =>
|
||||
{
|
||||
OfficialAssetsProgress.Visible = false;
|
||||
var texturePack = TexturePack.FromArchive(Path.Combine(TexturePack.TexturePackPath, "Minecraft.zip"));
|
||||
var texturePack = TexturePack.FromArchive(
|
||||
Path.Combine(Paths.TexturePacks, "Minecraft.zip"));
|
||||
_texturePacks.Add(texturePack);
|
||||
AddTexturePackRow(texturePack);
|
||||
});
|
||||
@ -239,10 +240,10 @@ namespace TrueCraft.Launcher.Views
|
||||
AddTexturePackRow(TexturePack.Default);
|
||||
|
||||
// Make sure to create the texture pack directory if there is none.
|
||||
if (!Directory.Exists(TexturePack.TexturePackPath))
|
||||
Directory.CreateDirectory(TexturePack.TexturePackPath);
|
||||
if (!Directory.Exists(Paths.TexturePacks))
|
||||
Directory.CreateDirectory(Paths.TexturePacks);
|
||||
|
||||
var zips = Directory.EnumerateFiles(TexturePack.TexturePackPath);
|
||||
var zips = Directory.EnumerateFiles(Paths.TexturePacks);
|
||||
bool officialPresent = false;
|
||||
foreach (var zip in zips)
|
||||
{
|
||||
|
Reference in New Issue
Block a user