config part 3: fully compliable but still HEAVILY a WIP.

This commit is contained in:
Bitl 2023-05-22 22:48:25 -07:00
parent 43c7856fba
commit ad8c128aa4
9 changed files with 154 additions and 161 deletions

View File

@ -17,11 +17,12 @@ namespace Novetus.Bootstrapper
private void NovetusLaunchForm_Load(object sender, EventArgs e)
{
if (File.Exists(LocalPaths.ConfigPath))
{
FileManagement.ReadInfoFile(LocalPaths.InfoPath,
FileManagement.ReadInfoFile(LocalPaths.InfoPath,
LocalPaths.VersionTermList,
LocalPaths.LauncherPath);
if (File.Exists(LocalPaths.ConfigPath))
{
ReadConfigValues(LocalPaths.ConfigPath);
}

View File

@ -89,6 +89,11 @@ namespace Novetus.Core
public void CreateFile()
{
INI = new INIFile(FullPath);
DeployDefaults();
}
public virtual void DeployDefaults()
{
GenerateDefaults();
GenerateDefaultsEvent();
}
@ -169,12 +174,24 @@ namespace Novetus.Core
public int ReadSettingInt(string name)
{
return Convert.ToInt32(ReadSetting(name));
bool result = int.TryParse(ReadSetting(name), out int value);
if(result)
{
return value;
}
return 0;
}
public bool ReadSettingBool(string name)
{
return Convert.ToBoolean(ReadSetting(name));
bool result = bool.TryParse(ReadSetting(name), out bool value);
if (result)
{
return value;
}
return false;
}
public virtual void ReadSettingEvent()
@ -271,7 +288,7 @@ namespace Novetus.Core
public override void ReadSettingEvent()
{
FileManagement.ReloadLoadoutValue();
//FileManagement.ReloadLoadoutValue();
}
}
#endregion
@ -793,10 +810,7 @@ namespace Novetus.Core
GlobalVars.ProgramInformation.InitialBootup = Convert.ToBoolean(initialBootup);
GlobalVars.ProgramInformation.VersionName = verNumber;
GlobalVars.ProgramInformation.IsSnapshot = Convert.ToBoolean(isSnapshot);
GlobalVars.UserConfiguration.SaveSetting("SelectedClient", GlobalVars.ProgramInformation.DefaultClient);
GlobalVars.UserConfiguration.SaveSetting("Map", GlobalVars.ProgramInformation.DefaultMap);
GlobalVars.UserConfiguration.SaveSetting("MapPath", GlobalPaths.MapsDir + @"\\" + GlobalVars.ProgramInformation.DefaultMap);
GlobalVars.UserConfiguration.SaveSetting("MapPathSnip", GlobalPaths.MapsDirBase + @"\\" + GlobalVars.ProgramInformation.DefaultMap);
RegisterDefaults();
}
catch (Exception ex)
{
@ -805,6 +819,14 @@ namespace Novetus.Core
}
}
public static void RegisterDefaults()
{
GlobalVars.UserConfiguration.SaveSetting("SelectedClient", GlobalVars.ProgramInformation.DefaultClient);
GlobalVars.UserConfiguration.SaveSetting("Map", GlobalVars.ProgramInformation.DefaultMap);
GlobalVars.UserConfiguration.SaveSetting("MapPath", GlobalPaths.MapsDir + @"\\" + GlobalVars.ProgramInformation.DefaultMap);
GlobalVars.UserConfiguration.SaveSetting("MapPathSnip", GlobalPaths.MapsDirBase + @"\\" + GlobalVars.ProgramInformation.DefaultMap);
}
public static void TurnOffInitialSequence()
{
//READ

View File

@ -110,7 +110,6 @@ namespace Novetus.Core
#region File Names
public static readonly string ConfigName = "config.ini";
public static readonly string CMDConfigName = "config_cmd.ini";
public static string ConfigNameCustomization = "config_customization.ini";
public static readonly string InfoName = "info.ini";
public static readonly string ScriptName = "CSMPFunctions";

View File

@ -79,7 +79,7 @@ namespace NovetusLauncher
void CheckBox1CheckedChanged(object sender, EventArgs e)
{
GlobalVars.UserConfiguration.CloseOnLaunch = checkBox1.Checked;
GlobalVars.UserConfiguration.SaveSettingBool("CloseOnLaunch", checkBox1.Checked);
}
void Button4Click(object sender, EventArgs e)
@ -179,7 +179,7 @@ namespace NovetusLauncher
void NumericUpDown3ValueChanged(object sender, EventArgs e)
{
GlobalVars.UserConfiguration.PlayerLimit = Convert.ToInt32(numericUpDown3.Value);
GlobalVars.UserConfiguration.SaveSettingInt("PlayerLimit", Convert.ToInt32(numericUpDown3.Value));
}
void Button22Click(object sender, EventArgs e)
@ -199,7 +199,7 @@ namespace NovetusLauncher
void CheckBox4CheckedChanged(object sender, EventArgs e)
{
GlobalVars.UserConfiguration.UPnP = checkBox4.Checked;
GlobalVars.UserConfiguration.SaveSettingBool("UPnP", checkBox4.Checked);
}
void CheckBox4Click(object sender, EventArgs e)
@ -225,7 +225,7 @@ namespace NovetusLauncher
private void checkBox2_CheckedChanged(object sender, EventArgs e)
{
GlobalVars.UserConfiguration.DiscordRichPresence = checkBox2.Checked;
GlobalVars.UserConfiguration.SaveSettingBool("DiscordRichPresence", checkBox2.Checked);
}
void CheckBox2Click(object sender, EventArgs e)
@ -266,17 +266,17 @@ namespace NovetusLauncher
private void checkBox9_CheckedChanged(object sender, EventArgs e)
{
GlobalVars.UserConfiguration.ShowServerNotifications = checkBox9.Checked;
GlobalVars.UserConfiguration.SaveSettingBool("ShowServerNotifications", checkBox9.Checked);
}
private void textBox7_TextChanged(object sender, EventArgs e)
{
GlobalVars.UserConfiguration.ServerBrowserServerName = textBox7.Text;
GlobalVars.UserConfiguration.SaveSetting("ServerBrowserServerName", textBox7.Text);
}
private void textBox8_TextChanged(object sender, EventArgs e)
{
GlobalVars.UserConfiguration.ServerBrowserServerAddress = textBox8.Text;
GlobalVars.UserConfiguration.SaveSetting("ServerBrowserServerAddress", textBox8.Text);
}
private void textBox8_Click(object sender, EventArgs e)

View File

@ -88,8 +88,8 @@ namespace NovetusLauncher
void CheckBox1CheckedChanged(object sender, EventArgs e)
{
GlobalVars.UserConfiguration.CloseOnLaunch = checkBox1.Checked;
}
GlobalVars.UserConfiguration.SaveSettingBool("CloseOnLaunch", checkBox1.Checked);
}
void Button4Click(object sender, EventArgs e)
{
@ -188,8 +188,8 @@ namespace NovetusLauncher
void NumericUpDown3ValueChanged(object sender, EventArgs e)
{
GlobalVars.UserConfiguration.PlayerLimit = Convert.ToInt32(numericUpDown3.Value);
}
GlobalVars.UserConfiguration.SaveSettingInt("PlayerLimit", Convert.ToInt32(numericUpDown3.Value));
}
void Button22Click(object sender, EventArgs e)
{
@ -208,8 +208,8 @@ namespace NovetusLauncher
void CheckBox4CheckedChanged(object sender, EventArgs e)
{
GlobalVars.UserConfiguration.UPnP = checkBox4.Checked;
}
GlobalVars.UserConfiguration.SaveSettingBool("UPnP", checkBox4.Checked);
}
void CheckBox4Click(object sender, EventArgs e)
{
@ -234,8 +234,8 @@ namespace NovetusLauncher
private void checkBox2_CheckedChanged(object sender, EventArgs e)
{
GlobalVars.UserConfiguration.DiscordRichPresence = checkBox2.Checked;
}
GlobalVars.UserConfiguration.SaveSettingBool("DiscordRichPresence", checkBox2.Checked);
}
void CheckBox2Click(object sender, EventArgs e)
{
@ -308,22 +308,22 @@ namespace NovetusLauncher
browser.Show();
}
private void checkBox9_CheckedChanged(object sender, EventArgs e)
{
GlobalVars.UserConfiguration.ShowServerNotifications = checkBox9.Checked;
}
private void checkBox9_CheckedChanged(object sender, EventArgs e)
{
GlobalVars.UserConfiguration.SaveSettingBool("ShowServerNotifications", checkBox9.Checked);
}
private void textBox7_TextChanged(object sender, EventArgs e)
{
GlobalVars.UserConfiguration.ServerBrowserServerName = textBox7.Text;
}
private void textBox7_TextChanged(object sender, EventArgs e)
{
GlobalVars.UserConfiguration.SaveSetting("ServerBrowserServerName", textBox7.Text);
}
private void textBox8_TextChanged(object sender, EventArgs e)
{
GlobalVars.UserConfiguration.ServerBrowserServerAddress = textBox8.Text;
}
private void textBox8_TextChanged(object sender, EventArgs e)
{
GlobalVars.UserConfiguration.SaveSetting("ServerBrowserServerAddress", textBox8.Text);
}
private void textBox8_Click(object sender, EventArgs e)
private void textBox8_Click(object sender, EventArgs e)
{
launcherForm.ShowMasterServerWarning();
}

