Now load terrain.png from current texture pack
This commit is contained in:
parent
ef5c6b7861
commit
b799809d74
@ -11,6 +11,9 @@ namespace TrueCraft.Client
|
||||
[STAThread]
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
UserSettings.Local = new UserSettings();
|
||||
UserSettings.Local.Load();
|
||||
|
||||
var user = new TrueCraftUser { Username = args[1] };
|
||||
var client = new MultiplayerClient(user);
|
||||
var game = new TrueCraftGame(client, ParseEndPoint(args[0]));
|
||||
|
37
TrueCraft.Client/Rendering/TexturePackExtensions.cs
Normal file
37
TrueCraft.Client/Rendering/TexturePackExtensions.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using TrueCraft.Core;
|
||||
using Ionic.Zip;
|
||||
|
||||
namespace TrueCraft.Client.Rendering
|
||||
{
|
||||
public static class TexturePackExtensions
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="instance"></param>
|
||||
/// <param name="entryName"></param>
|
||||
/// <returns></returns>
|
||||
public static Texture2D GetTexture(this TexturePack instance, GraphicsDevice graphicsDevice, string entryName)
|
||||
{
|
||||
ZipEntry entry = null;
|
||||
foreach (var item in instance.Archive.Entries)
|
||||
{
|
||||
if (item.FileName == entryName)
|
||||
{
|
||||
entry = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (entry == null)
|
||||
return null;
|
||||
|
||||
Texture2D texture = null;
|
||||
using (var reader = entry.OpenReader())
|
||||
texture = Texture2D.FromStream(graphicsDevice, reader);
|
||||
return texture;
|
||||
}
|
||||
}
|
||||
}
|
@ -70,6 +70,10 @@
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Ionic.Zip.Reduced, Version=1.9.1.8, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\lib\Ionic.Zip.Reduced.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="OpenTK, Version=1.1.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MonoGame.Framework.Linux.3.4.0.459\lib\net40\OpenTK.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
@ -109,6 +113,7 @@
|
||||
<Compile Include="Rendering\Font.cs" />
|
||||
<Compile Include="Rendering\FontRenderer.cs" />
|
||||
<Compile Include="Rendering\FontStyle.cs" />
|
||||
<Compile Include="Rendering\TexturePackExtensions.cs" />
|
||||
<Compile Include="TrueCraftGame.cs" />
|
||||
<Compile Include="MultiplayerClient.cs" />
|
||||
<Compile Include="Handlers\PacketHandlers.cs" />
|
||||
|
@ -14,6 +14,7 @@ using TrueCraft.Core.Networking.Packets;
|
||||
using TrueCraft.API.World;
|
||||
using System.Collections.Concurrent;
|
||||
using TrueCraft.Client.Input;
|
||||
using TrueCraft.Core;
|
||||
|
||||
namespace TrueCraft.Client
|
||||
{
|
||||
@ -41,6 +42,7 @@ namespace TrueCraft.Client
|
||||
private MouseComponent MouseComponent { get; set; }
|
||||
private GameTime GameTime { get; set; }
|
||||
private Microsoft.Xna.Framework.Vector3 Delta { get; set; }
|
||||
private TexturePack TexturePack { get; set; }
|
||||
|
||||
private BasicEffect OpaqueEffect, TransparentEffect;
|
||||
|
||||
@ -124,6 +126,7 @@ namespace TrueCraft.Client
|
||||
|
||||
protected override void LoadContent()
|
||||
{
|
||||
TexturePack = new TexturePack(UserSettings.Local.SelectedTexturePack);
|
||||
DejaVu = new FontRenderer(
|
||||
new Font(Content, "Fonts/DejaVu", FontStyle.Regular),
|
||||
new Font(Content, "Fonts/DejaVu", FontStyle.Bold),
|
||||
@ -138,7 +141,7 @@ namespace TrueCraft.Client
|
||||
OpaqueEffect.DirectionalLight1.SpecularColor = Color.Black.ToVector3();
|
||||
OpaqueEffect.DirectionalLight2.SpecularColor = Color.Black.ToVector3();
|
||||
OpaqueEffect.TextureEnabled = true;
|
||||
OpaqueEffect.Texture = Texture2D.FromStream(GraphicsDevice, File.OpenRead("Content/terrain.png"));
|
||||
OpaqueEffect.Texture = TexturePack.GetTexture(GraphicsDevice, "terrain.png");
|
||||
OpaqueEffect.FogEnabled = true;
|
||||
OpaqueEffect.FogStart = 512f;
|
||||
OpaqueEffect.FogEnd = 1000f;
|
||||
@ -146,7 +149,7 @@ namespace TrueCraft.Client
|
||||
|
||||
TransparentEffect = new BasicEffect(GraphicsDevice);
|
||||
TransparentEffect.TextureEnabled = true;
|
||||
TransparentEffect.Texture = Texture2D.FromStream(GraphicsDevice, File.OpenRead("Content/terrain.png"));
|
||||
TransparentEffect.Texture = TexturePack.GetTexture(GraphicsDevice, "terrain.png");
|
||||
|
||||
base.LoadContent();
|
||||
}
|
||||
@ -250,7 +253,7 @@ namespace TrueCraft.Client
|
||||
Client.Yaw += look.X;
|
||||
Client.Pitch += look.Y;
|
||||
Client.Yaw %= 360;
|
||||
Client.Pitch = MathHelper.Clamp(Client.Pitch, -89.9f, 89.9f);
|
||||
Client.Pitch = Microsoft.Xna.Framework.MathHelper.Clamp(Client.Pitch, -89.9f, 89.9f);
|
||||
|
||||
if (look != Vector2.Zero)
|
||||
UpdateCamera();
|
||||
@ -312,7 +315,7 @@ namespace TrueCraft.Client
|
||||
if (Delta != Microsoft.Xna.Framework.Vector3.Zero)
|
||||
{
|
||||
var lookAt = Microsoft.Xna.Framework.Vector3.Transform(
|
||||
Delta, Matrix.CreateRotationY(MathHelper.ToRadians(Client.Yaw)));
|
||||
Delta, Matrix.CreateRotationY(Microsoft.Xna.Framework.MathHelper.ToRadians(Client.Yaw)));
|
||||
|
||||
Client.Position += new TrueCraft.API.Vector3(lookAt.X, lookAt.Y, lookAt.Z)
|
||||
* (gameTime.ElapsedGameTime.TotalSeconds * 4.3717);
|
||||
|
@ -60,12 +60,14 @@ namespace TrueCraft.Launcher.Views
|
||||
{
|
||||
var texturePack = _texturePacks[TexturePackListView.SelectedRow];
|
||||
if (_lastTexturePack != texturePack)
|
||||
{
|
||||
UserSettings.Local.SelectedTexturePack = texturePack.Path;
|
||||
UserSettings.Local.Save();
|
||||
}
|
||||
};
|
||||
|
||||
OpenFolderButton.Clicked += (sender, e) =>
|
||||
{
|
||||
// TODO: Implement cross-platform logic here.
|
||||
var dir = new DirectoryInfo(TexturePack.TexturePackPath);
|
||||
Process.Start(dir.FullName);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user