Skip to content

Commit

Permalink
LOTS of research and fixes...
Browse files Browse the repository at this point in the history
  • Loading branch information
Foxxyyy committed Jun 21, 2024
1 parent f474754 commit 9d51caf
Show file tree
Hide file tree
Showing 35 changed files with 6,507 additions and 2,939 deletions.
1,291 changes: 647 additions & 644 deletions Codex.Games.RDR1.strings.txt

Large diffs are not rendered by default.

42 changes: 24 additions & 18 deletions Files/StrtblFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -482,23 +482,29 @@ private string GetFixedUIString(string str, bool fromXml = false)

public static string GetLanguageFromIndex(int index)
{
/*
* Flash languages abbreviations:
* brplu = br + pl + ru
* efigs = en + fr + it + de + es
*/

string name = string.Empty;
switch (index)
{
case 0: name = "English"; break;
case 1: name = "Spanish"; break;
case 2: name = "French"; break;
case 3: name = "German"; break;
case 4: name = "Italian"; break;
case 5: name = "Japanese"; break;
case 6: name = "Chinese-traditional"; break;
case 7: name = "Chinese-simplified"; break;
case 8: name = "Korean"; break;
case 0: name = "English"; break; //en
case 1: name = "Spanish"; break; //es
case 2: name = "French"; break; //fr
case 3: name = "German"; break; //de
case 4: name = "Italian"; break; //it
case 5: name = "Japanese"; break; //jp
case 6: name = "Chinese-traditional"; break; //cht
case 7: name = "Chinese-simplified"; break; //chs
case 8: name = "Korean"; break; //ko
case 9: name = "Spanish-spain"; break;
case 10: name = "Spanish-mexico"; break;
case 11: name = "Portuguese"; break;
case 12: name = "Polish"; break;
case 13: name = "Russian"; break;
case 10: name = "Spanish-mexico"; break; //mx
case 11: name = "Portuguese"; break; //bp
case 12: name = "Polish"; break; //pl
case 13: name = "Russian"; break; //ru
}
return name;
}
Expand Down Expand Up @@ -804,7 +810,7 @@ public Dictionary<JenkHash, string> Dict
get
{
if (StringData == null) return null;
return StringData.ToDictionary(s => s.FontTex.Character, s => s.Value);
return StringData.Where(s => s.FontTex != null).ToDictionary(s => s.FontTex.Character, s => s.Value);
}
}

Expand All @@ -817,10 +823,10 @@ public override string ToString()
[TC(typeof(EXP))] public class Rsc6StringTableData
{
public int Length { get; set; } //stringLength
public string Value { get; set; } //m_String
public Vector2 Scale { get; set; } //m_Scale
public byte OffsetX { get; set; } //m_OffsetX
public byte OffsetY { get; set; } //m_OffsetY
public string Value { get; set; } //m_String, text that is displayed by the game
public Vector2 Scale { get; set; } //m_Scale, adjusts the text size
public byte OffsetX { get; set; } //m_OffsetX, adjust the X location of the text
public byte OffsetY { get; set; } //m_OffsetY, adjust the Y location of the text
public Rsc6FontTexGlyph FontTex { get; set; }

public byte[] ValueData; //For writing purpose
Expand Down
20 changes: 9 additions & 11 deletions Files/WedtFile.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using CodeX.Core.Engine;
using CodeX.Core.Utilities;
using CodeX.Games.RDR1.RPF6;
using CodeX.Games.RDR1.RSC6;

Expand All @@ -9,14 +8,15 @@ public class WedtFile : FilePack
{
public Rpf6FileEntry FileEntry;
public Rsc6ExpressionDictionary Expressions;
public string Name;
public JenkHash Hash;

public WedtFile(Rpf6FileEntry file) : base(file)
{
FileEntry = file;
Name = file?.NameLower;
Hash = JenkHash.GenHash(file?.NameLower ?? "");
}

public WedtFile(Rsc6ExpressionDictionary expressions) : base(null)
{
Expressions = expressions;
}

public override void Load(byte[] data)
Expand All @@ -31,12 +31,10 @@ public override void Load(byte[] data)

public override byte[] Save()
{
throw new System.NotImplementedException();
}

public override string ToString()
{
return Expressions.ToString();
var writer = new Rsc6DataWriter();
writer.WriteBlock(Expressions);
byte[] data = writer.Build(11);
return data;
}
}
}
18 changes: 11 additions & 7 deletions Files/WftFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ namespace CodeX.Games.RDR1.Files
public class WftFile : PiecePack
{
public Rsc6Fragment Fragment;
public JenkHash Hash;
public string Name;

public WftFile(Rpf6FileEntry file) : base(file)
{
Name = file.NameLower;
Hash = JenkHash.GenHash(file.NameLower);
}

public WftFile(Rsc6Fragment fragment) : base(null)
{
Fragment = fragment;
}

public override void Load(byte[] data)
Expand All @@ -36,21 +37,24 @@ public override void Load(byte[] data)
var d = Fragment.Drawable.Item;
var b = Fragment.Bounds.Item;

Piece = d;
Piece = d.Drawable;
Piece.Name = e.Name;
Piece.FilePack = this;

if (!RDR1Map.LoadingMap)
{
Piece.Collider = b;
}
Pieces.Add(e.ShortNameHash, d);
Pieces.Add(e.ShortNameHash, d.Drawable);
}
}