View File

@ -99,8 +99,8 @@ namespace NovetusLauncher
if (FormStyle == Settings.Style.Stylish)
{
Parent.Text = "Novetus " + GlobalVars.ProgramInformation.Version + " [CLIENT: " +
GlobalVars.UserConfiguration.SelectedClient + " | MAP: " +
GlobalVars.UserConfiguration.Map + "]";
GlobalVars.UserConfiguration.ReadSetting("SelectedClient") + " | MAP: " +
GlobalVars.UserConfiguration.ReadSetting("Map") + "]";
}
Splash splash = SplashReader.GetSplash();
@ -175,11 +175,11 @@ namespace NovetusLauncher
{
WriteConfigValues();
}
if (GlobalVars.UserConfiguration.DiscordRichPresence)
if (GlobalVars.UserConfiguration.ReadSettingBool("DiscordRichPresence"))
{
IDiscordRPC.Shutdown();
}
if (GlobalVars.UserConfiguration.WebProxyEnabled)
if (GlobalVars.UserConfiguration.ReadSettingBool("WebProxyEnabled"))
{
GlobalVars.Proxy.Stop();
}
@ -221,7 +221,7 @@ namespace NovetusLauncher
{
ClientBox.Items.Add(dir.Name);
}
ClientBox.SelectedItem = GlobalVars.UserConfiguration.SelectedClient;
ClientBox.SelectedItem = GlobalVars.UserConfiguration.ReadSetting("SelectedClient");
Tree.Nodes.Clear();
_TreeCache.Nodes.Clear();
MapDescBox.Text = "";
@ -354,7 +354,7 @@ namespace NovetusLauncher
break;
}
if (GlobalVars.UserConfiguration.CloseOnLaunch && !GlobalVars.isConsoleOnly)
if (GlobalVars.UserConfiguration.ReadSettingBool("CloseOnLaunch") && !GlobalVars.isConsoleOnly)
{
Parent.Visible = false;
}
@ -374,7 +374,7 @@ namespace NovetusLauncher
switch (LocalVars.Clicks)
{
case 1:
SplashLabel.Text = "Hi " + GlobalVars.UserConfiguration.PlayerName + "!";
SplashLabel.Text = "Hi " + GlobalVars.UserConfiguration.ReadSetting("SelectedClient") + "!";
break;
case 3:
SplashLabel.Text = "How are you doing today?";
@ -452,7 +452,7 @@ namespace NovetusLauncher
{
ClientManagement.UpdateRichPresence(ClientManagement.GetStateForType(GlobalVars.GameOpened));
if (GlobalVars.UserConfiguration.CloseOnLaunch)
if (GlobalVars.UserConfiguration.ReadSettingBool("CloseOnLaunch"))
{
Parent.Visible = true;
}
@ -548,21 +548,21 @@ namespace NovetusLauncher
case 0:
if (FormStyle != Settings.Style.Extended)
{
GlobalVars.UserConfiguration.LauncherStyle = Settings.Style.Extended;
GlobalVars.UserConfiguration.SaveSettingInt("LauncherStyle", (int)Settings.Style.Extended);
RestartApp();
}
break;
case 1:
if (FormStyle != Settings.Style.Compact)
{
GlobalVars.UserConfiguration.LauncherStyle = Settings.Style.Compact;
GlobalVars.UserConfiguration.SaveSettingInt("LauncherStyle", (int)Settings.Style.Compact);
RestartApp();
}
break;
case 2:
if (FormStyle != Settings.Style.Stylish)
{
GlobalVars.UserConfiguration.LauncherStyle = Settings.Style.Stylish;
GlobalVars.UserConfiguration.SaveSettingInt("LauncherStyle", (int)Settings.Style.Stylish);
RestartApp();
}
break;
@ -580,28 +580,26 @@ namespace NovetusLauncher
public void ReadConfigValues(bool initial = false)
{
FileManagement.Config(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigName, false);
CloseOnLaunchCheckbox.Checked = GlobalVars.UserConfiguration.CloseOnLaunch;
PlayerIDTextBox.Text = GlobalVars.UserConfiguration.UserID.ToString();
CloseOnLaunchCheckbox.Checked = GlobalVars.UserConfiguration.ReadSettingBool("CloseOnLaunch");
PlayerIDTextBox.Text = GlobalVars.UserConfiguration.ReadSetting("UserID");
PlayerTripcodeLabel.Text = GlobalVars.PlayerTripcode.ToString();
PlayerLimitBox.Value = Convert.ToDecimal(GlobalVars.UserConfiguration.PlayerLimit);
PlayerNameTextBox.Text = GlobalVars.UserConfiguration.PlayerName;
SelectedClientLabel.Text = GlobalVars.UserConfiguration.SelectedClient;
SelectedMapLabel.Text = GlobalVars.UserConfiguration.Map;
Tree.SelectedNode = TreeNodeHelper.SearchTreeView(GlobalVars.UserConfiguration.Map, Tree.Nodes);
PlayerLimitBox.Value = Convert.ToDecimal(GlobalVars.UserConfiguration.ReadSettingInt("PlayerLimit"));
PlayerNameTextBox.Text = GlobalVars.UserConfiguration.ReadSetting("PlayerName");
SelectedClientLabel.Text = GlobalVars.UserConfiguration.ReadSetting("SelectedClient");
SelectedMapLabel.Text = GlobalVars.UserConfiguration.ReadSetting("Map");
Tree.SelectedNode = TreeNodeHelper.SearchTreeView(GlobalVars.UserConfiguration.ReadSetting("Map"), Tree.Nodes);
Tree.Focus();
IPBox.Text = GlobalVars.CurrentServer.ToString();
HostPortBox.Value = Convert.ToDecimal(GlobalVars.UserConfiguration.RobloxPort);
HostPortBox.Value = Convert.ToDecimal(GlobalVars.UserConfiguration.ReadSettingInt("RobloxPort"));
IPLabel.Text = GlobalVars.CurrentServer.ServerIP;
PortLabel.Text = GlobalVars.CurrentServer.ServerPort.ToString();
DiscordRichPresenceCheckbox.Checked = GlobalVars.UserConfiguration.DiscordRichPresence;
uPnPCheckBox.Checked = GlobalVars.UserConfiguration.UPnP;
ShowServerNotifsCheckBox.Checked = GlobalVars.UserConfiguration.ShowServerNotifications;
ServerBrowserNameBox.Text = GlobalVars.UserConfiguration.ServerBrowserServerName;
ServerBrowserAddressBox.Text = GlobalVars.UserConfiguration.ServerBrowserServerAddress;
DiscordRichPresenceCheckbox.Checked = GlobalVars.UserConfiguration.ReadSettingBool("DiscordRichPresence");
uPnPCheckBox.Checked = GlobalVars.UserConfiguration.ReadSettingBool("UPnP");
ShowServerNotifsCheckBox.Checked = GlobalVars.UserConfiguration.ReadSettingBool("ShowServerNotifications");
ServerBrowserNameBox.Text = GlobalVars.UserConfiguration.ReadSetting("ServerBrowserServerName");
ServerBrowserAddressBox.Text = GlobalVars.UserConfiguration.ReadSetting("ServerBrowserServerAddress");
switch (GlobalVars.UserConfiguration.LauncherStyle)
switch ((Settings.Style)GlobalVars.UserConfiguration.ReadSettingInt("LauncherStyle"))
{
case Settings.Style.Compact:
StyleSelectorBox.SelectedIndex = 1;
@ -621,19 +619,18 @@ namespace NovetusLauncher
public void WriteConfigValues(bool ShowBox = false)
{
FileManagement.Config(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigName, true);
/*
ClientManagement.ReadClientValues();
Util.ConsolePrint("Config Saved.", 3);
if (ShowBox)
{
MessageBox.Show("Config Saved!", "Novetus - Config Saved", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}*/
}
public void WriteCustomizationValues()
{
FileManagement.Customization(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigNameCustomization, true);
Util.ConsolePrint("Config Saved.", 3);
//Util.ConsolePrint("Config Saved.", 3);
}
public void ResetConfigValuesInternal()
@ -669,7 +666,7 @@ namespace NovetusLauncher
public bool GenerateIfInvalid()
{
string clientpath = GlobalPaths.ClientDir + @"\\" + GlobalVars.UserConfiguration.SelectedClient + @"\\clientinfo.nov";
string clientpath = GlobalPaths.ClientDir + @"\\" + GlobalVars.UserConfiguration.ReadSetting("SelectedClient") + @"\\clientinfo.nov";
if (!File.Exists(clientpath))
{
@ -682,7 +679,7 @@ namespace NovetusLauncher
{
Util.LogExceptions(ex);
MessageBox.Show("Failed to generate default clientinfo.nov. Info: " + ex.Message + "\n\nLoading default client '" + GlobalVars.ProgramInformation.DefaultClient + "'", "Novetus - Client Info Generation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
GlobalVars.UserConfiguration.SelectedClient = GlobalVars.ProgramInformation.DefaultClient;
GlobalVars.UserConfiguration.SaveSetting("SelectedClient", GlobalVars.ProgramInformation.DefaultClient);
return false;
}
}
@ -697,7 +694,7 @@ namespace NovetusLauncher
{
if (Tabs.SelectedTab == Tabs.TabPages[TabPageClients])
{
ClientBox.SelectedItem = GlobalVars.UserConfiguration.SelectedClient;
ClientBox.SelectedItem = GlobalVars.UserConfiguration.ReadSetting("PlayerLimit");
}
}
@ -732,13 +729,13 @@ namespace NovetusLauncher
}
ClientDescriptionBox.Text = GlobalVars.SelectedClientInfo.Description;
SelectedClientLabel.Text = GlobalVars.UserConfiguration.SelectedClient;
SelectedClientLabel.Text = GlobalVars.UserConfiguration.ReadSetting("SelectedClient");
}
public void GeneratePlayerID()
{
NovetusFuncs.GeneratePlayerID();
PlayerIDTextBox.Text = Convert.ToString(GlobalVars.UserConfiguration.UserID);
PlayerIDTextBox.Text = GlobalVars.UserConfiguration.ReadSetting("UserID");
}
public async void InstallAddon()
@ -807,7 +804,7 @@ namespace NovetusLauncher
string[] fileexts = new string[] { ".rbxl", ".rbxlx", ".bz2" };
TreeNodeHelper.ListDirectory(Tree, mapdir, fileexts);
TreeNodeHelper.CopyNodes(Tree.Nodes, _TreeCache.Nodes);
Tree.SelectedNode = TreeNodeHelper.SearchTreeView(GlobalVars.UserConfiguration.Map, Tree.Nodes);
Tree.SelectedNode = TreeNodeHelper.SearchTreeView(GlobalVars.UserConfiguration.ReadSetting("Map"), Tree.Nodes);
if (FormStyle == Settings.Style.Stylish)
{
Tree.SelectedNode.BackColor = SystemColors.Highlight;
@ -855,13 +852,13 @@ namespace NovetusLauncher
{
if (Tree.SelectedNode.Nodes.Count == 0)
{
GlobalVars.UserConfiguration.Map = Tree.SelectedNode.Text.ToString();
GlobalVars.UserConfiguration.MapPathSnip = Tree.SelectedNode.FullPath.ToString().Replace(@"\", @"\\");
GlobalVars.UserConfiguration.MapPath = GlobalPaths.BasePath + @"\\" + GlobalVars.UserConfiguration.MapPathSnip;
GlobalVars.UserConfiguration.SaveSetting("Map", Tree.SelectedNode.Text.ToString());
GlobalVars.UserConfiguration.SaveSetting("MapPathSnip", Tree.SelectedNode.FullPath.ToString().Replace(@"\", @"\\"));
GlobalVars.UserConfiguration.SaveSetting("MapPath", GlobalPaths.BasePath + @"\\" + GlobalVars.UserConfiguration.ReadSetting("MapPathSnip"));
if (FormStyle != Settings.Style.Stylish)
{
SelectedMapLabel.Text = GlobalVars.UserConfiguration.Map;
SelectedMapLabel.Text = GlobalVars.UserConfiguration.ReadSetting("Map");
LoadMapDesc();
}
}
@ -968,7 +965,7 @@ namespace NovetusLauncher
public void ChangeServerPort()
{
GlobalVars.UserConfiguration.RobloxPort = Convert.ToInt32(HostPortBox.Value);
GlobalVars.UserConfiguration.SaveSettingInt("RobloxPort", Convert.ToInt32(HostPortBox.Value));
}
public void ChangeClient()
@ -991,13 +988,13 @@ namespace NovetusLauncher
if (ClientBox.SelectedItem == null)
return;
string ourselectedclient = GlobalVars.UserConfiguration.SelectedClient;
string ourselectedclient = GlobalVars.UserConfiguration.ReadSetting("SelectedClient");
GlobalVars.UserConfiguration.SelectedClient = ClientBox.SelectedItem.ToString();
GlobalVars.UserConfiguration.SaveSetting("SelectedClient", ClientBox.SelectedItem.ToString());
if (!string.IsNullOrWhiteSpace(ourselectedclient))
{
if (!ourselectedclient.Equals(GlobalVars.UserConfiguration.SelectedClient))
if (!ourselectedclient.Equals(GlobalVars.UserConfiguration.ReadSetting("SelectedClient")))
{
ReadClientValues(true);
}
@ -1051,8 +1048,8 @@ namespace NovetusLauncher
public void ChangeName()
{
GlobalVars.UserConfiguration.PlayerName = PlayerNameTextBox.Text;
int autoNameID = GetSpecialNameID(GlobalVars.UserConfiguration.PlayerName);
GlobalVars.UserConfiguration.SaveSetting("PlayerName", PlayerNameTextBox.Text);
int autoNameID = GetSpecialNameID(GlobalVars.UserConfiguration.ReadSetting("PlayerName"));
if (LocalVars.launcherInitState == false && autoNameID > 0)
{
PlayerIDTextBox.Text = autoNameID.ToString();
@ -1066,16 +1063,16 @@ namespace NovetusLauncher
{
if (PlayerIDTextBox.Text.Equals(""))
{
GlobalVars.UserConfiguration.UserID = 0;
GlobalVars.UserConfiguration.SaveSettingInt("UserID", 0);
}
else
{
GlobalVars.UserConfiguration.UserID = Convert.ToInt32(PlayerIDTextBox.Text);
GlobalVars.UserConfiguration.SaveSettingInt("UserID", Convert.ToInt32(PlayerIDTextBox.Text));
}
}
else
{
GlobalVars.UserConfiguration.UserID = 0;
GlobalVars.UserConfiguration.SaveSettingInt("UserID", 0);
}
}

View File

@ -105,14 +105,12 @@ namespace NovetusLauncher
public void ReadConfigValues(bool initial = false)
{
FileManagement.Config(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigName, false);
launcherFormStylishInterface1.minimizeOnLaunchBox.IsChecked = GlobalVars.UserConfiguration.CloseOnLaunch;
launcherFormStylishInterface1.userIDBox.Text = GlobalVars.UserConfiguration.UserID.ToString();
launcherFormStylishInterface1.minimizeOnLaunchBox.IsChecked = GlobalVars.UserConfiguration.ReadSettingBool("CloseOnLaunch");
launcherFormStylishInterface1.userIDBox.Text = GlobalVars.UserConfiguration.ReadSetting("UserID");
launcherFormStylishInterface1.tripcodeLabel.Content = GlobalVars.PlayerTripcode.ToString();
launcherFormStylishInterface1.maxPlayersBox.Text = GlobalVars.UserConfiguration.PlayerLimit.ToString();
launcherFormStylishInterface1.userNameBox.Text = GlobalVars.UserConfiguration.PlayerName;
launcherFormStylishInterface1.mapsBox.SelectedNode = TreeNodeHelper.SearchTreeView(GlobalVars.UserConfiguration.Map, launcherFormStylishInterface1.mapsBox.Nodes);
launcherFormStylishInterface1.maxPlayersBox.Text = GlobalVars.UserConfiguration.ReadSetting("PlayerLimit");
launcherFormStylishInterface1.userNameBox.Text = GlobalVars.UserConfiguration.ReadSetting("PlayerName");
launcherFormStylishInterface1.mapsBox.SelectedNode = TreeNodeHelper.SearchTreeView(GlobalVars.UserConfiguration.ReadSetting("Map"), launcherFormStylishInterface1.mapsBox.Nodes);
launcherFormStylishInterface1.mapsBox.Focus();
//stupid fucking HACK because we aren't selecting it properly.
if (launcherFormStylishInterface1.mapsBox.SelectedNode != null)
@ -120,14 +118,14 @@ namespace NovetusLauncher
launcherFormStylishInterface1.mapsBox.SelectedNode.BackColor = SystemColors.Highlight;
launcherFormStylishInterface1.mapsBox.SelectedNode.ForeColor = SystemColors.HighlightText;
}
launcherFormStylishInterface1.serverPortBox.Text = GlobalVars.UserConfiguration.RobloxPort.ToString();
launcherFormStylishInterface1.discordRichPresenceBox.IsChecked = GlobalVars.UserConfiguration.DiscordRichPresence;
launcherFormStylishInterface1.uPnPBox.IsChecked = GlobalVars.UserConfiguration.UPnP;
launcherFormStylishInterface1.NotifBox.IsChecked = GlobalVars.UserConfiguration.ShowServerNotifications;
launcherFormStylishInterface1.browserNameBox.Text = GlobalVars.UserConfiguration.ServerBrowserServerName;
launcherFormStylishInterface1.browserAddressBox.Text = GlobalVars.UserConfiguration.ServerBrowserServerAddress;
launcherFormStylishInterface1.serverPortBox.Text = GlobalVars.UserConfiguration.ReadSetting("RobloxPort");
launcherFormStylishInterface1.discordRichPresenceBox.IsChecked = GlobalVars.UserConfiguration.ReadSettingBool("DiscordRichPresence");
launcherFormStylishInterface1.uPnPBox.IsChecked = GlobalVars.UserConfiguration.ReadSettingBool("UPnP");
launcherFormStylishInterface1.NotifBox.IsChecked = GlobalVars.UserConfiguration.ReadSettingBool("ShowServerNotifications");
launcherFormStylishInterface1.browserNameBox.Text = GlobalVars.UserConfiguration.ReadSetting("ServerBrowserServerName");
launcherFormStylishInterface1.browserAddressBox.Text = GlobalVars.UserConfiguration.ReadSetting("ServerBrowserServerAddress");
switch (GlobalVars.UserConfiguration.LauncherStyle)
switch ((Settings.Style)GlobalVars.UserConfiguration.ReadSettingInt("LauncherStyle"))
{
case Settings.Style.Compact:
launcherFormStylishInterface1.styleBox.SelectedIndex = 1;
@ -146,12 +144,11 @@ namespace NovetusLauncher
public void WriteConfigValues(bool ShowBox = false)
{
FileManagement.Config(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigName, true);
ReadClientValues();
if (ShowBox)
{
MessageBox.Show("Config Saved!", "Novetus - Config Saved", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
//ReadClientValues();
//if (ShowBox)
//{
//MessageBox.Show("Config Saved!", "Novetus - Config Saved", MessageBoxButtons.OK, MessageBoxIcon.Information);
//}
}
public void ResetConfigValues(bool ShowBox = false)
@ -174,7 +171,7 @@ namespace NovetusLauncher
{
foreach (object o in launcherFormStylishInterface1.clientListBox.Items)
{
if ((o is ClientListItem) && (o as ClientListItem).ClientName.Contains(GlobalVars.UserConfiguration.SelectedClient))
if ((o is ClientListItem) && (o as ClientListItem).ClientName.Contains(GlobalVars.UserConfiguration.ReadSetting("SelectedClient")))
{
launcherFormStylishInterface1.clientListBox.SelectedItem = o;
break;
@ -199,7 +196,7 @@ namespace NovetusLauncher
launcherFormStylishInterface1.clientWarningBox.Text = "No warnings provided.";
}
launcherFormStylishInterface1.clientDescBox.Text = GlobalVars.UserConfiguration.SelectedClient + ": " + GlobalVars.SelectedClientInfo.Description;
launcherFormStylishInterface1.clientDescBox.Text = GlobalVars.UserConfiguration.ReadSetting("SelectedClient") + ": " + GlobalVars.SelectedClientInfo.Description;
}
#endregion
}

View File

@ -76,7 +76,7 @@ namespace NovetusLauncher
foreach (object o in clientListBox.Items)
{
if ((o is ClientListItem) && (o as ClientListItem).ClientName.Contains(GlobalVars.UserConfiguration.SelectedClient))
if ((o is ClientListItem) && (o as ClientListItem).ClientName.Contains(GlobalVars.UserConfiguration.ReadSetting("SelectedClient")))
{
clientListBox.SelectedItem = o;
break;
@ -139,8 +139,8 @@ namespace NovetusLauncher
LoadMapDesc();
FormParent.Text = "Novetus " + GlobalVars.ProgramInformation.Version + " [CLIENT: " +
GlobalVars.UserConfiguration.SelectedClient + " | MAP: " +
GlobalVars.UserConfiguration.Map + "]";
GlobalVars.UserConfiguration.ReadSetting("SelectedClient") + " | MAP: " +
GlobalVars.UserConfiguration.ReadSetting("Map") + "]";
}
private void clientListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
@ -166,14 +166,14 @@ namespace NovetusLauncher
if (clientListBox.SelectedItem == null)
return;
string ourselectedclient = GlobalVars.UserConfiguration.SelectedClient;
string ourselectedclient = GlobalVars.UserConfiguration.ReadSetting("SelectedClient");
ClientListItem cli = (ClientListItem)clientListBox.SelectedItem ?? null;
GlobalVars.UserConfiguration.SelectedClient = (cli != null) ? cli.ToString() : "";
GlobalVars.UserConfiguration.SaveSetting("SelectedClient", (cli != null) ? cli.ToString() : "");
if (!string.IsNullOrWhiteSpace(ourselectedclient))
{
if (!ourselectedclient.Equals(GlobalVars.UserConfiguration.SelectedClient))
if (!ourselectedclient.Equals(GlobalVars.UserConfiguration.ReadSetting("SelectedClient")))
{
FormParent.ReadClientValues(true);
}
@ -188,8 +188,8 @@ namespace NovetusLauncher
}
FormParent.Text = "Novetus " + GlobalVars.ProgramInformation.Version + " [CLIENT: " +
GlobalVars.UserConfiguration.SelectedClient + " | MAP: " +
GlobalVars.UserConfiguration.Map + "]";
GlobalVars.UserConfiguration.ReadSetting("SelectedClient") + " | MAP: " +
GlobalVars.UserConfiguration.ReadSetting("Map") + "]";
ClientManagement.UpdateRichPresence(ClientManagement.GetStateForType(GlobalVars.GameOpened));
@ -250,7 +250,7 @@ namespace NovetusLauncher
private void regenerateIDButton_Click(object sender, RoutedEventArgs e)
{
NovetusFuncs.GeneratePlayerID();
userIDBox.Text = Convert.ToString(GlobalVars.UserConfiguration.UserID);
userIDBox.Text = GlobalVars.UserConfiguration.ReadSetting("UserID");
}
private void addMapButton_Click(object sender, RoutedEventArgs e)
@ -292,8 +292,8 @@ namespace NovetusLauncher
if (!IsLoaded)
return;
GlobalVars.UserConfiguration.PlayerName = userNameBox.Text;
int autoNameID = launcherForm.GetSpecialNameID(GlobalVars.UserConfiguration.PlayerName);
GlobalVars.UserConfiguration.SaveSetting("PlayerName", userNameBox.Text);
int autoNameID = launcherForm.GetSpecialNameID(GlobalVars.UserConfiguration.ReadSetting("PlayerName"));
if (LocalVars.launcherInitState == false && autoNameID > 0)
{
userIDBox.Text = autoNameID.ToString();
@ -310,16 +310,16 @@ namespace NovetusLauncher
{
if (userIDBox.Text.Equals(""))
{
GlobalVars.UserConfiguration.UserID = 0;
GlobalVars.UserConfiguration.SaveSettingInt("UserID", 0);
}
else
{
GlobalVars.UserConfiguration.UserID = Convert.ToInt32(userIDBox.Text);
GlobalVars.UserConfiguration.SaveSettingInt("UserID", Convert.ToInt32(userIDBox.Text));
}
}
else
{
GlobalVars.UserConfiguration.UserID = 0;
GlobalVars.UserConfiguration.SaveSettingInt("UserID", 0);
}
}
@ -334,70 +334,70 @@ namespace NovetusLauncher
{
if (!IsLoaded)
return;
GlobalVars.UserConfiguration.RobloxPort = Convert.ToInt32(serverPortBox.Text);
GlobalVars.UserConfiguration.SaveSettingInt("RobloxPort", Convert.ToInt32(serverPortBox.Text));
}
private void maxPlayersBox_TextChanged(object sender, TextChangedEventArgs e)
{
if (!IsLoaded)
return;
GlobalVars.UserConfiguration.PlayerLimit = Convert.ToInt32(maxPlayersBox.Text);
GlobalVars.UserConfiguration.SaveSettingInt("PlayerLimit", Convert.ToInt32(maxPlayersBox.Text));
}
private void uPnPBox_Checked(object sender, RoutedEventArgs e)
{
if (!IsLoaded)
return;
GlobalVars.UserConfiguration.UPnP = (bool)uPnPBox.IsChecked;
GlobalVars.UserConfiguration.SaveSettingBool("UPnP", (bool)uPnPBox.IsChecked);
}
private void uPnPBox_Unchecked(object sender, RoutedEventArgs e)
{
if (!IsLoaded)
return;
GlobalVars.UserConfiguration.UPnP = (bool)uPnPBox.IsChecked;
GlobalVars.UserConfiguration.SaveSettingBool("UPnP", (bool)uPnPBox.IsChecked);
}
private void NotifBox_Checked(object sender, RoutedEventArgs e)
{
if (!IsLoaded)
return;
GlobalVars.UserConfiguration.ShowServerNotifications = (bool)NotifBox.IsChecked;
GlobalVars.UserConfiguration.SaveSettingBool("ShowServerNotifications", (bool)NotifBox.IsChecked);
}
private void NotifBox_Unchecked(object sender, RoutedEventArgs e)
{
if (!IsLoaded)
return;
GlobalVars.UserConfiguration.ShowServerNotifications = (bool)NotifBox.IsChecked;
GlobalVars.UserConfiguration.SaveSettingBool("ShowServerNotifications", (bool)NotifBox.IsChecked);
}
private void browserNameBox_TextChanged(object sender, TextChangedEventArgs e)
{
if (!IsLoaded)
return;
GlobalVars.UserConfiguration.ServerBrowserServerName = browserNameBox.Text;
GlobalVars.UserConfiguration.SaveSetting("ServerBrowserServerName", browserNameBox.Text);
}
private void browserAddressBox_TextChanged(object sender, TextChangedEventArgs e)
{
if (!IsLoaded)
return;
GlobalVars.UserConfiguration.ServerBrowserServerAddress = browserAddressBox.Text;
GlobalVars.UserConfiguration.SaveSetting("ServerBrowserServerAddress", browserAddressBox.Text);
}
private void discordRichPresenceBox_Checked(object sender, RoutedEventArgs e)
{
if (!IsLoaded)
return;
GlobalVars.UserConfiguration.DiscordRichPresence = (bool)discordRichPresenceBox.IsChecked;
GlobalVars.UserConfiguration.SaveSettingBool("DiscordRichPresence", (bool)discordRichPresenceBox.IsChecked);
}
private void discordRichPresenceBox_Unchecked(object sender, RoutedEventArgs e)
{
if (!IsLoaded)
return;
GlobalVars.UserConfiguration.DiscordRichPresence = (bool)discordRichPresenceBox.IsChecked;
GlobalVars.UserConfiguration.SaveSettingBool("DiscordRichPresence", (bool)discordRichPresenceBox.IsChecked);
}
private void minimizeOnLaunchBox_Checked(object sender, RoutedEventArgs e)
@ -482,11 +482,11 @@ namespace NovetusLauncher
switch (styleBox.SelectedIndex)
{
case 0:
GlobalVars.UserConfiguration.LauncherStyle = Settings.Style.Extended;
GlobalVars.UserConfiguration.SaveSettingInt("LauncherStyle", (int)Settings.Style.Extended);
launcherForm.RestartApp();
break;
case 1:
GlobalVars.UserConfiguration.LauncherStyle = Settings.Style.Compact;
GlobalVars.UserConfiguration.SaveSettingInt("LauncherStyle", (int)Settings.Style.Compact);
launcherForm.RestartApp();
break;
default:

View File

@ -85,22 +85,7 @@ namespace NovetusLauncher
return;
}
string CFGName = GlobalPaths.CMDConfigName;
if (ConsoleArgs["configname"] != null)
{
CFGName = ConsoleArgs["configname"];
}
if (ConsoleArgs["confignooverride"] == null)
{
cmdConfig = new FileFormat.Config(CFGName);
GlobalVars.UserConfiguration = cmdConfig;
}
else
{
cmdConfig = GlobalVars.UserConfiguration;
}
cmdConfig = GlobalVars.UserConfiguration;
//disableCommands = true;
bool no3d = false;
@ -570,14 +555,6 @@ namespace NovetusLauncher
{
CommandLineArguments.Arguments ConsoleArgs = new CommandLineArguments.Arguments(argList);
if (ConsoleArgs["confignodelete"] == null || ConsoleArgs["confignooverride"] == null)
{
if (File.Exists(cmdConfig.FullPath))
{
Util.FixedFileDelete(cmdConfig.FullPath);
}
}
ConsoleForm.CloseEvent(e);
}
}