diff --git a/M64MM.Utils/Appearance/ColorPart.cs b/M64MM.Utils/Appearance/ColorPart.cs index 78602de..a8e24b3 100644 --- a/M64MM.Utils/Appearance/ColorPart.cs +++ b/M64MM.Utils/Appearance/ColorPart.cs @@ -27,8 +27,8 @@ public void CommitColorsToRam(long baseOffset) { byte[] colors_L = {LightColor.R, LightColor.G, LightColor.B, 0x0}; byte[] colors_D = {DarkColor.R, DarkColor.G, DarkColor.B, 0x0}; - if (colors_L.Aggregate((x, y) => (byte)(x + y)) == 0) colors_L[3] = 0xFF; - if (colors_D.Aggregate((x, y) => (byte)(x + y)) == 0) colors_D[3] = 0xFF; + if (colors_L.Sum(x => (int)x) == 0) colors_L[3] = 0xFF; + if (colors_D.Sum(x => (int)x) == 0) colors_D[3] = 0xFF; WriteBytes(baseOffset + Offset86, SwapEndian(colors_L, 4)); diff --git a/M64MM.Utils/Appearance/ColorStandardNaming.cs b/M64MM.Utils/Appearance/ColorStandardNaming.cs new file mode 100644 index 0000000..c7ba545 --- /dev/null +++ b/M64MM.Utils/Appearance/ColorStandardNaming.cs @@ -0,0 +1,46 @@ +namespace M64MM.Utils { + public enum CCStandardPart { + PANTS, + HAT, + GLOVES, + SHOES, + SKIN, + HAIR, + SHIRT, + SHIRT_SHOULDER, + SHIRT_ARM, + OVERALLS_TOP, + OVERALLS_BOTTOM, + LEGS_TOP, + LEGS_BOTTOM, + CUSTOM1, + CUSTOM2, + CUSTOM3, + CUSTOM4, + CUSTOM5, + CUSTOM6, + CUSTOM7, + CUSTOM8, + LEGACY_CHARA_TINT, // X3S and others + LEVEL_TINT1, + LEVEL_TINT2, // Anything beyond is futureproofing + LEVEL_TINT3, + LEVEL_TINT4 + } + + public static class CCStandardHelpers { + public static readonly CCStandardPart[] SparkStandard = new CCStandardPart[] { + CCStandardPart.SHIRT, CCStandardPart.SHIRT_ARM, CCStandardPart.SHIRT_SHOULDER, + CCStandardPart.OVERALLS_BOTTOM, CCStandardPart.LEGS_TOP, CCStandardPart.LEGS_BOTTOM, + CCStandardPart.CUSTOM1, CCStandardPart.CUSTOM2, CCStandardPart.CUSTOM3, CCStandardPart.CUSTOM4, + CCStandardPart.CUSTOM5, CCStandardPart.CUSTOM6, CCStandardPart.CUSTOM7, CCStandardPart.CUSTOM8 + }; + + public static readonly CCStandardPart[] ColorcodeableStandard = new CCStandardPart[] { + CCStandardPart.SHIRT, CCStandardPart.SHIRT_ARM, CCStandardPart.SHIRT_SHOULDER, + CCStandardPart.OVERALLS_BOTTOM, CCStandardPart.LEGS_TOP, CCStandardPart.LEGS_BOTTOM, + CCStandardPart.CUSTOM1, CCStandardPart.CUSTOM2, CCStandardPart.CUSTOM3, CCStandardPart.CUSTOM4, + CCStandardPart.CUSTOM5, CCStandardPart.CUSTOM6, CCStandardPart.CUSTOM7, CCStandardPart.CUSTOM8 + }; + } +} \ No newline at end of file diff --git a/M64MM.Utils/Appearance/Lightset.cs b/M64MM.Utils/Appearance/Lightset.cs new file mode 100644 index 0000000..db6ba44 --- /dev/null +++ b/M64MM.Utils/Appearance/Lightset.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace M64MM.Utils { + public class Lightset { + private Dictionary _parts; + private Dictionary _partMapping; + + public bool SparkCompatible { + get + { + return _partMapping.Keys.Any(x => CCStandardHelpers.SparkStandard.Contains(x)); + } + } + + public bool NormalColorcodeCompatible + { + get + { + return _partMapping.Keys.Any(x => CCStandardHelpers.ColorcodeableStandard.Contains(x)); + } + } + + /// + /// Sets a ColorPart to a given ID. If the ID exists, it's overwritten. If the ColorPart is already assigned, the previous entry is erased. + /// + /// An ID to get the part by + /// The CC part to set + public void SetPart(string id, ColorPart part) { + if (_parts.ContainsKey(id)) { + _parts[id] = part; + } + else { + if (_parts.Values.Contains(part)) { + _parts.Remove(_parts.FirstOrDefault(x => x.Value == part).Key); + } + _parts.Add(id, part); + } + } + + public void SetPartMapping(CCStandardPart source, string id) { + if (!_parts.ContainsKey(id)) { + throw new ArgumentException($"This Lightset has no part with ID \"{id}\"."); + } + + if (_partMapping.ContainsKey(source)) { + _partMapping[source] = id; + } + else { + _partMapping.Add(source, id); + } + } + + public ColorPart GetPartById(string id) + { + if (!_parts.ContainsKey(id)) return null; + + return _parts[id]; + } + + public ColorPart GetPart(CCStandardPart stdPart) { + return GetPartById(_partMapping[stdPart]); + } + + } +} \ No newline at end of file diff --git a/M64MM.Utils/Appearance/Looks.cs b/M64MM.Utils/Appearance/Looks.cs index 3fc3ffa..77050ff 100644 --- a/M64MM.Utils/Appearance/Looks.cs +++ b/M64MM.Utils/Appearance/Looks.cs @@ -244,7 +244,7 @@ public enum ModelHeaderType { } }; - public enum ShadowParts { + public enum ShadowAxis { X, Y, Z diff --git a/M64MM.Utils/Core.cs b/M64MM.Utils/Core.cs index 82118d0..d2a7e5c 100644 --- a/M64MM.Utils/Core.cs +++ b/M64MM.Utils/Core.cs @@ -37,6 +37,7 @@ public static class Core public static SettingsGroup coreSettingsGroup; static bool _cameraFrozen = false; static bool _cameraSoftFrozen = false; + public static Lightset CurrentLightset { get; set; } public static bool TurboUpdateEnabled { diff --git a/M64MM.Utils/M64MM.Utils.csproj b/M64MM.Utils/M64MM.Utils.csproj index 0f71053..b00cdd6 100644 --- a/M64MM.Utils/M64MM.Utils.csproj +++ b/M64MM.Utils/M64MM.Utils.csproj @@ -91,6 +91,8 @@ + + diff --git a/M64MM2/AppearanceForm.cs b/M64MM2/AppearanceForm.cs index 775be8e..530c933 100644 --- a/M64MM2/AppearanceForm.cs +++ b/M64MM2/AppearanceForm.cs @@ -229,16 +229,16 @@ public void ExecuteRandomCC() { void UpdateTrackbar(object sender, EventArgs e) { TrackBar changedBar = ((TrackBar)sender); - ShadowParts part = ShadowParts.X; + ShadowAxis part = ShadowAxis.X; switch (changedBar.Name) { case "tbLeftRight": - part = ShadowParts.X; + part = ShadowAxis.X; break; case "tbBottomTop": - part = ShadowParts.Y; + part = ShadowAxis.Y; break; case "tbBackFront": - part = ShadowParts.Z; + part = ShadowAxis.Z; break; }