diff --git a/TRLevelReader/Model/TR3/TR3Room.cs b/TRLevelReader/Model/TR3/TR3Room.cs index 461ac6f3e..ba6fb9bd9 100644 --- a/TRLevelReader/Model/TR3/TR3Room.cs +++ b/TRLevelReader/Model/TR3/TR3Room.cs @@ -154,7 +154,7 @@ public void SetVertexLight(short val) } #region Vertex Effects & Filters - public void SetColourFilter(Color col) + public void SetColourFilter(Color col, bool replace) { foreach (TR3RoomVertex vert in RoomData.Vertices) { @@ -166,7 +166,27 @@ public void SetColourFilter(Color col) byte newGreen = ConvertColorChannelToRGB555(col.G); byte newBlue = ConvertColorChannelToRGB555(col.B); - vert.Colour = (ushort)((Blend(curRed, newRed) << 10) | (Blend(curGreen, newGreen) << 5) | (Blend(curBlue, newBlue))); + if (replace) + { + byte applyR = curRed; + byte applyG = curGreen; + byte applyB = curBlue; + + if (newRed > 0) + applyR = newRed; + + if (newGreen > 0) + applyG = newGreen; + + if (newBlue > 0) + applyB = newBlue; + + vert.Colour = (ushort)((applyR << 10) | (applyG << 5) | (applyB)); + } + else + { + vert.Colour = (ushort)((Blend(curRed, newRed) << 10) | (Blend(curGreen, newGreen) << 5) | (Blend(curBlue, newBlue))); + } } } diff --git a/TRRandomizerCore/Editors/RandomizerSettings.cs b/TRRandomizerCore/Editors/RandomizerSettings.cs index bf5a1b162..39b437fbe 100644 --- a/TRRandomizerCore/Editors/RandomizerSettings.cs +++ b/TRRandomizerCore/Editors/RandomizerSettings.cs @@ -83,8 +83,10 @@ public class RandomizerSettings public bool ReassignPuzzleNames => RandomizeEnemies && CrossLevelEnemies; public bool RandomizeVfx { get; set; } - public Color VfxFilterColor { get; set; } + public bool VfxVivid { get; set; } + public bool VfxLevel { get; set; } + public bool VfxRoom { get; set; } public void ApplyConfig(Config config) { @@ -168,6 +170,9 @@ public void ApplyConfig(Config config) RandomizeVfx = config.GetBool(nameof(RandomizeVfx)); VfxFilterColor = Color.FromArgb(config.GetInt(nameof(VfxFilterColor))); + VfxVivid = config.GetBool(nameof(VfxVivid)); + VfxLevel = config.GetBool(nameof(VfxLevel)); + VfxRoom = config.GetBool(nameof(VfxRoom)); } public void StoreConfig(Config config) @@ -249,6 +254,9 @@ public void StoreConfig(Config config) config[nameof(RandomizeVfx)] = RandomizeVfx; config[nameof(VfxFilterColor)] = VfxFilterColor.ToArgb(); + config[nameof(VfxVivid)] = VfxVivid; + config[nameof(VfxLevel)] = VfxLevel; + config[nameof(VfxRoom)] = VfxRoom; } public int GetSaveTarget(int numLevels) diff --git a/TRRandomizerCore/Randomizers/TR3/TR3VfxRandomizer.cs b/TRRandomizerCore/Randomizers/TR3/TR3VfxRandomizer.cs index 063d4af76..40a71106b 100644 --- a/TRRandomizerCore/Randomizers/TR3/TR3VfxRandomizer.cs +++ b/TRRandomizerCore/Randomizers/TR3/TR3VfxRandomizer.cs @@ -8,6 +8,7 @@ using TRRandomizerCore.Helpers; using TRRandomizerCore.Levels; using TRRandomizerCore.Textures; +using TRRandomizerCore.Utilities; namespace TRRandomizerCore.Randomizers { @@ -15,10 +16,14 @@ public class TR3VfxRandomizer : BaseTR3Randomizer { private List _filterLevels; + private Color[] _colors; + public override void Randomize(int seed) { _generator = new Random(seed); + _colors = ColorUtilities.GetAvailableColors(); + ChooseFilterLevels(); foreach (TR3ScriptedLevel lvl in Levels) @@ -52,7 +57,21 @@ private void ChooseFilterLevels() private void SetVertexFilterMode(TR3CombinedLevel level) { - FilterVertices(level.Data); + if (Settings.VfxRoom) + { + //Change every room + FilterVerticesRandomRoom(level.Data); + } + else if (Settings.VfxLevel) + { + //Change every level + FilterVerticesRandomLevel(level.Data, _colors[_generator.Next(0, _colors.Length - 1)]); + } + else + { + //Normal filter + FilterVertices(level.Data); + } if (level.HasCutScene) { @@ -64,7 +83,25 @@ private void FilterVertices(TR3Level level) { foreach (TR3Room room in level.Rooms) { - room.SetColourFilter(Settings.VfxFilterColor); + room.SetColourFilter(Settings.VfxFilterColor, Settings.VfxVivid); + } + } + + private void FilterVerticesRandomLevel(TR3Level level, Color col) + { + foreach (TR3Room room in level.Rooms) + { + room.SetColourFilter(col, Settings.VfxVivid); + } + } + + private void FilterVerticesRandomRoom(TR3Level level) + { + foreach (TR3Room room in level.Rooms) + { + Color col = _colors[_generator.Next(0, _colors.Length - 1)]; + + room.SetColourFilter(col, Settings.VfxVivid); } } } diff --git a/TRRandomizerCore/TRRandomizerController.cs b/TRRandomizerCore/TRRandomizerController.cs index 8120f5c86..1c55f0034 100644 --- a/TRRandomizerCore/TRRandomizerController.cs +++ b/TRRandomizerCore/TRRandomizerController.cs @@ -8,6 +8,7 @@ using TRGE.Core; using System.Collections.Generic; using System.Drawing; +using TRRandomizerCore.Utilities; namespace TRRandomizerCore { @@ -650,151 +651,27 @@ public Color[] VfxAvailableColorChoices { get { - return new Color[] - { - Color.AliceBlue, - Color.AntiqueWhite, - Color.Aqua, - Color.Aquamarine, - Color.Azure, - Color.Beige, - Color.Bisque, - Color.Black, - Color.BlanchedAlmond, - Color.Blue, - Color.BlueViolet, - Color.Brown, - Color.BurlyWood, - Color.CadetBlue, - Color.Chartreuse, - Color.Chocolate, - Color.Coral, - Color.CornflowerBlue, - Color.Cornsilk, - Color.Crimson, - Color.Cyan, - Color.DarkBlue, - Color.DarkCyan, - Color.DarkGoldenrod, - Color.DarkGray, - Color.DarkGreen, - Color.DarkKhaki, - Color.DarkMagenta, - Color.DarkOliveGreen, - Color.DarkOrange, - Color.DarkOrchid, - Color.DarkRed, - Color.DarkSalmon, - Color.DarkSeaGreen, - Color.DarkSlateBlue, - Color.DarkSlateGray, - Color.DarkTurquoise, - Color.DarkViolet, - Color.DeepPink, - Color.DeepSkyBlue, - Color.DimGray, - Color.DodgerBlue, - Color.Firebrick, - Color.FloralWhite, - Color.ForestGreen, - Color.Fuchsia, - Color.Gainsboro, - Color.GhostWhite, - Color.Gold, - Color.Goldenrod, - Color.Gray, - Color.Green, - Color.GreenYellow, - Color.Honeydew, - Color.HotPink, - Color.IndianRed, - Color.Indigo, - Color.Ivory, - Color.Khaki, - Color.Lavender, - Color.LavenderBlush, - Color.LawnGreen, - Color.LemonChiffon, - Color.LightBlue, - Color.LightCoral, - Color.LightCyan, - Color.LightGoldenrodYellow, - Color.LightGreen, - Color.LightGray, - Color.LightPink, - Color.LightSalmon, - Color.LightSeaGreen, - Color.LightSkyBlue, - Color.LightSlateGray, - Color.LightSteelBlue, - Color.LightYellow, - Color.Lime, - Color.LimeGreen, - Color.Linen, - Color.Magenta, - Color.Maroon, - Color.MediumAquamarine, - Color.MediumBlue, - Color.MediumOrchid, - Color.MediumPurple, - Color.MediumSeaGreen, - Color.MediumSlateBlue, - Color.MediumSpringGreen, - Color.MediumTurquoise, - Color.MediumVioletRed, - Color.MidnightBlue, - Color.MintCream, - Color.MistyRose, - Color.Moccasin, - Color.NavajoWhite, - Color.Navy, - Color.OldLace, - Color.Olive, - Color.OliveDrab, - Color.Orange, - Color.OrangeRed, - Color.Orchid, - Color.PaleGoldenrod, - Color.PaleGreen, - Color.PaleTurquoise, - Color.PaleVioletRed, - Color.PapayaWhip, - Color.PeachPuff, - Color.Peru, - Color.Pink, - Color.Plum, - Color.PowderBlue, - Color.Purple, - Color.Red, - Color.RosyBrown, - Color.RoyalBlue, - Color.SaddleBrown, - Color.Salmon, - Color.SandyBrown, - Color.SeaGreen, - Color.SeaShell, - Color.Sienna, - Color.Silver, - Color.SkyBlue, - Color.SlateBlue, - Color.SlateGray, - Color.Snow, - Color.SpringGreen, - Color.SteelBlue, - Color.Tan, - Color.Teal, - Color.Thistle, - Color.Tomato, - Color.Turquoise, - Color.Violet, - Color.Wheat, - Color.White, - Color.WhiteSmoke, - Color.Yellow, - Color.YellowGreen, - }; + return ColorUtilities.GetAvailableColors(); } } + + public bool VfxVivid + { + get => LevelRandomizer.VfxVivid; + set => LevelRandomizer.VfxVivid = value; + } + + public bool VfxLevel + { + get => LevelRandomizer.VfxLevel; + set => LevelRandomizer.VfxLevel = value; + } + + public bool VfxRoom + { + get => LevelRandomizer.VfxRoom; + set => LevelRandomizer.VfxRoom = value; + } #endregion #region TREditor Passthrough diff --git a/TRRandomizerCore/Utilities/ColorUtilities.cs b/TRRandomizerCore/Utilities/ColorUtilities.cs new file mode 100644 index 000000000..de8dbe9ed --- /dev/null +++ b/TRRandomizerCore/Utilities/ColorUtilities.cs @@ -0,0 +1,159 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TRRandomizerCore.Utilities +{ + public static class ColorUtilities + { + public static Color[] GetAvailableColors() + { + return new Color[] + { + Color.AliceBlue, + Color.AntiqueWhite, + Color.Aqua, + Color.Aquamarine, + Color.Azure, + Color.Beige, + Color.Bisque, + Color.Black, + Color.BlanchedAlmond, + Color.Blue, + Color.BlueViolet, + Color.Brown, + Color.BurlyWood, + Color.CadetBlue, + Color.Chartreuse, + Color.Chocolate, + Color.Coral, + Color.CornflowerBlue, + Color.Cornsilk, + Color.Crimson, + Color.Cyan, + Color.DarkBlue, + Color.DarkCyan, + Color.DarkGoldenrod, + Color.DarkGray, + Color.DarkGreen, + Color.DarkKhaki, + Color.DarkMagenta, + Color.DarkOliveGreen, + Color.DarkOrange, + Color.DarkOrchid, + Color.DarkRed, + Color.DarkSalmon, + Color.DarkSeaGreen, + Color.DarkSlateBlue, + Color.DarkSlateGray, + Color.DarkTurquoise, + Color.DarkViolet, + Color.DeepPink, + Color.DeepSkyBlue, + Color.DimGray, + Color.DodgerBlue, + Color.Firebrick, + Color.FloralWhite, + Color.ForestGreen, + Color.Fuchsia, + Color.Gainsboro, + Color.GhostWhite, + Color.Gold, + Color.Goldenrod, + Color.Gray, + Color.Green, + Color.GreenYellow, + Color.Honeydew, + Color.HotPink, + Color.IndianRed, + Color.Indigo, + Color.Ivory, + Color.Khaki, + Color.Lavender, + Color.LavenderBlush, + Color.LawnGreen, + Color.LemonChiffon, + Color.LightBlue, + Color.LightCoral, + Color.LightCyan, + Color.LightGoldenrodYellow, + Color.LightGreen, + Color.LightGray, + Color.LightPink, + Color.LightSalmon, + Color.LightSeaGreen, + Color.LightSkyBlue, + Color.LightSlateGray, + Color.LightSteelBlue, + Color.LightYellow, + Color.Lime, + Color.LimeGreen, + Color.Linen, + Color.Magenta, + Color.Maroon, + Color.MediumAquamarine, + Color.MediumBlue, + Color.MediumOrchid, + Color.MediumPurple, + Color.MediumSeaGreen, + Color.MediumSlateBlue, + Color.MediumSpringGreen, + Color.MediumTurquoise, + Color.MediumVioletRed, + Color.MidnightBlue, + Color.MintCream, + Color.MistyRose, + Color.Moccasin, + Color.NavajoWhite, + Color.Navy, + Color.OldLace, + Color.Olive, + Color.OliveDrab, + Color.Orange, + Color.OrangeRed, + Color.Orchid, + Color.PaleGoldenrod, + Color.PaleGreen, + Color.PaleTurquoise, + Color.PaleVioletRed, + Color.PapayaWhip, + Color.PeachPuff, + Color.Peru, + Color.Pink, + Color.Plum, + Color.PowderBlue, + Color.Purple, + Color.Red, + Color.RosyBrown, + Color.RoyalBlue, + Color.SaddleBrown, + Color.Salmon, + Color.SandyBrown, + Color.SeaGreen, + Color.SeaShell, + Color.Sienna, + Color.Silver, + Color.SkyBlue, + Color.SlateBlue, + Color.SlateGray, + Color.Snow, + Color.SpringGreen, + Color.SteelBlue, + Color.Tan, + Color.Teal, + Color.Thistle, + Color.Tomato, + Color.Turquoise, + Color.Violet, + Color.Wheat, + Color.White, + Color.WhiteSmoke, + Color.Yellow, + Color.YellowGreen, + }; + } + } +} diff --git a/TRRandomizerView/Model/ControllerOptions.cs b/TRRandomizerView/Model/ControllerOptions.cs index f806fc412..20da93f7d 100644 --- a/TRRandomizerView/Model/ControllerOptions.cs +++ b/TRRandomizerView/Model/ControllerOptions.cs @@ -44,6 +44,9 @@ public class ControllerOptions : INotifyPropertyChanged private Color _vfxFilterColor; private bool _vfxRandomize; private Color[] _vfxAvailColors; + private bool _vfxVivid; + private bool _vfxLevel; + private bool _vfxRoom; private List _secretBoolItemControls, _itemBoolItemControls, _enemyBoolItemControls, _textureBoolItemControls, _audioBoolItemControls, _outfitBoolItemControls, _textBoolItemControls, _startBoolItemControls, _environmentBoolItemControls; @@ -367,6 +370,36 @@ public Color[] VfxAvailColors } } + public bool VfxVivid + { + get => _vfxVivid; + set + { + _vfxVivid = value; + FirePropertyChanged(); + } + } + + public bool VfxRoom + { + get => _vfxRoom; + set + { + _vfxRoom = value; + FirePropertyChanged(); + } + } + + public bool VfxLevel + { + get => _vfxLevel; + set + { + _vfxLevel = value; + FirePropertyChanged(); + } + } + public bool RandomizeAudioTracks { get => _audioTrackControl.IsActive; @@ -1328,6 +1361,9 @@ public void Load(TRRandomizerController controller) VfxFilterColor = _controller.VfxFilterColor; VfxRandomize = _controller.RandomizeVfx; VfxAvailColors = _controller.VfxAvailableColorChoices; + VfxVivid = _controller.VfxVivid; + VfxLevel = _controller.VfxLevel; + VfxRoom = _controller.VfxRoom; RandomizeAudioTracks = _controller.RandomizeAudioTracks; AudioTracksSeed = _controller.AudioTracksSeed; @@ -1566,6 +1602,9 @@ public void Save() _controller.NightModeDarkness = NightModeDarkness; _controller.VfxFilterColor = VfxFilterColor; _controller.RandomizeVfx = VfxRandomize; + _controller.VfxVivid = VfxVivid; + _controller.VfxLevel = VfxLevel; + _controller.VfxRoom = VfxRoom; _controller.RandomizeAudioTracks = RandomizeAudioTracks; _controller.AudioTracksSeed = AudioTracksSeed; diff --git a/TRRandomizerView/Windows/AdvancedWindow.xaml b/TRRandomizerView/Windows/AdvancedWindow.xaml index 44990cb38..a2d4e966b 100644 --- a/TRRandomizerView/Windows/AdvancedWindow.xaml +++ b/TRRandomizerView/Windows/AdvancedWindow.xaml @@ -441,12 +441,13 @@ + + + - - @@ -495,6 +496,30 @@ VerticalAlignment="Center"/> + + + + + + + + + + + + + + + + + + + + + + + +