Initial release: HSUI v1.0.0.0 - HUD replacement with configurable hotbars
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Text;
|
||||
|
||||
namespace HSUI.Config.Profiles
|
||||
{
|
||||
public static class ImportExportHelper
|
||||
{
|
||||
public static string CompressAndBase64Encode(string jsonString)
|
||||
{
|
||||
using MemoryStream output = new();
|
||||
|
||||
using (DeflateStream gzip = new(output, CompressionLevel.Optimal))
|
||||
{
|
||||
using StreamWriter writer = new(gzip, Encoding.UTF8);
|
||||
writer.Write(jsonString);
|
||||
}
|
||||
|
||||
return Convert.ToBase64String(output.ToArray());
|
||||
}
|
||||
|
||||
public static string Base64DecodeAndDecompress(string base64String)
|
||||
{
|
||||
var base64EncodedBytes = Convert.FromBase64String(base64String);
|
||||
|
||||
using MemoryStream inputStream = new(base64EncodedBytes);
|
||||
using DeflateStream gzip = new(inputStream, CompressionMode.Decompress);
|
||||
using StreamReader reader = new(gzip, Encoding.UTF8);
|
||||
var decodedString = reader.ReadToEnd();
|
||||
|
||||
return decodedString;
|
||||
}
|
||||
|
||||
public static string GenerateExportString(object obj)
|
||||
{
|
||||
JsonSerializerSettings settings = new JsonSerializerSettings
|
||||
{
|
||||
TypeNameAssemblyFormatHandling = TypeNameAssemblyFormatHandling.Simple,
|
||||
TypeNameHandling = TypeNameHandling.Objects
|
||||
};
|
||||
|
||||
var jsonString = JsonConvert.SerializeObject(obj, Formatting.Indented, settings);
|
||||
return CompressAndBase64Encode(jsonString);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
using HSUI.Helpers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HSUI.Config.Profiles
|
||||
{
|
||||
public class Profile
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public bool AutoSwitchEnabled = false;
|
||||
public AutoSwitchData AutoSwitchData = new AutoSwitchData();
|
||||
public int HudLayout;
|
||||
public bool AttachHudEnabled = false;
|
||||
|
||||
public Profile(string name, bool autoSwitchEnabled = false, AutoSwitchData? autoSwitchData = null, bool attachHudEnabled = false, int hudLayout = 0)
|
||||
{
|
||||
Name = name;
|
||||
|
||||
AutoSwitchEnabled = autoSwitchEnabled;
|
||||
AutoSwitchData = autoSwitchData ?? AutoSwitchData;
|
||||
|
||||
AttachHudEnabled = attachHudEnabled;
|
||||
HudLayout = hudLayout;
|
||||
}
|
||||
}
|
||||
|
||||
public class AutoSwitchData
|
||||
{
|
||||
public Dictionary<JobRoles, List<bool>> Map;
|
||||
|
||||
public AutoSwitchData()
|
||||
{
|
||||
Map = new Dictionary<JobRoles, List<bool>>();
|
||||
|
||||
JobRoles[] roles = (JobRoles[])Enum.GetValues(typeof(JobRoles));
|
||||
|
||||
foreach (JobRoles role in roles)
|
||||
{
|
||||
int count = JobsHelper.JobsByRole[role].Count;
|
||||
List<bool> list = new List<bool>(count);
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
list.Add(false);
|
||||
}
|
||||
|
||||
Map.Add(role, list);
|
||||
}
|
||||
}
|
||||
|
||||
public bool GetRoleEnabled(JobRoles role)
|
||||
{
|
||||
foreach (bool value in Map[role])
|
||||
{
|
||||
if (!value)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void SetRoleEnabled(JobRoles role, bool value)
|
||||
{
|
||||
for (int i = 0; i < Map[role].Count; i++)
|
||||
{
|
||||
Map[role][i] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsEnabled(JobRoles role, int index)
|
||||
{
|
||||
if (Map.TryGetValue(role, out List<bool>? list) && list != null)
|
||||
{
|
||||
if (index >= list.Count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return list[index];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool ValidateRolesData()
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
JobRoles[] roles = (JobRoles[])Enum.GetValues(typeof(JobRoles));
|
||||
|
||||
foreach (JobRoles role in roles)
|
||||
{
|
||||
int count = JobsHelper.JobsByRole[role].Count;
|
||||
List<bool> list = Map[role];
|
||||
|
||||
if (list.Count < count)
|
||||
{
|
||||
for (int i = 0; i < count - list.Count; i++)
|
||||
{
|
||||
list.Add(false);
|
||||
}
|
||||
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user