upload
This commit is contained in:
commit
1c7a8cf25f
579 files changed
+83196
No files matched your search
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using VibranceHud.Controls;
|
||||
|
||||
namespace VibranceHud.DarkBoost;
|
||||
|
||||
internal sealed class DarkBoostBanGate
|
||||
{
|
||||
internal const string CardTitle = "Dark Boost can get you banned";
|
||||
|
||||
internal const string Body = "Some games, like Rust, ban players who see in the dark. It mostly happens when another player reports you. PlexusX never touches the game, but the ban risk is yours.";
|
||||
|
||||
internal const string DialogTitle = "Before you turn on Dark Boost";
|
||||
|
||||
internal const string AcceptButton = "I understand the risk";
|
||||
|
||||
internal const string CancelButton = "Cancel";
|
||||
|
||||
private readonly AppSettings _settings;
|
||||
|
||||
private readonly Action _save;
|
||||
|
||||
private readonly Func<IWin32Window?, bool>? _ask;
|
||||
|
||||
internal bool Accepted => _settings.DarkBoostBanRiskAccepted;
|
||||
|
||||
internal DarkBoostBanGate(AppSettings settings, Action save, Func<IWin32Window?, bool>? ask = null)
|
||||
{
|
||||
_settings = settings ?? throw new ArgumentNullException("settings");
|
||||
_save = save ?? ((Action)(() =>
|
||||
{
|
||||
}));
|
||||
_ask = ask;
|
||||
}
|
||||
|
||||
internal bool Pass(IWin32Window? owner)
|
||||
{
|
||||
if (_settings.DarkBoostBanRiskAccepted)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (!((_ask != null) ? _ask(owner) : AskWithDialog(owner)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_settings.DarkBoostBanRiskAccepted = true;
|
||||
_save();
|
||||
return true;
|
||||
}
|
||||
|
||||
internal static GlassDialog BuildDialog()
|
||||
{
|
||||
return new GlassDialog("Before you turn on Dark Boost", "Some games, like Rust, ban players who see in the dark. It mostly happens when another player reports you. PlexusX never touches the game, but the ban risk is yours.", GlassDialogButtons.ConfirmSafeEnter, GlassDialogTone.Warning, "I understand the risk", "Cancel");
|
||||
}
|
||||
|
||||
internal static bool AskWithDialog(IWin32Window? owner)
|
||||
{
|
||||
return GlassDialog.Show(owner, "Before you turn on Dark Boost", "Some games, like Rust, ban players who see in the dark. It mostly happens when another player reports you. PlexusX never touches the game, but the ban risk is yours.", GlassDialogButtons.ConfirmSafeEnter, GlassDialogTone.Warning, "I understand the risk", "Cancel") == DialogResult.Yes;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
|
||||
namespace VibranceHud.DarkBoost;
|
||||
|
||||
public static class DarkBoostFade
|
||||
{
|
||||
public static readonly TimeSpan Duration = TimeSpan.FromMilliseconds(250.0);
|
||||
|
||||
public static double Amount(double from, double to, TimeSpan elapsed, bool fade)
|
||||
{
|
||||
if (!fade || elapsed >= Duration)
|
||||
{
|
||||
return to;
|
||||
}
|
||||
if (elapsed <= TimeSpan.Zero)
|
||||
{
|
||||
return from;
|
||||
}
|
||||
double num = elapsed.TotalMilliseconds / Duration.TotalMilliseconds;
|
||||
return from + (to - from) * num;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
using System;
|
||||
|
||||
namespace VibranceHud.DarkBoost;
|
||||
|
||||
internal static class DarkBoostLook
|
||||
{
|
||||
internal const double CleanShare = 0.85;
|
||||
|
||||
internal static double FloorScale(int blackLevel)
|
||||
{
|
||||
return 1.0 + (double)(7 * Math.Clamp(blackLevel, 0, 100)) / 100.0;
|
||||
}
|
||||
|
||||
internal static int PeakColumn(float[] basis, out double columnSum)
|
||||
{
|
||||
int result = 0;
|
||||
columnSum = double.MinValue;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
double num = basis[i] + basis[5 + i] + basis[10 + i];
|
||||
if (num > columnSum)
|
||||
{
|
||||
columnSum = num;
|
||||
result = i;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static float[] Base(float[] basis, DarkBoostTint tint, int blackLevel)
|
||||
{
|
||||
float[] array = (float[])basis.Clone();
|
||||
double num = FloorScale(blackLevel);
|
||||
if (tint == DarkBoostTint.Green)
|
||||
{
|
||||
if (num != 1.0)
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
array[20 + i] = (float)((double)basis[20 + i] * num);
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
int num2 = PeakColumn(basis, out var columnSum);
|
||||
double[] array2 = DarkBoostTints.PreviewWeights(tint);
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
for (int k = 0; k < 3; k++)
|
||||
{
|
||||
ref float reference = ref array[j * 5 + k];
|
||||
float num3;
|
||||
if (array2 == null)
|
||||
{
|
||||
num3 = ((j == k) ? ((float)(columnSum * 0.85)) : 0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
num3 = (float)((double)basis[j * 5 + num2] * array2[k]);
|
||||
}
|
||||
reference = num3;
|
||||
}
|
||||
}
|
||||
for (int l = 0; l < 3; l++)
|
||||
{
|
||||
array[20 + l] = (float)((double)basis[20 + num2] * ((array2 == null) ? 0.85 : array2[l]) * num);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
internal static float[] Picture(float[] basis, DarkBoostTint tint, int blackLevel, double strength)
|
||||
{
|
||||
return DarkBoostPicture.Matrix(Base(basis, tint, blackLevel), strength);
|
||||
}
|
||||
|
||||
internal static float[] Lerp(float[] own, float[] boost, double strength)
|
||||
{
|
||||
double num = (double.IsFinite(strength) ? Math.Clamp(strength, 0.0, 1.0) : 1.0);
|
||||
if (num <= 0.0)
|
||||
{
|
||||
return (float[])own.Clone();
|
||||
}
|
||||
if (num >= 1.0)
|
||||
{
|
||||
return (float[])boost.Clone();
|
||||
}
|
||||
float[] array = new float[own.Length];
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
array[i] = (float)((1.0 - num) * (double)own[i] + num * (double)boost[i]);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
internal static float[] Identity()
|
||||
{
|
||||
float[] array = new float[25];
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
array[i * 5 + i] = 1f;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
internal static (byte R, byte G, byte B) Pixel(double r, double g, double b, float[] m, ushort[]? ramp)
|
||||
{
|
||||
return (R: Ch(0), G: Ch(1), B: Ch(2));
|
||||
byte Ch(int c)
|
||||
{
|
||||
double num = r * (double)m[c] + g * (double)m[5 + c] + b * (double)m[10 + c] + (double)m[20 + c];
|
||||
int num2 = (int)Math.Clamp(Math.Round(255.0 * num, MidpointRounding.ToEven), 0.0, 255.0);
|
||||
if (ramp != null)
|
||||
{
|
||||
num2 = (int)Math.Clamp(Math.Round((double)(int)ramp[c * 256 + num2] / 257.0, MidpointRounding.ToEven), 0.0, 255.0);
|
||||
}
|
||||
return (byte)num2;
|
||||
}
|
||||
}
|
||||
|
||||
internal static double WhiteFrom(float[] m)
|
||||
{
|
||||
double num = 1.0;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
double num2 = m[i] + m[5 + i] + m[10 + i];
|
||||
if (num2 > 0.0)
|
||||
{
|
||||
num = Math.Min(num, (double)(1f - m[20 + i]) / num2);
|
||||
}
|
||||
}
|
||||
return Math.Clamp(num, 0.0, 1.0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
|
||||
namespace VibranceHud.DarkBoost;
|
||||
|
||||
public sealed record DarkBoostSetup(string Name, DarkBoostTint Tint, int Strength, int BlackLevel)
|
||||
{
|
||||
public DarkBoostSetup Clamped()
|
||||
{
|
||||
return this with
|
||||
{
|
||||
Name = (string.IsNullOrWhiteSpace(Name) ? "Setup" : Name.Trim()),
|
||||
Strength = Math.Clamp(Strength, 0, 100),
|
||||
BlackLevel = Math.Clamp(BlackLevel, 0, 100)
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace VibranceHud.DarkBoost;
|
||||
|
||||
public static class DarkBoostSetups
|
||||
{
|
||||
public static DarkBoostSetup Default => new DarkBoostSetup("Setup 1", DarkBoostTint.Green, 100, 0);
|
||||
|
||||
public static List<DarkBoostSetup> Normalise(IEnumerable<DarkBoostSetup?>? saved)
|
||||
{
|
||||
List<DarkBoostSetup> list = (from s in saved ?? Array.Empty<DarkBoostSetup>()
|
||||
where s != null
|
||||
select s.Clamped()).ToList();
|
||||
if (list.Count == 0)
|
||||
{
|
||||
list.Add(Default);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static int Selected(int saved, int count)
|
||||
{
|
||||
if (count > 0)
|
||||
{
|
||||
return Math.Clamp(saved, 0, count - 1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int Next(int selected, int count)
|
||||
{
|
||||
if (count > 0)
|
||||
{
|
||||
return (Selected(selected, count) + 1) % count;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static DarkBoostSetup InUse(AppSettings settings)
|
||||
{
|
||||
List<DarkBoostSetup> list = Normalise(settings.DarkBoostSetups);
|
||||
return list[Selected(settings.DarkBoostSelected, list.Count)];
|
||||
}
|
||||
|
||||
public static int AdvanceInSettings(AppSettings settings)
|
||||
{
|
||||
settings.DarkBoostSelected = Next(count: (settings.DarkBoostSetups = Normalise(settings.DarkBoostSetups)).Count, selected: settings.DarkBoostSelected);
|
||||
return settings.DarkBoostSelected;
|
||||
}
|
||||
|
||||
public static bool CanDelete(int count)
|
||||
{
|
||||
return count > 1;
|
||||
}
|
||||
|
||||
public static int Delete(List<DarkBoostSetup> setups, int selected)
|
||||
{
|
||||
if (!CanDelete(setups.Count))
|
||||
{
|
||||
return Selected(selected, setups.Count);
|
||||
}
|
||||
int num = Selected(selected, setups.Count);
|
||||
setups.RemoveAt(num);
|
||||
return Math.Max(0, num - 1);
|
||||
}
|
||||
|
||||
public static int SaveNew(List<DarkBoostSetup> setups, int selected)
|
||||
{
|
||||
DarkBoostSetup darkBoostSetup = ((setups.Count == 0) ? Default : setups[Selected(selected, setups.Count)]);
|
||||
int n = setups.Count + 1;
|
||||
while (setups.Any((DarkBoostSetup s) => string.Equals(s.Name, "Setup " + n, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
n++;
|
||||
}
|
||||
setups.Add(darkBoostSetup with
|
||||
{
|
||||
Name = "Setup " + n
|
||||
});
|
||||
return setups.Count - 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace VibranceHud.DarkBoost;
|
||||
|
||||
public enum DarkBoostTint
|
||||
{
|
||||
Green,
|
||||
Clean,
|
||||
Amber,
|
||||
Cyan,
|
||||
White
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
namespace VibranceHud.DarkBoost;
|
||||
|
||||
public static class DarkBoostTints
|
||||
{
|
||||
public static readonly DarkBoostTint[] All = new DarkBoostTint[5]
|
||||
{
|
||||
DarkBoostTint.Green,
|
||||
DarkBoostTint.Clean,
|
||||
DarkBoostTint.Amber,
|
||||
DarkBoostTint.Cyan,
|
||||
DarkBoostTint.White
|
||||
};
|
||||
|
||||
public static string Name(DarkBoostTint t)
|
||||
{
|
||||
return t.ToString();
|
||||
}
|
||||
|
||||
public static string Fact(DarkBoostTint t)
|
||||
{
|
||||
return t switch
|
||||
{
|
||||
DarkBoostTint.Green => "Green adds all colours together, so it pulls out the most detail.",
|
||||
DarkBoostTint.Clean => "Clean keeps the game’s own colours. A little less detail than Green.",
|
||||
DarkBoostTint.Amber => "Amber adds all colours together and makes the picture warm orange.",
|
||||
DarkBoostTint.Cyan => "Cyan adds all colours together and makes the picture blue-green.",
|
||||
_ => "White adds all colours together and makes the picture grey.",
|
||||
};
|
||||
}
|
||||
|
||||
public static double[]? PreviewWeights(DarkBoostTint t)
|
||||
{
|
||||
return t switch
|
||||
{
|
||||
DarkBoostTint.Green => new double[3] { 0.08, 1.0, 0.25 },
|
||||
DarkBoostTint.Amber => new double[3] { 1.0, 0.62, 0.12 },
|
||||
DarkBoostTint.Cyan => new double[3] { 0.12, 0.85, 1.0 },
|
||||
DarkBoostTint.White => new double[3] { 0.9, 0.9, 0.9 },
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user