Large scale refactor to add class support!
Instance classes are now strongly typed with real property fields that are derived from the JSON API Dump! This required a lot of reworking across the board: - Classes and Enums are auto-generated in the 'Generated' folder now. This is done using a custom built-in plugin, which can be found in the Plugins folder of this project. - Property objects are now tied to .NET's reflection system. Reading and writing from them will try to redirect into a field of the Instance they are bound to. - Property types that were loosely defined now have proper data types (such as Color3uint8, Content, ProtectedString, SharedString, etc) - Fixed an error with the CFrame directional vectors. - The binary PRNT chunk now writes instances in child->parent order. - Enums are now generated correctly, with up-to-date values. - INST chunks are now referred to as 'Classes' instead of 'Types'. - Unary operator added to Vector2 and Vector3. - CollectionService tags can now be manipulated per-instance using the Instance.Tags member. - The Instance.Archivable property now works correctly. - XML files now save/load metadata correctly. - Cleaned up the property tokens directory. I probably missed a few things, but that's a general overview of everything that changed.
This commit is contained in:
66
Utility/FontUtility.cs
Normal file
66
Utility/FontUtility.cs
Normal file
@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using RobloxFiles.Enums;
|
||||
|
||||
namespace RobloxFiles.Utility
|
||||
{
|
||||
public static class FontUtility
|
||||
{
|
||||
public static IReadOnlyDictionary<int, FontSize> FontSizes = new Dictionary<int, FontSize>()
|
||||
{
|
||||
{ 8, FontSize.Size8 },
|
||||
{ 9, FontSize.Size9 },
|
||||
{ 10, FontSize.Size10 },
|
||||
{ 11, FontSize.Size11 },
|
||||
{ 12, FontSize.Size12 },
|
||||
{ 14, FontSize.Size14 },
|
||||
{ 18, FontSize.Size18 },
|
||||
{ 24, FontSize.Size24 },
|
||||
{ 28, FontSize.Size28 },
|
||||
{ 32, FontSize.Size32 },
|
||||
{ 36, FontSize.Size36 },
|
||||
{ 42, FontSize.Size42 },
|
||||
{ 48, FontSize.Size48 },
|
||||
{ 60, FontSize.Size60 },
|
||||
{ 96, FontSize.Size96 },
|
||||
};
|
||||
|
||||
private static Dictionary<int, FontSize> IntToFontSize = new Dictionary<int, FontSize>();
|
||||
|
||||
public static FontSize GetFontSize(int fontSize)
|
||||
{
|
||||
if (fontSize > 60)
|
||||
return FontSize.Size96;
|
||||
|
||||
if (FontSizes.ContainsKey(fontSize))
|
||||
return FontSizes[fontSize];
|
||||
|
||||
FontSize closest = FontSizes
|
||||
.Where(pair => pair.Key <= fontSize)
|
||||
.Select(pair => pair.Value)
|
||||
.Last();
|
||||
|
||||
return closest;
|
||||
}
|
||||
|
||||
public static FontSize GetFontSize(float size)
|
||||
{
|
||||
int fontSize = (int)size;
|
||||
return GetFontSize(fontSize);
|
||||
}
|
||||
|
||||
public static int GetFontSize(FontSize fontSize)
|
||||
{
|
||||
int value = FontSizes
|
||||
.Where(pair => pair.Value == fontSize)
|
||||
.Select(pair => pair.Key)
|
||||
.First();
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,5 @@
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
|
||||
// This global class defines extension methods to numeric types
|
||||
// where I don't want system globalization to come into play.
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
internal static class Formatting
|
||||
{
|
||||
@ -105,4 +102,14 @@ internal static class Formatting
|
||||
{
|
||||
return int.Parse(s, invariant);
|
||||
}
|
||||
|
||||
public static bool FuzzyEquals(this float a, float b, float epsilon = 10e-5f)
|
||||
{
|
||||
return Math.Abs(a - b) < epsilon;
|
||||
}
|
||||
|
||||
public static bool FuzzyEquals(this double a, double b, double epsilon = 10e-5)
|
||||
{
|
||||
return Math.Abs(a - b) < epsilon;
|
||||
}
|
||||
}
|
@ -25,6 +25,7 @@ namespace RobloxFiles.Utility
|
||||
{Material.DiamondPlate, 7.85f},
|
||||
{Material.Fabric, 0.70f},
|
||||
{Material.Foil, 2.70f},
|
||||
{Material.ForceField, 2.40f},
|
||||
{Material.Glacier, 0.92f},
|
||||
{Material.Glass, 2.40f},
|
||||
{Material.Granite, 2.69f},
|
||||
@ -68,6 +69,7 @@ namespace RobloxFiles.Utility
|
||||
{Material.DiamondPlate, 0.25f},
|
||||
{Material.Fabric, 0.05f},
|
||||
{Material.Foil, 0.25f},
|
||||
{Material.ForceField, 0.20f},
|
||||
{Material.Glacier, 0.15f},
|
||||
{Material.Glass, 0.20f},
|
||||
{Material.Granite, 0.20f},
|
||||
@ -111,6 +113,7 @@ namespace RobloxFiles.Utility
|
||||
{Material.DiamondPlate, 0.35f},
|
||||
{Material.Fabric, 0.35f},
|
||||
{Material.Foil, 0.40f},
|
||||
{Material.ForceField, 0.25f},
|
||||
{Material.Glacier, 0.05f},
|
||||
{Material.Glass, 0.25f},
|
||||
{Material.Granite, 0.40f},
|
||||
|
Reference in New Issue
Block a user