public override byte[] Save()
{
return null;
var writer = new Rsc6DataWriter();
writer.WriteBlock(Fragment);
byte[] data = writer.Build(138);
return data;
}
}
}
2 changes: 1 addition & 1 deletion Prefabs/RDR1Animals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void BuildPiece()

Wft = peds.LoadWft(Prefab.WftEntry);

var skel = Wft?.Fragment?.Drawable.Item?.Skeleton;
var skel = Wft?.Fragment?.Drawable.Item?.Drawable.Skeleton;
SetSkeleton(skel);

var piece = Wft.Piece;
Expand Down
2 changes: 1 addition & 1 deletion Prefabs/RDR1Animator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private void UpdateAnim(Rsc6Animation anim, float t, int uvIndex = -1)
var v = anim.Evaluate(f, i);
v = new Vector4(v.Z, v.X, v.Y, v.W);

if (boneid.TrackType == Rsc6TrackType.Quaternion) //Quaternion - needs to be normalized
if (boneid.TrackType == Rsc6TrackType.QUATERNION) //Quaternion - needs to be normalized
{
v = Vector4.Normalize(v);
}
Expand Down
2 changes: 1 addition & 1 deletion Prefabs/RDR1Peds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public void BuildPiece()
Wft = peds.LoadWft(Prefab.WftEntry);
Wfd = peds.LoadWfd(Prefab.WfdEntry);

var skel = Wfd?.FragDrawable?.Drawable.Item?.Skeleton ?? Wft?.Fragment?.Drawable.Item?.Skeleton;
var skel = Wfd?.FragDrawable?.Drawable.Item?.Skeleton ?? Wft?.Fragment?.Drawable.Item?.Drawable.Skeleton;
SetSkeleton(skel);

var piece = Wfd?.Piece ?? Wft.Piece;
Expand Down
2 changes: 1 addition & 1 deletion Prefabs/RDR1Vehicles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public void BuildPiece()
Wfd = peds.LoadWfd(Prefab.WfdEntry);
Wtd = peds.LoadWtd(Prefab.WtdEntry);

var skel = Wft?.Fragment?.Drawable.Item?.Skeleton;
var skel = Wft?.Fragment?.Drawable.Item?.Drawable.Skeleton;
SetSkeleton(skel);

//A few models doesn't use a frag drawable
Expand Down
28 changes: 12 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,17 @@ Be sure this project is still WIP, including the separated engine. If you want t

# Udpates

I make regular updates to this project when I have some spare time, so it will or will not work with older versions of CodeX.
Here are some of the noticeable features for RDR1 :
* You can import, replace, edit and create files or folders as you wish without the need to rebuild the entire .RPFs (unlike MagicRDR)
* You can view, edit and search files in multiple .RPFs at the same time, they're all accessible in the tree view (unlike MagicRDR)
* You can search for files, but you can also search for words/text/hex through all the files
* You can view a certain number of resources, some of them can technically be exported and reimported from XML

> Models (.wfd / .wvd)
> Collisions (.wbd)
> Textures (.wtd)
> Game strings (.strtbl / .sst)
> Map Data (.wsi)
> Animations (.was / .wcdt)
> Tree Data (.wsp)
> Grass Batches (.wsg)
I make regular updates to this project when I have some spare time, so it will or will not work with older versions of CodeX.

Here are some of the features :
* Import, replace, edit and create files or folders, without the need to rebuild the entire .RPF files (instant-save, unlike MagicRDR)
* View & edit multiple .RPF files at the same time (unlike MagicRDR)
* Search for files, as well as search for words, text, or hex within all the files.
* A significant number of files have been researched and can be viewed.
* Some files can be exported to XML (sometimes re-imported) : `.wvd, .wfd, .wsp, .wsg, .wtd, .wbd, .wedt, .sst, .strtbl, .fonttex, etc.`

I also work on an [RDR1 Sollumz fork](https://github.com/Foxxyyy/SollumzRDR), it can import `WFD & WVD` files (no exports yet).
Fragments can technically be imported if you rename the XML extension from `.wft.wml` to `.wfd.xml` and manually edit the file to keep the `<Drawable>` node part.

# CodeX Contributors
* dexyfex
Expand All @@ -55,4 +51,4 @@ Here are some of the noticeable features for RDR1 :
![Screenshot](Files/Properties/codex_scene_preview.png)
![Screenshot](Files/Properties/map_viewer.png)
![Screenshot](Files/Properties/model_viewer_1.png)
![Screenshot](Files/Properties/model_viewer_2.png)
![Screenshot](Files/Properties/model_viewer_2.png)
Loading

0 comments on commit 9d51caf

Please sign in to comment.