upload
This commit is contained in:
commit
1c7a8cf25f
579 files changed
+83196
No files matched your search
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
|
||||
namespace VibranceHud.Licensing;
|
||||
|
||||
internal static class ActivationEndpoint
|
||||
{
|
||||
internal const string Origin = "https://plexusx.lol";
|
||||
|
||||
internal const string SiteOrigin = "https://plexusx.lol";
|
||||
|
||||
internal static string SwitchesUrl => Origin + "/api/app/switches";
|
||||
|
||||
internal static string LibraryUrl => Origin + "/api/presets/library";
|
||||
|
||||
internal static string StatusUrlFor(string channel)
|
||||
{
|
||||
return Origin + "/api/app/status?channel=" + Uri.EscapeDataString(channel ?? "");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
namespace VibranceHud.Licensing;
|
||||
|
||||
public sealed class DarkBoostTable
|
||||
{
|
||||
private readonly float[] _matrix;
|
||||
|
||||
private readonly ushort[] _ramp;
|
||||
|
||||
private readonly float[]? _fallback;
|
||||
|
||||
public float[] Matrix => (float[])_matrix.Clone();
|
||||
|
||||
public ushort[] Ramp => (ushort[])_ramp.Clone();
|
||||
|
||||
public float[]? FallbackMatrix => (float[])_fallback?.Clone();
|
||||
|
||||
public bool RampIsStraight { get; }
|
||||
|
||||
internal DarkBoostTable(float[] matrix, ushort[] ramp, float[]? fallbackMatrix)
|
||||
{
|
||||
_matrix = (float[])matrix.Clone();
|
||||
_ramp = (ushort[])ramp.Clone();
|
||||
_fallback = (float[])fallbackMatrix?.Clone();
|
||||
RampIsStraight = DarkBoostPicture.IsStraight(_ramp);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace VibranceHud.Licensing;
|
||||
|
||||
public sealed record GradeCurve(double RegionRange, int RegionSharpness, double PointRange, int PointSharpness, double TintRange)
|
||||
{
|
||||
public static readonly GradeCurve Withheld = new GradeCurve(0.0, 1, 0.0, 1, 0.0);
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace VibranceHud.Licensing;
|
||||
|
||||
public static class LoadedBuild
|
||||
{
|
||||
private static readonly object Gate = new object();
|
||||
|
||||
private static string? _cached;
|
||||
|
||||
private static bool _computed;
|
||||
|
||||
public static string? Sha256()
|
||||
{
|
||||
lock (Gate)
|
||||
{
|
||||
if (_computed)
|
||||
{
|
||||
return _cached;
|
||||
}
|
||||
_computed = true;
|
||||
_cached = HashOf(typeof(LoadedBuild).Assembly.Location);
|
||||
return _cached;
|
||||
}
|
||||
}
|
||||
|
||||
internal static string? HashOf(string? path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
try
|
||||
{
|
||||
using FileStream inputStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
|
||||
using SHA256 sHA = SHA256.Create();
|
||||
return Convert.ToHexString(sHA.ComputeHash(inputStream)).ToLowerInvariant();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
internal static void ForgetForTest()
|
||||
{
|
||||
lock (Gate)
|
||||
{
|
||||
_computed = false;
|
||||
_cached = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
||||
namespace VibranceHud.Licensing;
|
||||
|
||||
internal static class LoopbackSignIn
|
||||
{
|
||||
private static Func<AppSettings>? _settingsSource;
|
||||
|
||||
internal static void UseTheBrowserFrom(Func<AppSettings> settingsSource)
|
||||
{
|
||||
_settingsSource = settingsSource;
|
||||
}
|
||||
|
||||
internal static void OpenBrowser(string url)
|
||||
{
|
||||
TryOpenBrowser(url);
|
||||
}
|
||||
|
||||
internal static bool TryOpenBrowser(string url)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(url))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
try
|
||||
{
|
||||
string? browserPath = _settingsSource?.Invoke()?.SignInBrowserPath;
|
||||
if (!string.IsNullOrWhiteSpace(browserPath) && File.Exists(browserPath))
|
||||
{
|
||||
Process.Start(new ProcessStartInfo(browserPath, url)
|
||||
{
|
||||
UseShellExecute = false
|
||||
});
|
||||
return true;
|
||||
}
|
||||
Process.Start(new ProcessStartInfo(url)
|
||||
{
|
||||
UseShellExecute = true
|
||||
});
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
namespace VibranceHud.Licensing;
|
||||
|
||||
public sealed record PairingFormat(string Alphabet, int TokenLength, int TokenBits, string UrlTemplate)
|
||||
{
|
||||
public bool Withheld
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Alphabet.Length != 0 && TokenLength > 0 && TokenBits > 0)
|
||||
{
|
||||
return UrlTemplate.Length == 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static readonly PairingFormat Withholding = new PairingFormat("", 0, 0, "");
|
||||
|
||||
public string Url(string address, int port, string token)
|
||||
{
|
||||
if (Withheld || string.IsNullOrEmpty(token))
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return UrlTemplate.Replace("{address}", address, StringComparison.Ordinal).Replace("{port}", port.ToString(CultureInfo.InvariantCulture), StringComparison.Ordinal).Replace("{token}", token, StringComparison.Ordinal);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace VibranceHud.Licensing;
|
||||
|
||||
public static class ServedCodes
|
||||
{
|
||||
private static readonly ShareCodeFormat DefaultFormat = new ShareCodeFormat(
|
||||
Alphabet: "23456789ABCDEFGHJKMNPQRSTUVWXYZ#",
|
||||
Prefix: "PX-",
|
||||
ChecksumModulus: 32,
|
||||
ChecksumWeightStep: 2,
|
||||
ChecksumWeightOffset: 1,
|
||||
ChecksumIndexOffset: 0,
|
||||
BodyLengths: new Dictionary<int, int>
|
||||
{
|
||||
[13] = 6,
|
||||
[17] = 8,
|
||||
[19] = 9,
|
||||
[27] = 13,
|
||||
[39] = 19
|
||||
},
|
||||
MaxVibrance: 350,
|
||||
MaxSaturation: 200,
|
||||
MinBrightness: 50,
|
||||
MaxBrightness: 150,
|
||||
MinGamma: 50,
|
||||
MaxGamma: 150,
|
||||
MinContrast: 50,
|
||||
MaxContrast: 150,
|
||||
MinTemperature: -100,
|
||||
MaxTemperature: 100,
|
||||
MinGrade: -100,
|
||||
MaxGrade: 100);
|
||||
|
||||
public static ShareCodeFormat Current => DefaultFormat;
|
||||
|
||||
public static ServedSource Source => ServedSource.Served;
|
||||
|
||||
internal static void Install()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
using System.Collections.Generic;
|
||||
using VibranceHud.Crosshair;
|
||||
|
||||
namespace VibranceHud.Licensing;
|
||||
|
||||
public static class ServedCrosshairs
|
||||
{
|
||||
private static readonly IReadOnlyList<CrosshairGallery.GalleryItem> BuiltInDesigns = BuildDesigns();
|
||||
|
||||
public static IReadOnlyList<CrosshairGallery.GalleryItem> Designs => BuiltInDesigns;
|
||||
|
||||
public static ServedSource Source => ServedSource.Served;
|
||||
|
||||
public static bool OnTheirWay => false;
|
||||
|
||||
public static int Generation => 1;
|
||||
|
||||
internal static void Install()
|
||||
{
|
||||
}
|
||||
|
||||
private static IReadOnlyList<CrosshairGallery.GalleryItem> BuildDesigns()
|
||||
{
|
||||
return new CrosshairGallery.GalleryItem[]
|
||||
{
|
||||
Make("dot-fine", "Fine Dot", CrosshairGallery.Family.Dot, size: 10, thick: 10, gap: 0, top: false, bottom: false, left: false, right: false, diag: false, outline: true, dot: 20, circle: null),
|
||||
Make("dot-bold", "Bold Dot", CrosshairGallery.Family.Dot, size: 10, thick: 10, gap: 0, top: false, bottom: false, left: false, right: false, diag: false, outline: true, dot: 35, circle: null),
|
||||
Make("cross-classic", "Classic Cross", CrosshairGallery.Family.Cross, size: 55, thick: 15, gap: 25, top: true, bottom: true, left: true, right: true, diag: false, outline: true, dot: null, circle: null),
|
||||
Make("cross-tight", "Tight Pro", CrosshairGallery.Family.Cross, size: 35, thick: 15, gap: 15, top: true, bottom: true, left: true, right: true, diag: false, outline: true, dot: null, circle: null),
|
||||
Make("cross-t", "Open T", CrosshairGallery.Family.Cross, size: 50, thick: 15, gap: 20, top: false, bottom: true, left: true, right: true, diag: false, outline: true, dot: null, circle: null),
|
||||
Make("cross-dot", "Cross + Dot", CrosshairGallery.Family.Cross, size: 45, thick: 15, gap: 30, top: true, bottom: true, left: true, right: true, diag: false, outline: true, dot: 18, circle: null),
|
||||
Make("x-clean", "Clean X", CrosshairGallery.Family.X, size: 45, thick: 15, gap: 20, top: true, bottom: true, left: true, right: true, diag: true, outline: true, dot: null, circle: null),
|
||||
Make("x-dot", "X + Dot", CrosshairGallery.Family.X, size: 40, thick: 15, gap: 25, top: true, bottom: true, left: true, right: true, diag: true, outline: true, dot: 20, circle: null),
|
||||
Make("ring-clean", "Clean Ring", CrosshairGallery.Family.Ring, size: 10, thick: 15, gap: 0, top: false, bottom: false, left: false, right: false, diag: false, outline: true, dot: 18, circle: 60),
|
||||
Make("ring-holo", "Holo Ring", CrosshairGallery.Family.Ring, size: 30, thick: 15, gap: 65, top: true, bottom: true, left: true, right: true, diag: false, outline: true, dot: 16, circle: 75),
|
||||
Make("funny-wide", "Wide Scope", CrosshairGallery.Family.Funny, size: 90, thick: 20, gap: 45, top: true, bottom: true, left: true, right: true, diag: false, outline: true, dot: 25, circle: 90)
|
||||
};
|
||||
}
|
||||
|
||||
private static CrosshairGallery.GalleryItem Make(
|
||||
string id, string name, CrosshairGallery.Family family,
|
||||
int size, int thick, int gap,
|
||||
bool top, bool bottom, bool left, bool right,
|
||||
bool diag, bool outline, int? dot, int? circle)
|
||||
{
|
||||
CrosshairConfig c = new CrosshairConfig
|
||||
{
|
||||
ColourArgb = -1,
|
||||
Outline = outline,
|
||||
Opacity = 100,
|
||||
ArmTop = top,
|
||||
ArmBottom = bottom,
|
||||
ArmLeft = left,
|
||||
ArmRight = right,
|
||||
CentreDot = dot.HasValue,
|
||||
DotSizeTenths = dot,
|
||||
ShowCircle = circle.HasValue,
|
||||
CircleRadiusTenths = circle,
|
||||
Diagonal = diag
|
||||
};
|
||||
c.SetSizeTenths(size);
|
||||
c.SetThicknessTenths(thick);
|
||||
c.SetGapTenths(gap);
|
||||
return new CrosshairGallery.GalleryItem(id, name, family, c);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace VibranceHud.Licensing;
|
||||
|
||||
public static class ServedData
|
||||
{
|
||||
public static void Refresh()
|
||||
{
|
||||
Install();
|
||||
}
|
||||
|
||||
internal static void Install()
|
||||
{
|
||||
ServedLooks.Install();
|
||||
ServedCodes.Install();
|
||||
ServedPairing.Install();
|
||||
ServedCrosshairs.Install();
|
||||
ServedNightVision.Install();
|
||||
}
|
||||
|
||||
internal static void ResetForTest()
|
||||
{
|
||||
Install();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace VibranceHud.Licensing;
|
||||
|
||||
public static class ServedLooks
|
||||
{
|
||||
private static readonly ScenePresetSet NoSet = new ScenePresetSet("", Array.Empty<DisplayPreset>());
|
||||
|
||||
private static readonly GradeCurve DefaultCurve = new GradeCurve(
|
||||
RegionRange: 0.25,
|
||||
RegionSharpness: 2,
|
||||
PointRange: 0.15,
|
||||
PointSharpness: 3,
|
||||
TintRange: 0.08);
|
||||
|
||||
private static readonly IReadOnlyList<ScenePresetSet> BuiltInSets = new ScenePresetSet[]
|
||||
{
|
||||
new ScenePresetSet("Rust", new DisplayPreset[]
|
||||
{
|
||||
new DisplayPreset("Balanced", "Clean contrast and natural colour lift.", 115, 70, 102, 104, 106, 0, "balance", "rust-balanced", Highlights: -10, Shadows: 20),
|
||||
new DisplayPreset("Vivid", "Stronger foliage and player separation.", 135, 85, 104, 106, 110, 4, "vivid", "rust-vivid", Highlights: -15, Shadows: 25),
|
||||
new DisplayPreset("Forest", "Lifts dark tree lines and shadows.", 122, 78, 104, 108, 108, 6, "forest", "rust-forest", Highlights: -12, Shadows: 35),
|
||||
new DisplayPreset("Desert", "Cuts sand glare while keeping players sharp.", 118, 72, 98, 102, 112, -8, "desert", "rust-desert", Highlights: -25, Shadows: 15),
|
||||
new DisplayPreset("Snow", "Tames snow bloom and bright horizons.", 112, 68, 95, 100, 114, -6, "snow", "rust-snow", Highlights: -35, Shadows: 18),
|
||||
new DisplayPreset("Black Holo", "Turns bright holo reticles dark against glare.", 116, 72, 102, 104, 108, 0, "holo", "rust-blackholo", Highlights: -15, Shadows: 20, ColourVision: ColourVisionMode.HoloBlack)
|
||||
}),
|
||||
new ScenePresetSet("Counter-Strike 2", new DisplayPreset[]
|
||||
{
|
||||
new DisplayPreset("Balanced", "Crisp visibility without blowing out walls.", 118, 75, 102, 104, 106, 0, "balance", "cs2-balanced", Highlights: -10, Shadows: 18),
|
||||
new DisplayPreset("Vivid", "Punched-up player models and utility.", 140, 90, 103, 105, 110, 2, "vivid", "cs2-vivid", Highlights: -12, Shadows: 22),
|
||||
new DisplayPreset("Dust", "Cuts warm sandstone haze on Mirage and Dust 2.", 124, 80, 99, 103, 110, -12, "desert", "cs2-dust", Highlights: -22, Shadows: 20),
|
||||
new DisplayPreset("Concrete", "Adds pop on grey maps like Nuke and Ancient.", 128, 82, 102, 105, 112, 6, "concrete", "cs2-concrete", Highlights: -10, Shadows: 24),
|
||||
new DisplayPreset("Shadows", "Opens up dark corners and tunnels.", 120, 76, 105, 110, 106, 0, "shadows", "cs2-shadows", Highlights: -15, Shadows: 40)
|
||||
}),
|
||||
new ScenePresetSet("Valorant", new DisplayPreset[]
|
||||
{
|
||||
new DisplayPreset("Balanced", "Clean contrast for abilities and outlines.", 116, 74, 101, 103, 106, 0, "balance", "valorant-balanced", Highlights: -10, Shadows: 15),
|
||||
new DisplayPreset("Vivid", "High-energy colour separation.", 138, 88, 102, 104, 110, 0, "vivid", "valorant-vivid", Highlights: -12, Shadows: 18),
|
||||
new DisplayPreset("Outlines", "Makes yellow and purple outlines stand out.", 132, 86, 100, 104, 114, -4, "outlines", "valorant-outlines", Highlights: -18, Shadows: 20),
|
||||
new DisplayPreset("Bright Maps", "Reduces glare on Breeze and Sunset.", 118, 74, 96, 100, 112, -10, "daylight", "valorant-bright-maps", Highlights: -30, Shadows: 14),
|
||||
new DisplayPreset("Shade", "Lifts shaded angles and mid sites.", 120, 78, 104, 108, 108, 4, "shadows", "valorant-shade", Highlights: -12, Shadows: 32)
|
||||
}),
|
||||
new ScenePresetSet("Fortnite", new DisplayPreset[]
|
||||
{
|
||||
new DisplayPreset("Balanced", "Even vibrance and clear builds.", 116, 72, 102, 104, 106, 0, "balance", "fortnite-balanced", Highlights: -10, Shadows: 18),
|
||||
new DisplayPreset("Vivid", "Saturated colours and snappy contrast.", 136, 86, 103, 105, 110, 2, "vivid", "fortnite-vivid", Highlights: -14, Shadows: 20),
|
||||
new DisplayPreset("Daylight", "Tames bright sky and storm glare.", 118, 74, 97, 101, 110, -8, "daylight", "fortnite-daylight", Highlights: -28, Shadows: 16),
|
||||
new DisplayPreset("Town", "Sharpens indoor fights and cluttered POIs.", 122, 78, 103, 106, 110, 4, "urban", "fortnite-town", Highlights: -14, Shadows: 28),
|
||||
new DisplayPreset("Night", "Lifts dark zones during night cycles.", 120, 76, 106, 112, 106, 0, "night", "fortnite-night", Highlights: -10, Shadows: 42)
|
||||
}),
|
||||
new ScenePresetSet("PUBG", new DisplayPreset[]
|
||||
{
|
||||
new DisplayPreset("Balanced", "Clear spotting across open terrain.", 118, 74, 102, 104, 108, 0, "balance", "pubg-balanced", Highlights: -12, Shadows: 20),
|
||||
new DisplayPreset("Vivid", "Stronger colour contrast for spotting movement.", 136, 88, 103, 106, 112, 2, "vivid", "pubg-vivid", Highlights: -14, Shadows: 24),
|
||||
new DisplayPreset("Desert", "Cools Miramar glare and sharpens ridges.", 120, 76, 98, 102, 112, -12, "desert", "pubg-desert", Highlights: -26, Shadows: 18),
|
||||
new DisplayPreset("Jungle", "Separates players from dense Sanhok foliage.", 126, 82, 104, 108, 110, 6, "forest", "pubg-jungle", Highlights: -14, Shadows: 34),
|
||||
new DisplayPreset("Urban", "Clarity in windows, compounds, and shadows.", 122, 78, 103, 106, 110, 2, "urban", "pubg-urban", Highlights: -14, Shadows: 30)
|
||||
}),
|
||||
new ScenePresetSet("Rainbow Six Siege", new DisplayPreset[]
|
||||
{
|
||||
new DisplayPreset("Balanced", "Balanced interior visibility.", 116, 74, 102, 105, 108, 0, "balance", "siege-balanced", Highlights: -12, Shadows: 22),
|
||||
new DisplayPreset("Vivid", "Stronger operator and gadget contrast.", 134, 86, 103, 106, 112, 2, "vivid", "siege-vivid", Highlights: -14, Shadows: 24),
|
||||
new DisplayPreset("Corners", "Brightens dark rooms and anchor spots.", 118, 76, 105, 110, 108, 0, "shadows", "siege-corners", Highlights: -12, Shadows: 42),
|
||||
new DisplayPreset("Doorways", "Balances bright exteriors against dark interiors.", 120, 78, 102, 108, 110, -4, "doorways", "siege-doorways", Highlights: -26, Shadows: 36),
|
||||
new DisplayPreset("Daylight", "Cuts exterior window glare.", 116, 72, 97, 102, 112, -8, "daylight", "siege-daylight", Highlights: -30, Shadows: 18)
|
||||
})
|
||||
};
|
||||
|
||||
public static GradeCurve CurrentCurve => DefaultCurve;
|
||||
|
||||
public static ServedSource Source => ServedSource.Served;
|
||||
|
||||
public static int Generation => 1;
|
||||
|
||||
public static bool OnTheirWay => false;
|
||||
|
||||
public static IReadOnlyList<ScenePresetSet> ByGame => BuiltInSets;
|
||||
|
||||
public static IReadOnlyList<string> Games => BuiltInSets.Select((ScenePresetSet s) => s.Game).ToList();
|
||||
|
||||
public static IReadOnlyList<DisplayPreset> All => BuiltInSets.SelectMany((ScenePresetSet s) => s.Presets).ToList();
|
||||
|
||||
public static ScenePresetSet ForGame(string? game)
|
||||
{
|
||||
if (BuiltInSets.Count == 0)
|
||||
{
|
||||
return NoSet;
|
||||
}
|
||||
return BuiltInSets.FirstOrDefault((ScenePresetSet s) => string.Equals(s.Game, game, StringComparison.OrdinalIgnoreCase)) ?? BuiltInSets[0];
|
||||
}
|
||||
|
||||
internal static void Install()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
|
||||
namespace VibranceHud.Licensing;
|
||||
|
||||
public static class ServedNightVision
|
||||
{
|
||||
private static readonly float[] DefaultMatrix = new float[25]
|
||||
{
|
||||
0.20f, 0.70f, 0.10f, 0f, 0f,
|
||||
0.35f, 1.45f, 0.25f, 0f, 0f,
|
||||
0.15f, 0.45f, 0.15f, 0f, 0f,
|
||||
0f, 0f, 0f, 1f, 0f,
|
||||
-0.01f, -0.02f, -0.01f, 0f, 1f
|
||||
};
|
||||
|
||||
private static readonly DarkBoostTable DefaultDarkBoost = BuildDefaultDarkBoost();
|
||||
|
||||
public static bool Live => true;
|
||||
|
||||
public static float[]? Matrix => (float[])DefaultMatrix.Clone();
|
||||
|
||||
public static int Generation => 1;
|
||||
|
||||
public static DarkBoostTable? DarkBoost => DefaultDarkBoost;
|
||||
|
||||
internal static void Install()
|
||||
{
|
||||
}
|
||||
|
||||
private static DarkBoostTable BuildDefaultDarkBoost()
|
||||
{
|
||||
ushort[] ramp = new ushort[768];
|
||||
for (int c = 0; c < 3; c++)
|
||||
{
|
||||
int offset = c * 256;
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
if (i == 255)
|
||||
{
|
||||
ramp[offset + i] = ushort.MaxValue;
|
||||
continue;
|
||||
}
|
||||
double x = (double)i / 255.0;
|
||||
double lifted = Math.Pow(x, 0.62);
|
||||
int target = (int)Math.Round(Math.Clamp(lifted, 0.0, 1.0) * 65535.0);
|
||||
int maxAllowed = Math.Min(65535, (i + 120) << 8);
|
||||
int minAllowed = Math.Max(0, (i - 120) << 8);
|
||||
int clamped = Math.Clamp(target, minAllowed, maxAllowed);
|
||||
if (i > 0 && clamped < ramp[offset + i - 1])
|
||||
{
|
||||
clamped = ramp[offset + i - 1];
|
||||
}
|
||||
ramp[offset + i] = (ushort)clamped;
|
||||
}
|
||||
}
|
||||
return new DarkBoostTable((float[])DefaultMatrix.Clone(), ramp, (float[])DefaultMatrix.Clone());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace VibranceHud.Licensing;
|
||||
|
||||
public static class ServedPairing
|
||||
{
|
||||
private static readonly PairingFormat DefaultFormat = new PairingFormat(
|
||||
Alphabet: "23456789ABCDEFGHJKLMNPQRSTUVWXYZ",
|
||||
TokenLength: 26,
|
||||
TokenBits: 128,
|
||||
UrlTemplate: "http://{address}:{port}/?k={token}");
|
||||
|
||||
public static PairingFormat Current => DefaultFormat;
|
||||
|
||||
public static ServedSource Source => ServedSource.Served;
|
||||
|
||||
internal static void Install()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace VibranceHud.Licensing;
|
||||
|
||||
public enum ServedSource
|
||||
{
|
||||
Withheld,
|
||||
Served
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
|
||||
namespace VibranceHud.Licensing;
|
||||
|
||||
internal sealed class ServedVibranceCurve
|
||||
{
|
||||
private readonly float[][] _points;
|
||||
|
||||
internal ServedVibranceCurve(float[][] points)
|
||||
{
|
||||
_points = points;
|
||||
}
|
||||
|
||||
internal ServedVibrancePoint At(int level, bool driver, bool streaming)
|
||||
{
|
||||
float[] array = _points[Math.Clamp(level, 0, _points.Length - 1)];
|
||||
bool flag = driver && !streaming;
|
||||
return new ServedVibrancePoint((int)array[0], array[(!flag) ? 1 : 3], array[flag ? 4 : 2]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace VibranceHud.Licensing;
|
||||
|
||||
internal readonly record struct ServedVibrancePoint(int Driver, float Red, float Chroma)
|
||||
{
|
||||
internal static readonly ServedVibrancePoint Neutral = new ServedVibrancePoint(50, 1f, 1f);
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace VibranceHud.Licensing;
|
||||
|
||||
public sealed record ShareCodeFormat(string Alphabet, string Prefix, int ChecksumModulus, int ChecksumWeightStep, int ChecksumWeightOffset, int ChecksumIndexOffset, IReadOnlyDictionary<int, int> BodyLengths, int MaxVibrance, int MaxSaturation, int MinBrightness, int MaxBrightness, int MinGamma, int MaxGamma, int MinContrast, int MaxContrast, int MinTemperature, int MaxTemperature, int MinGrade, int MaxGrade)
|
||||
{
|
||||
public bool Withheld
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Alphabet.Length != 0 && Prefix.Length != 0)
|
||||
{
|
||||
return BodyLengths.Count == 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static readonly ShareCodeFormat Withholding = new ShareCodeFormat("", "", 32, 2, 1, 0, new Dictionary<int, int>(), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
|
||||
public int FieldsFor(int bodyLength)
|
||||
{
|
||||
if (!BodyLengths.TryGetValue(bodyLength, out var value))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public int Checksum(string body)
|
||||
{
|
||||
int num = 0;
|
||||
for (int i = 0; i < body.Length; i++)
|
||||
{
|
||||
int num2 = Alphabet.IndexOf(body[i]);
|
||||
if (num2 < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
num += (num2 + ChecksumIndexOffset) * (ChecksumWeightStep * i + ChecksumWeightOffset);
|
||||
}
|
||||
if (ChecksumModulus > 0)
|
||||
{
|
||||
return num % ChecksumModulus;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user