mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-30 02:42:54 +08:00
Merge branch 'master' of https://github.com/dexyfex/CodeWalker
This commit is contained in:
commit
176da9faf1
@ -1283,7 +1283,7 @@ namespace CodeWalker.GameFiles
|
|||||||
public string HeatsTyre { get; set; }
|
public string HeatsTyre { get; set; }
|
||||||
public string Material { get; set; }
|
public string Material { get; set; }
|
||||||
|
|
||||||
public Color4 Colour { get; set; }
|
public Color Colour { get; set; }
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
@ -1293,14 +1293,19 @@ namespace CodeWalker.GameFiles
|
|||||||
|
|
||||||
public static class BoundsMaterialTypes
|
public static class BoundsMaterialTypes
|
||||||
{
|
{
|
||||||
private static Dictionary<string, Color4> ColourDict;
|
private static Dictionary<string, Color> ColourDict;
|
||||||
private static List<BoundsMaterialData> Materials;
|
private static List<BoundsMaterialData> Materials;
|
||||||
|
|
||||||
public static void Init(GameFileCache gameFileCache)
|
public static void Init(GameFileCache gameFileCache)
|
||||||
{
|
{
|
||||||
var rpfman = gameFileCache.RpfMan;
|
var rpfman = gameFileCache.RpfMan;
|
||||||
|
|
||||||
InitColours();
|
var dic = new Dictionary<string,Color>();
|
||||||
|
string filename2 = "common.rpf\\data\\effects\\materialfx.dat";
|
||||||
|
string txt2 = rpfman.GetFileUTF8Text(filename2);
|
||||||
|
AddMaterialfxDat(txt2, dic);
|
||||||
|
|
||||||
|
ColourDict = dic;
|
||||||
|
|
||||||
var list = new List<BoundsMaterialData>();
|
var list = new List<BoundsMaterialData>();
|
||||||
string filename = "common.rpf\\data\\materials\\materials.dat";
|
string filename = "common.rpf\\data\\materials\\materials.dat";
|
||||||
@ -1314,25 +1319,47 @@ namespace CodeWalker.GameFiles
|
|||||||
Materials = list;
|
Materials = list;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void InitColours()
|
//Only gets the colors
|
||||||
|
private static void AddMaterialfxDat(string txt, Dictionary<string, Color> dic)
|
||||||
{
|
{
|
||||||
var dict = new Dictionary<string, Color4>();
|
dic.Clear();
|
||||||
string txt = File.ReadAllText("Materials.txt");
|
if (txt == null) return;
|
||||||
string[] lines = txt.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
|
|
||||||
for (int i = 0; i < lines.Length; i++)
|
string[] lines = txt.Split('\n');
|
||||||
|
string startLine = "MTLFX_TABLE_START";
|
||||||
|
string endLine = "MTLFX_TABLE_END";
|
||||||
|
|
||||||
|
for (int i = 1; i < lines.Length; i++)
|
||||||
{
|
{
|
||||||
var line = lines[i];
|
var line = lines[i];
|
||||||
if (line.Length < 10) continue;
|
|
||||||
if (line[0] == '#') continue;
|
if (line[0] == '#') continue;
|
||||||
|
if (line.StartsWith(startLine)) continue;
|
||||||
|
if (line.StartsWith(endLine)) break;
|
||||||
|
|
||||||
string[] parts = line.Split(new[] { '\t', ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
string[] parts = line.Split(new[] { '\t', ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
if (parts.Length != 2) continue;
|
|
||||||
string name = parts[0].Trim();
|
if (parts.Length < 5) continue; // FXGroup R G B ...
|
||||||
string cstr = parts[1].Trim();
|
|
||||||
uint cval = Convert.ToUInt32(cstr, 16);
|
int cp = 0;
|
||||||
Color4 c = new Color4(cval);
|
Color c = new Color();
|
||||||
dict[name] = c;
|
c.A = 0xFF;
|
||||||
|
string fxgroup = string.Empty;
|
||||||
|
for (int p = 0; p < parts.Length; p++)
|
||||||
|
{
|
||||||
|
string part = parts[p].Trim();
|
||||||
|
if (string.IsNullOrWhiteSpace(part)) continue;
|
||||||
|
switch (cp)
|
||||||
|
{
|
||||||
|
case 0: fxgroup = part; break;
|
||||||
|
case 1: c.R = byte.Parse(part); break;
|
||||||
|
case 2: c.G = byte.Parse(part); break;
|
||||||
|
case 3: c.B = byte.Parse(part); break;
|
||||||
|
}
|
||||||
|
cp++;
|
||||||
|
}
|
||||||
|
dic.Add(fxgroup, c);
|
||||||
}
|
}
|
||||||
ColourDict = dict;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AddMaterialsDat(string txt, List<BoundsMaterialData> list)
|
private static void AddMaterialsDat(string txt, List<BoundsMaterialData> list)
|
||||||
@ -1384,14 +1411,14 @@ namespace CodeWalker.GameFiles
|
|||||||
if (cp != 23)
|
if (cp != 23)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
Color4 c;
|
Color c;
|
||||||
if ((ColourDict != null) && (ColourDict.TryGetValue(d.Name, out c)))
|
if ((ColourDict != null) && (ColourDict.TryGetValue(d.FXGroup, out c)))
|
||||||
{
|
{
|
||||||
d.Colour = c;
|
d.Colour = c;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
d.Colour = new Color4(0xFFCCCCCC);
|
d.Colour = new Color(0xFFCCCCCC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1423,10 +1450,10 @@ namespace CodeWalker.GameFiles
|
|||||||
return m.Name;
|
return m.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Color4 GetMaterialColour(BoundsMaterialType type)
|
public static Color GetMaterialColour(BoundsMaterialType type)
|
||||||
{
|
{
|
||||||
var m = GetMaterial(type);
|
var m = GetMaterial(type);
|
||||||
if (m == null) return new Color4(0xFFCCCCCC);
|
if (m == null) return new Color(0xFFCCCCCC);
|
||||||
return m.Colour;
|
return m.Colour;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1871,6 +1871,17 @@ namespace CodeWalker.Project
|
|||||||
{
|
{
|
||||||
if ((CurrentYndFile == null) && (CurrentPathNode != null)) CurrentYndFile = CurrentPathNode.Ynd;
|
if ((CurrentYndFile == null) && (CurrentPathNode != null)) CurrentYndFile = CurrentPathNode.Ynd;
|
||||||
if (CurrentYndFile == null) return;
|
if (CurrentYndFile == null) return;
|
||||||
|
|
||||||
|
// Check that vehicle nodes and ped nodes add up to total nodes
|
||||||
|
if(CurrentYndFile.NodeDictionary != null && (CurrentYndFile.NodeDictionary.NodesCountPed + CurrentYndFile.NodeDictionary.NodesCountVehicle != CurrentYndFile.NodeDictionary.NodesCount))
|
||||||
|
{
|
||||||
|
var result = MessageBox.Show($"YND Area {CurrentYndFile.AreaID}: The total number of nodes ({CurrentYndFile.NodeDictionary.NodesCount}) does not match the total number of ped ({CurrentYndFile.NodeDictionary.NodesCountPed}) and vehicle ({CurrentYndFile.NodeDictionary.NodesCountVehicle}) nodes. You should manually adjust the number of nodes on the YND screen.\n\nDo you want to continue saving the YND file? Some of your nodes may not work in game.", $"Node count mismatch in Area {CurrentYndFile.AreaID}", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
|
||||||
|
if(result == DialogResult.Cancel)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
string yndname = CurrentYndFile.Name;
|
string yndname = CurrentYndFile.Name;
|
||||||
string filepath = CurrentYndFile.FilePath;
|
string filepath = CurrentYndFile.FilePath;
|
||||||
if (string.IsNullOrEmpty(filepath))
|
if (string.IsNullOrEmpty(filepath))
|
||||||
|
@ -1406,7 +1406,7 @@ namespace CodeWalker.Rendering
|
|||||||
if (poly == null) continue;
|
if (poly == null) continue;
|
||||||
byte matind = ((bgeom.PolygonMaterialIndices != null) && (i < bgeom.PolygonMaterialIndices.Length)) ? bgeom.PolygonMaterialIndices[i] : (byte)0;
|
byte matind = ((bgeom.PolygonMaterialIndices != null) && (i < bgeom.PolygonMaterialIndices.Length)) ? bgeom.PolygonMaterialIndices[i] : (byte)0;
|
||||||
BoundMaterial_s mat = ((bgeom.Materials != null) && (matind < bgeom.Materials.Length)) ? bgeom.Materials[matind] : new BoundMaterial_s();
|
BoundMaterial_s mat = ((bgeom.Materials != null) && (matind < bgeom.Materials.Length)) ? bgeom.Materials[matind] : new BoundMaterial_s();
|
||||||
Color4 color = BoundsMaterialTypes.GetMaterialColour(mat.Type);
|
Color color = BoundsMaterialTypes.GetMaterialColour(mat.Type);
|
||||||
Vector3 p1, p2, p3, p4, a1, n1;//, n2, n3, p5, p7, p8;
|
Vector3 p1, p2, p3, p4, a1, n1;//, n2, n3, p5, p7, p8;
|
||||||
Vector3 norm = Vector3.Zero;
|
Vector3 norm = Vector3.Zero;
|
||||||
uint colour = (uint)color.ToRgba();
|
uint colour = (uint)color.ToRgba();
|
||||||
|
Loading…
Reference in New Issue
Block a user