2021-03-07 01:10:31 +00:00
|
|
|
using System;
|
2021-04-27 16:44:44 +01:00
|
|
|
using System.Collections.Generic;
|
2021-04-13 01:50:42 +01:00
|
|
|
using System.Globalization;
|
2021-03-07 01:10:31 +00:00
|
|
|
using MessagePack;
|
|
|
|
|
|
2021-05-06 02:34:19 +01:00
|
|
|
[MessagePackObject]
|
2021-03-07 01:10:31 +00:00
|
|
|
public class PlayerSettings
|
|
|
|
|
{
|
2021-03-14 03:56:49 +00:00
|
|
|
[Key(0)] public string Name = "Anonymous";
|
2021-05-06 02:34:19 +01:00
|
|
|
[Key(2)] public bool TutorialPassed;
|
|
|
|
|
[Key(3)] public Dictionary<string, string> HashedStoryFiles = new Dictionary<string, string>();
|
2021-05-06 18:43:23 +01:00
|
|
|
[Key(4)] public PlayerGameplaySettings GameplaySettings = new PlayerGameplaySettings();
|
|
|
|
|
[Key(5)] public PlayerInputSettings InputSettings = new PlayerInputSettings();
|
2022-07-18 08:44:54 +01:00
|
|
|
[Key(6)] public PlayerGraphicsSettings GraphicsSettings = new PlayerGraphicsSettings();
|
2021-04-13 01:50:42 +01:00
|
|
|
|
|
|
|
|
public string FormatTemperature(float t)
|
|
|
|
|
{
|
2021-05-06 02:34:19 +01:00
|
|
|
return GameplaySettings.TemperatureUnit switch
|
2021-04-13 01:50:42 +01:00
|
|
|
{
|
|
|
|
|
TemperatureUnit.Kelvin => $"{Format(t)}°K",
|
|
|
|
|
TemperatureUnit.Celsius => $"{Format(t - 273.15f)}°C",
|
2021-05-06 18:43:23 +01:00
|
|
|
TemperatureUnit.Fahrenheit => $"{Format(t * (9f / 5) - 459.67f)}°F",
|
2021-04-13 01:50:42 +01:00
|
|
|
_ => throw new ArgumentOutOfRangeException()
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public float ParseTemperature(string s)
|
|
|
|
|
{
|
|
|
|
|
var t = float.Parse(s);
|
2021-05-06 02:34:19 +01:00
|
|
|
return GameplaySettings.TemperatureUnit switch
|
2021-04-13 01:50:42 +01:00
|
|
|
{
|
|
|
|
|
TemperatureUnit.Kelvin => t,
|
|
|
|
|
TemperatureUnit.Celsius => t + 273.15f,
|
|
|
|
|
TemperatureUnit.Fahrenheit => (t - 32) * (5f / 9) + 273.15f,
|
|
|
|
|
_ => throw new ArgumentOutOfRangeException()
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Format(float d)
|
|
|
|
|
{
|
|
|
|
|
var magnitude = d == 0.0f ? 0 : (int)Math.Floor(Math.Log10(Math.Abs(d))) + 1;
|
2021-05-06 02:34:19 +01:00
|
|
|
var digits = GameplaySettings.SignificantDigits;
|
2021-04-13 02:16:03 +01:00
|
|
|
digits -= magnitude;
|
|
|
|
|
if (digits < 0)
|
|
|
|
|
digits = 0;
|
|
|
|
|
var strdec = d.ToString($"N{digits}");
|
2021-04-13 01:50:42 +01:00
|
|
|
var dec = Convert.ToChar(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator);
|
|
|
|
|
return strdec.Contains(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator) ? strdec.TrimEnd('0').TrimEnd(dec) : strdec;
|
|
|
|
|
}
|
2021-05-06 02:34:19 +01:00
|
|
|
}
|
|
|
|
|
|
2021-05-07 19:51:23 +01:00
|
|
|
[MessagePackObject]
|
2021-05-06 02:34:19 +01:00
|
|
|
public class PlayerGameplaySettings
|
|
|
|
|
{
|
|
|
|
|
[Key(0)] public TemperatureUnit TemperatureUnit = TemperatureUnit.Celsius;
|
|
|
|
|
[Key(1)] public int SignificantDigits = 3;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-18 08:44:54 +01:00
|
|
|
[MessagePackObject]
|
|
|
|
|
public class PlayerGraphicsSettings
|
|
|
|
|
{
|
|
|
|
|
[Key(0)] public Quality NebulaQuality = Quality.Normal;
|
|
|
|
|
[Key(1)] public bool ShowAsteroidsInMinimap;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-07 19:51:23 +01:00
|
|
|
[MessagePackObject]
|
2021-05-06 02:34:19 +01:00
|
|
|
public class PlayerInputSettings
|
|
|
|
|
{
|
2021-05-08 07:35:16 +01:00
|
|
|
[Key(0)] public Dictionary<(string action, int binding), string> InputActionMap = new Dictionary<(string action, int binding), string>();
|
2021-05-06 18:43:23 +01:00
|
|
|
[Key(1)] public List<string> ActionBarInputs = new List<string>();
|
2022-07-18 08:44:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum Quality
|
|
|
|
|
{
|
|
|
|
|
Low,
|
|
|
|
|
Normal,
|
|
|
|
|
High,
|
|
|
|
|
Ultra
|
2026-06-13 05:21:22 +01:00
|
|
|
}
|