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