public static void Load()
{
if (KSP.IO.File.Exists<RemoteCore>("Settings.cfg"))
{
string[] ls = KSP.IO.File.ReadAllLines<RemoteCore>("Settings.cfg");
string
SPEEDOFLIGHT = "",
RCC = "",
SETKEY = "",
EXTPACK = "",
COLFRIEND = "";
foreach (string s in ls)
{
if (!s.StartsWith("//") && s.Length > 2)
{
if (s.StartsWith("Speed of Light"))
SPEEDOFLIGHT = s;
else if (s.StartsWith("RemoteCommand Crew"))
RCC = s;
else if (s.StartsWith("Settings Key"))
SETKEY = s;
else if (s.StartsWith("Extended Loading Range"))
EXTPACK = s;
else if (s.StartsWith("Colourblind friendly mode"))
COLFRIEND = s;
}
}
string[] temp = SPEEDOFLIGHT.Split("=".ToCharArray());
string tmp = temp[temp.Length - 1];
temp = tmp.Split(" ".ToCharArray());
try
{
speedOfLight = double.Parse(temp[temp.Length - 1]);
}
catch (Exception)
{
speedOfLight = 300000000;
}
temp = RCC.Split("=".ToCharArray());
tmp = temp[temp.Length - 1];
temp = tmp.Split(" ".ToCharArray());
try
{
int crew = int.Parse(temp[temp.Length - 1]);
if (crew > 0)
RemoteCommandCrew = crew;
else
RemoteCommandCrew = 1;
}
catch (Exception)
{
RemoteCommandCrew = 3;
}
temp = SETKEY.Split("=".ToCharArray());
tmp = temp[temp.Length - 1];
temp = tmp.Split(" ".ToCharArray());
try
{
Input.GetKey(temp[temp.Length - 1]);
settingsKey = temp[temp.Length - 1];
}
catch (Exception)
{
settingsKey = "f11";
}
temp = EXTPACK.Split("=".ToCharArray());
tmp = temp[temp.Length - 1];
temp = tmp.Split(" ".ToCharArray());
try
{
if (temp[temp.Length - 1].ToLower().Equals("on")) extPack = true;
if (temp[temp.Length - 1].ToLower().Equals("off")) extPack = false;
}
catch (Exception)
{
extPack = true;
}
temp = COLFRIEND.Split("=".ToCharArray());
tmp = temp[temp.Length - 1];
temp = tmp.Split(" ".ToCharArray());
try
{
if (temp[temp.Length - 1].ToLower().Equals("on")) ColFriend = true;
if (temp[temp.Length - 1].ToLower().Equals("off")) ColFriend = false;
}
catch (Exception)
{
ColFriend = false;
}
}
else
KSP.IO.File.WriteAllText<RemoteCore>(
"//Here you can edit key used to access the RemoteTech settings (modifier key + settings key) (Default: f11):\nSettings Key = " + "f11" +
"\n\n//Here you can edit the speed of light used to calculate control delay in m/s (Default: 300000000):\nSpeed of Light = " + "300000000" +
"\n\n//Here you can edit the required crew for a command station (Minimum: 1, Default: 3)\nRemoteCommand Crew = " + "3" +
"\n\n//Here you can toggle extended control range for unfocused vessels. If on, this could cause a bit of lag if you try to control an unfocused vessel when there are a lot of vessels in your immediate viscinity (default on)\nExtended Loading Range = " + "on" +
"\n\n//Here you can toggle coulourblind friendly mode (default off)\nColourblind friendly mode = " + "off"
, "Settings.cfg");
}