Skip to content

Commit

Permalink
LostArtefacts#281 - Ability to choose a stronger blending mode and ch…
Browse files Browse the repository at this point in the history
…oose whether color is random per level or per room, or fixed as per player choice.
  • Loading branch information
DanzaG committed Dec 12, 2021
1 parent c9d2812 commit c981cdf
Show file tree
Hide file tree
Showing 7 changed files with 333 additions and 150 deletions.
24 changes: 22 additions & 2 deletions TRLevelReader/Model/TR3/TR3Room.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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)));
}
}
}

Expand Down
10 changes: 9 additions & 1 deletion TRRandomizerCore/Editors/RandomizerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
41 changes: 39 additions & 2 deletions TRRandomizerCore/Randomizers/TR3/TR3VfxRandomizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,22 @@
using TRRandomizerCore.Helpers;
using TRRandomizerCore.Levels;
using TRRandomizerCore.Textures;
using TRRandomizerCore.Utilities;

namespace TRRandomizerCore.Randomizers
{
public class TR3VfxRandomizer : BaseTR3Randomizer
{
private List<TR3ScriptedLevel> _filterLevels;

private Color[] _colors;

public override void Randomize(int seed)
{
_generator = new Random(seed);

_colors = ColorUtilities.GetAvailableColors();

ChooseFilterLevels();

foreach (TR3ScriptedLevel lvl in Levels)
Expand Down Expand Up @@ -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)
{
Expand All @@ -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);
}
}
}
Expand Down
163 changes: 20 additions & 143 deletions TRRandomizerCore/TRRandomizerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using TRGE.Core;
using System.Collections.Generic;
using System.Drawing;
using TRRandomizerCore.Utilities;

namespace TRRandomizerCore
{
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit c981cdf

Please sign in to comment.