mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-22 15:02:54 +08:00
Moved all GameFiles to CodeWalker.Core
This commit is contained in:
parent
375db771ee
commit
cbd242b8cc
@ -41,7 +41,7 @@ namespace CodeWalker
|
|||||||
{
|
{
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
GTA5Keys.LoadFromPath(Settings.Default.GTAFolder, Settings.Default.Key);
|
GTA5Keys.LoadFromPath(GTAFolder.CurrentGTAFolder, Settings.Default.Key);
|
||||||
RpfMan = new RpfManager();
|
RpfMan = new RpfManager();
|
||||||
RpfMan.Init(GTAFolder.CurrentGTAFolder, UpdateStatus, UpdateStatus, false, false);
|
RpfMan.Init(GTAFolder.CurrentGTAFolder, UpdateStatus, UpdateStatus, false, false);
|
||||||
RPFScanComplete();
|
RPFScanComplete();
|
||||||
|
@ -64,7 +64,7 @@ namespace CodeWalker
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
GTA5Keys.LoadFromPath(Settings.Default.GTAFolder, Settings.Default.Key);
|
GTA5Keys.LoadFromPath(GTAFolder.CurrentGTAFolder, Settings.Default.Key);
|
||||||
KeysLoaded = true;
|
KeysLoaded = true;
|
||||||
UpdateStatus("Ready to scan...");
|
UpdateStatus("Ready to scan...");
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,61 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="GameFiles\FileTypes\AwcFile.cs" />
|
||||||
|
<Compile Include="GameFiles\FileTypes\CacheDatFile.cs" />
|
||||||
|
<Compile Include="GameFiles\FileTypes\CutFile.cs" />
|
||||||
|
<Compile Include="GameFiles\FileTypes\DlcContentFile.cs" />
|
||||||
|
<Compile Include="GameFiles\FileTypes\DlcSetupFile.cs" />
|
||||||
|
<Compile Include="GameFiles\FileTypes\FxcFile.cs" />
|
||||||
|
<Compile Include="GameFiles\FileTypes\GtxdFile.cs" />
|
||||||
|
<Compile Include="GameFiles\FileTypes\Gxt2File.cs" />
|
||||||
|
<Compile Include="GameFiles\FileTypes\JPsoFile.cs" />
|
||||||
|
<Compile Include="GameFiles\FileTypes\RelFile.cs" />
|
||||||
|
<Compile Include="GameFiles\FileTypes\Stats.cs" />
|
||||||
|
<Compile Include="GameFiles\FileTypes\YbnFile.cs" />
|
||||||
|
<Compile Include="GameFiles\FileTypes\YcdFile.cs" />
|
||||||
|
<Compile Include="GameFiles\FileTypes\YddFile.cs" />
|
||||||
|
<Compile Include="GameFiles\FileTypes\YdrFile.cs" />
|
||||||
|
<Compile Include="GameFiles\FileTypes\YftFile.cs" />
|
||||||
|
<Compile Include="GameFiles\FileTypes\YmapFile.cs" />
|
||||||
|
<Compile Include="GameFiles\FileTypes\YmfFile.cs" />
|
||||||
|
<Compile Include="GameFiles\FileTypes\YmtFile.cs" />
|
||||||
|
<Compile Include="GameFiles\FileTypes\YndFile.cs" />
|
||||||
|
<Compile Include="GameFiles\FileTypes\YnvFile.cs" />
|
||||||
|
<Compile Include="GameFiles\FileTypes\YptFile.cs" />
|
||||||
|
<Compile Include="GameFiles\FileTypes\YtdFile.cs" />
|
||||||
|
<Compile Include="GameFiles\FileTypes\YtypFile.cs" />
|
||||||
|
<Compile Include="GameFiles\FileTypes\YvrFile.cs" />
|
||||||
|
<Compile Include="GameFiles\FileTypes\YwrFile.cs" />
|
||||||
|
<Compile Include="GameFiles\GameFile.cs" />
|
||||||
|
<Compile Include="GameFiles\GameFileCache.cs" />
|
||||||
|
<Compile Include="GameFiles\MetaTypes\Archetype.cs" />
|
||||||
|
<Compile Include="GameFiles\MetaTypes\Meta.cs" />
|
||||||
|
<Compile Include="GameFiles\MetaTypes\MetaBuilder.cs" />
|
||||||
|
<Compile Include="GameFiles\MetaTypes\MetaNames.cs" />
|
||||||
|
<Compile Include="GameFiles\MetaTypes\MetaTypes.cs" />
|
||||||
|
<Compile Include="GameFiles\MetaTypes\MetaXml.cs" />
|
||||||
|
<Compile Include="GameFiles\MetaTypes\Pso.cs" />
|
||||||
|
<Compile Include="GameFiles\MetaTypes\PsoTypes.cs" />
|
||||||
|
<Compile Include="GameFiles\MetaTypes\Rbf.cs" />
|
||||||
|
<Compile Include="GameFiles\MetaTypes\XmlMeta.cs" />
|
||||||
|
<Compile Include="GameFiles\Resources\Bounds.cs" />
|
||||||
|
<Compile Include="GameFiles\Resources\Clip.cs" />
|
||||||
|
<Compile Include="GameFiles\Resources\Drawable.cs" />
|
||||||
|
<Compile Include="GameFiles\Resources\Frag.cs" />
|
||||||
|
<Compile Include="GameFiles\Resources\Nav.cs" />
|
||||||
|
<Compile Include="GameFiles\Resources\Node.cs" />
|
||||||
|
<Compile Include="GameFiles\Resources\Particle.cs" />
|
||||||
|
<Compile Include="GameFiles\Resources\ResourceBaseTypes.cs" />
|
||||||
|
<Compile Include="GameFiles\Resources\ResourceBuilder.cs" />
|
||||||
|
<Compile Include="GameFiles\Resources\ResourceData.cs" />
|
||||||
|
<Compile Include="GameFiles\Resources\ResourceFile.cs" />
|
||||||
|
<Compile Include="GameFiles\Resources\Texture.cs" />
|
||||||
|
<Compile Include="GameFiles\Resources\VehicleRecord.cs" />
|
||||||
|
<Compile Include="GameFiles\Resources\VertexType.cs" />
|
||||||
|
<Compile Include="GameFiles\Resources\WaypointRecord.cs" />
|
||||||
|
<Compile Include="GameFiles\RpfFile.cs" />
|
||||||
|
<Compile Include="GameFiles\RpfManager.cs" />
|
||||||
<Compile Include="GameFiles\Utils\Data.cs" />
|
<Compile Include="GameFiles\Utils\Data.cs" />
|
||||||
<Compile Include="GameFiles\Utils\GTACrypto.cs" />
|
<Compile Include="GameFiles\Utils\GTACrypto.cs" />
|
||||||
<Compile Include="GameFiles\Utils\GTAKeys.cs" />
|
<Compile Include="GameFiles\Utils\GTAKeys.cs" />
|
||||||
@ -63,6 +118,18 @@
|
|||||||
<Compile Include="Utils\Utils.cs" />
|
<Compile Include="Utils\Utils.cs" />
|
||||||
<Compile Include="Utils\Vectors.cs" />
|
<Compile Include="Utils\Vectors.cs" />
|
||||||
<Compile Include="Utils\Xml.cs" />
|
<Compile Include="Utils\Xml.cs" />
|
||||||
|
<Compile Include="World\AudioZones.cs" />
|
||||||
|
<Compile Include="World\Camera.cs" />
|
||||||
|
<Compile Include="World\Clouds.cs" />
|
||||||
|
<Compile Include="World\Entity.cs" />
|
||||||
|
<Compile Include="World\PopZones.cs" />
|
||||||
|
<Compile Include="World\Scenarios.cs" />
|
||||||
|
<Compile Include="World\Space.cs" />
|
||||||
|
<Compile Include="World\Timecycle.cs" />
|
||||||
|
<Compile Include="World\TimecycleMods.cs" />
|
||||||
|
<Compile Include="World\Trains.cs" />
|
||||||
|
<Compile Include="World\Water.cs" />
|
||||||
|
<Compile Include="World\Weather.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using SharpDX.D3DCompiler;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@ -104,8 +103,9 @@ namespace CodeWalker.GameFiles
|
|||||||
for (int s = 1; s < sc0; s++)
|
for (int s = 1; s < sc0; s++)
|
||||||
{
|
{
|
||||||
bool exbyteflag1 = (gindex==5); //GS seems to be in diff format??
|
bool exbyteflag1 = (gindex==5); //GS seems to be in diff format??
|
||||||
|
bool vsgsps = (gindex == 1) || (gindex == 2) || (gindex == 5);
|
||||||
FxcShader shader = new FxcShader();
|
FxcShader shader = new FxcShader();
|
||||||
if (!shader.Read(br, exbyteflag1))
|
if (!shader.Read(br, exbyteflag1, vsgsps))
|
||||||
{
|
{
|
||||||
LastError += shader.LastError;
|
LastError += shader.LastError;
|
||||||
//gindex = 6; //get outta the loop?
|
//gindex = 6; //get outta the loop?
|
||||||
@ -537,13 +537,14 @@ namespace CodeWalker.GameFiles
|
|||||||
public FxcShaderBufferRef[] Buffers { get; set; }//CBuffers
|
public FxcShaderBufferRef[] Buffers { get; set; }//CBuffers
|
||||||
public byte VersionMajor { get; set; }
|
public byte VersionMajor { get; set; }
|
||||||
public byte VersionMinor { get; set; }
|
public byte VersionMinor { get; set; }
|
||||||
|
public string VersionString { get; set; }
|
||||||
public byte[] ByteCode { get; set; }
|
public byte[] ByteCode { get; set; }
|
||||||
public ShaderBytecode ByteCodeObj { get; set; }
|
//public ShaderBytecode ByteCodeObj { get; set; }
|
||||||
public ShaderProfile ShaderProfile { get; set; }
|
//public ShaderProfile ShaderProfile { get; set; }
|
||||||
public string Disassembly { get; set; }
|
public string Disassembly { get; set; }
|
||||||
public string LastError { get; set; }
|
public string LastError { get; set; }
|
||||||
|
|
||||||
public bool Read(BinaryReader br, bool exbyteflag)
|
public bool Read(BinaryReader br, bool exbyteflag, bool vsgsps)
|
||||||
{
|
{
|
||||||
Offset = br.BaseStream.Position;
|
Offset = br.BaseStream.Position;
|
||||||
|
|
||||||
@ -592,38 +593,37 @@ namespace CodeWalker.GameFiles
|
|||||||
|
|
||||||
ByteCode = br.ReadBytes((int)datalength);
|
ByteCode = br.ReadBytes((int)datalength);
|
||||||
|
|
||||||
|
if (vsgsps)
|
||||||
try
|
|
||||||
{
|
{
|
||||||
ByteCodeObj = new ShaderBytecode(ByteCode);
|
|
||||||
|
|
||||||
ShaderProfile = ByteCodeObj.GetVersion();
|
|
||||||
|
|
||||||
|
|
||||||
switch (ShaderProfile.Version)
|
|
||||||
{
|
|
||||||
case ShaderVersion.VertexShader:
|
|
||||||
case ShaderVersion.PixelShader:
|
|
||||||
case ShaderVersion.GeometryShader:
|
|
||||||
VersionMajor = br.ReadByte();//4,5 //appears to be shader model version
|
VersionMajor = br.ReadByte();//4,5 //appears to be shader model version
|
||||||
VersionMinor = br.ReadByte(); //perhaps shader minor version
|
VersionMinor = br.ReadByte(); //perhaps shader minor version
|
||||||
break;
|
|
||||||
default:
|
|
||||||
VersionMajor = (byte)ShaderProfile.Major;
|
|
||||||
VersionMinor = (byte)ShaderProfile.Minor;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//try
|
||||||
//do disassembly last, so any errors won't cause the file read to break
|
//{
|
||||||
Disassembly = ByteCodeObj.Disassemble();
|
// ByteCodeObj = new ShaderBytecode(ByteCode);
|
||||||
|
// ShaderProfile = ByteCodeObj.GetVersion();
|
||||||
}
|
// switch (ShaderProfile.Version)
|
||||||
catch (Exception ex)
|
// {
|
||||||
{
|
// case ShaderVersion.VertexShader:
|
||||||
LastError += ex.ToString() + "\r\n";
|
// case ShaderVersion.PixelShader:
|
||||||
return false;
|
// case ShaderVersion.GeometryShader:
|
||||||
}
|
// VersionMajor = br.ReadByte();//4,5 //appears to be shader model version
|
||||||
|
// VersionMinor = br.ReadByte(); //perhaps shader minor version
|
||||||
|
// break;
|
||||||
|
// default:
|
||||||
|
// VersionMajor = (byte)ShaderProfile.Major;
|
||||||
|
// VersionMinor = (byte)ShaderProfile.Minor;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// //do disassembly last, so any errors won't cause the file read to break
|
||||||
|
// Disassembly = ByteCodeObj.Disassemble();
|
||||||
|
//}
|
||||||
|
//catch (Exception ex)
|
||||||
|
//{
|
||||||
|
// LastError += ex.ToString() + "\r\n";
|
||||||
|
// return false;
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
@ -72,4 +72,22 @@ namespace CodeWalker.GameFiles
|
|||||||
Gtxd = 16,
|
Gtxd = 16,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public struct GameFileCacheKey
|
||||||
|
{
|
||||||
|
public uint Hash { get; set; }
|
||||||
|
public GameFileType Type { get; set; }
|
||||||
|
|
||||||
|
public GameFileCacheKey(uint hash, GameFileType type)
|
||||||
|
{
|
||||||
|
Hash = hash;
|
||||||
|
Type = type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,5 +1,4 @@
|
|||||||
using CodeWalker.Properties;
|
using SharpDX;
|
||||||
using SharpDX;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -22,7 +21,7 @@ namespace CodeWalker.GameFiles
|
|||||||
private ConcurrentStack<GameFile> requestQueue = new ConcurrentStack<GameFile>();
|
private ConcurrentStack<GameFile> requestQueue = new ConcurrentStack<GameFile>();
|
||||||
|
|
||||||
////dynamic cache
|
////dynamic cache
|
||||||
private Cache<GameFileCacheKey, GameFile> mainCache = new Cache<GameFileCacheKey, GameFile>(Settings.Default.CacheSize, Settings.Default.CacheTime);//2GB
|
private Cache<GameFileCacheKey, GameFile> mainCache;
|
||||||
public volatile bool IsInited = false;
|
public volatile bool IsInited = false;
|
||||||
|
|
||||||
private volatile bool archetypesLoaded = false;
|
private volatile bool archetypesLoaded = false;
|
||||||
@ -86,6 +85,18 @@ namespace CodeWalker.GameFiles
|
|||||||
|
|
||||||
private bool PreloadedMode = false;
|
private bool PreloadedMode = false;
|
||||||
|
|
||||||
|
private string GTAFolder;
|
||||||
|
private string ExcludeFolders;
|
||||||
|
|
||||||
|
public GameFileCache(long size, double cacheTime, string folder, string dlc, bool mods, string excludeFolders)
|
||||||
|
{
|
||||||
|
mainCache = new Cache<GameFileCacheKey, GameFile>(size, cacheTime);//2GB is good as default
|
||||||
|
SelectedDlc = dlc;
|
||||||
|
EnableDlc = !string.IsNullOrEmpty(SelectedDlc);
|
||||||
|
EnableMods = mods;
|
||||||
|
GTAFolder = folder;
|
||||||
|
ExcludeFolders = excludeFolders;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void Clear()
|
public void Clear()
|
||||||
@ -110,18 +121,14 @@ namespace CodeWalker.GameFiles
|
|||||||
|
|
||||||
if (RpfMan == null)
|
if (RpfMan == null)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
SelectedDlc = Settings.Default.DLC;
|
|
||||||
EnableDlc = !string.IsNullOrEmpty(SelectedDlc);
|
EnableDlc = !string.IsNullOrEmpty(SelectedDlc);
|
||||||
EnableMods = Settings.Default.EnableMods;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RpfMan = new RpfManager();
|
RpfMan = new RpfManager();
|
||||||
RpfMan.ExcludePaths = GetExcludePaths();
|
RpfMan.ExcludePaths = GetExcludePaths();
|
||||||
RpfMan.EnableMods = EnableMods;
|
RpfMan.EnableMods = EnableMods;
|
||||||
RpfMan.Init(GTAFolder.CurrentGTAFolder, UpdateStatus, ErrorLog);//, true);
|
RpfMan.Init(GTAFolder, UpdateStatus, ErrorLog);//, true);
|
||||||
|
|
||||||
//RE test area!
|
//RE test area!
|
||||||
//DecodeRelFiles();
|
//DecodeRelFiles();
|
||||||
@ -2078,7 +2085,7 @@ namespace CodeWalker.GameFiles
|
|||||||
|
|
||||||
private string[] GetExcludePaths()
|
private string[] GetExcludePaths()
|
||||||
{
|
{
|
||||||
string[] exclpaths = Settings.Default.ExcludeFolders.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
|
string[] exclpaths = ExcludeFolders.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
if (exclpaths.Length > 0)
|
if (exclpaths.Length > 0)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < exclpaths.Length; i++)
|
for (int i = 0; i < exclpaths.Length; i++)
|
||||||
@ -2647,17 +2654,5 @@ namespace CodeWalker.GameFiles
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct GameFileCacheKey
|
|
||||||
{
|
|
||||||
public uint Hash { get; set; }
|
|
||||||
public GameFileType Type { get; set; }
|
|
||||||
|
|
||||||
public GameFileCacheKey(uint hash, GameFileType type)
|
|
||||||
{
|
|
||||||
Hash = hash;
|
|
||||||
Type = type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -6,7 +6,7 @@ using SharpDX;
|
|||||||
|
|
||||||
namespace CodeWalker.GameFiles
|
namespace CodeWalker.GameFiles
|
||||||
{
|
{
|
||||||
class XmlMeta
|
public class XmlMeta
|
||||||
{
|
{
|
||||||
public static Meta GetMeta(XmlDocument doc)
|
public static Meta GetMeta(XmlDocument doc)
|
||||||
{
|
{
|
@ -24,7 +24,6 @@
|
|||||||
|
|
||||||
|
|
||||||
using SharpDX;
|
using SharpDX;
|
||||||
using SharpDX.DXGI;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
@ -24,7 +24,6 @@
|
|||||||
|
|
||||||
|
|
||||||
using SharpDX;
|
using SharpDX;
|
||||||
using SharpDX.DXGI;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
@ -1,5 +1,4 @@
|
|||||||
using SharpDX.DXGI;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -443,149 +442,4 @@ namespace CodeWalker.GameFiles
|
|||||||
//UNKNOWN
|
//UNKNOWN
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TextureFormats
|
|
||||||
{
|
|
||||||
public static SharpDX.DXGI.Format GetDXGIFormat(TextureFormat fmt)
|
|
||||||
{
|
|
||||||
SharpDX.DXGI.Format format = SharpDX.DXGI.Format.Unknown;
|
|
||||||
switch (fmt)
|
|
||||||
{
|
|
||||||
// compressed
|
|
||||||
case TextureFormat.D3DFMT_DXT1: format = SharpDX.DXGI.Format.BC1_UNorm; break;
|
|
||||||
case TextureFormat.D3DFMT_DXT3: format = SharpDX.DXGI.Format.BC2_UNorm; break;
|
|
||||||
case TextureFormat.D3DFMT_DXT5: format = SharpDX.DXGI.Format.BC3_UNorm; break;
|
|
||||||
case TextureFormat.D3DFMT_ATI1: format = SharpDX.DXGI.Format.BC4_UNorm; break;
|
|
||||||
case TextureFormat.D3DFMT_ATI2: format = SharpDX.DXGI.Format.BC5_UNorm; break;
|
|
||||||
case TextureFormat.D3DFMT_BC7: format = SharpDX.DXGI.Format.BC7_UNorm; break;
|
|
||||||
|
|
||||||
// uncompressed
|
|
||||||
case TextureFormat.D3DFMT_A1R5G5B5: format = SharpDX.DXGI.Format.B5G5R5A1_UNorm; break;
|
|
||||||
case TextureFormat.D3DFMT_A8: format = SharpDX.DXGI.Format.A8_UNorm; break;
|
|
||||||
case TextureFormat.D3DFMT_A8B8G8R8: format = SharpDX.DXGI.Format.R8G8B8A8_UNorm; break;
|
|
||||||
case TextureFormat.D3DFMT_L8: format = SharpDX.DXGI.Format.R8_UNorm; break;
|
|
||||||
case TextureFormat.D3DFMT_A8R8G8B8: format = SharpDX.DXGI.Format.B8G8R8A8_UNorm; break;
|
|
||||||
}
|
|
||||||
return format;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int ByteSize(TextureFormat fmt)
|
|
||||||
{
|
|
||||||
switch (fmt)
|
|
||||||
{
|
|
||||||
// compressed
|
|
||||||
case TextureFormat.D3DFMT_DXT1: return 4;// BC1_UNorm
|
|
||||||
case TextureFormat.D3DFMT_DXT3: return 8;// BC2_UNorm
|
|
||||||
case TextureFormat.D3DFMT_DXT5: return 8;// BC3_UNorm
|
|
||||||
case TextureFormat.D3DFMT_ATI1: return 4;// BC4_UNorm
|
|
||||||
case TextureFormat.D3DFMT_ATI2: return 8;// BC5_UNorm
|
|
||||||
case TextureFormat.D3DFMT_BC7: return 8;// BC7_UNorm
|
|
||||||
|
|
||||||
// uncompressed
|
|
||||||
case TextureFormat.D3DFMT_A1R5G5B5: return 16;// B5G5R5A1_UNorm
|
|
||||||
case TextureFormat.D3DFMT_A8: return 8;// A8_UNorm
|
|
||||||
case TextureFormat.D3DFMT_A8B8G8R8: return 32;// R8G8B8A8_UNorm
|
|
||||||
case TextureFormat.D3DFMT_L8: return 8;// R8_UNorm
|
|
||||||
case TextureFormat.D3DFMT_A8R8G8B8: return 32;// B8G8R8A8_UNorm
|
|
||||||
|
|
||||||
default: return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void ComputePitch(Format fmt, int width, int height, out int rowPitch, out int slicePitch, uint flags)
|
|
||||||
{
|
|
||||||
int nbw, nbh;
|
|
||||||
switch (fmt)
|
|
||||||
{
|
|
||||||
case Format.BC1_Typeless:
|
|
||||||
case Format.BC1_UNorm:
|
|
||||||
case Format.BC1_UNorm_SRgb:
|
|
||||||
case Format.BC4_Typeless:
|
|
||||||
case Format.BC4_UNorm:
|
|
||||||
case Format.BC4_SNorm:
|
|
||||||
nbw = Math.Max(1, (width + 3) / 4);
|
|
||||||
nbh = Math.Max(1, (height + 3) / 4);
|
|
||||||
rowPitch = nbw * 8;
|
|
||||||
slicePitch = rowPitch * nbh;
|
|
||||||
break;
|
|
||||||
case Format.BC2_Typeless:
|
|
||||||
case Format.BC2_UNorm:
|
|
||||||
case Format.BC2_UNorm_SRgb:
|
|
||||||
case Format.BC3_Typeless:
|
|
||||||
case Format.BC3_UNorm:
|
|
||||||
case Format.BC3_UNorm_SRgb:
|
|
||||||
case Format.BC5_Typeless:
|
|
||||||
case Format.BC5_UNorm:
|
|
||||||
case Format.BC5_SNorm:
|
|
||||||
case Format.BC6H_Typeless:
|
|
||||||
case Format.BC6H_Uf16:
|
|
||||||
case Format.BC6H_Sf16:
|
|
||||||
case Format.BC7_Typeless:
|
|
||||||
case Format.BC7_UNorm:
|
|
||||||
case Format.BC7_UNorm_SRgb:
|
|
||||||
nbw = Math.Max(1, (width + 3) / 4);
|
|
||||||
nbh = Math.Max(1, (height + 3) / 4);
|
|
||||||
rowPitch = nbw * 16;
|
|
||||||
slicePitch = rowPitch * nbh;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Format.R8G8_B8G8_UNorm:
|
|
||||||
case Format.G8R8_G8B8_UNorm:
|
|
||||||
case Format.YUY2:
|
|
||||||
rowPitch = ((width + 1) >> 1) * 4;
|
|
||||||
slicePitch = rowPitch * height;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Format.Y210:
|
|
||||||
case Format.Y216:
|
|
||||||
rowPitch = ((width + 1) >> 1) * 8;
|
|
||||||
slicePitch = rowPitch * height;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Format.NV12:
|
|
||||||
case Format.Opaque420:
|
|
||||||
rowPitch = ((width + 1) >> 1) * 2;
|
|
||||||
slicePitch = rowPitch * (height + ((height + 1) >> 1));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Format.P010:
|
|
||||||
case Format.P016:
|
|
||||||
//case Format.XBOX_DXGI_FORMAT_D16_UNORM_S8_UINT:
|
|
||||||
//case Format.XBOX_DXGI_FORMAT_R16_UNORM_X8_TYPELESS:
|
|
||||||
//case Format.XBOX_DXGI_FORMAT_X16_TYPELESS_G8_UINT:
|
|
||||||
rowPitch = ((width + 1) >> 1) * 4;
|
|
||||||
slicePitch = rowPitch * (height + ((height + 1) >> 1));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Format.NV11:
|
|
||||||
rowPitch = ((width + 3) >> 2) * 4;
|
|
||||||
slicePitch = rowPitch * height * 2;
|
|
||||||
break;
|
|
||||||
|
|
||||||
//case Format.WIN10_DXGI_FORMAT_P208:
|
|
||||||
// rowPitch = ((width + 1) >> 1) * 2;
|
|
||||||
// slicePitch = rowPitch * height * 2;
|
|
||||||
// break;
|
|
||||||
|
|
||||||
//case Format.WIN10_DXGI_FORMAT_V208:
|
|
||||||
// rowPitch = width;
|
|
||||||
// slicePitch = rowPitch * (height + (((height + 1) >> 1) * 2));
|
|
||||||
// break;
|
|
||||||
|
|
||||||
//case Format.WIN10_DXGI_FORMAT_V408:
|
|
||||||
// rowPitch = width;
|
|
||||||
// slicePitch = rowPitch * (height + ((height >> 1) * 4));
|
|
||||||
// break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
int bpp = FormatHelper.SizeOfInBytes(fmt) * 8;
|
|
||||||
// Default byte alignment
|
|
||||||
rowPitch = (width * bpp + 7) / 8;
|
|
||||||
slicePitch = rowPitch * height;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,5 +1,4 @@
|
|||||||
using CodeWalker.Properties;
|
using SharpDX;
|
||||||
using SharpDX;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -12,8 +11,8 @@ namespace CodeWalker.World
|
|||||||
{
|
{
|
||||||
public Vector3 TargetRotation = Vector3.Zero;
|
public Vector3 TargetRotation = Vector3.Zero;
|
||||||
public Vector3 CurrentRotation = Vector3.Zero;
|
public Vector3 CurrentRotation = Vector3.Zero;
|
||||||
public float Smoothness = Settings.Default.CameraSmoothing;// 10.0f;//0.15f;
|
public float Smoothness;// 10.0f;//0.15f;
|
||||||
public float Sensitivity = Settings.Default.CameraSensitivity;// 0.005f;
|
public float Sensitivity;// 0.005f;
|
||||||
public float TargetDistance = 1.0f;
|
public float TargetDistance = 1.0f;
|
||||||
public float CurrentDistance = 1.0f;
|
public float CurrentDistance = 1.0f;
|
||||||
public float ZoomCurrentTime = 0.0f;
|
public float ZoomCurrentTime = 0.0f;
|
||||||
@ -22,7 +21,7 @@ namespace CodeWalker.World
|
|||||||
public float ZoomSpeed = 0.1f;
|
public float ZoomSpeed = 0.1f;
|
||||||
public float Width = 1920.0f;
|
public float Width = 1920.0f;
|
||||||
public float Height = 1080.0f;
|
public float Height = 1080.0f;
|
||||||
public float FieldOfView = Settings.Default.CameraFieldOfView;// 1.0f;
|
public float FieldOfView;// 1.0f;
|
||||||
public float FieldOfViewFactor = 0.5f / (float)Math.Tan(/*FieldOfView*/ 1.0f * 0.5f);
|
public float FieldOfViewFactor = 0.5f / (float)Math.Tan(/*FieldOfView*/ 1.0f * 0.5f);
|
||||||
public float AspectRatio = 1920.0f / 1080.0f;
|
public float AspectRatio = 1920.0f / 1080.0f;
|
||||||
public float ZNear = 0.5f;
|
public float ZNear = 0.5f;
|
||||||
@ -54,6 +53,15 @@ namespace CodeWalker.World
|
|||||||
private object syncRoot = new object();
|
private object syncRoot = new object();
|
||||||
|
|
||||||
|
|
||||||
|
public Camera(float smoothness, float sensitivity, float fov)
|
||||||
|
{
|
||||||
|
Smoothness = smoothness;
|
||||||
|
Sensitivity = sensitivity;
|
||||||
|
FieldOfView = fov;
|
||||||
|
FieldOfViewFactor = 0.5f / (float)Math.Tan(FieldOfView * 0.5f);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void SetMousePosition(int x, int y)
|
public void SetMousePosition(int x, int y)
|
||||||
{
|
{
|
||||||
MouseX = (x / Width) * 2.0f - 1.0f;
|
MouseX = (x / Width) * 2.0f - 1.0f;
|
@ -258,59 +258,8 @@
|
|||||||
<Compile Include="Forms\YwrForm.Designer.cs">
|
<Compile Include="Forms\YwrForm.Designer.cs">
|
||||||
<DependentUpon>YwrForm.cs</DependentUpon>
|
<DependentUpon>YwrForm.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="GameFiles\FileTypes\AwcFile.cs" />
|
<Compile Include="GameFiles\FxcParser.cs" />
|
||||||
<Compile Include="GameFiles\FileTypes\CutFile.cs" />
|
<Compile Include="GameFiles\GameFileCacheFactory.cs" />
|
||||||
<Compile Include="GameFiles\FileTypes\DlcContentFile.cs" />
|
|
||||||
<Compile Include="GameFiles\FileTypes\DlcSetupFile.cs" />
|
|
||||||
<Compile Include="GameFiles\FileTypes\GtxdFile.cs" />
|
|
||||||
<Compile Include="GameFiles\FileTypes\Gxt2File.cs" />
|
|
||||||
<Compile Include="GameFiles\FileTypes\JPsoFile.cs" />
|
|
||||||
<Compile Include="GameFiles\FileTypes\RelFile.cs" />
|
|
||||||
<Compile Include="GameFiles\FileTypes\Stats.cs" />
|
|
||||||
<Compile Include="GameFiles\FileTypes\YbnFile.cs" />
|
|
||||||
<Compile Include="GameFiles\FileTypes\YcdFile.cs" />
|
|
||||||
<Compile Include="GameFiles\FileTypes\YnvFile.cs" />
|
|
||||||
<Compile Include="GameFiles\FileTypes\YptFile.cs" />
|
|
||||||
<Compile Include="GameFiles\FileTypes\YvrFile.cs" />
|
|
||||||
<Compile Include="GameFiles\FileTypes\YwrFile.cs" />
|
|
||||||
<Compile Include="GameFiles\MetaTypes\MetaBuilder.cs" />
|
|
||||||
<Compile Include="GameFiles\MetaTypes\MetaXml.cs" />
|
|
||||||
<Compile Include="GameFiles\MetaTypes\XmlMeta.cs" />
|
|
||||||
<Compile Include="GameFiles\Resources\Archetype.cs" />
|
|
||||||
<Compile Include="GameFiles\FileTypes\CacheDatFile.cs" />
|
|
||||||
<Compile Include="GameFiles\Resources\Bounds.cs" />
|
|
||||||
<Compile Include="GameFiles\Resources\Clip.cs" />
|
|
||||||
<Compile Include="GameFiles\Resources\Drawable.cs" />
|
|
||||||
<Compile Include="GameFiles\Resources\Frag.cs" />
|
|
||||||
<Compile Include="GameFiles\FileTypes\FxcFile.cs" />
|
|
||||||
<Compile Include="GameFiles\GameFile.cs" />
|
|
||||||
<Compile Include="GameFiles\GameFileCache.cs" />
|
|
||||||
<Compile Include="GameFiles\Resources\Nav.cs" />
|
|
||||||
<Compile Include="GameFiles\Resources\Node.cs" />
|
|
||||||
<Compile Include="GameFiles\Resources\Particle.cs" />
|
|
||||||
<Compile Include="GameFiles\Resources\ResourceBuilder.cs" />
|
|
||||||
<Compile Include="GameFiles\Resources\Texture.cs" />
|
|
||||||
<Compile Include="GameFiles\Resources\VehicleRecord.cs" />
|
|
||||||
<Compile Include="GameFiles\Resources\WaypointRecord.cs" />
|
|
||||||
<Compile Include="GameFiles\MetaTypes\Meta.cs" />
|
|
||||||
<Compile Include="GameFiles\MetaTypes\MetaTypes.cs" />
|
|
||||||
<Compile Include="GameFiles\MetaTypes\MetaNames.cs" />
|
|
||||||
<Compile Include="GameFiles\MetaTypes\Pso.cs" />
|
|
||||||
<Compile Include="GameFiles\MetaTypes\PsoTypes.cs" />
|
|
||||||
<Compile Include="GameFiles\MetaTypes\Rbf.cs" />
|
|
||||||
<Compile Include="GameFiles\Resources\ResourceData.cs" />
|
|
||||||
<Compile Include="GameFiles\Resources\ResourceFile.cs" />
|
|
||||||
<Compile Include="GameFiles\Resources\ResourceBaseTypes.cs" />
|
|
||||||
<Compile Include="GameFiles\Resources\RpfManager.cs" />
|
|
||||||
<Compile Include="GameFiles\Resources\VertexType.cs" />
|
|
||||||
<Compile Include="GameFiles\FileTypes\YddFile.cs" />
|
|
||||||
<Compile Include="GameFiles\FileTypes\YdrFile.cs" />
|
|
||||||
<Compile Include="GameFiles\FileTypes\YftFile.cs" />
|
|
||||||
<Compile Include="GameFiles\FileTypes\YmapFile.cs" />
|
|
||||||
<Compile Include="GameFiles\FileTypes\YmfFile.cs" />
|
|
||||||
<Compile Include="GameFiles\FileTypes\YmtFile.cs" />
|
|
||||||
<Compile Include="GameFiles\FileTypes\YtypFile.cs" />
|
|
||||||
<Compile Include="GameFiles\FileTypes\YndFile.cs" />
|
|
||||||
<Compile Include="JenkGenForm.cs">
|
<Compile Include="JenkGenForm.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
@ -340,7 +289,6 @@
|
|||||||
<Compile Include="Project\ProjectFile.cs" />
|
<Compile Include="Project\ProjectFile.cs" />
|
||||||
<Compile Include="Project\UndoStep.cs" />
|
<Compile Include="Project\UndoStep.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="GameFiles\Resources\RpfFile.cs" />
|
|
||||||
<Compile Include="Rendering\DirectX\DXUtility.cs" />
|
<Compile Include="Rendering\DirectX\DXUtility.cs" />
|
||||||
<Compile Include="Rendering\Renderer.cs" />
|
<Compile Include="Rendering\Renderer.cs" />
|
||||||
<Compile Include="Rendering\Shaders\BasicShader.cs" />
|
<Compile Include="Rendering\Shaders\BasicShader.cs" />
|
||||||
@ -393,6 +341,7 @@
|
|||||||
<Compile Include="Utils\GTAFolder.cs" />
|
<Compile Include="Utils\GTAFolder.cs" />
|
||||||
<Compile Include="Utils\InputUtils.cs" />
|
<Compile Include="Utils\InputUtils.cs" />
|
||||||
<Compile Include="Utils\MapUtils.cs" />
|
<Compile Include="Utils\MapUtils.cs" />
|
||||||
|
<Compile Include="GameFiles\TextureFormats.cs" />
|
||||||
<Compile Include="Utils\TextureLoader.cs" />
|
<Compile Include="Utils\TextureLoader.cs" />
|
||||||
<Compile Include="ProjectForm.cs">
|
<Compile Include="ProjectForm.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
@ -412,8 +361,6 @@
|
|||||||
<Compile Include="WorldSearchForm.Designer.cs">
|
<Compile Include="WorldSearchForm.Designer.cs">
|
||||||
<DependentUpon>WorldSearchForm.cs</DependentUpon>
|
<DependentUpon>WorldSearchForm.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="World\AudioZones.cs" />
|
|
||||||
<Compile Include="World\Camera.cs" />
|
|
||||||
<Compile Include="Rendering\DirectX\DXForm.cs" />
|
<Compile Include="Rendering\DirectX\DXForm.cs" />
|
||||||
<Compile Include="Rendering\DirectX\DXManager.cs" />
|
<Compile Include="Rendering\DirectX\DXManager.cs" />
|
||||||
<Compile Include="Rendering\Utils\UnitQuad.cs" />
|
<Compile Include="Rendering\Utils\UnitQuad.cs" />
|
||||||
@ -429,17 +376,6 @@
|
|||||||
<Compile Include="WorldForm.Designer.cs">
|
<Compile Include="WorldForm.Designer.cs">
|
||||||
<DependentUpon>WorldForm.cs</DependentUpon>
|
<DependentUpon>WorldForm.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="GameFiles\FileTypes\YtdFile.cs" />
|
|
||||||
<Compile Include="World\Clouds.cs" />
|
|
||||||
<Compile Include="World\Entity.cs" />
|
|
||||||
<Compile Include="World\PopZones.cs" />
|
|
||||||
<Compile Include="World\Scenarios.cs" />
|
|
||||||
<Compile Include="World\Space.cs" />
|
|
||||||
<Compile Include="World\Timecycle.cs" />
|
|
||||||
<Compile Include="World\TimecycleMods.cs" />
|
|
||||||
<Compile Include="World\Trains.cs" />
|
|
||||||
<Compile Include="World\Water.cs" />
|
|
||||||
<Compile Include="World\Weather.cs" />
|
|
||||||
<Compile Include="World\Widget.cs" />
|
<Compile Include="World\Widget.cs" />
|
||||||
<EmbeddedResource Include="AboutForm.resx">
|
<EmbeddedResource Include="AboutForm.resx">
|
||||||
<DependentUpon>AboutForm.cs</DependentUpon>
|
<DependentUpon>AboutForm.cs</DependentUpon>
|
||||||
|
@ -40,7 +40,7 @@ namespace CodeWalker
|
|||||||
private MainTreeFolder SearchResults;
|
private MainTreeFolder SearchResults;
|
||||||
|
|
||||||
private List<RpfFile> AllRpfs { get; set; }
|
private List<RpfFile> AllRpfs { get; set; }
|
||||||
private GameFileCache FileCache { get; set; } = new GameFileCache();
|
private GameFileCache FileCache { get; set; } = GameFileCacheFactory.Create();
|
||||||
private object FileCacheSyncRoot = new object();
|
private object FileCacheSyncRoot = new object();
|
||||||
|
|
||||||
private bool EditMode = false;
|
private bool EditMode = false;
|
||||||
@ -73,7 +73,7 @@ namespace CodeWalker
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
GTA5Keys.LoadFromPath(Settings.Default.GTAFolder, Settings.Default.Key);
|
GTA5Keys.LoadFromPath(GTAFolder.CurrentGTAFolder, Settings.Default.Key);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
@ -30,7 +30,7 @@ namespace CodeWalker
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
GTA5Keys.LoadFromPath(Settings.Default.GTAFolder, Settings.Default.Key);
|
GTA5Keys.LoadFromPath(GTAFolder.CurrentGTAFolder, Settings.Default.Key);
|
||||||
KeysLoaded = true;
|
KeysLoaded = true;
|
||||||
UpdateStatus("Keys loaded. Nothing to do here!");
|
UpdateStatus("Keys loaded. Nothing to do here!");
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ namespace CodeWalker
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
GTA5Keys.LoadFromPath(Settings.Default.GTAFolder, Settings.Default.Key);
|
GTA5Keys.LoadFromPath(GTAFolder.CurrentGTAFolder, Settings.Default.Key);
|
||||||
KeysLoaded = true;
|
KeysLoaded = true;
|
||||||
UpdateExtractStatus("Ready to extract.");
|
UpdateExtractStatus("Ready to extract.");
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ namespace CodeWalker
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
GTA5Keys.LoadFromPath(Settings.Default.GTAFolder, Settings.Default.Key);
|
GTA5Keys.LoadFromPath(GTAFolder.CurrentGTAFolder, Settings.Default.Key);
|
||||||
KeysLoaded = true;
|
KeysLoaded = true;
|
||||||
UpdateDumpStatus("Ready.");
|
UpdateDumpStatus("Ready.");
|
||||||
UpdateExtractStatus("Ready to extract.");
|
UpdateExtractStatus("Ready to extract.");
|
||||||
|
@ -31,7 +31,7 @@ namespace CodeWalker
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
GTA5Keys.LoadFromPath(Settings.Default.GTAFolder, Settings.Default.Key);
|
GTA5Keys.LoadFromPath(GTAFolder.CurrentGTAFolder, Settings.Default.Key);
|
||||||
KeysLoaded = true;
|
KeysLoaded = true;
|
||||||
UpdateExtractStatus("Ready to extract.");
|
UpdateExtractStatus("Ready to extract.");
|
||||||
}
|
}
|
||||||
@ -163,6 +163,7 @@ namespace CodeWalker
|
|||||||
if (asm)
|
if (asm)
|
||||||
{
|
{
|
||||||
string asmfile = filebase + ".hlsl";
|
string asmfile = filebase + ".hlsl";
|
||||||
|
FxcParser.ParseShader(shader);
|
||||||
File.WriteAllText(asmfile, shader.Disassembly);
|
File.WriteAllText(asmfile, shader.Disassembly);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ namespace CodeWalker
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
GTA5Keys.LoadFromPath(Settings.Default.GTAFolder, Settings.Default.Key);
|
GTA5Keys.LoadFromPath(GTAFolder.CurrentGTAFolder, Settings.Default.Key);
|
||||||
KeysLoaded = true;
|
KeysLoaded = true;
|
||||||
UpdateExtractStatus("Ready to extract.");
|
UpdateExtractStatus("Ready to extract.");
|
||||||
}
|
}
|
||||||
|
@ -100,6 +100,7 @@ namespace CodeWalker.Forms
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
ShaderPanel.Enabled = true;
|
ShaderPanel.Enabled = true;
|
||||||
|
FxcParser.ParseShader(s);
|
||||||
if (!string.IsNullOrEmpty(s.LastError))
|
if (!string.IsNullOrEmpty(s.LastError))
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
50
GameFiles/FxcParser.cs
Normal file
50
GameFiles/FxcParser.cs
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
using SharpDX.D3DCompiler;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace CodeWalker.GameFiles
|
||||||
|
{
|
||||||
|
|
||||||
|
public static class FxcParser
|
||||||
|
{
|
||||||
|
|
||||||
|
public static bool ParseShader(FxcShader shader)
|
||||||
|
{
|
||||||
|
ShaderBytecode ByteCodeObj;
|
||||||
|
ShaderProfile ShaderProfile;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ByteCodeObj = new ShaderBytecode(shader.ByteCode);
|
||||||
|
|
||||||
|
ShaderProfile = ByteCodeObj.GetVersion();
|
||||||
|
|
||||||
|
|
||||||
|
switch (ShaderProfile.Version)
|
||||||
|
{
|
||||||
|
case ShaderVersion.VertexShader:
|
||||||
|
case ShaderVersion.PixelShader:
|
||||||
|
case ShaderVersion.GeometryShader:
|
||||||
|
//VersionMajor = br.ReadByte();//4,5 //appears to be shader model version
|
||||||
|
//VersionMinor = br.ReadByte(); //perhaps shader minor version
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
shader.VersionMajor = (byte)ShaderProfile.Major;
|
||||||
|
shader.VersionMinor = (byte)ShaderProfile.Minor;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
shader.Disassembly = ByteCodeObj.Disassemble();
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
shader.LastError += ex.ToString() + "\r\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
20
GameFiles/GameFileCacheFactory.cs
Normal file
20
GameFiles/GameFileCacheFactory.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
using CodeWalker.Properties;
|
||||||
|
|
||||||
|
namespace CodeWalker.GameFiles
|
||||||
|
{
|
||||||
|
|
||||||
|
public static class GameFileCacheFactory
|
||||||
|
{
|
||||||
|
|
||||||
|
public static GameFileCache Create()
|
||||||
|
{
|
||||||
|
var s = Settings.Default;
|
||||||
|
return new GameFileCache(s.CacheSize, s.CacheTime, GTAFolder.CurrentGTAFolder, s.DLC, s.EnableMods, s.ExcludeFolders);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
157
GameFiles/TextureFormats.cs
Normal file
157
GameFiles/TextureFormats.cs
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using SharpDX.DXGI;
|
||||||
|
|
||||||
|
namespace CodeWalker.GameFiles
|
||||||
|
{
|
||||||
|
|
||||||
|
public static class TextureFormats
|
||||||
|
{
|
||||||
|
public static Format GetDXGIFormat(TextureFormat fmt)
|
||||||
|
{
|
||||||
|
Format format = Format.Unknown;
|
||||||
|
switch (fmt)
|
||||||
|
{
|
||||||
|
// compressed
|
||||||
|
case TextureFormat.D3DFMT_DXT1: format = Format.BC1_UNorm; break;
|
||||||
|
case TextureFormat.D3DFMT_DXT3: format = Format.BC2_UNorm; break;
|
||||||
|
case TextureFormat.D3DFMT_DXT5: format = Format.BC3_UNorm; break;
|
||||||
|
case TextureFormat.D3DFMT_ATI1: format = Format.BC4_UNorm; break;
|
||||||
|
case TextureFormat.D3DFMT_ATI2: format = Format.BC5_UNorm; break;
|
||||||
|
case TextureFormat.D3DFMT_BC7: format = Format.BC7_UNorm; break;
|
||||||
|
|
||||||
|
// uncompressed
|
||||||
|
case TextureFormat.D3DFMT_A1R5G5B5: format = Format.B5G5R5A1_UNorm; break;
|
||||||
|
case TextureFormat.D3DFMT_A8: format = Format.A8_UNorm; break;
|
||||||
|
case TextureFormat.D3DFMT_A8B8G8R8: format = Format.R8G8B8A8_UNorm; break;
|
||||||
|
case TextureFormat.D3DFMT_L8: format = Format.R8_UNorm; break;
|
||||||
|
case TextureFormat.D3DFMT_A8R8G8B8: format = Format.B8G8R8A8_UNorm; break;
|
||||||
|
}
|
||||||
|
return format;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int ByteSize(TextureFormat fmt)
|
||||||
|
{
|
||||||
|
switch (fmt)
|
||||||
|
{
|
||||||
|
// compressed
|
||||||
|
case TextureFormat.D3DFMT_DXT1: return 4;// BC1_UNorm
|
||||||
|
case TextureFormat.D3DFMT_DXT3: return 8;// BC2_UNorm
|
||||||
|
case TextureFormat.D3DFMT_DXT5: return 8;// BC3_UNorm
|
||||||
|
case TextureFormat.D3DFMT_ATI1: return 4;// BC4_UNorm
|
||||||
|
case TextureFormat.D3DFMT_ATI2: return 8;// BC5_UNorm
|
||||||
|
case TextureFormat.D3DFMT_BC7: return 8;// BC7_UNorm
|
||||||
|
|
||||||
|
// uncompressed
|
||||||
|
case TextureFormat.D3DFMT_A1R5G5B5: return 16;// B5G5R5A1_UNorm
|
||||||
|
case TextureFormat.D3DFMT_A8: return 8;// A8_UNorm
|
||||||
|
case TextureFormat.D3DFMT_A8B8G8R8: return 32;// R8G8B8A8_UNorm
|
||||||
|
case TextureFormat.D3DFMT_L8: return 8;// R8_UNorm
|
||||||
|
case TextureFormat.D3DFMT_A8R8G8B8: return 32;// B8G8R8A8_UNorm
|
||||||
|
|
||||||
|
default: return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void ComputePitch(Format fmt, int width, int height, out int rowPitch, out int slicePitch, uint flags)
|
||||||
|
{
|
||||||
|
int nbw, nbh;
|
||||||
|
switch (fmt)
|
||||||
|
{
|
||||||
|
case Format.BC1_Typeless:
|
||||||
|
case Format.BC1_UNorm:
|
||||||
|
case Format.BC1_UNorm_SRgb:
|
||||||
|
case Format.BC4_Typeless:
|
||||||
|
case Format.BC4_UNorm:
|
||||||
|
case Format.BC4_SNorm:
|
||||||
|
nbw = Math.Max(1, (width + 3) / 4);
|
||||||
|
nbh = Math.Max(1, (height + 3) / 4);
|
||||||
|
rowPitch = nbw * 8;
|
||||||
|
slicePitch = rowPitch * nbh;
|
||||||
|
break;
|
||||||
|
case Format.BC2_Typeless:
|
||||||
|
case Format.BC2_UNorm:
|
||||||
|
case Format.BC2_UNorm_SRgb:
|
||||||
|
case Format.BC3_Typeless:
|
||||||
|
case Format.BC3_UNorm:
|
||||||
|
case Format.BC3_UNorm_SRgb:
|
||||||
|
case Format.BC5_Typeless:
|
||||||
|
case Format.BC5_UNorm:
|
||||||
|
case Format.BC5_SNorm:
|
||||||
|
case Format.BC6H_Typeless:
|
||||||
|
case Format.BC6H_Uf16:
|
||||||
|
case Format.BC6H_Sf16:
|
||||||
|
case Format.BC7_Typeless:
|
||||||
|
case Format.BC7_UNorm:
|
||||||
|
case Format.BC7_UNorm_SRgb:
|
||||||
|
nbw = Math.Max(1, (width + 3) / 4);
|
||||||
|
nbh = Math.Max(1, (height + 3) / 4);
|
||||||
|
rowPitch = nbw * 16;
|
||||||
|
slicePitch = rowPitch * nbh;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Format.R8G8_B8G8_UNorm:
|
||||||
|
case Format.G8R8_G8B8_UNorm:
|
||||||
|
case Format.YUY2:
|
||||||
|
rowPitch = ((width + 1) >> 1) * 4;
|
||||||
|
slicePitch = rowPitch * height;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Format.Y210:
|
||||||
|
case Format.Y216:
|
||||||
|
rowPitch = ((width + 1) >> 1) * 8;
|
||||||
|
slicePitch = rowPitch * height;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Format.NV12:
|
||||||
|
case Format.Opaque420:
|
||||||
|
rowPitch = ((width + 1) >> 1) * 2;
|
||||||
|
slicePitch = rowPitch * (height + ((height + 1) >> 1));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Format.P010:
|
||||||
|
case Format.P016:
|
||||||
|
//case Format.XBOX_DXGI_FORMAT_D16_UNORM_S8_UINT:
|
||||||
|
//case Format.XBOX_DXGI_FORMAT_R16_UNORM_X8_TYPELESS:
|
||||||
|
//case Format.XBOX_DXGI_FORMAT_X16_TYPELESS_G8_UINT:
|
||||||
|
rowPitch = ((width + 1) >> 1) * 4;
|
||||||
|
slicePitch = rowPitch * (height + ((height + 1) >> 1));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Format.NV11:
|
||||||
|
rowPitch = ((width + 3) >> 2) * 4;
|
||||||
|
slicePitch = rowPitch * height * 2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
//case Format.WIN10_DXGI_FORMAT_P208:
|
||||||
|
// rowPitch = ((width + 1) >> 1) * 2;
|
||||||
|
// slicePitch = rowPitch * height * 2;
|
||||||
|
// break;
|
||||||
|
|
||||||
|
//case Format.WIN10_DXGI_FORMAT_V208:
|
||||||
|
// rowPitch = width;
|
||||||
|
// slicePitch = rowPitch * (height + (((height + 1) >> 1) * 2));
|
||||||
|
// break;
|
||||||
|
|
||||||
|
//case Format.WIN10_DXGI_FORMAT_V408:
|
||||||
|
// rowPitch = width;
|
||||||
|
// slicePitch = rowPitch * (height + ((height >> 1) * 4));
|
||||||
|
// break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
int bpp = FormatHelper.SizeOfInBytes(fmt) * 8;
|
||||||
|
// Default byte alignment
|
||||||
|
rowPitch = (width * bpp + 7) / 8;
|
||||||
|
slicePitch = rowPitch * height;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -37,7 +37,7 @@ namespace CodeWalker
|
|||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
GTA5Keys.LoadFromPath(GTAFolder.CurrentGTAFolder, Settings.Default.Key);
|
GTA5Keys.LoadFromPath(GTAFolder.CurrentGTAFolder, Settings.Default.Key);
|
||||||
GameFileCache gfc = new GameFileCache();
|
GameFileCache gfc = GameFileCacheFactory.Create();
|
||||||
gfc.DoFullStringIndex = true;
|
gfc.DoFullStringIndex = true;
|
||||||
gfc.Init(UpdateStatus, UpdateStatus);
|
gfc.Init(UpdateStatus, UpdateStatus);
|
||||||
IndexBuildComplete();
|
IndexBuildComplete();
|
||||||
|
@ -86,7 +86,7 @@ namespace CodeWalker
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GameFileCache = new GameFileCache();
|
GameFileCache = GameFileCacheFactory.Create();
|
||||||
new Thread(new ThreadStart(() => {
|
new Thread(new ThreadStart(() => {
|
||||||
GameFileCache.Init(UpdateStatus, UpdateStatus);
|
GameFileCache.Init(UpdateStatus, UpdateStatus);
|
||||||
RpfMan = GameFileCache.RpfMan;
|
RpfMan = GameFileCache.RpfMan;
|
||||||
|
@ -27,7 +27,7 @@ namespace CodeWalker.Rendering
|
|||||||
|
|
||||||
public ShaderManager shaders;
|
public ShaderManager shaders;
|
||||||
|
|
||||||
public Camera camera = new Camera();
|
public Camera camera;
|
||||||
|
|
||||||
private double currentRealTime = 0;
|
private double currentRealTime = 0;
|
||||||
private float currentElapsedTime = 0;
|
private float currentElapsedTime = 0;
|
||||||
@ -154,9 +154,12 @@ namespace CodeWalker.Rendering
|
|||||||
gameFileCache = cache;
|
gameFileCache = cache;
|
||||||
if (gameFileCache == null)
|
if (gameFileCache == null)
|
||||||
{
|
{
|
||||||
gameFileCache = new GameFileCache();
|
gameFileCache = GameFileCacheFactory.Create();
|
||||||
}
|
}
|
||||||
renderableCache = new RenderableCache();
|
renderableCache = new RenderableCache();
|
||||||
|
|
||||||
|
var s = Settings.Default;
|
||||||
|
camera = new Camera(s.CameraSmoothing, s.CameraSensitivity, s.CameraFieldOfView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -86,6 +86,7 @@ namespace CodeWalker
|
|||||||
{
|
{
|
||||||
CurrentGTAFolder = folder;
|
CurrentGTAFolder = folder;
|
||||||
Settings.Default.GTAFolder = folder;
|
Settings.Default.GTAFolder = folder;
|
||||||
|
Settings.Default.Save();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ namespace CodeWalker
|
|||||||
|
|
||||||
|
|
||||||
public GameFileCache GameFileCache { get { return gameFileCache; } }
|
public GameFileCache GameFileCache { get { return gameFileCache; } }
|
||||||
GameFileCache gameFileCache = new GameFileCache();
|
GameFileCache gameFileCache = GameFileCacheFactory.Create();
|
||||||
|
|
||||||
|
|
||||||
WorldControlMode ControlMode = WorldControlMode.Free;
|
WorldControlMode ControlMode = WorldControlMode.Free;
|
||||||
|
Loading…
Reference in New Issue
Block a user